]> git.ipfire.org Git - thirdparty/grsecurity-scrape.git/blob - test/grsecurity-3.0-3.12.6-201312221037.patch
Auto commit, 1 new patch{es}.
[thirdparty/grsecurity-scrape.git] / test / grsecurity-3.0-3.12.6-201312221037.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 2b23383..a66cff0 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..9406b3d 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 @@ -2097,6 +2097,7 @@ config XIP_PHYS_ADDR
845 config KEXEC
846 bool "Kexec system call (EXPERIMENTAL)"
847 depends on (!SMP || PM_SLEEP_SMP)
848 + depends on !GRKERNSEC_KMEM
849 help
850 kexec is a system call that implements the ability to shutdown your
851 current kernel, and to start another kernel. It is like a reboot
852 diff --git a/arch/arm/include/asm/atomic.h b/arch/arm/include/asm/atomic.h
853 index da1c77d..2ee6056 100644
854 --- a/arch/arm/include/asm/atomic.h
855 +++ b/arch/arm/include/asm/atomic.h
856 @@ -17,17 +17,35 @@
857 #include <asm/barrier.h>
858 #include <asm/cmpxchg.h>
859
860 +#ifdef CONFIG_GENERIC_ATOMIC64
861 +#include <asm-generic/atomic64.h>
862 +#endif
863 +
864 #define ATOMIC_INIT(i) { (i) }
865
866 #ifdef __KERNEL__
867
868 +#define _ASM_EXTABLE(from, to) \
869 +" .pushsection __ex_table,\"a\"\n"\
870 +" .align 3\n" \
871 +" .long " #from ", " #to"\n" \
872 +" .popsection"
873 +
874 /*
875 * On ARM, ordinary assignment (str instruction) doesn't clear the local
876 * strex/ldrex monitor on some implementations. The reason we can use it for
877 * atomic_set() is the clrex or dummy strex done on every exception return.
878 */
879 #define atomic_read(v) (*(volatile int *)&(v)->counter)
880 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
881 +{
882 + return v->counter;
883 +}
884 #define atomic_set(v,i) (((v)->counter) = (i))
885 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
886 +{
887 + v->counter = i;
888 +}
889
890 #if __LINUX_ARM_ARCH__ >= 6
891
892 @@ -42,6 +60,35 @@ static inline void atomic_add(int i, atomic_t *v)
893 int result;
894
895 __asm__ __volatile__("@ atomic_add\n"
896 +"1: ldrex %1, [%3]\n"
897 +" adds %0, %1, %4\n"
898 +
899 +#ifdef CONFIG_PAX_REFCOUNT
900 +" bvc 3f\n"
901 +"2: bkpt 0xf103\n"
902 +"3:\n"
903 +#endif
904 +
905 +" strex %1, %0, [%3]\n"
906 +" teq %1, #0\n"
907 +" bne 1b"
908 +
909 +#ifdef CONFIG_PAX_REFCOUNT
910 +"\n4:\n"
911 + _ASM_EXTABLE(2b, 4b)
912 +#endif
913 +
914 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
915 + : "r" (&v->counter), "Ir" (i)
916 + : "cc");
917 +}
918 +
919 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
920 +{
921 + unsigned long tmp;
922 + int result;
923 +
924 + __asm__ __volatile__("@ atomic_add_unchecked\n"
925 "1: ldrex %0, [%3]\n"
926 " add %0, %0, %4\n"
927 " strex %1, %0, [%3]\n"
928 @@ -60,6 +107,42 @@ static inline int atomic_add_return(int i, atomic_t *v)
929 smp_mb();
930
931 __asm__ __volatile__("@ atomic_add_return\n"
932 +"1: ldrex %1, [%3]\n"
933 +" adds %0, %1, %4\n"
934 +
935 +#ifdef CONFIG_PAX_REFCOUNT
936 +" bvc 3f\n"
937 +" mov %0, %1\n"
938 +"2: bkpt 0xf103\n"
939 +"3:\n"
940 +#endif
941 +
942 +" strex %1, %0, [%3]\n"
943 +" teq %1, #0\n"
944 +" bne 1b"
945 +
946 +#ifdef CONFIG_PAX_REFCOUNT
947 +"\n4:\n"
948 + _ASM_EXTABLE(2b, 4b)
949 +#endif
950 +
951 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
952 + : "r" (&v->counter), "Ir" (i)
953 + : "cc");
954 +
955 + smp_mb();
956 +
957 + return result;
958 +}
959 +
960 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
961 +{
962 + unsigned long tmp;
963 + int result;
964 +
965 + smp_mb();
966 +
967 + __asm__ __volatile__("@ atomic_add_return_unchecked\n"
968 "1: ldrex %0, [%3]\n"
969 " add %0, %0, %4\n"
970 " strex %1, %0, [%3]\n"
971 @@ -80,6 +163,35 @@ static inline void atomic_sub(int i, atomic_t *v)
972 int result;
973
974 __asm__ __volatile__("@ atomic_sub\n"
975 +"1: ldrex %1, [%3]\n"
976 +" subs %0, %1, %4\n"
977 +
978 +#ifdef CONFIG_PAX_REFCOUNT
979 +" bvc 3f\n"
980 +"2: bkpt 0xf103\n"
981 +"3:\n"
982 +#endif
983 +
984 +" strex %1, %0, [%3]\n"
985 +" teq %1, #0\n"
986 +" bne 1b"
987 +
988 +#ifdef CONFIG_PAX_REFCOUNT
989 +"\n4:\n"
990 + _ASM_EXTABLE(2b, 4b)
991 +#endif
992 +
993 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
994 + : "r" (&v->counter), "Ir" (i)
995 + : "cc");
996 +}
997 +
998 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
999 +{
1000 + unsigned long tmp;
1001 + int result;
1002 +
1003 + __asm__ __volatile__("@ atomic_sub_unchecked\n"
1004 "1: ldrex %0, [%3]\n"
1005 " sub %0, %0, %4\n"
1006 " strex %1, %0, [%3]\n"
1007 @@ -98,11 +210,25 @@ static inline int atomic_sub_return(int i, atomic_t *v)
1008 smp_mb();
1009
1010 __asm__ __volatile__("@ atomic_sub_return\n"
1011 -"1: ldrex %0, [%3]\n"
1012 -" sub %0, %0, %4\n"
1013 +"1: ldrex %1, [%3]\n"
1014 +" subs %0, %1, %4\n"
1015 +
1016 +#ifdef CONFIG_PAX_REFCOUNT
1017 +" bvc 3f\n"
1018 +" mov %0, %1\n"
1019 +"2: bkpt 0xf103\n"
1020 +"3:\n"
1021 +#endif
1022 +
1023 " strex %1, %0, [%3]\n"
1024 " teq %1, #0\n"
1025 " bne 1b"
1026 +
1027 +#ifdef CONFIG_PAX_REFCOUNT
1028 +"\n4:\n"
1029 + _ASM_EXTABLE(2b, 4b)
1030 +#endif
1031 +
1032 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1033 : "r" (&v->counter), "Ir" (i)
1034 : "cc");
1035 @@ -134,6 +260,28 @@ static inline int atomic_cmpxchg(atomic_t *ptr, int old, int new)
1036 return oldval;
1037 }
1038
1039 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *ptr, int old, int new)
1040 +{
1041 + unsigned long oldval, res;
1042 +
1043 + smp_mb();
1044 +
1045 + do {
1046 + __asm__ __volatile__("@ atomic_cmpxchg_unchecked\n"
1047 + "ldrex %1, [%3]\n"
1048 + "mov %0, #0\n"
1049 + "teq %1, %4\n"
1050 + "strexeq %0, %5, [%3]\n"
1051 + : "=&r" (res), "=&r" (oldval), "+Qo" (ptr->counter)
1052 + : "r" (&ptr->counter), "Ir" (old), "r" (new)
1053 + : "cc");
1054 + } while (res);
1055 +
1056 + smp_mb();
1057 +
1058 + return oldval;
1059 +}
1060 +
1061 static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1062 {
1063 unsigned long tmp, tmp2;
1064 @@ -167,7 +315,17 @@ static inline int atomic_add_return(int i, atomic_t *v)
1065
1066 return val;
1067 }
1068 +
1069 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
1070 +{
1071 + return atomic_add_return(i, v);
1072 +}
1073 +
1074 #define atomic_add(i, v) (void) atomic_add_return(i, v)
1075 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
1076 +{
1077 + (void) atomic_add_return(i, v);
1078 +}
1079
1080 static inline int atomic_sub_return(int i, atomic_t *v)
1081 {
1082 @@ -182,6 +340,10 @@ static inline int atomic_sub_return(int i, atomic_t *v)
1083 return val;
1084 }
1085 #define atomic_sub(i, v) (void) atomic_sub_return(i, v)
1086 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
1087 +{
1088 + (void) atomic_sub_return(i, v);
1089 +}
1090
1091 static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
1092 {
1093 @@ -197,6 +359,11 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
1094 return ret;
1095 }
1096
1097 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
1098 +{
1099 + return atomic_cmpxchg(v, old, new);
1100 +}
1101 +
1102 static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1103 {
1104 unsigned long flags;
1105 @@ -209,6 +376,10 @@ static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1106 #endif /* __LINUX_ARM_ARCH__ */
1107
1108 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
1109 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
1110 +{
1111 + return xchg(&v->counter, new);
1112 +}
1113
1114 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
1115 {
1116 @@ -221,11 +392,27 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
1117 }
1118
1119 #define atomic_inc(v) atomic_add(1, v)
1120 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
1121 +{
1122 + atomic_add_unchecked(1, v);
1123 +}
1124 #define atomic_dec(v) atomic_sub(1, v)
1125 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
1126 +{
1127 + atomic_sub_unchecked(1, v);
1128 +}
1129
1130 #define atomic_inc_and_test(v) (atomic_add_return(1, v) == 0)
1131 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
1132 +{
1133 + return atomic_add_return_unchecked(1, v) == 0;
1134 +}
1135 #define atomic_dec_and_test(v) (atomic_sub_return(1, v) == 0)
1136 #define atomic_inc_return(v) (atomic_add_return(1, v))
1137 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
1138 +{
1139 + return atomic_add_return_unchecked(1, v);
1140 +}
1141 #define atomic_dec_return(v) (atomic_sub_return(1, v))
1142 #define atomic_sub_and_test(i, v) (atomic_sub_return(i, v) == 0)
1143
1144 @@ -241,6 +428,14 @@ typedef struct {
1145 u64 __aligned(8) counter;
1146 } atomic64_t;
1147
1148 +#ifdef CONFIG_PAX_REFCOUNT
1149 +typedef struct {
1150 + u64 __aligned(8) counter;
1151 +} atomic64_unchecked_t;
1152 +#else
1153 +typedef atomic64_t atomic64_unchecked_t;
1154 +#endif
1155 +
1156 #define ATOMIC64_INIT(i) { (i) }
1157
1158 #ifdef CONFIG_ARM_LPAE
1159 @@ -257,6 +452,19 @@ static inline u64 atomic64_read(const atomic64_t *v)
1160 return result;
1161 }
1162
1163 +static inline u64 atomic64_read_unchecked(const atomic64_unchecked_t *v)
1164 +{
1165 + u64 result;
1166 +
1167 + __asm__ __volatile__("@ atomic64_read_unchecked\n"
1168 +" ldrd %0, %H0, [%1]"
1169 + : "=&r" (result)
1170 + : "r" (&v->counter), "Qo" (v->counter)
1171 + );
1172 +
1173 + return result;
1174 +}
1175 +
1176 static inline void atomic64_set(atomic64_t *v, u64 i)
1177 {
1178 __asm__ __volatile__("@ atomic64_set\n"
1179 @@ -265,6 +473,15 @@ static inline void atomic64_set(atomic64_t *v, u64 i)
1180 : "r" (&v->counter), "r" (i)
1181 );
1182 }
1183 +
1184 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, u64 i)
1185 +{
1186 + __asm__ __volatile__("@ atomic64_set_unchecked\n"
1187 +" strd %2, %H2, [%1]"
1188 + : "=Qo" (v->counter)
1189 + : "r" (&v->counter), "r" (i)
1190 + );
1191 +}
1192 #else
1193 static inline u64 atomic64_read(const atomic64_t *v)
1194 {
1195 @@ -279,6 +496,19 @@ static inline u64 atomic64_read(const atomic64_t *v)
1196 return result;
1197 }
1198
1199 +static inline u64 atomic64_read_unchecked(atomic64_unchecked_t *v)
1200 +{
1201 + u64 result;
1202 +
1203 + __asm__ __volatile__("@ atomic64_read_unchecked\n"
1204 +" ldrexd %0, %H0, [%1]"
1205 + : "=&r" (result)
1206 + : "r" (&v->counter), "Qo" (v->counter)
1207 + );
1208 +
1209 + return result;
1210 +}
1211 +
1212 static inline void atomic64_set(atomic64_t *v, u64 i)
1213 {
1214 u64 tmp;
1215 @@ -292,6 +522,21 @@ static inline void atomic64_set(atomic64_t *v, u64 i)
1216 : "r" (&v->counter), "r" (i)
1217 : "cc");
1218 }
1219 +
1220 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, u64 i)
1221 +{
1222 + u64 tmp;
1223 +
1224 + __asm__ __volatile__("@ atomic64_set_unchecked\n"
1225 +"1: ldrexd %0, %H0, [%2]\n"
1226 +" strexd %0, %3, %H3, [%2]\n"
1227 +" teq %0, #0\n"
1228 +" bne 1b"
1229 + : "=&r" (tmp), "=Qo" (v->counter)
1230 + : "r" (&v->counter), "r" (i)
1231 + : "cc");
1232 +}
1233 +
1234 #endif
1235
1236 static inline void atomic64_add(u64 i, atomic64_t *v)
1237 @@ -302,6 +547,36 @@ static inline void atomic64_add(u64 i, atomic64_t *v)
1238 __asm__ __volatile__("@ atomic64_add\n"
1239 "1: ldrexd %0, %H0, [%3]\n"
1240 " adds %0, %0, %4\n"
1241 +" adcs %H0, %H0, %H4\n"
1242 +
1243 +#ifdef CONFIG_PAX_REFCOUNT
1244 +" bvc 3f\n"
1245 +"2: bkpt 0xf103\n"
1246 +"3:\n"
1247 +#endif
1248 +
1249 +" strexd %1, %0, %H0, [%3]\n"
1250 +" teq %1, #0\n"
1251 +" bne 1b"
1252 +
1253 +#ifdef CONFIG_PAX_REFCOUNT
1254 +"\n4:\n"
1255 + _ASM_EXTABLE(2b, 4b)
1256 +#endif
1257 +
1258 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1259 + : "r" (&v->counter), "r" (i)
1260 + : "cc");
1261 +}
1262 +
1263 +static inline void atomic64_add_unchecked(u64 i, atomic64_unchecked_t *v)
1264 +{
1265 + u64 result;
1266 + unsigned long tmp;
1267 +
1268 + __asm__ __volatile__("@ atomic64_add_unchecked\n"
1269 +"1: ldrexd %0, %H0, [%3]\n"
1270 +" adds %0, %0, %4\n"
1271 " adc %H0, %H0, %H4\n"
1272 " strexd %1, %0, %H0, [%3]\n"
1273 " teq %1, #0\n"
1274 @@ -313,12 +588,49 @@ static inline void atomic64_add(u64 i, atomic64_t *v)
1275
1276 static inline u64 atomic64_add_return(u64 i, atomic64_t *v)
1277 {
1278 - u64 result;
1279 - unsigned long tmp;
1280 + u64 result, tmp;
1281
1282 smp_mb();
1283
1284 __asm__ __volatile__("@ atomic64_add_return\n"
1285 +"1: ldrexd %1, %H1, [%3]\n"
1286 +" adds %0, %1, %4\n"
1287 +" adcs %H0, %H1, %H4\n"
1288 +
1289 +#ifdef CONFIG_PAX_REFCOUNT
1290 +" bvc 3f\n"
1291 +" mov %0, %1\n"
1292 +" mov %H0, %H1\n"
1293 +"2: bkpt 0xf103\n"
1294 +"3:\n"
1295 +#endif
1296 +
1297 +" strexd %1, %0, %H0, [%3]\n"
1298 +" teq %1, #0\n"
1299 +" bne 1b"
1300 +
1301 +#ifdef CONFIG_PAX_REFCOUNT
1302 +"\n4:\n"
1303 + _ASM_EXTABLE(2b, 4b)
1304 +#endif
1305 +
1306 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1307 + : "r" (&v->counter), "r" (i)
1308 + : "cc");
1309 +
1310 + smp_mb();
1311 +
1312 + return result;
1313 +}
1314 +
1315 +static inline u64 atomic64_add_return_unchecked(u64 i, atomic64_unchecked_t *v)
1316 +{
1317 + u64 result;
1318 + unsigned long tmp;
1319 +
1320 + smp_mb();
1321 +
1322 + __asm__ __volatile__("@ atomic64_add_return_unchecked\n"
1323 "1: ldrexd %0, %H0, [%3]\n"
1324 " adds %0, %0, %4\n"
1325 " adc %H0, %H0, %H4\n"
1326 @@ -342,6 +654,36 @@ static inline void atomic64_sub(u64 i, atomic64_t *v)
1327 __asm__ __volatile__("@ atomic64_sub\n"
1328 "1: ldrexd %0, %H0, [%3]\n"
1329 " subs %0, %0, %4\n"
1330 +" sbcs %H0, %H0, %H4\n"
1331 +
1332 +#ifdef CONFIG_PAX_REFCOUNT
1333 +" bvc 3f\n"
1334 +"2: bkpt 0xf103\n"
1335 +"3:\n"
1336 +#endif
1337 +
1338 +" strexd %1, %0, %H0, [%3]\n"
1339 +" teq %1, #0\n"
1340 +" bne 1b"
1341 +
1342 +#ifdef CONFIG_PAX_REFCOUNT
1343 +"\n4:\n"
1344 + _ASM_EXTABLE(2b, 4b)
1345 +#endif
1346 +
1347 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1348 + : "r" (&v->counter), "r" (i)
1349 + : "cc");
1350 +}
1351 +
1352 +static inline void atomic64_sub_unchecked(u64 i, atomic64_unchecked_t *v)
1353 +{
1354 + u64 result;
1355 + unsigned long tmp;
1356 +
1357 + __asm__ __volatile__("@ atomic64_sub_unchecked\n"
1358 +"1: ldrexd %0, %H0, [%3]\n"
1359 +" subs %0, %0, %4\n"
1360 " sbc %H0, %H0, %H4\n"
1361 " strexd %1, %0, %H0, [%3]\n"
1362 " teq %1, #0\n"
1363 @@ -353,18 +695,32 @@ static inline void atomic64_sub(u64 i, atomic64_t *v)
1364
1365 static inline u64 atomic64_sub_return(u64 i, atomic64_t *v)
1366 {
1367 - u64 result;
1368 - unsigned long tmp;
1369 + u64 result, tmp;
1370
1371 smp_mb();
1372
1373 __asm__ __volatile__("@ atomic64_sub_return\n"
1374 -"1: ldrexd %0, %H0, [%3]\n"
1375 -" subs %0, %0, %4\n"
1376 -" sbc %H0, %H0, %H4\n"
1377 +"1: ldrexd %1, %H1, [%3]\n"
1378 +" subs %0, %1, %4\n"
1379 +" sbcs %H0, %H1, %H4\n"
1380 +
1381 +#ifdef CONFIG_PAX_REFCOUNT
1382 +" bvc 3f\n"
1383 +" mov %0, %1\n"
1384 +" mov %H0, %H1\n"
1385 +"2: bkpt 0xf103\n"
1386 +"3:\n"
1387 +#endif
1388 +
1389 " strexd %1, %0, %H0, [%3]\n"
1390 " teq %1, #0\n"
1391 " bne 1b"
1392 +
1393 +#ifdef CONFIG_PAX_REFCOUNT
1394 +"\n4:\n"
1395 + _ASM_EXTABLE(2b, 4b)
1396 +#endif
1397 +
1398 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1399 : "r" (&v->counter), "r" (i)
1400 : "cc");
1401 @@ -398,6 +754,30 @@ static inline u64 atomic64_cmpxchg(atomic64_t *ptr, u64 old, u64 new)
1402 return oldval;
1403 }
1404
1405 +static inline u64 atomic64_cmpxchg_unchecked(atomic64_unchecked_t *ptr, u64 old, u64 new)
1406 +{
1407 + u64 oldval;
1408 + unsigned long res;
1409 +
1410 + smp_mb();
1411 +
1412 + do {
1413 + __asm__ __volatile__("@ atomic64_cmpxchg_unchecked\n"
1414 + "ldrexd %1, %H1, [%3]\n"
1415 + "mov %0, #0\n"
1416 + "teq %1, %4\n"
1417 + "teqeq %H1, %H4\n"
1418 + "strexdeq %0, %5, %H5, [%3]"
1419 + : "=&r" (res), "=&r" (oldval), "+Qo" (ptr->counter)
1420 + : "r" (&ptr->counter), "r" (old), "r" (new)
1421 + : "cc");
1422 + } while (res);
1423 +
1424 + smp_mb();
1425 +
1426 + return oldval;
1427 +}
1428 +
1429 static inline u64 atomic64_xchg(atomic64_t *ptr, u64 new)
1430 {
1431 u64 result;
1432 @@ -421,21 +801,34 @@ static inline u64 atomic64_xchg(atomic64_t *ptr, u64 new)
1433
1434 static inline u64 atomic64_dec_if_positive(atomic64_t *v)
1435 {
1436 - u64 result;
1437 - unsigned long tmp;
1438 + u64 result, tmp;
1439
1440 smp_mb();
1441
1442 __asm__ __volatile__("@ atomic64_dec_if_positive\n"
1443 -"1: ldrexd %0, %H0, [%3]\n"
1444 -" subs %0, %0, #1\n"
1445 -" sbc %H0, %H0, #0\n"
1446 +"1: ldrexd %1, %H1, [%3]\n"
1447 +" subs %0, %1, #1\n"
1448 +" sbcs %H0, %H1, #0\n"
1449 +
1450 +#ifdef CONFIG_PAX_REFCOUNT
1451 +" bvc 3f\n"
1452 +" mov %0, %1\n"
1453 +" mov %H0, %H1\n"
1454 +"2: bkpt 0xf103\n"
1455 +"3:\n"
1456 +#endif
1457 +
1458 " teq %H0, #0\n"
1459 -" bmi 2f\n"
1460 +" bmi 4f\n"
1461 " strexd %1, %0, %H0, [%3]\n"
1462 " teq %1, #0\n"
1463 " bne 1b\n"
1464 -"2:"
1465 +"4:\n"
1466 +
1467 +#ifdef CONFIG_PAX_REFCOUNT
1468 + _ASM_EXTABLE(2b, 4b)
1469 +#endif
1470 +
1471 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1472 : "r" (&v->counter)
1473 : "cc");
1474 @@ -458,13 +851,25 @@ static inline int atomic64_add_unless(atomic64_t *v, u64 a, u64 u)
1475 " teq %0, %5\n"
1476 " teqeq %H0, %H5\n"
1477 " moveq %1, #0\n"
1478 -" beq 2f\n"
1479 +" beq 4f\n"
1480 " adds %0, %0, %6\n"
1481 -" adc %H0, %H0, %H6\n"
1482 +" adcs %H0, %H0, %H6\n"
1483 +
1484 +#ifdef CONFIG_PAX_REFCOUNT
1485 +" bvc 3f\n"
1486 +"2: bkpt 0xf103\n"
1487 +"3:\n"
1488 +#endif
1489 +
1490 " strexd %2, %0, %H0, [%4]\n"
1491 " teq %2, #0\n"
1492 " bne 1b\n"
1493 -"2:"
1494 +"4:\n"
1495 +
1496 +#ifdef CONFIG_PAX_REFCOUNT
1497 + _ASM_EXTABLE(2b, 4b)
1498 +#endif
1499 +
1500 : "=&r" (val), "+r" (ret), "=&r" (tmp), "+Qo" (v->counter)
1501 : "r" (&v->counter), "r" (u), "r" (a)
1502 : "cc");
1503 @@ -477,10 +882,13 @@ static inline int atomic64_add_unless(atomic64_t *v, u64 a, u64 u)
1504
1505 #define atomic64_add_negative(a, v) (atomic64_add_return((a), (v)) < 0)
1506 #define atomic64_inc(v) atomic64_add(1LL, (v))
1507 +#define atomic64_inc_unchecked(v) atomic64_add_unchecked(1LL, (v))
1508 #define atomic64_inc_return(v) atomic64_add_return(1LL, (v))
1509 +#define atomic64_inc_return_unchecked(v) atomic64_add_return_unchecked(1LL, (v))
1510 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
1511 #define atomic64_sub_and_test(a, v) (atomic64_sub_return((a), (v)) == 0)
1512 #define atomic64_dec(v) atomic64_sub(1LL, (v))
1513 +#define atomic64_dec_unchecked(v) atomic64_sub_unchecked(1LL, (v))
1514 #define atomic64_dec_return(v) atomic64_sub_return(1LL, (v))
1515 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
1516 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
1517 diff --git a/arch/arm/include/asm/cache.h b/arch/arm/include/asm/cache.h
1518 index 75fe66b..ba3dee4 100644
1519 --- a/arch/arm/include/asm/cache.h
1520 +++ b/arch/arm/include/asm/cache.h
1521 @@ -4,8 +4,10 @@
1522 #ifndef __ASMARM_CACHE_H
1523 #define __ASMARM_CACHE_H
1524
1525 +#include <linux/const.h>
1526 +
1527 #define L1_CACHE_SHIFT CONFIG_ARM_L1_CACHE_SHIFT
1528 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
1529 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
1530
1531 /*
1532 * Memory returned by kmalloc() may be used for DMA, so we must make
1533 @@ -24,5 +26,6 @@
1534 #endif
1535
1536 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
1537 +#define __read_only __attribute__ ((__section__(".data..read_only")))
1538
1539 #endif
1540 diff --git a/arch/arm/include/asm/cacheflush.h b/arch/arm/include/asm/cacheflush.h
1541 index 15f2d5b..43ffa53 100644
1542 --- a/arch/arm/include/asm/cacheflush.h
1543 +++ b/arch/arm/include/asm/cacheflush.h
1544 @@ -116,7 +116,7 @@ struct cpu_cache_fns {
1545 void (*dma_unmap_area)(const void *, size_t, int);
1546
1547 void (*dma_flush_range)(const void *, const void *);
1548 -};
1549 +} __no_const;
1550
1551 /*
1552 * Select the calling method
1553 diff --git a/arch/arm/include/asm/checksum.h b/arch/arm/include/asm/checksum.h
1554 index 6dcc164..b14d917 100644
1555 --- a/arch/arm/include/asm/checksum.h
1556 +++ b/arch/arm/include/asm/checksum.h
1557 @@ -37,7 +37,19 @@ __wsum
1558 csum_partial_copy_nocheck(const void *src, void *dst, int len, __wsum sum);
1559
1560 __wsum
1561 -csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr);
1562 +__csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr);
1563 +
1564 +static inline __wsum
1565 +csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr)
1566 +{
1567 + __wsum ret;
1568 + pax_open_userland();
1569 + ret = __csum_partial_copy_from_user(src, dst, len, sum, err_ptr);
1570 + pax_close_userland();
1571 + return ret;
1572 +}
1573 +
1574 +
1575
1576 /*
1577 * Fold a partial checksum without adding pseudo headers
1578 diff --git a/arch/arm/include/asm/cmpxchg.h b/arch/arm/include/asm/cmpxchg.h
1579 index 4f009c1..466c59b 100644
1580 --- a/arch/arm/include/asm/cmpxchg.h
1581 +++ b/arch/arm/include/asm/cmpxchg.h
1582 @@ -102,6 +102,8 @@ static inline unsigned long __xchg(unsigned long x, volatile void *ptr, int size
1583
1584 #define xchg(ptr,x) \
1585 ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
1586 +#define xchg_unchecked(ptr,x) \
1587 + ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
1588
1589 #include <asm-generic/cmpxchg-local.h>
1590
1591 diff --git a/arch/arm/include/asm/domain.h b/arch/arm/include/asm/domain.h
1592 index 6ddbe44..b5e38b1 100644
1593 --- a/arch/arm/include/asm/domain.h
1594 +++ b/arch/arm/include/asm/domain.h
1595 @@ -48,18 +48,37 @@
1596 * Domain types
1597 */
1598 #define DOMAIN_NOACCESS 0
1599 -#define DOMAIN_CLIENT 1
1600 #ifdef CONFIG_CPU_USE_DOMAINS
1601 +#define DOMAIN_USERCLIENT 1
1602 +#define DOMAIN_KERNELCLIENT 1
1603 #define DOMAIN_MANAGER 3
1604 +#define DOMAIN_VECTORS DOMAIN_USER
1605 #else
1606 +
1607 +#ifdef CONFIG_PAX_KERNEXEC
1608 #define DOMAIN_MANAGER 1
1609 +#define DOMAIN_KERNEXEC 3
1610 +#else
1611 +#define DOMAIN_MANAGER 1
1612 +#endif
1613 +
1614 +#ifdef CONFIG_PAX_MEMORY_UDEREF
1615 +#define DOMAIN_USERCLIENT 0
1616 +#define DOMAIN_UDEREF 1
1617 +#define DOMAIN_VECTORS DOMAIN_KERNEL
1618 +#else
1619 +#define DOMAIN_USERCLIENT 1
1620 +#define DOMAIN_VECTORS DOMAIN_USER
1621 +#endif
1622 +#define DOMAIN_KERNELCLIENT 1
1623 +
1624 #endif
1625
1626 #define domain_val(dom,type) ((type) << (2*(dom)))
1627
1628 #ifndef __ASSEMBLY__
1629
1630 -#ifdef CONFIG_CPU_USE_DOMAINS
1631 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
1632 static inline void set_domain(unsigned val)
1633 {
1634 asm volatile(
1635 @@ -68,15 +87,7 @@ static inline void set_domain(unsigned val)
1636 isb();
1637 }
1638
1639 -#define modify_domain(dom,type) \
1640 - do { \
1641 - struct thread_info *thread = current_thread_info(); \
1642 - unsigned int domain = thread->cpu_domain; \
1643 - domain &= ~domain_val(dom, DOMAIN_MANAGER); \
1644 - thread->cpu_domain = domain | domain_val(dom, type); \
1645 - set_domain(thread->cpu_domain); \
1646 - } while (0)
1647 -
1648 +extern void modify_domain(unsigned int dom, unsigned int type);
1649 #else
1650 static inline void set_domain(unsigned val) { }
1651 static inline void modify_domain(unsigned dom, unsigned type) { }
1652 diff --git a/arch/arm/include/asm/elf.h b/arch/arm/include/asm/elf.h
1653 index f4b46d3..abc9b2b 100644
1654 --- a/arch/arm/include/asm/elf.h
1655 +++ b/arch/arm/include/asm/elf.h
1656 @@ -114,7 +114,14 @@ int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs);
1657 the loader. We need to make sure that it is out of the way of the program
1658 that it will "exec", and that there is sufficient room for the brk. */
1659
1660 -#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
1661 +#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
1662 +
1663 +#ifdef CONFIG_PAX_ASLR
1664 +#define PAX_ELF_ET_DYN_BASE 0x00008000UL
1665 +
1666 +#define PAX_DELTA_MMAP_LEN ((current->personality == PER_LINUX_32BIT) ? 16 : 10)
1667 +#define PAX_DELTA_STACK_LEN ((current->personality == PER_LINUX_32BIT) ? 16 : 10)
1668 +#endif
1669
1670 /* When the program starts, a1 contains a pointer to a function to be
1671 registered with atexit, as per the SVR4 ABI. A value of 0 means we
1672 @@ -124,10 +131,6 @@ int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs);
1673 extern void elf_set_personality(const struct elf32_hdr *);
1674 #define SET_PERSONALITY(ex) elf_set_personality(&(ex))
1675
1676 -struct mm_struct;
1677 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
1678 -#define arch_randomize_brk arch_randomize_brk
1679 -
1680 #ifdef CONFIG_MMU
1681 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
1682 struct linux_binprm;
1683 diff --git a/arch/arm/include/asm/fncpy.h b/arch/arm/include/asm/fncpy.h
1684 index de53547..52b9a28 100644
1685 --- a/arch/arm/include/asm/fncpy.h
1686 +++ b/arch/arm/include/asm/fncpy.h
1687 @@ -81,7 +81,9 @@
1688 BUG_ON((uintptr_t)(dest_buf) & (FNCPY_ALIGN - 1) || \
1689 (__funcp_address & ~(uintptr_t)1 & (FNCPY_ALIGN - 1))); \
1690 \
1691 + pax_open_kernel(); \
1692 memcpy(dest_buf, (void const *)(__funcp_address & ~1), size); \
1693 + pax_close_kernel(); \
1694 flush_icache_range((unsigned long)(dest_buf), \
1695 (unsigned long)(dest_buf) + (size)); \
1696 \
1697 diff --git a/arch/arm/include/asm/futex.h b/arch/arm/include/asm/futex.h
1698 index e42cf59..7b94b8f 100644
1699 --- a/arch/arm/include/asm/futex.h
1700 +++ b/arch/arm/include/asm/futex.h
1701 @@ -50,6 +50,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1702 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
1703 return -EFAULT;
1704
1705 + pax_open_userland();
1706 +
1707 smp_mb();
1708 __asm__ __volatile__("@futex_atomic_cmpxchg_inatomic\n"
1709 "1: ldrex %1, [%4]\n"
1710 @@ -65,6 +67,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1711 : "cc", "memory");
1712 smp_mb();
1713
1714 + pax_close_userland();
1715 +
1716 *uval = val;
1717 return ret;
1718 }
1719 @@ -95,6 +99,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1720 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
1721 return -EFAULT;
1722
1723 + pax_open_userland();
1724 +
1725 __asm__ __volatile__("@futex_atomic_cmpxchg_inatomic\n"
1726 "1: " TUSER(ldr) " %1, [%4]\n"
1727 " teq %1, %2\n"
1728 @@ -105,6 +111,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1729 : "r" (oldval), "r" (newval), "r" (uaddr), "Ir" (-EFAULT)
1730 : "cc", "memory");
1731
1732 + pax_close_userland();
1733 +
1734 *uval = val;
1735 return ret;
1736 }
1737 @@ -127,6 +135,7 @@ futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
1738 return -EFAULT;
1739
1740 pagefault_disable(); /* implies preempt_disable() */
1741 + pax_open_userland();
1742
1743 switch (op) {
1744 case FUTEX_OP_SET:
1745 @@ -148,6 +157,7 @@ futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
1746 ret = -ENOSYS;
1747 }
1748
1749 + pax_close_userland();
1750 pagefault_enable(); /* subsumes preempt_enable() */
1751
1752 if (!ret) {
1753 diff --git a/arch/arm/include/asm/kmap_types.h b/arch/arm/include/asm/kmap_types.h
1754 index 83eb2f7..ed77159 100644
1755 --- a/arch/arm/include/asm/kmap_types.h
1756 +++ b/arch/arm/include/asm/kmap_types.h
1757 @@ -4,6 +4,6 @@
1758 /*
1759 * This is the "bare minimum". AIO seems to require this.
1760 */
1761 -#define KM_TYPE_NR 16
1762 +#define KM_TYPE_NR 17
1763
1764 #endif
1765 diff --git a/arch/arm/include/asm/mach/dma.h b/arch/arm/include/asm/mach/dma.h
1766 index 9e614a1..3302cca 100644
1767 --- a/arch/arm/include/asm/mach/dma.h
1768 +++ b/arch/arm/include/asm/mach/dma.h
1769 @@ -22,7 +22,7 @@ struct dma_ops {
1770 int (*residue)(unsigned int, dma_t *); /* optional */
1771 int (*setspeed)(unsigned int, dma_t *, int); /* optional */
1772 const char *type;
1773 -};
1774 +} __do_const;
1775
1776 struct dma_struct {
1777 void *addr; /* single DMA address */
1778 diff --git a/arch/arm/include/asm/mach/map.h b/arch/arm/include/asm/mach/map.h
1779 index 2fe141f..192dc01 100644
1780 --- a/arch/arm/include/asm/mach/map.h
1781 +++ b/arch/arm/include/asm/mach/map.h
1782 @@ -27,13 +27,16 @@ struct map_desc {
1783 #define MT_MINICLEAN 6
1784 #define MT_LOW_VECTORS 7
1785 #define MT_HIGH_VECTORS 8
1786 -#define MT_MEMORY 9
1787 +#define MT_MEMORY_RWX 9
1788 #define MT_ROM 10
1789 -#define MT_MEMORY_NONCACHED 11
1790 +#define MT_MEMORY_NONCACHED_RX 11
1791 #define MT_MEMORY_DTCM 12
1792 #define MT_MEMORY_ITCM 13
1793 #define MT_MEMORY_SO 14
1794 #define MT_MEMORY_DMA_READY 15
1795 +#define MT_MEMORY_RW 16
1796 +#define MT_MEMORY_RX 17
1797 +#define MT_MEMORY_NONCACHED_RW 18
1798
1799 #ifdef CONFIG_MMU
1800 extern void iotable_init(struct map_desc *, int);
1801 diff --git a/arch/arm/include/asm/outercache.h b/arch/arm/include/asm/outercache.h
1802 index f94784f..9a09a4a 100644
1803 --- a/arch/arm/include/asm/outercache.h
1804 +++ b/arch/arm/include/asm/outercache.h
1805 @@ -35,7 +35,7 @@ struct outer_cache_fns {
1806 #endif
1807 void (*set_debug)(unsigned long);
1808 void (*resume)(void);
1809 -};
1810 +} __no_const;
1811
1812 extern struct outer_cache_fns outer_cache;
1813
1814 diff --git a/arch/arm/include/asm/page.h b/arch/arm/include/asm/page.h
1815 index 4355f0e..c229913 100644
1816 --- a/arch/arm/include/asm/page.h
1817 +++ b/arch/arm/include/asm/page.h
1818 @@ -114,7 +114,7 @@ struct cpu_user_fns {
1819 void (*cpu_clear_user_highpage)(struct page *page, unsigned long vaddr);
1820 void (*cpu_copy_user_highpage)(struct page *to, struct page *from,
1821 unsigned long vaddr, struct vm_area_struct *vma);
1822 -};
1823 +} __no_const;
1824
1825 #ifdef MULTI_USER
1826 extern struct cpu_user_fns cpu_user;
1827 diff --git a/arch/arm/include/asm/pgalloc.h b/arch/arm/include/asm/pgalloc.h
1828 index 943504f..c37a730 100644
1829 --- a/arch/arm/include/asm/pgalloc.h
1830 +++ b/arch/arm/include/asm/pgalloc.h
1831 @@ -17,6 +17,7 @@
1832 #include <asm/processor.h>
1833 #include <asm/cacheflush.h>
1834 #include <asm/tlbflush.h>
1835 +#include <asm/system_info.h>
1836
1837 #define check_pgt_cache() do { } while (0)
1838
1839 @@ -43,6 +44,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1840 set_pud(pud, __pud(__pa(pmd) | PMD_TYPE_TABLE));
1841 }
1842
1843 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1844 +{
1845 + pud_populate(mm, pud, pmd);
1846 +}
1847 +
1848 #else /* !CONFIG_ARM_LPAE */
1849
1850 /*
1851 @@ -51,6 +57,7 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1852 #define pmd_alloc_one(mm,addr) ({ BUG(); ((pmd_t *)2); })
1853 #define pmd_free(mm, pmd) do { } while (0)
1854 #define pud_populate(mm,pmd,pte) BUG()
1855 +#define pud_populate_kernel(mm,pmd,pte) BUG()
1856
1857 #endif /* CONFIG_ARM_LPAE */
1858
1859 @@ -126,6 +133,19 @@ static inline void pte_free(struct mm_struct *mm, pgtable_t pte)
1860 __free_page(pte);
1861 }
1862
1863 +static inline void __section_update(pmd_t *pmdp, unsigned long addr, pmdval_t prot)
1864 +{
1865 +#ifdef CONFIG_ARM_LPAE
1866 + pmdp[0] = __pmd(pmd_val(pmdp[0]) | prot);
1867 +#else
1868 + if (addr & SECTION_SIZE)
1869 + pmdp[1] = __pmd(pmd_val(pmdp[1]) | prot);
1870 + else
1871 + pmdp[0] = __pmd(pmd_val(pmdp[0]) | prot);
1872 +#endif
1873 + flush_pmd_entry(pmdp);
1874 +}
1875 +
1876 static inline void __pmd_populate(pmd_t *pmdp, phys_addr_t pte,
1877 pmdval_t prot)
1878 {
1879 @@ -155,7 +175,7 @@ pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmdp, pte_t *ptep)
1880 static inline void
1881 pmd_populate(struct mm_struct *mm, pmd_t *pmdp, pgtable_t ptep)
1882 {
1883 - __pmd_populate(pmdp, page_to_phys(ptep), _PAGE_USER_TABLE);
1884 + __pmd_populate(pmdp, page_to_phys(ptep), _PAGE_USER_TABLE | __supported_pmd_mask);
1885 }
1886 #define pmd_pgtable(pmd) pmd_page(pmd)
1887
1888 diff --git a/arch/arm/include/asm/pgtable-2level-hwdef.h b/arch/arm/include/asm/pgtable-2level-hwdef.h
1889 index 5cfba15..f415e1a 100644
1890 --- a/arch/arm/include/asm/pgtable-2level-hwdef.h
1891 +++ b/arch/arm/include/asm/pgtable-2level-hwdef.h
1892 @@ -20,12 +20,15 @@
1893 #define PMD_TYPE_FAULT (_AT(pmdval_t, 0) << 0)
1894 #define PMD_TYPE_TABLE (_AT(pmdval_t, 1) << 0)
1895 #define PMD_TYPE_SECT (_AT(pmdval_t, 2) << 0)
1896 +#define PMD_PXNTABLE (_AT(pmdval_t, 1) << 2) /* v7 */
1897 #define PMD_BIT4 (_AT(pmdval_t, 1) << 4)
1898 #define PMD_DOMAIN(x) (_AT(pmdval_t, (x)) << 5)
1899 #define PMD_PROTECTION (_AT(pmdval_t, 1) << 9) /* v5 */
1900 +
1901 /*
1902 * - section
1903 */
1904 +#define PMD_SECT_PXN (_AT(pmdval_t, 1) << 0) /* v7 */
1905 #define PMD_SECT_BUFFERABLE (_AT(pmdval_t, 1) << 2)
1906 #define PMD_SECT_CACHEABLE (_AT(pmdval_t, 1) << 3)
1907 #define PMD_SECT_XN (_AT(pmdval_t, 1) << 4) /* v6 */
1908 @@ -37,6 +40,7 @@
1909 #define PMD_SECT_nG (_AT(pmdval_t, 1) << 17) /* v6 */
1910 #define PMD_SECT_SUPER (_AT(pmdval_t, 1) << 18) /* v6 */
1911 #define PMD_SECT_AF (_AT(pmdval_t, 0))
1912 +#define PMD_SECT_RDONLY (_AT(pmdval_t, 0))
1913
1914 #define PMD_SECT_UNCACHED (_AT(pmdval_t, 0))
1915 #define PMD_SECT_BUFFERED (PMD_SECT_BUFFERABLE)
1916 @@ -66,6 +70,7 @@
1917 * - extended small page/tiny page
1918 */
1919 #define PTE_EXT_XN (_AT(pteval_t, 1) << 0) /* v6 */
1920 +#define PTE_EXT_PXN (_AT(pteval_t, 1) << 2) /* v7 */
1921 #define PTE_EXT_AP_MASK (_AT(pteval_t, 3) << 4)
1922 #define PTE_EXT_AP0 (_AT(pteval_t, 1) << 4)
1923 #define PTE_EXT_AP1 (_AT(pteval_t, 2) << 4)
1924 diff --git a/arch/arm/include/asm/pgtable-2level.h b/arch/arm/include/asm/pgtable-2level.h
1925 index f97ee02..cc9fe9e 100644
1926 --- a/arch/arm/include/asm/pgtable-2level.h
1927 +++ b/arch/arm/include/asm/pgtable-2level.h
1928 @@ -126,6 +126,9 @@
1929 #define L_PTE_SHARED (_AT(pteval_t, 1) << 10) /* shared(v6), coherent(xsc3) */
1930 #define L_PTE_NONE (_AT(pteval_t, 1) << 11)
1931
1932 +/* Two-level page tables only have PXN in the PGD, not in the PTE. */
1933 +#define L_PTE_PXN (_AT(pteval_t, 0))
1934 +
1935 /*
1936 * These are the memory types, defined to be compatible with
1937 * pre-ARMv6 CPUs cacheable and bufferable bits: XXCB
1938 diff --git a/arch/arm/include/asm/pgtable-3level-hwdef.h b/arch/arm/include/asm/pgtable-3level-hwdef.h
1939 index 626989f..9d67a33 100644
1940 --- a/arch/arm/include/asm/pgtable-3level-hwdef.h
1941 +++ b/arch/arm/include/asm/pgtable-3level-hwdef.h
1942 @@ -75,6 +75,7 @@
1943 #define PTE_EXT_SHARED (_AT(pteval_t, 3) << 8) /* SH[1:0], inner shareable */
1944 #define PTE_EXT_AF (_AT(pteval_t, 1) << 10) /* Access Flag */
1945 #define PTE_EXT_NG (_AT(pteval_t, 1) << 11) /* nG */
1946 +#define PTE_EXT_PXN (_AT(pteval_t, 1) << 53) /* PXN */
1947 #define PTE_EXT_XN (_AT(pteval_t, 1) << 54) /* XN */
1948
1949 /*
1950 diff --git a/arch/arm/include/asm/pgtable-3level.h b/arch/arm/include/asm/pgtable-3level.h
1951 index 5689c18..eea12f9 100644
1952 --- a/arch/arm/include/asm/pgtable-3level.h
1953 +++ b/arch/arm/include/asm/pgtable-3level.h
1954 @@ -82,6 +82,7 @@
1955 #define L_PTE_RDONLY (_AT(pteval_t, 1) << 7) /* AP[2] */
1956 #define L_PTE_SHARED (_AT(pteval_t, 3) << 8) /* SH[1:0], inner shareable */
1957 #define L_PTE_YOUNG (_AT(pteval_t, 1) << 10) /* AF */
1958 +#define L_PTE_PXN (_AT(pteval_t, 1) << 53) /* PXN */
1959 #define L_PTE_XN (_AT(pteval_t, 1) << 54) /* XN */
1960 #define L_PTE_DIRTY (_AT(pteval_t, 1) << 55) /* unused */
1961 #define L_PTE_SPECIAL (_AT(pteval_t, 1) << 56) /* unused */
1962 @@ -95,6 +96,7 @@
1963 /*
1964 * To be used in assembly code with the upper page attributes.
1965 */
1966 +#define L_PTE_PXN_HIGH (1 << (53 - 32))
1967 #define L_PTE_XN_HIGH (1 << (54 - 32))
1968 #define L_PTE_DIRTY_HIGH (1 << (55 - 32))
1969
1970 diff --git a/arch/arm/include/asm/pgtable.h b/arch/arm/include/asm/pgtable.h
1971 index 1571d12..b8a9b43 100644
1972 --- a/arch/arm/include/asm/pgtable.h
1973 +++ b/arch/arm/include/asm/pgtable.h
1974 @@ -33,6 +33,9 @@
1975 #include <asm/pgtable-2level.h>
1976 #endif
1977
1978 +#define ktla_ktva(addr) (addr)
1979 +#define ktva_ktla(addr) (addr)
1980 +
1981 /*
1982 * Just any arbitrary offset to the start of the vmalloc VM area: the
1983 * current 8MB value just means that there will be a 8MB "hole" after the
1984 @@ -48,6 +51,9 @@
1985 #define LIBRARY_TEXT_START 0x0c000000
1986
1987 #ifndef __ASSEMBLY__
1988 +extern pteval_t __supported_pte_mask;
1989 +extern pmdval_t __supported_pmd_mask;
1990 +
1991 extern void __pte_error(const char *file, int line, pte_t);
1992 extern void __pmd_error(const char *file, int line, pmd_t);
1993 extern void __pgd_error(const char *file, int line, pgd_t);
1994 @@ -56,6 +62,48 @@ extern void __pgd_error(const char *file, int line, pgd_t);
1995 #define pmd_ERROR(pmd) __pmd_error(__FILE__, __LINE__, pmd)
1996 #define pgd_ERROR(pgd) __pgd_error(__FILE__, __LINE__, pgd)
1997
1998 +#define __HAVE_ARCH_PAX_OPEN_KERNEL
1999 +#define __HAVE_ARCH_PAX_CLOSE_KERNEL
2000 +
2001 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2002 +#include <asm/domain.h>
2003 +#include <linux/thread_info.h>
2004 +#include <linux/preempt.h>
2005 +
2006 +static inline int test_domain(int domain, int domaintype)
2007 +{
2008 + return ((current_thread_info()->cpu_domain) & domain_val(domain, 3)) == domain_val(domain, domaintype);
2009 +}
2010 +#endif
2011 +
2012 +#ifdef CONFIG_PAX_KERNEXEC
2013 +static inline unsigned long pax_open_kernel(void) {
2014 +#ifdef CONFIG_ARM_LPAE
2015 + /* TODO */
2016 +#else
2017 + preempt_disable();
2018 + BUG_ON(test_domain(DOMAIN_KERNEL, DOMAIN_KERNEXEC));
2019 + modify_domain(DOMAIN_KERNEL, DOMAIN_KERNEXEC);
2020 +#endif
2021 + return 0;
2022 +}
2023 +
2024 +static inline unsigned long pax_close_kernel(void) {
2025 +#ifdef CONFIG_ARM_LPAE
2026 + /* TODO */
2027 +#else
2028 + BUG_ON(test_domain(DOMAIN_KERNEL, DOMAIN_MANAGER));
2029 + /* DOMAIN_MANAGER = "client" under KERNEXEC */
2030 + modify_domain(DOMAIN_KERNEL, DOMAIN_MANAGER);
2031 + preempt_enable_no_resched();
2032 +#endif
2033 + return 0;
2034 +}
2035 +#else
2036 +static inline unsigned long pax_open_kernel(void) { return 0; }
2037 +static inline unsigned long pax_close_kernel(void) { return 0; }
2038 +#endif
2039 +
2040 /*
2041 * This is the lowest virtual address we can permit any user space
2042 * mapping to be mapped at. This is particularly important for
2043 @@ -75,8 +123,8 @@ extern void __pgd_error(const char *file, int line, pgd_t);
2044 /*
2045 * The pgprot_* and protection_map entries will be fixed up in runtime
2046 * to include the cachable and bufferable bits based on memory policy,
2047 - * as well as any architecture dependent bits like global/ASID and SMP
2048 - * shared mapping bits.
2049 + * as well as any architecture dependent bits like global/ASID, PXN,
2050 + * and SMP shared mapping bits.
2051 */
2052 #define _L_PTE_DEFAULT L_PTE_PRESENT | L_PTE_YOUNG
2053
2054 @@ -260,7 +308,7 @@ static inline pte_t pte_mkspecial(pte_t pte) { return pte; }
2055 static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
2056 {
2057 const pteval_t mask = L_PTE_XN | L_PTE_RDONLY | L_PTE_USER |
2058 - L_PTE_NONE | L_PTE_VALID;
2059 + L_PTE_NONE | L_PTE_VALID | __supported_pte_mask;
2060 pte_val(pte) = (pte_val(pte) & ~mask) | (pgprot_val(newprot) & mask);
2061 return pte;
2062 }
2063 diff --git a/arch/arm/include/asm/proc-fns.h b/arch/arm/include/asm/proc-fns.h
2064 index 5324c11..bcae5f0 100644
2065 --- a/arch/arm/include/asm/proc-fns.h
2066 +++ b/arch/arm/include/asm/proc-fns.h
2067 @@ -75,7 +75,7 @@ extern struct processor {
2068 unsigned int suspend_size;
2069 void (*do_suspend)(void *);
2070 void (*do_resume)(void *);
2071 -} processor;
2072 +} __do_const processor;
2073
2074 #ifndef MULTI_CPU
2075 extern void cpu_proc_init(void);
2076 diff --git a/arch/arm/include/asm/psci.h b/arch/arm/include/asm/psci.h
2077 index c4ae171..ea0c0c2 100644
2078 --- a/arch/arm/include/asm/psci.h
2079 +++ b/arch/arm/include/asm/psci.h
2080 @@ -29,7 +29,7 @@ struct psci_operations {
2081 int (*cpu_off)(struct psci_power_state state);
2082 int (*cpu_on)(unsigned long cpuid, unsigned long entry_point);
2083 int (*migrate)(unsigned long cpuid);
2084 -};
2085 +} __no_const;
2086
2087 extern struct psci_operations psci_ops;
2088 extern struct smp_operations psci_smp_ops;
2089 diff --git a/arch/arm/include/asm/smp.h b/arch/arm/include/asm/smp.h
2090 index a8cae71c..65dd797 100644
2091 --- a/arch/arm/include/asm/smp.h
2092 +++ b/arch/arm/include/asm/smp.h
2093 @@ -110,7 +110,7 @@ struct smp_operations {
2094 int (*cpu_disable)(unsigned int cpu);
2095 #endif
2096 #endif
2097 -};
2098 +} __no_const;
2099
2100 /*
2101 * set platform specific SMP operations
2102 diff --git a/arch/arm/include/asm/thread_info.h b/arch/arm/include/asm/thread_info.h
2103 index df5e13d..97efb82 100644
2104 --- a/arch/arm/include/asm/thread_info.h
2105 +++ b/arch/arm/include/asm/thread_info.h
2106 @@ -88,9 +88,9 @@ struct thread_info {
2107 .flags = 0, \
2108 .preempt_count = INIT_PREEMPT_COUNT, \
2109 .addr_limit = KERNEL_DS, \
2110 - .cpu_domain = domain_val(DOMAIN_USER, DOMAIN_MANAGER) | \
2111 - domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \
2112 - domain_val(DOMAIN_IO, DOMAIN_CLIENT), \
2113 + .cpu_domain = domain_val(DOMAIN_USER, DOMAIN_USERCLIENT) | \
2114 + domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT) | \
2115 + domain_val(DOMAIN_IO, DOMAIN_KERNELCLIENT), \
2116 .restart_block = { \
2117 .fn = do_no_restart_syscall, \
2118 }, \
2119 @@ -163,7 +163,11 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
2120 #define TIF_SYSCALL_AUDIT 9
2121 #define TIF_SYSCALL_TRACEPOINT 10
2122 #define TIF_SECCOMP 11 /* seccomp syscall filtering active */
2123 -#define TIF_NOHZ 12 /* in adaptive nohz mode */
2124 +/* within 8 bits of TIF_SYSCALL_TRACE
2125 + * to meet flexible second operand requirements
2126 + */
2127 +#define TIF_GRSEC_SETXID 12
2128 +#define TIF_NOHZ 13 /* in adaptive nohz mode */
2129 #define TIF_USING_IWMMXT 17
2130 #define TIF_MEMDIE 18 /* is terminating due to OOM killer */
2131 #define TIF_RESTORE_SIGMASK 20
2132 @@ -176,10 +180,11 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
2133 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
2134 #define _TIF_SECCOMP (1 << TIF_SECCOMP)
2135 #define _TIF_USING_IWMMXT (1 << TIF_USING_IWMMXT)
2136 +#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
2137
2138 /* Checks for any syscall work in entry-common.S */
2139 #define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
2140 - _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP)
2141 + _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP | _TIF_GRSEC_SETXID)
2142
2143 /*
2144 * Change these and you break ASM code in entry-common.S
2145 diff --git a/arch/arm/include/asm/uaccess.h b/arch/arm/include/asm/uaccess.h
2146 index 72abdc5..9eba222 100644
2147 --- a/arch/arm/include/asm/uaccess.h
2148 +++ b/arch/arm/include/asm/uaccess.h
2149 @@ -18,6 +18,7 @@
2150 #include <asm/domain.h>
2151 #include <asm/unified.h>
2152 #include <asm/compiler.h>
2153 +#include <asm/pgtable.h>
2154
2155 #if __LINUX_ARM_ARCH__ < 6
2156 #include <asm-generic/uaccess-unaligned.h>
2157 @@ -70,11 +71,38 @@ extern int __put_user_bad(void);
2158 static inline void set_fs(mm_segment_t fs)
2159 {
2160 current_thread_info()->addr_limit = fs;
2161 - modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_CLIENT : DOMAIN_MANAGER);
2162 + modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_KERNELCLIENT : DOMAIN_MANAGER);
2163 }
2164
2165 #define segment_eq(a,b) ((a) == (b))
2166
2167 +#define __HAVE_ARCH_PAX_OPEN_USERLAND
2168 +#define __HAVE_ARCH_PAX_CLOSE_USERLAND
2169 +
2170 +static inline void pax_open_userland(void)
2171 +{
2172 +
2173 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2174 + if (segment_eq(get_fs(), USER_DS)) {
2175 + BUG_ON(test_domain(DOMAIN_USER, DOMAIN_UDEREF));
2176 + modify_domain(DOMAIN_USER, DOMAIN_UDEREF);
2177 + }
2178 +#endif
2179 +
2180 +}
2181 +
2182 +static inline void pax_close_userland(void)
2183 +{
2184 +
2185 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2186 + if (segment_eq(get_fs(), USER_DS)) {
2187 + BUG_ON(test_domain(DOMAIN_USER, DOMAIN_NOACCESS));
2188 + modify_domain(DOMAIN_USER, DOMAIN_NOACCESS);
2189 + }
2190 +#endif
2191 +
2192 +}
2193 +
2194 #define __addr_ok(addr) ({ \
2195 unsigned long flag; \
2196 __asm__("cmp %2, %0; movlo %0, #0" \
2197 @@ -150,8 +178,12 @@ extern int __get_user_4(void *);
2198
2199 #define get_user(x,p) \
2200 ({ \
2201 + int __e; \
2202 might_fault(); \
2203 - __get_user_check(x,p); \
2204 + pax_open_userland(); \
2205 + __e = __get_user_check(x,p); \
2206 + pax_close_userland(); \
2207 + __e; \
2208 })
2209
2210 extern int __put_user_1(void *, unsigned int);
2211 @@ -195,8 +227,12 @@ extern int __put_user_8(void *, unsigned long long);
2212
2213 #define put_user(x,p) \
2214 ({ \
2215 + int __e; \
2216 might_fault(); \
2217 - __put_user_check(x,p); \
2218 + pax_open_userland(); \
2219 + __e = __put_user_check(x,p); \
2220 + pax_close_userland(); \
2221 + __e; \
2222 })
2223
2224 #else /* CONFIG_MMU */
2225 @@ -237,13 +273,17 @@ static inline void set_fs(mm_segment_t fs)
2226 #define __get_user(x,ptr) \
2227 ({ \
2228 long __gu_err = 0; \
2229 + pax_open_userland(); \
2230 __get_user_err((x),(ptr),__gu_err); \
2231 + pax_close_userland(); \
2232 __gu_err; \
2233 })
2234
2235 #define __get_user_error(x,ptr,err) \
2236 ({ \
2237 + pax_open_userland(); \
2238 __get_user_err((x),(ptr),err); \
2239 + pax_close_userland(); \
2240 (void) 0; \
2241 })
2242
2243 @@ -319,13 +359,17 @@ do { \
2244 #define __put_user(x,ptr) \
2245 ({ \
2246 long __pu_err = 0; \
2247 + pax_open_userland(); \
2248 __put_user_err((x),(ptr),__pu_err); \
2249 + pax_close_userland(); \
2250 __pu_err; \
2251 })
2252
2253 #define __put_user_error(x,ptr,err) \
2254 ({ \
2255 + pax_open_userland(); \
2256 __put_user_err((x),(ptr),err); \
2257 + pax_close_userland(); \
2258 (void) 0; \
2259 })
2260
2261 @@ -425,11 +469,44 @@ do { \
2262
2263
2264 #ifdef CONFIG_MMU
2265 -extern unsigned long __must_check __copy_from_user(void *to, const void __user *from, unsigned long n);
2266 -extern unsigned long __must_check __copy_to_user(void __user *to, const void *from, unsigned long n);
2267 +extern unsigned long __must_check ___copy_from_user(void *to, const void __user *from, unsigned long n);
2268 +extern unsigned long __must_check ___copy_to_user(void __user *to, const void *from, unsigned long n);
2269 +
2270 +static inline unsigned long __must_check __copy_from_user(void *to, const void __user *from, unsigned long n)
2271 +{
2272 + unsigned long ret;
2273 +
2274 + check_object_size(to, n, false);
2275 + pax_open_userland();
2276 + ret = ___copy_from_user(to, from, n);
2277 + pax_close_userland();
2278 + return ret;
2279 +}
2280 +
2281 +static inline unsigned long __must_check __copy_to_user(void __user *to, const void *from, unsigned long n)
2282 +{
2283 + unsigned long ret;
2284 +
2285 + check_object_size(from, n, true);
2286 + pax_open_userland();
2287 + ret = ___copy_to_user(to, from, n);
2288 + pax_close_userland();
2289 + return ret;
2290 +}
2291 +
2292 extern unsigned long __must_check __copy_to_user_std(void __user *to, const void *from, unsigned long n);
2293 -extern unsigned long __must_check __clear_user(void __user *addr, unsigned long n);
2294 +extern unsigned long __must_check ___clear_user(void __user *addr, unsigned long n);
2295 extern unsigned long __must_check __clear_user_std(void __user *addr, unsigned long n);
2296 +
2297 +static inline unsigned long __must_check __clear_user(void __user *addr, unsigned long n)
2298 +{
2299 + unsigned long ret;
2300 + pax_open_userland();
2301 + ret = ___clear_user(addr, n);
2302 + pax_close_userland();
2303 + return ret;
2304 +}
2305 +
2306 #else
2307 #define __copy_from_user(to,from,n) (memcpy(to, (void __force *)from, n), 0)
2308 #define __copy_to_user(to,from,n) (memcpy((void __force *)to, from, n), 0)
2309 @@ -438,6 +515,9 @@ extern unsigned long __must_check __clear_user_std(void __user *addr, unsigned l
2310
2311 static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
2312 {
2313 + if ((long)n < 0)
2314 + return n;
2315 +
2316 if (access_ok(VERIFY_READ, from, n))
2317 n = __copy_from_user(to, from, n);
2318 else /* security hole - plug it */
2319 @@ -447,6 +527,9 @@ static inline unsigned long __must_check copy_from_user(void *to, const void __u
2320
2321 static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
2322 {
2323 + if ((long)n < 0)
2324 + return n;
2325 +
2326 if (access_ok(VERIFY_WRITE, to, n))
2327 n = __copy_to_user(to, from, n);
2328 return n;
2329 diff --git a/arch/arm/include/uapi/asm/ptrace.h b/arch/arm/include/uapi/asm/ptrace.h
2330 index 5af0ed1..cea83883 100644
2331 --- a/arch/arm/include/uapi/asm/ptrace.h
2332 +++ b/arch/arm/include/uapi/asm/ptrace.h
2333 @@ -92,7 +92,7 @@
2334 * ARMv7 groups of PSR bits
2335 */
2336 #define APSR_MASK 0xf80f0000 /* N, Z, C, V, Q and GE flags */
2337 -#define PSR_ISET_MASK 0x01000010 /* ISA state (J, T) mask */
2338 +#define PSR_ISET_MASK 0x01000020 /* ISA state (J, T) mask */
2339 #define PSR_IT_MASK 0x0600fc00 /* If-Then execution state mask */
2340 #define PSR_ENDIAN_MASK 0x00000200 /* Endianness state mask */
2341
2342 diff --git a/arch/arm/kernel/armksyms.c b/arch/arm/kernel/armksyms.c
2343 index 60d3b73..e5a0f22 100644
2344 --- a/arch/arm/kernel/armksyms.c
2345 +++ b/arch/arm/kernel/armksyms.c
2346 @@ -53,7 +53,7 @@ EXPORT_SYMBOL(arm_delay_ops);
2347
2348 /* networking */
2349 EXPORT_SYMBOL(csum_partial);
2350 -EXPORT_SYMBOL(csum_partial_copy_from_user);
2351 +EXPORT_SYMBOL(__csum_partial_copy_from_user);
2352 EXPORT_SYMBOL(csum_partial_copy_nocheck);
2353 EXPORT_SYMBOL(__csum_ipv6_magic);
2354
2355 @@ -89,9 +89,9 @@ EXPORT_SYMBOL(__memzero);
2356 #ifdef CONFIG_MMU
2357 EXPORT_SYMBOL(copy_page);
2358
2359 -EXPORT_SYMBOL(__copy_from_user);
2360 -EXPORT_SYMBOL(__copy_to_user);
2361 -EXPORT_SYMBOL(__clear_user);
2362 +EXPORT_SYMBOL(___copy_from_user);
2363 +EXPORT_SYMBOL(___copy_to_user);
2364 +EXPORT_SYMBOL(___clear_user);
2365
2366 EXPORT_SYMBOL(__get_user_1);
2367 EXPORT_SYMBOL(__get_user_2);
2368 diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S
2369 index ec3e5cf..b450ee3 100644
2370 --- a/arch/arm/kernel/entry-armv.S
2371 +++ b/arch/arm/kernel/entry-armv.S
2372 @@ -47,6 +47,87 @@
2373 9997:
2374 .endm
2375
2376 + .macro pax_enter_kernel
2377 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2378 + @ make aligned space for saved DACR
2379 + sub sp, sp, #8
2380 + @ save regs
2381 + stmdb sp!, {r1, r2}
2382 + @ read DACR from cpu_domain into r1
2383 + mov r2, sp
2384 + @ assume 8K pages, since we have to split the immediate in two
2385 + bic r2, r2, #(0x1fc0)
2386 + bic r2, r2, #(0x3f)
2387 + ldr r1, [r2, #TI_CPU_DOMAIN]
2388 + @ store old DACR on stack
2389 + str r1, [sp, #8]
2390 +#ifdef CONFIG_PAX_KERNEXEC
2391 + @ set type of DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2392 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2393 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2394 +#endif
2395 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2396 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2397 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2398 +#endif
2399 + @ write r1 to current_thread_info()->cpu_domain
2400 + str r1, [r2, #TI_CPU_DOMAIN]
2401 + @ write r1 to DACR
2402 + mcr p15, 0, r1, c3, c0, 0
2403 + @ instruction sync
2404 + instr_sync
2405 + @ restore regs
2406 + ldmia sp!, {r1, r2}
2407 +#endif
2408 + .endm
2409 +
2410 + .macro pax_open_userland
2411 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2412 + @ save regs
2413 + stmdb sp!, {r0, r1}
2414 + @ read DACR from cpu_domain into r1
2415 + mov r0, sp
2416 + @ assume 8K pages, since we have to split the immediate in two
2417 + bic r0, r0, #(0x1fc0)
2418 + bic r0, r0, #(0x3f)
2419 + ldr r1, [r0, #TI_CPU_DOMAIN]
2420 + @ set current DOMAIN_USER to DOMAIN_CLIENT
2421 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2422 + orr r1, r1, #(domain_val(DOMAIN_USER, DOMAIN_UDEREF))
2423 + @ write r1 to current_thread_info()->cpu_domain
2424 + str r1, [r0, #TI_CPU_DOMAIN]
2425 + @ write r1 to DACR
2426 + mcr p15, 0, r1, c3, c0, 0
2427 + @ instruction sync
2428 + instr_sync
2429 + @ restore regs
2430 + ldmia sp!, {r0, r1}
2431 +#endif
2432 + .endm
2433 +
2434 + .macro pax_close_userland
2435 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2436 + @ save regs
2437 + stmdb sp!, {r0, r1}
2438 + @ read DACR from cpu_domain into r1
2439 + mov r0, sp
2440 + @ assume 8K pages, since we have to split the immediate in two
2441 + bic r0, r0, #(0x1fc0)
2442 + bic r0, r0, #(0x3f)
2443 + ldr r1, [r0, #TI_CPU_DOMAIN]
2444 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2445 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2446 + @ write r1 to current_thread_info()->cpu_domain
2447 + str r1, [r0, #TI_CPU_DOMAIN]
2448 + @ write r1 to DACR
2449 + mcr p15, 0, r1, c3, c0, 0
2450 + @ instruction sync
2451 + instr_sync
2452 + @ restore regs
2453 + ldmia sp!, {r0, r1}
2454 +#endif
2455 + .endm
2456 +
2457 .macro pabt_helper
2458 @ PABORT handler takes pt_regs in r2, fault address in r4 and psr in r5
2459 #ifdef MULTI_PABORT
2460 @@ -89,11 +170,15 @@
2461 * Invalid mode handlers
2462 */
2463 .macro inv_entry, reason
2464 +
2465 + pax_enter_kernel
2466 +
2467 sub sp, sp, #S_FRAME_SIZE
2468 ARM( stmib sp, {r1 - lr} )
2469 THUMB( stmia sp, {r0 - r12} )
2470 THUMB( str sp, [sp, #S_SP] )
2471 THUMB( str lr, [sp, #S_LR] )
2472 +
2473 mov r1, #\reason
2474 .endm
2475
2476 @@ -149,7 +234,11 @@ ENDPROC(__und_invalid)
2477 .macro svc_entry, stack_hole=0
2478 UNWIND(.fnstart )
2479 UNWIND(.save {r0 - pc} )
2480 +
2481 + pax_enter_kernel
2482 +
2483 sub sp, sp, #(S_FRAME_SIZE + \stack_hole - 4)
2484 +
2485 #ifdef CONFIG_THUMB2_KERNEL
2486 SPFIX( str r0, [sp] ) @ temporarily saved
2487 SPFIX( mov r0, sp )
2488 @@ -164,7 +253,12 @@ ENDPROC(__und_invalid)
2489 ldmia r0, {r3 - r5}
2490 add r7, sp, #S_SP - 4 @ here for interlock avoidance
2491 mov r6, #-1 @ "" "" "" ""
2492 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2493 + @ offset sp by 8 as done in pax_enter_kernel
2494 + add r2, sp, #(S_FRAME_SIZE + \stack_hole + 4)
2495 +#else
2496 add r2, sp, #(S_FRAME_SIZE + \stack_hole - 4)
2497 +#endif
2498 SPFIX( addeq r2, r2, #4 )
2499 str r3, [sp, #-4]! @ save the "real" r0 copied
2500 @ from the exception stack
2501 @@ -317,6 +411,9 @@ ENDPROC(__pabt_svc)
2502 .macro usr_entry
2503 UNWIND(.fnstart )
2504 UNWIND(.cantunwind ) @ don't unwind the user space
2505 +
2506 + pax_enter_kernel_user
2507 +
2508 sub sp, sp, #S_FRAME_SIZE
2509 ARM( stmib sp, {r1 - r12} )
2510 THUMB( stmia sp, {r0 - r12} )
2511 @@ -416,7 +513,9 @@ __und_usr:
2512 tst r3, #PSR_T_BIT @ Thumb mode?
2513 bne __und_usr_thumb
2514 sub r4, r2, #4 @ ARM instr at LR - 4
2515 + pax_open_userland
2516 1: ldrt r0, [r4]
2517 + pax_close_userland
2518 #ifdef CONFIG_CPU_ENDIAN_BE8
2519 rev r0, r0 @ little endian instruction
2520 #endif
2521 @@ -451,10 +550,14 @@ __und_usr_thumb:
2522 */
2523 .arch armv6t2
2524 #endif
2525 + pax_open_userland
2526 2: ldrht r5, [r4]
2527 + pax_close_userland
2528 cmp r5, #0xe800 @ 32bit instruction if xx != 0
2529 blo __und_usr_fault_16 @ 16bit undefined instruction
2530 + pax_open_userland
2531 3: ldrht r0, [r2]
2532 + pax_close_userland
2533 add r2, r2, #2 @ r2 is PC + 2, make it PC + 4
2534 str r2, [sp, #S_PC] @ it's a 2x16bit instr, update
2535 orr r0, r0, r5, lsl #16
2536 @@ -483,7 +586,8 @@ ENDPROC(__und_usr)
2537 */
2538 .pushsection .fixup, "ax"
2539 .align 2
2540 -4: mov pc, r9
2541 +4: pax_close_userland
2542 + mov pc, r9
2543 .popsection
2544 .pushsection __ex_table,"a"
2545 .long 1b, 4b
2546 @@ -693,7 +797,7 @@ ENTRY(__switch_to)
2547 THUMB( str lr, [ip], #4 )
2548 ldr r4, [r2, #TI_TP_VALUE]
2549 ldr r5, [r2, #TI_TP_VALUE + 4]
2550 -#ifdef CONFIG_CPU_USE_DOMAINS
2551 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2552 ldr r6, [r2, #TI_CPU_DOMAIN]
2553 #endif
2554 switch_tls r1, r4, r5, r3, r7
2555 @@ -702,7 +806,7 @@ ENTRY(__switch_to)
2556 ldr r8, =__stack_chk_guard
2557 ldr r7, [r7, #TSK_STACK_CANARY]
2558 #endif
2559 -#ifdef CONFIG_CPU_USE_DOMAINS
2560 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2561 mcr p15, 0, r6, c3, c0, 0 @ Set domain register
2562 #endif
2563 mov r5, r0
2564 diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S
2565 index bc6bd96..bd026cb 100644
2566 --- a/arch/arm/kernel/entry-common.S
2567 +++ b/arch/arm/kernel/entry-common.S
2568 @@ -10,18 +10,46 @@
2569
2570 #include <asm/unistd.h>
2571 #include <asm/ftrace.h>
2572 +#include <asm/domain.h>
2573 #include <asm/unwind.h>
2574
2575 +#include "entry-header.S"
2576 +
2577 #ifdef CONFIG_NEED_RET_TO_USER
2578 #include <mach/entry-macro.S>
2579 #else
2580 .macro arch_ret_to_user, tmp1, tmp2
2581 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2582 + @ save regs
2583 + stmdb sp!, {r1, r2}
2584 + @ read DACR from cpu_domain into r1
2585 + mov r2, sp
2586 + @ assume 8K pages, since we have to split the immediate in two
2587 + bic r2, r2, #(0x1fc0)
2588 + bic r2, r2, #(0x3f)
2589 + ldr r1, [r2, #TI_CPU_DOMAIN]
2590 +#ifdef CONFIG_PAX_KERNEXEC
2591 + @ set type of DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2592 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2593 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2594 +#endif
2595 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2596 + @ set current DOMAIN_USER to DOMAIN_UDEREF
2597 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2598 + orr r1, r1, #(domain_val(DOMAIN_USER, DOMAIN_UDEREF))
2599 +#endif
2600 + @ write r1 to current_thread_info()->cpu_domain
2601 + str r1, [r2, #TI_CPU_DOMAIN]
2602 + @ write r1 to DACR
2603 + mcr p15, 0, r1, c3, c0, 0
2604 + @ instruction sync
2605 + instr_sync
2606 + @ restore regs
2607 + ldmia sp!, {r1, r2}
2608 +#endif
2609 .endm
2610 #endif
2611
2612 -#include "entry-header.S"
2613 -
2614 -
2615 .align 5
2616 /*
2617 * This is the fast syscall return path. We do as little as
2618 @@ -413,6 +441,12 @@ ENTRY(vector_swi)
2619 USER( ldr scno, [lr, #-4] ) @ get SWI instruction
2620 #endif
2621
2622 + /*
2623 + * do this here to avoid a performance hit of wrapping the code above
2624 + * that directly dereferences userland to parse the SWI instruction
2625 + */
2626 + pax_enter_kernel_user
2627 +
2628 adr tbl, sys_call_table @ load syscall table pointer
2629
2630 #if defined(CONFIG_OABI_COMPAT)
2631 diff --git a/arch/arm/kernel/entry-header.S b/arch/arm/kernel/entry-header.S
2632 index 39f89fb..d612bd9 100644
2633 --- a/arch/arm/kernel/entry-header.S
2634 +++ b/arch/arm/kernel/entry-header.S
2635 @@ -184,6 +184,60 @@
2636 msr cpsr_c, \rtemp @ switch back to the SVC mode
2637 .endm
2638
2639 + .macro pax_enter_kernel_user
2640 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2641 + @ save regs
2642 + stmdb sp!, {r0, r1}
2643 + @ read DACR from cpu_domain into r1
2644 + mov r0, sp
2645 + @ assume 8K pages, since we have to split the immediate in two
2646 + bic r0, r0, #(0x1fc0)
2647 + bic r0, r0, #(0x3f)
2648 + ldr r1, [r0, #TI_CPU_DOMAIN]
2649 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2650 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2651 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2652 +#endif
2653 +#ifdef CONFIG_PAX_KERNEXEC
2654 + @ set current DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2655 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2656 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2657 +#endif
2658 + @ write r1 to current_thread_info()->cpu_domain
2659 + str r1, [r0, #TI_CPU_DOMAIN]
2660 + @ write r1 to DACR
2661 + mcr p15, 0, r1, c3, c0, 0
2662 + @ instruction sync
2663 + instr_sync
2664 + @ restore regs
2665 + ldmia sp!, {r0, r1}
2666 +#endif
2667 + .endm
2668 +
2669 + .macro pax_exit_kernel
2670 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2671 + @ save regs
2672 + stmdb sp!, {r0, r1}
2673 + @ read old DACR from stack into r1
2674 + ldr r1, [sp, #(8 + S_SP)]
2675 + sub r1, r1, #8
2676 + ldr r1, [r1]
2677 +
2678 + @ write r1 to current_thread_info()->cpu_domain
2679 + mov r0, sp
2680 + @ assume 8K pages, since we have to split the immediate in two
2681 + bic r0, r0, #(0x1fc0)
2682 + bic r0, r0, #(0x3f)
2683 + str r1, [r0, #TI_CPU_DOMAIN]
2684 + @ write r1 to DACR
2685 + mcr p15, 0, r1, c3, c0, 0
2686 + @ instruction sync
2687 + instr_sync
2688 + @ restore regs
2689 + ldmia sp!, {r0, r1}
2690 +#endif
2691 + .endm
2692 +
2693 #ifndef CONFIG_THUMB2_KERNEL
2694 .macro svc_exit, rpsr, irq = 0
2695 .if \irq != 0
2696 @@ -203,6 +257,9 @@
2697 blne trace_hardirqs_off
2698 #endif
2699 .endif
2700 +
2701 + pax_exit_kernel
2702 +
2703 msr spsr_cxsf, \rpsr
2704 #if defined(CONFIG_CPU_V6)
2705 ldr r0, [sp]
2706 @@ -266,6 +323,9 @@
2707 blne trace_hardirqs_off
2708 #endif
2709 .endif
2710 +
2711 + pax_exit_kernel
2712 +
2713 ldr lr, [sp, #S_SP] @ top of the stack
2714 ldrd r0, r1, [sp, #S_LR] @ calling lr and pc
2715 clrex @ clear the exclusive monitor
2716 diff --git a/arch/arm/kernel/fiq.c b/arch/arm/kernel/fiq.c
2717 index 918875d..cd5fa27 100644
2718 --- a/arch/arm/kernel/fiq.c
2719 +++ b/arch/arm/kernel/fiq.c
2720 @@ -87,7 +87,10 @@ void set_fiq_handler(void *start, unsigned int length)
2721 void *base = vectors_page;
2722 unsigned offset = FIQ_OFFSET;
2723
2724 + pax_open_kernel();
2725 memcpy(base + offset, start, length);
2726 + pax_close_kernel();
2727 +
2728 if (!cache_is_vipt_nonaliasing())
2729 flush_icache_range((unsigned long)base + offset, offset +
2730 length);
2731 diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S
2732 index 476de57..4857a76 100644
2733 --- a/arch/arm/kernel/head.S
2734 +++ b/arch/arm/kernel/head.S
2735 @@ -52,7 +52,9 @@
2736 .equ swapper_pg_dir, KERNEL_RAM_VADDR - PG_DIR_SIZE
2737
2738 .macro pgtbl, rd, phys
2739 - add \rd, \phys, #TEXT_OFFSET - PG_DIR_SIZE
2740 + mov \rd, #TEXT_OFFSET
2741 + sub \rd, #PG_DIR_SIZE
2742 + add \rd, \rd, \phys
2743 .endm
2744
2745 /*
2746 @@ -432,7 +434,7 @@ __enable_mmu:
2747 mov r5, #(domain_val(DOMAIN_USER, DOMAIN_MANAGER) | \
2748 domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \
2749 domain_val(DOMAIN_TABLE, DOMAIN_MANAGER) | \
2750 - domain_val(DOMAIN_IO, DOMAIN_CLIENT))
2751 + domain_val(DOMAIN_IO, DOMAIN_KERNELCLIENT))
2752 mcr p15, 0, r5, c3, c0, 0 @ load domain access register
2753 mcr p15, 0, r4, c2, c0, 0 @ load page table pointer
2754 #endif
2755 diff --git a/arch/arm/kernel/module.c b/arch/arm/kernel/module.c
2756 index 084dc88..fce4e68 100644
2757 --- a/arch/arm/kernel/module.c
2758 +++ b/arch/arm/kernel/module.c
2759 @@ -37,12 +37,39 @@
2760 #endif
2761
2762 #ifdef CONFIG_MMU
2763 -void *module_alloc(unsigned long size)
2764 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
2765 {
2766 + if (!size || PAGE_ALIGN(size) > MODULES_END - MODULES_VADDR)
2767 + return NULL;
2768 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
2769 - GFP_KERNEL, PAGE_KERNEL_EXEC, -1,
2770 + GFP_KERNEL, prot, -1,
2771 __builtin_return_address(0));
2772 }
2773 +
2774 +void *module_alloc(unsigned long size)
2775 +{
2776 +
2777 +#ifdef CONFIG_PAX_KERNEXEC
2778 + return __module_alloc(size, PAGE_KERNEL);
2779 +#else
2780 + return __module_alloc(size, PAGE_KERNEL_EXEC);
2781 +#endif
2782 +
2783 +}
2784 +
2785 +#ifdef CONFIG_PAX_KERNEXEC
2786 +void module_free_exec(struct module *mod, void *module_region)
2787 +{
2788 + module_free(mod, module_region);
2789 +}
2790 +EXPORT_SYMBOL(module_free_exec);
2791 +
2792 +void *module_alloc_exec(unsigned long size)
2793 +{
2794 + return __module_alloc(size, PAGE_KERNEL_EXEC);
2795 +}
2796 +EXPORT_SYMBOL(module_alloc_exec);
2797 +#endif
2798 #endif
2799
2800 int
2801 diff --git a/arch/arm/kernel/patch.c b/arch/arm/kernel/patch.c
2802 index 07314af..c46655c 100644
2803 --- a/arch/arm/kernel/patch.c
2804 +++ b/arch/arm/kernel/patch.c
2805 @@ -18,6 +18,7 @@ void __kprobes __patch_text(void *addr, unsigned int insn)
2806 bool thumb2 = IS_ENABLED(CONFIG_THUMB2_KERNEL);
2807 int size;
2808
2809 + pax_open_kernel();
2810 if (thumb2 && __opcode_is_thumb16(insn)) {
2811 *(u16 *)addr = __opcode_to_mem_thumb16(insn);
2812 size = sizeof(u16);
2813 @@ -39,6 +40,7 @@ void __kprobes __patch_text(void *addr, unsigned int insn)
2814 *(u32 *)addr = insn;
2815 size = sizeof(u32);
2816 }
2817 + pax_close_kernel();
2818
2819 flush_icache_range((uintptr_t)(addr),
2820 (uintptr_t)(addr) + size);
2821 diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
2822 index 92f7b15..7048500 100644
2823 --- a/arch/arm/kernel/process.c
2824 +++ b/arch/arm/kernel/process.c
2825 @@ -217,6 +217,7 @@ void machine_power_off(void)
2826
2827 if (pm_power_off)
2828 pm_power_off();
2829 + BUG();
2830 }
2831
2832 /*
2833 @@ -230,7 +231,7 @@ void machine_power_off(void)
2834 * executing pre-reset code, and using RAM that the primary CPU's code wishes
2835 * to use. Implementing such co-ordination would be essentially impossible.
2836 */
2837 -void machine_restart(char *cmd)
2838 +__noreturn void machine_restart(char *cmd)
2839 {
2840 local_irq_disable();
2841 smp_send_stop();
2842 @@ -253,8 +254,8 @@ void __show_regs(struct pt_regs *regs)
2843
2844 show_regs_print_info(KERN_DEFAULT);
2845
2846 - print_symbol("PC is at %s\n", instruction_pointer(regs));
2847 - print_symbol("LR is at %s\n", regs->ARM_lr);
2848 + printk("PC is at %pA\n", (void *)instruction_pointer(regs));
2849 + printk("LR is at %pA\n", (void *)regs->ARM_lr);
2850 printk("pc : [<%08lx>] lr : [<%08lx>] psr: %08lx\n"
2851 "sp : %08lx ip : %08lx fp : %08lx\n",
2852 regs->ARM_pc, regs->ARM_lr, regs->ARM_cpsr,
2853 @@ -425,12 +426,6 @@ unsigned long get_wchan(struct task_struct *p)
2854 return 0;
2855 }
2856
2857 -unsigned long arch_randomize_brk(struct mm_struct *mm)
2858 -{
2859 - unsigned long range_end = mm->brk + 0x02000000;
2860 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
2861 -}
2862 -
2863 #ifdef CONFIG_MMU
2864 #ifdef CONFIG_KUSER_HELPERS
2865 /*
2866 @@ -446,7 +441,7 @@ static struct vm_area_struct gate_vma = {
2867
2868 static int __init gate_vma_init(void)
2869 {
2870 - gate_vma.vm_page_prot = PAGE_READONLY_EXEC;
2871 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
2872 return 0;
2873 }
2874 arch_initcall(gate_vma_init);
2875 @@ -472,41 +467,16 @@ int in_gate_area_no_mm(unsigned long addr)
2876
2877 const char *arch_vma_name(struct vm_area_struct *vma)
2878 {
2879 - return is_gate_vma(vma) ? "[vectors]" :
2880 - (vma->vm_mm && vma->vm_start == vma->vm_mm->context.sigpage) ?
2881 - "[sigpage]" : NULL;
2882 + return is_gate_vma(vma) ? "[vectors]" : NULL;
2883 }
2884
2885 -static struct page *signal_page;
2886 -extern struct page *get_signal_page(void);
2887 -
2888 int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
2889 {
2890 struct mm_struct *mm = current->mm;
2891 - unsigned long addr;
2892 - int ret;
2893 -
2894 - if (!signal_page)
2895 - signal_page = get_signal_page();
2896 - if (!signal_page)
2897 - return -ENOMEM;
2898
2899 down_write(&mm->mmap_sem);
2900 - addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, 0);
2901 - if (IS_ERR_VALUE(addr)) {
2902 - ret = addr;
2903 - goto up_fail;
2904 - }
2905 -
2906 - ret = install_special_mapping(mm, addr, PAGE_SIZE,
2907 - VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC,
2908 - &signal_page);
2909 -
2910 - if (ret == 0)
2911 - mm->context.sigpage = addr;
2912 -
2913 - up_fail:
2914 + mm->context.sigpage = (PAGE_OFFSET + (get_random_int() % 0x3FFEFFE0)) & 0xFFFFFFFC;
2915 up_write(&mm->mmap_sem);
2916 - return ret;
2917 + return 0;
2918 }
2919 #endif
2920 diff --git a/arch/arm/kernel/psci.c b/arch/arm/kernel/psci.c
2921 index 4693188..4596c5e 100644
2922 --- a/arch/arm/kernel/psci.c
2923 +++ b/arch/arm/kernel/psci.c
2924 @@ -24,7 +24,7 @@
2925 #include <asm/opcodes-virt.h>
2926 #include <asm/psci.h>
2927
2928 -struct psci_operations psci_ops;
2929 +struct psci_operations psci_ops __read_only;
2930
2931 static int (*invoke_psci_fn)(u32, u32, u32, u32);
2932
2933 diff --git a/arch/arm/kernel/ptrace.c b/arch/arm/kernel/ptrace.c
2934 index 0dd3b79..e018f64 100644
2935 --- a/arch/arm/kernel/ptrace.c
2936 +++ b/arch/arm/kernel/ptrace.c
2937 @@ -929,10 +929,19 @@ static int tracehook_report_syscall(struct pt_regs *regs,
2938 return current_thread_info()->syscall;
2939 }
2940
2941 +#ifdef CONFIG_GRKERNSEC_SETXID
2942 +extern void gr_delayed_cred_worker(void);
2943 +#endif
2944 +
2945 asmlinkage int syscall_trace_enter(struct pt_regs *regs, int scno)
2946 {
2947 current_thread_info()->syscall = scno;
2948
2949 +#ifdef CONFIG_GRKERNSEC_SETXID
2950 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
2951 + gr_delayed_cred_worker();
2952 +#endif
2953 +
2954 /* Do the secure computing check first; failures should be fast. */
2955 if (secure_computing(scno) == -1)
2956 return -1;
2957 diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
2958 index 0e1e2b3..c0e821d 100644
2959 --- a/arch/arm/kernel/setup.c
2960 +++ b/arch/arm/kernel/setup.c
2961 @@ -98,21 +98,23 @@ EXPORT_SYMBOL(system_serial_high);
2962 unsigned int elf_hwcap __read_mostly;
2963 EXPORT_SYMBOL(elf_hwcap);
2964
2965 +pteval_t __supported_pte_mask __read_only;
2966 +pmdval_t __supported_pmd_mask __read_only;
2967
2968 #ifdef MULTI_CPU
2969 -struct processor processor __read_mostly;
2970 +struct processor processor;
2971 #endif
2972 #ifdef MULTI_TLB
2973 -struct cpu_tlb_fns cpu_tlb __read_mostly;
2974 +struct cpu_tlb_fns cpu_tlb __read_only;
2975 #endif
2976 #ifdef MULTI_USER
2977 -struct cpu_user_fns cpu_user __read_mostly;
2978 +struct cpu_user_fns cpu_user __read_only;
2979 #endif
2980 #ifdef MULTI_CACHE
2981 -struct cpu_cache_fns cpu_cache __read_mostly;
2982 +struct cpu_cache_fns cpu_cache __read_only;
2983 #endif
2984 #ifdef CONFIG_OUTER_CACHE
2985 -struct outer_cache_fns outer_cache __read_mostly;
2986 +struct outer_cache_fns outer_cache __read_only;
2987 EXPORT_SYMBOL(outer_cache);
2988 #endif
2989
2990 @@ -245,9 +247,13 @@ static int __get_cpu_architecture(void)
2991 asm("mrc p15, 0, %0, c0, c1, 4"
2992 : "=r" (mmfr0));
2993 if ((mmfr0 & 0x0000000f) >= 0x00000003 ||
2994 - (mmfr0 & 0x000000f0) >= 0x00000030)
2995 + (mmfr0 & 0x000000f0) >= 0x00000030) {
2996 cpu_arch = CPU_ARCH_ARMv7;
2997 - else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
2998 + if ((mmfr0 & 0x0000000f) == 0x00000005 || (mmfr0 & 0x0000000f) == 0x00000004) {
2999 + __supported_pte_mask |= L_PTE_PXN;
3000 + __supported_pmd_mask |= PMD_PXNTABLE;
3001 + }
3002 + } else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
3003 (mmfr0 & 0x000000f0) == 0x00000020)
3004 cpu_arch = CPU_ARCH_ARMv6;
3005 else
3006 @@ -571,7 +577,7 @@ static void __init setup_processor(void)
3007 __cpu_architecture = __get_cpu_architecture();
3008
3009 #ifdef MULTI_CPU
3010 - processor = *list->proc;
3011 + memcpy((void *)&processor, list->proc, sizeof processor);
3012 #endif
3013 #ifdef MULTI_TLB
3014 cpu_tlb = *list->tlb;
3015 diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c
3016 index ab33042..11248a8 100644
3017 --- a/arch/arm/kernel/signal.c
3018 +++ b/arch/arm/kernel/signal.c
3019 @@ -45,8 +45,6 @@ static const unsigned long sigreturn_codes[7] = {
3020 MOV_R7_NR_RT_SIGRETURN, SWI_SYS_RT_SIGRETURN, SWI_THUMB_RT_SIGRETURN,
3021 };
3022
3023 -static unsigned long signal_return_offset;
3024 -
3025 #ifdef CONFIG_CRUNCH
3026 static int preserve_crunch_context(struct crunch_sigframe __user *frame)
3027 {
3028 @@ -411,8 +409,7 @@ setup_return(struct pt_regs *regs, struct ksignal *ksig,
3029 * except when the MPU has protected the vectors
3030 * page from PL0
3031 */
3032 - retcode = mm->context.sigpage + signal_return_offset +
3033 - (idx << 2) + thumb;
3034 + retcode = mm->context.sigpage + (idx << 2) + thumb;
3035 } else
3036 #endif
3037 {
3038 @@ -616,33 +613,3 @@ do_work_pending(struct pt_regs *regs, unsigned int thread_flags, int syscall)
3039 } while (thread_flags & _TIF_WORK_MASK);
3040 return 0;
3041 }
3042 -
3043 -struct page *get_signal_page(void)
3044 -{
3045 - unsigned long ptr;
3046 - unsigned offset;
3047 - struct page *page;
3048 - void *addr;
3049 -
3050 - page = alloc_pages(GFP_KERNEL, 0);
3051 -
3052 - if (!page)
3053 - return NULL;
3054 -
3055 - addr = page_address(page);
3056 -
3057 - /* Give the signal return code some randomness */
3058 - offset = 0x200 + (get_random_int() & 0x7fc);
3059 - signal_return_offset = offset;
3060 -
3061 - /*
3062 - * Copy signal return handlers into the vector page, and
3063 - * set sigreturn to be a pointer to these.
3064 - */
3065 - memcpy(addr + offset, sigreturn_codes, sizeof(sigreturn_codes));
3066 -
3067 - ptr = (unsigned long)addr + offset;
3068 - flush_icache_range(ptr, ptr + sizeof(sigreturn_codes));
3069 -
3070 - return page;
3071 -}
3072 diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
3073 index 72024ea..ae302dd 100644
3074 --- a/arch/arm/kernel/smp.c
3075 +++ b/arch/arm/kernel/smp.c
3076 @@ -70,7 +70,7 @@ enum ipi_msg_type {
3077
3078 static DECLARE_COMPLETION(cpu_running);
3079
3080 -static struct smp_operations smp_ops;
3081 +static struct smp_operations smp_ops __read_only;
3082
3083 void __init smp_set_ops(struct smp_operations *ops)
3084 {
3085 diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
3086 index 65ed63f..430c478 100644
3087 --- a/arch/arm/kernel/traps.c
3088 +++ b/arch/arm/kernel/traps.c
3089 @@ -55,7 +55,7 @@ static void dump_mem(const char *, const char *, unsigned long, unsigned long);
3090 void dump_backtrace_entry(unsigned long where, unsigned long from, unsigned long frame)
3091 {
3092 #ifdef CONFIG_KALLSYMS
3093 - printk("[<%08lx>] (%pS) from [<%08lx>] (%pS)\n", where, (void *)where, from, (void *)from);
3094 + printk("[<%08lx>] (%pA) from [<%08lx>] (%pA)\n", where, (void *)where, from, (void *)from);
3095 #else
3096 printk("Function entered at [<%08lx>] from [<%08lx>]\n", where, from);
3097 #endif
3098 @@ -257,6 +257,8 @@ static arch_spinlock_t die_lock = __ARCH_SPIN_LOCK_UNLOCKED;
3099 static int die_owner = -1;
3100 static unsigned int die_nest_count;
3101
3102 +extern void gr_handle_kernel_exploit(void);
3103 +
3104 static unsigned long oops_begin(void)
3105 {
3106 int cpu;
3107 @@ -299,6 +301,9 @@ static void oops_end(unsigned long flags, struct pt_regs *regs, int signr)
3108 panic("Fatal exception in interrupt");
3109 if (panic_on_oops)
3110 panic("Fatal exception");
3111 +
3112 + gr_handle_kernel_exploit();
3113 +
3114 if (signr)
3115 do_exit(signr);
3116 }
3117 @@ -629,7 +634,9 @@ asmlinkage int arm_syscall(int no, struct pt_regs *regs)
3118 * The user helper at 0xffff0fe0 must be used instead.
3119 * (see entry-armv.S for details)
3120 */
3121 + pax_open_kernel();
3122 *((unsigned int *)0xffff0ff0) = regs->ARM_r0;
3123 + pax_close_kernel();
3124 }
3125 return 0;
3126
3127 @@ -886,7 +893,11 @@ void __init early_trap_init(void *vectors_base)
3128 kuser_init(vectors_base);
3129
3130 flush_icache_range(vectors, vectors + PAGE_SIZE * 2);
3131 - modify_domain(DOMAIN_USER, DOMAIN_CLIENT);
3132 +
3133 +#ifndef CONFIG_PAX_MEMORY_UDEREF
3134 + modify_domain(DOMAIN_USER, DOMAIN_USERCLIENT);
3135 +#endif
3136 +
3137 #else /* ifndef CONFIG_CPU_V7M */
3138 /*
3139 * on V7-M there is no need to copy the vector table to a dedicated
3140 diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S
3141 index 7bcee5c..e2f3249 100644
3142 --- a/arch/arm/kernel/vmlinux.lds.S
3143 +++ b/arch/arm/kernel/vmlinux.lds.S
3144 @@ -8,7 +8,11 @@
3145 #include <asm/thread_info.h>
3146 #include <asm/memory.h>
3147 #include <asm/page.h>
3148 -
3149 +
3150 +#ifdef CONFIG_PAX_KERNEXEC
3151 +#include <asm/pgtable.h>
3152 +#endif
3153 +
3154 #define PROC_INFO \
3155 . = ALIGN(4); \
3156 VMLINUX_SYMBOL(__proc_info_begin) = .; \
3157 @@ -34,7 +38,7 @@
3158 #endif
3159
3160 #if (defined(CONFIG_SMP_ON_UP) && !defined(CONFIG_DEBUG_SPINLOCK)) || \
3161 - defined(CONFIG_GENERIC_BUG)
3162 + defined(CONFIG_GENERIC_BUG) || defined(CONFIG_PAX_REFCOUNT)
3163 #define ARM_EXIT_KEEP(x) x
3164 #define ARM_EXIT_DISCARD(x)
3165 #else
3166 @@ -90,6 +94,11 @@ SECTIONS
3167 _text = .;
3168 HEAD_TEXT
3169 }
3170 +
3171 +#ifdef CONFIG_PAX_KERNEXEC
3172 + . = ALIGN(1<<SECTION_SHIFT);
3173 +#endif
3174 +
3175 .text : { /* Real text segment */
3176 _stext = .; /* Text and read-only data */
3177 __exception_text_start = .;
3178 @@ -112,6 +121,8 @@ SECTIONS
3179 ARM_CPU_KEEP(PROC_INFO)
3180 }
3181
3182 + _etext = .; /* End of text section */
3183 +
3184 RO_DATA(PAGE_SIZE)
3185
3186 . = ALIGN(4);
3187 @@ -142,7 +153,9 @@ SECTIONS
3188
3189 NOTES
3190
3191 - _etext = .; /* End of text and rodata section */
3192 +#ifdef CONFIG_PAX_KERNEXEC
3193 + . = ALIGN(1<<SECTION_SHIFT);
3194 +#endif
3195
3196 #ifndef CONFIG_XIP_KERNEL
3197 . = ALIGN(PAGE_SIZE);
3198 @@ -220,6 +233,11 @@ SECTIONS
3199 . = PAGE_OFFSET + TEXT_OFFSET;
3200 #else
3201 __init_end = .;
3202 +
3203 +#ifdef CONFIG_PAX_KERNEXEC
3204 + . = ALIGN(1<<SECTION_SHIFT);
3205 +#endif
3206 +
3207 . = ALIGN(THREAD_SIZE);
3208 __data_loc = .;
3209 #endif
3210 diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c
3211 index 9c697db..115237f 100644
3212 --- a/arch/arm/kvm/arm.c
3213 +++ b/arch/arm/kvm/arm.c
3214 @@ -56,7 +56,7 @@ static unsigned long hyp_default_vectors;
3215 static DEFINE_PER_CPU(struct kvm_vcpu *, kvm_arm_running_vcpu);
3216
3217 /* The VMID used in the VTTBR */
3218 -static atomic64_t kvm_vmid_gen = ATOMIC64_INIT(1);
3219 +static atomic64_unchecked_t kvm_vmid_gen = ATOMIC64_INIT(1);
3220 static u8 kvm_next_vmid;
3221 static DEFINE_SPINLOCK(kvm_vmid_lock);
3222
3223 @@ -396,7 +396,7 @@ void force_vm_exit(const cpumask_t *mask)
3224 */
3225 static bool need_new_vmid_gen(struct kvm *kvm)
3226 {
3227 - return unlikely(kvm->arch.vmid_gen != atomic64_read(&kvm_vmid_gen));
3228 + return unlikely(kvm->arch.vmid_gen != atomic64_read_unchecked(&kvm_vmid_gen));
3229 }
3230
3231 /**
3232 @@ -429,7 +429,7 @@ static void update_vttbr(struct kvm *kvm)
3233
3234 /* First user of a new VMID generation? */
3235 if (unlikely(kvm_next_vmid == 0)) {
3236 - atomic64_inc(&kvm_vmid_gen);
3237 + atomic64_inc_unchecked(&kvm_vmid_gen);
3238 kvm_next_vmid = 1;
3239
3240 /*
3241 @@ -446,7 +446,7 @@ static void update_vttbr(struct kvm *kvm)
3242 kvm_call_hyp(__kvm_flush_vm_context);
3243 }
3244
3245 - kvm->arch.vmid_gen = atomic64_read(&kvm_vmid_gen);
3246 + kvm->arch.vmid_gen = atomic64_read_unchecked(&kvm_vmid_gen);
3247 kvm->arch.vmid = kvm_next_vmid;
3248 kvm_next_vmid++;
3249
3250 diff --git a/arch/arm/lib/clear_user.S b/arch/arm/lib/clear_user.S
3251 index 14a0d98..7771a7d 100644
3252 --- a/arch/arm/lib/clear_user.S
3253 +++ b/arch/arm/lib/clear_user.S
3254 @@ -12,14 +12,14 @@
3255
3256 .text
3257
3258 -/* Prototype: int __clear_user(void *addr, size_t sz)
3259 +/* Prototype: int ___clear_user(void *addr, size_t sz)
3260 * Purpose : clear some user memory
3261 * Params : addr - user memory address to clear
3262 * : sz - number of bytes to clear
3263 * Returns : number of bytes NOT cleared
3264 */
3265 ENTRY(__clear_user_std)
3266 -WEAK(__clear_user)
3267 +WEAK(___clear_user)
3268 stmfd sp!, {r1, lr}
3269 mov r2, #0
3270 cmp r1, #4
3271 @@ -44,7 +44,7 @@ WEAK(__clear_user)
3272 USER( strnebt r2, [r0])
3273 mov r0, #0
3274 ldmfd sp!, {r1, pc}
3275 -ENDPROC(__clear_user)
3276 +ENDPROC(___clear_user)
3277 ENDPROC(__clear_user_std)
3278
3279 .pushsection .fixup,"ax"
3280 diff --git a/arch/arm/lib/copy_from_user.S b/arch/arm/lib/copy_from_user.S
3281 index 66a477a..bee61d3 100644
3282 --- a/arch/arm/lib/copy_from_user.S
3283 +++ b/arch/arm/lib/copy_from_user.S
3284 @@ -16,7 +16,7 @@
3285 /*
3286 * Prototype:
3287 *
3288 - * size_t __copy_from_user(void *to, const void *from, size_t n)
3289 + * size_t ___copy_from_user(void *to, const void *from, size_t n)
3290 *
3291 * Purpose:
3292 *
3293 @@ -84,11 +84,11 @@
3294
3295 .text
3296
3297 -ENTRY(__copy_from_user)
3298 +ENTRY(___copy_from_user)
3299
3300 #include "copy_template.S"
3301
3302 -ENDPROC(__copy_from_user)
3303 +ENDPROC(___copy_from_user)
3304
3305 .pushsection .fixup,"ax"
3306 .align 0
3307 diff --git a/arch/arm/lib/copy_page.S b/arch/arm/lib/copy_page.S
3308 index 6ee2f67..d1cce76 100644
3309 --- a/arch/arm/lib/copy_page.S
3310 +++ b/arch/arm/lib/copy_page.S
3311 @@ -10,6 +10,7 @@
3312 * ASM optimised string functions
3313 */
3314 #include <linux/linkage.h>
3315 +#include <linux/const.h>
3316 #include <asm/assembler.h>
3317 #include <asm/asm-offsets.h>
3318 #include <asm/cache.h>
3319 diff --git a/arch/arm/lib/copy_to_user.S b/arch/arm/lib/copy_to_user.S
3320 index d066df6..df28194 100644
3321 --- a/arch/arm/lib/copy_to_user.S
3322 +++ b/arch/arm/lib/copy_to_user.S
3323 @@ -16,7 +16,7 @@
3324 /*
3325 * Prototype:
3326 *
3327 - * size_t __copy_to_user(void *to, const void *from, size_t n)
3328 + * size_t ___copy_to_user(void *to, const void *from, size_t n)
3329 *
3330 * Purpose:
3331 *
3332 @@ -88,11 +88,11 @@
3333 .text
3334
3335 ENTRY(__copy_to_user_std)
3336 -WEAK(__copy_to_user)
3337 +WEAK(___copy_to_user)
3338
3339 #include "copy_template.S"
3340
3341 -ENDPROC(__copy_to_user)
3342 +ENDPROC(___copy_to_user)
3343 ENDPROC(__copy_to_user_std)
3344
3345 .pushsection .fixup,"ax"
3346 diff --git a/arch/arm/lib/csumpartialcopyuser.S b/arch/arm/lib/csumpartialcopyuser.S
3347 index 7d08b43..f7ca7ea 100644
3348 --- a/arch/arm/lib/csumpartialcopyuser.S
3349 +++ b/arch/arm/lib/csumpartialcopyuser.S
3350 @@ -57,8 +57,8 @@
3351 * Returns : r0 = checksum, [[sp, #0], #0] = 0 or -EFAULT
3352 */
3353
3354 -#define FN_ENTRY ENTRY(csum_partial_copy_from_user)
3355 -#define FN_EXIT ENDPROC(csum_partial_copy_from_user)
3356 +#define FN_ENTRY ENTRY(__csum_partial_copy_from_user)
3357 +#define FN_EXIT ENDPROC(__csum_partial_copy_from_user)
3358
3359 #include "csumpartialcopygeneric.S"
3360
3361 diff --git a/arch/arm/lib/delay.c b/arch/arm/lib/delay.c
3362 index 5306de3..aed6d03 100644
3363 --- a/arch/arm/lib/delay.c
3364 +++ b/arch/arm/lib/delay.c
3365 @@ -28,7 +28,7 @@
3366 /*
3367 * Default to the loop-based delay implementation.
3368 */
3369 -struct arm_delay_ops arm_delay_ops = {
3370 +struct arm_delay_ops arm_delay_ops __read_only = {
3371 .delay = __loop_delay,
3372 .const_udelay = __loop_const_udelay,
3373 .udelay = __loop_udelay,
3374 diff --git a/arch/arm/lib/uaccess_with_memcpy.c b/arch/arm/lib/uaccess_with_memcpy.c
3375 index 025f742..a9e5b3b 100644
3376 --- a/arch/arm/lib/uaccess_with_memcpy.c
3377 +++ b/arch/arm/lib/uaccess_with_memcpy.c
3378 @@ -104,7 +104,7 @@ out:
3379 }
3380
3381 unsigned long
3382 -__copy_to_user(void __user *to, const void *from, unsigned long n)
3383 +___copy_to_user(void __user *to, const void *from, unsigned long n)
3384 {
3385 /*
3386 * This test is stubbed out of the main function above to keep
3387 @@ -155,7 +155,7 @@ out:
3388 return n;
3389 }
3390
3391 -unsigned long __clear_user(void __user *addr, unsigned long n)
3392 +unsigned long ___clear_user(void __user *addr, unsigned long n)
3393 {
3394 /* See rational for this in __copy_to_user() above. */
3395 if (n < 64)
3396 diff --git a/arch/arm/mach-kirkwood/common.c b/arch/arm/mach-kirkwood/common.c
3397 index 1767611..d2e7e24 100644
3398 --- a/arch/arm/mach-kirkwood/common.c
3399 +++ b/arch/arm/mach-kirkwood/common.c
3400 @@ -156,7 +156,16 @@ static void clk_gate_fn_disable(struct clk_hw *hw)
3401 clk_gate_ops.disable(hw);
3402 }
3403
3404 -static struct clk_ops clk_gate_fn_ops;
3405 +static int clk_gate_fn_is_enabled(struct clk_hw *hw)
3406 +{
3407 + return clk_gate_ops.is_enabled(hw);
3408 +}
3409 +
3410 +static struct clk_ops clk_gate_fn_ops = {
3411 + .enable = clk_gate_fn_enable,
3412 + .disable = clk_gate_fn_disable,
3413 + .is_enabled = clk_gate_fn_is_enabled,
3414 +};
3415
3416 static struct clk __init *clk_register_gate_fn(struct device *dev,
3417 const char *name,
3418 @@ -190,14 +199,6 @@ static struct clk __init *clk_register_gate_fn(struct device *dev,
3419 gate_fn->fn_en = fn_en;
3420 gate_fn->fn_dis = fn_dis;
3421
3422 - /* ops is the gate ops, but with our enable/disable functions */
3423 - if (clk_gate_fn_ops.enable != clk_gate_fn_enable ||
3424 - clk_gate_fn_ops.disable != clk_gate_fn_disable) {
3425 - clk_gate_fn_ops = clk_gate_ops;
3426 - clk_gate_fn_ops.enable = clk_gate_fn_enable;
3427 - clk_gate_fn_ops.disable = clk_gate_fn_disable;
3428 - }
3429 -
3430 clk = clk_register(dev, &gate_fn->gate.hw);
3431
3432 if (IS_ERR(clk))
3433 diff --git a/arch/arm/mach-omap2/board-n8x0.c b/arch/arm/mach-omap2/board-n8x0.c
3434 index 827d1500..2885dc6 100644
3435 --- a/arch/arm/mach-omap2/board-n8x0.c
3436 +++ b/arch/arm/mach-omap2/board-n8x0.c
3437 @@ -627,7 +627,7 @@ static int n8x0_menelaus_late_init(struct device *dev)
3438 }
3439 #endif
3440
3441 -static struct menelaus_platform_data n8x0_menelaus_platform_data __initdata = {
3442 +static struct menelaus_platform_data n8x0_menelaus_platform_data __initconst = {
3443 .late_init = n8x0_menelaus_late_init,
3444 };
3445
3446 diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
3447 index 579697a..1d5a3b2 100644
3448 --- a/arch/arm/mach-omap2/gpmc.c
3449 +++ b/arch/arm/mach-omap2/gpmc.c
3450 @@ -148,7 +148,6 @@ struct omap3_gpmc_regs {
3451 };
3452
3453 static struct gpmc_client_irq gpmc_client_irq[GPMC_NR_IRQ];
3454 -static struct irq_chip gpmc_irq_chip;
3455 static int gpmc_irq_start;
3456
3457 static struct resource gpmc_mem_root;
3458 @@ -716,6 +715,18 @@ static void gpmc_irq_noop(struct irq_data *data) { }
3459
3460 static unsigned int gpmc_irq_noop_ret(struct irq_data *data) { return 0; }
3461
3462 +static struct irq_chip gpmc_irq_chip = {
3463 + .name = "gpmc",
3464 + .irq_startup = gpmc_irq_noop_ret,
3465 + .irq_enable = gpmc_irq_enable,
3466 + .irq_disable = gpmc_irq_disable,
3467 + .irq_shutdown = gpmc_irq_noop,
3468 + .irq_ack = gpmc_irq_noop,
3469 + .irq_mask = gpmc_irq_noop,
3470 + .irq_unmask = gpmc_irq_noop,
3471 +
3472 +};
3473 +
3474 static int gpmc_setup_irq(void)
3475 {
3476 int i;
3477 @@ -730,15 +741,6 @@ static int gpmc_setup_irq(void)
3478 return gpmc_irq_start;
3479 }
3480
3481 - gpmc_irq_chip.name = "gpmc";
3482 - gpmc_irq_chip.irq_startup = gpmc_irq_noop_ret;
3483 - gpmc_irq_chip.irq_enable = gpmc_irq_enable;
3484 - gpmc_irq_chip.irq_disable = gpmc_irq_disable;
3485 - gpmc_irq_chip.irq_shutdown = gpmc_irq_noop;
3486 - gpmc_irq_chip.irq_ack = gpmc_irq_noop;
3487 - gpmc_irq_chip.irq_mask = gpmc_irq_noop;
3488 - gpmc_irq_chip.irq_unmask = gpmc_irq_noop;
3489 -
3490 gpmc_client_irq[0].bitmask = GPMC_IRQ_FIFOEVENTENABLE;
3491 gpmc_client_irq[1].bitmask = GPMC_IRQ_COUNT_EVENT;
3492
3493 diff --git a/arch/arm/mach-omap2/omap-mpuss-lowpower.c b/arch/arm/mach-omap2/omap-mpuss-lowpower.c
3494 index f991016..145ebeb 100644
3495 --- a/arch/arm/mach-omap2/omap-mpuss-lowpower.c
3496 +++ b/arch/arm/mach-omap2/omap-mpuss-lowpower.c
3497 @@ -84,7 +84,7 @@ struct cpu_pm_ops {
3498 int (*finish_suspend)(unsigned long cpu_state);
3499 void (*resume)(void);
3500 void (*scu_prepare)(unsigned int cpu_id, unsigned int cpu_state);
3501 -};
3502 +} __no_const;
3503
3504 static DEFINE_PER_CPU(struct omap4_cpu_pm_info, omap4_pm_info);
3505 static struct powerdomain *mpuss_pd;
3506 @@ -102,7 +102,7 @@ static void dummy_cpu_resume(void)
3507 static void dummy_scu_prepare(unsigned int cpu_id, unsigned int cpu_state)
3508 {}
3509
3510 -struct cpu_pm_ops omap_pm_ops = {
3511 +static struct cpu_pm_ops omap_pm_ops __read_only = {
3512 .finish_suspend = default_finish_suspend,
3513 .resume = dummy_cpu_resume,
3514 .scu_prepare = dummy_scu_prepare,
3515 diff --git a/arch/arm/mach-omap2/omap-wakeupgen.c b/arch/arm/mach-omap2/omap-wakeupgen.c
3516 index 813c615..ce467c6 100644
3517 --- a/arch/arm/mach-omap2/omap-wakeupgen.c
3518 +++ b/arch/arm/mach-omap2/omap-wakeupgen.c
3519 @@ -339,7 +339,7 @@ static int irq_cpu_hotplug_notify(struct notifier_block *self,
3520 return NOTIFY_OK;
3521 }
3522
3523 -static struct notifier_block __refdata irq_hotplug_notifier = {
3524 +static struct notifier_block irq_hotplug_notifier = {
3525 .notifier_call = irq_cpu_hotplug_notify,
3526 };
3527
3528 diff --git a/arch/arm/mach-omap2/omap_device.c b/arch/arm/mach-omap2/omap_device.c
3529 index 53f0735..5b54eb6 100644
3530 --- a/arch/arm/mach-omap2/omap_device.c
3531 +++ b/arch/arm/mach-omap2/omap_device.c
3532 @@ -504,7 +504,7 @@ void omap_device_delete(struct omap_device *od)
3533 struct platform_device __init *omap_device_build(const char *pdev_name,
3534 int pdev_id,
3535 struct omap_hwmod *oh,
3536 - void *pdata, int pdata_len)
3537 + const void *pdata, int pdata_len)
3538 {
3539 struct omap_hwmod *ohs[] = { oh };
3540
3541 @@ -532,7 +532,7 @@ struct platform_device __init *omap_device_build(const char *pdev_name,
3542 struct platform_device __init *omap_device_build_ss(const char *pdev_name,
3543 int pdev_id,
3544 struct omap_hwmod **ohs,
3545 - int oh_cnt, void *pdata,
3546 + int oh_cnt, const void *pdata,
3547 int pdata_len)
3548 {
3549 int ret = -ENOMEM;
3550 diff --git a/arch/arm/mach-omap2/omap_device.h b/arch/arm/mach-omap2/omap_device.h
3551 index 17ca1ae..beba869 100644
3552 --- a/arch/arm/mach-omap2/omap_device.h
3553 +++ b/arch/arm/mach-omap2/omap_device.h
3554 @@ -71,12 +71,12 @@ int omap_device_idle(struct platform_device *pdev);
3555 /* Core code interface */
3556
3557 struct platform_device *omap_device_build(const char *pdev_name, int pdev_id,
3558 - struct omap_hwmod *oh, void *pdata,
3559 + struct omap_hwmod *oh, const void *pdata,
3560 int pdata_len);
3561
3562 struct platform_device *omap_device_build_ss(const char *pdev_name, int pdev_id,
3563 struct omap_hwmod **oh, int oh_cnt,
3564 - void *pdata, int pdata_len);
3565 + const void *pdata, int pdata_len);
3566
3567 struct omap_device *omap_device_alloc(struct platform_device *pdev,
3568 struct omap_hwmod **ohs, int oh_cnt);
3569 diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
3570 index 832adb1..49b62c4 100644
3571 --- a/arch/arm/mach-omap2/omap_hwmod.c
3572 +++ b/arch/arm/mach-omap2/omap_hwmod.c
3573 @@ -194,10 +194,10 @@ struct omap_hwmod_soc_ops {
3574 int (*init_clkdm)(struct omap_hwmod *oh);
3575 void (*update_context_lost)(struct omap_hwmod *oh);
3576 int (*get_context_lost)(struct omap_hwmod *oh);
3577 -};
3578 +} __no_const;
3579
3580 /* soc_ops: adapts the omap_hwmod code to the currently-booted SoC */
3581 -static struct omap_hwmod_soc_ops soc_ops;
3582 +static struct omap_hwmod_soc_ops soc_ops __read_only;
3583
3584 /* omap_hwmod_list contains all registered struct omap_hwmods */
3585 static LIST_HEAD(omap_hwmod_list);
3586 diff --git a/arch/arm/mach-omap2/wd_timer.c b/arch/arm/mach-omap2/wd_timer.c
3587 index d15c7bb..b2d1f0c 100644
3588 --- a/arch/arm/mach-omap2/wd_timer.c
3589 +++ b/arch/arm/mach-omap2/wd_timer.c
3590 @@ -110,7 +110,9 @@ static int __init omap_init_wdt(void)
3591 struct omap_hwmod *oh;
3592 char *oh_name = "wd_timer2";
3593 char *dev_name = "omap_wdt";
3594 - struct omap_wd_timer_platform_data pdata;
3595 + static struct omap_wd_timer_platform_data pdata = {
3596 + .read_reset_sources = prm_read_reset_sources
3597 + };
3598
3599 if (!cpu_class_is_omap2() || of_have_populated_dt())
3600 return 0;
3601 @@ -121,8 +123,6 @@ static int __init omap_init_wdt(void)
3602 return -EINVAL;
3603 }
3604
3605 - pdata.read_reset_sources = prm_read_reset_sources;
3606 -
3607 pdev = omap_device_build(dev_name, id, oh, &pdata,
3608 sizeof(struct omap_wd_timer_platform_data));
3609 WARN(IS_ERR(pdev), "Can't build omap_device for %s:%s.\n",
3610 diff --git a/arch/arm/mach-tegra/cpuidle-tegra20.c b/arch/arm/mach-tegra/cpuidle-tegra20.c
3611 index b82dcae..44ee5b6 100644
3612 --- a/arch/arm/mach-tegra/cpuidle-tegra20.c
3613 +++ b/arch/arm/mach-tegra/cpuidle-tegra20.c
3614 @@ -180,7 +180,7 @@ static int tegra20_idle_lp2_coupled(struct cpuidle_device *dev,
3615 bool entered_lp2 = false;
3616
3617 if (tegra_pending_sgi())
3618 - ACCESS_ONCE(abort_flag) = true;
3619 + ACCESS_ONCE_RW(abort_flag) = true;
3620
3621 cpuidle_coupled_parallel_barrier(dev, &abort_barrier);
3622
3623 diff --git a/arch/arm/mach-ux500/setup.h b/arch/arm/mach-ux500/setup.h
3624 index 656324a..0beba28 100644
3625 --- a/arch/arm/mach-ux500/setup.h
3626 +++ b/arch/arm/mach-ux500/setup.h
3627 @@ -40,13 +40,6 @@ extern void ux500_timer_init(void);
3628 .type = MT_DEVICE, \
3629 }
3630
3631 -#define __MEM_DEV_DESC(x, sz) { \
3632 - .virtual = IO_ADDRESS(x), \
3633 - .pfn = __phys_to_pfn(x), \
3634 - .length = sz, \
3635 - .type = MT_MEMORY, \
3636 -}
3637 -
3638 extern struct smp_operations ux500_smp_ops;
3639 extern void ux500_cpu_die(unsigned int cpu);
3640
3641 diff --git a/arch/arm/mm/Kconfig b/arch/arm/mm/Kconfig
3642 index cd2c88e..4dd9b67 100644
3643 --- a/arch/arm/mm/Kconfig
3644 +++ b/arch/arm/mm/Kconfig
3645 @@ -446,7 +446,7 @@ config CPU_32v5
3646
3647 config CPU_32v6
3648 bool
3649 - select CPU_USE_DOMAINS if CPU_V6 && MMU
3650 + select CPU_USE_DOMAINS if CPU_V6 && MMU && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
3651 select TLS_REG_EMUL if !CPU_32v6K && !MMU
3652
3653 config CPU_32v6K
3654 @@ -601,6 +601,7 @@ config CPU_CP15_MPU
3655
3656 config CPU_USE_DOMAINS
3657 bool
3658 + depends on !ARM_LPAE && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
3659 help
3660 This option enables or disables the use of domain switching
3661 via the set_fs() function.
3662 @@ -800,6 +801,7 @@ config NEED_KUSER_HELPERS
3663 config KUSER_HELPERS
3664 bool "Enable kuser helpers in vector page" if !NEED_KUSER_HELPERS
3665 default y
3666 + depends on !(CPU_V6 || CPU_V6K || CPU_V7) || GRKERNSEC_OLD_ARM_USERLAND
3667 help
3668 Warning: disabling this option may break user programs.
3669
3670 @@ -812,7 +814,7 @@ config KUSER_HELPERS
3671 See Documentation/arm/kernel_user_helpers.txt for details.
3672
3673 However, the fixed address nature of these helpers can be used
3674 - by ROP (return orientated programming) authors when creating
3675 + by ROP (Return Oriented Programming) authors when creating
3676 exploits.
3677
3678 If all of the binaries and libraries which run on your platform
3679 diff --git a/arch/arm/mm/alignment.c b/arch/arm/mm/alignment.c
3680 index 6f4585b..7b6f52b 100644
3681 --- a/arch/arm/mm/alignment.c
3682 +++ b/arch/arm/mm/alignment.c
3683 @@ -211,10 +211,12 @@ union offset_union {
3684 #define __get16_unaligned_check(ins,val,addr) \
3685 do { \
3686 unsigned int err = 0, v, a = addr; \
3687 + pax_open_userland(); \
3688 __get8_unaligned_check(ins,v,a,err); \
3689 val = v << ((BE) ? 8 : 0); \
3690 __get8_unaligned_check(ins,v,a,err); \
3691 val |= v << ((BE) ? 0 : 8); \
3692 + pax_close_userland(); \
3693 if (err) \
3694 goto fault; \
3695 } while (0)
3696 @@ -228,6 +230,7 @@ union offset_union {
3697 #define __get32_unaligned_check(ins,val,addr) \
3698 do { \
3699 unsigned int err = 0, v, a = addr; \
3700 + pax_open_userland(); \
3701 __get8_unaligned_check(ins,v,a,err); \
3702 val = v << ((BE) ? 24 : 0); \
3703 __get8_unaligned_check(ins,v,a,err); \
3704 @@ -236,6 +239,7 @@ union offset_union {
3705 val |= v << ((BE) ? 8 : 16); \
3706 __get8_unaligned_check(ins,v,a,err); \
3707 val |= v << ((BE) ? 0 : 24); \
3708 + pax_close_userland(); \
3709 if (err) \
3710 goto fault; \
3711 } while (0)
3712 @@ -249,6 +253,7 @@ union offset_union {
3713 #define __put16_unaligned_check(ins,val,addr) \
3714 do { \
3715 unsigned int err = 0, v = val, a = addr; \
3716 + pax_open_userland(); \
3717 __asm__( FIRST_BYTE_16 \
3718 ARM( "1: "ins" %1, [%2], #1\n" ) \
3719 THUMB( "1: "ins" %1, [%2]\n" ) \
3720 @@ -268,6 +273,7 @@ union offset_union {
3721 " .popsection\n" \
3722 : "=r" (err), "=&r" (v), "=&r" (a) \
3723 : "0" (err), "1" (v), "2" (a)); \
3724 + pax_close_userland(); \
3725 if (err) \
3726 goto fault; \
3727 } while (0)
3728 @@ -281,6 +287,7 @@ union offset_union {
3729 #define __put32_unaligned_check(ins,val,addr) \
3730 do { \
3731 unsigned int err = 0, v = val, a = addr; \
3732 + pax_open_userland(); \
3733 __asm__( FIRST_BYTE_32 \
3734 ARM( "1: "ins" %1, [%2], #1\n" ) \
3735 THUMB( "1: "ins" %1, [%2]\n" ) \
3736 @@ -310,6 +317,7 @@ union offset_union {
3737 " .popsection\n" \
3738 : "=r" (err), "=&r" (v), "=&r" (a) \
3739 : "0" (err), "1" (v), "2" (a)); \
3740 + pax_close_userland(); \
3741 if (err) \
3742 goto fault; \
3743 } while (0)
3744 diff --git a/arch/arm/mm/cache-l2x0.c b/arch/arm/mm/cache-l2x0.c
3745 index 447da6f..77a5057 100644
3746 --- a/arch/arm/mm/cache-l2x0.c
3747 +++ b/arch/arm/mm/cache-l2x0.c
3748 @@ -45,7 +45,7 @@ struct l2x0_of_data {
3749 void (*setup)(const struct device_node *, u32 *, u32 *);
3750 void (*save)(void);
3751 struct outer_cache_fns outer_cache;
3752 -};
3753 +} __do_const;
3754
3755 static bool of_init = false;
3756
3757 diff --git a/arch/arm/mm/context.c b/arch/arm/mm/context.c
3758 index 84e6f77..0b52f31 100644
3759 --- a/arch/arm/mm/context.c
3760 +++ b/arch/arm/mm/context.c
3761 @@ -43,7 +43,7 @@
3762 #define NUM_USER_ASIDS ASID_FIRST_VERSION
3763
3764 static DEFINE_RAW_SPINLOCK(cpu_asid_lock);
3765 -static atomic64_t asid_generation = ATOMIC64_INIT(ASID_FIRST_VERSION);
3766 +static atomic64_unchecked_t asid_generation = ATOMIC64_INIT(ASID_FIRST_VERSION);
3767 static DECLARE_BITMAP(asid_map, NUM_USER_ASIDS);
3768
3769 static DEFINE_PER_CPU(atomic64_t, active_asids);
3770 @@ -180,7 +180,7 @@ static int is_reserved_asid(u64 asid)
3771 static u64 new_context(struct mm_struct *mm, unsigned int cpu)
3772 {
3773 u64 asid = atomic64_read(&mm->context.id);
3774 - u64 generation = atomic64_read(&asid_generation);
3775 + u64 generation = atomic64_read_unchecked(&asid_generation);
3776
3777 if (asid != 0 && is_reserved_asid(asid)) {
3778 /*
3779 @@ -198,7 +198,7 @@ static u64 new_context(struct mm_struct *mm, unsigned int cpu)
3780 */
3781 asid = find_next_zero_bit(asid_map, NUM_USER_ASIDS, 1);
3782 if (asid == NUM_USER_ASIDS) {
3783 - generation = atomic64_add_return(ASID_FIRST_VERSION,
3784 + generation = atomic64_add_return_unchecked(ASID_FIRST_VERSION,
3785 &asid_generation);
3786 flush_context(cpu);
3787 asid = find_next_zero_bit(asid_map, NUM_USER_ASIDS, 1);
3788 @@ -227,14 +227,14 @@ void check_and_switch_context(struct mm_struct *mm, struct task_struct *tsk)
3789 cpu_set_reserved_ttbr0();
3790
3791 asid = atomic64_read(&mm->context.id);
3792 - if (!((asid ^ atomic64_read(&asid_generation)) >> ASID_BITS)
3793 + if (!((asid ^ atomic64_read_unchecked(&asid_generation)) >> ASID_BITS)
3794 && atomic64_xchg(&per_cpu(active_asids, cpu), asid))
3795 goto switch_mm_fastpath;
3796
3797 raw_spin_lock_irqsave(&cpu_asid_lock, flags);
3798 /* Check that our ASID belongs to the current generation. */
3799 asid = atomic64_read(&mm->context.id);
3800 - if ((asid ^ atomic64_read(&asid_generation)) >> ASID_BITS) {
3801 + if ((asid ^ atomic64_read_unchecked(&asid_generation)) >> ASID_BITS) {
3802 asid = new_context(mm, cpu);
3803 atomic64_set(&mm->context.id, asid);
3804 }
3805 diff --git a/arch/arm/mm/fault.c b/arch/arm/mm/fault.c
3806 index eb8830a..5360ce7 100644
3807 --- a/arch/arm/mm/fault.c
3808 +++ b/arch/arm/mm/fault.c
3809 @@ -25,6 +25,7 @@
3810 #include <asm/system_misc.h>
3811 #include <asm/system_info.h>
3812 #include <asm/tlbflush.h>
3813 +#include <asm/sections.h>
3814
3815 #include "fault.h"
3816
3817 @@ -138,6 +139,31 @@ __do_kernel_fault(struct mm_struct *mm, unsigned long addr, unsigned int fsr,
3818 if (fixup_exception(regs))
3819 return;
3820
3821 +#ifdef CONFIG_PAX_MEMORY_UDEREF
3822 + if (addr < TASK_SIZE) {
3823 + if (current->signal->curr_ip)
3824 + 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),
3825 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3826 + else
3827 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to access userland memory at %08lx\n", current->comm, task_pid_nr(current),
3828 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3829 + }
3830 +#endif
3831 +
3832 +#ifdef CONFIG_PAX_KERNEXEC
3833 + if ((fsr & FSR_WRITE) &&
3834 + (((unsigned long)_stext <= addr && addr < init_mm.end_code) ||
3835 + (MODULES_VADDR <= addr && addr < MODULES_END)))
3836 + {
3837 + if (current->signal->curr_ip)
3838 + 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),
3839 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
3840 + else
3841 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
3842 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
3843 + }
3844 +#endif
3845 +
3846 /*
3847 * No handler, we'll have to terminate things with extreme prejudice.
3848 */
3849 @@ -174,6 +200,13 @@ __do_user_fault(struct task_struct *tsk, unsigned long addr,
3850 }
3851 #endif
3852
3853 +#ifdef CONFIG_PAX_PAGEEXEC
3854 + if (fsr & FSR_LNX_PF) {
3855 + pax_report_fault(regs, (void *)regs->ARM_pc, (void *)regs->ARM_sp);
3856 + do_group_exit(SIGKILL);
3857 + }
3858 +#endif
3859 +
3860 tsk->thread.address = addr;
3861 tsk->thread.error_code = fsr;
3862 tsk->thread.trap_no = 14;
3863 @@ -401,6 +434,33 @@ do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
3864 }
3865 #endif /* CONFIG_MMU */
3866
3867 +#ifdef CONFIG_PAX_PAGEEXEC
3868 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
3869 +{
3870 + long i;
3871 +
3872 + printk(KERN_ERR "PAX: bytes at PC: ");
3873 + for (i = 0; i < 20; i++) {
3874 + unsigned char c;
3875 + if (get_user(c, (__force unsigned char __user *)pc+i))
3876 + printk(KERN_CONT "?? ");
3877 + else
3878 + printk(KERN_CONT "%02x ", c);
3879 + }
3880 + printk("\n");
3881 +
3882 + printk(KERN_ERR "PAX: bytes at SP-4: ");
3883 + for (i = -1; i < 20; i++) {
3884 + unsigned long c;
3885 + if (get_user(c, (__force unsigned long __user *)sp+i))
3886 + printk(KERN_CONT "???????? ");
3887 + else
3888 + printk(KERN_CONT "%08lx ", c);
3889 + }
3890 + printk("\n");
3891 +}
3892 +#endif
3893 +
3894 /*
3895 * First Level Translation Fault Handler
3896 *
3897 @@ -548,9 +608,22 @@ do_DataAbort(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
3898 const struct fsr_info *inf = fsr_info + fsr_fs(fsr);
3899 struct siginfo info;
3900
3901 +#ifdef CONFIG_PAX_MEMORY_UDEREF
3902 + if (addr < TASK_SIZE && is_domain_fault(fsr)) {
3903 + if (current->signal->curr_ip)
3904 + 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),
3905 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3906 + else
3907 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to access userland memory at %08lx\n", current->comm, task_pid_nr(current),
3908 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3909 + goto die;
3910 + }
3911 +#endif
3912 +
3913 if (!inf->fn(addr, fsr & ~FSR_LNX_PF, regs))
3914 return;
3915
3916 +die:
3917 printk(KERN_ALERT "Unhandled fault: %s (0x%03x) at 0x%08lx\n",
3918 inf->name, fsr, addr);
3919
3920 @@ -574,15 +647,98 @@ hook_ifault_code(int nr, int (*fn)(unsigned long, unsigned int, struct pt_regs *
3921 ifsr_info[nr].name = name;
3922 }
3923
3924 +asmlinkage int sys_sigreturn(struct pt_regs *regs);
3925 +asmlinkage int sys_rt_sigreturn(struct pt_regs *regs);
3926 +
3927 asmlinkage void __exception
3928 do_PrefetchAbort(unsigned long addr, unsigned int ifsr, struct pt_regs *regs)
3929 {
3930 const struct fsr_info *inf = ifsr_info + fsr_fs(ifsr);
3931 struct siginfo info;
3932 + unsigned long pc = instruction_pointer(regs);
3933 +
3934 + if (user_mode(regs)) {
3935 + unsigned long sigpage = current->mm->context.sigpage;
3936 +
3937 + if (sigpage <= pc && pc < sigpage + 7*4) {
3938 + if (pc < sigpage + 3*4)
3939 + sys_sigreturn(regs);
3940 + else
3941 + sys_rt_sigreturn(regs);
3942 + return;
3943 + }
3944 + if (pc == 0xffff0f60UL) {
3945 + /*
3946 + * PaX: __kuser_cmpxchg64 emulation
3947 + */
3948 + // TODO
3949 + //regs->ARM_pc = regs->ARM_lr;
3950 + //return;
3951 + }
3952 + if (pc == 0xffff0fa0UL) {
3953 + /*
3954 + * PaX: __kuser_memory_barrier emulation
3955 + */
3956 + // dmb(); implied by the exception
3957 + regs->ARM_pc = regs->ARM_lr;
3958 + return;
3959 + }
3960 + if (pc == 0xffff0fc0UL) {
3961 + /*
3962 + * PaX: __kuser_cmpxchg emulation
3963 + */
3964 + // TODO
3965 + //long new;
3966 + //int op;
3967 +
3968 + //op = FUTEX_OP_SET << 28;
3969 + //new = futex_atomic_op_inuser(op, regs->ARM_r2);
3970 + //regs->ARM_r0 = old != new;
3971 + //regs->ARM_pc = regs->ARM_lr;
3972 + //return;
3973 + }
3974 + if (pc == 0xffff0fe0UL) {
3975 + /*
3976 + * PaX: __kuser_get_tls emulation
3977 + */
3978 + regs->ARM_r0 = current_thread_info()->tp_value[0];
3979 + regs->ARM_pc = regs->ARM_lr;
3980 + return;
3981 + }
3982 + }
3983 +
3984 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
3985 + else if (is_domain_fault(ifsr) || is_xn_fault(ifsr)) {
3986 + if (current->signal->curr_ip)
3987 + 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),
3988 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()),
3989 + pc >= TASK_SIZE ? "non-executable kernel" : "userland", pc);
3990 + else
3991 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to execute %s memory at %08lx\n", current->comm, task_pid_nr(current),
3992 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()),
3993 + pc >= TASK_SIZE ? "non-executable kernel" : "userland", pc);
3994 + goto die;
3995 + }
3996 +#endif
3997 +
3998 +#ifdef CONFIG_PAX_REFCOUNT
3999 + if (fsr_fs(ifsr) == FAULT_CODE_DEBUG) {
4000 + unsigned int bkpt;
4001 +
4002 + if (!probe_kernel_address(pc, bkpt) && cpu_to_le32(bkpt) == 0xe12f1073) {
4003 + current->thread.error_code = ifsr;
4004 + current->thread.trap_no = 0;
4005 + pax_report_refcount_overflow(regs);
4006 + fixup_exception(regs);
4007 + return;
4008 + }
4009 + }
4010 +#endif
4011
4012 if (!inf->fn(addr, ifsr | FSR_LNX_PF, regs))
4013 return;
4014
4015 +die:
4016 printk(KERN_ALERT "Unhandled prefetch abort: %s (0x%03x) at 0x%08lx\n",
4017 inf->name, ifsr, addr);
4018
4019 diff --git a/arch/arm/mm/fault.h b/arch/arm/mm/fault.h
4020 index cf08bdf..772656c 100644
4021 --- a/arch/arm/mm/fault.h
4022 +++ b/arch/arm/mm/fault.h
4023 @@ -3,6 +3,7 @@
4024
4025 /*
4026 * Fault status register encodings. We steal bit 31 for our own purposes.
4027 + * Set when the FSR value is from an instruction fault.
4028 */
4029 #define FSR_LNX_PF (1 << 31)
4030 #define FSR_WRITE (1 << 11)
4031 @@ -22,6 +23,17 @@ static inline int fsr_fs(unsigned int fsr)
4032 }
4033 #endif
4034
4035 +/* valid for LPAE and !LPAE */
4036 +static inline int is_xn_fault(unsigned int fsr)
4037 +{
4038 + return ((fsr_fs(fsr) & 0x3c) == 0xc);
4039 +}
4040 +
4041 +static inline int is_domain_fault(unsigned int fsr)
4042 +{
4043 + return ((fsr_fs(fsr) & 0xD) == 0x9);
4044 +}
4045 +
4046 void do_bad_area(unsigned long addr, unsigned int fsr, struct pt_regs *regs);
4047 unsigned long search_exception_table(unsigned long addr);
4048
4049 diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
4050 index 18ec4c5..479bb6a 100644
4051 --- a/arch/arm/mm/init.c
4052 +++ b/arch/arm/mm/init.c
4053 @@ -30,6 +30,8 @@
4054 #include <asm/setup.h>
4055 #include <asm/tlb.h>
4056 #include <asm/fixmap.h>
4057 +#include <asm/system_info.h>
4058 +#include <asm/cp15.h>
4059
4060 #include <asm/mach/arch.h>
4061 #include <asm/mach/map.h>
4062 @@ -684,7 +686,46 @@ void free_initmem(void)
4063 {
4064 #ifdef CONFIG_HAVE_TCM
4065 extern char __tcm_start, __tcm_end;
4066 +#endif
4067
4068 +#ifdef CONFIG_PAX_KERNEXEC
4069 + unsigned long addr;
4070 + pgd_t *pgd;
4071 + pud_t *pud;
4072 + pmd_t *pmd;
4073 + int cpu_arch = cpu_architecture();
4074 + unsigned int cr = get_cr();
4075 +
4076 + if (cpu_arch >= CPU_ARCH_ARMv6 && (cr & CR_XP)) {
4077 + /* make pages tables, etc before .text NX */
4078 + for (addr = PAGE_OFFSET; addr < (unsigned long)_stext; addr += SECTION_SIZE) {
4079 + pgd = pgd_offset_k(addr);
4080 + pud = pud_offset(pgd, addr);
4081 + pmd = pmd_offset(pud, addr);
4082 + __section_update(pmd, addr, PMD_SECT_XN);
4083 + }
4084 + /* make init NX */
4085 + for (addr = (unsigned long)__init_begin; addr < (unsigned long)_sdata; addr += SECTION_SIZE) {
4086 + pgd = pgd_offset_k(addr);
4087 + pud = pud_offset(pgd, addr);
4088 + pmd = pmd_offset(pud, addr);
4089 + __section_update(pmd, addr, PMD_SECT_XN);
4090 + }
4091 + /* make kernel code/rodata RX */
4092 + for (addr = (unsigned long)_stext; addr < (unsigned long)__init_begin; addr += SECTION_SIZE) {
4093 + pgd = pgd_offset_k(addr);
4094 + pud = pud_offset(pgd, addr);
4095 + pmd = pmd_offset(pud, addr);
4096 +#ifdef CONFIG_ARM_LPAE
4097 + __section_update(pmd, addr, PMD_SECT_RDONLY);
4098 +#else
4099 + __section_update(pmd, addr, PMD_SECT_APX|PMD_SECT_AP_WRITE);
4100 +#endif
4101 + }
4102 + }
4103 +#endif
4104 +
4105 +#ifdef CONFIG_HAVE_TCM
4106 poison_init_mem(&__tcm_start, &__tcm_end - &__tcm_start);
4107 free_reserved_area(&__tcm_start, &__tcm_end, -1, "TCM link");
4108 #endif
4109 diff --git a/arch/arm/mm/ioremap.c b/arch/arm/mm/ioremap.c
4110 index f123d6e..04bf569 100644
4111 --- a/arch/arm/mm/ioremap.c
4112 +++ b/arch/arm/mm/ioremap.c
4113 @@ -392,9 +392,9 @@ __arm_ioremap_exec(phys_addr_t phys_addr, size_t size, bool cached)
4114 unsigned int mtype;
4115
4116 if (cached)
4117 - mtype = MT_MEMORY;
4118 + mtype = MT_MEMORY_RX;
4119 else
4120 - mtype = MT_MEMORY_NONCACHED;
4121 + mtype = MT_MEMORY_NONCACHED_RX;
4122
4123 return __arm_ioremap_caller(phys_addr, size, mtype,
4124 __builtin_return_address(0));
4125 diff --git a/arch/arm/mm/mmap.c b/arch/arm/mm/mmap.c
4126 index 304661d..53a6b19 100644
4127 --- a/arch/arm/mm/mmap.c
4128 +++ b/arch/arm/mm/mmap.c
4129 @@ -59,6 +59,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4130 struct vm_area_struct *vma;
4131 int do_align = 0;
4132 int aliasing = cache_is_vipt_aliasing();
4133 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
4134 struct vm_unmapped_area_info info;
4135
4136 /*
4137 @@ -81,6 +82,10 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4138 if (len > TASK_SIZE)
4139 return -ENOMEM;
4140
4141 +#ifdef CONFIG_PAX_RANDMMAP
4142 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4143 +#endif
4144 +
4145 if (addr) {
4146 if (do_align)
4147 addr = COLOUR_ALIGN(addr, pgoff);
4148 @@ -88,8 +93,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4149 addr = PAGE_ALIGN(addr);
4150
4151 vma = find_vma(mm, addr);
4152 - if (TASK_SIZE - len >= addr &&
4153 - (!vma || addr + len <= vma->vm_start))
4154 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4155 return addr;
4156 }
4157
4158 @@ -99,6 +103,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4159 info.high_limit = TASK_SIZE;
4160 info.align_mask = do_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
4161 info.align_offset = pgoff << PAGE_SHIFT;
4162 + info.threadstack_offset = offset;
4163 return vm_unmapped_area(&info);
4164 }
4165
4166 @@ -112,6 +117,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4167 unsigned long addr = addr0;
4168 int do_align = 0;
4169 int aliasing = cache_is_vipt_aliasing();
4170 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
4171 struct vm_unmapped_area_info info;
4172
4173 /*
4174 @@ -132,6 +138,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4175 return addr;
4176 }
4177
4178 +#ifdef CONFIG_PAX_RANDMMAP
4179 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4180 +#endif
4181 +
4182 /* requesting a specific address */
4183 if (addr) {
4184 if (do_align)
4185 @@ -139,8 +149,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4186 else
4187 addr = PAGE_ALIGN(addr);
4188 vma = find_vma(mm, addr);
4189 - if (TASK_SIZE - len >= addr &&
4190 - (!vma || addr + len <= vma->vm_start))
4191 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4192 return addr;
4193 }
4194
4195 @@ -150,6 +159,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4196 info.high_limit = mm->mmap_base;
4197 info.align_mask = do_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
4198 info.align_offset = pgoff << PAGE_SHIFT;
4199 + info.threadstack_offset = offset;
4200 addr = vm_unmapped_area(&info);
4201
4202 /*
4203 @@ -173,6 +183,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
4204 {
4205 unsigned long random_factor = 0UL;
4206
4207 +#ifdef CONFIG_PAX_RANDMMAP
4208 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4209 +#endif
4210 +
4211 /* 8 bits of randomness in 20 address space bits */
4212 if ((current->flags & PF_RANDOMIZE) &&
4213 !(current->personality & ADDR_NO_RANDOMIZE))
4214 @@ -180,9 +194,21 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
4215
4216 if (mmap_is_legacy()) {
4217 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
4218 +
4219 +#ifdef CONFIG_PAX_RANDMMAP
4220 + if (mm->pax_flags & MF_PAX_RANDMMAP)
4221 + mm->mmap_base += mm->delta_mmap;
4222 +#endif
4223 +
4224 mm->get_unmapped_area = arch_get_unmapped_area;
4225 } else {
4226 mm->mmap_base = mmap_base(random_factor);
4227 +
4228 +#ifdef CONFIG_PAX_RANDMMAP
4229 + if (mm->pax_flags & MF_PAX_RANDMMAP)
4230 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
4231 +#endif
4232 +
4233 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
4234 }
4235 }
4236 diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
4237 index b1d17ee..7a6f4d3 100644
4238 --- a/arch/arm/mm/mmu.c
4239 +++ b/arch/arm/mm/mmu.c
4240 @@ -36,6 +36,22 @@
4241 #include "mm.h"
4242 #include "tcm.h"
4243
4244 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
4245 +void modify_domain(unsigned int dom, unsigned int type)
4246 +{
4247 + struct thread_info *thread = current_thread_info();
4248 + unsigned int domain = thread->cpu_domain;
4249 + /*
4250 + * DOMAIN_MANAGER might be defined to some other value,
4251 + * use the arch-defined constant
4252 + */
4253 + domain &= ~domain_val(dom, 3);
4254 + thread->cpu_domain = domain | domain_val(dom, type);
4255 + set_domain(thread->cpu_domain);
4256 +}
4257 +EXPORT_SYMBOL(modify_domain);
4258 +#endif
4259 +
4260 /*
4261 * empty_zero_page is a special page that is used for
4262 * zero-initialized data and COW.
4263 @@ -228,10 +244,18 @@ __setup("noalign", noalign_setup);
4264
4265 #endif /* ifdef CONFIG_CPU_CP15 / else */
4266
4267 -#define PROT_PTE_DEVICE L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY|L_PTE_XN
4268 +#define PROT_PTE_DEVICE L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY
4269 #define PROT_SECT_DEVICE PMD_TYPE_SECT|PMD_SECT_AP_WRITE
4270
4271 -static struct mem_type mem_types[] = {
4272 +#ifdef CONFIG_PAX_KERNEXEC
4273 +#define L_PTE_KERNEXEC L_PTE_RDONLY
4274 +#define PMD_SECT_KERNEXEC PMD_SECT_RDONLY
4275 +#else
4276 +#define L_PTE_KERNEXEC L_PTE_DIRTY
4277 +#define PMD_SECT_KERNEXEC PMD_SECT_AP_WRITE
4278 +#endif
4279 +
4280 +static struct mem_type mem_types[] __read_only = {
4281 [MT_DEVICE] = { /* Strongly ordered / ARMv6 shared device */
4282 .prot_pte = PROT_PTE_DEVICE | L_PTE_MT_DEV_SHARED |
4283 L_PTE_SHARED,
4284 @@ -260,16 +284,16 @@ static struct mem_type mem_types[] = {
4285 [MT_UNCACHED] = {
4286 .prot_pte = PROT_PTE_DEVICE,
4287 .prot_l1 = PMD_TYPE_TABLE,
4288 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4289 + .prot_sect = PROT_SECT_DEVICE,
4290 .domain = DOMAIN_IO,
4291 },
4292 [MT_CACHECLEAN] = {
4293 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4294 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4295 .domain = DOMAIN_KERNEL,
4296 },
4297 #ifndef CONFIG_ARM_LPAE
4298 [MT_MINICLEAN] = {
4299 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN | PMD_SECT_MINICACHE,
4300 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_MINICACHE | PMD_SECT_RDONLY,
4301 .domain = DOMAIN_KERNEL,
4302 },
4303 #endif
4304 @@ -277,36 +301,54 @@ static struct mem_type mem_types[] = {
4305 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4306 L_PTE_RDONLY,
4307 .prot_l1 = PMD_TYPE_TABLE,
4308 - .domain = DOMAIN_USER,
4309 + .domain = DOMAIN_VECTORS,
4310 },
4311 [MT_HIGH_VECTORS] = {
4312 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4313 L_PTE_USER | L_PTE_RDONLY,
4314 .prot_l1 = PMD_TYPE_TABLE,
4315 - .domain = DOMAIN_USER,
4316 + .domain = DOMAIN_VECTORS,
4317 },
4318 - [MT_MEMORY] = {
4319 + [MT_MEMORY_RWX] = {
4320 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4321 .prot_l1 = PMD_TYPE_TABLE,
4322 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4323 .domain = DOMAIN_KERNEL,
4324 },
4325 + [MT_MEMORY_RW] = {
4326 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4327 + .prot_l1 = PMD_TYPE_TABLE,
4328 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4329 + .domain = DOMAIN_KERNEL,
4330 + },
4331 + [MT_MEMORY_RX] = {
4332 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC,
4333 + .prot_l1 = PMD_TYPE_TABLE,
4334 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4335 + .domain = DOMAIN_KERNEL,
4336 + },
4337 [MT_ROM] = {
4338 - .prot_sect = PMD_TYPE_SECT,
4339 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4340 .domain = DOMAIN_KERNEL,
4341 },
4342 - [MT_MEMORY_NONCACHED] = {
4343 + [MT_MEMORY_NONCACHED_RW] = {
4344 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4345 L_PTE_MT_BUFFERABLE,
4346 .prot_l1 = PMD_TYPE_TABLE,
4347 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4348 .domain = DOMAIN_KERNEL,
4349 },
4350 + [MT_MEMORY_NONCACHED_RX] = {
4351 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC |
4352 + L_PTE_MT_BUFFERABLE,
4353 + .prot_l1 = PMD_TYPE_TABLE,
4354 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4355 + .domain = DOMAIN_KERNEL,
4356 + },
4357 [MT_MEMORY_DTCM] = {
4358 - .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4359 - L_PTE_XN,
4360 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4361 .prot_l1 = PMD_TYPE_TABLE,
4362 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4363 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4364 .domain = DOMAIN_KERNEL,
4365 },
4366 [MT_MEMORY_ITCM] = {
4367 @@ -316,10 +358,10 @@ static struct mem_type mem_types[] = {
4368 },
4369 [MT_MEMORY_SO] = {
4370 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4371 - L_PTE_MT_UNCACHED | L_PTE_XN,
4372 + L_PTE_MT_UNCACHED,
4373 .prot_l1 = PMD_TYPE_TABLE,
4374 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE | PMD_SECT_S |
4375 - PMD_SECT_UNCACHED | PMD_SECT_XN,
4376 + PMD_SECT_UNCACHED,
4377 .domain = DOMAIN_KERNEL,
4378 },
4379 [MT_MEMORY_DMA_READY] = {
4380 @@ -405,9 +447,35 @@ static void __init build_mem_type_table(void)
4381 * to prevent speculative instruction fetches.
4382 */
4383 mem_types[MT_DEVICE].prot_sect |= PMD_SECT_XN;
4384 + mem_types[MT_DEVICE].prot_pte |= L_PTE_XN;
4385 mem_types[MT_DEVICE_NONSHARED].prot_sect |= PMD_SECT_XN;
4386 + mem_types[MT_DEVICE_NONSHARED].prot_pte |= L_PTE_XN;
4387 mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_XN;
4388 + mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_XN;
4389 mem_types[MT_DEVICE_WC].prot_sect |= PMD_SECT_XN;
4390 + mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_XN;
4391 +
4392 + /* Mark other regions on ARMv6+ as execute-never */
4393 +
4394 +#ifdef CONFIG_PAX_KERNEXEC
4395 + mem_types[MT_UNCACHED].prot_sect |= PMD_SECT_XN;
4396 + mem_types[MT_UNCACHED].prot_pte |= L_PTE_XN;
4397 + mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_XN;
4398 + mem_types[MT_CACHECLEAN].prot_pte |= L_PTE_XN;
4399 +#ifndef CONFIG_ARM_LPAE
4400 + mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_XN;
4401 + mem_types[MT_MINICLEAN].prot_pte |= L_PTE_XN;
4402 +#endif
4403 + mem_types[MT_MEMORY_RW].prot_sect |= PMD_SECT_XN;
4404 + mem_types[MT_MEMORY_RW].prot_pte |= L_PTE_XN;
4405 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_XN;
4406 + mem_types[MT_MEMORY_NONCACHED_RW].prot_pte |= PMD_SECT_XN;
4407 + mem_types[MT_MEMORY_DTCM].prot_sect |= PMD_SECT_XN;
4408 + mem_types[MT_MEMORY_DTCM].prot_pte |= L_PTE_XN;
4409 +#endif
4410 +
4411 + mem_types[MT_MEMORY_SO].prot_sect |= PMD_SECT_XN;
4412 + mem_types[MT_MEMORY_SO].prot_pte |= L_PTE_XN;
4413 }
4414 if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
4415 /*
4416 @@ -468,6 +536,9 @@ static void __init build_mem_type_table(void)
4417 * from SVC mode and no access from userspace.
4418 */
4419 mem_types[MT_ROM].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4420 +#ifdef CONFIG_PAX_KERNEXEC
4421 + mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4422 +#endif
4423 mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4424 mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4425 #endif
4426 @@ -485,11 +556,17 @@ static void __init build_mem_type_table(void)
4427 mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_SHARED;
4428 mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_S;
4429 mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_SHARED;
4430 - mem_types[MT_MEMORY].prot_sect |= PMD_SECT_S;
4431 - mem_types[MT_MEMORY].prot_pte |= L_PTE_SHARED;
4432 + mem_types[MT_MEMORY_RWX].prot_sect |= PMD_SECT_S;
4433 + mem_types[MT_MEMORY_RWX].prot_pte |= L_PTE_SHARED;
4434 + mem_types[MT_MEMORY_RW].prot_sect |= PMD_SECT_S;
4435 + mem_types[MT_MEMORY_RW].prot_pte |= L_PTE_SHARED;
4436 + mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_S;
4437 + mem_types[MT_MEMORY_RX].prot_pte |= L_PTE_SHARED;
4438 mem_types[MT_MEMORY_DMA_READY].prot_pte |= L_PTE_SHARED;
4439 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_S;
4440 - mem_types[MT_MEMORY_NONCACHED].prot_pte |= L_PTE_SHARED;
4441 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_S;
4442 + mem_types[MT_MEMORY_NONCACHED_RW].prot_pte |= L_PTE_SHARED;
4443 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= PMD_SECT_S;
4444 + mem_types[MT_MEMORY_NONCACHED_RX].prot_pte |= L_PTE_SHARED;
4445 }
4446 }
4447
4448 @@ -500,15 +577,20 @@ static void __init build_mem_type_table(void)
4449 if (cpu_arch >= CPU_ARCH_ARMv6) {
4450 if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
4451 /* Non-cacheable Normal is XCB = 001 */
4452 - mem_types[MT_MEMORY_NONCACHED].prot_sect |=
4453 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |=
4454 + PMD_SECT_BUFFERED;
4455 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |=
4456 PMD_SECT_BUFFERED;
4457 } else {
4458 /* For both ARMv6 and non-TEX-remapping ARMv7 */
4459 - mem_types[MT_MEMORY_NONCACHED].prot_sect |=
4460 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |=
4461 + PMD_SECT_TEX(1);
4462 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |=
4463 PMD_SECT_TEX(1);
4464 }
4465 } else {
4466 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_BUFFERABLE;
4467 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_BUFFERABLE;
4468 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= PMD_SECT_BUFFERABLE;
4469 }
4470
4471 #ifdef CONFIG_ARM_LPAE
4472 @@ -524,6 +606,8 @@ static void __init build_mem_type_table(void)
4473 vecs_pgprot |= PTE_EXT_AF;
4474 #endif
4475
4476 + user_pgprot |= __supported_pte_mask;
4477 +
4478 for (i = 0; i < 16; i++) {
4479 pteval_t v = pgprot_val(protection_map[i]);
4480 protection_map[i] = __pgprot(v | user_pgprot);
4481 @@ -541,10 +625,15 @@ static void __init build_mem_type_table(void)
4482
4483 mem_types[MT_LOW_VECTORS].prot_l1 |= ecc_mask;
4484 mem_types[MT_HIGH_VECTORS].prot_l1 |= ecc_mask;
4485 - mem_types[MT_MEMORY].prot_sect |= ecc_mask | cp->pmd;
4486 - mem_types[MT_MEMORY].prot_pte |= kern_pgprot;
4487 + mem_types[MT_MEMORY_RWX].prot_sect |= ecc_mask | cp->pmd;
4488 + mem_types[MT_MEMORY_RWX].prot_pte |= kern_pgprot;
4489 + mem_types[MT_MEMORY_RW].prot_sect |= ecc_mask | cp->pmd;
4490 + mem_types[MT_MEMORY_RW].prot_pte |= kern_pgprot;
4491 + mem_types[MT_MEMORY_RX].prot_sect |= ecc_mask | cp->pmd;
4492 + mem_types[MT_MEMORY_RX].prot_pte |= kern_pgprot;
4493 mem_types[MT_MEMORY_DMA_READY].prot_pte |= kern_pgprot;
4494 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= ecc_mask;
4495 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= ecc_mask;
4496 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= ecc_mask;
4497 mem_types[MT_ROM].prot_sect |= cp->pmd;
4498
4499 switch (cp->pmd) {
4500 @@ -1186,18 +1275,15 @@ void __init arm_mm_memblock_reserve(void)
4501 * called function. This means you can't use any function or debugging
4502 * method which may touch any device, otherwise the kernel _will_ crash.
4503 */
4504 +
4505 +static char vectors[PAGE_SIZE * 2] __read_only __aligned(PAGE_SIZE);
4506 +
4507 static void __init devicemaps_init(const struct machine_desc *mdesc)
4508 {
4509 struct map_desc map;
4510 unsigned long addr;
4511 - void *vectors;
4512
4513 - /*
4514 - * Allocate the vector page early.
4515 - */
4516 - vectors = early_alloc(PAGE_SIZE * 2);
4517 -
4518 - early_trap_init(vectors);
4519 + early_trap_init(&vectors);
4520
4521 for (addr = VMALLOC_START; addr; addr += PMD_SIZE)
4522 pmd_clear(pmd_off_k(addr));
4523 @@ -1237,7 +1323,7 @@ static void __init devicemaps_init(const struct machine_desc *mdesc)
4524 * location (0xffff0000). If we aren't using high-vectors, also
4525 * create a mapping at the low-vectors virtual address.
4526 */
4527 - map.pfn = __phys_to_pfn(virt_to_phys(vectors));
4528 + map.pfn = __phys_to_pfn(virt_to_phys(&vectors));
4529 map.virtual = 0xffff0000;
4530 map.length = PAGE_SIZE;
4531 #ifdef CONFIG_KUSER_HELPERS
4532 @@ -1309,8 +1395,39 @@ static void __init map_lowmem(void)
4533 map.pfn = __phys_to_pfn(start);
4534 map.virtual = __phys_to_virt(start);
4535 map.length = end - start;
4536 - map.type = MT_MEMORY;
4537
4538 +#ifdef CONFIG_PAX_KERNEXEC
4539 + if (map.virtual <= (unsigned long)_stext && ((unsigned long)_end < (map.virtual + map.length))) {
4540 + struct map_desc kernel;
4541 + struct map_desc initmap;
4542 +
4543 + /* when freeing initmem we will make this RW */
4544 + initmap.pfn = __phys_to_pfn(__pa(__init_begin));
4545 + initmap.virtual = (unsigned long)__init_begin;
4546 + initmap.length = _sdata - __init_begin;
4547 + initmap.type = MT_MEMORY_RWX;
4548 + create_mapping(&initmap);
4549 +
4550 + /* when freeing initmem we will make this RX */
4551 + kernel.pfn = __phys_to_pfn(__pa(_stext));
4552 + kernel.virtual = (unsigned long)_stext;
4553 + kernel.length = __init_begin - _stext;
4554 + kernel.type = MT_MEMORY_RWX;
4555 + create_mapping(&kernel);
4556 +
4557 + if (map.virtual < (unsigned long)_stext) {
4558 + map.length = (unsigned long)_stext - map.virtual;
4559 + map.type = MT_MEMORY_RWX;
4560 + create_mapping(&map);
4561 + }
4562 +
4563 + map.pfn = __phys_to_pfn(__pa(_sdata));
4564 + map.virtual = (unsigned long)_sdata;
4565 + map.length = end - __pa(_sdata);
4566 + }
4567 +#endif
4568 +
4569 + map.type = MT_MEMORY_RW;
4570 create_mapping(&map);
4571 }
4572 }
4573 diff --git a/arch/arm/plat-omap/sram.c b/arch/arm/plat-omap/sram.c
4574 index a5bc92d..0bb4730 100644
4575 --- a/arch/arm/plat-omap/sram.c
4576 +++ b/arch/arm/plat-omap/sram.c
4577 @@ -93,6 +93,8 @@ void __init omap_map_sram(unsigned long start, unsigned long size,
4578 * Looks like we need to preserve some bootloader code at the
4579 * beginning of SRAM for jumping to flash for reboot to work...
4580 */
4581 + pax_open_kernel();
4582 memset_io(omap_sram_base + omap_sram_skip, 0,
4583 omap_sram_size - omap_sram_skip);
4584 + pax_close_kernel();
4585 }
4586 diff --git a/arch/arm/plat-samsung/include/plat/dma-ops.h b/arch/arm/plat-samsung/include/plat/dma-ops.h
4587 index ce6d763..cfea917 100644
4588 --- a/arch/arm/plat-samsung/include/plat/dma-ops.h
4589 +++ b/arch/arm/plat-samsung/include/plat/dma-ops.h
4590 @@ -47,7 +47,7 @@ struct samsung_dma_ops {
4591 int (*started)(unsigned ch);
4592 int (*flush)(unsigned ch);
4593 int (*stop)(unsigned ch);
4594 -};
4595 +} __no_const;
4596
4597 extern void *samsung_dmadev_get_ops(void);
4598 extern void *s3c_dma_get_ops(void);
4599 diff --git a/arch/avr32/include/asm/cache.h b/arch/avr32/include/asm/cache.h
4600 index c3a58a1..78fbf54 100644
4601 --- a/arch/avr32/include/asm/cache.h
4602 +++ b/arch/avr32/include/asm/cache.h
4603 @@ -1,8 +1,10 @@
4604 #ifndef __ASM_AVR32_CACHE_H
4605 #define __ASM_AVR32_CACHE_H
4606
4607 +#include <linux/const.h>
4608 +
4609 #define L1_CACHE_SHIFT 5
4610 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4611 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4612
4613 /*
4614 * Memory returned by kmalloc() may be used for DMA, so we must make
4615 diff --git a/arch/avr32/include/asm/elf.h b/arch/avr32/include/asm/elf.h
4616 index d232888..87c8df1 100644
4617 --- a/arch/avr32/include/asm/elf.h
4618 +++ b/arch/avr32/include/asm/elf.h
4619 @@ -84,8 +84,14 @@ typedef struct user_fpu_struct elf_fpregset_t;
4620 the loader. We need to make sure that it is out of the way of the program
4621 that it will "exec", and that there is sufficient room for the brk. */
4622
4623 -#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
4624 +#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
4625
4626 +#ifdef CONFIG_PAX_ASLR
4627 +#define PAX_ELF_ET_DYN_BASE 0x00001000UL
4628 +
4629 +#define PAX_DELTA_MMAP_LEN 15
4630 +#define PAX_DELTA_STACK_LEN 15
4631 +#endif
4632
4633 /* This yields a mask that user programs can use to figure out what
4634 instruction set this CPU supports. This could be done in user space,
4635 diff --git a/arch/avr32/include/asm/kmap_types.h b/arch/avr32/include/asm/kmap_types.h
4636 index 479330b..53717a8 100644
4637 --- a/arch/avr32/include/asm/kmap_types.h
4638 +++ b/arch/avr32/include/asm/kmap_types.h
4639 @@ -2,9 +2,9 @@
4640 #define __ASM_AVR32_KMAP_TYPES_H
4641
4642 #ifdef CONFIG_DEBUG_HIGHMEM
4643 -# define KM_TYPE_NR 29
4644 +# define KM_TYPE_NR 30
4645 #else
4646 -# define KM_TYPE_NR 14
4647 +# define KM_TYPE_NR 15
4648 #endif
4649
4650 #endif /* __ASM_AVR32_KMAP_TYPES_H */
4651 diff --git a/arch/avr32/mm/fault.c b/arch/avr32/mm/fault.c
4652 index 0eca933..eb78c7b 100644
4653 --- a/arch/avr32/mm/fault.c
4654 +++ b/arch/avr32/mm/fault.c
4655 @@ -41,6 +41,23 @@ static inline int notify_page_fault(struct pt_regs *regs, int trap)
4656
4657 int exception_trace = 1;
4658
4659 +#ifdef CONFIG_PAX_PAGEEXEC
4660 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
4661 +{
4662 + unsigned long i;
4663 +
4664 + printk(KERN_ERR "PAX: bytes at PC: ");
4665 + for (i = 0; i < 20; i++) {
4666 + unsigned char c;
4667 + if (get_user(c, (unsigned char *)pc+i))
4668 + printk(KERN_CONT "???????? ");
4669 + else
4670 + printk(KERN_CONT "%02x ", c);
4671 + }
4672 + printk("\n");
4673 +}
4674 +#endif
4675 +
4676 /*
4677 * This routine handles page faults. It determines the address and the
4678 * problem, and then passes it off to one of the appropriate routines.
4679 @@ -176,6 +193,16 @@ bad_area:
4680 up_read(&mm->mmap_sem);
4681
4682 if (user_mode(regs)) {
4683 +
4684 +#ifdef CONFIG_PAX_PAGEEXEC
4685 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
4686 + if (ecr == ECR_PROTECTION_X || ecr == ECR_TLB_MISS_X) {
4687 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->sp);
4688 + do_group_exit(SIGKILL);
4689 + }
4690 + }
4691 +#endif
4692 +
4693 if (exception_trace && printk_ratelimit())
4694 printk("%s%s[%d]: segfault at %08lx pc %08lx "
4695 "sp %08lx ecr %lu\n",
4696 diff --git a/arch/blackfin/include/asm/cache.h b/arch/blackfin/include/asm/cache.h
4697 index 568885a..f8008df 100644
4698 --- a/arch/blackfin/include/asm/cache.h
4699 +++ b/arch/blackfin/include/asm/cache.h
4700 @@ -7,6 +7,7 @@
4701 #ifndef __ARCH_BLACKFIN_CACHE_H
4702 #define __ARCH_BLACKFIN_CACHE_H
4703
4704 +#include <linux/const.h>
4705 #include <linux/linkage.h> /* for asmlinkage */
4706
4707 /*
4708 @@ -14,7 +15,7 @@
4709 * Blackfin loads 32 bytes for cache
4710 */
4711 #define L1_CACHE_SHIFT 5
4712 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4713 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4714 #define SMP_CACHE_BYTES L1_CACHE_BYTES
4715
4716 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
4717 diff --git a/arch/cris/include/arch-v10/arch/cache.h b/arch/cris/include/arch-v10/arch/cache.h
4718 index aea2718..3639a60 100644
4719 --- a/arch/cris/include/arch-v10/arch/cache.h
4720 +++ b/arch/cris/include/arch-v10/arch/cache.h
4721 @@ -1,8 +1,9 @@
4722 #ifndef _ASM_ARCH_CACHE_H
4723 #define _ASM_ARCH_CACHE_H
4724
4725 +#include <linux/const.h>
4726 /* Etrax 100LX have 32-byte cache-lines. */
4727 -#define L1_CACHE_BYTES 32
4728 #define L1_CACHE_SHIFT 5
4729 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4730
4731 #endif /* _ASM_ARCH_CACHE_H */
4732 diff --git a/arch/cris/include/arch-v32/arch/cache.h b/arch/cris/include/arch-v32/arch/cache.h
4733 index 7caf25d..ee65ac5 100644
4734 --- a/arch/cris/include/arch-v32/arch/cache.h
4735 +++ b/arch/cris/include/arch-v32/arch/cache.h
4736 @@ -1,11 +1,12 @@
4737 #ifndef _ASM_CRIS_ARCH_CACHE_H
4738 #define _ASM_CRIS_ARCH_CACHE_H
4739
4740 +#include <linux/const.h>
4741 #include <arch/hwregs/dma.h>
4742
4743 /* A cache-line is 32 bytes. */
4744 -#define L1_CACHE_BYTES 32
4745 #define L1_CACHE_SHIFT 5
4746 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4747
4748 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
4749
4750 diff --git a/arch/frv/include/asm/atomic.h b/arch/frv/include/asm/atomic.h
4751 index b86329d..6709906 100644
4752 --- a/arch/frv/include/asm/atomic.h
4753 +++ b/arch/frv/include/asm/atomic.h
4754 @@ -186,6 +186,16 @@ static inline void atomic64_dec(atomic64_t *v)
4755 #define atomic64_cmpxchg(v, old, new) (__cmpxchg_64(old, new, &(v)->counter))
4756 #define atomic64_xchg(v, new) (__xchg_64(new, &(v)->counter))
4757
4758 +#define atomic64_read_unchecked(v) atomic64_read(v)
4759 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
4760 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
4761 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
4762 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
4763 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
4764 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
4765 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
4766 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
4767 +
4768 static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
4769 {
4770 int c, old;
4771 diff --git a/arch/frv/include/asm/cache.h b/arch/frv/include/asm/cache.h
4772 index 2797163..c2a401d 100644
4773 --- a/arch/frv/include/asm/cache.h
4774 +++ b/arch/frv/include/asm/cache.h
4775 @@ -12,10 +12,11 @@
4776 #ifndef __ASM_CACHE_H
4777 #define __ASM_CACHE_H
4778
4779 +#include <linux/const.h>
4780
4781 /* bytes per L1 cache line */
4782 #define L1_CACHE_SHIFT (CONFIG_FRV_L1_CACHE_SHIFT)
4783 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4784 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4785
4786 #define __cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
4787 #define ____cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
4788 diff --git a/arch/frv/include/asm/kmap_types.h b/arch/frv/include/asm/kmap_types.h
4789 index 43901f2..0d8b865 100644
4790 --- a/arch/frv/include/asm/kmap_types.h
4791 +++ b/arch/frv/include/asm/kmap_types.h
4792 @@ -2,6 +2,6 @@
4793 #ifndef _ASM_KMAP_TYPES_H
4794 #define _ASM_KMAP_TYPES_H
4795
4796 -#define KM_TYPE_NR 17
4797 +#define KM_TYPE_NR 18
4798
4799 #endif
4800 diff --git a/arch/frv/mm/elf-fdpic.c b/arch/frv/mm/elf-fdpic.c
4801 index 836f147..4cf23f5 100644
4802 --- a/arch/frv/mm/elf-fdpic.c
4803 +++ b/arch/frv/mm/elf-fdpic.c
4804 @@ -61,6 +61,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4805 {
4806 struct vm_area_struct *vma;
4807 struct vm_unmapped_area_info info;
4808 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
4809
4810 if (len > TASK_SIZE)
4811 return -ENOMEM;
4812 @@ -73,8 +74,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4813 if (addr) {
4814 addr = PAGE_ALIGN(addr);
4815 vma = find_vma(current->mm, addr);
4816 - if (TASK_SIZE - len >= addr &&
4817 - (!vma || addr + len <= vma->vm_start))
4818 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4819 goto success;
4820 }
4821
4822 @@ -85,6 +85,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4823 info.high_limit = (current->mm->start_stack - 0x00200000);
4824 info.align_mask = 0;
4825 info.align_offset = 0;
4826 + info.threadstack_offset = offset;
4827 addr = vm_unmapped_area(&info);
4828 if (!(addr & ~PAGE_MASK))
4829 goto success;
4830 diff --git a/arch/hexagon/include/asm/cache.h b/arch/hexagon/include/asm/cache.h
4831 index f4ca594..adc72fd6 100644
4832 --- a/arch/hexagon/include/asm/cache.h
4833 +++ b/arch/hexagon/include/asm/cache.h
4834 @@ -21,9 +21,11 @@
4835 #ifndef __ASM_CACHE_H
4836 #define __ASM_CACHE_H
4837
4838 +#include <linux/const.h>
4839 +
4840 /* Bytes per L1 cache line */
4841 -#define L1_CACHE_SHIFT (5)
4842 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4843 +#define L1_CACHE_SHIFT 5
4844 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4845
4846 #define __cacheline_aligned __aligned(L1_CACHE_BYTES)
4847 #define ____cacheline_aligned __aligned(L1_CACHE_BYTES)
4848 diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig
4849 index 7740ab1..17fa8c5 100644
4850 --- a/arch/ia64/Kconfig
4851 +++ b/arch/ia64/Kconfig
4852 @@ -554,6 +554,7 @@ source "drivers/sn/Kconfig"
4853 config KEXEC
4854 bool "kexec system call"
4855 depends on !IA64_HP_SIM && (!SMP || HOTPLUG_CPU)
4856 + depends on !GRKERNSEC_KMEM
4857 help
4858 kexec is a system call that implements the ability to shutdown your
4859 current kernel, and to start another kernel. It is like a reboot
4860 diff --git a/arch/ia64/include/asm/atomic.h b/arch/ia64/include/asm/atomic.h
4861 index 6e6fe18..a6ae668 100644
4862 --- a/arch/ia64/include/asm/atomic.h
4863 +++ b/arch/ia64/include/asm/atomic.h
4864 @@ -208,6 +208,16 @@ atomic64_add_negative (__s64 i, atomic64_t *v)
4865 #define atomic64_inc(v) atomic64_add(1, (v))
4866 #define atomic64_dec(v) atomic64_sub(1, (v))
4867
4868 +#define atomic64_read_unchecked(v) atomic64_read(v)
4869 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
4870 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
4871 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
4872 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
4873 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
4874 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
4875 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
4876 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
4877 +
4878 /* Atomic operations are already serializing */
4879 #define smp_mb__before_atomic_dec() barrier()
4880 #define smp_mb__after_atomic_dec() barrier()
4881 diff --git a/arch/ia64/include/asm/cache.h b/arch/ia64/include/asm/cache.h
4882 index 988254a..e1ee885 100644
4883 --- a/arch/ia64/include/asm/cache.h
4884 +++ b/arch/ia64/include/asm/cache.h
4885 @@ -1,6 +1,7 @@
4886 #ifndef _ASM_IA64_CACHE_H
4887 #define _ASM_IA64_CACHE_H
4888
4889 +#include <linux/const.h>
4890
4891 /*
4892 * Copyright (C) 1998-2000 Hewlett-Packard Co
4893 @@ -9,7 +10,7 @@
4894
4895 /* Bytes per L1 (data) cache line. */
4896 #define L1_CACHE_SHIFT CONFIG_IA64_L1_CACHE_SHIFT
4897 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4898 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4899
4900 #ifdef CONFIG_SMP
4901 # define SMP_CACHE_SHIFT L1_CACHE_SHIFT
4902 diff --git a/arch/ia64/include/asm/elf.h b/arch/ia64/include/asm/elf.h
4903 index 5a83c5c..4d7f553 100644
4904 --- a/arch/ia64/include/asm/elf.h
4905 +++ b/arch/ia64/include/asm/elf.h
4906 @@ -42,6 +42,13 @@
4907 */
4908 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x800000000UL)
4909
4910 +#ifdef CONFIG_PAX_ASLR
4911 +#define PAX_ELF_ET_DYN_BASE (current->personality == PER_LINUX32 ? 0x08048000UL : 0x4000000000000000UL)
4912 +
4913 +#define PAX_DELTA_MMAP_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
4914 +#define PAX_DELTA_STACK_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
4915 +#endif
4916 +
4917 #define PT_IA_64_UNWIND 0x70000001
4918
4919 /* IA-64 relocations: */
4920 diff --git a/arch/ia64/include/asm/pgalloc.h b/arch/ia64/include/asm/pgalloc.h
4921 index 96a8d92..617a1cf 100644
4922 --- a/arch/ia64/include/asm/pgalloc.h
4923 +++ b/arch/ia64/include/asm/pgalloc.h
4924 @@ -39,6 +39,12 @@ pgd_populate(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
4925 pgd_val(*pgd_entry) = __pa(pud);
4926 }
4927
4928 +static inline void
4929 +pgd_populate_kernel(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
4930 +{
4931 + pgd_populate(mm, pgd_entry, pud);
4932 +}
4933 +
4934 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
4935 {
4936 return quicklist_alloc(0, GFP_KERNEL, NULL);
4937 @@ -57,6 +63,12 @@ pud_populate(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
4938 pud_val(*pud_entry) = __pa(pmd);
4939 }
4940
4941 +static inline void
4942 +pud_populate_kernel(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
4943 +{
4944 + pud_populate(mm, pud_entry, pmd);
4945 +}
4946 +
4947 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
4948 {
4949 return quicklist_alloc(0, GFP_KERNEL, NULL);
4950 diff --git a/arch/ia64/include/asm/pgtable.h b/arch/ia64/include/asm/pgtable.h
4951 index 7935115..c0eca6a 100644
4952 --- a/arch/ia64/include/asm/pgtable.h
4953 +++ b/arch/ia64/include/asm/pgtable.h
4954 @@ -12,7 +12,7 @@
4955 * David Mosberger-Tang <davidm@hpl.hp.com>
4956 */
4957
4958 -
4959 +#include <linux/const.h>
4960 #include <asm/mman.h>
4961 #include <asm/page.h>
4962 #include <asm/processor.h>
4963 @@ -142,6 +142,17 @@
4964 #define PAGE_READONLY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4965 #define PAGE_COPY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4966 #define PAGE_COPY_EXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RX)
4967 +
4968 +#ifdef CONFIG_PAX_PAGEEXEC
4969 +# define PAGE_SHARED_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RW)
4970 +# define PAGE_READONLY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4971 +# define PAGE_COPY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4972 +#else
4973 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
4974 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
4975 +# define PAGE_COPY_NOEXEC PAGE_COPY
4976 +#endif
4977 +
4978 #define PAGE_GATE __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_X_RX)
4979 #define PAGE_KERNEL __pgprot(__DIRTY_BITS | _PAGE_PL_0 | _PAGE_AR_RWX)
4980 #define PAGE_KERNELRX __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_RX)
4981 diff --git a/arch/ia64/include/asm/spinlock.h b/arch/ia64/include/asm/spinlock.h
4982 index 45698cd..e8e2dbc 100644
4983 --- a/arch/ia64/include/asm/spinlock.h
4984 +++ b/arch/ia64/include/asm/spinlock.h
4985 @@ -71,7 +71,7 @@ static __always_inline void __ticket_spin_unlock(arch_spinlock_t *lock)
4986 unsigned short *p = (unsigned short *)&lock->lock + 1, tmp;
4987
4988 asm volatile ("ld2.bias %0=[%1]" : "=r"(tmp) : "r"(p));
4989 - ACCESS_ONCE(*p) = (tmp + 2) & ~1;
4990 + ACCESS_ONCE_RW(*p) = (tmp + 2) & ~1;
4991 }
4992
4993 static __always_inline void __ticket_spin_unlock_wait(arch_spinlock_t *lock)
4994 diff --git a/arch/ia64/include/asm/uaccess.h b/arch/ia64/include/asm/uaccess.h
4995 index 449c8c0..18965fb 100644
4996 --- a/arch/ia64/include/asm/uaccess.h
4997 +++ b/arch/ia64/include/asm/uaccess.h
4998 @@ -240,12 +240,24 @@ extern unsigned long __must_check __copy_user (void __user *to, const void __use
4999 static inline unsigned long
5000 __copy_to_user (void __user *to, const void *from, unsigned long count)
5001 {
5002 + if (count > INT_MAX)
5003 + return count;
5004 +
5005 + if (!__builtin_constant_p(count))
5006 + check_object_size(from, count, true);
5007 +
5008 return __copy_user(to, (__force void __user *) from, count);
5009 }
5010
5011 static inline unsigned long
5012 __copy_from_user (void *to, const void __user *from, unsigned long count)
5013 {
5014 + if (count > INT_MAX)
5015 + return count;
5016 +
5017 + if (!__builtin_constant_p(count))
5018 + check_object_size(to, count, false);
5019 +
5020 return __copy_user((__force void __user *) to, from, count);
5021 }
5022
5023 @@ -255,10 +267,13 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
5024 ({ \
5025 void __user *__cu_to = (to); \
5026 const void *__cu_from = (from); \
5027 - long __cu_len = (n); \
5028 + unsigned long __cu_len = (n); \
5029 \
5030 - if (__access_ok(__cu_to, __cu_len, get_fs())) \
5031 + if (__cu_len <= INT_MAX && __access_ok(__cu_to, __cu_len, get_fs())) { \
5032 + if (!__builtin_constant_p(n)) \
5033 + check_object_size(__cu_from, __cu_len, true); \
5034 __cu_len = __copy_user(__cu_to, (__force void __user *) __cu_from, __cu_len); \
5035 + } \
5036 __cu_len; \
5037 })
5038
5039 @@ -266,11 +281,14 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
5040 ({ \
5041 void *__cu_to = (to); \
5042 const void __user *__cu_from = (from); \
5043 - long __cu_len = (n); \
5044 + unsigned long __cu_len = (n); \
5045 \
5046 __chk_user_ptr(__cu_from); \
5047 - if (__access_ok(__cu_from, __cu_len, get_fs())) \
5048 + if (__cu_len <= INT_MAX && __access_ok(__cu_from, __cu_len, get_fs())) { \
5049 + if (!__builtin_constant_p(n)) \
5050 + check_object_size(__cu_to, __cu_len, false); \
5051 __cu_len = __copy_user((__force void __user *) __cu_to, __cu_from, __cu_len); \
5052 + } \
5053 __cu_len; \
5054 })
5055
5056 diff --git a/arch/ia64/kernel/module.c b/arch/ia64/kernel/module.c
5057 index 24603be..948052d 100644
5058 --- a/arch/ia64/kernel/module.c
5059 +++ b/arch/ia64/kernel/module.c
5060 @@ -307,8 +307,7 @@ plt_target (struct plt_entry *plt)
5061 void
5062 module_free (struct module *mod, void *module_region)
5063 {
5064 - if (mod && mod->arch.init_unw_table &&
5065 - module_region == mod->module_init) {
5066 + if (mod && mod->arch.init_unw_table && module_region == mod->module_init_rx) {
5067 unw_remove_unwind_table(mod->arch.init_unw_table);
5068 mod->arch.init_unw_table = NULL;
5069 }
5070 @@ -494,15 +493,39 @@ module_frob_arch_sections (Elf_Ehdr *ehdr, Elf_Shdr *sechdrs, char *secstrings,
5071 }
5072
5073 static inline int
5074 +in_init_rx (const struct module *mod, uint64_t addr)
5075 +{
5076 + return addr - (uint64_t) mod->module_init_rx < mod->init_size_rx;
5077 +}
5078 +
5079 +static inline int
5080 +in_init_rw (const struct module *mod, uint64_t addr)
5081 +{
5082 + return addr - (uint64_t) mod->module_init_rw < mod->init_size_rw;
5083 +}
5084 +
5085 +static inline int
5086 in_init (const struct module *mod, uint64_t addr)
5087 {
5088 - return addr - (uint64_t) mod->module_init < mod->init_size;
5089 + return in_init_rx(mod, addr) || in_init_rw(mod, addr);
5090 +}
5091 +
5092 +static inline int
5093 +in_core_rx (const struct module *mod, uint64_t addr)
5094 +{
5095 + return addr - (uint64_t) mod->module_core_rx < mod->core_size_rx;
5096 +}
5097 +
5098 +static inline int
5099 +in_core_rw (const struct module *mod, uint64_t addr)
5100 +{
5101 + return addr - (uint64_t) mod->module_core_rw < mod->core_size_rw;
5102 }
5103
5104 static inline int
5105 in_core (const struct module *mod, uint64_t addr)
5106 {
5107 - return addr - (uint64_t) mod->module_core < mod->core_size;
5108 + return in_core_rx(mod, addr) || in_core_rw(mod, addr);
5109 }
5110
5111 static inline int
5112 @@ -685,7 +708,14 @@ do_reloc (struct module *mod, uint8_t r_type, Elf64_Sym *sym, uint64_t addend,
5113 break;
5114
5115 case RV_BDREL:
5116 - val -= (uint64_t) (in_init(mod, val) ? mod->module_init : mod->module_core);
5117 + if (in_init_rx(mod, val))
5118 + val -= (uint64_t) mod->module_init_rx;
5119 + else if (in_init_rw(mod, val))
5120 + val -= (uint64_t) mod->module_init_rw;
5121 + else if (in_core_rx(mod, val))
5122 + val -= (uint64_t) mod->module_core_rx;
5123 + else if (in_core_rw(mod, val))
5124 + val -= (uint64_t) mod->module_core_rw;
5125 break;
5126
5127 case RV_LTV:
5128 @@ -820,15 +850,15 @@ apply_relocate_add (Elf64_Shdr *sechdrs, const char *strtab, unsigned int symind
5129 * addresses have been selected...
5130 */
5131 uint64_t gp;
5132 - if (mod->core_size > MAX_LTOFF)
5133 + if (mod->core_size_rx + mod->core_size_rw > MAX_LTOFF)
5134 /*
5135 * This takes advantage of fact that SHF_ARCH_SMALL gets allocated
5136 * at the end of the module.
5137 */
5138 - gp = mod->core_size - MAX_LTOFF / 2;
5139 + gp = mod->core_size_rx + mod->core_size_rw - MAX_LTOFF / 2;
5140 else
5141 - gp = mod->core_size / 2;
5142 - gp = (uint64_t) mod->module_core + ((gp + 7) & -8);
5143 + gp = (mod->core_size_rx + mod->core_size_rw) / 2;
5144 + gp = (uint64_t) mod->module_core_rx + ((gp + 7) & -8);
5145 mod->arch.gp = gp;
5146 DEBUGP("%s: placing gp at 0x%lx\n", __func__, gp);
5147 }
5148 diff --git a/arch/ia64/kernel/palinfo.c b/arch/ia64/kernel/palinfo.c
5149 index ab33328..f39506c 100644
5150 --- a/arch/ia64/kernel/palinfo.c
5151 +++ b/arch/ia64/kernel/palinfo.c
5152 @@ -980,7 +980,7 @@ static int palinfo_cpu_callback(struct notifier_block *nfb,
5153 return NOTIFY_OK;
5154 }
5155
5156 -static struct notifier_block __refdata palinfo_cpu_notifier =
5157 +static struct notifier_block palinfo_cpu_notifier =
5158 {
5159 .notifier_call = palinfo_cpu_callback,
5160 .priority = 0,
5161 diff --git a/arch/ia64/kernel/sys_ia64.c b/arch/ia64/kernel/sys_ia64.c
5162 index 41e33f8..65180b2a 100644
5163 --- a/arch/ia64/kernel/sys_ia64.c
5164 +++ b/arch/ia64/kernel/sys_ia64.c
5165 @@ -28,6 +28,7 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5166 unsigned long align_mask = 0;
5167 struct mm_struct *mm = current->mm;
5168 struct vm_unmapped_area_info info;
5169 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
5170
5171 if (len > RGN_MAP_LIMIT)
5172 return -ENOMEM;
5173 @@ -43,6 +44,13 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5174 if (REGION_NUMBER(addr) == RGN_HPAGE)
5175 addr = 0;
5176 #endif
5177 +
5178 +#ifdef CONFIG_PAX_RANDMMAP
5179 + if (mm->pax_flags & MF_PAX_RANDMMAP)
5180 + addr = mm->free_area_cache;
5181 + else
5182 +#endif
5183 +
5184 if (!addr)
5185 addr = TASK_UNMAPPED_BASE;
5186
5187 @@ -61,6 +69,7 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5188 info.high_limit = TASK_SIZE;
5189 info.align_mask = align_mask;
5190 info.align_offset = 0;
5191 + info.threadstack_offset = offset;
5192 return vm_unmapped_area(&info);
5193 }
5194
5195 diff --git a/arch/ia64/kernel/vmlinux.lds.S b/arch/ia64/kernel/vmlinux.lds.S
5196 index 0ccb28f..8992469 100644
5197 --- a/arch/ia64/kernel/vmlinux.lds.S
5198 +++ b/arch/ia64/kernel/vmlinux.lds.S
5199 @@ -198,7 +198,7 @@ SECTIONS {
5200 /* Per-cpu data: */
5201 . = ALIGN(PERCPU_PAGE_SIZE);
5202 PERCPU_VADDR(SMP_CACHE_BYTES, PERCPU_ADDR, :percpu)
5203 - __phys_per_cpu_start = __per_cpu_load;
5204 + __phys_per_cpu_start = per_cpu_load;
5205 /*
5206 * ensure percpu data fits
5207 * into percpu page size
5208 diff --git a/arch/ia64/mm/fault.c b/arch/ia64/mm/fault.c
5209 index 7225dad..2a7c8256 100644
5210 --- a/arch/ia64/mm/fault.c
5211 +++ b/arch/ia64/mm/fault.c
5212 @@ -72,6 +72,23 @@ mapped_kernel_page_is_present (unsigned long address)
5213 return pte_present(pte);
5214 }
5215
5216 +#ifdef CONFIG_PAX_PAGEEXEC
5217 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
5218 +{
5219 + unsigned long i;
5220 +
5221 + printk(KERN_ERR "PAX: bytes at PC: ");
5222 + for (i = 0; i < 8; i++) {
5223 + unsigned int c;
5224 + if (get_user(c, (unsigned int *)pc+i))
5225 + printk(KERN_CONT "???????? ");
5226 + else
5227 + printk(KERN_CONT "%08x ", c);
5228 + }
5229 + printk("\n");
5230 +}
5231 +#endif
5232 +
5233 # define VM_READ_BIT 0
5234 # define VM_WRITE_BIT 1
5235 # define VM_EXEC_BIT 2
5236 @@ -151,8 +168,21 @@ retry:
5237 if (((isr >> IA64_ISR_R_BIT) & 1UL) && (!(vma->vm_flags & (VM_READ | VM_WRITE))))
5238 goto bad_area;
5239
5240 - if ((vma->vm_flags & mask) != mask)
5241 + if ((vma->vm_flags & mask) != mask) {
5242 +
5243 +#ifdef CONFIG_PAX_PAGEEXEC
5244 + if (!(vma->vm_flags & VM_EXEC) && (mask & VM_EXEC)) {
5245 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || address != regs->cr_iip)
5246 + goto bad_area;
5247 +
5248 + up_read(&mm->mmap_sem);
5249 + pax_report_fault(regs, (void *)regs->cr_iip, (void *)regs->r12);
5250 + do_group_exit(SIGKILL);
5251 + }
5252 +#endif
5253 +
5254 goto bad_area;
5255 + }
5256
5257 /*
5258 * If for any reason at all we couldn't handle the fault, make
5259 diff --git a/arch/ia64/mm/hugetlbpage.c b/arch/ia64/mm/hugetlbpage.c
5260 index 68232db..6ca80af 100644
5261 --- a/arch/ia64/mm/hugetlbpage.c
5262 +++ b/arch/ia64/mm/hugetlbpage.c
5263 @@ -154,6 +154,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5264 unsigned long pgoff, unsigned long flags)
5265 {
5266 struct vm_unmapped_area_info info;
5267 + unsigned long offset = gr_rand_threadstack_offset(current->mm, file, flags);
5268
5269 if (len > RGN_MAP_LIMIT)
5270 return -ENOMEM;
5271 @@ -177,6 +178,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5272 info.high_limit = HPAGE_REGION_BASE + RGN_MAP_LIMIT;
5273 info.align_mask = PAGE_MASK & (HPAGE_SIZE - 1);
5274 info.align_offset = 0;
5275 + info.threadstack_offset = offset;
5276 return vm_unmapped_area(&info);
5277 }
5278
5279 diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
5280 index b6f7f43..c04320d 100644
5281 --- a/arch/ia64/mm/init.c
5282 +++ b/arch/ia64/mm/init.c
5283 @@ -120,6 +120,19 @@ ia64_init_addr_space (void)
5284 vma->vm_start = current->thread.rbs_bot & PAGE_MASK;
5285 vma->vm_end = vma->vm_start + PAGE_SIZE;
5286 vma->vm_flags = VM_DATA_DEFAULT_FLAGS|VM_GROWSUP|VM_ACCOUNT;
5287 +
5288 +#ifdef CONFIG_PAX_PAGEEXEC
5289 + if (current->mm->pax_flags & MF_PAX_PAGEEXEC) {
5290 + vma->vm_flags &= ~VM_EXEC;
5291 +
5292 +#ifdef CONFIG_PAX_MPROTECT
5293 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
5294 + vma->vm_flags &= ~VM_MAYEXEC;
5295 +#endif
5296 +
5297 + }
5298 +#endif
5299 +
5300 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
5301 down_write(&current->mm->mmap_sem);
5302 if (insert_vm_struct(current->mm, vma)) {
5303 diff --git a/arch/m32r/include/asm/cache.h b/arch/m32r/include/asm/cache.h
5304 index 40b3ee9..8c2c112 100644
5305 --- a/arch/m32r/include/asm/cache.h
5306 +++ b/arch/m32r/include/asm/cache.h
5307 @@ -1,8 +1,10 @@
5308 #ifndef _ASM_M32R_CACHE_H
5309 #define _ASM_M32R_CACHE_H
5310
5311 +#include <linux/const.h>
5312 +
5313 /* L1 cache line size */
5314 #define L1_CACHE_SHIFT 4
5315 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5316 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5317
5318 #endif /* _ASM_M32R_CACHE_H */
5319 diff --git a/arch/m32r/lib/usercopy.c b/arch/m32r/lib/usercopy.c
5320 index 82abd15..d95ae5d 100644
5321 --- a/arch/m32r/lib/usercopy.c
5322 +++ b/arch/m32r/lib/usercopy.c
5323 @@ -14,6 +14,9 @@
5324 unsigned long
5325 __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5326 {
5327 + if ((long)n < 0)
5328 + return n;
5329 +
5330 prefetch(from);
5331 if (access_ok(VERIFY_WRITE, to, n))
5332 __copy_user(to,from,n);
5333 @@ -23,6 +26,9 @@ __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5334 unsigned long
5335 __generic_copy_from_user(void *to, const void __user *from, unsigned long n)
5336 {
5337 + if ((long)n < 0)
5338 + return n;
5339 +
5340 prefetchw(to);
5341 if (access_ok(VERIFY_READ, from, n))
5342 __copy_user_zeroing(to,from,n);
5343 diff --git a/arch/m68k/include/asm/cache.h b/arch/m68k/include/asm/cache.h
5344 index 0395c51..5f26031 100644
5345 --- a/arch/m68k/include/asm/cache.h
5346 +++ b/arch/m68k/include/asm/cache.h
5347 @@ -4,9 +4,11 @@
5348 #ifndef __ARCH_M68K_CACHE_H
5349 #define __ARCH_M68K_CACHE_H
5350
5351 +#include <linux/const.h>
5352 +
5353 /* bytes per L1 cache line */
5354 #define L1_CACHE_SHIFT 4
5355 -#define L1_CACHE_BYTES (1<< L1_CACHE_SHIFT)
5356 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5357
5358 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
5359
5360 diff --git a/arch/metag/mm/hugetlbpage.c b/arch/metag/mm/hugetlbpage.c
5361 index 0424315..defcca9 100644
5362 --- a/arch/metag/mm/hugetlbpage.c
5363 +++ b/arch/metag/mm/hugetlbpage.c
5364 @@ -205,6 +205,7 @@ hugetlb_get_unmapped_area_new_pmd(unsigned long len)
5365 info.high_limit = TASK_SIZE;
5366 info.align_mask = PAGE_MASK & HUGEPT_MASK;
5367 info.align_offset = 0;
5368 + info.threadstack_offset = 0;
5369 return vm_unmapped_area(&info);
5370 }
5371
5372 diff --git a/arch/microblaze/include/asm/cache.h b/arch/microblaze/include/asm/cache.h
5373 index 4efe96a..60e8699 100644
5374 --- a/arch/microblaze/include/asm/cache.h
5375 +++ b/arch/microblaze/include/asm/cache.h
5376 @@ -13,11 +13,12 @@
5377 #ifndef _ASM_MICROBLAZE_CACHE_H
5378 #define _ASM_MICROBLAZE_CACHE_H
5379
5380 +#include <linux/const.h>
5381 #include <asm/registers.h>
5382
5383 #define L1_CACHE_SHIFT 5
5384 /* word-granular cache in microblaze */
5385 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5386 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5387
5388 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5389
5390 diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
5391 index f75ab4a..adc6968 100644
5392 --- a/arch/mips/Kconfig
5393 +++ b/arch/mips/Kconfig
5394 @@ -2283,6 +2283,7 @@ source "kernel/Kconfig.preempt"
5395
5396 config KEXEC
5397 bool "Kexec system call"
5398 + depends on !GRKERNSEC_KMEM
5399 help
5400 kexec is a system call that implements the ability to shutdown your
5401 current kernel, and to start another kernel. It is like a reboot
5402 diff --git a/arch/mips/include/asm/atomic.h b/arch/mips/include/asm/atomic.h
5403 index 08b6079..8b554d2 100644
5404 --- a/arch/mips/include/asm/atomic.h
5405 +++ b/arch/mips/include/asm/atomic.h
5406 @@ -21,15 +21,39 @@
5407 #include <asm/cmpxchg.h>
5408 #include <asm/war.h>
5409
5410 +#ifdef CONFIG_GENERIC_ATOMIC64
5411 +#include <asm-generic/atomic64.h>
5412 +#endif
5413 +
5414 #define ATOMIC_INIT(i) { (i) }
5415
5416 +#ifdef CONFIG_64BIT
5417 +#define _ASM_EXTABLE(from, to) \
5418 +" .section __ex_table,\"a\"\n" \
5419 +" .dword " #from ", " #to"\n" \
5420 +" .previous\n"
5421 +#else
5422 +#define _ASM_EXTABLE(from, to) \
5423 +" .section __ex_table,\"a\"\n" \
5424 +" .word " #from ", " #to"\n" \
5425 +" .previous\n"
5426 +#endif
5427 +
5428 /*
5429 * atomic_read - read atomic variable
5430 * @v: pointer of type atomic_t
5431 *
5432 * Atomically reads the value of @v.
5433 */
5434 -#define atomic_read(v) (*(volatile int *)&(v)->counter)
5435 +static inline int atomic_read(const atomic_t *v)
5436 +{
5437 + return (*(volatile const int *) &v->counter);
5438 +}
5439 +
5440 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
5441 +{
5442 + return (*(volatile const int *) &v->counter);
5443 +}
5444
5445 /*
5446 * atomic_set - set atomic variable
5447 @@ -38,7 +62,15 @@
5448 *
5449 * Atomically sets the value of @v to @i.
5450 */
5451 -#define atomic_set(v, i) ((v)->counter = (i))
5452 +static inline void atomic_set(atomic_t *v, int i)
5453 +{
5454 + v->counter = i;
5455 +}
5456 +
5457 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
5458 +{
5459 + v->counter = i;
5460 +}
5461
5462 /*
5463 * atomic_add - add integer to atomic variable
5464 @@ -47,7 +79,67 @@
5465 *
5466 * Atomically adds @i to @v.
5467 */
5468 -static __inline__ void atomic_add(int i, atomic_t * v)
5469 +static __inline__ void atomic_add(int i, atomic_t *v)
5470 +{
5471 + int temp;
5472 +
5473 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5474 + __asm__ __volatile__(
5475 + " .set mips3 \n"
5476 + "1: ll %0, %1 # atomic_add \n"
5477 +#ifdef CONFIG_PAX_REFCOUNT
5478 + /* Exception on overflow. */
5479 + "2: add %0, %2 \n"
5480 +#else
5481 + " addu %0, %2 \n"
5482 +#endif
5483 + " sc %0, %1 \n"
5484 + " beqzl %0, 1b \n"
5485 +#ifdef CONFIG_PAX_REFCOUNT
5486 + "3: \n"
5487 + _ASM_EXTABLE(2b, 3b)
5488 +#endif
5489 + " .set mips0 \n"
5490 + : "=&r" (temp), "+m" (v->counter)
5491 + : "Ir" (i));
5492 + } else if (kernel_uses_llsc) {
5493 + __asm__ __volatile__(
5494 + " .set mips3 \n"
5495 + "1: ll %0, %1 # atomic_add \n"
5496 +#ifdef CONFIG_PAX_REFCOUNT
5497 + /* Exception on overflow. */
5498 + "2: add %0, %2 \n"
5499 +#else
5500 + " addu %0, %2 \n"
5501 +#endif
5502 + " sc %0, %1 \n"
5503 + " beqz %0, 1b \n"
5504 +#ifdef CONFIG_PAX_REFCOUNT
5505 + "3: \n"
5506 + _ASM_EXTABLE(2b, 3b)
5507 +#endif
5508 + " .set mips0 \n"
5509 + : "=&r" (temp), "+m" (v->counter)
5510 + : "Ir" (i));
5511 + } else {
5512 + unsigned long flags;
5513 +
5514 + raw_local_irq_save(flags);
5515 + __asm__ __volatile__(
5516 +#ifdef CONFIG_PAX_REFCOUNT
5517 + /* Exception on overflow. */
5518 + "1: add %0, %1 \n"
5519 + "2: \n"
5520 + _ASM_EXTABLE(1b, 2b)
5521 +#else
5522 + " addu %0, %1 \n"
5523 +#endif
5524 + : "+r" (v->counter) : "Ir" (i));
5525 + raw_local_irq_restore(flags);
5526 + }
5527 +}
5528 +
5529 +static __inline__ void atomic_add_unchecked(int i, atomic_unchecked_t *v)
5530 {
5531 if (kernel_uses_llsc && R10000_LLSC_WAR) {
5532 int temp;
5533 @@ -90,7 +182,67 @@ static __inline__ void atomic_add(int i, atomic_t * v)
5534 *
5535 * Atomically subtracts @i from @v.
5536 */
5537 -static __inline__ void atomic_sub(int i, atomic_t * v)
5538 +static __inline__ void atomic_sub(int i, atomic_t *v)
5539 +{
5540 + int temp;
5541 +
5542 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5543 + __asm__ __volatile__(
5544 + " .set mips3 \n"
5545 + "1: ll %0, %1 # atomic64_sub \n"
5546 +#ifdef CONFIG_PAX_REFCOUNT
5547 + /* Exception on overflow. */
5548 + "2: sub %0, %2 \n"
5549 +#else
5550 + " subu %0, %2 \n"
5551 +#endif
5552 + " sc %0, %1 \n"
5553 + " beqzl %0, 1b \n"
5554 +#ifdef CONFIG_PAX_REFCOUNT
5555 + "3: \n"
5556 + _ASM_EXTABLE(2b, 3b)
5557 +#endif
5558 + " .set mips0 \n"
5559 + : "=&r" (temp), "+m" (v->counter)
5560 + : "Ir" (i));
5561 + } else if (kernel_uses_llsc) {
5562 + __asm__ __volatile__(
5563 + " .set mips3 \n"
5564 + "1: ll %0, %1 # atomic64_sub \n"
5565 +#ifdef CONFIG_PAX_REFCOUNT
5566 + /* Exception on overflow. */
5567 + "2: sub %0, %2 \n"
5568 +#else
5569 + " subu %0, %2 \n"
5570 +#endif
5571 + " sc %0, %1 \n"
5572 + " beqz %0, 1b \n"
5573 +#ifdef CONFIG_PAX_REFCOUNT
5574 + "3: \n"
5575 + _ASM_EXTABLE(2b, 3b)
5576 +#endif
5577 + " .set mips0 \n"
5578 + : "=&r" (temp), "+m" (v->counter)
5579 + : "Ir" (i));
5580 + } else {
5581 + unsigned long flags;
5582 +
5583 + raw_local_irq_save(flags);
5584 + __asm__ __volatile__(
5585 +#ifdef CONFIG_PAX_REFCOUNT
5586 + /* Exception on overflow. */
5587 + "1: sub %0, %1 \n"
5588 + "2: \n"
5589 + _ASM_EXTABLE(1b, 2b)
5590 +#else
5591 + " subu %0, %1 \n"
5592 +#endif
5593 + : "+r" (v->counter) : "Ir" (i));
5594 + raw_local_irq_restore(flags);
5595 + }
5596 +}
5597 +
5598 +static __inline__ void atomic_sub_unchecked(long i, atomic_unchecked_t *v)
5599 {
5600 if (kernel_uses_llsc && R10000_LLSC_WAR) {
5601 int temp;
5602 @@ -129,7 +281,93 @@ static __inline__ void atomic_sub(int i, atomic_t * v)
5603 /*
5604 * Same as above, but return the result value
5605 */
5606 -static __inline__ int atomic_add_return(int i, atomic_t * v)
5607 +static __inline__ int atomic_add_return(int i, atomic_t *v)
5608 +{
5609 + int result;
5610 + int temp;
5611 +
5612 + smp_mb__before_llsc();
5613 +
5614 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5615 + __asm__ __volatile__(
5616 + " .set mips3 \n"
5617 + "1: ll %1, %2 # atomic_add_return \n"
5618 +#ifdef CONFIG_PAX_REFCOUNT
5619 + "2: add %0, %1, %3 \n"
5620 +#else
5621 + " addu %0, %1, %3 \n"
5622 +#endif
5623 + " sc %0, %2 \n"
5624 + " beqzl %0, 1b \n"
5625 +#ifdef CONFIG_PAX_REFCOUNT
5626 + " b 4f \n"
5627 + " .set noreorder \n"
5628 + "3: b 5f \n"
5629 + " move %0, %1 \n"
5630 + " .set reorder \n"
5631 + _ASM_EXTABLE(2b, 3b)
5632 +#endif
5633 + "4: addu %0, %1, %3 \n"
5634 +#ifdef CONFIG_PAX_REFCOUNT
5635 + "5: \n"
5636 +#endif
5637 + " .set mips0 \n"
5638 + : "=&r" (result), "=&r" (temp), "+m" (v->counter)
5639 + : "Ir" (i));
5640 + } else if (kernel_uses_llsc) {
5641 + __asm__ __volatile__(
5642 + " .set mips3 \n"
5643 + "1: ll %1, %2 # atomic_add_return \n"
5644 +#ifdef CONFIG_PAX_REFCOUNT
5645 + "2: add %0, %1, %3 \n"
5646 +#else
5647 + " addu %0, %1, %3 \n"
5648 +#endif
5649 + " sc %0, %2 \n"
5650 + " bnez %0, 4f \n"
5651 + " b 1b \n"
5652 +#ifdef CONFIG_PAX_REFCOUNT
5653 + " .set noreorder \n"
5654 + "3: b 5f \n"
5655 + " move %0, %1 \n"
5656 + " .set reorder \n"
5657 + _ASM_EXTABLE(2b, 3b)
5658 +#endif
5659 + "4: addu %0, %1, %3 \n"
5660 +#ifdef CONFIG_PAX_REFCOUNT
5661 + "5: \n"
5662 +#endif
5663 + " .set mips0 \n"
5664 + : "=&r" (result), "=&r" (temp), "+m" (v->counter)
5665 + : "Ir" (i));
5666 + } else {
5667 + unsigned long flags;
5668 +
5669 + raw_local_irq_save(flags);
5670 + __asm__ __volatile__(
5671 + " lw %0, %1 \n"
5672 +#ifdef CONFIG_PAX_REFCOUNT
5673 + /* Exception on overflow. */
5674 + "1: add %0, %2 \n"
5675 +#else
5676 + " addu %0, %2 \n"
5677 +#endif
5678 + " sw %0, %1 \n"
5679 +#ifdef CONFIG_PAX_REFCOUNT
5680 + /* Note: Dest reg is not modified on overflow */
5681 + "2: \n"
5682 + _ASM_EXTABLE(1b, 2b)
5683 +#endif
5684 + : "=&r" (result), "+m" (v->counter) : "Ir" (i));
5685 + raw_local_irq_restore(flags);
5686 + }
5687 +
5688 + smp_llsc_mb();
5689 +
5690 + return result;
5691 +}
5692 +
5693 +static __inline__ int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
5694 {
5695 int result;
5696
5697 @@ -178,7 +416,93 @@ static __inline__ int atomic_add_return(int i, atomic_t * v)
5698 return result;
5699 }
5700
5701 -static __inline__ int atomic_sub_return(int i, atomic_t * v)
5702 +static __inline__ int atomic_sub_return(int i, atomic_t *v)
5703 +{
5704 + int result;
5705 + int temp;
5706 +
5707 + smp_mb__before_llsc();
5708 +
5709 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5710 + __asm__ __volatile__(
5711 + " .set mips3 \n"
5712 + "1: ll %1, %2 # atomic_sub_return \n"
5713 +#ifdef CONFIG_PAX_REFCOUNT
5714 + "2: sub %0, %1, %3 \n"
5715 +#else
5716 + " subu %0, %1, %3 \n"
5717 +#endif
5718 + " sc %0, %2 \n"
5719 + " beqzl %0, 1b \n"
5720 +#ifdef CONFIG_PAX_REFCOUNT
5721 + " b 4f \n"
5722 + " .set noreorder \n"
5723 + "3: b 5f \n"
5724 + " move %0, %1 \n"
5725 + " .set reorder \n"
5726 + _ASM_EXTABLE(2b, 3b)
5727 +#endif
5728 + "4: subu %0, %1, %3 \n"
5729 +#ifdef CONFIG_PAX_REFCOUNT
5730 + "5: \n"
5731 +#endif
5732 + " .set mips0 \n"
5733 + : "=&r" (result), "=&r" (temp), "=m" (v->counter)
5734 + : "Ir" (i), "m" (v->counter)
5735 + : "memory");
5736 + } else if (kernel_uses_llsc) {
5737 + __asm__ __volatile__(
5738 + " .set mips3 \n"
5739 + "1: ll %1, %2 # atomic_sub_return \n"
5740 +#ifdef CONFIG_PAX_REFCOUNT
5741 + "2: sub %0, %1, %3 \n"
5742 +#else
5743 + " subu %0, %1, %3 \n"
5744 +#endif
5745 + " sc %0, %2 \n"
5746 + " bnez %0, 4f \n"
5747 + " b 1b \n"
5748 +#ifdef CONFIG_PAX_REFCOUNT
5749 + " .set noreorder \n"
5750 + "3: b 5f \n"
5751 + " move %0, %1 \n"
5752 + " .set reorder \n"
5753 + _ASM_EXTABLE(2b, 3b)
5754 +#endif
5755 + "4: subu %0, %1, %3 \n"
5756 +#ifdef CONFIG_PAX_REFCOUNT
5757 + "5: \n"
5758 +#endif
5759 + " .set mips0 \n"
5760 + : "=&r" (result), "=&r" (temp), "+m" (v->counter)
5761 + : "Ir" (i));
5762 + } else {
5763 + unsigned long flags;
5764 +
5765 + raw_local_irq_save(flags);
5766 + __asm__ __volatile__(
5767 + " lw %0, %1 \n"
5768 +#ifdef CONFIG_PAX_REFCOUNT
5769 + /* Exception on overflow. */
5770 + "1: sub %0, %2 \n"
5771 +#else
5772 + " subu %0, %2 \n"
5773 +#endif
5774 + " sw %0, %1 \n"
5775 +#ifdef CONFIG_PAX_REFCOUNT
5776 + /* Note: Dest reg is not modified on overflow */
5777 + "2: \n"
5778 + _ASM_EXTABLE(1b, 2b)
5779 +#endif
5780 + : "=&r" (result), "+m" (v->counter) : "Ir" (i));
5781 + raw_local_irq_restore(flags);
5782 + }
5783 +
5784 + smp_llsc_mb();
5785 +
5786 + return result;
5787 +}
5788 +static __inline__ int atomic_sub_return_unchecked(int i, atomic_unchecked_t *v)
5789 {
5790 int result;
5791
5792 @@ -238,7 +562,7 @@ static __inline__ int atomic_sub_return(int i, atomic_t * v)
5793 * Atomically test @v and subtract @i if @v is greater or equal than @i.
5794 * The function returns the old value of @v minus @i.
5795 */
5796 -static __inline__ int atomic_sub_if_positive(int i, atomic_t * v)
5797 +static __inline__ int atomic_sub_if_positive(int i, atomic_t *v)
5798 {
5799 int result;
5800
5801 @@ -295,8 +619,26 @@ static __inline__ int atomic_sub_if_positive(int i, atomic_t * v)
5802 return result;
5803 }
5804
5805 -#define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
5806 -#define atomic_xchg(v, new) (xchg(&((v)->counter), (new)))
5807 +static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
5808 +{
5809 + return cmpxchg(&v->counter, old, new);
5810 +}
5811 +
5812 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old,
5813 + int new)
5814 +{
5815 + return cmpxchg(&(v->counter), old, new);
5816 +}
5817 +
5818 +static inline int atomic_xchg(atomic_t *v, int new)
5819 +{
5820 + return xchg(&v->counter, new);
5821 +}
5822 +
5823 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
5824 +{
5825 + return xchg(&(v->counter), new);
5826 +}
5827
5828 /**
5829 * __atomic_add_unless - add unless the number is a given value
5830 @@ -324,6 +666,10 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5831
5832 #define atomic_dec_return(v) atomic_sub_return(1, (v))
5833 #define atomic_inc_return(v) atomic_add_return(1, (v))
5834 +static __inline__ int atomic_inc_return_unchecked(atomic_unchecked_t *v)
5835 +{
5836 + return atomic_add_return_unchecked(1, v);
5837 +}
5838
5839 /*
5840 * atomic_sub_and_test - subtract value from variable and test result
5841 @@ -345,6 +691,10 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5842 * other cases.
5843 */
5844 #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
5845 +static __inline__ int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
5846 +{
5847 + return atomic_add_return_unchecked(1, v) == 0;
5848 +}
5849
5850 /*
5851 * atomic_dec_and_test - decrement by 1 and test
5852 @@ -369,6 +719,10 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5853 * Atomically increments @v by 1.
5854 */
5855 #define atomic_inc(v) atomic_add(1, (v))
5856 +static __inline__ void atomic_inc_unchecked(atomic_unchecked_t *v)
5857 +{
5858 + atomic_add_unchecked(1, v);
5859 +}
5860
5861 /*
5862 * atomic_dec - decrement and test
5863 @@ -377,6 +731,10 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5864 * Atomically decrements @v by 1.
5865 */
5866 #define atomic_dec(v) atomic_sub(1, (v))
5867 +static __inline__ void atomic_dec_unchecked(atomic_unchecked_t *v)
5868 +{
5869 + atomic_sub_unchecked(1, v);
5870 +}
5871
5872 /*
5873 * atomic_add_negative - add and test if negative
5874 @@ -398,14 +756,30 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5875 * @v: pointer of type atomic64_t
5876 *
5877 */
5878 -#define atomic64_read(v) (*(volatile long *)&(v)->counter)
5879 +static inline long atomic64_read(const atomic64_t *v)
5880 +{
5881 + return (*(volatile const long *) &v->counter);
5882 +}
5883 +
5884 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
5885 +{
5886 + return (*(volatile const long *) &v->counter);
5887 +}
5888
5889 /*
5890 * atomic64_set - set atomic variable
5891 * @v: pointer of type atomic64_t
5892 * @i: required value
5893 */
5894 -#define atomic64_set(v, i) ((v)->counter = (i))
5895 +static inline void atomic64_set(atomic64_t *v, long i)
5896 +{
5897 + v->counter = i;
5898 +}
5899 +
5900 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
5901 +{
5902 + v->counter = i;
5903 +}
5904
5905 /*
5906 * atomic64_add - add integer to atomic variable
5907 @@ -414,7 +788,66 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5908 *
5909 * Atomically adds @i to @v.
5910 */
5911 -static __inline__ void atomic64_add(long i, atomic64_t * v)
5912 +static __inline__ void atomic64_add(long i, atomic64_t *v)
5913 +{
5914 + long temp;
5915 +
5916 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5917 + __asm__ __volatile__(
5918 + " .set mips3 \n"
5919 + "1: lld %0, %1 # atomic64_add \n"
5920 +#ifdef CONFIG_PAX_REFCOUNT
5921 + /* Exception on overflow. */
5922 + "2: dadd %0, %2 \n"
5923 +#else
5924 + " daddu %0, %2 \n"
5925 +#endif
5926 + " scd %0, %1 \n"
5927 + " beqzl %0, 1b \n"
5928 +#ifdef CONFIG_PAX_REFCOUNT
5929 + "3: \n"
5930 + _ASM_EXTABLE(2b, 3b)
5931 +#endif
5932 + " .set mips0 \n"
5933 + : "=&r" (temp), "+m" (v->counter)
5934 + : "Ir" (i));
5935 + } else if (kernel_uses_llsc) {
5936 + __asm__ __volatile__(
5937 + " .set mips3 \n"
5938 + "1: lld %0, %1 # atomic64_add \n"
5939 +#ifdef CONFIG_PAX_REFCOUNT
5940 + /* Exception on overflow. */
5941 + "2: dadd %0, %2 \n"
5942 +#else
5943 + " daddu %0, %2 \n"
5944 +#endif
5945 + " scd %0, %1 \n"
5946 + " beqz %0, 1b \n"
5947 +#ifdef CONFIG_PAX_REFCOUNT
5948 + "3: \n"
5949 + _ASM_EXTABLE(2b, 3b)
5950 +#endif
5951 + " .set mips0 \n"
5952 + : "=&r" (temp), "+m" (v->counter)
5953 + : "Ir" (i));
5954 + } else {
5955 + unsigned long flags;
5956 +
5957 + raw_local_irq_save(flags);
5958 + __asm__ __volatile__(
5959 +#ifdef CONFIG_PAX_REFCOUNT
5960 + /* Exception on overflow. */
5961 + "1: dadd %0, %1 \n"
5962 + "2: \n"
5963 + _ASM_EXTABLE(1b, 2b)
5964 +#else
5965 + " daddu %0, %1 \n"
5966 +#endif
5967 + : "+r" (v->counter) : "Ir" (i));
5968 + raw_local_irq_restore(flags);
5969 + }
5970 +}
5971 +static __inline__ void atomic64_add_unchecked(long i, atomic64_unchecked_t *v)
5972 {
5973 if (kernel_uses_llsc && R10000_LLSC_WAR) {
5974 long temp;
5975 @@ -457,7 +890,67 @@ static __inline__ void atomic64_add(long i, atomic64_t * v)
5976 *
5977 * Atomically subtracts @i from @v.
5978 */
5979 -static __inline__ void atomic64_sub(long i, atomic64_t * v)
5980 +static __inline__ void atomic64_sub(long i, atomic64_t *v)
5981 +{
5982 + long temp;
5983 +
5984 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5985 + __asm__ __volatile__(
5986 + " .set mips3 \n"
5987 + "1: lld %0, %1 # atomic64_sub \n"
5988 +#ifdef CONFIG_PAX_REFCOUNT
5989 + /* Exception on overflow. */
5990 + "2: dsub %0, %2 \n"
5991 +#else
5992 + " dsubu %0, %2 \n"
5993 +#endif
5994 + " scd %0, %1 \n"
5995 + " beqzl %0, 1b \n"
5996 +#ifdef CONFIG_PAX_REFCOUNT
5997 + "3: \n"
5998 + _ASM_EXTABLE(2b, 3b)
5999 +#endif
6000 + " .set mips0 \n"
6001 + : "=&r" (temp), "+m" (v->counter)
6002 + : "Ir" (i));
6003 + } else if (kernel_uses_llsc) {
6004 + __asm__ __volatile__(
6005 + " .set mips3 \n"
6006 + "1: lld %0, %1 # atomic64_sub \n"
6007 +#ifdef CONFIG_PAX_REFCOUNT
6008 + /* Exception on overflow. */
6009 + "2: dsub %0, %2 \n"
6010 +#else
6011 + " dsubu %0, %2 \n"
6012 +#endif
6013 + " scd %0, %1 \n"
6014 + " beqz %0, 1b \n"
6015 +#ifdef CONFIG_PAX_REFCOUNT
6016 + "3: \n"
6017 + _ASM_EXTABLE(2b, 3b)
6018 +#endif
6019 + " .set mips0 \n"
6020 + : "=&r" (temp), "+m" (v->counter)
6021 + : "Ir" (i));
6022 + } else {
6023 + unsigned long flags;
6024 +
6025 + raw_local_irq_save(flags);
6026 + __asm__ __volatile__(
6027 +#ifdef CONFIG_PAX_REFCOUNT
6028 + /* Exception on overflow. */
6029 + "1: dsub %0, %1 \n"
6030 + "2: \n"
6031 + _ASM_EXTABLE(1b, 2b)
6032 +#else
6033 + " dsubu %0, %1 \n"
6034 +#endif
6035 + : "+r" (v->counter) : "Ir" (i));
6036 + raw_local_irq_restore(flags);
6037 + }
6038 +}
6039 +
6040 +static __inline__ void atomic64_sub_unchecked(long i, atomic64_unchecked_t *v)
6041 {
6042 if (kernel_uses_llsc && R10000_LLSC_WAR) {
6043 long temp;
6044 @@ -496,7 +989,93 @@ static __inline__ void atomic64_sub(long i, atomic64_t * v)
6045 /*
6046 * Same as above, but return the result value
6047 */
6048 -static __inline__ long atomic64_add_return(long i, atomic64_t * v)
6049 +static __inline__ long atomic64_add_return(long i, atomic64_t *v)
6050 +{
6051 + long result;
6052 + long temp;
6053 +
6054 + smp_mb__before_llsc();
6055 +
6056 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
6057 + __asm__ __volatile__(
6058 + " .set mips3 \n"
6059 + "1: lld %1, %2 # atomic64_add_return \n"
6060 +#ifdef CONFIG_PAX_REFCOUNT
6061 + "2: dadd %0, %1, %3 \n"
6062 +#else
6063 + " daddu %0, %1, %3 \n"
6064 +#endif
6065 + " scd %0, %2 \n"
6066 + " beqzl %0, 1b \n"
6067 +#ifdef CONFIG_PAX_REFCOUNT
6068 + " b 4f \n"
6069 + " .set noreorder \n"
6070 + "3: b 5f \n"
6071 + " move %0, %1 \n"
6072 + " .set reorder \n"
6073 + _ASM_EXTABLE(2b, 3b)
6074 +#endif
6075 + "4: daddu %0, %1, %3 \n"
6076 +#ifdef CONFIG_PAX_REFCOUNT
6077 + "5: \n"
6078 +#endif
6079 + " .set mips0 \n"
6080 + : "=&r" (result), "=&r" (temp), "+m" (v->counter)
6081 + : "Ir" (i));
6082 + } else if (kernel_uses_llsc) {
6083 + __asm__ __volatile__(
6084 + " .set mips3 \n"
6085 + "1: lld %1, %2 # atomic64_add_return \n"
6086 +#ifdef CONFIG_PAX_REFCOUNT
6087 + "2: dadd %0, %1, %3 \n"
6088 +#else
6089 + " daddu %0, %1, %3 \n"
6090 +#endif
6091 + " scd %0, %2 \n"
6092 + " bnez %0, 4f \n"
6093 + " b 1b \n"
6094 +#ifdef CONFIG_PAX_REFCOUNT
6095 + " .set noreorder \n"
6096 + "3: b 5f \n"
6097 + " move %0, %1 \n"
6098 + " .set reorder \n"
6099 + _ASM_EXTABLE(2b, 3b)
6100 +#endif
6101 + "4: daddu %0, %1, %3 \n"
6102 +#ifdef CONFIG_PAX_REFCOUNT
6103 + "5: \n"
6104 +#endif
6105 + " .set mips0 \n"
6106 + : "=&r" (result), "=&r" (temp), "=m" (v->counter)
6107 + : "Ir" (i), "m" (v->counter)
6108 + : "memory");
6109 + } else {
6110 + unsigned long flags;
6111 +
6112 + raw_local_irq_save(flags);
6113 + __asm__ __volatile__(
6114 + " ld %0, %1 \n"
6115 +#ifdef CONFIG_PAX_REFCOUNT
6116 + /* Exception on overflow. */
6117 + "1: dadd %0, %2 \n"
6118 +#else
6119 + " daddu %0, %2 \n"
6120 +#endif
6121 + " sd %0, %1 \n"
6122 +#ifdef CONFIG_PAX_REFCOUNT
6123 + /* Note: Dest reg is not modified on overflow */
6124 + "2: \n"
6125 + _ASM_EXTABLE(1b, 2b)
6126 +#endif
6127 + : "=&r" (result), "+m" (v->counter) : "Ir" (i));
6128 + raw_local_irq_restore(flags);
6129 + }
6130 +
6131 + smp_llsc_mb();
6132 +
6133 + return result;
6134 +}
6135 +static __inline__ long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
6136 {
6137 long result;
6138
6139 @@ -546,7 +1125,97 @@ static __inline__ long atomic64_add_return(long i, atomic64_t * v)
6140 return result;
6141 }
6142
6143 -static __inline__ long atomic64_sub_return(long i, atomic64_t * v)
6144 +static __inline__ long atomic64_sub_return(long i, atomic64_t *v)
6145 +{
6146 + long result;
6147 + long temp;
6148 +
6149 + smp_mb__before_llsc();
6150 +
6151 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
6152 + long temp;
6153 +
6154 + __asm__ __volatile__(
6155 + " .set mips3 \n"
6156 + "1: lld %1, %2 # atomic64_sub_return \n"
6157 +#ifdef CONFIG_PAX_REFCOUNT
6158 + "2: dsub %0, %1, %3 \n"
6159 +#else
6160 + " dsubu %0, %1, %3 \n"
6161 +#endif
6162 + " scd %0, %2 \n"
6163 + " beqzl %0, 1b \n"
6164 +#ifdef CONFIG_PAX_REFCOUNT
6165 + " b 4f \n"
6166 + " .set noreorder \n"
6167 + "3: b 5f \n"
6168 + " move %0, %1 \n"
6169 + " .set reorder \n"
6170 + _ASM_EXTABLE(2b, 3b)
6171 +#endif
6172 + "4: dsubu %0, %1, %3 \n"
6173 +#ifdef CONFIG_PAX_REFCOUNT
6174 + "5: \n"
6175 +#endif
6176 + " .set mips0 \n"
6177 + : "=&r" (result), "=&r" (temp), "=m" (v->counter)
6178 + : "Ir" (i), "m" (v->counter)
6179 + : "memory");
6180 + } else if (kernel_uses_llsc) {
6181 + __asm__ __volatile__(
6182 + " .set mips3 \n"
6183 + "1: lld %1, %2 # atomic64_sub_return \n"
6184 +#ifdef CONFIG_PAX_REFCOUNT
6185 + "2: dsub %0, %1, %3 \n"
6186 +#else
6187 + " dsubu %0, %1, %3 \n"
6188 +#endif
6189 + " scd %0, %2 \n"
6190 + " bnez %0, 4f \n"
6191 + " b 1b \n"
6192 +#ifdef CONFIG_PAX_REFCOUNT
6193 + " .set noreorder \n"
6194 + "3: b 5f \n"
6195 + " move %0, %1 \n"
6196 + " .set reorder \n"
6197 + _ASM_EXTABLE(2b, 3b)
6198 +#endif
6199 + "4: dsubu %0, %1, %3 \n"
6200 +#ifdef CONFIG_PAX_REFCOUNT
6201 + "5: \n"
6202 +#endif
6203 + " .set mips0 \n"
6204 + : "=&r" (result), "=&r" (temp), "=m" (v->counter)
6205 + : "Ir" (i), "m" (v->counter)
6206 + : "memory");
6207 + } else {
6208 + unsigned long flags;
6209 +
6210 + raw_local_irq_save(flags);
6211 + __asm__ __volatile__(
6212 + " ld %0, %1 \n"
6213 +#ifdef CONFIG_PAX_REFCOUNT
6214 + /* Exception on overflow. */
6215 + "1: dsub %0, %2 \n"
6216 +#else
6217 + " dsubu %0, %2 \n"
6218 +#endif
6219 + " sd %0, %1 \n"
6220 +#ifdef CONFIG_PAX_REFCOUNT
6221 + /* Note: Dest reg is not modified on overflow */
6222 + "2: \n"
6223 + _ASM_EXTABLE(1b, 2b)
6224 +#endif
6225 + : "=&r" (result), "+m" (v->counter) : "Ir" (i));
6226 + raw_local_irq_restore(flags);
6227 + }
6228 +
6229 + smp_llsc_mb();
6230 +
6231 + return result;
6232 +}
6233 +
6234 +static __inline__ long atomic64_sub_return_unchecked(long i, atomic64_unchecked_t *v)
6235 {
6236 long result;
6237
6238 @@ -605,7 +1274,7 @@ static __inline__ long atomic64_sub_return(long i, atomic64_t * v)
6239 * Atomically test @v and subtract @i if @v is greater or equal than @i.
6240 * The function returns the old value of @v minus @i.
6241 */
6242 -static __inline__ long atomic64_sub_if_positive(long i, atomic64_t * v)
6243 +static __inline__ long atomic64_sub_if_positive(long i, atomic64_t *v)
6244 {
6245 long result;
6246
6247 @@ -662,9 +1331,26 @@ static __inline__ long atomic64_sub_if_positive(long i, atomic64_t * v)
6248 return result;
6249 }
6250
6251 -#define atomic64_cmpxchg(v, o, n) \
6252 - ((__typeof__((v)->counter))cmpxchg(&((v)->counter), (o), (n)))
6253 -#define atomic64_xchg(v, new) (xchg(&((v)->counter), (new)))
6254 +static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
6255 +{
6256 + return cmpxchg(&v->counter, old, new);
6257 +}
6258 +
6259 +static inline long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long old,
6260 + long new)
6261 +{
6262 + return cmpxchg(&(v->counter), old, new);
6263 +}
6264 +
6265 +static inline long atomic64_xchg(atomic64_t *v, long new)
6266 +{
6267 + return xchg(&v->counter, new);
6268 +}
6269 +
6270 +static inline long atomic64_xchg_unchecked(atomic64_unchecked_t *v, long new)
6271 +{
6272 + return xchg(&(v->counter), new);
6273 +}
6274
6275 /**
6276 * atomic64_add_unless - add unless the number is a given value
6277 @@ -694,6 +1380,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
6278
6279 #define atomic64_dec_return(v) atomic64_sub_return(1, (v))
6280 #define atomic64_inc_return(v) atomic64_add_return(1, (v))
6281 +#define atomic64_inc_return_unchecked(v) atomic64_add_return_unchecked(1, (v))
6282
6283 /*
6284 * atomic64_sub_and_test - subtract value from variable and test result
6285 @@ -715,6 +1402,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
6286 * other cases.
6287 */
6288 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
6289 +#define atomic64_inc_and_test_unchecked(v) atomic64_add_return_unchecked(1, (v)) == 0)
6290
6291 /*
6292 * atomic64_dec_and_test - decrement by 1 and test
6293 @@ -739,6 +1427,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
6294 * Atomically increments @v by 1.
6295 */
6296 #define atomic64_inc(v) atomic64_add(1, (v))
6297 +#define atomic64_inc_unchecked(v) atomic64_add_unchecked(1, (v))
6298
6299 /*
6300 * atomic64_dec - decrement and test
6301 @@ -747,6 +1436,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
6302 * Atomically decrements @v by 1.
6303 */
6304 #define atomic64_dec(v) atomic64_sub(1, (v))
6305 +#define atomic64_dec_unchecked(v) atomic64_sub_unchecked(1, (v))
6306
6307 /*
6308 * atomic64_add_negative - add and test if negative
6309 diff --git a/arch/mips/include/asm/cache.h b/arch/mips/include/asm/cache.h
6310 index b4db69f..8f3b093 100644
6311 --- a/arch/mips/include/asm/cache.h
6312 +++ b/arch/mips/include/asm/cache.h
6313 @@ -9,10 +9,11 @@
6314 #ifndef _ASM_CACHE_H
6315 #define _ASM_CACHE_H
6316
6317 +#include <linux/const.h>
6318 #include <kmalloc.h>
6319
6320 #define L1_CACHE_SHIFT CONFIG_MIPS_L1_CACHE_SHIFT
6321 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
6322 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
6323
6324 #define SMP_CACHE_SHIFT L1_CACHE_SHIFT
6325 #define SMP_CACHE_BYTES L1_CACHE_BYTES
6326 diff --git a/arch/mips/include/asm/elf.h b/arch/mips/include/asm/elf.h
6327 index cf3ae24..238d22f 100644
6328 --- a/arch/mips/include/asm/elf.h
6329 +++ b/arch/mips/include/asm/elf.h
6330 @@ -372,13 +372,16 @@ extern const char *__elf_platform;
6331 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
6332 #endif
6333
6334 +#ifdef CONFIG_PAX_ASLR
6335 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
6336 +
6337 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6338 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6339 +#endif
6340 +
6341 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
6342 struct linux_binprm;
6343 extern int arch_setup_additional_pages(struct linux_binprm *bprm,
6344 int uses_interp);
6345
6346 -struct mm_struct;
6347 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
6348 -#define arch_randomize_brk arch_randomize_brk
6349 -
6350 #endif /* _ASM_ELF_H */
6351 diff --git a/arch/mips/include/asm/exec.h b/arch/mips/include/asm/exec.h
6352 index c1f6afa..38cc6e9 100644
6353 --- a/arch/mips/include/asm/exec.h
6354 +++ b/arch/mips/include/asm/exec.h
6355 @@ -12,6 +12,6 @@
6356 #ifndef _ASM_EXEC_H
6357 #define _ASM_EXEC_H
6358
6359 -extern unsigned long arch_align_stack(unsigned long sp);
6360 +#define arch_align_stack(x) ((x) & ~0xfUL)
6361
6362 #endif /* _ASM_EXEC_H */
6363 diff --git a/arch/mips/include/asm/local.h b/arch/mips/include/asm/local.h
6364 index d44622c..64990d2 100644
6365 --- a/arch/mips/include/asm/local.h
6366 +++ b/arch/mips/include/asm/local.h
6367 @@ -12,15 +12,25 @@ typedef struct
6368 atomic_long_t a;
6369 } local_t;
6370
6371 +typedef struct {
6372 + atomic_long_unchecked_t a;
6373 +} local_unchecked_t;
6374 +
6375 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
6376
6377 #define local_read(l) atomic_long_read(&(l)->a)
6378 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
6379 #define local_set(l, i) atomic_long_set(&(l)->a, (i))
6380 +#define local_set_unchecked(l, i) atomic_long_set_unchecked(&(l)->a, (i))
6381
6382 #define local_add(i, l) atomic_long_add((i), (&(l)->a))
6383 +#define local_add_unchecked(i, l) atomic_long_add_unchecked((i), (&(l)->a))
6384 #define local_sub(i, l) atomic_long_sub((i), (&(l)->a))
6385 +#define local_sub_unchecked(i, l) atomic_long_sub_unchecked((i), (&(l)->a))
6386 #define local_inc(l) atomic_long_inc(&(l)->a)
6387 +#define local_inc_unchecked(l) atomic_long_inc_unchecked(&(l)->a)
6388 #define local_dec(l) atomic_long_dec(&(l)->a)
6389 +#define local_dec_unchecked(l) atomic_long_dec_unchecked(&(l)->a)
6390
6391 /*
6392 * Same as above, but return the result value
6393 @@ -70,6 +80,51 @@ static __inline__ long local_add_return(long i, local_t * l)
6394 return result;
6395 }
6396
6397 +static __inline__ long local_add_return_unchecked(long i, local_unchecked_t * l)
6398 +{
6399 + unsigned long result;
6400 +
6401 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
6402 + unsigned long temp;
6403 +
6404 + __asm__ __volatile__(
6405 + " .set mips3 \n"
6406 + "1:" __LL "%1, %2 # local_add_return \n"
6407 + " addu %0, %1, %3 \n"
6408 + __SC "%0, %2 \n"
6409 + " beqzl %0, 1b \n"
6410 + " addu %0, %1, %3 \n"
6411 + " .set mips0 \n"
6412 + : "=&r" (result), "=&r" (temp), "=m" (l->a.counter)
6413 + : "Ir" (i), "m" (l->a.counter)
6414 + : "memory");
6415 + } else if (kernel_uses_llsc) {
6416 + unsigned long temp;
6417 +
6418 + __asm__ __volatile__(
6419 + " .set mips3 \n"
6420 + "1:" __LL "%1, %2 # local_add_return \n"
6421 + " addu %0, %1, %3 \n"
6422 + __SC "%0, %2 \n"
6423 + " beqz %0, 1b \n"
6424 + " addu %0, %1, %3 \n"
6425 + " .set mips0 \n"
6426 + : "=&r" (result), "=&r" (temp), "=m" (l->a.counter)
6427 + : "Ir" (i), "m" (l->a.counter)
6428 + : "memory");
6429 + } else {
6430 + unsigned long flags;
6431 +
6432 + local_irq_save(flags);
6433 + result = l->a.counter;
6434 + result += i;
6435 + l->a.counter = result;
6436 + local_irq_restore(flags);
6437 + }
6438 +
6439 + return result;
6440 +}
6441 +
6442 static __inline__ long local_sub_return(long i, local_t * l)
6443 {
6444 unsigned long result;
6445 @@ -117,6 +172,8 @@ static __inline__ long local_sub_return(long i, local_t * l)
6446
6447 #define local_cmpxchg(l, o, n) \
6448 ((long)cmpxchg_local(&((l)->a.counter), (o), (n)))
6449 +#define local_cmpxchg_unchecked(l, o, n) \
6450 + ((long)cmpxchg_local(&((l)->a.counter), (o), (n)))
6451 #define local_xchg(l, n) (atomic_long_xchg((&(l)->a), (n)))
6452
6453 /**
6454 diff --git a/arch/mips/include/asm/page.h b/arch/mips/include/asm/page.h
6455 index f6be474..12ad554 100644
6456 --- a/arch/mips/include/asm/page.h
6457 +++ b/arch/mips/include/asm/page.h
6458 @@ -95,7 +95,7 @@ extern void copy_user_highpage(struct page *to, struct page *from,
6459 #ifdef CONFIG_CPU_MIPS32
6460 typedef struct { unsigned long pte_low, pte_high; } pte_t;
6461 #define pte_val(x) ((x).pte_low | ((unsigned long long)(x).pte_high << 32))
6462 - #define __pte(x) ({ pte_t __pte = {(x), ((unsigned long long)(x)) >> 32}; __pte; })
6463 + #define __pte(x) ({ pte_t __pte = {(x), (x) >> 32}; __pte; })
6464 #else
6465 typedef struct { unsigned long long pte; } pte_t;
6466 #define pte_val(x) ((x).pte)
6467 diff --git a/arch/mips/include/asm/pgalloc.h b/arch/mips/include/asm/pgalloc.h
6468 index 881d18b..cea38bc 100644
6469 --- a/arch/mips/include/asm/pgalloc.h
6470 +++ b/arch/mips/include/asm/pgalloc.h
6471 @@ -37,6 +37,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6472 {
6473 set_pud(pud, __pud((unsigned long)pmd));
6474 }
6475 +
6476 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6477 +{
6478 + pud_populate(mm, pud, pmd);
6479 +}
6480 #endif
6481
6482 /*
6483 diff --git a/arch/mips/include/asm/smtc_proc.h b/arch/mips/include/asm/smtc_proc.h
6484 index 25da651..ae2a259 100644
6485 --- a/arch/mips/include/asm/smtc_proc.h
6486 +++ b/arch/mips/include/asm/smtc_proc.h
6487 @@ -18,6 +18,6 @@ extern struct smtc_cpu_proc smtc_cpu_stats[NR_CPUS];
6488
6489 /* Count of number of recoveries of "stolen" FPU access rights on 34K */
6490
6491 -extern atomic_t smtc_fpu_recoveries;
6492 +extern atomic_unchecked_t smtc_fpu_recoveries;
6493
6494 #endif /* __ASM_SMTC_PROC_H */
6495 diff --git a/arch/mips/include/asm/thread_info.h b/arch/mips/include/asm/thread_info.h
6496 index 61215a3..213ee0e 100644
6497 --- a/arch/mips/include/asm/thread_info.h
6498 +++ b/arch/mips/include/asm/thread_info.h
6499 @@ -116,6 +116,8 @@ static inline struct thread_info *current_thread_info(void)
6500 #define TIF_32BIT_ADDR 23 /* 32-bit address space (o32/n32) */
6501 #define TIF_FPUBOUND 24 /* thread bound to FPU-full CPU set */
6502 #define TIF_LOAD_WATCH 25 /* If set, load watch registers */
6503 +/* li takes a 32bit immediate */
6504 +#define TIF_GRSEC_SETXID 29 /* update credentials on syscall entry/exit */
6505 #define TIF_SYSCALL_TRACE 31 /* syscall trace active */
6506
6507 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
6508 @@ -132,20 +134,18 @@ static inline struct thread_info *current_thread_info(void)
6509 #define _TIF_32BIT_ADDR (1<<TIF_32BIT_ADDR)
6510 #define _TIF_FPUBOUND (1<<TIF_FPUBOUND)
6511 #define _TIF_LOAD_WATCH (1<<TIF_LOAD_WATCH)
6512 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
6513
6514 -#define _TIF_WORK_SYSCALL_ENTRY (_TIF_NOHZ | _TIF_SYSCALL_TRACE | \
6515 - _TIF_SYSCALL_AUDIT)
6516 +#define _TIF_WORK_SYSCALL_ENTRY (_TIF_NOHZ | _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_GRSEC_SETXID)
6517
6518 /* work to do in syscall_trace_leave() */
6519 -#define _TIF_WORK_SYSCALL_EXIT (_TIF_NOHZ | _TIF_SYSCALL_TRACE | \
6520 - _TIF_SYSCALL_AUDIT)
6521 +#define _TIF_WORK_SYSCALL_EXIT (_TIF_NOHZ | _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_GRSEC_SETXID)
6522
6523 /* work to do on interrupt/exception return */
6524 #define _TIF_WORK_MASK \
6525 (_TIF_SIGPENDING | _TIF_NEED_RESCHED | _TIF_NOTIFY_RESUME)
6526 /* work to do on any return to u-space */
6527 -#define _TIF_ALLWORK_MASK (_TIF_NOHZ | _TIF_WORK_MASK | \
6528 - _TIF_WORK_SYSCALL_EXIT)
6529 +#define _TIF_ALLWORK_MASK (_TIF_NOHZ | _TIF_WORK_MASK | _TIF_WORK_SYSCALL_EXIT | _TIF_GRSEC_SETXID)
6530
6531 #endif /* __KERNEL__ */
6532
6533 diff --git a/arch/mips/kernel/binfmt_elfn32.c b/arch/mips/kernel/binfmt_elfn32.c
6534 index 1188e00..41cf144 100644
6535 --- a/arch/mips/kernel/binfmt_elfn32.c
6536 +++ b/arch/mips/kernel/binfmt_elfn32.c
6537 @@ -50,6 +50,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
6538 #undef ELF_ET_DYN_BASE
6539 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
6540
6541 +#ifdef CONFIG_PAX_ASLR
6542 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
6543 +
6544 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6545 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6546 +#endif
6547 +
6548 #include <asm/processor.h>
6549 #include <linux/module.h>
6550 #include <linux/elfcore.h>
6551 diff --git a/arch/mips/kernel/binfmt_elfo32.c b/arch/mips/kernel/binfmt_elfo32.c
6552 index 202e581..689ca79 100644
6553 --- a/arch/mips/kernel/binfmt_elfo32.c
6554 +++ b/arch/mips/kernel/binfmt_elfo32.c
6555 @@ -56,6 +56,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
6556 #undef ELF_ET_DYN_BASE
6557 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
6558
6559 +#ifdef CONFIG_PAX_ASLR
6560 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
6561 +
6562 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6563 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6564 +#endif
6565 +
6566 #include <asm/processor.h>
6567
6568 /*
6569 diff --git a/arch/mips/kernel/irq.c b/arch/mips/kernel/irq.c
6570 index d1fea7a..45602ea 100644
6571 --- a/arch/mips/kernel/irq.c
6572 +++ b/arch/mips/kernel/irq.c
6573 @@ -77,17 +77,17 @@ void ack_bad_irq(unsigned int irq)
6574 printk("unexpected IRQ # %d\n", irq);
6575 }
6576
6577 -atomic_t irq_err_count;
6578 +atomic_unchecked_t irq_err_count;
6579
6580 int arch_show_interrupts(struct seq_file *p, int prec)
6581 {
6582 - seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
6583 + seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read_unchecked(&irq_err_count));
6584 return 0;
6585 }
6586
6587 asmlinkage void spurious_interrupt(void)
6588 {
6589 - atomic_inc(&irq_err_count);
6590 + atomic_inc_unchecked(&irq_err_count);
6591 }
6592
6593 void __init init_IRQ(void)
6594 diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
6595 index ddc7610..8c58f17 100644
6596 --- a/arch/mips/kernel/process.c
6597 +++ b/arch/mips/kernel/process.c
6598 @@ -566,15 +566,3 @@ unsigned long get_wchan(struct task_struct *task)
6599 out:
6600 return pc;
6601 }
6602 -
6603 -/*
6604 - * Don't forget that the stack pointer must be aligned on a 8 bytes
6605 - * boundary for 32-bits ABI and 16 bytes for 64-bits ABI.
6606 - */
6607 -unsigned long arch_align_stack(unsigned long sp)
6608 -{
6609 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
6610 - sp -= get_random_int() & ~PAGE_MASK;
6611 -
6612 - return sp & ALMASK;
6613 -}
6614 diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c
6615 index 8ae1ebe..1bcbf47 100644
6616 --- a/arch/mips/kernel/ptrace.c
6617 +++ b/arch/mips/kernel/ptrace.c
6618 @@ -529,6 +529,10 @@ static inline int audit_arch(void)
6619 return arch;
6620 }
6621
6622 +#ifdef CONFIG_GRKERNSEC_SETXID
6623 +extern void gr_delayed_cred_worker(void);
6624 +#endif
6625 +
6626 /*
6627 * Notification of system call entry/exit
6628 * - triggered by current->work.syscall_trace
6629 @@ -540,6 +544,11 @@ asmlinkage void syscall_trace_enter(struct pt_regs *regs)
6630 /* do the secure computing check first */
6631 secure_computing_strict(regs->regs[2]);
6632
6633 +#ifdef CONFIG_GRKERNSEC_SETXID
6634 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
6635 + gr_delayed_cred_worker();
6636 +#endif
6637 +
6638 if (!(current->ptrace & PT_PTRACED))
6639 goto out;
6640
6641 diff --git a/arch/mips/kernel/smtc-proc.c b/arch/mips/kernel/smtc-proc.c
6642 index c10aa84..9ec2e60 100644
6643 --- a/arch/mips/kernel/smtc-proc.c
6644 +++ b/arch/mips/kernel/smtc-proc.c
6645 @@ -31,7 +31,7 @@ unsigned long selfipis[NR_CPUS];
6646
6647 struct smtc_cpu_proc smtc_cpu_stats[NR_CPUS];
6648
6649 -atomic_t smtc_fpu_recoveries;
6650 +atomic_unchecked_t smtc_fpu_recoveries;
6651
6652 static int smtc_proc_show(struct seq_file *m, void *v)
6653 {
6654 @@ -48,7 +48,7 @@ static int smtc_proc_show(struct seq_file *m, void *v)
6655 for(i = 0; i < NR_CPUS; i++)
6656 seq_printf(m, "%d: %ld\n", i, smtc_cpu_stats[i].selfipis);
6657 seq_printf(m, "%d Recoveries of \"stolen\" FPU\n",
6658 - atomic_read(&smtc_fpu_recoveries));
6659 + atomic_read_unchecked(&smtc_fpu_recoveries));
6660 return 0;
6661 }
6662
6663 @@ -73,7 +73,7 @@ void init_smtc_stats(void)
6664 smtc_cpu_stats[i].selfipis = 0;
6665 }
6666
6667 - atomic_set(&smtc_fpu_recoveries, 0);
6668 + atomic_set_unchecked(&smtc_fpu_recoveries, 0);
6669
6670 proc_create("smtc", 0444, NULL, &smtc_proc_fops);
6671 }
6672 diff --git a/arch/mips/kernel/smtc.c b/arch/mips/kernel/smtc.c
6673 index dfc1b91..11a2c07 100644
6674 --- a/arch/mips/kernel/smtc.c
6675 +++ b/arch/mips/kernel/smtc.c
6676 @@ -1359,7 +1359,7 @@ void smtc_soft_dump(void)
6677 }
6678 smtc_ipi_qdump();
6679 printk("%d Recoveries of \"stolen\" FPU\n",
6680 - atomic_read(&smtc_fpu_recoveries));
6681 + atomic_read_unchecked(&smtc_fpu_recoveries));
6682 }
6683
6684
6685 diff --git a/arch/mips/kernel/sync-r4k.c b/arch/mips/kernel/sync-r4k.c
6686 index 84536bf..79caa4d 100644
6687 --- a/arch/mips/kernel/sync-r4k.c
6688 +++ b/arch/mips/kernel/sync-r4k.c
6689 @@ -21,8 +21,8 @@
6690 #include <asm/mipsregs.h>
6691
6692 static atomic_t count_start_flag = ATOMIC_INIT(0);
6693 -static atomic_t count_count_start = ATOMIC_INIT(0);
6694 -static atomic_t count_count_stop = ATOMIC_INIT(0);
6695 +static atomic_unchecked_t count_count_start = ATOMIC_INIT(0);
6696 +static atomic_unchecked_t count_count_stop = ATOMIC_INIT(0);
6697 static atomic_t count_reference = ATOMIC_INIT(0);
6698
6699 #define COUNTON 100
6700 @@ -69,13 +69,13 @@ void synchronise_count_master(int cpu)
6701
6702 for (i = 0; i < NR_LOOPS; i++) {
6703 /* slaves loop on '!= 2' */
6704 - while (atomic_read(&count_count_start) != 1)
6705 + while (atomic_read_unchecked(&count_count_start) != 1)
6706 mb();
6707 - atomic_set(&count_count_stop, 0);
6708 + atomic_set_unchecked(&count_count_stop, 0);
6709 smp_wmb();
6710
6711 /* this lets the slaves write their count register */
6712 - atomic_inc(&count_count_start);
6713 + atomic_inc_unchecked(&count_count_start);
6714
6715 /*
6716 * Everyone initialises count in the last loop:
6717 @@ -86,11 +86,11 @@ void synchronise_count_master(int cpu)
6718 /*
6719 * Wait for all slaves to leave the synchronization point:
6720 */
6721 - while (atomic_read(&count_count_stop) != 1)
6722 + while (atomic_read_unchecked(&count_count_stop) != 1)
6723 mb();
6724 - atomic_set(&count_count_start, 0);
6725 + atomic_set_unchecked(&count_count_start, 0);
6726 smp_wmb();
6727 - atomic_inc(&count_count_stop);
6728 + atomic_inc_unchecked(&count_count_stop);
6729 }
6730 /* Arrange for an interrupt in a short while */
6731 write_c0_compare(read_c0_count() + COUNTON);
6732 @@ -131,8 +131,8 @@ void synchronise_count_slave(int cpu)
6733 initcount = atomic_read(&count_reference);
6734
6735 for (i = 0; i < NR_LOOPS; i++) {
6736 - atomic_inc(&count_count_start);
6737 - while (atomic_read(&count_count_start) != 2)
6738 + atomic_inc_unchecked(&count_count_start);
6739 + while (atomic_read_unchecked(&count_count_start) != 2)
6740 mb();
6741
6742 /*
6743 @@ -141,8 +141,8 @@ void synchronise_count_slave(int cpu)
6744 if (i == NR_LOOPS-1)
6745 write_c0_count(initcount);
6746
6747 - atomic_inc(&count_count_stop);
6748 - while (atomic_read(&count_count_stop) != 2)
6749 + atomic_inc_unchecked(&count_count_stop);
6750 + while (atomic_read_unchecked(&count_count_stop) != 2)
6751 mb();
6752 }
6753 /* Arrange for an interrupt in a short while */
6754 diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
6755 index 524841f..3eef41e 100644
6756 --- a/arch/mips/kernel/traps.c
6757 +++ b/arch/mips/kernel/traps.c
6758 @@ -684,7 +684,18 @@ asmlinkage void do_ov(struct pt_regs *regs)
6759 siginfo_t info;
6760
6761 prev_state = exception_enter();
6762 - die_if_kernel("Integer overflow", regs);
6763 + if (unlikely(!user_mode(regs))) {
6764 +
6765 +#ifdef CONFIG_PAX_REFCOUNT
6766 + if (fixup_exception(regs)) {
6767 + pax_report_refcount_overflow(regs);
6768 + exception_exit(prev_state);
6769 + return;
6770 + }
6771 +#endif
6772 +
6773 + die("Integer overflow", regs);
6774 + }
6775
6776 info.si_code = FPE_INTOVF;
6777 info.si_signo = SIGFPE;
6778 diff --git a/arch/mips/mm/fault.c b/arch/mips/mm/fault.c
6779 index becc42b..9e43d4b 100644
6780 --- a/arch/mips/mm/fault.c
6781 +++ b/arch/mips/mm/fault.c
6782 @@ -28,6 +28,23 @@
6783 #include <asm/highmem.h> /* For VMALLOC_END */
6784 #include <linux/kdebug.h>
6785
6786 +#ifdef CONFIG_PAX_PAGEEXEC
6787 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
6788 +{
6789 + unsigned long i;
6790 +
6791 + printk(KERN_ERR "PAX: bytes at PC: ");
6792 + for (i = 0; i < 5; i++) {
6793 + unsigned int c;
6794 + if (get_user(c, (unsigned int *)pc+i))
6795 + printk(KERN_CONT "???????? ");
6796 + else
6797 + printk(KERN_CONT "%08x ", c);
6798 + }
6799 + printk("\n");
6800 +}
6801 +#endif
6802 +
6803 /*
6804 * This routine handles page faults. It determines the address,
6805 * and the problem, and then passes it off to one of the appropriate
6806 @@ -199,6 +216,14 @@ bad_area:
6807 bad_area_nosemaphore:
6808 /* User mode accesses just cause a SIGSEGV */
6809 if (user_mode(regs)) {
6810 +
6811 +#ifdef CONFIG_PAX_PAGEEXEC
6812 + if (cpu_has_rixi && (mm->pax_flags & MF_PAX_PAGEEXEC) && !write && address == instruction_pointer(regs)) {
6813 + pax_report_fault(regs, (void *)address, (void *)user_stack_pointer(regs));
6814 + do_group_exit(SIGKILL);
6815 + }
6816 +#endif
6817 +
6818 tsk->thread.cp0_badvaddr = address;
6819 tsk->thread.error_code = write;
6820 #if 0
6821 diff --git a/arch/mips/mm/mmap.c b/arch/mips/mm/mmap.c
6822 index f1baadd..8537544 100644
6823 --- a/arch/mips/mm/mmap.c
6824 +++ b/arch/mips/mm/mmap.c
6825 @@ -59,6 +59,7 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
6826 struct vm_area_struct *vma;
6827 unsigned long addr = addr0;
6828 int do_color_align;
6829 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
6830 struct vm_unmapped_area_info info;
6831
6832 if (unlikely(len > TASK_SIZE))
6833 @@ -84,6 +85,11 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
6834 do_color_align = 1;
6835
6836 /* requesting a specific address */
6837 +
6838 +#ifdef CONFIG_PAX_RANDMMAP
6839 + if (!(current->mm->pax_flags & MF_PAX_RANDMMAP))
6840 +#endif
6841 +
6842 if (addr) {
6843 if (do_color_align)
6844 addr = COLOUR_ALIGN(addr, pgoff);
6845 @@ -91,14 +97,14 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
6846 addr = PAGE_ALIGN(addr);
6847
6848 vma = find_vma(mm, addr);
6849 - if (TASK_SIZE - len >= addr &&
6850 - (!vma || addr + len <= vma->vm_start))
6851 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vmm, addr, len, offset))
6852 return addr;
6853 }
6854
6855 info.length = len;
6856 info.align_mask = do_color_align ? (PAGE_MASK & shm_align_mask) : 0;
6857 info.align_offset = pgoff << PAGE_SHIFT;
6858 + info.threadstack_offset = offset;
6859
6860 if (dir == DOWN) {
6861 info.flags = VM_UNMAPPED_AREA_TOPDOWN;
6862 @@ -146,6 +152,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
6863 {
6864 unsigned long random_factor = 0UL;
6865
6866 +#ifdef CONFIG_PAX_RANDMMAP
6867 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
6868 +#endif
6869 +
6870 if (current->flags & PF_RANDOMIZE) {
6871 random_factor = get_random_int();
6872 random_factor = random_factor << PAGE_SHIFT;
6873 @@ -157,40 +167,25 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
6874
6875 if (mmap_is_legacy()) {
6876 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
6877 +
6878 +#ifdef CONFIG_PAX_RANDMMAP
6879 + if (mm->pax_flags & MF_PAX_RANDMMAP)
6880 + mm->mmap_base += mm->delta_mmap;
6881 +#endif
6882 +
6883 mm->get_unmapped_area = arch_get_unmapped_area;
6884 } else {
6885 mm->mmap_base = mmap_base(random_factor);
6886 +
6887 +#ifdef CONFIG_PAX_RANDMMAP
6888 + if (mm->pax_flags & MF_PAX_RANDMMAP)
6889 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
6890 +#endif
6891 +
6892 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
6893 }
6894 }
6895
6896 -static inline unsigned long brk_rnd(void)
6897 -{
6898 - unsigned long rnd = get_random_int();
6899 -
6900 - rnd = rnd << PAGE_SHIFT;
6901 - /* 8MB for 32bit, 256MB for 64bit */
6902 - if (TASK_IS_32BIT_ADDR)
6903 - rnd = rnd & 0x7ffffful;
6904 - else
6905 - rnd = rnd & 0xffffffful;
6906 -
6907 - return rnd;
6908 -}
6909 -
6910 -unsigned long arch_randomize_brk(struct mm_struct *mm)
6911 -{
6912 - unsigned long base = mm->brk;
6913 - unsigned long ret;
6914 -
6915 - ret = PAGE_ALIGN(base + brk_rnd());
6916 -
6917 - if (ret < mm->brk)
6918 - return mm->brk;
6919 -
6920 - return ret;
6921 -}
6922 -
6923 int __virt_addr_valid(const volatile void *kaddr)
6924 {
6925 return pfn_valid(PFN_DOWN(virt_to_phys(kaddr)));
6926 diff --git a/arch/mips/sgi-ip27/ip27-nmi.c b/arch/mips/sgi-ip27/ip27-nmi.c
6927 index a2358b4..7cead4f 100644
6928 --- a/arch/mips/sgi-ip27/ip27-nmi.c
6929 +++ b/arch/mips/sgi-ip27/ip27-nmi.c
6930 @@ -187,9 +187,9 @@ void
6931 cont_nmi_dump(void)
6932 {
6933 #ifndef REAL_NMI_SIGNAL
6934 - static atomic_t nmied_cpus = ATOMIC_INIT(0);
6935 + static atomic_unchecked_t nmied_cpus = ATOMIC_INIT(0);
6936
6937 - atomic_inc(&nmied_cpus);
6938 + atomic_inc_unchecked(&nmied_cpus);
6939 #endif
6940 /*
6941 * Only allow 1 cpu to proceed
6942 @@ -233,7 +233,7 @@ cont_nmi_dump(void)
6943 udelay(10000);
6944 }
6945 #else
6946 - while (atomic_read(&nmied_cpus) != num_online_cpus());
6947 + while (atomic_read_unchecked(&nmied_cpus) != num_online_cpus());
6948 #endif
6949
6950 /*
6951 diff --git a/arch/mn10300/proc-mn103e010/include/proc/cache.h b/arch/mn10300/proc-mn103e010/include/proc/cache.h
6952 index 967d144..db12197 100644
6953 --- a/arch/mn10300/proc-mn103e010/include/proc/cache.h
6954 +++ b/arch/mn10300/proc-mn103e010/include/proc/cache.h
6955 @@ -11,12 +11,14 @@
6956 #ifndef _ASM_PROC_CACHE_H
6957 #define _ASM_PROC_CACHE_H
6958
6959 +#include <linux/const.h>
6960 +
6961 /* L1 cache */
6962
6963 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
6964 #define L1_CACHE_NENTRIES 256 /* number of entries in each way */
6965 -#define L1_CACHE_BYTES 16 /* bytes per entry */
6966 #define L1_CACHE_SHIFT 4 /* shift for bytes per entry */
6967 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
6968 #define L1_CACHE_WAYDISP 0x1000 /* displacement of one way from the next */
6969
6970 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
6971 diff --git a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
6972 index bcb5df2..84fabd2 100644
6973 --- a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
6974 +++ b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
6975 @@ -16,13 +16,15 @@
6976 #ifndef _ASM_PROC_CACHE_H
6977 #define _ASM_PROC_CACHE_H
6978
6979 +#include <linux/const.h>
6980 +
6981 /*
6982 * L1 cache
6983 */
6984 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
6985 #define L1_CACHE_NENTRIES 128 /* number of entries in each way */
6986 -#define L1_CACHE_BYTES 32 /* bytes per entry */
6987 #define L1_CACHE_SHIFT 5 /* shift for bytes per entry */
6988 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
6989 #define L1_CACHE_WAYDISP 0x1000 /* distance from one way to the next */
6990
6991 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
6992 diff --git a/arch/openrisc/include/asm/cache.h b/arch/openrisc/include/asm/cache.h
6993 index 4ce7a01..449202a 100644
6994 --- a/arch/openrisc/include/asm/cache.h
6995 +++ b/arch/openrisc/include/asm/cache.h
6996 @@ -19,11 +19,13 @@
6997 #ifndef __ASM_OPENRISC_CACHE_H
6998 #define __ASM_OPENRISC_CACHE_H
6999
7000 +#include <linux/const.h>
7001 +
7002 /* FIXME: How can we replace these with values from the CPU...
7003 * they shouldn't be hard-coded!
7004 */
7005
7006 -#define L1_CACHE_BYTES 16
7007 #define L1_CACHE_SHIFT 4
7008 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7009
7010 #endif /* __ASM_OPENRISC_CACHE_H */
7011 diff --git a/arch/parisc/include/asm/atomic.h b/arch/parisc/include/asm/atomic.h
7012 index 472886c..00e7df9 100644
7013 --- a/arch/parisc/include/asm/atomic.h
7014 +++ b/arch/parisc/include/asm/atomic.h
7015 @@ -252,6 +252,16 @@ static inline long atomic64_dec_if_positive(atomic64_t *v)
7016 return dec;
7017 }
7018
7019 +#define atomic64_read_unchecked(v) atomic64_read(v)
7020 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
7021 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
7022 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
7023 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
7024 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
7025 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
7026 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
7027 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
7028 +
7029 #endif /* !CONFIG_64BIT */
7030
7031
7032 diff --git a/arch/parisc/include/asm/cache.h b/arch/parisc/include/asm/cache.h
7033 index 47f11c7..3420df2 100644
7034 --- a/arch/parisc/include/asm/cache.h
7035 +++ b/arch/parisc/include/asm/cache.h
7036 @@ -5,6 +5,7 @@
7037 #ifndef __ARCH_PARISC_CACHE_H
7038 #define __ARCH_PARISC_CACHE_H
7039
7040 +#include <linux/const.h>
7041
7042 /*
7043 * PA 2.0 processors have 64-byte cachelines; PA 1.1 processors have
7044 @@ -15,13 +16,13 @@
7045 * just ruin performance.
7046 */
7047 #ifdef CONFIG_PA20
7048 -#define L1_CACHE_BYTES 64
7049 #define L1_CACHE_SHIFT 6
7050 #else
7051 -#define L1_CACHE_BYTES 32
7052 #define L1_CACHE_SHIFT 5
7053 #endif
7054
7055 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7056 +
7057 #ifndef __ASSEMBLY__
7058
7059 #define SMP_CACHE_BYTES L1_CACHE_BYTES
7060 diff --git a/arch/parisc/include/asm/elf.h b/arch/parisc/include/asm/elf.h
7061 index ad2b503..bdf1651 100644
7062 --- a/arch/parisc/include/asm/elf.h
7063 +++ b/arch/parisc/include/asm/elf.h
7064 @@ -342,6 +342,13 @@ struct pt_regs; /* forward declaration... */
7065
7066 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x01000000)
7067
7068 +#ifdef CONFIG_PAX_ASLR
7069 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
7070 +
7071 +#define PAX_DELTA_MMAP_LEN 16
7072 +#define PAX_DELTA_STACK_LEN 16
7073 +#endif
7074 +
7075 /* This yields a mask that user programs can use to figure out what
7076 instruction set this CPU supports. This could be done in user space,
7077 but it's not easy, and we've already done it here. */
7078 diff --git a/arch/parisc/include/asm/pgalloc.h b/arch/parisc/include/asm/pgalloc.h
7079 index fc987a1..6e068ef 100644
7080 --- a/arch/parisc/include/asm/pgalloc.h
7081 +++ b/arch/parisc/include/asm/pgalloc.h
7082 @@ -61,6 +61,11 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
7083 (__u32)(__pa((unsigned long)pmd) >> PxD_VALUE_SHIFT));
7084 }
7085
7086 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
7087 +{
7088 + pgd_populate(mm, pgd, pmd);
7089 +}
7090 +
7091 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
7092 {
7093 pmd_t *pmd = (pmd_t *)__get_free_pages(GFP_KERNEL|__GFP_REPEAT,
7094 @@ -93,6 +98,7 @@ static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
7095 #define pmd_alloc_one(mm, addr) ({ BUG(); ((pmd_t *)2); })
7096 #define pmd_free(mm, x) do { } while (0)
7097 #define pgd_populate(mm, pmd, pte) BUG()
7098 +#define pgd_populate_kernel(mm, pmd, pte) BUG()
7099
7100 #endif
7101
7102 diff --git a/arch/parisc/include/asm/pgtable.h b/arch/parisc/include/asm/pgtable.h
7103 index 34899b5..02dd060 100644
7104 --- a/arch/parisc/include/asm/pgtable.h
7105 +++ b/arch/parisc/include/asm/pgtable.h
7106 @@ -223,6 +223,17 @@ extern void purge_tlb_entries(struct mm_struct *, unsigned long);
7107 #define PAGE_EXECREAD __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_EXEC |_PAGE_ACCESSED)
7108 #define PAGE_COPY PAGE_EXECREAD
7109 #define PAGE_RWX __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_EXEC |_PAGE_ACCESSED)
7110 +
7111 +#ifdef CONFIG_PAX_PAGEEXEC
7112 +# define PAGE_SHARED_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_ACCESSED)
7113 +# define PAGE_COPY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
7114 +# define PAGE_READONLY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
7115 +#else
7116 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
7117 +# define PAGE_COPY_NOEXEC PAGE_COPY
7118 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
7119 +#endif
7120 +
7121 #define PAGE_KERNEL __pgprot(_PAGE_KERNEL)
7122 #define PAGE_KERNEL_EXEC __pgprot(_PAGE_KERNEL_EXEC)
7123 #define PAGE_KERNEL_RWX __pgprot(_PAGE_KERNEL_RWX)
7124 diff --git a/arch/parisc/include/asm/uaccess.h b/arch/parisc/include/asm/uaccess.h
7125 index e0a8235..ce2f1e1 100644
7126 --- a/arch/parisc/include/asm/uaccess.h
7127 +++ b/arch/parisc/include/asm/uaccess.h
7128 @@ -245,10 +245,10 @@ static inline unsigned long __must_check copy_from_user(void *to,
7129 const void __user *from,
7130 unsigned long n)
7131 {
7132 - int sz = __compiletime_object_size(to);
7133 + size_t sz = __compiletime_object_size(to);
7134 int ret = -EFAULT;
7135
7136 - if (likely(sz == -1 || !__builtin_constant_p(n) || sz >= n))
7137 + if (likely(sz == (size_t)-1 || !__builtin_constant_p(n) || sz >= n))
7138 ret = __copy_from_user(to, from, n);
7139 else
7140 copy_from_user_overflow();
7141 diff --git a/arch/parisc/kernel/module.c b/arch/parisc/kernel/module.c
7142 index 2a625fb..9908930 100644
7143 --- a/arch/parisc/kernel/module.c
7144 +++ b/arch/parisc/kernel/module.c
7145 @@ -98,16 +98,38 @@
7146
7147 /* three functions to determine where in the module core
7148 * or init pieces the location is */
7149 +static inline int in_init_rx(struct module *me, void *loc)
7150 +{
7151 + return (loc >= me->module_init_rx &&
7152 + loc < (me->module_init_rx + me->init_size_rx));
7153 +}
7154 +
7155 +static inline int in_init_rw(struct module *me, void *loc)
7156 +{
7157 + return (loc >= me->module_init_rw &&
7158 + loc < (me->module_init_rw + me->init_size_rw));
7159 +}
7160 +
7161 static inline int in_init(struct module *me, void *loc)
7162 {
7163 - return (loc >= me->module_init &&
7164 - loc <= (me->module_init + me->init_size));
7165 + return in_init_rx(me, loc) || in_init_rw(me, loc);
7166 +}
7167 +
7168 +static inline int in_core_rx(struct module *me, void *loc)
7169 +{
7170 + return (loc >= me->module_core_rx &&
7171 + loc < (me->module_core_rx + me->core_size_rx));
7172 +}
7173 +
7174 +static inline int in_core_rw(struct module *me, void *loc)
7175 +{
7176 + return (loc >= me->module_core_rw &&
7177 + loc < (me->module_core_rw + me->core_size_rw));
7178 }
7179
7180 static inline int in_core(struct module *me, void *loc)
7181 {
7182 - return (loc >= me->module_core &&
7183 - loc <= (me->module_core + me->core_size));
7184 + return in_core_rx(me, loc) || in_core_rw(me, loc);
7185 }
7186
7187 static inline int in_local(struct module *me, void *loc)
7188 @@ -371,13 +393,13 @@ int module_frob_arch_sections(CONST Elf_Ehdr *hdr,
7189 }
7190
7191 /* align things a bit */
7192 - me->core_size = ALIGN(me->core_size, 16);
7193 - me->arch.got_offset = me->core_size;
7194 - me->core_size += gots * sizeof(struct got_entry);
7195 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
7196 + me->arch.got_offset = me->core_size_rw;
7197 + me->core_size_rw += gots * sizeof(struct got_entry);
7198
7199 - me->core_size = ALIGN(me->core_size, 16);
7200 - me->arch.fdesc_offset = me->core_size;
7201 - me->core_size += fdescs * sizeof(Elf_Fdesc);
7202 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
7203 + me->arch.fdesc_offset = me->core_size_rw;
7204 + me->core_size_rw += fdescs * sizeof(Elf_Fdesc);
7205
7206 me->arch.got_max = gots;
7207 me->arch.fdesc_max = fdescs;
7208 @@ -395,7 +417,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
7209
7210 BUG_ON(value == 0);
7211
7212 - got = me->module_core + me->arch.got_offset;
7213 + got = me->module_core_rw + me->arch.got_offset;
7214 for (i = 0; got[i].addr; i++)
7215 if (got[i].addr == value)
7216 goto out;
7217 @@ -413,7 +435,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
7218 #ifdef CONFIG_64BIT
7219 static Elf_Addr get_fdesc(struct module *me, unsigned long value)
7220 {
7221 - Elf_Fdesc *fdesc = me->module_core + me->arch.fdesc_offset;
7222 + Elf_Fdesc *fdesc = me->module_core_rw + me->arch.fdesc_offset;
7223
7224 if (!value) {
7225 printk(KERN_ERR "%s: zero OPD requested!\n", me->name);
7226 @@ -431,7 +453,7 @@ static Elf_Addr get_fdesc(struct module *me, unsigned long value)
7227
7228 /* Create new one */
7229 fdesc->addr = value;
7230 - fdesc->gp = (Elf_Addr)me->module_core + me->arch.got_offset;
7231 + fdesc->gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
7232 return (Elf_Addr)fdesc;
7233 }
7234 #endif /* CONFIG_64BIT */
7235 @@ -843,7 +865,7 @@ register_unwind_table(struct module *me,
7236
7237 table = (unsigned char *)sechdrs[me->arch.unwind_section].sh_addr;
7238 end = table + sechdrs[me->arch.unwind_section].sh_size;
7239 - gp = (Elf_Addr)me->module_core + me->arch.got_offset;
7240 + gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
7241
7242 DEBUGP("register_unwind_table(), sect = %d at 0x%p - 0x%p (gp=0x%lx)\n",
7243 me->arch.unwind_section, table, end, gp);
7244 diff --git a/arch/parisc/kernel/sys_parisc.c b/arch/parisc/kernel/sys_parisc.c
7245 index 0d3a9d4..44975d0 100644
7246 --- a/arch/parisc/kernel/sys_parisc.c
7247 +++ b/arch/parisc/kernel/sys_parisc.c
7248 @@ -33,9 +33,11 @@
7249 #include <linux/utsname.h>
7250 #include <linux/personality.h>
7251
7252 -static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
7253 +static unsigned long get_unshared_area(struct file *filp, unsigned long addr, unsigned long len,
7254 + unsigned long flags)
7255 {
7256 struct vm_unmapped_area_info info;
7257 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
7258
7259 info.flags = 0;
7260 info.length = len;
7261 @@ -43,6 +45,7 @@ static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
7262 info.high_limit = TASK_SIZE;
7263 info.align_mask = 0;
7264 info.align_offset = 0;
7265 + info.threadstack_offset = offset;
7266 return vm_unmapped_area(&info);
7267 }
7268
7269 @@ -69,15 +72,17 @@ static unsigned long shared_align_offset(struct file *filp, unsigned long pgoff)
7270 }
7271
7272 static unsigned long get_shared_area(struct file *filp, unsigned long addr,
7273 - unsigned long len, unsigned long pgoff)
7274 + unsigned long len, unsigned long pgoff, unsigned long flags)
7275 {
7276 struct vm_unmapped_area_info info;
7277 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
7278
7279 info.flags = 0;
7280 info.length = len;
7281 info.low_limit = PAGE_ALIGN(addr);
7282 info.high_limit = TASK_SIZE;
7283 info.align_mask = PAGE_MASK & (SHMLBA - 1);
7284 + info.threadstack_offset = offset;
7285 info.align_offset = shared_align_offset(filp, pgoff);
7286 return vm_unmapped_area(&info);
7287 }
7288 @@ -93,13 +98,20 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7289 return -EINVAL;
7290 return addr;
7291 }
7292 - if (!addr)
7293 + if (!addr) {
7294 addr = TASK_UNMAPPED_BASE;
7295
7296 +#ifdef CONFIG_PAX_RANDMMAP
7297 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
7298 + addr += current->mm->delta_mmap;
7299 +#endif
7300 +
7301 + }
7302 +
7303 if (filp || (flags & MAP_SHARED))
7304 - addr = get_shared_area(filp, addr, len, pgoff);
7305 + addr = get_shared_area(filp, addr, len, pgoff, flags);
7306 else
7307 - addr = get_unshared_area(addr, len);
7308 + addr = get_unshared_area(addr, len, flags);
7309
7310 return addr;
7311 }
7312 diff --git a/arch/parisc/kernel/traps.c b/arch/parisc/kernel/traps.c
7313 index 1cd1d0c..44ec918 100644
7314 --- a/arch/parisc/kernel/traps.c
7315 +++ b/arch/parisc/kernel/traps.c
7316 @@ -722,9 +722,7 @@ void notrace handle_interruption(int code, struct pt_regs *regs)
7317
7318 down_read(&current->mm->mmap_sem);
7319 vma = find_vma(current->mm,regs->iaoq[0]);
7320 - if (vma && (regs->iaoq[0] >= vma->vm_start)
7321 - && (vma->vm_flags & VM_EXEC)) {
7322 -
7323 + if (vma && (regs->iaoq[0] >= vma->vm_start)) {
7324 fault_address = regs->iaoq[0];
7325 fault_space = regs->iasq[0];
7326
7327 diff --git a/arch/parisc/mm/fault.c b/arch/parisc/mm/fault.c
7328 index 0293588..3b229aa 100644
7329 --- a/arch/parisc/mm/fault.c
7330 +++ b/arch/parisc/mm/fault.c
7331 @@ -15,6 +15,7 @@
7332 #include <linux/sched.h>
7333 #include <linux/interrupt.h>
7334 #include <linux/module.h>
7335 +#include <linux/unistd.h>
7336
7337 #include <asm/uaccess.h>
7338 #include <asm/traps.h>
7339 @@ -52,7 +53,7 @@ DEFINE_PER_CPU(struct exception_data, exception_data);
7340 static unsigned long
7341 parisc_acctyp(unsigned long code, unsigned int inst)
7342 {
7343 - if (code == 6 || code == 16)
7344 + if (code == 6 || code == 7 || code == 16)
7345 return VM_EXEC;
7346
7347 switch (inst & 0xf0000000) {
7348 @@ -138,6 +139,116 @@ parisc_acctyp(unsigned long code, unsigned int inst)
7349 }
7350 #endif
7351
7352 +#ifdef CONFIG_PAX_PAGEEXEC
7353 +/*
7354 + * PaX: decide what to do with offenders (instruction_pointer(regs) = fault address)
7355 + *
7356 + * returns 1 when task should be killed
7357 + * 2 when rt_sigreturn trampoline was detected
7358 + * 3 when unpatched PLT trampoline was detected
7359 + */
7360 +static int pax_handle_fetch_fault(struct pt_regs *regs)
7361 +{
7362 +
7363 +#ifdef CONFIG_PAX_EMUPLT
7364 + int err;
7365 +
7366 + do { /* PaX: unpatched PLT emulation */
7367 + unsigned int bl, depwi;
7368 +
7369 + err = get_user(bl, (unsigned int *)instruction_pointer(regs));
7370 + err |= get_user(depwi, (unsigned int *)(instruction_pointer(regs)+4));
7371 +
7372 + if (err)
7373 + break;
7374 +
7375 + if (bl == 0xEA9F1FDDU && depwi == 0xD6801C1EU) {
7376 + unsigned int ldw, bv, ldw2, addr = instruction_pointer(regs)-12;
7377 +
7378 + err = get_user(ldw, (unsigned int *)addr);
7379 + err |= get_user(bv, (unsigned int *)(addr+4));
7380 + err |= get_user(ldw2, (unsigned int *)(addr+8));
7381 +
7382 + if (err)
7383 + break;
7384 +
7385 + if (ldw == 0x0E801096U &&
7386 + bv == 0xEAC0C000U &&
7387 + ldw2 == 0x0E881095U)
7388 + {
7389 + unsigned int resolver, map;
7390 +
7391 + err = get_user(resolver, (unsigned int *)(instruction_pointer(regs)+8));
7392 + err |= get_user(map, (unsigned int *)(instruction_pointer(regs)+12));
7393 + if (err)
7394 + break;
7395 +
7396 + regs->gr[20] = instruction_pointer(regs)+8;
7397 + regs->gr[21] = map;
7398 + regs->gr[22] = resolver;
7399 + regs->iaoq[0] = resolver | 3UL;
7400 + regs->iaoq[1] = regs->iaoq[0] + 4;
7401 + return 3;
7402 + }
7403 + }
7404 + } while (0);
7405 +#endif
7406 +
7407 +#ifdef CONFIG_PAX_EMUTRAMP
7408 +
7409 +#ifndef CONFIG_PAX_EMUSIGRT
7410 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
7411 + return 1;
7412 +#endif
7413 +
7414 + do { /* PaX: rt_sigreturn emulation */
7415 + unsigned int ldi1, ldi2, bel, nop;
7416 +
7417 + err = get_user(ldi1, (unsigned int *)instruction_pointer(regs));
7418 + err |= get_user(ldi2, (unsigned int *)(instruction_pointer(regs)+4));
7419 + err |= get_user(bel, (unsigned int *)(instruction_pointer(regs)+8));
7420 + err |= get_user(nop, (unsigned int *)(instruction_pointer(regs)+12));
7421 +
7422 + if (err)
7423 + break;
7424 +
7425 + if ((ldi1 == 0x34190000U || ldi1 == 0x34190002U) &&
7426 + ldi2 == 0x3414015AU &&
7427 + bel == 0xE4008200U &&
7428 + nop == 0x08000240U)
7429 + {
7430 + regs->gr[25] = (ldi1 & 2) >> 1;
7431 + regs->gr[20] = __NR_rt_sigreturn;
7432 + regs->gr[31] = regs->iaoq[1] + 16;
7433 + regs->sr[0] = regs->iasq[1];
7434 + regs->iaoq[0] = 0x100UL;
7435 + regs->iaoq[1] = regs->iaoq[0] + 4;
7436 + regs->iasq[0] = regs->sr[2];
7437 + regs->iasq[1] = regs->sr[2];
7438 + return 2;
7439 + }
7440 + } while (0);
7441 +#endif
7442 +
7443 + return 1;
7444 +}
7445 +
7446 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
7447 +{
7448 + unsigned long i;
7449 +
7450 + printk(KERN_ERR "PAX: bytes at PC: ");
7451 + for (i = 0; i < 5; i++) {
7452 + unsigned int c;
7453 + if (get_user(c, (unsigned int *)pc+i))
7454 + printk(KERN_CONT "???????? ");
7455 + else
7456 + printk(KERN_CONT "%08x ", c);
7457 + }
7458 + printk("\n");
7459 +}
7460 +#endif
7461 +
7462 int fixup_exception(struct pt_regs *regs)
7463 {
7464 const struct exception_table_entry *fix;
7465 @@ -204,8 +315,33 @@ retry:
7466
7467 good_area:
7468
7469 - if ((vma->vm_flags & acc_type) != acc_type)
7470 + if ((vma->vm_flags & acc_type) != acc_type) {
7471 +
7472 +#ifdef CONFIG_PAX_PAGEEXEC
7473 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && (acc_type & VM_EXEC) &&
7474 + (address & ~3UL) == instruction_pointer(regs))
7475 + {
7476 + up_read(&mm->mmap_sem);
7477 + switch (pax_handle_fetch_fault(regs)) {
7478 +
7479 +#ifdef CONFIG_PAX_EMUPLT
7480 + case 3:
7481 + return;
7482 +#endif
7483 +
7484 +#ifdef CONFIG_PAX_EMUTRAMP
7485 + case 2:
7486 + return;
7487 +#endif
7488 +
7489 + }
7490 + pax_report_fault(regs, (void *)instruction_pointer(regs), (void *)regs->gr[30]);
7491 + do_group_exit(SIGKILL);
7492 + }
7493 +#endif
7494 +
7495 goto bad_area;
7496 + }
7497
7498 /*
7499 * If for any reason at all we couldn't handle the fault, make
7500 diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
7501 index 38f3b7e..7e485c0 100644
7502 --- a/arch/powerpc/Kconfig
7503 +++ b/arch/powerpc/Kconfig
7504 @@ -378,6 +378,7 @@ config ARCH_ENABLE_MEMORY_HOTREMOVE
7505 config KEXEC
7506 bool "kexec system call"
7507 depends on (PPC_BOOK3S || FSL_BOOKE || (44x && !SMP))
7508 + depends on !GRKERNSEC_KMEM
7509 help
7510 kexec is a system call that implements the ability to shutdown your
7511 current kernel, and to start another kernel. It is like a reboot
7512 diff --git a/arch/powerpc/include/asm/atomic.h b/arch/powerpc/include/asm/atomic.h
7513 index e3b1d41..8e81edf 100644
7514 --- a/arch/powerpc/include/asm/atomic.h
7515 +++ b/arch/powerpc/include/asm/atomic.h
7516 @@ -523,6 +523,16 @@ static __inline__ long atomic64_inc_not_zero(atomic64_t *v)
7517 return t1;
7518 }
7519
7520 +#define atomic64_read_unchecked(v) atomic64_read(v)
7521 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
7522 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
7523 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
7524 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
7525 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
7526 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
7527 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
7528 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
7529 +
7530 #endif /* __powerpc64__ */
7531
7532 #endif /* __KERNEL__ */
7533 diff --git a/arch/powerpc/include/asm/cache.h b/arch/powerpc/include/asm/cache.h
7534 index 9e495c9..b6878e5 100644
7535 --- a/arch/powerpc/include/asm/cache.h
7536 +++ b/arch/powerpc/include/asm/cache.h
7537 @@ -3,6 +3,7 @@
7538
7539 #ifdef __KERNEL__
7540
7541 +#include <linux/const.h>
7542
7543 /* bytes per L1 cache line */
7544 #if defined(CONFIG_8xx) || defined(CONFIG_403GCX)
7545 @@ -22,7 +23,7 @@
7546 #define L1_CACHE_SHIFT 7
7547 #endif
7548
7549 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
7550 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7551
7552 #define SMP_CACHE_BYTES L1_CACHE_BYTES
7553
7554 diff --git a/arch/powerpc/include/asm/elf.h b/arch/powerpc/include/asm/elf.h
7555 index cc0655a..13eac2e 100644
7556 --- a/arch/powerpc/include/asm/elf.h
7557 +++ b/arch/powerpc/include/asm/elf.h
7558 @@ -28,8 +28,19 @@
7559 the loader. We need to make sure that it is out of the way of the program
7560 that it will "exec", and that there is sufficient room for the brk. */
7561
7562 -extern unsigned long randomize_et_dyn(unsigned long base);
7563 -#define ELF_ET_DYN_BASE (randomize_et_dyn(0x20000000))
7564 +#define ELF_ET_DYN_BASE (0x20000000)
7565 +
7566 +#ifdef CONFIG_PAX_ASLR
7567 +#define PAX_ELF_ET_DYN_BASE (0x10000000UL)
7568 +
7569 +#ifdef __powerpc64__
7570 +#define PAX_DELTA_MMAP_LEN (is_32bit_task() ? 16 : 28)
7571 +#define PAX_DELTA_STACK_LEN (is_32bit_task() ? 16 : 28)
7572 +#else
7573 +#define PAX_DELTA_MMAP_LEN 15
7574 +#define PAX_DELTA_STACK_LEN 15
7575 +#endif
7576 +#endif
7577
7578 /*
7579 * Our registers are always unsigned longs, whether we're a 32 bit
7580 @@ -123,10 +134,6 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm,
7581 (0x7ff >> (PAGE_SHIFT - 12)) : \
7582 (0x3ffff >> (PAGE_SHIFT - 12)))
7583
7584 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
7585 -#define arch_randomize_brk arch_randomize_brk
7586 -
7587 -
7588 #ifdef CONFIG_SPU_BASE
7589 /* Notes used in ET_CORE. Note name is "SPU/<fd>/<filename>". */
7590 #define NT_SPU 1
7591 diff --git a/arch/powerpc/include/asm/exec.h b/arch/powerpc/include/asm/exec.h
7592 index 8196e9c..d83a9f3 100644
7593 --- a/arch/powerpc/include/asm/exec.h
7594 +++ b/arch/powerpc/include/asm/exec.h
7595 @@ -4,6 +4,6 @@
7596 #ifndef _ASM_POWERPC_EXEC_H
7597 #define _ASM_POWERPC_EXEC_H
7598
7599 -extern unsigned long arch_align_stack(unsigned long sp);
7600 +#define arch_align_stack(x) ((x) & ~0xfUL)
7601
7602 #endif /* _ASM_POWERPC_EXEC_H */
7603 diff --git a/arch/powerpc/include/asm/kmap_types.h b/arch/powerpc/include/asm/kmap_types.h
7604 index 5acabbd..7ea14fa 100644
7605 --- a/arch/powerpc/include/asm/kmap_types.h
7606 +++ b/arch/powerpc/include/asm/kmap_types.h
7607 @@ -10,7 +10,7 @@
7608 * 2 of the License, or (at your option) any later version.
7609 */
7610
7611 -#define KM_TYPE_NR 16
7612 +#define KM_TYPE_NR 17
7613
7614 #endif /* __KERNEL__ */
7615 #endif /* _ASM_POWERPC_KMAP_TYPES_H */
7616 diff --git a/arch/powerpc/include/asm/mman.h b/arch/powerpc/include/asm/mman.h
7617 index 8565c25..2865190 100644
7618 --- a/arch/powerpc/include/asm/mman.h
7619 +++ b/arch/powerpc/include/asm/mman.h
7620 @@ -24,7 +24,7 @@ static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot)
7621 }
7622 #define arch_calc_vm_prot_bits(prot) arch_calc_vm_prot_bits(prot)
7623
7624 -static inline pgprot_t arch_vm_get_page_prot(unsigned long vm_flags)
7625 +static inline pgprot_t arch_vm_get_page_prot(vm_flags_t vm_flags)
7626 {
7627 return (vm_flags & VM_SAO) ? __pgprot(_PAGE_SAO) : __pgprot(0);
7628 }
7629 diff --git a/arch/powerpc/include/asm/page.h b/arch/powerpc/include/asm/page.h
7630 index b9f4262..dcf04f7 100644
7631 --- a/arch/powerpc/include/asm/page.h
7632 +++ b/arch/powerpc/include/asm/page.h
7633 @@ -230,8 +230,9 @@ extern long long virt_phys_offset;
7634 * and needs to be executable. This means the whole heap ends
7635 * up being executable.
7636 */
7637 -#define VM_DATA_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
7638 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7639 +#define VM_DATA_DEFAULT_FLAGS32 \
7640 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
7641 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7642
7643 #define VM_DATA_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
7644 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7645 @@ -259,6 +260,9 @@ extern long long virt_phys_offset;
7646 #define is_kernel_addr(x) ((x) >= PAGE_OFFSET)
7647 #endif
7648
7649 +#define ktla_ktva(addr) (addr)
7650 +#define ktva_ktla(addr) (addr)
7651 +
7652 #ifndef CONFIG_PPC_BOOK3S_64
7653 /*
7654 * Use the top bit of the higher-level page table entries to indicate whether
7655 diff --git a/arch/powerpc/include/asm/page_64.h b/arch/powerpc/include/asm/page_64.h
7656 index 88693ce..ac6f9ab 100644
7657 --- a/arch/powerpc/include/asm/page_64.h
7658 +++ b/arch/powerpc/include/asm/page_64.h
7659 @@ -153,15 +153,18 @@ do { \
7660 * stack by default, so in the absence of a PT_GNU_STACK program header
7661 * we turn execute permission off.
7662 */
7663 -#define VM_STACK_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
7664 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7665 +#define VM_STACK_DEFAULT_FLAGS32 \
7666 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
7667 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7668
7669 #define VM_STACK_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
7670 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7671
7672 +#ifndef CONFIG_PAX_PAGEEXEC
7673 #define VM_STACK_DEFAULT_FLAGS \
7674 (is_32bit_task() ? \
7675 VM_STACK_DEFAULT_FLAGS32 : VM_STACK_DEFAULT_FLAGS64)
7676 +#endif
7677
7678 #include <asm-generic/getorder.h>
7679
7680 diff --git a/arch/powerpc/include/asm/pgalloc-64.h b/arch/powerpc/include/asm/pgalloc-64.h
7681 index 256d6f8..b0166a7 100644
7682 --- a/arch/powerpc/include/asm/pgalloc-64.h
7683 +++ b/arch/powerpc/include/asm/pgalloc-64.h
7684 @@ -53,6 +53,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
7685 #ifndef CONFIG_PPC_64K_PAGES
7686
7687 #define pgd_populate(MM, PGD, PUD) pgd_set(PGD, PUD)
7688 +#define pgd_populate_kernel(MM, PGD, PUD) pgd_populate((MM), (PGD), (PUD))
7689
7690 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
7691 {
7692 @@ -70,6 +71,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
7693 pud_set(pud, (unsigned long)pmd);
7694 }
7695
7696 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
7697 +{
7698 + pud_populate(mm, pud, pmd);
7699 +}
7700 +
7701 #define pmd_populate(mm, pmd, pte_page) \
7702 pmd_populate_kernel(mm, pmd, page_address(pte_page))
7703 #define pmd_populate_kernel(mm, pmd, pte) pmd_set(pmd, (unsigned long)(pte))
7704 @@ -169,6 +175,7 @@ extern void __tlb_remove_table(void *_table);
7705 #endif
7706
7707 #define pud_populate(mm, pud, pmd) pud_set(pud, (unsigned long)pmd)
7708 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
7709
7710 static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd,
7711 pte_t *pte)
7712 diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h
7713 index 7d6eacf..14c0240 100644
7714 --- a/arch/powerpc/include/asm/pgtable.h
7715 +++ b/arch/powerpc/include/asm/pgtable.h
7716 @@ -2,6 +2,7 @@
7717 #define _ASM_POWERPC_PGTABLE_H
7718 #ifdef __KERNEL__
7719
7720 +#include <linux/const.h>
7721 #ifndef __ASSEMBLY__
7722 #include <asm/processor.h> /* For TASK_SIZE */
7723 #include <asm/mmu.h>
7724 diff --git a/arch/powerpc/include/asm/pte-hash32.h b/arch/powerpc/include/asm/pte-hash32.h
7725 index 4aad413..85d86bf 100644
7726 --- a/arch/powerpc/include/asm/pte-hash32.h
7727 +++ b/arch/powerpc/include/asm/pte-hash32.h
7728 @@ -21,6 +21,7 @@
7729 #define _PAGE_FILE 0x004 /* when !present: nonlinear file mapping */
7730 #define _PAGE_USER 0x004 /* usermode access allowed */
7731 #define _PAGE_GUARDED 0x008 /* G: prohibit speculative access */
7732 +#define _PAGE_EXEC _PAGE_GUARDED
7733 #define _PAGE_COHERENT 0x010 /* M: enforce memory coherence (SMP systems) */
7734 #define _PAGE_NO_CACHE 0x020 /* I: cache inhibit */
7735 #define _PAGE_WRITETHRU 0x040 /* W: cache write-through */
7736 diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
7737 index 10d1ef0..8f83abc 100644
7738 --- a/arch/powerpc/include/asm/reg.h
7739 +++ b/arch/powerpc/include/asm/reg.h
7740 @@ -234,6 +234,7 @@
7741 #define SPRN_DBCR 0x136 /* e300 Data Breakpoint Control Reg */
7742 #define SPRN_DSISR 0x012 /* Data Storage Interrupt Status Register */
7743 #define DSISR_NOHPTE 0x40000000 /* no translation found */
7744 +#define DSISR_GUARDED 0x10000000 /* fetch from guarded storage */
7745 #define DSISR_PROTFAULT 0x08000000 /* protection fault */
7746 #define DSISR_ISSTORE 0x02000000 /* access was a store */
7747 #define DSISR_DABRMATCH 0x00400000 /* hit data breakpoint */
7748 diff --git a/arch/powerpc/include/asm/smp.h b/arch/powerpc/include/asm/smp.h
7749 index 98da78e..dc68271 100644
7750 --- a/arch/powerpc/include/asm/smp.h
7751 +++ b/arch/powerpc/include/asm/smp.h
7752 @@ -50,7 +50,7 @@ struct smp_ops_t {
7753 int (*cpu_disable)(void);
7754 void (*cpu_die)(unsigned int nr);
7755 int (*cpu_bootable)(unsigned int nr);
7756 -};
7757 +} __no_const;
7758
7759 extern void smp_send_debugger_break(void);
7760 extern void start_secondary_resume(void);
7761 diff --git a/arch/powerpc/include/asm/thread_info.h b/arch/powerpc/include/asm/thread_info.h
7762 index ba7b197..d292e26 100644
7763 --- a/arch/powerpc/include/asm/thread_info.h
7764 +++ b/arch/powerpc/include/asm/thread_info.h
7765 @@ -93,7 +93,6 @@ static inline struct thread_info *current_thread_info(void)
7766 #define TIF_POLLING_NRFLAG 3 /* true if poll_idle() is polling
7767 TIF_NEED_RESCHED */
7768 #define TIF_32BIT 4 /* 32 bit binary */
7769 -#define TIF_PERFMON_WORK 5 /* work for pfm_handle_work() */
7770 #define TIF_PERFMON_CTXSW 6 /* perfmon needs ctxsw calls */
7771 #define TIF_SYSCALL_AUDIT 7 /* syscall auditing active */
7772 #define TIF_SINGLESTEP 8 /* singlestepping active */
7773 @@ -107,6 +106,9 @@ static inline struct thread_info *current_thread_info(void)
7774 #define TIF_EMULATE_STACK_STORE 16 /* Is an instruction emulation
7775 for stack store? */
7776 #define TIF_MEMDIE 17 /* is terminating due to OOM killer */
7777 +#define TIF_PERFMON_WORK 18 /* work for pfm_handle_work() */
7778 +/* mask must be expressable within 16 bits to satisfy 'andi' instruction reqs */
7779 +#define TIF_GRSEC_SETXID 5 /* update credentials on syscall entry/exit */
7780
7781 /* as above, but as bit values */
7782 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
7783 @@ -126,9 +128,10 @@ static inline struct thread_info *current_thread_info(void)
7784 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
7785 #define _TIF_EMULATE_STACK_STORE (1<<TIF_EMULATE_STACK_STORE)
7786 #define _TIF_NOHZ (1<<TIF_NOHZ)
7787 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
7788 #define _TIF_SYSCALL_T_OR_A (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
7789 _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT | \
7790 - _TIF_NOHZ)
7791 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
7792
7793 #define _TIF_USER_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED | \
7794 _TIF_NOTIFY_RESUME | _TIF_UPROBE)
7795 diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h
7796 index 9485b43..4718d50 100644
7797 --- a/arch/powerpc/include/asm/uaccess.h
7798 +++ b/arch/powerpc/include/asm/uaccess.h
7799 @@ -318,52 +318,6 @@ do { \
7800 extern unsigned long __copy_tofrom_user(void __user *to,
7801 const void __user *from, unsigned long size);
7802
7803 -#ifndef __powerpc64__
7804 -
7805 -static inline unsigned long copy_from_user(void *to,
7806 - const void __user *from, unsigned long n)
7807 -{
7808 - unsigned long over;
7809 -
7810 - if (access_ok(VERIFY_READ, from, n))
7811 - return __copy_tofrom_user((__force void __user *)to, from, n);
7812 - if ((unsigned long)from < TASK_SIZE) {
7813 - over = (unsigned long)from + n - TASK_SIZE;
7814 - return __copy_tofrom_user((__force void __user *)to, from,
7815 - n - over) + over;
7816 - }
7817 - return n;
7818 -}
7819 -
7820 -static inline unsigned long copy_to_user(void __user *to,
7821 - const void *from, unsigned long n)
7822 -{
7823 - unsigned long over;
7824 -
7825 - if (access_ok(VERIFY_WRITE, to, n))
7826 - return __copy_tofrom_user(to, (__force void __user *)from, n);
7827 - if ((unsigned long)to < TASK_SIZE) {
7828 - over = (unsigned long)to + n - TASK_SIZE;
7829 - return __copy_tofrom_user(to, (__force void __user *)from,
7830 - n - over) + over;
7831 - }
7832 - return n;
7833 -}
7834 -
7835 -#else /* __powerpc64__ */
7836 -
7837 -#define __copy_in_user(to, from, size) \
7838 - __copy_tofrom_user((to), (from), (size))
7839 -
7840 -extern unsigned long copy_from_user(void *to, const void __user *from,
7841 - unsigned long n);
7842 -extern unsigned long copy_to_user(void __user *to, const void *from,
7843 - unsigned long n);
7844 -extern unsigned long copy_in_user(void __user *to, const void __user *from,
7845 - unsigned long n);
7846 -
7847 -#endif /* __powerpc64__ */
7848 -
7849 static inline unsigned long __copy_from_user_inatomic(void *to,
7850 const void __user *from, unsigned long n)
7851 {
7852 @@ -387,6 +341,10 @@ static inline unsigned long __copy_from_user_inatomic(void *to,
7853 if (ret == 0)
7854 return 0;
7855 }
7856 +
7857 + if (!__builtin_constant_p(n))
7858 + check_object_size(to, n, false);
7859 +
7860 return __copy_tofrom_user((__force void __user *)to, from, n);
7861 }
7862
7863 @@ -413,6 +371,10 @@ static inline unsigned long __copy_to_user_inatomic(void __user *to,
7864 if (ret == 0)
7865 return 0;
7866 }
7867 +
7868 + if (!__builtin_constant_p(n))
7869 + check_object_size(from, n, true);
7870 +
7871 return __copy_tofrom_user(to, (__force const void __user *)from, n);
7872 }
7873
7874 @@ -430,6 +392,92 @@ static inline unsigned long __copy_to_user(void __user *to,
7875 return __copy_to_user_inatomic(to, from, size);
7876 }
7877
7878 +#ifndef __powerpc64__
7879 +
7880 +static inline unsigned long __must_check copy_from_user(void *to,
7881 + const void __user *from, unsigned long n)
7882 +{
7883 + unsigned long over;
7884 +
7885 + if ((long)n < 0)
7886 + return n;
7887 +
7888 + if (access_ok(VERIFY_READ, from, n)) {
7889 + if (!__builtin_constant_p(n))
7890 + check_object_size(to, n, false);
7891 + return __copy_tofrom_user((__force void __user *)to, from, n);
7892 + }
7893 + if ((unsigned long)from < TASK_SIZE) {
7894 + over = (unsigned long)from + n - TASK_SIZE;
7895 + if (!__builtin_constant_p(n - over))
7896 + check_object_size(to, n - over, false);
7897 + return __copy_tofrom_user((__force void __user *)to, from,
7898 + n - over) + over;
7899 + }
7900 + return n;
7901 +}
7902 +
7903 +static inline unsigned long __must_check copy_to_user(void __user *to,
7904 + const void *from, unsigned long n)
7905 +{
7906 + unsigned long over;
7907 +
7908 + if ((long)n < 0)
7909 + return n;
7910 +
7911 + if (access_ok(VERIFY_WRITE, to, n)) {
7912 + if (!__builtin_constant_p(n))
7913 + check_object_size(from, n, true);
7914 + return __copy_tofrom_user(to, (__force void __user *)from, n);
7915 + }
7916 + if ((unsigned long)to < TASK_SIZE) {
7917 + over = (unsigned long)to + n - TASK_SIZE;
7918 + if (!__builtin_constant_p(n))
7919 + check_object_size(from, n - over, true);
7920 + return __copy_tofrom_user(to, (__force void __user *)from,
7921 + n - over) + over;
7922 + }
7923 + return n;
7924 +}
7925 +
7926 +#else /* __powerpc64__ */
7927 +
7928 +#define __copy_in_user(to, from, size) \
7929 + __copy_tofrom_user((to), (from), (size))
7930 +
7931 +static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
7932 +{
7933 + if ((long)n < 0 || n > INT_MAX)
7934 + return n;
7935 +
7936 + if (!__builtin_constant_p(n))
7937 + check_object_size(to, n, false);
7938 +
7939 + if (likely(access_ok(VERIFY_READ, from, n)))
7940 + n = __copy_from_user(to, from, n);
7941 + else
7942 + memset(to, 0, n);
7943 + return n;
7944 +}
7945 +
7946 +static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
7947 +{
7948 + if ((long)n < 0 || n > INT_MAX)
7949 + return n;
7950 +
7951 + if (likely(access_ok(VERIFY_WRITE, to, n))) {
7952 + if (!__builtin_constant_p(n))
7953 + check_object_size(from, n, true);
7954 + n = __copy_to_user(to, from, n);
7955 + }
7956 + return n;
7957 +}
7958 +
7959 +extern unsigned long copy_in_user(void __user *to, const void __user *from,
7960 + unsigned long n);
7961 +
7962 +#endif /* __powerpc64__ */
7963 +
7964 extern unsigned long __clear_user(void __user *addr, unsigned long size);
7965
7966 static inline unsigned long clear_user(void __user *addr, unsigned long size)
7967 diff --git a/arch/powerpc/kernel/exceptions-64e.S b/arch/powerpc/kernel/exceptions-64e.S
7968 index 2d06704..1616f1b 100644
7969 --- a/arch/powerpc/kernel/exceptions-64e.S
7970 +++ b/arch/powerpc/kernel/exceptions-64e.S
7971 @@ -757,6 +757,7 @@ storage_fault_common:
7972 std r14,_DAR(r1)
7973 std r15,_DSISR(r1)
7974 addi r3,r1,STACK_FRAME_OVERHEAD
7975 + bl .save_nvgprs
7976 mr r4,r14
7977 mr r5,r15
7978 ld r14,PACA_EXGEN+EX_R14(r13)
7979 @@ -765,8 +766,7 @@ storage_fault_common:
7980 cmpdi r3,0
7981 bne- 1f
7982 b .ret_from_except_lite
7983 -1: bl .save_nvgprs
7984 - mr r5,r3
7985 +1: mr r5,r3
7986 addi r3,r1,STACK_FRAME_OVERHEAD
7987 ld r4,_DAR(r1)
7988 bl .bad_page_fault
7989 diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
7990 index 3a9ed6a..b534681 100644
7991 --- a/arch/powerpc/kernel/exceptions-64s.S
7992 +++ b/arch/powerpc/kernel/exceptions-64s.S
7993 @@ -1364,10 +1364,10 @@ handle_page_fault:
7994 11: ld r4,_DAR(r1)
7995 ld r5,_DSISR(r1)
7996 addi r3,r1,STACK_FRAME_OVERHEAD
7997 + bl .save_nvgprs
7998 bl .do_page_fault
7999 cmpdi r3,0
8000 beq+ 12f
8001 - bl .save_nvgprs
8002 mr r5,r3
8003 addi r3,r1,STACK_FRAME_OVERHEAD
8004 lwz r4,_DAR(r1)
8005 diff --git a/arch/powerpc/kernel/module_32.c b/arch/powerpc/kernel/module_32.c
8006 index 2e3200c..72095ce 100644
8007 --- a/arch/powerpc/kernel/module_32.c
8008 +++ b/arch/powerpc/kernel/module_32.c
8009 @@ -162,7 +162,7 @@ int module_frob_arch_sections(Elf32_Ehdr *hdr,
8010 me->arch.core_plt_section = i;
8011 }
8012 if (!me->arch.core_plt_section || !me->arch.init_plt_section) {
8013 - printk("Module doesn't contain .plt or .init.plt sections.\n");
8014 + printk("Module %s doesn't contain .plt or .init.plt sections.\n", me->name);
8015 return -ENOEXEC;
8016 }
8017
8018 @@ -192,11 +192,16 @@ static uint32_t do_plt_call(void *location,
8019
8020 DEBUGP("Doing plt for call to 0x%x at 0x%x\n", val, (unsigned int)location);
8021 /* Init, or core PLT? */
8022 - if (location >= mod->module_core
8023 - && location < mod->module_core + mod->core_size)
8024 + if ((location >= mod->module_core_rx && location < mod->module_core_rx + mod->core_size_rx) ||
8025 + (location >= mod->module_core_rw && location < mod->module_core_rw + mod->core_size_rw))
8026 entry = (void *)sechdrs[mod->arch.core_plt_section].sh_addr;
8027 - else
8028 + else if ((location >= mod->module_init_rx && location < mod->module_init_rx + mod->init_size_rx) ||
8029 + (location >= mod->module_init_rw && location < mod->module_init_rw + mod->init_size_rw))
8030 entry = (void *)sechdrs[mod->arch.init_plt_section].sh_addr;
8031 + else {
8032 + printk(KERN_ERR "%s: invalid R_PPC_REL24 entry found\n", mod->name);
8033 + return ~0UL;
8034 + }
8035
8036 /* Find this entry, or if that fails, the next avail. entry */
8037 while (entry->jump[0]) {
8038 diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
8039 index 96d2fdf..f6d10c8 100644
8040 --- a/arch/powerpc/kernel/process.c
8041 +++ b/arch/powerpc/kernel/process.c
8042 @@ -886,8 +886,8 @@ void show_regs(struct pt_regs * regs)
8043 * Lookup NIP late so we have the best change of getting the
8044 * above info out without failing
8045 */
8046 - printk("NIP ["REG"] %pS\n", regs->nip, (void *)regs->nip);
8047 - printk("LR ["REG"] %pS\n", regs->link, (void *)regs->link);
8048 + printk("NIP ["REG"] %pA\n", regs->nip, (void *)regs->nip);
8049 + printk("LR ["REG"] %pA\n", regs->link, (void *)regs->link);
8050 #endif
8051 #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
8052 printk("PACATMSCRATCH [%llx]\n", get_paca()->tm_scratch);
8053 @@ -1352,10 +1352,10 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
8054 newsp = stack[0];
8055 ip = stack[STACK_FRAME_LR_SAVE];
8056 if (!firstframe || ip != lr) {
8057 - printk("["REG"] ["REG"] %pS", sp, ip, (void *)ip);
8058 + printk("["REG"] ["REG"] %pA", sp, ip, (void *)ip);
8059 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
8060 if ((ip == rth || ip == mrth) && curr_frame >= 0) {
8061 - printk(" (%pS)",
8062 + printk(" (%pA)",
8063 (void *)current->ret_stack[curr_frame].ret);
8064 curr_frame--;
8065 }
8066 @@ -1375,7 +1375,7 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
8067 struct pt_regs *regs = (struct pt_regs *)
8068 (sp + STACK_FRAME_OVERHEAD);
8069 lr = regs->link;
8070 - printk("--- Exception: %lx at %pS\n LR = %pS\n",
8071 + printk("--- Exception: %lx at %pA\n LR = %pA\n",
8072 regs->trap, (void *)regs->nip, (void *)lr);
8073 firstframe = 1;
8074 }
8075 @@ -1411,58 +1411,3 @@ void notrace __ppc64_runlatch_off(void)
8076 mtspr(SPRN_CTRLT, ctrl);
8077 }
8078 #endif /* CONFIG_PPC64 */
8079 -
8080 -unsigned long arch_align_stack(unsigned long sp)
8081 -{
8082 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
8083 - sp -= get_random_int() & ~PAGE_MASK;
8084 - return sp & ~0xf;
8085 -}
8086 -
8087 -static inline unsigned long brk_rnd(void)
8088 -{
8089 - unsigned long rnd = 0;
8090 -
8091 - /* 8MB for 32bit, 1GB for 64bit */
8092 - if (is_32bit_task())
8093 - rnd = (long)(get_random_int() % (1<<(23-PAGE_SHIFT)));
8094 - else
8095 - rnd = (long)(get_random_int() % (1<<(30-PAGE_SHIFT)));
8096 -
8097 - return rnd << PAGE_SHIFT;
8098 -}
8099 -
8100 -unsigned long arch_randomize_brk(struct mm_struct *mm)
8101 -{
8102 - unsigned long base = mm->brk;
8103 - unsigned long ret;
8104 -
8105 -#ifdef CONFIG_PPC_STD_MMU_64
8106 - /*
8107 - * If we are using 1TB segments and we are allowed to randomise
8108 - * the heap, we can put it above 1TB so it is backed by a 1TB
8109 - * segment. Otherwise the heap will be in the bottom 1TB
8110 - * which always uses 256MB segments and this may result in a
8111 - * performance penalty.
8112 - */
8113 - if (!is_32bit_task() && (mmu_highuser_ssize == MMU_SEGSIZE_1T))
8114 - base = max_t(unsigned long, mm->brk, 1UL << SID_SHIFT_1T);
8115 -#endif
8116 -
8117 - ret = PAGE_ALIGN(base + brk_rnd());
8118 -
8119 - if (ret < mm->brk)
8120 - return mm->brk;
8121 -
8122 - return ret;
8123 -}
8124 -
8125 -unsigned long randomize_et_dyn(unsigned long base)
8126 -{
8127 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
8128 -
8129 - if (ret < base)
8130 - return base;
8131 -
8132 - return ret;
8133 -}
8134 diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
8135 index 9a0d24c..e7fbedf 100644
8136 --- a/arch/powerpc/kernel/ptrace.c
8137 +++ b/arch/powerpc/kernel/ptrace.c
8138 @@ -1761,6 +1761,10 @@ long arch_ptrace(struct task_struct *child, long request,
8139 return ret;
8140 }
8141
8142 +#ifdef CONFIG_GRKERNSEC_SETXID
8143 +extern void gr_delayed_cred_worker(void);
8144 +#endif
8145 +
8146 /*
8147 * We must return the syscall number to actually look up in the table.
8148 * This can be -1L to skip running any syscall at all.
8149 @@ -1773,6 +1777,11 @@ long do_syscall_trace_enter(struct pt_regs *regs)
8150
8151 secure_computing_strict(regs->gpr[0]);
8152
8153 +#ifdef CONFIG_GRKERNSEC_SETXID
8154 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8155 + gr_delayed_cred_worker();
8156 +#endif
8157 +
8158 if (test_thread_flag(TIF_SYSCALL_TRACE) &&
8159 tracehook_report_syscall_entry(regs))
8160 /*
8161 @@ -1807,6 +1816,11 @@ void do_syscall_trace_leave(struct pt_regs *regs)
8162 {
8163 int step;
8164
8165 +#ifdef CONFIG_GRKERNSEC_SETXID
8166 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8167 + gr_delayed_cred_worker();
8168 +#endif
8169 +
8170 audit_syscall_exit(regs);
8171
8172 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
8173 diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c
8174 index fea2dba..a779f6b 100644
8175 --- a/arch/powerpc/kernel/signal_32.c
8176 +++ b/arch/powerpc/kernel/signal_32.c
8177 @@ -1002,7 +1002,7 @@ int handle_rt_signal32(unsigned long sig, struct k_sigaction *ka,
8178 /* Save user registers on the stack */
8179 frame = &rt_sf->uc.uc_mcontext;
8180 addr = frame;
8181 - if (vdso32_rt_sigtramp && current->mm->context.vdso_base) {
8182 + if (vdso32_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
8183 sigret = 0;
8184 tramp = current->mm->context.vdso_base + vdso32_rt_sigtramp;
8185 } else {
8186 diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c
8187 index 1e7ba88..17afb1b 100644
8188 --- a/arch/powerpc/kernel/signal_64.c
8189 +++ b/arch/powerpc/kernel/signal_64.c
8190 @@ -763,7 +763,7 @@ int handle_rt_signal64(int signr, struct k_sigaction *ka, siginfo_t *info,
8191 #endif
8192
8193 /* Set up to return from userspace. */
8194 - if (vdso64_rt_sigtramp && current->mm->context.vdso_base) {
8195 + if (vdso64_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
8196 regs->link = current->mm->context.vdso_base + vdso64_rt_sigtramp;
8197 } else {
8198 err |= setup_trampoline(__NR_rt_sigreturn, &frame->tramp[0]);
8199 diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
8200 index f783c93..619baf1 100644
8201 --- a/arch/powerpc/kernel/traps.c
8202 +++ b/arch/powerpc/kernel/traps.c
8203 @@ -142,6 +142,8 @@ static unsigned __kprobes long oops_begin(struct pt_regs *regs)
8204 return flags;
8205 }
8206
8207 +extern void gr_handle_kernel_exploit(void);
8208 +
8209 static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
8210 int signr)
8211 {
8212 @@ -191,6 +193,9 @@ static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
8213 panic("Fatal exception in interrupt");
8214 if (panic_on_oops)
8215 panic("Fatal exception");
8216 +
8217 + gr_handle_kernel_exploit();
8218 +
8219 do_exit(signr);
8220 }
8221
8222 diff --git a/arch/powerpc/kernel/vdso.c b/arch/powerpc/kernel/vdso.c
8223 index 1d9c926..25f4741 100644
8224 --- a/arch/powerpc/kernel/vdso.c
8225 +++ b/arch/powerpc/kernel/vdso.c
8226 @@ -34,6 +34,7 @@
8227 #include <asm/firmware.h>
8228 #include <asm/vdso.h>
8229 #include <asm/vdso_datapage.h>
8230 +#include <asm/mman.h>
8231
8232 #include "setup.h"
8233
8234 @@ -222,7 +223,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
8235 vdso_base = VDSO32_MBASE;
8236 #endif
8237
8238 - current->mm->context.vdso_base = 0;
8239 + current->mm->context.vdso_base = ~0UL;
8240
8241 /* vDSO has a problem and was disabled, just don't "enable" it for the
8242 * process
8243 @@ -242,7 +243,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
8244 vdso_base = get_unmapped_area(NULL, vdso_base,
8245 (vdso_pages << PAGE_SHIFT) +
8246 ((VDSO_ALIGNMENT - 1) & PAGE_MASK),
8247 - 0, 0);
8248 + 0, MAP_PRIVATE | MAP_EXECUTABLE);
8249 if (IS_ERR_VALUE(vdso_base)) {
8250 rc = vdso_base;
8251 goto fail_mmapsem;
8252 diff --git a/arch/powerpc/lib/usercopy_64.c b/arch/powerpc/lib/usercopy_64.c
8253 index 5eea6f3..5d10396 100644
8254 --- a/arch/powerpc/lib/usercopy_64.c
8255 +++ b/arch/powerpc/lib/usercopy_64.c
8256 @@ -9,22 +9,6 @@
8257 #include <linux/module.h>
8258 #include <asm/uaccess.h>
8259
8260 -unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
8261 -{
8262 - if (likely(access_ok(VERIFY_READ, from, n)))
8263 - n = __copy_from_user(to, from, n);
8264 - else
8265 - memset(to, 0, n);
8266 - return n;
8267 -}
8268 -
8269 -unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
8270 -{
8271 - if (likely(access_ok(VERIFY_WRITE, to, n)))
8272 - n = __copy_to_user(to, from, n);
8273 - return n;
8274 -}
8275 -
8276 unsigned long copy_in_user(void __user *to, const void __user *from,
8277 unsigned long n)
8278 {
8279 @@ -35,7 +19,5 @@ unsigned long copy_in_user(void __user *to, const void __user *from,
8280 return n;
8281 }
8282
8283 -EXPORT_SYMBOL(copy_from_user);
8284 -EXPORT_SYMBOL(copy_to_user);
8285 EXPORT_SYMBOL(copy_in_user);
8286
8287 diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c
8288 index 51ab9e7..7d3c78b 100644
8289 --- a/arch/powerpc/mm/fault.c
8290 +++ b/arch/powerpc/mm/fault.c
8291 @@ -33,6 +33,10 @@
8292 #include <linux/magic.h>
8293 #include <linux/ratelimit.h>
8294 #include <linux/context_tracking.h>
8295 +#include <linux/slab.h>
8296 +#include <linux/pagemap.h>
8297 +#include <linux/compiler.h>
8298 +#include <linux/unistd.h>
8299
8300 #include <asm/firmware.h>
8301 #include <asm/page.h>
8302 @@ -69,6 +73,33 @@ static inline int notify_page_fault(struct pt_regs *regs)
8303 }
8304 #endif
8305
8306 +#ifdef CONFIG_PAX_PAGEEXEC
8307 +/*
8308 + * PaX: decide what to do with offenders (regs->nip = fault address)
8309 + *
8310 + * returns 1 when task should be killed
8311 + */
8312 +static int pax_handle_fetch_fault(struct pt_regs *regs)
8313 +{
8314 + return 1;
8315 +}
8316 +
8317 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
8318 +{
8319 + unsigned long i;
8320 +
8321 + printk(KERN_ERR "PAX: bytes at PC: ");
8322 + for (i = 0; i < 5; i++) {
8323 + unsigned int c;
8324 + if (get_user(c, (unsigned int __user *)pc+i))
8325 + printk(KERN_CONT "???????? ");
8326 + else
8327 + printk(KERN_CONT "%08x ", c);
8328 + }
8329 + printk("\n");
8330 +}
8331 +#endif
8332 +
8333 /*
8334 * Check whether the instruction at regs->nip is a store using
8335 * an update addressing form which will update r1.
8336 @@ -216,7 +247,7 @@ int __kprobes do_page_fault(struct pt_regs *regs, unsigned long address,
8337 * indicate errors in DSISR but can validly be set in SRR1.
8338 */
8339 if (trap == 0x400)
8340 - error_code &= 0x48200000;
8341 + error_code &= 0x58200000;
8342 else
8343 is_write = error_code & DSISR_ISSTORE;
8344 #else
8345 @@ -378,7 +409,7 @@ good_area:
8346 * "undefined". Of those that can be set, this is the only
8347 * one which seems bad.
8348 */
8349 - if (error_code & 0x10000000)
8350 + if (error_code & DSISR_GUARDED)
8351 /* Guarded storage error. */
8352 goto bad_area;
8353 #endif /* CONFIG_8xx */
8354 @@ -393,7 +424,7 @@ good_area:
8355 * processors use the same I/D cache coherency mechanism
8356 * as embedded.
8357 */
8358 - if (error_code & DSISR_PROTFAULT)
8359 + if (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))
8360 goto bad_area;
8361 #endif /* CONFIG_PPC_STD_MMU */
8362
8363 @@ -483,6 +514,23 @@ bad_area:
8364 bad_area_nosemaphore:
8365 /* User mode accesses cause a SIGSEGV */
8366 if (user_mode(regs)) {
8367 +
8368 +#ifdef CONFIG_PAX_PAGEEXEC
8369 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
8370 +#ifdef CONFIG_PPC_STD_MMU
8371 + if (is_exec && (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))) {
8372 +#else
8373 + if (is_exec && regs->nip == address) {
8374 +#endif
8375 + switch (pax_handle_fetch_fault(regs)) {
8376 + }
8377 +
8378 + pax_report_fault(regs, (void *)regs->nip, (void *)regs->gpr[PT_R1]);
8379 + do_group_exit(SIGKILL);
8380 + }
8381 + }
8382 +#endif
8383 +
8384 _exception(SIGSEGV, regs, code, address);
8385 goto bail;
8386 }
8387 diff --git a/arch/powerpc/mm/mmap.c b/arch/powerpc/mm/mmap.c
8388 index cb8bdbe..d770680 100644
8389 --- a/arch/powerpc/mm/mmap.c
8390 +++ b/arch/powerpc/mm/mmap.c
8391 @@ -57,6 +57,10 @@ static unsigned long mmap_rnd(void)
8392 {
8393 unsigned long rnd = 0;
8394
8395 +#ifdef CONFIG_PAX_RANDMMAP
8396 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8397 +#endif
8398 +
8399 if (current->flags & PF_RANDOMIZE) {
8400 /* 8MB for 32bit, 1GB for 64bit */
8401 if (is_32bit_task())
8402 @@ -91,9 +95,21 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8403 */
8404 if (mmap_is_legacy()) {
8405 mm->mmap_base = TASK_UNMAPPED_BASE;
8406 +
8407 +#ifdef CONFIG_PAX_RANDMMAP
8408 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8409 + mm->mmap_base += mm->delta_mmap;
8410 +#endif
8411 +
8412 mm->get_unmapped_area = arch_get_unmapped_area;
8413 } else {
8414 mm->mmap_base = mmap_base();
8415 +
8416 +#ifdef CONFIG_PAX_RANDMMAP
8417 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8418 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
8419 +#endif
8420 +
8421 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
8422 }
8423 }
8424 diff --git a/arch/powerpc/mm/slice.c b/arch/powerpc/mm/slice.c
8425 index 7ce9cf3..a964087 100644
8426 --- a/arch/powerpc/mm/slice.c
8427 +++ b/arch/powerpc/mm/slice.c
8428 @@ -103,7 +103,7 @@ static int slice_area_is_free(struct mm_struct *mm, unsigned long addr,
8429 if ((mm->task_size - len) < addr)
8430 return 0;
8431 vma = find_vma(mm, addr);
8432 - return (!vma || (addr + len) <= vma->vm_start);
8433 + return check_heap_stack_gap(vma, addr, len, 0);
8434 }
8435
8436 static int slice_low_has_vma(struct mm_struct *mm, unsigned long slice)
8437 @@ -277,6 +277,12 @@ static unsigned long slice_find_area_bottomup(struct mm_struct *mm,
8438 info.align_offset = 0;
8439
8440 addr = TASK_UNMAPPED_BASE;
8441 +
8442 +#ifdef CONFIG_PAX_RANDMMAP
8443 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8444 + addr += mm->delta_mmap;
8445 +#endif
8446 +
8447 while (addr < TASK_SIZE) {
8448 info.low_limit = addr;
8449 if (!slice_scan_available(addr, available, 1, &addr))
8450 @@ -410,6 +416,11 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len,
8451 if (fixed && addr > (mm->task_size - len))
8452 return -EINVAL;
8453
8454 +#ifdef CONFIG_PAX_RANDMMAP
8455 + if (!fixed && (mm->pax_flags & MF_PAX_RANDMMAP))
8456 + addr = 0;
8457 +#endif
8458 +
8459 /* If hint, make sure it matches our alignment restrictions */
8460 if (!fixed && addr) {
8461 addr = _ALIGN_UP(addr, 1ul << pshift);
8462 diff --git a/arch/powerpc/platforms/cell/spufs/file.c b/arch/powerpc/platforms/cell/spufs/file.c
8463 index 9098692..3d54cd1 100644
8464 --- a/arch/powerpc/platforms/cell/spufs/file.c
8465 +++ b/arch/powerpc/platforms/cell/spufs/file.c
8466 @@ -280,9 +280,9 @@ spufs_mem_mmap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
8467 return VM_FAULT_NOPAGE;
8468 }
8469
8470 -static int spufs_mem_mmap_access(struct vm_area_struct *vma,
8471 +static ssize_t spufs_mem_mmap_access(struct vm_area_struct *vma,
8472 unsigned long address,
8473 - void *buf, int len, int write)
8474 + void *buf, size_t len, int write)
8475 {
8476 struct spu_context *ctx = vma->vm_file->private_data;
8477 unsigned long offset = address - vma->vm_start;
8478 diff --git a/arch/s390/include/asm/atomic.h b/arch/s390/include/asm/atomic.h
8479 index c797832..ce575c8 100644
8480 --- a/arch/s390/include/asm/atomic.h
8481 +++ b/arch/s390/include/asm/atomic.h
8482 @@ -326,6 +326,16 @@ static inline long long atomic64_dec_if_positive(atomic64_t *v)
8483 #define atomic64_dec_and_test(_v) (atomic64_sub_return(1, _v) == 0)
8484 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
8485
8486 +#define atomic64_read_unchecked(v) atomic64_read(v)
8487 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
8488 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
8489 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
8490 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
8491 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
8492 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
8493 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
8494 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
8495 +
8496 #define smp_mb__before_atomic_dec() smp_mb()
8497 #define smp_mb__after_atomic_dec() smp_mb()
8498 #define smp_mb__before_atomic_inc() smp_mb()
8499 diff --git a/arch/s390/include/asm/cache.h b/arch/s390/include/asm/cache.h
8500 index 4d7ccac..d03d0ad 100644
8501 --- a/arch/s390/include/asm/cache.h
8502 +++ b/arch/s390/include/asm/cache.h
8503 @@ -9,8 +9,10 @@
8504 #ifndef __ARCH_S390_CACHE_H
8505 #define __ARCH_S390_CACHE_H
8506
8507 -#define L1_CACHE_BYTES 256
8508 +#include <linux/const.h>
8509 +
8510 #define L1_CACHE_SHIFT 8
8511 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
8512 #define NET_SKB_PAD 32
8513
8514 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
8515 diff --git a/arch/s390/include/asm/elf.h b/arch/s390/include/asm/elf.h
8516 index 78f4f87..598ce39 100644
8517 --- a/arch/s390/include/asm/elf.h
8518 +++ b/arch/s390/include/asm/elf.h
8519 @@ -162,8 +162,14 @@ extern unsigned int vdso_enabled;
8520 the loader. We need to make sure that it is out of the way of the program
8521 that it will "exec", and that there is sufficient room for the brk. */
8522
8523 -extern unsigned long randomize_et_dyn(unsigned long base);
8524 -#define ELF_ET_DYN_BASE (randomize_et_dyn(STACK_TOP / 3 * 2))
8525 +#define ELF_ET_DYN_BASE (STACK_TOP / 3 * 2)
8526 +
8527 +#ifdef CONFIG_PAX_ASLR
8528 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_31BIT) ? 0x10000UL : 0x80000000UL)
8529 +
8530 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
8531 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
8532 +#endif
8533
8534 /* This yields a mask that user programs can use to figure out what
8535 instruction set this CPU supports. */
8536 @@ -222,9 +228,6 @@ struct linux_binprm;
8537 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
8538 int arch_setup_additional_pages(struct linux_binprm *, int);
8539
8540 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
8541 -#define arch_randomize_brk arch_randomize_brk
8542 -
8543 void *fill_cpu_elf_notes(void *ptr, struct save_area *sa);
8544
8545 #endif
8546 diff --git a/arch/s390/include/asm/exec.h b/arch/s390/include/asm/exec.h
8547 index c4a93d6..4d2a9b4 100644
8548 --- a/arch/s390/include/asm/exec.h
8549 +++ b/arch/s390/include/asm/exec.h
8550 @@ -7,6 +7,6 @@
8551 #ifndef __ASM_EXEC_H
8552 #define __ASM_EXEC_H
8553
8554 -extern unsigned long arch_align_stack(unsigned long sp);
8555 +#define arch_align_stack(x) ((x) & ~0xfUL)
8556
8557 #endif /* __ASM_EXEC_H */
8558 diff --git a/arch/s390/include/asm/uaccess.h b/arch/s390/include/asm/uaccess.h
8559 index 9c33ed4..e40cbef 100644
8560 --- a/arch/s390/include/asm/uaccess.h
8561 +++ b/arch/s390/include/asm/uaccess.h
8562 @@ -252,6 +252,10 @@ static inline unsigned long __must_check
8563 copy_to_user(void __user *to, const void *from, unsigned long n)
8564 {
8565 might_fault();
8566 +
8567 + if ((long)n < 0)
8568 + return n;
8569 +
8570 return __copy_to_user(to, from, n);
8571 }
8572
8573 @@ -275,6 +279,9 @@ copy_to_user(void __user *to, const void *from, unsigned long n)
8574 static inline unsigned long __must_check
8575 __copy_from_user(void *to, const void __user *from, unsigned long n)
8576 {
8577 + if ((long)n < 0)
8578 + return n;
8579 +
8580 if (__builtin_constant_p(n) && (n <= 256))
8581 return uaccess.copy_from_user_small(n, from, to);
8582 else
8583 @@ -306,10 +313,14 @@ __compiletime_warning("copy_from_user() buffer size is not provably correct")
8584 static inline unsigned long __must_check
8585 copy_from_user(void *to, const void __user *from, unsigned long n)
8586 {
8587 - unsigned int sz = __compiletime_object_size(to);
8588 + size_t sz = __compiletime_object_size(to);
8589
8590 might_fault();
8591 - if (unlikely(sz != -1 && sz < n)) {
8592 +
8593 + if ((long)n < 0)
8594 + return n;
8595 +
8596 + if (unlikely(sz != (size_t)-1 && sz < n)) {
8597 copy_from_user_overflow();
8598 return n;
8599 }
8600 diff --git a/arch/s390/kernel/module.c b/arch/s390/kernel/module.c
8601 index 7845e15..59c4353 100644
8602 --- a/arch/s390/kernel/module.c
8603 +++ b/arch/s390/kernel/module.c
8604 @@ -169,11 +169,11 @@ int module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
8605
8606 /* Increase core size by size of got & plt and set start
8607 offsets for got and plt. */
8608 - me->core_size = ALIGN(me->core_size, 4);
8609 - me->arch.got_offset = me->core_size;
8610 - me->core_size += me->arch.got_size;
8611 - me->arch.plt_offset = me->core_size;
8612 - me->core_size += me->arch.plt_size;
8613 + me->core_size_rw = ALIGN(me->core_size_rw, 4);
8614 + me->arch.got_offset = me->core_size_rw;
8615 + me->core_size_rw += me->arch.got_size;
8616 + me->arch.plt_offset = me->core_size_rx;
8617 + me->core_size_rx += me->arch.plt_size;
8618 return 0;
8619 }
8620
8621 @@ -289,7 +289,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8622 if (info->got_initialized == 0) {
8623 Elf_Addr *gotent;
8624
8625 - gotent = me->module_core + me->arch.got_offset +
8626 + gotent = me->module_core_rw + me->arch.got_offset +
8627 info->got_offset;
8628 *gotent = val;
8629 info->got_initialized = 1;
8630 @@ -312,7 +312,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8631 rc = apply_rela_bits(loc, val, 0, 64, 0);
8632 else if (r_type == R_390_GOTENT ||
8633 r_type == R_390_GOTPLTENT) {
8634 - val += (Elf_Addr) me->module_core - loc;
8635 + val += (Elf_Addr) me->module_core_rw - loc;
8636 rc = apply_rela_bits(loc, val, 1, 32, 1);
8637 }
8638 break;
8639 @@ -325,7 +325,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8640 case R_390_PLTOFF64: /* 16 bit offset from GOT to PLT. */
8641 if (info->plt_initialized == 0) {
8642 unsigned int *ip;
8643 - ip = me->module_core + me->arch.plt_offset +
8644 + ip = me->module_core_rx + me->arch.plt_offset +
8645 info->plt_offset;
8646 #ifndef CONFIG_64BIT
8647 ip[0] = 0x0d105810; /* basr 1,0; l 1,6(1); br 1 */
8648 @@ -350,7 +350,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8649 val - loc + 0xffffUL < 0x1ffffeUL) ||
8650 (r_type == R_390_PLT32DBL &&
8651 val - loc + 0xffffffffULL < 0x1fffffffeULL)))
8652 - val = (Elf_Addr) me->module_core +
8653 + val = (Elf_Addr) me->module_core_rx +
8654 me->arch.plt_offset +
8655 info->plt_offset;
8656 val += rela->r_addend - loc;
8657 @@ -372,7 +372,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8658 case R_390_GOTOFF32: /* 32 bit offset to GOT. */
8659 case R_390_GOTOFF64: /* 64 bit offset to GOT. */
8660 val = val + rela->r_addend -
8661 - ((Elf_Addr) me->module_core + me->arch.got_offset);
8662 + ((Elf_Addr) me->module_core_rw + me->arch.got_offset);
8663 if (r_type == R_390_GOTOFF16)
8664 rc = apply_rela_bits(loc, val, 0, 16, 0);
8665 else if (r_type == R_390_GOTOFF32)
8666 @@ -382,7 +382,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8667 break;
8668 case R_390_GOTPC: /* 32 bit PC relative offset to GOT. */
8669 case R_390_GOTPCDBL: /* 32 bit PC rel. off. to GOT shifted by 1. */
8670 - val = (Elf_Addr) me->module_core + me->arch.got_offset +
8671 + val = (Elf_Addr) me->module_core_rw + me->arch.got_offset +
8672 rela->r_addend - loc;
8673 if (r_type == R_390_GOTPC)
8674 rc = apply_rela_bits(loc, val, 1, 32, 0);
8675 diff --git a/arch/s390/kernel/process.c b/arch/s390/kernel/process.c
8676 index c5dbb33..b41f4ee 100644
8677 --- a/arch/s390/kernel/process.c
8678 +++ b/arch/s390/kernel/process.c
8679 @@ -237,39 +237,3 @@ unsigned long get_wchan(struct task_struct *p)
8680 }
8681 return 0;
8682 }
8683 -
8684 -unsigned long arch_align_stack(unsigned long sp)
8685 -{
8686 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
8687 - sp -= get_random_int() & ~PAGE_MASK;
8688 - return sp & ~0xf;
8689 -}
8690 -
8691 -static inline unsigned long brk_rnd(void)
8692 -{
8693 - /* 8MB for 32bit, 1GB for 64bit */
8694 - if (is_32bit_task())
8695 - return (get_random_int() & 0x7ffUL) << PAGE_SHIFT;
8696 - else
8697 - return (get_random_int() & 0x3ffffUL) << PAGE_SHIFT;
8698 -}
8699 -
8700 -unsigned long arch_randomize_brk(struct mm_struct *mm)
8701 -{
8702 - unsigned long ret = PAGE_ALIGN(mm->brk + brk_rnd());
8703 -
8704 - if (ret < mm->brk)
8705 - return mm->brk;
8706 - return ret;
8707 -}
8708 -
8709 -unsigned long randomize_et_dyn(unsigned long base)
8710 -{
8711 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
8712 -
8713 - if (!(current->flags & PF_RANDOMIZE))
8714 - return base;
8715 - if (ret < base)
8716 - return base;
8717 - return ret;
8718 -}
8719 diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c
8720 index 4002329..99b67cb 100644
8721 --- a/arch/s390/mm/mmap.c
8722 +++ b/arch/s390/mm/mmap.c
8723 @@ -90,9 +90,21 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8724 */
8725 if (mmap_is_legacy()) {
8726 mm->mmap_base = TASK_UNMAPPED_BASE;
8727 +
8728 +#ifdef CONFIG_PAX_RANDMMAP
8729 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8730 + mm->mmap_base += mm->delta_mmap;
8731 +#endif
8732 +
8733 mm->get_unmapped_area = arch_get_unmapped_area;
8734 } else {
8735 mm->mmap_base = mmap_base();
8736 +
8737 +#ifdef CONFIG_PAX_RANDMMAP
8738 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8739 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
8740 +#endif
8741 +
8742 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
8743 }
8744 }
8745 @@ -173,9 +185,21 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8746 */
8747 if (mmap_is_legacy()) {
8748 mm->mmap_base = TASK_UNMAPPED_BASE;
8749 +
8750 +#ifdef CONFIG_PAX_RANDMMAP
8751 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8752 + mm->mmap_base += mm->delta_mmap;
8753 +#endif
8754 +
8755 mm->get_unmapped_area = s390_get_unmapped_area;
8756 } else {
8757 mm->mmap_base = mmap_base();
8758 +
8759 +#ifdef CONFIG_PAX_RANDMMAP
8760 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8761 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
8762 +#endif
8763 +
8764 mm->get_unmapped_area = s390_get_unmapped_area_topdown;
8765 }
8766 }
8767 diff --git a/arch/score/include/asm/cache.h b/arch/score/include/asm/cache.h
8768 index ae3d59f..f65f075 100644
8769 --- a/arch/score/include/asm/cache.h
8770 +++ b/arch/score/include/asm/cache.h
8771 @@ -1,7 +1,9 @@
8772 #ifndef _ASM_SCORE_CACHE_H
8773 #define _ASM_SCORE_CACHE_H
8774
8775 +#include <linux/const.h>
8776 +
8777 #define L1_CACHE_SHIFT 4
8778 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
8779 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
8780
8781 #endif /* _ASM_SCORE_CACHE_H */
8782 diff --git a/arch/score/include/asm/exec.h b/arch/score/include/asm/exec.h
8783 index f9f3cd5..58ff438 100644
8784 --- a/arch/score/include/asm/exec.h
8785 +++ b/arch/score/include/asm/exec.h
8786 @@ -1,6 +1,6 @@
8787 #ifndef _ASM_SCORE_EXEC_H
8788 #define _ASM_SCORE_EXEC_H
8789
8790 -extern unsigned long arch_align_stack(unsigned long sp);
8791 +#define arch_align_stack(x) (x)
8792
8793 #endif /* _ASM_SCORE_EXEC_H */
8794 diff --git a/arch/score/kernel/process.c b/arch/score/kernel/process.c
8795 index a1519ad3..e8ac1ff 100644
8796 --- a/arch/score/kernel/process.c
8797 +++ b/arch/score/kernel/process.c
8798 @@ -116,8 +116,3 @@ unsigned long get_wchan(struct task_struct *task)
8799
8800 return task_pt_regs(task)->cp0_epc;
8801 }
8802 -
8803 -unsigned long arch_align_stack(unsigned long sp)
8804 -{
8805 - return sp;
8806 -}
8807 diff --git a/arch/sh/include/asm/cache.h b/arch/sh/include/asm/cache.h
8808 index ef9e555..331bd29 100644
8809 --- a/arch/sh/include/asm/cache.h
8810 +++ b/arch/sh/include/asm/cache.h
8811 @@ -9,10 +9,11 @@
8812 #define __ASM_SH_CACHE_H
8813 #ifdef __KERNEL__
8814
8815 +#include <linux/const.h>
8816 #include <linux/init.h>
8817 #include <cpu/cache.h>
8818
8819 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
8820 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
8821
8822 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
8823
8824 diff --git a/arch/sh/mm/mmap.c b/arch/sh/mm/mmap.c
8825 index 6777177..cb5e44f 100644
8826 --- a/arch/sh/mm/mmap.c
8827 +++ b/arch/sh/mm/mmap.c
8828 @@ -36,6 +36,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
8829 struct mm_struct *mm = current->mm;
8830 struct vm_area_struct *vma;
8831 int do_colour_align;
8832 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8833 struct vm_unmapped_area_info info;
8834
8835 if (flags & MAP_FIXED) {
8836 @@ -55,6 +56,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
8837 if (filp || (flags & MAP_SHARED))
8838 do_colour_align = 1;
8839
8840 +#ifdef CONFIG_PAX_RANDMMAP
8841 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8842 +#endif
8843 +
8844 if (addr) {
8845 if (do_colour_align)
8846 addr = COLOUR_ALIGN(addr, pgoff);
8847 @@ -62,14 +67,13 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
8848 addr = PAGE_ALIGN(addr);
8849
8850 vma = find_vma(mm, addr);
8851 - if (TASK_SIZE - len >= addr &&
8852 - (!vma || addr + len <= vma->vm_start))
8853 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8854 return addr;
8855 }
8856
8857 info.flags = 0;
8858 info.length = len;
8859 - info.low_limit = TASK_UNMAPPED_BASE;
8860 + info.low_limit = mm->mmap_base;
8861 info.high_limit = TASK_SIZE;
8862 info.align_mask = do_colour_align ? (PAGE_MASK & shm_align_mask) : 0;
8863 info.align_offset = pgoff << PAGE_SHIFT;
8864 @@ -85,6 +89,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8865 struct mm_struct *mm = current->mm;
8866 unsigned long addr = addr0;
8867 int do_colour_align;
8868 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8869 struct vm_unmapped_area_info info;
8870
8871 if (flags & MAP_FIXED) {
8872 @@ -104,6 +109,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8873 if (filp || (flags & MAP_SHARED))
8874 do_colour_align = 1;
8875
8876 +#ifdef CONFIG_PAX_RANDMMAP
8877 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8878 +#endif
8879 +
8880 /* requesting a specific address */
8881 if (addr) {
8882 if (do_colour_align)
8883 @@ -112,8 +121,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8884 addr = PAGE_ALIGN(addr);
8885
8886 vma = find_vma(mm, addr);
8887 - if (TASK_SIZE - len >= addr &&
8888 - (!vma || addr + len <= vma->vm_start))
8889 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8890 return addr;
8891 }
8892
8893 @@ -135,6 +143,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8894 VM_BUG_ON(addr != -ENOMEM);
8895 info.flags = 0;
8896 info.low_limit = TASK_UNMAPPED_BASE;
8897 +
8898 +#ifdef CONFIG_PAX_RANDMMAP
8899 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8900 + info.low_limit += mm->delta_mmap;
8901 +#endif
8902 +
8903 info.high_limit = TASK_SIZE;
8904 addr = vm_unmapped_area(&info);
8905 }
8906 diff --git a/arch/sparc/include/asm/atomic_64.h b/arch/sparc/include/asm/atomic_64.h
8907 index be56a24..443328f 100644
8908 --- a/arch/sparc/include/asm/atomic_64.h
8909 +++ b/arch/sparc/include/asm/atomic_64.h
8910 @@ -14,18 +14,40 @@
8911 #define ATOMIC64_INIT(i) { (i) }
8912
8913 #define atomic_read(v) (*(volatile int *)&(v)->counter)
8914 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
8915 +{
8916 + return v->counter;
8917 +}
8918 #define atomic64_read(v) (*(volatile long *)&(v)->counter)
8919 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
8920 +{
8921 + return v->counter;
8922 +}
8923
8924 #define atomic_set(v, i) (((v)->counter) = i)
8925 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
8926 +{
8927 + v->counter = i;
8928 +}
8929 #define atomic64_set(v, i) (((v)->counter) = i)
8930 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
8931 +{
8932 + v->counter = i;
8933 +}
8934
8935 extern void atomic_add(int, atomic_t *);
8936 +extern void atomic_add_unchecked(int, atomic_unchecked_t *);
8937 extern void atomic64_add(long, atomic64_t *);
8938 +extern void atomic64_add_unchecked(long, atomic64_unchecked_t *);
8939 extern void atomic_sub(int, atomic_t *);
8940 +extern void atomic_sub_unchecked(int, atomic_unchecked_t *);
8941 extern void atomic64_sub(long, atomic64_t *);
8942 +extern void atomic64_sub_unchecked(long, atomic64_unchecked_t *);
8943
8944 extern int atomic_add_ret(int, atomic_t *);
8945 +extern int atomic_add_ret_unchecked(int, atomic_unchecked_t *);
8946 extern long atomic64_add_ret(long, atomic64_t *);
8947 +extern long atomic64_add_ret_unchecked(long, atomic64_unchecked_t *);
8948 extern int atomic_sub_ret(int, atomic_t *);
8949 extern long atomic64_sub_ret(long, atomic64_t *);
8950
8951 @@ -33,13 +55,29 @@ extern long atomic64_sub_ret(long, atomic64_t *);
8952 #define atomic64_dec_return(v) atomic64_sub_ret(1, v)
8953
8954 #define atomic_inc_return(v) atomic_add_ret(1, v)
8955 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
8956 +{
8957 + return atomic_add_ret_unchecked(1, v);
8958 +}
8959 #define atomic64_inc_return(v) atomic64_add_ret(1, v)
8960 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
8961 +{
8962 + return atomic64_add_ret_unchecked(1, v);
8963 +}
8964
8965 #define atomic_sub_return(i, v) atomic_sub_ret(i, v)
8966 #define atomic64_sub_return(i, v) atomic64_sub_ret(i, v)
8967
8968 #define atomic_add_return(i, v) atomic_add_ret(i, v)
8969 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
8970 +{
8971 + return atomic_add_ret_unchecked(i, v);
8972 +}
8973 #define atomic64_add_return(i, v) atomic64_add_ret(i, v)
8974 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
8975 +{
8976 + return atomic64_add_ret_unchecked(i, v);
8977 +}
8978
8979 /*
8980 * atomic_inc_and_test - increment and test
8981 @@ -50,6 +88,10 @@ extern long atomic64_sub_ret(long, atomic64_t *);
8982 * other cases.
8983 */
8984 #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
8985 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
8986 +{
8987 + return atomic_inc_return_unchecked(v) == 0;
8988 +}
8989 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
8990
8991 #define atomic_sub_and_test(i, v) (atomic_sub_ret(i, v) == 0)
8992 @@ -59,25 +101,60 @@ extern long atomic64_sub_ret(long, atomic64_t *);
8993 #define atomic64_dec_and_test(v) (atomic64_sub_ret(1, v) == 0)
8994
8995 #define atomic_inc(v) atomic_add(1, v)
8996 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
8997 +{
8998 + atomic_add_unchecked(1, v);
8999 +}
9000 #define atomic64_inc(v) atomic64_add(1, v)
9001 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
9002 +{
9003 + atomic64_add_unchecked(1, v);
9004 +}
9005
9006 #define atomic_dec(v) atomic_sub(1, v)
9007 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
9008 +{
9009 + atomic_sub_unchecked(1, v);
9010 +}
9011 #define atomic64_dec(v) atomic64_sub(1, v)
9012 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
9013 +{
9014 + atomic64_sub_unchecked(1, v);
9015 +}
9016
9017 #define atomic_add_negative(i, v) (atomic_add_ret(i, v) < 0)
9018 #define atomic64_add_negative(i, v) (atomic64_add_ret(i, v) < 0)
9019
9020 #define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
9021 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
9022 +{
9023 + return cmpxchg(&v->counter, old, new);
9024 +}
9025 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
9026 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
9027 +{
9028 + return xchg(&v->counter, new);
9029 +}
9030
9031 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
9032 {
9033 - int c, old;
9034 + int c, old, new;
9035 c = atomic_read(v);
9036 for (;;) {
9037 - if (unlikely(c == (u)))
9038 + if (unlikely(c == u))
9039 break;
9040 - old = atomic_cmpxchg((v), c, c + (a));
9041 +
9042 + asm volatile("addcc %2, %0, %0\n"
9043 +
9044 +#ifdef CONFIG_PAX_REFCOUNT
9045 + "tvs %%icc, 6\n"
9046 +#endif
9047 +
9048 + : "=r" (new)
9049 + : "0" (c), "ir" (a)
9050 + : "cc");
9051 +
9052 + old = atomic_cmpxchg(v, c, new);
9053 if (likely(old == c))
9054 break;
9055 c = old;
9056 @@ -88,20 +165,35 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
9057 #define atomic64_cmpxchg(v, o, n) \
9058 ((__typeof__((v)->counter))cmpxchg(&((v)->counter), (o), (n)))
9059 #define atomic64_xchg(v, new) (xchg(&((v)->counter), new))
9060 +static inline long atomic64_xchg_unchecked(atomic64_unchecked_t *v, long new)
9061 +{
9062 + return xchg(&v->counter, new);
9063 +}
9064
9065 static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
9066 {
9067 - long c, old;
9068 + long c, old, new;
9069 c = atomic64_read(v);
9070 for (;;) {
9071 - if (unlikely(c == (u)))
9072 + if (unlikely(c == u))
9073 break;
9074 - old = atomic64_cmpxchg((v), c, c + (a));
9075 +
9076 + asm volatile("addcc %2, %0, %0\n"
9077 +
9078 +#ifdef CONFIG_PAX_REFCOUNT
9079 + "tvs %%xcc, 6\n"
9080 +#endif
9081 +
9082 + : "=r" (new)
9083 + : "0" (c), "ir" (a)
9084 + : "cc");
9085 +
9086 + old = atomic64_cmpxchg(v, c, new);
9087 if (likely(old == c))
9088 break;
9089 c = old;
9090 }
9091 - return c != (u);
9092 + return c != u;
9093 }
9094
9095 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
9096 diff --git a/arch/sparc/include/asm/cache.h b/arch/sparc/include/asm/cache.h
9097 index 5bb6991..5c2132e 100644
9098 --- a/arch/sparc/include/asm/cache.h
9099 +++ b/arch/sparc/include/asm/cache.h
9100 @@ -7,10 +7,12 @@
9101 #ifndef _SPARC_CACHE_H
9102 #define _SPARC_CACHE_H
9103
9104 +#include <linux/const.h>
9105 +
9106 #define ARCH_SLAB_MINALIGN __alignof__(unsigned long long)
9107
9108 #define L1_CACHE_SHIFT 5
9109 -#define L1_CACHE_BYTES 32
9110 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
9111
9112 #ifdef CONFIG_SPARC32
9113 #define SMP_CACHE_BYTES_SHIFT 5
9114 diff --git a/arch/sparc/include/asm/elf_32.h b/arch/sparc/include/asm/elf_32.h
9115 index a24e41f..47677ff 100644
9116 --- a/arch/sparc/include/asm/elf_32.h
9117 +++ b/arch/sparc/include/asm/elf_32.h
9118 @@ -114,6 +114,13 @@ typedef struct {
9119
9120 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE)
9121
9122 +#ifdef CONFIG_PAX_ASLR
9123 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
9124 +
9125 +#define PAX_DELTA_MMAP_LEN 16
9126 +#define PAX_DELTA_STACK_LEN 16
9127 +#endif
9128 +
9129 /* This yields a mask that user programs can use to figure out what
9130 instruction set this cpu supports. This can NOT be done in userspace
9131 on Sparc. */
9132 diff --git a/arch/sparc/include/asm/elf_64.h b/arch/sparc/include/asm/elf_64.h
9133 index 370ca1e..d4f4a98 100644
9134 --- a/arch/sparc/include/asm/elf_64.h
9135 +++ b/arch/sparc/include/asm/elf_64.h
9136 @@ -189,6 +189,13 @@ typedef struct {
9137 #define ELF_ET_DYN_BASE 0x0000010000000000UL
9138 #define COMPAT_ELF_ET_DYN_BASE 0x0000000070000000UL
9139
9140 +#ifdef CONFIG_PAX_ASLR
9141 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_32BIT) ? 0x10000UL : 0x100000UL)
9142 +
9143 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_32BIT) ? 14 : 28)
9144 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_32BIT) ? 15 : 29)
9145 +#endif
9146 +
9147 extern unsigned long sparc64_elf_hwcap;
9148 #define ELF_HWCAP sparc64_elf_hwcap
9149
9150 diff --git a/arch/sparc/include/asm/pgalloc_32.h b/arch/sparc/include/asm/pgalloc_32.h
9151 index 9b1c36d..209298b 100644
9152 --- a/arch/sparc/include/asm/pgalloc_32.h
9153 +++ b/arch/sparc/include/asm/pgalloc_32.h
9154 @@ -33,6 +33,7 @@ static inline void pgd_set(pgd_t * pgdp, pmd_t * pmdp)
9155 }
9156
9157 #define pgd_populate(MM, PGD, PMD) pgd_set(PGD, PMD)
9158 +#define pgd_populate_kernel(MM, PGD, PMD) pgd_populate((MM), (PGD), (PMD))
9159
9160 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm,
9161 unsigned long address)
9162 diff --git a/arch/sparc/include/asm/pgalloc_64.h b/arch/sparc/include/asm/pgalloc_64.h
9163 index bcfe063..b333142 100644
9164 --- a/arch/sparc/include/asm/pgalloc_64.h
9165 +++ b/arch/sparc/include/asm/pgalloc_64.h
9166 @@ -26,6 +26,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
9167 }
9168
9169 #define pud_populate(MM, PUD, PMD) pud_set(PUD, PMD)
9170 +#define pud_populate_kernel(MM, PUD, PMD) pud_populate((MM), (PUD), (PMD))
9171
9172 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
9173 {
9174 diff --git a/arch/sparc/include/asm/pgtable_32.h b/arch/sparc/include/asm/pgtable_32.h
9175 index 502f632..da1917f 100644
9176 --- a/arch/sparc/include/asm/pgtable_32.h
9177 +++ b/arch/sparc/include/asm/pgtable_32.h
9178 @@ -50,6 +50,9 @@ extern unsigned long calc_highpages(void);
9179 #define PAGE_SHARED SRMMU_PAGE_SHARED
9180 #define PAGE_COPY SRMMU_PAGE_COPY
9181 #define PAGE_READONLY SRMMU_PAGE_RDONLY
9182 +#define PAGE_SHARED_NOEXEC SRMMU_PAGE_SHARED_NOEXEC
9183 +#define PAGE_COPY_NOEXEC SRMMU_PAGE_COPY_NOEXEC
9184 +#define PAGE_READONLY_NOEXEC SRMMU_PAGE_RDONLY_NOEXEC
9185 #define PAGE_KERNEL SRMMU_PAGE_KERNEL
9186
9187 /* Top-level page directory - dummy used by init-mm.
9188 @@ -62,18 +65,18 @@ extern unsigned long ptr_in_current_pgd;
9189
9190 /* xwr */
9191 #define __P000 PAGE_NONE
9192 -#define __P001 PAGE_READONLY
9193 -#define __P010 PAGE_COPY
9194 -#define __P011 PAGE_COPY
9195 +#define __P001 PAGE_READONLY_NOEXEC
9196 +#define __P010 PAGE_COPY_NOEXEC
9197 +#define __P011 PAGE_COPY_NOEXEC
9198 #define __P100 PAGE_READONLY
9199 #define __P101 PAGE_READONLY
9200 #define __P110 PAGE_COPY
9201 #define __P111 PAGE_COPY
9202
9203 #define __S000 PAGE_NONE
9204 -#define __S001 PAGE_READONLY
9205 -#define __S010 PAGE_SHARED
9206 -#define __S011 PAGE_SHARED
9207 +#define __S001 PAGE_READONLY_NOEXEC
9208 +#define __S010 PAGE_SHARED_NOEXEC
9209 +#define __S011 PAGE_SHARED_NOEXEC
9210 #define __S100 PAGE_READONLY
9211 #define __S101 PAGE_READONLY
9212 #define __S110 PAGE_SHARED
9213 diff --git a/arch/sparc/include/asm/pgtsrmmu.h b/arch/sparc/include/asm/pgtsrmmu.h
9214 index 79da178..c2eede8 100644
9215 --- a/arch/sparc/include/asm/pgtsrmmu.h
9216 +++ b/arch/sparc/include/asm/pgtsrmmu.h
9217 @@ -115,6 +115,11 @@
9218 SRMMU_EXEC | SRMMU_REF)
9219 #define SRMMU_PAGE_RDONLY __pgprot(SRMMU_VALID | SRMMU_CACHE | \
9220 SRMMU_EXEC | SRMMU_REF)
9221 +
9222 +#define SRMMU_PAGE_SHARED_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_WRITE | SRMMU_REF)
9223 +#define SRMMU_PAGE_COPY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
9224 +#define SRMMU_PAGE_RDONLY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
9225 +
9226 #define SRMMU_PAGE_KERNEL __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_PRIV | \
9227 SRMMU_DIRTY | SRMMU_REF)
9228
9229 diff --git a/arch/sparc/include/asm/spinlock_64.h b/arch/sparc/include/asm/spinlock_64.h
9230 index 9689176..63c18ea 100644
9231 --- a/arch/sparc/include/asm/spinlock_64.h
9232 +++ b/arch/sparc/include/asm/spinlock_64.h
9233 @@ -92,14 +92,19 @@ static inline void arch_spin_lock_flags(arch_spinlock_t *lock, unsigned long fla
9234
9235 /* Multi-reader locks, these are much saner than the 32-bit Sparc ones... */
9236
9237 -static void inline arch_read_lock(arch_rwlock_t *lock)
9238 +static inline void arch_read_lock(arch_rwlock_t *lock)
9239 {
9240 unsigned long tmp1, tmp2;
9241
9242 __asm__ __volatile__ (
9243 "1: ldsw [%2], %0\n"
9244 " brlz,pn %0, 2f\n"
9245 -"4: add %0, 1, %1\n"
9246 +"4: addcc %0, 1, %1\n"
9247 +
9248 +#ifdef CONFIG_PAX_REFCOUNT
9249 +" tvs %%icc, 6\n"
9250 +#endif
9251 +
9252 " cas [%2], %0, %1\n"
9253 " cmp %0, %1\n"
9254 " bne,pn %%icc, 1b\n"
9255 @@ -112,10 +117,10 @@ static void inline arch_read_lock(arch_rwlock_t *lock)
9256 " .previous"
9257 : "=&r" (tmp1), "=&r" (tmp2)
9258 : "r" (lock)
9259 - : "memory");
9260 + : "memory", "cc");
9261 }
9262
9263 -static int inline arch_read_trylock(arch_rwlock_t *lock)
9264 +static inline int arch_read_trylock(arch_rwlock_t *lock)
9265 {
9266 int tmp1, tmp2;
9267
9268 @@ -123,7 +128,12 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
9269 "1: ldsw [%2], %0\n"
9270 " brlz,a,pn %0, 2f\n"
9271 " mov 0, %0\n"
9272 -" add %0, 1, %1\n"
9273 +" addcc %0, 1, %1\n"
9274 +
9275 +#ifdef CONFIG_PAX_REFCOUNT
9276 +" tvs %%icc, 6\n"
9277 +#endif
9278 +
9279 " cas [%2], %0, %1\n"
9280 " cmp %0, %1\n"
9281 " bne,pn %%icc, 1b\n"
9282 @@ -136,13 +146,18 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
9283 return tmp1;
9284 }
9285
9286 -static void inline arch_read_unlock(arch_rwlock_t *lock)
9287 +static inline void arch_read_unlock(arch_rwlock_t *lock)
9288 {
9289 unsigned long tmp1, tmp2;
9290
9291 __asm__ __volatile__(
9292 "1: lduw [%2], %0\n"
9293 -" sub %0, 1, %1\n"
9294 +" subcc %0, 1, %1\n"
9295 +
9296 +#ifdef CONFIG_PAX_REFCOUNT
9297 +" tvs %%icc, 6\n"
9298 +#endif
9299 +
9300 " cas [%2], %0, %1\n"
9301 " cmp %0, %1\n"
9302 " bne,pn %%xcc, 1b\n"
9303 @@ -152,7 +167,7 @@ static void inline arch_read_unlock(arch_rwlock_t *lock)
9304 : "memory");
9305 }
9306
9307 -static void inline arch_write_lock(arch_rwlock_t *lock)
9308 +static inline void arch_write_lock(arch_rwlock_t *lock)
9309 {
9310 unsigned long mask, tmp1, tmp2;
9311
9312 @@ -177,7 +192,7 @@ static void inline arch_write_lock(arch_rwlock_t *lock)
9313 : "memory");
9314 }
9315
9316 -static void inline arch_write_unlock(arch_rwlock_t *lock)
9317 +static inline void arch_write_unlock(arch_rwlock_t *lock)
9318 {
9319 __asm__ __volatile__(
9320 " stw %%g0, [%0]"
9321 @@ -186,7 +201,7 @@ static void inline arch_write_unlock(arch_rwlock_t *lock)
9322 : "memory");
9323 }
9324
9325 -static int inline arch_write_trylock(arch_rwlock_t *lock)
9326 +static inline int arch_write_trylock(arch_rwlock_t *lock)
9327 {
9328 unsigned long mask, tmp1, tmp2, result;
9329
9330 diff --git a/arch/sparc/include/asm/thread_info_32.h b/arch/sparc/include/asm/thread_info_32.h
9331 index dd38075..e7cac83 100644
9332 --- a/arch/sparc/include/asm/thread_info_32.h
9333 +++ b/arch/sparc/include/asm/thread_info_32.h
9334 @@ -49,6 +49,8 @@ struct thread_info {
9335 unsigned long w_saved;
9336
9337 struct restart_block restart_block;
9338 +
9339 + unsigned long lowest_stack;
9340 };
9341
9342 /*
9343 diff --git a/arch/sparc/include/asm/thread_info_64.h b/arch/sparc/include/asm/thread_info_64.h
9344 index d5e5042..9bfee76 100644
9345 --- a/arch/sparc/include/asm/thread_info_64.h
9346 +++ b/arch/sparc/include/asm/thread_info_64.h
9347 @@ -63,6 +63,8 @@ struct thread_info {
9348 struct pt_regs *kern_una_regs;
9349 unsigned int kern_una_insn;
9350
9351 + unsigned long lowest_stack;
9352 +
9353 unsigned long fpregs[0] __attribute__ ((aligned(64)));
9354 };
9355
9356 @@ -192,10 +194,11 @@ register struct thread_info *current_thread_info_reg asm("g6");
9357 #define TIF_UNALIGNED 5 /* allowed to do unaligned accesses */
9358 /* flag bit 6 is available */
9359 #define TIF_32BIT 7 /* 32-bit binary */
9360 -/* flag bit 8 is available */
9361 +#define TIF_GRSEC_SETXID 8 /* update credentials on syscall entry/exit */
9362 #define TIF_SECCOMP 9 /* secure computing */
9363 #define TIF_SYSCALL_AUDIT 10 /* syscall auditing active */
9364 #define TIF_SYSCALL_TRACEPOINT 11 /* syscall tracepoint instrumentation */
9365 +
9366 /* NOTE: Thread flags >= 12 should be ones we have no interest
9367 * in using in assembly, else we can't use the mask as
9368 * an immediate value in instructions such as andcc.
9369 @@ -214,12 +217,18 @@ register struct thread_info *current_thread_info_reg asm("g6");
9370 #define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
9371 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
9372 #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
9373 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
9374
9375 #define _TIF_USER_WORK_MASK ((0xff << TI_FLAG_WSAVED_SHIFT) | \
9376 _TIF_DO_NOTIFY_RESUME_MASK | \
9377 _TIF_NEED_RESCHED)
9378 #define _TIF_DO_NOTIFY_RESUME_MASK (_TIF_NOTIFY_RESUME | _TIF_SIGPENDING)
9379
9380 +#define _TIF_WORK_SYSCALL \
9381 + (_TIF_SYSCALL_TRACE | _TIF_SECCOMP | _TIF_SYSCALL_AUDIT | \
9382 + _TIF_SYSCALL_TRACEPOINT | _TIF_GRSEC_SETXID)
9383 +
9384 +
9385 /*
9386 * Thread-synchronous status.
9387 *
9388 diff --git a/arch/sparc/include/asm/uaccess.h b/arch/sparc/include/asm/uaccess.h
9389 index 0167d26..767bb0c 100644
9390 --- a/arch/sparc/include/asm/uaccess.h
9391 +++ b/arch/sparc/include/asm/uaccess.h
9392 @@ -1,5 +1,6 @@
9393 #ifndef ___ASM_SPARC_UACCESS_H
9394 #define ___ASM_SPARC_UACCESS_H
9395 +
9396 #if defined(__sparc__) && defined(__arch64__)
9397 #include <asm/uaccess_64.h>
9398 #else
9399 diff --git a/arch/sparc/include/asm/uaccess_32.h b/arch/sparc/include/asm/uaccess_32.h
9400 index 53a28dd..50c38c3 100644
9401 --- a/arch/sparc/include/asm/uaccess_32.h
9402 +++ b/arch/sparc/include/asm/uaccess_32.h
9403 @@ -250,27 +250,46 @@ extern unsigned long __copy_user(void __user *to, const void __user *from, unsig
9404
9405 static inline unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
9406 {
9407 - if (n && __access_ok((unsigned long) to, n))
9408 + if ((long)n < 0)
9409 + return n;
9410 +
9411 + if (n && __access_ok((unsigned long) to, n)) {
9412 + if (!__builtin_constant_p(n))
9413 + check_object_size(from, n, true);
9414 return __copy_user(to, (__force void __user *) from, n);
9415 - else
9416 + } else
9417 return n;
9418 }
9419
9420 static inline unsigned long __copy_to_user(void __user *to, const void *from, unsigned long n)
9421 {
9422 + if ((long)n < 0)
9423 + return n;
9424 +
9425 + if (!__builtin_constant_p(n))
9426 + check_object_size(from, n, true);
9427 +
9428 return __copy_user(to, (__force void __user *) from, n);
9429 }
9430
9431 static inline unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
9432 {
9433 - if (n && __access_ok((unsigned long) from, n))
9434 + if ((long)n < 0)
9435 + return n;
9436 +
9437 + if (n && __access_ok((unsigned long) from, n)) {
9438 + if (!__builtin_constant_p(n))
9439 + check_object_size(to, n, false);
9440 return __copy_user((__force void __user *) to, from, n);
9441 - else
9442 + } else
9443 return n;
9444 }
9445
9446 static inline unsigned long __copy_from_user(void *to, const void __user *from, unsigned long n)
9447 {
9448 + if ((long)n < 0)
9449 + return n;
9450 +
9451 return __copy_user((__force void __user *) to, from, n);
9452 }
9453
9454 diff --git a/arch/sparc/include/asm/uaccess_64.h b/arch/sparc/include/asm/uaccess_64.h
9455 index e562d3c..191f176 100644
9456 --- a/arch/sparc/include/asm/uaccess_64.h
9457 +++ b/arch/sparc/include/asm/uaccess_64.h
9458 @@ -10,6 +10,7 @@
9459 #include <linux/compiler.h>
9460 #include <linux/string.h>
9461 #include <linux/thread_info.h>
9462 +#include <linux/kernel.h>
9463 #include <asm/asi.h>
9464 #include <asm/spitfire.h>
9465 #include <asm-generic/uaccess-unaligned.h>
9466 @@ -214,8 +215,15 @@ extern unsigned long copy_from_user_fixup(void *to, const void __user *from,
9467 static inline unsigned long __must_check
9468 copy_from_user(void *to, const void __user *from, unsigned long size)
9469 {
9470 - unsigned long ret = ___copy_from_user(to, from, size);
9471 + unsigned long ret;
9472
9473 + if ((long)size < 0 || size > INT_MAX)
9474 + return size;
9475 +
9476 + if (!__builtin_constant_p(size))
9477 + check_object_size(to, size, false);
9478 +
9479 + ret = ___copy_from_user(to, from, size);
9480 if (unlikely(ret))
9481 ret = copy_from_user_fixup(to, from, size);
9482
9483 @@ -231,8 +239,15 @@ extern unsigned long copy_to_user_fixup(void __user *to, const void *from,
9484 static inline unsigned long __must_check
9485 copy_to_user(void __user *to, const void *from, unsigned long size)
9486 {
9487 - unsigned long ret = ___copy_to_user(to, from, size);
9488 + unsigned long ret;
9489
9490 + if ((long)size < 0 || size > INT_MAX)
9491 + return size;
9492 +
9493 + if (!__builtin_constant_p(size))
9494 + check_object_size(from, size, true);
9495 +
9496 + ret = ___copy_to_user(to, from, size);
9497 if (unlikely(ret))
9498 ret = copy_to_user_fixup(to, from, size);
9499 return ret;
9500 diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile
9501 index d15cc17..d0ae796 100644
9502 --- a/arch/sparc/kernel/Makefile
9503 +++ b/arch/sparc/kernel/Makefile
9504 @@ -4,7 +4,7 @@
9505 #
9506
9507 asflags-y := -ansi
9508 -ccflags-y := -Werror
9509 +#ccflags-y := -Werror
9510
9511 extra-y := head_$(BITS).o
9512
9513 diff --git a/arch/sparc/kernel/process_32.c b/arch/sparc/kernel/process_32.c
9514 index fdd819d..5af08c8 100644
9515 --- a/arch/sparc/kernel/process_32.c
9516 +++ b/arch/sparc/kernel/process_32.c
9517 @@ -116,14 +116,14 @@ void show_regs(struct pt_regs *r)
9518
9519 printk("PSR: %08lx PC: %08lx NPC: %08lx Y: %08lx %s\n",
9520 r->psr, r->pc, r->npc, r->y, print_tainted());
9521 - printk("PC: <%pS>\n", (void *) r->pc);
9522 + printk("PC: <%pA>\n", (void *) r->pc);
9523 printk("%%G: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
9524 r->u_regs[0], r->u_regs[1], r->u_regs[2], r->u_regs[3],
9525 r->u_regs[4], r->u_regs[5], r->u_regs[6], r->u_regs[7]);
9526 printk("%%O: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
9527 r->u_regs[8], r->u_regs[9], r->u_regs[10], r->u_regs[11],
9528 r->u_regs[12], r->u_regs[13], r->u_regs[14], r->u_regs[15]);
9529 - printk("RPC: <%pS>\n", (void *) r->u_regs[15]);
9530 + printk("RPC: <%pA>\n", (void *) r->u_regs[15]);
9531
9532 printk("%%L: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
9533 rw->locals[0], rw->locals[1], rw->locals[2], rw->locals[3],
9534 @@ -160,7 +160,7 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
9535 rw = (struct reg_window32 *) fp;
9536 pc = rw->ins[7];
9537 printk("[%08lx : ", pc);
9538 - printk("%pS ] ", (void *) pc);
9539 + printk("%pA ] ", (void *) pc);
9540 fp = rw->ins[6];
9541 } while (++count < 16);
9542 printk("\n");
9543 diff --git a/arch/sparc/kernel/process_64.c b/arch/sparc/kernel/process_64.c
9544 index baebab2..9cd13b1 100644
9545 --- a/arch/sparc/kernel/process_64.c
9546 +++ b/arch/sparc/kernel/process_64.c
9547 @@ -158,7 +158,7 @@ static void show_regwindow(struct pt_regs *regs)
9548 printk("i4: %016lx i5: %016lx i6: %016lx i7: %016lx\n",
9549 rwk->ins[4], rwk->ins[5], rwk->ins[6], rwk->ins[7]);
9550 if (regs->tstate & TSTATE_PRIV)
9551 - printk("I7: <%pS>\n", (void *) rwk->ins[7]);
9552 + printk("I7: <%pA>\n", (void *) rwk->ins[7]);
9553 }
9554
9555 void show_regs(struct pt_regs *regs)
9556 @@ -167,7 +167,7 @@ void show_regs(struct pt_regs *regs)
9557
9558 printk("TSTATE: %016lx TPC: %016lx TNPC: %016lx Y: %08x %s\n", regs->tstate,
9559 regs->tpc, regs->tnpc, regs->y, print_tainted());
9560 - printk("TPC: <%pS>\n", (void *) regs->tpc);
9561 + printk("TPC: <%pA>\n", (void *) regs->tpc);
9562 printk("g0: %016lx g1: %016lx g2: %016lx g3: %016lx\n",
9563 regs->u_regs[0], regs->u_regs[1], regs->u_regs[2],
9564 regs->u_regs[3]);
9565 @@ -180,7 +180,7 @@ void show_regs(struct pt_regs *regs)
9566 printk("o4: %016lx o5: %016lx sp: %016lx ret_pc: %016lx\n",
9567 regs->u_regs[12], regs->u_regs[13], regs->u_regs[14],
9568 regs->u_regs[15]);
9569 - printk("RPC: <%pS>\n", (void *) regs->u_regs[15]);
9570 + printk("RPC: <%pA>\n", (void *) regs->u_regs[15]);
9571 show_regwindow(regs);
9572 show_stack(current, (unsigned long *) regs->u_regs[UREG_FP]);
9573 }
9574 @@ -269,7 +269,7 @@ void arch_trigger_all_cpu_backtrace(void)
9575 ((tp && tp->task) ? tp->task->pid : -1));
9576
9577 if (gp->tstate & TSTATE_PRIV) {
9578 - printk(" TPC[%pS] O7[%pS] I7[%pS] RPC[%pS]\n",
9579 + printk(" TPC[%pA] O7[%pA] I7[%pA] RPC[%pA]\n",
9580 (void *) gp->tpc,
9581 (void *) gp->o7,
9582 (void *) gp->i7,
9583 diff --git a/arch/sparc/kernel/prom_common.c b/arch/sparc/kernel/prom_common.c
9584 index 79cc0d1..ec62734 100644
9585 --- a/arch/sparc/kernel/prom_common.c
9586 +++ b/arch/sparc/kernel/prom_common.c
9587 @@ -144,7 +144,7 @@ static int __init prom_common_nextprop(phandle node, char *prev, char *buf)
9588
9589 unsigned int prom_early_allocated __initdata;
9590
9591 -static struct of_pdt_ops prom_sparc_ops __initdata = {
9592 +static struct of_pdt_ops prom_sparc_ops __initconst = {
9593 .nextprop = prom_common_nextprop,
9594 .getproplen = prom_getproplen,
9595 .getproperty = prom_getproperty,
9596 diff --git a/arch/sparc/kernel/ptrace_64.c b/arch/sparc/kernel/ptrace_64.c
9597 index 773c1f2..a8bdd87 100644
9598 --- a/arch/sparc/kernel/ptrace_64.c
9599 +++ b/arch/sparc/kernel/ptrace_64.c
9600 @@ -1059,6 +1059,10 @@ long arch_ptrace(struct task_struct *child, long request,
9601 return ret;
9602 }
9603
9604 +#ifdef CONFIG_GRKERNSEC_SETXID
9605 +extern void gr_delayed_cred_worker(void);
9606 +#endif
9607 +
9608 asmlinkage int syscall_trace_enter(struct pt_regs *regs)
9609 {
9610 int ret = 0;
9611 @@ -1066,6 +1070,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
9612 /* do the secure computing check first */
9613 secure_computing_strict(regs->u_regs[UREG_G1]);
9614
9615 +#ifdef CONFIG_GRKERNSEC_SETXID
9616 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
9617 + gr_delayed_cred_worker();
9618 +#endif
9619 +
9620 if (test_thread_flag(TIF_SYSCALL_TRACE))
9621 ret = tracehook_report_syscall_entry(regs);
9622
9623 @@ -1086,6 +1095,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
9624
9625 asmlinkage void syscall_trace_leave(struct pt_regs *regs)
9626 {
9627 +#ifdef CONFIG_GRKERNSEC_SETXID
9628 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
9629 + gr_delayed_cred_worker();
9630 +#endif
9631 +
9632 audit_syscall_exit(regs);
9633
9634 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
9635 diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c
9636 index e142545..fd29654 100644
9637 --- a/arch/sparc/kernel/smp_64.c
9638 +++ b/arch/sparc/kernel/smp_64.c
9639 @@ -869,8 +869,8 @@ extern unsigned long xcall_flush_dcache_page_cheetah;
9640 extern unsigned long xcall_flush_dcache_page_spitfire;
9641
9642 #ifdef CONFIG_DEBUG_DCFLUSH
9643 -extern atomic_t dcpage_flushes;
9644 -extern atomic_t dcpage_flushes_xcall;
9645 +extern atomic_unchecked_t dcpage_flushes;
9646 +extern atomic_unchecked_t dcpage_flushes_xcall;
9647 #endif
9648
9649 static inline void __local_flush_dcache_page(struct page *page)
9650 @@ -894,7 +894,7 @@ void smp_flush_dcache_page_impl(struct page *page, int cpu)
9651 return;
9652
9653 #ifdef CONFIG_DEBUG_DCFLUSH
9654 - atomic_inc(&dcpage_flushes);
9655 + atomic_inc_unchecked(&dcpage_flushes);
9656 #endif
9657
9658 this_cpu = get_cpu();
9659 @@ -918,7 +918,7 @@ void smp_flush_dcache_page_impl(struct page *page, int cpu)
9660 xcall_deliver(data0, __pa(pg_addr),
9661 (u64) pg_addr, cpumask_of(cpu));
9662 #ifdef CONFIG_DEBUG_DCFLUSH
9663 - atomic_inc(&dcpage_flushes_xcall);
9664 + atomic_inc_unchecked(&dcpage_flushes_xcall);
9665 #endif
9666 }
9667 }
9668 @@ -937,7 +937,7 @@ void flush_dcache_page_all(struct mm_struct *mm, struct page *page)
9669 preempt_disable();
9670
9671 #ifdef CONFIG_DEBUG_DCFLUSH
9672 - atomic_inc(&dcpage_flushes);
9673 + atomic_inc_unchecked(&dcpage_flushes);
9674 #endif
9675 data0 = 0;
9676 pg_addr = page_address(page);
9677 @@ -954,7 +954,7 @@ void flush_dcache_page_all(struct mm_struct *mm, struct page *page)
9678 xcall_deliver(data0, __pa(pg_addr),
9679 (u64) pg_addr, cpu_online_mask);
9680 #ifdef CONFIG_DEBUG_DCFLUSH
9681 - atomic_inc(&dcpage_flushes_xcall);
9682 + atomic_inc_unchecked(&dcpage_flushes_xcall);
9683 #endif
9684 }
9685 __local_flush_dcache_page(page);
9686 diff --git a/arch/sparc/kernel/sys_sparc_32.c b/arch/sparc/kernel/sys_sparc_32.c
9687 index 3a8d184..49498a8 100644
9688 --- a/arch/sparc/kernel/sys_sparc_32.c
9689 +++ b/arch/sparc/kernel/sys_sparc_32.c
9690 @@ -52,7 +52,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
9691 if (len > TASK_SIZE - PAGE_SIZE)
9692 return -ENOMEM;
9693 if (!addr)
9694 - addr = TASK_UNMAPPED_BASE;
9695 + addr = current->mm->mmap_base;
9696
9697 info.flags = 0;
9698 info.length = len;
9699 diff --git a/arch/sparc/kernel/sys_sparc_64.c b/arch/sparc/kernel/sys_sparc_64.c
9700 index 51561b8..8256764 100644
9701 --- a/arch/sparc/kernel/sys_sparc_64.c
9702 +++ b/arch/sparc/kernel/sys_sparc_64.c
9703 @@ -90,13 +90,14 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
9704 struct vm_area_struct * vma;
9705 unsigned long task_size = TASK_SIZE;
9706 int do_color_align;
9707 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
9708 struct vm_unmapped_area_info info;
9709
9710 if (flags & MAP_FIXED) {
9711 /* We do not accept a shared mapping if it would violate
9712 * cache aliasing constraints.
9713 */
9714 - if ((flags & MAP_SHARED) &&
9715 + if ((filp || (flags & MAP_SHARED)) &&
9716 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
9717 return -EINVAL;
9718 return addr;
9719 @@ -111,6 +112,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
9720 if (filp || (flags & MAP_SHARED))
9721 do_color_align = 1;
9722
9723 +#ifdef CONFIG_PAX_RANDMMAP
9724 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
9725 +#endif
9726 +
9727 if (addr) {
9728 if (do_color_align)
9729 addr = COLOR_ALIGN(addr, pgoff);
9730 @@ -118,22 +123,28 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
9731 addr = PAGE_ALIGN(addr);
9732
9733 vma = find_vma(mm, addr);
9734 - if (task_size - len >= addr &&
9735 - (!vma || addr + len <= vma->vm_start))
9736 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
9737 return addr;
9738 }
9739
9740 info.flags = 0;
9741 info.length = len;
9742 - info.low_limit = TASK_UNMAPPED_BASE;
9743 + info.low_limit = mm->mmap_base;
9744 info.high_limit = min(task_size, VA_EXCLUDE_START);
9745 info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
9746 info.align_offset = pgoff << PAGE_SHIFT;
9747 + info.threadstack_offset = offset;
9748 addr = vm_unmapped_area(&info);
9749
9750 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
9751 VM_BUG_ON(addr != -ENOMEM);
9752 info.low_limit = VA_EXCLUDE_END;
9753 +
9754 +#ifdef CONFIG_PAX_RANDMMAP
9755 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9756 + info.low_limit += mm->delta_mmap;
9757 +#endif
9758 +
9759 info.high_limit = task_size;
9760 addr = vm_unmapped_area(&info);
9761 }
9762 @@ -151,6 +162,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9763 unsigned long task_size = STACK_TOP32;
9764 unsigned long addr = addr0;
9765 int do_color_align;
9766 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
9767 struct vm_unmapped_area_info info;
9768
9769 /* This should only ever run for 32-bit processes. */
9770 @@ -160,7 +172,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9771 /* We do not accept a shared mapping if it would violate
9772 * cache aliasing constraints.
9773 */
9774 - if ((flags & MAP_SHARED) &&
9775 + if ((filp || (flags & MAP_SHARED)) &&
9776 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
9777 return -EINVAL;
9778 return addr;
9779 @@ -173,6 +185,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9780 if (filp || (flags & MAP_SHARED))
9781 do_color_align = 1;
9782
9783 +#ifdef CONFIG_PAX_RANDMMAP
9784 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
9785 +#endif
9786 +
9787 /* requesting a specific address */
9788 if (addr) {
9789 if (do_color_align)
9790 @@ -181,8 +197,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9791 addr = PAGE_ALIGN(addr);
9792
9793 vma = find_vma(mm, addr);
9794 - if (task_size - len >= addr &&
9795 - (!vma || addr + len <= vma->vm_start))
9796 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
9797 return addr;
9798 }
9799
9800 @@ -192,6 +207,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9801 info.high_limit = mm->mmap_base;
9802 info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
9803 info.align_offset = pgoff << PAGE_SHIFT;
9804 + info.threadstack_offset = offset;
9805 addr = vm_unmapped_area(&info);
9806
9807 /*
9808 @@ -204,6 +220,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9809 VM_BUG_ON(addr != -ENOMEM);
9810 info.flags = 0;
9811 info.low_limit = TASK_UNMAPPED_BASE;
9812 +
9813 +#ifdef CONFIG_PAX_RANDMMAP
9814 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9815 + info.low_limit += mm->delta_mmap;
9816 +#endif
9817 +
9818 info.high_limit = STACK_TOP32;
9819 addr = vm_unmapped_area(&info);
9820 }
9821 @@ -260,10 +282,14 @@ unsigned long get_fb_unmapped_area(struct file *filp, unsigned long orig_addr, u
9822 EXPORT_SYMBOL(get_fb_unmapped_area);
9823
9824 /* Essentially the same as PowerPC. */
9825 -static unsigned long mmap_rnd(void)
9826 +static unsigned long mmap_rnd(struct mm_struct *mm)
9827 {
9828 unsigned long rnd = 0UL;
9829
9830 +#ifdef CONFIG_PAX_RANDMMAP
9831 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
9832 +#endif
9833 +
9834 if (current->flags & PF_RANDOMIZE) {
9835 unsigned long val = get_random_int();
9836 if (test_thread_flag(TIF_32BIT))
9837 @@ -276,7 +302,7 @@ static unsigned long mmap_rnd(void)
9838
9839 void arch_pick_mmap_layout(struct mm_struct *mm)
9840 {
9841 - unsigned long random_factor = mmap_rnd();
9842 + unsigned long random_factor = mmap_rnd(mm);
9843 unsigned long gap;
9844
9845 /*
9846 @@ -289,6 +315,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
9847 gap == RLIM_INFINITY ||
9848 sysctl_legacy_va_layout) {
9849 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
9850 +
9851 +#ifdef CONFIG_PAX_RANDMMAP
9852 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9853 + mm->mmap_base += mm->delta_mmap;
9854 +#endif
9855 +
9856 mm->get_unmapped_area = arch_get_unmapped_area;
9857 } else {
9858 /* We know it's 32-bit */
9859 @@ -300,6 +332,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
9860 gap = (task_size / 6 * 5);
9861
9862 mm->mmap_base = PAGE_ALIGN(task_size - gap - random_factor);
9863 +
9864 +#ifdef CONFIG_PAX_RANDMMAP
9865 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9866 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
9867 +#endif
9868 +
9869 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
9870 }
9871 }
9872 diff --git a/arch/sparc/kernel/syscalls.S b/arch/sparc/kernel/syscalls.S
9873 index d950197..192f9d8 100644
9874 --- a/arch/sparc/kernel/syscalls.S
9875 +++ b/arch/sparc/kernel/syscalls.S
9876 @@ -52,7 +52,7 @@ sys32_rt_sigreturn:
9877 #endif
9878 .align 32
9879 1: ldx [%g6 + TI_FLAGS], %l5
9880 - andcc %l5, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
9881 + andcc %l5, _TIF_WORK_SYSCALL, %g0
9882 be,pt %icc, rtrap
9883 nop
9884 call syscall_trace_leave
9885 @@ -184,7 +184,7 @@ linux_sparc_syscall32:
9886
9887 srl %i3, 0, %o3 ! IEU0
9888 srl %i2, 0, %o2 ! IEU0 Group
9889 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
9890 + andcc %l0, _TIF_WORK_SYSCALL, %g0
9891 bne,pn %icc, linux_syscall_trace32 ! CTI
9892 mov %i0, %l5 ! IEU1
9893 5: call %l7 ! CTI Group brk forced
9894 @@ -207,7 +207,7 @@ linux_sparc_syscall:
9895
9896 mov %i3, %o3 ! IEU1
9897 mov %i4, %o4 ! IEU0 Group
9898 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
9899 + andcc %l0, _TIF_WORK_SYSCALL, %g0
9900 bne,pn %icc, linux_syscall_trace ! CTI Group
9901 mov %i0, %l5 ! IEU0
9902 2: call %l7 ! CTI Group brk forced
9903 @@ -223,7 +223,7 @@ ret_sys_call:
9904
9905 cmp %o0, -ERESTART_RESTARTBLOCK
9906 bgeu,pn %xcc, 1f
9907 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
9908 + andcc %l0, _TIF_WORK_SYSCALL, %g0
9909 ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1 ! pc = npc
9910
9911 2:
9912 diff --git a/arch/sparc/kernel/traps_32.c b/arch/sparc/kernel/traps_32.c
9913 index 6629829..036032d 100644
9914 --- a/arch/sparc/kernel/traps_32.c
9915 +++ b/arch/sparc/kernel/traps_32.c
9916 @@ -44,6 +44,8 @@ static void instruction_dump(unsigned long *pc)
9917 #define __SAVE __asm__ __volatile__("save %sp, -0x40, %sp\n\t")
9918 #define __RESTORE __asm__ __volatile__("restore %g0, %g0, %g0\n\t")
9919
9920 +extern void gr_handle_kernel_exploit(void);
9921 +
9922 void die_if_kernel(char *str, struct pt_regs *regs)
9923 {
9924 static int die_counter;
9925 @@ -76,15 +78,17 @@ void die_if_kernel(char *str, struct pt_regs *regs)
9926 count++ < 30 &&
9927 (((unsigned long) rw) >= PAGE_OFFSET) &&
9928 !(((unsigned long) rw) & 0x7)) {
9929 - printk("Caller[%08lx]: %pS\n", rw->ins[7],
9930 + printk("Caller[%08lx]: %pA\n", rw->ins[7],
9931 (void *) rw->ins[7]);
9932 rw = (struct reg_window32 *)rw->ins[6];
9933 }
9934 }
9935 printk("Instruction DUMP:");
9936 instruction_dump ((unsigned long *) regs->pc);
9937 - if(regs->psr & PSR_PS)
9938 + if(regs->psr & PSR_PS) {
9939 + gr_handle_kernel_exploit();
9940 do_exit(SIGKILL);
9941 + }
9942 do_exit(SIGSEGV);
9943 }
9944
9945 diff --git a/arch/sparc/kernel/traps_64.c b/arch/sparc/kernel/traps_64.c
9946 index b3f833a..f485f80 100644
9947 --- a/arch/sparc/kernel/traps_64.c
9948 +++ b/arch/sparc/kernel/traps_64.c
9949 @@ -76,7 +76,7 @@ static void dump_tl1_traplog(struct tl1_traplog *p)
9950 i + 1,
9951 p->trapstack[i].tstate, p->trapstack[i].tpc,
9952 p->trapstack[i].tnpc, p->trapstack[i].tt);
9953 - printk("TRAPLOG: TPC<%pS>\n", (void *) p->trapstack[i].tpc);
9954 + printk("TRAPLOG: TPC<%pA>\n", (void *) p->trapstack[i].tpc);
9955 }
9956 }
9957
9958 @@ -96,6 +96,12 @@ void bad_trap(struct pt_regs *regs, long lvl)
9959
9960 lvl -= 0x100;
9961 if (regs->tstate & TSTATE_PRIV) {
9962 +
9963 +#ifdef CONFIG_PAX_REFCOUNT
9964 + if (lvl == 6)
9965 + pax_report_refcount_overflow(regs);
9966 +#endif
9967 +
9968 sprintf(buffer, "Kernel bad sw trap %lx", lvl);
9969 die_if_kernel(buffer, regs);
9970 }
9971 @@ -114,11 +120,16 @@ void bad_trap(struct pt_regs *regs, long lvl)
9972 void bad_trap_tl1(struct pt_regs *regs, long lvl)
9973 {
9974 char buffer[32];
9975 -
9976 +
9977 if (notify_die(DIE_TRAP_TL1, "bad trap tl1", regs,
9978 0, lvl, SIGTRAP) == NOTIFY_STOP)
9979 return;
9980
9981 +#ifdef CONFIG_PAX_REFCOUNT
9982 + if (lvl == 6)
9983 + pax_report_refcount_overflow(regs);
9984 +#endif
9985 +
9986 dump_tl1_traplog((struct tl1_traplog *)(regs + 1));
9987
9988 sprintf (buffer, "Bad trap %lx at tl>0", lvl);
9989 @@ -1142,7 +1153,7 @@ static void cheetah_log_errors(struct pt_regs *regs, struct cheetah_err_info *in
9990 regs->tpc, regs->tnpc, regs->u_regs[UREG_I7], regs->tstate);
9991 printk("%s" "ERROR(%d): ",
9992 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id());
9993 - printk("TPC<%pS>\n", (void *) regs->tpc);
9994 + printk("TPC<%pA>\n", (void *) regs->tpc);
9995 printk("%s" "ERROR(%d): M_SYND(%lx), E_SYND(%lx)%s%s\n",
9996 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id(),
9997 (afsr & CHAFSR_M_SYNDROME) >> CHAFSR_M_SYNDROME_SHIFT,
9998 @@ -1749,7 +1760,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
9999 smp_processor_id(),
10000 (type & 0x1) ? 'I' : 'D',
10001 regs->tpc);
10002 - printk(KERN_EMERG "TPC<%pS>\n", (void *) regs->tpc);
10003 + printk(KERN_EMERG "TPC<%pA>\n", (void *) regs->tpc);
10004 panic("Irrecoverable Cheetah+ parity error.");
10005 }
10006
10007 @@ -1757,7 +1768,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
10008 smp_processor_id(),
10009 (type & 0x1) ? 'I' : 'D',
10010 regs->tpc);
10011 - printk(KERN_WARNING "TPC<%pS>\n", (void *) regs->tpc);
10012 + printk(KERN_WARNING "TPC<%pA>\n", (void *) regs->tpc);
10013 }
10014
10015 struct sun4v_error_entry {
10016 @@ -1830,8 +1841,8 @@ struct sun4v_error_entry {
10017 /*0x38*/u64 reserved_5;
10018 };
10019
10020 -static atomic_t sun4v_resum_oflow_cnt = ATOMIC_INIT(0);
10021 -static atomic_t sun4v_nonresum_oflow_cnt = ATOMIC_INIT(0);
10022 +static atomic_unchecked_t sun4v_resum_oflow_cnt = ATOMIC_INIT(0);
10023 +static atomic_unchecked_t sun4v_nonresum_oflow_cnt = ATOMIC_INIT(0);
10024
10025 static const char *sun4v_err_type_to_str(u8 type)
10026 {
10027 @@ -1923,7 +1934,7 @@ static void sun4v_report_real_raddr(const char *pfx, struct pt_regs *regs)
10028 }
10029
10030 static void sun4v_log_error(struct pt_regs *regs, struct sun4v_error_entry *ent,
10031 - int cpu, const char *pfx, atomic_t *ocnt)
10032 + int cpu, const char *pfx, atomic_unchecked_t *ocnt)
10033 {
10034 u64 *raw_ptr = (u64 *) ent;
10035 u32 attrs;
10036 @@ -1981,8 +1992,8 @@ static void sun4v_log_error(struct pt_regs *regs, struct sun4v_error_entry *ent,
10037
10038 show_regs(regs);
10039
10040 - if ((cnt = atomic_read(ocnt)) != 0) {
10041 - atomic_set(ocnt, 0);
10042 + if ((cnt = atomic_read_unchecked(ocnt)) != 0) {
10043 + atomic_set_unchecked(ocnt, 0);
10044 wmb();
10045 printk("%s: Queue overflowed %d times.\n",
10046 pfx, cnt);
10047 @@ -2036,7 +2047,7 @@ void sun4v_resum_error(struct pt_regs *regs, unsigned long offset)
10048 */
10049 void sun4v_resum_overflow(struct pt_regs *regs)
10050 {
10051 - atomic_inc(&sun4v_resum_oflow_cnt);
10052 + atomic_inc_unchecked(&sun4v_resum_oflow_cnt);
10053 }
10054
10055 /* We run with %pil set to PIL_NORMAL_MAX and PSTATE_IE enabled in %pstate.
10056 @@ -2089,7 +2100,7 @@ void sun4v_nonresum_overflow(struct pt_regs *regs)
10057 /* XXX Actually even this can make not that much sense. Perhaps
10058 * XXX we should just pull the plug and panic directly from here?
10059 */
10060 - atomic_inc(&sun4v_nonresum_oflow_cnt);
10061 + atomic_inc_unchecked(&sun4v_nonresum_oflow_cnt);
10062 }
10063
10064 unsigned long sun4v_err_itlb_vaddr;
10065 @@ -2104,9 +2115,9 @@ void sun4v_itlb_error_report(struct pt_regs *regs, int tl)
10066
10067 printk(KERN_EMERG "SUN4V-ITLB: Error at TPC[%lx], tl %d\n",
10068 regs->tpc, tl);
10069 - printk(KERN_EMERG "SUN4V-ITLB: TPC<%pS>\n", (void *) regs->tpc);
10070 + printk(KERN_EMERG "SUN4V-ITLB: TPC<%pA>\n", (void *) regs->tpc);
10071 printk(KERN_EMERG "SUN4V-ITLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
10072 - printk(KERN_EMERG "SUN4V-ITLB: O7<%pS>\n",
10073 + printk(KERN_EMERG "SUN4V-ITLB: O7<%pA>\n",
10074 (void *) regs->u_regs[UREG_I7]);
10075 printk(KERN_EMERG "SUN4V-ITLB: vaddr[%lx] ctx[%lx] "
10076 "pte[%lx] error[%lx]\n",
10077 @@ -2128,9 +2139,9 @@ void sun4v_dtlb_error_report(struct pt_regs *regs, int tl)
10078
10079 printk(KERN_EMERG "SUN4V-DTLB: Error at TPC[%lx], tl %d\n",
10080 regs->tpc, tl);
10081 - printk(KERN_EMERG "SUN4V-DTLB: TPC<%pS>\n", (void *) regs->tpc);
10082 + printk(KERN_EMERG "SUN4V-DTLB: TPC<%pA>\n", (void *) regs->tpc);
10083 printk(KERN_EMERG "SUN4V-DTLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
10084 - printk(KERN_EMERG "SUN4V-DTLB: O7<%pS>\n",
10085 + printk(KERN_EMERG "SUN4V-DTLB: O7<%pA>\n",
10086 (void *) regs->u_regs[UREG_I7]);
10087 printk(KERN_EMERG "SUN4V-DTLB: vaddr[%lx] ctx[%lx] "
10088 "pte[%lx] error[%lx]\n",
10089 @@ -2336,13 +2347,13 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
10090 fp = (unsigned long)sf->fp + STACK_BIAS;
10091 }
10092
10093 - printk(" [%016lx] %pS\n", pc, (void *) pc);
10094 + printk(" [%016lx] %pA\n", pc, (void *) pc);
10095 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
10096 if ((pc + 8UL) == (unsigned long) &return_to_handler) {
10097 int index = tsk->curr_ret_stack;
10098 if (tsk->ret_stack && index >= graph) {
10099 pc = tsk->ret_stack[index - graph].ret;
10100 - printk(" [%016lx] %pS\n", pc, (void *) pc);
10101 + printk(" [%016lx] %pA\n", pc, (void *) pc);
10102 graph++;
10103 }
10104 }
10105 @@ -2360,6 +2371,8 @@ static inline struct reg_window *kernel_stack_up(struct reg_window *rw)
10106 return (struct reg_window *) (fp + STACK_BIAS);
10107 }
10108
10109 +extern void gr_handle_kernel_exploit(void);
10110 +
10111 void die_if_kernel(char *str, struct pt_regs *regs)
10112 {
10113 static int die_counter;
10114 @@ -2388,7 +2401,7 @@ void die_if_kernel(char *str, struct pt_regs *regs)
10115 while (rw &&
10116 count++ < 30 &&
10117 kstack_valid(tp, (unsigned long) rw)) {
10118 - printk("Caller[%016lx]: %pS\n", rw->ins[7],
10119 + printk("Caller[%016lx]: %pA\n", rw->ins[7],
10120 (void *) rw->ins[7]);
10121
10122 rw = kernel_stack_up(rw);
10123 @@ -2401,8 +2414,10 @@ void die_if_kernel(char *str, struct pt_regs *regs)
10124 }
10125 user_instruction_dump ((unsigned int __user *) regs->tpc);
10126 }
10127 - if (regs->tstate & TSTATE_PRIV)
10128 + if (regs->tstate & TSTATE_PRIV) {
10129 + gr_handle_kernel_exploit();
10130 do_exit(SIGKILL);
10131 + }
10132 do_exit(SIGSEGV);
10133 }
10134 EXPORT_SYMBOL(die_if_kernel);
10135 diff --git a/arch/sparc/kernel/unaligned_64.c b/arch/sparc/kernel/unaligned_64.c
10136 index 8201c25e..072a2a7 100644
10137 --- a/arch/sparc/kernel/unaligned_64.c
10138 +++ b/arch/sparc/kernel/unaligned_64.c
10139 @@ -286,7 +286,7 @@ static void log_unaligned(struct pt_regs *regs)
10140 static DEFINE_RATELIMIT_STATE(ratelimit, 5 * HZ, 5);
10141
10142 if (__ratelimit(&ratelimit)) {
10143 - printk("Kernel unaligned access at TPC[%lx] %pS\n",
10144 + printk("Kernel unaligned access at TPC[%lx] %pA\n",
10145 regs->tpc, (void *) regs->tpc);
10146 }
10147 }
10148 diff --git a/arch/sparc/lib/Makefile b/arch/sparc/lib/Makefile
10149 index dbe119b..089c7c1 100644
10150 --- a/arch/sparc/lib/Makefile
10151 +++ b/arch/sparc/lib/Makefile
10152 @@ -2,7 +2,7 @@
10153 #
10154
10155 asflags-y := -ansi -DST_DIV0=0x02
10156 -ccflags-y := -Werror
10157 +#ccflags-y := -Werror
10158
10159 lib-$(CONFIG_SPARC32) += ashrdi3.o
10160 lib-$(CONFIG_SPARC32) += memcpy.o memset.o
10161 diff --git a/arch/sparc/lib/atomic_64.S b/arch/sparc/lib/atomic_64.S
10162 index 85c233d..68500e0 100644
10163 --- a/arch/sparc/lib/atomic_64.S
10164 +++ b/arch/sparc/lib/atomic_64.S
10165 @@ -17,7 +17,12 @@
10166 ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
10167 BACKOFF_SETUP(%o2)
10168 1: lduw [%o1], %g1
10169 - add %g1, %o0, %g7
10170 + addcc %g1, %o0, %g7
10171 +
10172 +#ifdef CONFIG_PAX_REFCOUNT
10173 + tvs %icc, 6
10174 +#endif
10175 +
10176 cas [%o1], %g1, %g7
10177 cmp %g1, %g7
10178 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
10179 @@ -27,10 +32,28 @@ ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
10180 2: BACKOFF_SPIN(%o2, %o3, 1b)
10181 ENDPROC(atomic_add)
10182
10183 +ENTRY(atomic_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
10184 + BACKOFF_SETUP(%o2)
10185 +1: lduw [%o1], %g1
10186 + add %g1, %o0, %g7
10187 + cas [%o1], %g1, %g7
10188 + cmp %g1, %g7
10189 + bne,pn %icc, 2f
10190 + nop
10191 + retl
10192 + nop
10193 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10194 +ENDPROC(atomic_add_unchecked)
10195 +
10196 ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
10197 BACKOFF_SETUP(%o2)
10198 1: lduw [%o1], %g1
10199 - sub %g1, %o0, %g7
10200 + subcc %g1, %o0, %g7
10201 +
10202 +#ifdef CONFIG_PAX_REFCOUNT
10203 + tvs %icc, 6
10204 +#endif
10205 +
10206 cas [%o1], %g1, %g7
10207 cmp %g1, %g7
10208 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
10209 @@ -40,10 +63,28 @@ ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
10210 2: BACKOFF_SPIN(%o2, %o3, 1b)
10211 ENDPROC(atomic_sub)
10212
10213 +ENTRY(atomic_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
10214 + BACKOFF_SETUP(%o2)
10215 +1: lduw [%o1], %g1
10216 + sub %g1, %o0, %g7
10217 + cas [%o1], %g1, %g7
10218 + cmp %g1, %g7
10219 + bne,pn %icc, 2f
10220 + nop
10221 + retl
10222 + nop
10223 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10224 +ENDPROC(atomic_sub_unchecked)
10225 +
10226 ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
10227 BACKOFF_SETUP(%o2)
10228 1: lduw [%o1], %g1
10229 - add %g1, %o0, %g7
10230 + addcc %g1, %o0, %g7
10231 +
10232 +#ifdef CONFIG_PAX_REFCOUNT
10233 + tvs %icc, 6
10234 +#endif
10235 +
10236 cas [%o1], %g1, %g7
10237 cmp %g1, %g7
10238 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
10239 @@ -53,10 +94,29 @@ ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
10240 2: BACKOFF_SPIN(%o2, %o3, 1b)
10241 ENDPROC(atomic_add_ret)
10242
10243 +ENTRY(atomic_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
10244 + BACKOFF_SETUP(%o2)
10245 +1: lduw [%o1], %g1
10246 + addcc %g1, %o0, %g7
10247 + cas [%o1], %g1, %g7
10248 + cmp %g1, %g7
10249 + bne,pn %icc, 2f
10250 + add %g7, %o0, %g7
10251 + sra %g7, 0, %o0
10252 + retl
10253 + nop
10254 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10255 +ENDPROC(atomic_add_ret_unchecked)
10256 +
10257 ENTRY(atomic_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
10258 BACKOFF_SETUP(%o2)
10259 1: lduw [%o1], %g1
10260 - sub %g1, %o0, %g7
10261 + subcc %g1, %o0, %g7
10262 +
10263 +#ifdef CONFIG_PAX_REFCOUNT
10264 + tvs %icc, 6
10265 +#endif
10266 +
10267 cas [%o1], %g1, %g7
10268 cmp %g1, %g7
10269 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
10270 @@ -69,7 +129,12 @@ ENDPROC(atomic_sub_ret)
10271 ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
10272 BACKOFF_SETUP(%o2)
10273 1: ldx [%o1], %g1
10274 - add %g1, %o0, %g7
10275 + addcc %g1, %o0, %g7
10276 +
10277 +#ifdef CONFIG_PAX_REFCOUNT
10278 + tvs %xcc, 6
10279 +#endif
10280 +
10281 casx [%o1], %g1, %g7
10282 cmp %g1, %g7
10283 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
10284 @@ -79,10 +144,28 @@ ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
10285 2: BACKOFF_SPIN(%o2, %o3, 1b)
10286 ENDPROC(atomic64_add)
10287
10288 +ENTRY(atomic64_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
10289 + BACKOFF_SETUP(%o2)
10290 +1: ldx [%o1], %g1
10291 + addcc %g1, %o0, %g7
10292 + casx [%o1], %g1, %g7
10293 + cmp %g1, %g7
10294 + bne,pn %xcc, 2f
10295 + nop
10296 + retl
10297 + nop
10298 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10299 +ENDPROC(atomic64_add_unchecked)
10300 +
10301 ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
10302 BACKOFF_SETUP(%o2)
10303 1: ldx [%o1], %g1
10304 - sub %g1, %o0, %g7
10305 + subcc %g1, %o0, %g7
10306 +
10307 +#ifdef CONFIG_PAX_REFCOUNT
10308 + tvs %xcc, 6
10309 +#endif
10310 +
10311 casx [%o1], %g1, %g7
10312 cmp %g1, %g7
10313 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
10314 @@ -92,10 +175,28 @@ ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
10315 2: BACKOFF_SPIN(%o2, %o3, 1b)
10316 ENDPROC(atomic64_sub)
10317
10318 +ENTRY(atomic64_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
10319 + BACKOFF_SETUP(%o2)
10320 +1: ldx [%o1], %g1
10321 + subcc %g1, %o0, %g7
10322 + casx [%o1], %g1, %g7
10323 + cmp %g1, %g7
10324 + bne,pn %xcc, 2f
10325 + nop
10326 + retl
10327 + nop
10328 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10329 +ENDPROC(atomic64_sub_unchecked)
10330 +
10331 ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
10332 BACKOFF_SETUP(%o2)
10333 1: ldx [%o1], %g1
10334 - add %g1, %o0, %g7
10335 + addcc %g1, %o0, %g7
10336 +
10337 +#ifdef CONFIG_PAX_REFCOUNT
10338 + tvs %xcc, 6
10339 +#endif
10340 +
10341 casx [%o1], %g1, %g7
10342 cmp %g1, %g7
10343 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
10344 @@ -105,10 +206,29 @@ ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
10345 2: BACKOFF_SPIN(%o2, %o3, 1b)
10346 ENDPROC(atomic64_add_ret)
10347
10348 +ENTRY(atomic64_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
10349 + BACKOFF_SETUP(%o2)
10350 +1: ldx [%o1], %g1
10351 + addcc %g1, %o0, %g7
10352 + casx [%o1], %g1, %g7
10353 + cmp %g1, %g7
10354 + bne,pn %xcc, 2f
10355 + add %g7, %o0, %g7
10356 + mov %g7, %o0
10357 + retl
10358 + nop
10359 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10360 +ENDPROC(atomic64_add_ret_unchecked)
10361 +
10362 ENTRY(atomic64_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
10363 BACKOFF_SETUP(%o2)
10364 1: ldx [%o1], %g1
10365 - sub %g1, %o0, %g7
10366 + subcc %g1, %o0, %g7
10367 +
10368 +#ifdef CONFIG_PAX_REFCOUNT
10369 + tvs %xcc, 6
10370 +#endif
10371 +
10372 casx [%o1], %g1, %g7
10373 cmp %g1, %g7
10374 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
10375 diff --git a/arch/sparc/lib/ksyms.c b/arch/sparc/lib/ksyms.c
10376 index 323335b..ed85ea2 100644
10377 --- a/arch/sparc/lib/ksyms.c
10378 +++ b/arch/sparc/lib/ksyms.c
10379 @@ -100,12 +100,18 @@ EXPORT_SYMBOL(__clear_user);
10380
10381 /* Atomic counter implementation. */
10382 EXPORT_SYMBOL(atomic_add);
10383 +EXPORT_SYMBOL(atomic_add_unchecked);
10384 EXPORT_SYMBOL(atomic_add_ret);
10385 +EXPORT_SYMBOL(atomic_add_ret_unchecked);
10386 EXPORT_SYMBOL(atomic_sub);
10387 +EXPORT_SYMBOL(atomic_sub_unchecked);
10388 EXPORT_SYMBOL(atomic_sub_ret);
10389 EXPORT_SYMBOL(atomic64_add);
10390 +EXPORT_SYMBOL(atomic64_add_unchecked);
10391 EXPORT_SYMBOL(atomic64_add_ret);
10392 +EXPORT_SYMBOL(atomic64_add_ret_unchecked);
10393 EXPORT_SYMBOL(atomic64_sub);
10394 +EXPORT_SYMBOL(atomic64_sub_unchecked);
10395 EXPORT_SYMBOL(atomic64_sub_ret);
10396 EXPORT_SYMBOL(atomic64_dec_if_positive);
10397
10398 diff --git a/arch/sparc/mm/Makefile b/arch/sparc/mm/Makefile
10399 index 30c3ecc..736f015 100644
10400 --- a/arch/sparc/mm/Makefile
10401 +++ b/arch/sparc/mm/Makefile
10402 @@ -2,7 +2,7 @@
10403 #
10404
10405 asflags-y := -ansi
10406 -ccflags-y := -Werror
10407 +#ccflags-y := -Werror
10408
10409 obj-$(CONFIG_SPARC64) += ultra.o tlb.o tsb.o gup.o
10410 obj-y += fault_$(BITS).o
10411 diff --git a/arch/sparc/mm/fault_32.c b/arch/sparc/mm/fault_32.c
10412 index 59dbd46..1dd7f5e 100644
10413 --- a/arch/sparc/mm/fault_32.c
10414 +++ b/arch/sparc/mm/fault_32.c
10415 @@ -21,6 +21,9 @@
10416 #include <linux/perf_event.h>
10417 #include <linux/interrupt.h>
10418 #include <linux/kdebug.h>
10419 +#include <linux/slab.h>
10420 +#include <linux/pagemap.h>
10421 +#include <linux/compiler.h>
10422
10423 #include <asm/page.h>
10424 #include <asm/pgtable.h>
10425 @@ -159,6 +162,277 @@ static unsigned long compute_si_addr(struct pt_regs *regs, int text_fault)
10426 return safe_compute_effective_address(regs, insn);
10427 }
10428
10429 +#ifdef CONFIG_PAX_PAGEEXEC
10430 +#ifdef CONFIG_PAX_DLRESOLVE
10431 +static void pax_emuplt_close(struct vm_area_struct *vma)
10432 +{
10433 + vma->vm_mm->call_dl_resolve = 0UL;
10434 +}
10435 +
10436 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
10437 +{
10438 + unsigned int *kaddr;
10439 +
10440 + vmf->page = alloc_page(GFP_HIGHUSER);
10441 + if (!vmf->page)
10442 + return VM_FAULT_OOM;
10443 +
10444 + kaddr = kmap(vmf->page);
10445 + memset(kaddr, 0, PAGE_SIZE);
10446 + kaddr[0] = 0x9DE3BFA8U; /* save */
10447 + flush_dcache_page(vmf->page);
10448 + kunmap(vmf->page);
10449 + return VM_FAULT_MAJOR;
10450 +}
10451 +
10452 +static const struct vm_operations_struct pax_vm_ops = {
10453 + .close = pax_emuplt_close,
10454 + .fault = pax_emuplt_fault
10455 +};
10456 +
10457 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
10458 +{
10459 + int ret;
10460 +
10461 + INIT_LIST_HEAD(&vma->anon_vma_chain);
10462 + vma->vm_mm = current->mm;
10463 + vma->vm_start = addr;
10464 + vma->vm_end = addr + PAGE_SIZE;
10465 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
10466 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
10467 + vma->vm_ops = &pax_vm_ops;
10468 +
10469 + ret = insert_vm_struct(current->mm, vma);
10470 + if (ret)
10471 + return ret;
10472 +
10473 + ++current->mm->total_vm;
10474 + return 0;
10475 +}
10476 +#endif
10477 +
10478 +/*
10479 + * PaX: decide what to do with offenders (regs->pc = fault address)
10480 + *
10481 + * returns 1 when task should be killed
10482 + * 2 when patched PLT trampoline was detected
10483 + * 3 when unpatched PLT trampoline was detected
10484 + */
10485 +static int pax_handle_fetch_fault(struct pt_regs *regs)
10486 +{
10487 +
10488 +#ifdef CONFIG_PAX_EMUPLT
10489 + int err;
10490 +
10491 + do { /* PaX: patched PLT emulation #1 */
10492 + unsigned int sethi1, sethi2, jmpl;
10493 +
10494 + err = get_user(sethi1, (unsigned int *)regs->pc);
10495 + err |= get_user(sethi2, (unsigned int *)(regs->pc+4));
10496 + err |= get_user(jmpl, (unsigned int *)(regs->pc+8));
10497 +
10498 + if (err)
10499 + break;
10500 +
10501 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
10502 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
10503 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
10504 + {
10505 + unsigned int addr;
10506 +
10507 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
10508 + addr = regs->u_regs[UREG_G1];
10509 + addr += (((jmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
10510 + regs->pc = addr;
10511 + regs->npc = addr+4;
10512 + return 2;
10513 + }
10514 + } while (0);
10515 +
10516 + do { /* PaX: patched PLT emulation #2 */
10517 + unsigned int ba;
10518 +
10519 + err = get_user(ba, (unsigned int *)regs->pc);
10520 +
10521 + if (err)
10522 + break;
10523 +
10524 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
10525 + unsigned int addr;
10526 +
10527 + if ((ba & 0xFFC00000U) == 0x30800000U)
10528 + addr = regs->pc + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
10529 + else
10530 + addr = regs->pc + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
10531 + regs->pc = addr;
10532 + regs->npc = addr+4;
10533 + return 2;
10534 + }
10535 + } while (0);
10536 +
10537 + do { /* PaX: patched PLT emulation #3 */
10538 + unsigned int sethi, bajmpl, nop;
10539 +
10540 + err = get_user(sethi, (unsigned int *)regs->pc);
10541 + err |= get_user(bajmpl, (unsigned int *)(regs->pc+4));
10542 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
10543 +
10544 + if (err)
10545 + break;
10546 +
10547 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10548 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
10549 + nop == 0x01000000U)
10550 + {
10551 + unsigned int addr;
10552 +
10553 + addr = (sethi & 0x003FFFFFU) << 10;
10554 + regs->u_regs[UREG_G1] = addr;
10555 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
10556 + addr += (((bajmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
10557 + else
10558 + addr = regs->pc + ((((bajmpl | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
10559 + regs->pc = addr;
10560 + regs->npc = addr+4;
10561 + return 2;
10562 + }
10563 + } while (0);
10564 +
10565 + do { /* PaX: unpatched PLT emulation step 1 */
10566 + unsigned int sethi, ba, nop;
10567 +
10568 + err = get_user(sethi, (unsigned int *)regs->pc);
10569 + err |= get_user(ba, (unsigned int *)(regs->pc+4));
10570 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
10571 +
10572 + if (err)
10573 + break;
10574 +
10575 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10576 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
10577 + nop == 0x01000000U)
10578 + {
10579 + unsigned int addr, save, call;
10580 +
10581 + if ((ba & 0xFFC00000U) == 0x30800000U)
10582 + addr = regs->pc + 4 + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
10583 + else
10584 + addr = regs->pc + 4 + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
10585 +
10586 + err = get_user(save, (unsigned int *)addr);
10587 + err |= get_user(call, (unsigned int *)(addr+4));
10588 + err |= get_user(nop, (unsigned int *)(addr+8));
10589 + if (err)
10590 + break;
10591 +
10592 +#ifdef CONFIG_PAX_DLRESOLVE
10593 + if (save == 0x9DE3BFA8U &&
10594 + (call & 0xC0000000U) == 0x40000000U &&
10595 + nop == 0x01000000U)
10596 + {
10597 + struct vm_area_struct *vma;
10598 + unsigned long call_dl_resolve;
10599 +
10600 + down_read(&current->mm->mmap_sem);
10601 + call_dl_resolve = current->mm->call_dl_resolve;
10602 + up_read(&current->mm->mmap_sem);
10603 + if (likely(call_dl_resolve))
10604 + goto emulate;
10605 +
10606 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
10607 +
10608 + down_write(&current->mm->mmap_sem);
10609 + if (current->mm->call_dl_resolve) {
10610 + call_dl_resolve = current->mm->call_dl_resolve;
10611 + up_write(&current->mm->mmap_sem);
10612 + if (vma)
10613 + kmem_cache_free(vm_area_cachep, vma);
10614 + goto emulate;
10615 + }
10616 +
10617 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
10618 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
10619 + up_write(&current->mm->mmap_sem);
10620 + if (vma)
10621 + kmem_cache_free(vm_area_cachep, vma);
10622 + return 1;
10623 + }
10624 +
10625 + if (pax_insert_vma(vma, call_dl_resolve)) {
10626 + up_write(&current->mm->mmap_sem);
10627 + kmem_cache_free(vm_area_cachep, vma);
10628 + return 1;
10629 + }
10630 +
10631 + current->mm->call_dl_resolve = call_dl_resolve;
10632 + up_write(&current->mm->mmap_sem);
10633 +
10634 +emulate:
10635 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
10636 + regs->pc = call_dl_resolve;
10637 + regs->npc = addr+4;
10638 + return 3;
10639 + }
10640 +#endif
10641 +
10642 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
10643 + if ((save & 0xFFC00000U) == 0x05000000U &&
10644 + (call & 0xFFFFE000U) == 0x85C0A000U &&
10645 + nop == 0x01000000U)
10646 + {
10647 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
10648 + regs->u_regs[UREG_G2] = addr + 4;
10649 + addr = (save & 0x003FFFFFU) << 10;
10650 + addr += (((call | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
10651 + regs->pc = addr;
10652 + regs->npc = addr+4;
10653 + return 3;
10654 + }
10655 + }
10656 + } while (0);
10657 +
10658 + do { /* PaX: unpatched PLT emulation step 2 */
10659 + unsigned int save, call, nop;
10660 +
10661 + err = get_user(save, (unsigned int *)(regs->pc-4));
10662 + err |= get_user(call, (unsigned int *)regs->pc);
10663 + err |= get_user(nop, (unsigned int *)(regs->pc+4));
10664 + if (err)
10665 + break;
10666 +
10667 + if (save == 0x9DE3BFA8U &&
10668 + (call & 0xC0000000U) == 0x40000000U &&
10669 + nop == 0x01000000U)
10670 + {
10671 + unsigned int dl_resolve = regs->pc + ((((call | 0xC0000000U) ^ 0x20000000U) + 0x20000000U) << 2);
10672 +
10673 + regs->u_regs[UREG_RETPC] = regs->pc;
10674 + regs->pc = dl_resolve;
10675 + regs->npc = dl_resolve+4;
10676 + return 3;
10677 + }
10678 + } while (0);
10679 +#endif
10680 +
10681 + return 1;
10682 +}
10683 +
10684 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
10685 +{
10686 + unsigned long i;
10687 +
10688 + printk(KERN_ERR "PAX: bytes at PC: ");
10689 + for (i = 0; i < 8; i++) {
10690 + unsigned int c;
10691 + if (get_user(c, (unsigned int *)pc+i))
10692 + printk(KERN_CONT "???????? ");
10693 + else
10694 + printk(KERN_CONT "%08x ", c);
10695 + }
10696 + printk("\n");
10697 +}
10698 +#endif
10699 +
10700 static noinline void do_fault_siginfo(int code, int sig, struct pt_regs *regs,
10701 int text_fault)
10702 {
10703 @@ -229,6 +503,24 @@ good_area:
10704 if (!(vma->vm_flags & VM_WRITE))
10705 goto bad_area;
10706 } else {
10707 +
10708 +#ifdef CONFIG_PAX_PAGEEXEC
10709 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && text_fault && !(vma->vm_flags & VM_EXEC)) {
10710 + up_read(&mm->mmap_sem);
10711 + switch (pax_handle_fetch_fault(regs)) {
10712 +
10713 +#ifdef CONFIG_PAX_EMUPLT
10714 + case 2:
10715 + case 3:
10716 + return;
10717 +#endif
10718 +
10719 + }
10720 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->u_regs[UREG_FP]);
10721 + do_group_exit(SIGKILL);
10722 + }
10723 +#endif
10724 +
10725 /* Allow reads even for write-only mappings */
10726 if (!(vma->vm_flags & (VM_READ | VM_EXEC)))
10727 goto bad_area;
10728 diff --git a/arch/sparc/mm/fault_64.c b/arch/sparc/mm/fault_64.c
10729 index 2ebec26..b212598 100644
10730 --- a/arch/sparc/mm/fault_64.c
10731 +++ b/arch/sparc/mm/fault_64.c
10732 @@ -21,6 +21,9 @@
10733 #include <linux/kprobes.h>
10734 #include <linux/kdebug.h>
10735 #include <linux/percpu.h>
10736 +#include <linux/slab.h>
10737 +#include <linux/pagemap.h>
10738 +#include <linux/compiler.h>
10739
10740 #include <asm/page.h>
10741 #include <asm/pgtable.h>
10742 @@ -74,7 +77,7 @@ static void __kprobes bad_kernel_pc(struct pt_regs *regs, unsigned long vaddr)
10743 printk(KERN_CRIT "OOPS: Bogus kernel PC [%016lx] in fault handler\n",
10744 regs->tpc);
10745 printk(KERN_CRIT "OOPS: RPC [%016lx]\n", regs->u_regs[15]);
10746 - printk("OOPS: RPC <%pS>\n", (void *) regs->u_regs[15]);
10747 + printk("OOPS: RPC <%pA>\n", (void *) regs->u_regs[15]);
10748 printk(KERN_CRIT "OOPS: Fault was to vaddr[%lx]\n", vaddr);
10749 dump_stack();
10750 unhandled_fault(regs->tpc, current, regs);
10751 @@ -270,6 +273,466 @@ static void noinline __kprobes bogus_32bit_fault_address(struct pt_regs *regs,
10752 show_regs(regs);
10753 }
10754
10755 +#ifdef CONFIG_PAX_PAGEEXEC
10756 +#ifdef CONFIG_PAX_DLRESOLVE
10757 +static void pax_emuplt_close(struct vm_area_struct *vma)
10758 +{
10759 + vma->vm_mm->call_dl_resolve = 0UL;
10760 +}
10761 +
10762 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
10763 +{
10764 + unsigned int *kaddr;
10765 +
10766 + vmf->page = alloc_page(GFP_HIGHUSER);
10767 + if (!vmf->page)
10768 + return VM_FAULT_OOM;
10769 +
10770 + kaddr = kmap(vmf->page);
10771 + memset(kaddr, 0, PAGE_SIZE);
10772 + kaddr[0] = 0x9DE3BFA8U; /* save */
10773 + flush_dcache_page(vmf->page);
10774 + kunmap(vmf->page);
10775 + return VM_FAULT_MAJOR;
10776 +}
10777 +
10778 +static const struct vm_operations_struct pax_vm_ops = {
10779 + .close = pax_emuplt_close,
10780 + .fault = pax_emuplt_fault
10781 +};
10782 +
10783 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
10784 +{
10785 + int ret;
10786 +
10787 + INIT_LIST_HEAD(&vma->anon_vma_chain);
10788 + vma->vm_mm = current->mm;
10789 + vma->vm_start = addr;
10790 + vma->vm_end = addr + PAGE_SIZE;
10791 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
10792 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
10793 + vma->vm_ops = &pax_vm_ops;
10794 +
10795 + ret = insert_vm_struct(current->mm, vma);
10796 + if (ret)
10797 + return ret;
10798 +
10799 + ++current->mm->total_vm;
10800 + return 0;
10801 +}
10802 +#endif
10803 +
10804 +/*
10805 + * PaX: decide what to do with offenders (regs->tpc = fault address)
10806 + *
10807 + * returns 1 when task should be killed
10808 + * 2 when patched PLT trampoline was detected
10809 + * 3 when unpatched PLT trampoline was detected
10810 + */
10811 +static int pax_handle_fetch_fault(struct pt_regs *regs)
10812 +{
10813 +
10814 +#ifdef CONFIG_PAX_EMUPLT
10815 + int err;
10816 +
10817 + do { /* PaX: patched PLT emulation #1 */
10818 + unsigned int sethi1, sethi2, jmpl;
10819 +
10820 + err = get_user(sethi1, (unsigned int *)regs->tpc);
10821 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+4));
10822 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+8));
10823 +
10824 + if (err)
10825 + break;
10826 +
10827 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
10828 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
10829 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
10830 + {
10831 + unsigned long addr;
10832 +
10833 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
10834 + addr = regs->u_regs[UREG_G1];
10835 + addr += (((jmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
10836 +
10837 + if (test_thread_flag(TIF_32BIT))
10838 + addr &= 0xFFFFFFFFUL;
10839 +
10840 + regs->tpc = addr;
10841 + regs->tnpc = addr+4;
10842 + return 2;
10843 + }
10844 + } while (0);
10845 +
10846 + do { /* PaX: patched PLT emulation #2 */
10847 + unsigned int ba;
10848 +
10849 + err = get_user(ba, (unsigned int *)regs->tpc);
10850 +
10851 + if (err)
10852 + break;
10853 +
10854 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
10855 + unsigned long addr;
10856 +
10857 + if ((ba & 0xFFC00000U) == 0x30800000U)
10858 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
10859 + else
10860 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
10861 +
10862 + if (test_thread_flag(TIF_32BIT))
10863 + addr &= 0xFFFFFFFFUL;
10864 +
10865 + regs->tpc = addr;
10866 + regs->tnpc = addr+4;
10867 + return 2;
10868 + }
10869 + } while (0);
10870 +
10871 + do { /* PaX: patched PLT emulation #3 */
10872 + unsigned int sethi, bajmpl, nop;
10873 +
10874 + err = get_user(sethi, (unsigned int *)regs->tpc);
10875 + err |= get_user(bajmpl, (unsigned int *)(regs->tpc+4));
10876 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
10877 +
10878 + if (err)
10879 + break;
10880 +
10881 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10882 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
10883 + nop == 0x01000000U)
10884 + {
10885 + unsigned long addr;
10886 +
10887 + addr = (sethi & 0x003FFFFFU) << 10;
10888 + regs->u_regs[UREG_G1] = addr;
10889 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
10890 + addr += (((bajmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
10891 + else
10892 + addr = regs->tpc + ((((bajmpl | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
10893 +
10894 + if (test_thread_flag(TIF_32BIT))
10895 + addr &= 0xFFFFFFFFUL;
10896 +
10897 + regs->tpc = addr;
10898 + regs->tnpc = addr+4;
10899 + return 2;
10900 + }
10901 + } while (0);
10902 +
10903 + do { /* PaX: patched PLT emulation #4 */
10904 + unsigned int sethi, mov1, call, mov2;
10905 +
10906 + err = get_user(sethi, (unsigned int *)regs->tpc);
10907 + err |= get_user(mov1, (unsigned int *)(regs->tpc+4));
10908 + err |= get_user(call, (unsigned int *)(regs->tpc+8));
10909 + err |= get_user(mov2, (unsigned int *)(regs->tpc+12));
10910 +
10911 + if (err)
10912 + break;
10913 +
10914 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10915 + mov1 == 0x8210000FU &&
10916 + (call & 0xC0000000U) == 0x40000000U &&
10917 + mov2 == 0x9E100001U)
10918 + {
10919 + unsigned long addr;
10920 +
10921 + regs->u_regs[UREG_G1] = regs->u_regs[UREG_RETPC];
10922 + addr = regs->tpc + 4 + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
10923 +
10924 + if (test_thread_flag(TIF_32BIT))
10925 + addr &= 0xFFFFFFFFUL;
10926 +
10927 + regs->tpc = addr;
10928 + regs->tnpc = addr+4;
10929 + return 2;
10930 + }
10931 + } while (0);
10932 +
10933 + do { /* PaX: patched PLT emulation #5 */
10934 + unsigned int sethi, sethi1, sethi2, or1, or2, sllx, jmpl, nop;
10935 +
10936 + err = get_user(sethi, (unsigned int *)regs->tpc);
10937 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
10938 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
10939 + err |= get_user(or1, (unsigned int *)(regs->tpc+12));
10940 + err |= get_user(or2, (unsigned int *)(regs->tpc+16));
10941 + err |= get_user(sllx, (unsigned int *)(regs->tpc+20));
10942 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+24));
10943 + err |= get_user(nop, (unsigned int *)(regs->tpc+28));
10944 +
10945 + if (err)
10946 + break;
10947 +
10948 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10949 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
10950 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
10951 + (or1 & 0xFFFFE000U) == 0x82106000U &&
10952 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
10953 + sllx == 0x83287020U &&
10954 + jmpl == 0x81C04005U &&
10955 + nop == 0x01000000U)
10956 + {
10957 + unsigned long addr;
10958 +
10959 + regs->u_regs[UREG_G1] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
10960 + regs->u_regs[UREG_G1] <<= 32;
10961 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
10962 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
10963 + regs->tpc = addr;
10964 + regs->tnpc = addr+4;
10965 + return 2;
10966 + }
10967 + } while (0);
10968 +
10969 + do { /* PaX: patched PLT emulation #6 */
10970 + unsigned int sethi, sethi1, sethi2, sllx, or, jmpl, nop;
10971 +
10972 + err = get_user(sethi, (unsigned int *)regs->tpc);
10973 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
10974 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
10975 + err |= get_user(sllx, (unsigned int *)(regs->tpc+12));
10976 + err |= get_user(or, (unsigned int *)(regs->tpc+16));
10977 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+20));
10978 + err |= get_user(nop, (unsigned int *)(regs->tpc+24));
10979 +
10980 + if (err)
10981 + break;
10982 +
10983 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10984 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
10985 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
10986 + sllx == 0x83287020U &&
10987 + (or & 0xFFFFE000U) == 0x8A116000U &&
10988 + jmpl == 0x81C04005U &&
10989 + nop == 0x01000000U)
10990 + {
10991 + unsigned long addr;
10992 +
10993 + regs->u_regs[UREG_G1] = (sethi1 & 0x003FFFFFU) << 10;
10994 + regs->u_regs[UREG_G1] <<= 32;
10995 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or & 0x3FFU);
10996 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
10997 + regs->tpc = addr;
10998 + regs->tnpc = addr+4;
10999 + return 2;
11000 + }
11001 + } while (0);
11002 +
11003 + do { /* PaX: unpatched PLT emulation step 1 */
11004 + unsigned int sethi, ba, nop;
11005 +
11006 + err = get_user(sethi, (unsigned int *)regs->tpc);
11007 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
11008 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
11009 +
11010 + if (err)
11011 + break;
11012 +
11013 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
11014 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
11015 + nop == 0x01000000U)
11016 + {
11017 + unsigned long addr;
11018 + unsigned int save, call;
11019 + unsigned int sethi1, sethi2, or1, or2, sllx, add, jmpl;
11020 +
11021 + if ((ba & 0xFFC00000U) == 0x30800000U)
11022 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
11023 + else
11024 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
11025 +
11026 + if (test_thread_flag(TIF_32BIT))
11027 + addr &= 0xFFFFFFFFUL;
11028 +
11029 + err = get_user(save, (unsigned int *)addr);
11030 + err |= get_user(call, (unsigned int *)(addr+4));
11031 + err |= get_user(nop, (unsigned int *)(addr+8));
11032 + if (err)
11033 + break;
11034 +
11035 +#ifdef CONFIG_PAX_DLRESOLVE
11036 + if (save == 0x9DE3BFA8U &&
11037 + (call & 0xC0000000U) == 0x40000000U &&
11038 + nop == 0x01000000U)
11039 + {
11040 + struct vm_area_struct *vma;
11041 + unsigned long call_dl_resolve;
11042 +
11043 + down_read(&current->mm->mmap_sem);
11044 + call_dl_resolve = current->mm->call_dl_resolve;
11045 + up_read(&current->mm->mmap_sem);
11046 + if (likely(call_dl_resolve))
11047 + goto emulate;
11048 +
11049 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
11050 +
11051 + down_write(&current->mm->mmap_sem);
11052 + if (current->mm->call_dl_resolve) {
11053 + call_dl_resolve = current->mm->call_dl_resolve;
11054 + up_write(&current->mm->mmap_sem);
11055 + if (vma)
11056 + kmem_cache_free(vm_area_cachep, vma);
11057 + goto emulate;
11058 + }
11059 +
11060 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
11061 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
11062 + up_write(&current->mm->mmap_sem);
11063 + if (vma)
11064 + kmem_cache_free(vm_area_cachep, vma);
11065 + return 1;
11066 + }
11067 +
11068 + if (pax_insert_vma(vma, call_dl_resolve)) {
11069 + up_write(&current->mm->mmap_sem);
11070 + kmem_cache_free(vm_area_cachep, vma);
11071 + return 1;
11072 + }
11073 +
11074 + current->mm->call_dl_resolve = call_dl_resolve;
11075 + up_write(&current->mm->mmap_sem);
11076 +
11077 +emulate:
11078 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
11079 + regs->tpc = call_dl_resolve;
11080 + regs->tnpc = addr+4;
11081 + return 3;
11082 + }
11083 +#endif
11084 +
11085 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
11086 + if ((save & 0xFFC00000U) == 0x05000000U &&
11087 + (call & 0xFFFFE000U) == 0x85C0A000U &&
11088 + nop == 0x01000000U)
11089 + {
11090 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
11091 + regs->u_regs[UREG_G2] = addr + 4;
11092 + addr = (save & 0x003FFFFFU) << 10;
11093 + addr += (((call | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
11094 +
11095 + if (test_thread_flag(TIF_32BIT))
11096 + addr &= 0xFFFFFFFFUL;
11097 +
11098 + regs->tpc = addr;
11099 + regs->tnpc = addr+4;
11100 + return 3;
11101 + }
11102 +
11103 + /* PaX: 64-bit PLT stub */
11104 + err = get_user(sethi1, (unsigned int *)addr);
11105 + err |= get_user(sethi2, (unsigned int *)(addr+4));
11106 + err |= get_user(or1, (unsigned int *)(addr+8));
11107 + err |= get_user(or2, (unsigned int *)(addr+12));
11108 + err |= get_user(sllx, (unsigned int *)(addr+16));
11109 + err |= get_user(add, (unsigned int *)(addr+20));
11110 + err |= get_user(jmpl, (unsigned int *)(addr+24));
11111 + err |= get_user(nop, (unsigned int *)(addr+28));
11112 + if (err)
11113 + break;
11114 +
11115 + if ((sethi1 & 0xFFC00000U) == 0x09000000U &&
11116 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
11117 + (or1 & 0xFFFFE000U) == 0x88112000U &&
11118 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
11119 + sllx == 0x89293020U &&
11120 + add == 0x8A010005U &&
11121 + jmpl == 0x89C14000U &&
11122 + nop == 0x01000000U)
11123 + {
11124 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
11125 + regs->u_regs[UREG_G4] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
11126 + regs->u_regs[UREG_G4] <<= 32;
11127 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
11128 + regs->u_regs[UREG_G5] += regs->u_regs[UREG_G4];
11129 + regs->u_regs[UREG_G4] = addr + 24;
11130 + addr = regs->u_regs[UREG_G5];
11131 + regs->tpc = addr;
11132 + regs->tnpc = addr+4;
11133 + return 3;
11134 + }
11135 + }
11136 + } while (0);
11137 +
11138 +#ifdef CONFIG_PAX_DLRESOLVE
11139 + do { /* PaX: unpatched PLT emulation step 2 */
11140 + unsigned int save, call, nop;
11141 +
11142 + err = get_user(save, (unsigned int *)(regs->tpc-4));
11143 + err |= get_user(call, (unsigned int *)regs->tpc);
11144 + err |= get_user(nop, (unsigned int *)(regs->tpc+4));
11145 + if (err)
11146 + break;
11147 +
11148 + if (save == 0x9DE3BFA8U &&
11149 + (call & 0xC0000000U) == 0x40000000U &&
11150 + nop == 0x01000000U)
11151 + {
11152 + unsigned long dl_resolve = regs->tpc + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
11153 +
11154 + if (test_thread_flag(TIF_32BIT))
11155 + dl_resolve &= 0xFFFFFFFFUL;
11156 +
11157 + regs->u_regs[UREG_RETPC] = regs->tpc;
11158 + regs->tpc = dl_resolve;
11159 + regs->tnpc = dl_resolve+4;
11160 + return 3;
11161 + }
11162 + } while (0);
11163 +#endif
11164 +
11165 + do { /* PaX: patched PLT emulation #7, must be AFTER the unpatched PLT emulation */
11166 + unsigned int sethi, ba, nop;
11167 +
11168 + err = get_user(sethi, (unsigned int *)regs->tpc);
11169 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
11170 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
11171 +
11172 + if (err)
11173 + break;
11174 +
11175 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
11176 + (ba & 0xFFF00000U) == 0x30600000U &&
11177 + nop == 0x01000000U)
11178 + {
11179 + unsigned long addr;
11180 +
11181 + addr = (sethi & 0x003FFFFFU) << 10;
11182 + regs->u_regs[UREG_G1] = addr;
11183 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
11184 +
11185 + if (test_thread_flag(TIF_32BIT))
11186 + addr &= 0xFFFFFFFFUL;
11187 +
11188 + regs->tpc = addr;
11189 + regs->tnpc = addr+4;
11190 + return 2;
11191 + }
11192 + } while (0);
11193 +
11194 +#endif
11195 +
11196 + return 1;
11197 +}
11198 +
11199 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
11200 +{
11201 + unsigned long i;
11202 +
11203 + printk(KERN_ERR "PAX: bytes at PC: ");
11204 + for (i = 0; i < 8; i++) {
11205 + unsigned int c;
11206 + if (get_user(c, (unsigned int *)pc+i))
11207 + printk(KERN_CONT "???????? ");
11208 + else
11209 + printk(KERN_CONT "%08x ", c);
11210 + }
11211 + printk("\n");
11212 +}
11213 +#endif
11214 +
11215 asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs)
11216 {
11217 struct mm_struct *mm = current->mm;
11218 @@ -342,6 +805,29 @@ retry:
11219 if (!vma)
11220 goto bad_area;
11221
11222 +#ifdef CONFIG_PAX_PAGEEXEC
11223 + /* PaX: detect ITLB misses on non-exec pages */
11224 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && vma->vm_start <= address &&
11225 + !(vma->vm_flags & VM_EXEC) && (fault_code & FAULT_CODE_ITLB))
11226 + {
11227 + if (address != regs->tpc)
11228 + goto good_area;
11229 +
11230 + up_read(&mm->mmap_sem);
11231 + switch (pax_handle_fetch_fault(regs)) {
11232 +
11233 +#ifdef CONFIG_PAX_EMUPLT
11234 + case 2:
11235 + case 3:
11236 + return;
11237 +#endif
11238 +
11239 + }
11240 + pax_report_fault(regs, (void *)regs->tpc, (void *)(regs->u_regs[UREG_FP] + STACK_BIAS));
11241 + do_group_exit(SIGKILL);
11242 + }
11243 +#endif
11244 +
11245 /* Pure DTLB misses do not tell us whether the fault causing
11246 * load/store/atomic was a write or not, it only says that there
11247 * was no match. So in such a case we (carefully) read the
11248 diff --git a/arch/sparc/mm/hugetlbpage.c b/arch/sparc/mm/hugetlbpage.c
11249 index 9639964..806cd0c 100644
11250 --- a/arch/sparc/mm/hugetlbpage.c
11251 +++ b/arch/sparc/mm/hugetlbpage.c
11252 @@ -28,7 +28,8 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
11253 unsigned long addr,
11254 unsigned long len,
11255 unsigned long pgoff,
11256 - unsigned long flags)
11257 + unsigned long flags,
11258 + unsigned long offset)
11259 {
11260 unsigned long task_size = TASK_SIZE;
11261 struct vm_unmapped_area_info info;
11262 @@ -38,15 +39,22 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
11263
11264 info.flags = 0;
11265 info.length = len;
11266 - info.low_limit = TASK_UNMAPPED_BASE;
11267 + info.low_limit = mm->mmap_base;
11268 info.high_limit = min(task_size, VA_EXCLUDE_START);
11269 info.align_mask = PAGE_MASK & ~HPAGE_MASK;
11270 info.align_offset = 0;
11271 + info.threadstack_offset = offset;
11272 addr = vm_unmapped_area(&info);
11273
11274 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
11275 VM_BUG_ON(addr != -ENOMEM);
11276 info.low_limit = VA_EXCLUDE_END;
11277 +
11278 +#ifdef CONFIG_PAX_RANDMMAP
11279 + if (mm->pax_flags & MF_PAX_RANDMMAP)
11280 + info.low_limit += mm->delta_mmap;
11281 +#endif
11282 +
11283 info.high_limit = task_size;
11284 addr = vm_unmapped_area(&info);
11285 }
11286 @@ -58,7 +66,8 @@ static unsigned long
11287 hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
11288 const unsigned long len,
11289 const unsigned long pgoff,
11290 - const unsigned long flags)
11291 + const unsigned long flags,
11292 + const unsigned long offset)
11293 {
11294 struct mm_struct *mm = current->mm;
11295 unsigned long addr = addr0;
11296 @@ -73,6 +82,7 @@ hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
11297 info.high_limit = mm->mmap_base;
11298 info.align_mask = PAGE_MASK & ~HPAGE_MASK;
11299 info.align_offset = 0;
11300 + info.threadstack_offset = offset;
11301 addr = vm_unmapped_area(&info);
11302
11303 /*
11304 @@ -85,6 +95,12 @@ hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
11305 VM_BUG_ON(addr != -ENOMEM);
11306 info.flags = 0;
11307 info.low_limit = TASK_UNMAPPED_BASE;
11308 +
11309 +#ifdef CONFIG_PAX_RANDMMAP
11310 + if (mm->pax_flags & MF_PAX_RANDMMAP)
11311 + info.low_limit += mm->delta_mmap;
11312 +#endif
11313 +
11314 info.high_limit = STACK_TOP32;
11315 addr = vm_unmapped_area(&info);
11316 }
11317 @@ -99,6 +115,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
11318 struct mm_struct *mm = current->mm;
11319 struct vm_area_struct *vma;
11320 unsigned long task_size = TASK_SIZE;
11321 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
11322
11323 if (test_thread_flag(TIF_32BIT))
11324 task_size = STACK_TOP32;
11325 @@ -114,19 +131,22 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
11326 return addr;
11327 }
11328
11329 +#ifdef CONFIG_PAX_RANDMMAP
11330 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
11331 +#endif
11332 +
11333 if (addr) {
11334 addr = ALIGN(addr, HPAGE_SIZE);
11335 vma = find_vma(mm, addr);
11336 - if (task_size - len >= addr &&
11337 - (!vma || addr + len <= vma->vm_start))
11338 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
11339 return addr;
11340 }
11341 if (mm->get_unmapped_area == arch_get_unmapped_area)
11342 return hugetlb_get_unmapped_area_bottomup(file, addr, len,
11343 - pgoff, flags);
11344 + pgoff, flags, offset);
11345 else
11346 return hugetlb_get_unmapped_area_topdown(file, addr, len,
11347 - pgoff, flags);
11348 + pgoff, flags, offset);
11349 }
11350
11351 pte_t *huge_pte_alloc(struct mm_struct *mm,
11352 diff --git a/arch/sparc/mm/init_64.c b/arch/sparc/mm/init_64.c
11353 index ed82eda..0d80e77 100644
11354 --- a/arch/sparc/mm/init_64.c
11355 +++ b/arch/sparc/mm/init_64.c
11356 @@ -188,9 +188,9 @@ unsigned long sparc64_kern_sec_context __read_mostly;
11357 int num_kernel_image_mappings;
11358
11359 #ifdef CONFIG_DEBUG_DCFLUSH
11360 -atomic_t dcpage_flushes = ATOMIC_INIT(0);
11361 +atomic_unchecked_t dcpage_flushes = ATOMIC_INIT(0);
11362 #ifdef CONFIG_SMP
11363 -atomic_t dcpage_flushes_xcall = ATOMIC_INIT(0);
11364 +atomic_unchecked_t dcpage_flushes_xcall = ATOMIC_INIT(0);
11365 #endif
11366 #endif
11367
11368 @@ -198,7 +198,7 @@ inline void flush_dcache_page_impl(struct page *page)
11369 {
11370 BUG_ON(tlb_type == hypervisor);
11371 #ifdef CONFIG_DEBUG_DCFLUSH
11372 - atomic_inc(&dcpage_flushes);
11373 + atomic_inc_unchecked(&dcpage_flushes);
11374 #endif
11375
11376 #ifdef DCACHE_ALIASING_POSSIBLE
11377 @@ -466,10 +466,10 @@ void mmu_info(struct seq_file *m)
11378
11379 #ifdef CONFIG_DEBUG_DCFLUSH
11380 seq_printf(m, "DCPageFlushes\t: %d\n",
11381 - atomic_read(&dcpage_flushes));
11382 + atomic_read_unchecked(&dcpage_flushes));
11383 #ifdef CONFIG_SMP
11384 seq_printf(m, "DCPageFlushesXC\t: %d\n",
11385 - atomic_read(&dcpage_flushes_xcall));
11386 + atomic_read_unchecked(&dcpage_flushes_xcall));
11387 #endif /* CONFIG_SMP */
11388 #endif /* CONFIG_DEBUG_DCFLUSH */
11389 }
11390 diff --git a/arch/tile/Kconfig b/arch/tile/Kconfig
11391 index d45a2c4..3c05a78 100644
11392 --- a/arch/tile/Kconfig
11393 +++ b/arch/tile/Kconfig
11394 @@ -185,6 +185,7 @@ source "kernel/Kconfig.hz"
11395
11396 config KEXEC
11397 bool "kexec system call"
11398 + depends on !GRKERNSEC_KMEM
11399 ---help---
11400 kexec is a system call that implements the ability to shutdown your
11401 current kernel, and to start another kernel. It is like a reboot
11402 diff --git a/arch/tile/include/asm/atomic_64.h b/arch/tile/include/asm/atomic_64.h
11403 index ad220ee..2f537b3 100644
11404 --- a/arch/tile/include/asm/atomic_64.h
11405 +++ b/arch/tile/include/asm/atomic_64.h
11406 @@ -105,6 +105,16 @@ static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
11407
11408 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
11409
11410 +#define atomic64_read_unchecked(v) atomic64_read(v)
11411 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
11412 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
11413 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
11414 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
11415 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
11416 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
11417 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
11418 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
11419 +
11420 /* Atomic dec and inc don't implement barrier, so provide them if needed. */
11421 #define smp_mb__before_atomic_dec() smp_mb()
11422 #define smp_mb__after_atomic_dec() smp_mb()
11423 diff --git a/arch/tile/include/asm/cache.h b/arch/tile/include/asm/cache.h
11424 index 6160761..00cac88 100644
11425 --- a/arch/tile/include/asm/cache.h
11426 +++ b/arch/tile/include/asm/cache.h
11427 @@ -15,11 +15,12 @@
11428 #ifndef _ASM_TILE_CACHE_H
11429 #define _ASM_TILE_CACHE_H
11430
11431 +#include <linux/const.h>
11432 #include <arch/chip.h>
11433
11434 /* bytes per L1 data cache line */
11435 #define L1_CACHE_SHIFT CHIP_L1D_LOG_LINE_SIZE()
11436 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
11437 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
11438
11439 /* bytes per L2 cache line */
11440 #define L2_CACHE_SHIFT CHIP_L2_LOG_LINE_SIZE()
11441 diff --git a/arch/tile/include/asm/uaccess.h b/arch/tile/include/asm/uaccess.h
11442 index b6cde32..c0cb736 100644
11443 --- a/arch/tile/include/asm/uaccess.h
11444 +++ b/arch/tile/include/asm/uaccess.h
11445 @@ -414,9 +414,9 @@ static inline unsigned long __must_check copy_from_user(void *to,
11446 const void __user *from,
11447 unsigned long n)
11448 {
11449 - int sz = __compiletime_object_size(to);
11450 + size_t sz = __compiletime_object_size(to);
11451
11452 - if (likely(sz == -1 || sz >= n))
11453 + if (likely(sz == (size_t)-1 || sz >= n))
11454 n = _copy_from_user(to, from, n);
11455 else
11456 copy_from_user_overflow();
11457 diff --git a/arch/tile/mm/hugetlbpage.c b/arch/tile/mm/hugetlbpage.c
11458 index 0cb3bba..7338b2d 100644
11459 --- a/arch/tile/mm/hugetlbpage.c
11460 +++ b/arch/tile/mm/hugetlbpage.c
11461 @@ -212,6 +212,7 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
11462 info.high_limit = TASK_SIZE;
11463 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
11464 info.align_offset = 0;
11465 + info.threadstack_offset = 0;
11466 return vm_unmapped_area(&info);
11467 }
11468
11469 @@ -229,6 +230,7 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
11470 info.high_limit = current->mm->mmap_base;
11471 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
11472 info.align_offset = 0;
11473 + info.threadstack_offset = 0;
11474 addr = vm_unmapped_area(&info);
11475
11476 /*
11477 diff --git a/arch/um/Makefile b/arch/um/Makefile
11478 index 133f7de..1d6f2f1 100644
11479 --- a/arch/um/Makefile
11480 +++ b/arch/um/Makefile
11481 @@ -62,6 +62,10 @@ USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -D__KERNEL__,,\
11482 $(patsubst -I%,,$(KBUILD_CFLAGS)))) $(ARCH_INCLUDE) $(MODE_INCLUDE) \
11483 $(filter -I%,$(CFLAGS)) -D_FILE_OFFSET_BITS=64 -idirafter include
11484
11485 +ifdef CONSTIFY_PLUGIN
11486 +USER_CFLAGS += -fplugin-arg-constify_plugin-no-constify
11487 +endif
11488 +
11489 #This will adjust *FLAGS accordingly to the platform.
11490 include $(srctree)/$(ARCH_DIR)/Makefile-os-$(OS)
11491
11492 diff --git a/arch/um/defconfig b/arch/um/defconfig
11493 index 2665e6b..3e3822b 100644
11494 --- a/arch/um/defconfig
11495 +++ b/arch/um/defconfig
11496 @@ -51,7 +51,6 @@ CONFIG_X86_CMPXCHG=y
11497 CONFIG_X86_L1_CACHE_SHIFT=5
11498 CONFIG_X86_XADD=y
11499 CONFIG_X86_PPRO_FENCE=y
11500 -CONFIG_X86_WP_WORKS_OK=y
11501 CONFIG_X86_INVLPG=y
11502 CONFIG_X86_BSWAP=y
11503 CONFIG_X86_POPAD_OK=y
11504 diff --git a/arch/um/include/asm/cache.h b/arch/um/include/asm/cache.h
11505 index 19e1bdd..3665b77 100644
11506 --- a/arch/um/include/asm/cache.h
11507 +++ b/arch/um/include/asm/cache.h
11508 @@ -1,6 +1,7 @@
11509 #ifndef __UM_CACHE_H
11510 #define __UM_CACHE_H
11511
11512 +#include <linux/const.h>
11513
11514 #if defined(CONFIG_UML_X86) && !defined(CONFIG_64BIT)
11515 # define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
11516 @@ -12,6 +13,6 @@
11517 # define L1_CACHE_SHIFT 5
11518 #endif
11519
11520 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
11521 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
11522
11523 #endif
11524 diff --git a/arch/um/include/asm/kmap_types.h b/arch/um/include/asm/kmap_types.h
11525 index 2e0a6b1..a64d0f5 100644
11526 --- a/arch/um/include/asm/kmap_types.h
11527 +++ b/arch/um/include/asm/kmap_types.h
11528 @@ -8,6 +8,6 @@
11529
11530 /* No more #include "asm/arch/kmap_types.h" ! */
11531
11532 -#define KM_TYPE_NR 14
11533 +#define KM_TYPE_NR 15
11534
11535 #endif
11536 diff --git a/arch/um/include/asm/page.h b/arch/um/include/asm/page.h
11537 index 5ff53d9..5850cdf 100644
11538 --- a/arch/um/include/asm/page.h
11539 +++ b/arch/um/include/asm/page.h
11540 @@ -14,6 +14,9 @@
11541 #define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
11542 #define PAGE_MASK (~(PAGE_SIZE-1))
11543
11544 +#define ktla_ktva(addr) (addr)
11545 +#define ktva_ktla(addr) (addr)
11546 +
11547 #ifndef __ASSEMBLY__
11548
11549 struct page;
11550 diff --git a/arch/um/include/asm/pgtable-3level.h b/arch/um/include/asm/pgtable-3level.h
11551 index 0032f92..cd151e0 100644
11552 --- a/arch/um/include/asm/pgtable-3level.h
11553 +++ b/arch/um/include/asm/pgtable-3level.h
11554 @@ -58,6 +58,7 @@
11555 #define pud_present(x) (pud_val(x) & _PAGE_PRESENT)
11556 #define pud_populate(mm, pud, pmd) \
11557 set_pud(pud, __pud(_PAGE_TABLE + __pa(pmd)))
11558 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
11559
11560 #ifdef CONFIG_64BIT
11561 #define set_pud(pudptr, pudval) set_64bit((u64 *) (pudptr), pud_val(pudval))
11562 diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c
11563 index bbcef52..6a2a483 100644
11564 --- a/arch/um/kernel/process.c
11565 +++ b/arch/um/kernel/process.c
11566 @@ -367,22 +367,6 @@ int singlestepping(void * t)
11567 return 2;
11568 }
11569
11570 -/*
11571 - * Only x86 and x86_64 have an arch_align_stack().
11572 - * All other arches have "#define arch_align_stack(x) (x)"
11573 - * in their asm/system.h
11574 - * As this is included in UML from asm-um/system-generic.h,
11575 - * we can use it to behave as the subarch does.
11576 - */
11577 -#ifndef arch_align_stack
11578 -unsigned long arch_align_stack(unsigned long sp)
11579 -{
11580 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
11581 - sp -= get_random_int() % 8192;
11582 - return sp & ~0xf;
11583 -}
11584 -#endif
11585 -
11586 unsigned long get_wchan(struct task_struct *p)
11587 {
11588 unsigned long stack_page, sp, ip;
11589 diff --git a/arch/unicore32/include/asm/cache.h b/arch/unicore32/include/asm/cache.h
11590 index ad8f795..2c7eec6 100644
11591 --- a/arch/unicore32/include/asm/cache.h
11592 +++ b/arch/unicore32/include/asm/cache.h
11593 @@ -12,8 +12,10 @@
11594 #ifndef __UNICORE_CACHE_H__
11595 #define __UNICORE_CACHE_H__
11596
11597 -#define L1_CACHE_SHIFT (5)
11598 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
11599 +#include <linux/const.h>
11600 +
11601 +#define L1_CACHE_SHIFT 5
11602 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
11603
11604 /*
11605 * Memory returned by kmalloc() may be used for DMA, so we must make
11606 diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
11607 index f67e839..bfd4748 100644
11608 --- a/arch/x86/Kconfig
11609 +++ b/arch/x86/Kconfig
11610 @@ -247,7 +247,7 @@ config X86_HT
11611
11612 config X86_32_LAZY_GS
11613 def_bool y
11614 - depends on X86_32 && !CC_STACKPROTECTOR
11615 + depends on X86_32 && !CC_STACKPROTECTOR && !PAX_MEMORY_UDEREF
11616
11617 config ARCH_HWEIGHT_CFLAGS
11618 string
11619 @@ -1099,6 +1099,7 @@ config MICROCODE_EARLY
11620
11621 config X86_MSR
11622 tristate "/dev/cpu/*/msr - Model-specific register support"
11623 + depends on !GRKERNSEC_KMEM
11624 ---help---
11625 This device gives privileged processes access to the x86
11626 Model-Specific Registers (MSRs). It is a character device with
11627 @@ -1122,7 +1123,7 @@ choice
11628
11629 config NOHIGHMEM
11630 bool "off"
11631 - depends on !X86_NUMAQ
11632 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
11633 ---help---
11634 Linux can use up to 64 Gigabytes of physical memory on x86 systems.
11635 However, the address space of 32-bit x86 processors is only 4
11636 @@ -1159,7 +1160,7 @@ config NOHIGHMEM
11637
11638 config HIGHMEM4G
11639 bool "4GB"
11640 - depends on !X86_NUMAQ
11641 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
11642 ---help---
11643 Select this if you have a 32-bit processor and between 1 and 4
11644 gigabytes of physical RAM.
11645 @@ -1212,7 +1213,7 @@ config PAGE_OFFSET
11646 hex
11647 default 0xB0000000 if VMSPLIT_3G_OPT
11648 default 0x80000000 if VMSPLIT_2G
11649 - default 0x78000000 if VMSPLIT_2G_OPT
11650 + default 0x70000000 if VMSPLIT_2G_OPT
11651 default 0x40000000 if VMSPLIT_1G
11652 default 0xC0000000
11653 depends on X86_32
11654 @@ -1614,6 +1615,7 @@ config SECCOMP
11655
11656 config CC_STACKPROTECTOR
11657 bool "Enable -fstack-protector buffer overflow detection"
11658 + depends on X86_64 || !PAX_MEMORY_UDEREF
11659 ---help---
11660 This option turns on the -fstack-protector GCC feature. This
11661 feature puts, at the beginning of functions, a canary value on
11662 @@ -1632,6 +1634,7 @@ source kernel/Kconfig.hz
11663
11664 config KEXEC
11665 bool "kexec system call"
11666 + depends on !GRKERNSEC_KMEM
11667 ---help---
11668 kexec is a system call that implements the ability to shutdown your
11669 current kernel, and to start another kernel. It is like a reboot
11670 @@ -1733,6 +1736,8 @@ config X86_NEED_RELOCS
11671 config PHYSICAL_ALIGN
11672 hex "Alignment value to which kernel should be aligned"
11673 default "0x1000000"
11674 + range 0x200000 0x1000000 if PAX_KERNEXEC && X86_PAE
11675 + range 0x400000 0x1000000 if PAX_KERNEXEC && !X86_PAE
11676 range 0x2000 0x1000000 if X86_32
11677 range 0x200000 0x1000000 if X86_64
11678 ---help---
11679 @@ -1812,9 +1817,10 @@ config DEBUG_HOTPLUG_CPU0
11680 If unsure, say N.
11681
11682 config COMPAT_VDSO
11683 - def_bool y
11684 + def_bool n
11685 prompt "Compat VDSO support"
11686 depends on X86_32 || IA32_EMULATION
11687 + depends on !PAX_PAGEEXEC && !PAX_SEGMEXEC && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
11688 ---help---
11689 Map the 32-bit VDSO to the predictable old-style address too.
11690
11691 diff --git a/arch/x86/Kconfig.cpu b/arch/x86/Kconfig.cpu
11692 index c026cca..14657ae 100644
11693 --- a/arch/x86/Kconfig.cpu
11694 +++ b/arch/x86/Kconfig.cpu
11695 @@ -319,7 +319,7 @@ config X86_PPRO_FENCE
11696
11697 config X86_F00F_BUG
11698 def_bool y
11699 - depends on M586MMX || M586TSC || M586 || M486
11700 + depends on (M586MMX || M586TSC || M586 || M486) && !PAX_KERNEXEC
11701
11702 config X86_INVD_BUG
11703 def_bool y
11704 @@ -327,7 +327,7 @@ config X86_INVD_BUG
11705
11706 config X86_ALIGNMENT_16
11707 def_bool y
11708 - depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || MELAN || MK6 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
11709 + depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || X86_ELAN || MK8 || MK7 || MK6 || MCORE2 || MPENTIUM4 || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
11710
11711 config X86_INTEL_USERCOPY
11712 def_bool y
11713 @@ -373,7 +373,7 @@ config X86_CMPXCHG64
11714 # generates cmov.
11715 config X86_CMOV
11716 def_bool y
11717 - depends on (MK8 || MK7 || MCORE2 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
11718 + depends on (MK8 || MK7 || MCORE2 || MPSC || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
11719
11720 config X86_MINIMUM_CPU_FAMILY
11721 int
11722 diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug
11723 index 78d91af..8ceb94b 100644
11724 --- a/arch/x86/Kconfig.debug
11725 +++ b/arch/x86/Kconfig.debug
11726 @@ -74,7 +74,7 @@ config X86_PTDUMP
11727 config DEBUG_RODATA
11728 bool "Write protect kernel read-only data structures"
11729 default y
11730 - depends on DEBUG_KERNEL
11731 + depends on DEBUG_KERNEL && BROKEN
11732 ---help---
11733 Mark the kernel read-only data as write-protected in the pagetables,
11734 in order to catch accidental (and incorrect) writes to such const
11735 @@ -92,7 +92,7 @@ config DEBUG_RODATA_TEST
11736
11737 config DEBUG_SET_MODULE_RONX
11738 bool "Set loadable kernel module data as NX and text as RO"
11739 - depends on MODULES
11740 + depends on MODULES && BROKEN
11741 ---help---
11742 This option helps catch unintended modifications to loadable
11743 kernel module's text and read-only data. It also prevents execution
11744 diff --git a/arch/x86/Makefile b/arch/x86/Makefile
11745 index 57d0215..b4373fb 100644
11746 --- a/arch/x86/Makefile
11747 +++ b/arch/x86/Makefile
11748 @@ -49,14 +49,12 @@ ifeq ($(CONFIG_X86_32),y)
11749 # CPU-specific tuning. Anything which can be shared with UML should go here.
11750 include $(srctree)/arch/x86/Makefile_32.cpu
11751 KBUILD_CFLAGS += $(cflags-y)
11752 -
11753 - # temporary until string.h is fixed
11754 - KBUILD_CFLAGS += -ffreestanding
11755 else
11756 BITS := 64
11757 UTS_MACHINE := x86_64
11758 CHECKFLAGS += -D__x86_64__ -m64
11759
11760 + biarch := $(call cc-option,-m64)
11761 KBUILD_AFLAGS += -m64
11762 KBUILD_CFLAGS += -m64
11763
11764 @@ -89,6 +87,9 @@ else
11765 KBUILD_CFLAGS += -maccumulate-outgoing-args
11766 endif
11767
11768 +# temporary until string.h is fixed
11769 +KBUILD_CFLAGS += -ffreestanding
11770 +
11771 ifdef CONFIG_CC_STACKPROTECTOR
11772 cc_has_sp := $(srctree)/scripts/gcc-x86_$(BITS)-has-stack-protector.sh
11773 ifeq ($(shell $(CONFIG_SHELL) $(cc_has_sp) $(CC) $(KBUILD_CPPFLAGS) $(biarch)),y)
11774 @@ -247,3 +248,12 @@ define archhelp
11775 echo ' FDINITRD=file initrd for the booted kernel'
11776 echo ' kvmconfig - Enable additional options for guest kernel support'
11777 endef
11778 +
11779 +define OLD_LD
11780 +
11781 +*** ${VERSION}.${PATCHLEVEL} PaX kernels no longer build correctly with old versions of binutils.
11782 +*** Please upgrade your binutils to 2.18 or newer
11783 +endef
11784 +
11785 +archprepare:
11786 + $(if $(LDFLAGS_BUILD_ID),,$(error $(OLD_LD)))
11787 diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile
11788 index 6cf0111..f2e2398 100644
11789 --- a/arch/x86/boot/Makefile
11790 +++ b/arch/x86/boot/Makefile
11791 @@ -65,6 +65,9 @@ KBUILD_CFLAGS := $(USERINCLUDE) -m32 -g -Os -D_SETUP -D__KERNEL__ \
11792 $(call cc-option, -fno-unit-at-a-time)) \
11793 $(call cc-option, -fno-stack-protector) \
11794 $(call cc-option, -mpreferred-stack-boundary=2)
11795 +ifdef CONSTIFY_PLUGIN
11796 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
11797 +endif
11798 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
11799 GCOV_PROFILE := n
11800
11801 diff --git a/arch/x86/boot/bitops.h b/arch/x86/boot/bitops.h
11802 index 878e4b9..20537ab 100644
11803 --- a/arch/x86/boot/bitops.h
11804 +++ b/arch/x86/boot/bitops.h
11805 @@ -26,7 +26,7 @@ static inline int variable_test_bit(int nr, const void *addr)
11806 u8 v;
11807 const u32 *p = (const u32 *)addr;
11808
11809 - asm("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
11810 + asm volatile("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
11811 return v;
11812 }
11813
11814 @@ -37,7 +37,7 @@ static inline int variable_test_bit(int nr, const void *addr)
11815
11816 static inline void set_bit(int nr, void *addr)
11817 {
11818 - asm("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
11819 + asm volatile("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
11820 }
11821
11822 #endif /* BOOT_BITOPS_H */
11823 diff --git a/arch/x86/boot/boot.h b/arch/x86/boot/boot.h
11824 index ef72bae..353a184 100644
11825 --- a/arch/x86/boot/boot.h
11826 +++ b/arch/x86/boot/boot.h
11827 @@ -85,7 +85,7 @@ static inline void io_delay(void)
11828 static inline u16 ds(void)
11829 {
11830 u16 seg;
11831 - asm("movw %%ds,%0" : "=rm" (seg));
11832 + asm volatile("movw %%ds,%0" : "=rm" (seg));
11833 return seg;
11834 }
11835
11836 @@ -181,7 +181,7 @@ static inline void wrgs32(u32 v, addr_t addr)
11837 static inline int memcmp(const void *s1, const void *s2, size_t len)
11838 {
11839 u8 diff;
11840 - asm("repe; cmpsb; setnz %0"
11841 + asm volatile("repe; cmpsb; setnz %0"
11842 : "=qm" (diff), "+D" (s1), "+S" (s2), "+c" (len));
11843 return diff;
11844 }
11845 diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
11846 index c8a6792..2402765 100644
11847 --- a/arch/x86/boot/compressed/Makefile
11848 +++ b/arch/x86/boot/compressed/Makefile
11849 @@ -16,6 +16,9 @@ KBUILD_CFLAGS += $(cflags-y)
11850 KBUILD_CFLAGS += -mno-mmx -mno-sse
11851 KBUILD_CFLAGS += $(call cc-option,-ffreestanding)
11852 KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
11853 +ifdef CONSTIFY_PLUGIN
11854 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
11855 +endif
11856
11857 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
11858 GCOV_PROFILE := n
11859 diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c
11860 index b7388a4..03844ec 100644
11861 --- a/arch/x86/boot/compressed/eboot.c
11862 +++ b/arch/x86/boot/compressed/eboot.c
11863 @@ -150,7 +150,6 @@ again:
11864 *addr = max_addr;
11865 }
11866
11867 -free_pool:
11868 efi_call_phys1(sys_table->boottime->free_pool, map);
11869
11870 fail:
11871 @@ -214,7 +213,6 @@ static efi_status_t low_alloc(unsigned long size, unsigned long align,
11872 if (i == map_size / desc_size)
11873 status = EFI_NOT_FOUND;
11874
11875 -free_pool:
11876 efi_call_phys1(sys_table->boottime->free_pool, map);
11877 fail:
11878 return status;
11879 diff --git a/arch/x86/boot/compressed/efi_stub_32.S b/arch/x86/boot/compressed/efi_stub_32.S
11880 index a53440e..c3dbf1e 100644
11881 --- a/arch/x86/boot/compressed/efi_stub_32.S
11882 +++ b/arch/x86/boot/compressed/efi_stub_32.S
11883 @@ -46,16 +46,13 @@ ENTRY(efi_call_phys)
11884 * parameter 2, ..., param n. To make things easy, we save the return
11885 * address of efi_call_phys in a global variable.
11886 */
11887 - popl %ecx
11888 - movl %ecx, saved_return_addr(%edx)
11889 - /* get the function pointer into ECX*/
11890 - popl %ecx
11891 - movl %ecx, efi_rt_function_ptr(%edx)
11892 + popl saved_return_addr(%edx)
11893 + popl efi_rt_function_ptr(%edx)
11894
11895 /*
11896 * 3. Call the physical function.
11897 */
11898 - call *%ecx
11899 + call *efi_rt_function_ptr(%edx)
11900
11901 /*
11902 * 4. Balance the stack. And because EAX contain the return value,
11903 @@ -67,15 +64,12 @@ ENTRY(efi_call_phys)
11904 1: popl %edx
11905 subl $1b, %edx
11906
11907 - movl efi_rt_function_ptr(%edx), %ecx
11908 - pushl %ecx
11909 + pushl efi_rt_function_ptr(%edx)
11910
11911 /*
11912 * 10. Push the saved return address onto the stack and return.
11913 */
11914 - movl saved_return_addr(%edx), %ecx
11915 - pushl %ecx
11916 - ret
11917 + jmpl *saved_return_addr(%edx)
11918 ENDPROC(efi_call_phys)
11919 .previous
11920
11921 diff --git a/arch/x86/boot/compressed/head_32.S b/arch/x86/boot/compressed/head_32.S
11922 index 5d6f689..9d06730 100644
11923 --- a/arch/x86/boot/compressed/head_32.S
11924 +++ b/arch/x86/boot/compressed/head_32.S
11925 @@ -118,7 +118,7 @@ preferred_addr:
11926 notl %eax
11927 andl %eax, %ebx
11928 #else
11929 - movl $LOAD_PHYSICAL_ADDR, %ebx
11930 + movl $____LOAD_PHYSICAL_ADDR, %ebx
11931 #endif
11932
11933 /* Target address to relocate to for decompression */
11934 diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S
11935 index c337422..2c5be72 100644
11936 --- a/arch/x86/boot/compressed/head_64.S
11937 +++ b/arch/x86/boot/compressed/head_64.S
11938 @@ -95,7 +95,7 @@ ENTRY(startup_32)
11939 notl %eax
11940 andl %eax, %ebx
11941 #else
11942 - movl $LOAD_PHYSICAL_ADDR, %ebx
11943 + movl $____LOAD_PHYSICAL_ADDR, %ebx
11944 #endif
11945
11946 /* Target address to relocate to for decompression */
11947 @@ -270,7 +270,7 @@ preferred_addr:
11948 notq %rax
11949 andq %rax, %rbp
11950 #else
11951 - movq $LOAD_PHYSICAL_ADDR, %rbp
11952 + movq $____LOAD_PHYSICAL_ADDR, %rbp
11953 #endif
11954
11955 /* Target address to relocate to for decompression */
11956 @@ -362,8 +362,8 @@ gdt:
11957 .long gdt
11958 .word 0
11959 .quad 0x0000000000000000 /* NULL descriptor */
11960 - .quad 0x00af9a000000ffff /* __KERNEL_CS */
11961 - .quad 0x00cf92000000ffff /* __KERNEL_DS */
11962 + .quad 0x00af9b000000ffff /* __KERNEL_CS */
11963 + .quad 0x00cf93000000ffff /* __KERNEL_DS */
11964 .quad 0x0080890000000000 /* TS descriptor */
11965 .quad 0x0000000000000000 /* TS continued */
11966 gdt_end:
11967 diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
11968 index 434f077..b6b4b38 100644
11969 --- a/arch/x86/boot/compressed/misc.c
11970 +++ b/arch/x86/boot/compressed/misc.c
11971 @@ -283,7 +283,7 @@ static void handle_relocations(void *output, unsigned long output_len)
11972 * Calculate the delta between where vmlinux was linked to load
11973 * and where it was actually loaded.
11974 */
11975 - delta = min_addr - LOAD_PHYSICAL_ADDR;
11976 + delta = min_addr - ____LOAD_PHYSICAL_ADDR;
11977 if (!delta) {
11978 debug_putstr("No relocation needed... ");
11979 return;
11980 @@ -380,7 +380,7 @@ static void parse_elf(void *output)
11981 case PT_LOAD:
11982 #ifdef CONFIG_RELOCATABLE
11983 dest = output;
11984 - dest += (phdr->p_paddr - LOAD_PHYSICAL_ADDR);
11985 + dest += (phdr->p_paddr - ____LOAD_PHYSICAL_ADDR);
11986 #else
11987 dest = (void *)(phdr->p_paddr);
11988 #endif
11989 @@ -432,7 +432,7 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap,
11990 error("Destination address too large");
11991 #endif
11992 #ifndef CONFIG_RELOCATABLE
11993 - if ((unsigned long)output != LOAD_PHYSICAL_ADDR)
11994 + if ((unsigned long)output != ____LOAD_PHYSICAL_ADDR)
11995 error("Wrong destination address");
11996 #endif
11997
11998 diff --git a/arch/x86/boot/cpucheck.c b/arch/x86/boot/cpucheck.c
11999 index 4d3ff03..e4972ff 100644
12000 --- a/arch/x86/boot/cpucheck.c
12001 +++ b/arch/x86/boot/cpucheck.c
12002 @@ -74,7 +74,7 @@ static int has_fpu(void)
12003 u16 fcw = -1, fsw = -1;
12004 u32 cr0;
12005
12006 - asm("movl %%cr0,%0" : "=r" (cr0));
12007 + asm volatile("movl %%cr0,%0" : "=r" (cr0));
12008 if (cr0 & (X86_CR0_EM|X86_CR0_TS)) {
12009 cr0 &= ~(X86_CR0_EM|X86_CR0_TS);
12010 asm volatile("movl %0,%%cr0" : : "r" (cr0));
12011 @@ -90,7 +90,7 @@ static int has_eflag(u32 mask)
12012 {
12013 u32 f0, f1;
12014
12015 - asm("pushfl ; "
12016 + asm volatile("pushfl ; "
12017 "pushfl ; "
12018 "popl %0 ; "
12019 "movl %0,%1 ; "
12020 @@ -115,7 +115,7 @@ static void get_flags(void)
12021 set_bit(X86_FEATURE_FPU, cpu.flags);
12022
12023 if (has_eflag(X86_EFLAGS_ID)) {
12024 - asm("cpuid"
12025 + asm volatile("cpuid"
12026 : "=a" (max_intel_level),
12027 "=b" (cpu_vendor[0]),
12028 "=d" (cpu_vendor[1]),
12029 @@ -124,7 +124,7 @@ static void get_flags(void)
12030
12031 if (max_intel_level >= 0x00000001 &&
12032 max_intel_level <= 0x0000ffff) {
12033 - asm("cpuid"
12034 + asm volatile("cpuid"
12035 : "=a" (tfms),
12036 "=c" (cpu.flags[4]),
12037 "=d" (cpu.flags[0])
12038 @@ -136,7 +136,7 @@ static void get_flags(void)
12039 cpu.model += ((tfms >> 16) & 0xf) << 4;
12040 }
12041
12042 - asm("cpuid"
12043 + asm volatile("cpuid"
12044 : "=a" (max_amd_level)
12045 : "a" (0x80000000)
12046 : "ebx", "ecx", "edx");
12047 @@ -144,7 +144,7 @@ static void get_flags(void)
12048 if (max_amd_level >= 0x80000001 &&
12049 max_amd_level <= 0x8000ffff) {
12050 u32 eax = 0x80000001;
12051 - asm("cpuid"
12052 + asm volatile("cpuid"
12053 : "+a" (eax),
12054 "=c" (cpu.flags[6]),
12055 "=d" (cpu.flags[1])
12056 @@ -203,9 +203,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
12057 u32 ecx = MSR_K7_HWCR;
12058 u32 eax, edx;
12059
12060 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
12061 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
12062 eax &= ~(1 << 15);
12063 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
12064 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
12065
12066 get_flags(); /* Make sure it really did something */
12067 err = check_flags();
12068 @@ -218,9 +218,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
12069 u32 ecx = MSR_VIA_FCR;
12070 u32 eax, edx;
12071
12072 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
12073 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
12074 eax |= (1<<1)|(1<<7);
12075 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
12076 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
12077
12078 set_bit(X86_FEATURE_CX8, cpu.flags);
12079 err = check_flags();
12080 @@ -231,12 +231,12 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
12081 u32 eax, edx;
12082 u32 level = 1;
12083
12084 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
12085 - asm("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
12086 - asm("cpuid"
12087 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
12088 + asm volatile("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
12089 + asm volatile("cpuid"
12090 : "+a" (level), "=d" (cpu.flags[0])
12091 : : "ecx", "ebx");
12092 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
12093 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
12094
12095 err = check_flags();
12096 }
12097 diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S
12098 index 9ec06a1..2c25e79 100644
12099 --- a/arch/x86/boot/header.S
12100 +++ b/arch/x86/boot/header.S
12101 @@ -409,10 +409,14 @@ setup_data: .quad 0 # 64-bit physical pointer to
12102 # single linked list of
12103 # struct setup_data
12104
12105 -pref_address: .quad LOAD_PHYSICAL_ADDR # preferred load addr
12106 +pref_address: .quad ____LOAD_PHYSICAL_ADDR # preferred load addr
12107
12108 #define ZO_INIT_SIZE (ZO__end - ZO_startup_32 + ZO_z_extract_offset)
12109 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
12110 +#define VO_INIT_SIZE (VO__end - VO__text - __PAGE_OFFSET - ____LOAD_PHYSICAL_ADDR)
12111 +#else
12112 #define VO_INIT_SIZE (VO__end - VO__text)
12113 +#endif
12114 #if ZO_INIT_SIZE > VO_INIT_SIZE
12115 #define INIT_SIZE ZO_INIT_SIZE
12116 #else
12117 diff --git a/arch/x86/boot/memory.c b/arch/x86/boot/memory.c
12118 index db75d07..8e6d0af 100644
12119 --- a/arch/x86/boot/memory.c
12120 +++ b/arch/x86/boot/memory.c
12121 @@ -19,7 +19,7 @@
12122
12123 static int detect_memory_e820(void)
12124 {
12125 - int count = 0;
12126 + unsigned int count = 0;
12127 struct biosregs ireg, oreg;
12128 struct e820entry *desc = boot_params.e820_map;
12129 static struct e820entry buf; /* static so it is zeroed */
12130 diff --git a/arch/x86/boot/video-vesa.c b/arch/x86/boot/video-vesa.c
12131 index 11e8c6e..fdbb1ed 100644
12132 --- a/arch/x86/boot/video-vesa.c
12133 +++ b/arch/x86/boot/video-vesa.c
12134 @@ -200,6 +200,7 @@ static void vesa_store_pm_info(void)
12135
12136 boot_params.screen_info.vesapm_seg = oreg.es;
12137 boot_params.screen_info.vesapm_off = oreg.di;
12138 + boot_params.screen_info.vesapm_size = oreg.cx;
12139 }
12140
12141 /*
12142 diff --git a/arch/x86/boot/video.c b/arch/x86/boot/video.c
12143 index 43eda28..5ab5fdb 100644
12144 --- a/arch/x86/boot/video.c
12145 +++ b/arch/x86/boot/video.c
12146 @@ -96,7 +96,7 @@ static void store_mode_params(void)
12147 static unsigned int get_entry(void)
12148 {
12149 char entry_buf[4];
12150 - int i, len = 0;
12151 + unsigned int i, len = 0;
12152 int key;
12153 unsigned int v;
12154
12155 diff --git a/arch/x86/crypto/aes-x86_64-asm_64.S b/arch/x86/crypto/aes-x86_64-asm_64.S
12156 index 9105655..41779c1 100644
12157 --- a/arch/x86/crypto/aes-x86_64-asm_64.S
12158 +++ b/arch/x86/crypto/aes-x86_64-asm_64.S
12159 @@ -8,6 +8,8 @@
12160 * including this sentence is retained in full.
12161 */
12162
12163 +#include <asm/alternative-asm.h>
12164 +
12165 .extern crypto_ft_tab
12166 .extern crypto_it_tab
12167 .extern crypto_fl_tab
12168 @@ -70,6 +72,8 @@
12169 je B192; \
12170 leaq 32(r9),r9;
12171
12172 +#define ret pax_force_retaddr; ret
12173 +
12174 #define epilogue(FUNC,r1,r2,r3,r4,r5,r6,r7,r8,r9) \
12175 movq r1,r2; \
12176 movq r3,r4; \
12177 diff --git a/arch/x86/crypto/aesni-intel_asm.S b/arch/x86/crypto/aesni-intel_asm.S
12178 index 477e9d7..c92c7d8 100644
12179 --- a/arch/x86/crypto/aesni-intel_asm.S
12180 +++ b/arch/x86/crypto/aesni-intel_asm.S
12181 @@ -31,6 +31,7 @@
12182
12183 #include <linux/linkage.h>
12184 #include <asm/inst.h>
12185 +#include <asm/alternative-asm.h>
12186
12187 #ifdef __x86_64__
12188 .data
12189 @@ -205,7 +206,7 @@ enc: .octa 0x2
12190 * num_initial_blocks = b mod 4
12191 * encrypt the initial num_initial_blocks blocks and apply ghash on
12192 * the ciphertext
12193 -* %r10, %r11, %r12, %rax, %xmm5, %xmm6, %xmm7, %xmm8, %xmm9 registers
12194 +* %r10, %r11, %r15, %rax, %xmm5, %xmm6, %xmm7, %xmm8, %xmm9 registers
12195 * are clobbered
12196 * arg1, %arg2, %arg3, %r14 are used as a pointer only, not modified
12197 */
12198 @@ -214,8 +215,8 @@ enc: .octa 0x2
12199 .macro INITIAL_BLOCKS_DEC num_initial_blocks TMP1 TMP2 TMP3 TMP4 TMP5 XMM0 XMM1 \
12200 XMM2 XMM3 XMM4 XMMDst TMP6 TMP7 i i_seq operation
12201 mov arg7, %r10 # %r10 = AAD
12202 - mov arg8, %r12 # %r12 = aadLen
12203 - mov %r12, %r11
12204 + mov arg8, %r15 # %r15 = aadLen
12205 + mov %r15, %r11
12206 pxor %xmm\i, %xmm\i
12207 _get_AAD_loop\num_initial_blocks\operation:
12208 movd (%r10), \TMP1
12209 @@ -223,15 +224,15 @@ _get_AAD_loop\num_initial_blocks\operation:
12210 psrldq $4, %xmm\i
12211 pxor \TMP1, %xmm\i
12212 add $4, %r10
12213 - sub $4, %r12
12214 + sub $4, %r15
12215 jne _get_AAD_loop\num_initial_blocks\operation
12216 cmp $16, %r11
12217 je _get_AAD_loop2_done\num_initial_blocks\operation
12218 - mov $16, %r12
12219 + mov $16, %r15
12220 _get_AAD_loop2\num_initial_blocks\operation:
12221 psrldq $4, %xmm\i
12222 - sub $4, %r12
12223 - cmp %r11, %r12
12224 + sub $4, %r15
12225 + cmp %r11, %r15
12226 jne _get_AAD_loop2\num_initial_blocks\operation
12227 _get_AAD_loop2_done\num_initial_blocks\operation:
12228 movdqa SHUF_MASK(%rip), %xmm14
12229 @@ -443,7 +444,7 @@ _initial_blocks_done\num_initial_blocks\operation:
12230 * num_initial_blocks = b mod 4
12231 * encrypt the initial num_initial_blocks blocks and apply ghash on
12232 * the ciphertext
12233 -* %r10, %r11, %r12, %rax, %xmm5, %xmm6, %xmm7, %xmm8, %xmm9 registers
12234 +* %r10, %r11, %r15, %rax, %xmm5, %xmm6, %xmm7, %xmm8, %xmm9 registers
12235 * are clobbered
12236 * arg1, %arg2, %arg3, %r14 are used as a pointer only, not modified
12237 */
12238 @@ -452,8 +453,8 @@ _initial_blocks_done\num_initial_blocks\operation:
12239 .macro INITIAL_BLOCKS_ENC num_initial_blocks TMP1 TMP2 TMP3 TMP4 TMP5 XMM0 XMM1 \
12240 XMM2 XMM3 XMM4 XMMDst TMP6 TMP7 i i_seq operation
12241 mov arg7, %r10 # %r10 = AAD
12242 - mov arg8, %r12 # %r12 = aadLen
12243 - mov %r12, %r11
12244 + mov arg8, %r15 # %r15 = aadLen
12245 + mov %r15, %r11
12246 pxor %xmm\i, %xmm\i
12247 _get_AAD_loop\num_initial_blocks\operation:
12248 movd (%r10), \TMP1
12249 @@ -461,15 +462,15 @@ _get_AAD_loop\num_initial_blocks\operation:
12250 psrldq $4, %xmm\i
12251 pxor \TMP1, %xmm\i
12252 add $4, %r10
12253 - sub $4, %r12
12254 + sub $4, %r15
12255 jne _get_AAD_loop\num_initial_blocks\operation
12256 cmp $16, %r11
12257 je _get_AAD_loop2_done\num_initial_blocks\operation
12258 - mov $16, %r12
12259 + mov $16, %r15
12260 _get_AAD_loop2\num_initial_blocks\operation:
12261 psrldq $4, %xmm\i
12262 - sub $4, %r12
12263 - cmp %r11, %r12
12264 + sub $4, %r15
12265 + cmp %r11, %r15
12266 jne _get_AAD_loop2\num_initial_blocks\operation
12267 _get_AAD_loop2_done\num_initial_blocks\operation:
12268 movdqa SHUF_MASK(%rip), %xmm14
12269 @@ -1269,7 +1270,7 @@ TMP7 XMM1 XMM2 XMM3 XMM4 XMMDst
12270 *
12271 *****************************************************************************/
12272 ENTRY(aesni_gcm_dec)
12273 - push %r12
12274 + push %r15
12275 push %r13
12276 push %r14
12277 mov %rsp, %r14
12278 @@ -1279,8 +1280,8 @@ ENTRY(aesni_gcm_dec)
12279 */
12280 sub $VARIABLE_OFFSET, %rsp
12281 and $~63, %rsp # align rsp to 64 bytes
12282 - mov %arg6, %r12
12283 - movdqu (%r12), %xmm13 # %xmm13 = HashKey
12284 + mov %arg6, %r15
12285 + movdqu (%r15), %xmm13 # %xmm13 = HashKey
12286 movdqa SHUF_MASK(%rip), %xmm2
12287 PSHUFB_XMM %xmm2, %xmm13
12288
12289 @@ -1308,10 +1309,10 @@ ENTRY(aesni_gcm_dec)
12290 movdqa %xmm13, HashKey(%rsp) # store HashKey<<1 (mod poly)
12291 mov %arg4, %r13 # save the number of bytes of plaintext/ciphertext
12292 and $-16, %r13 # %r13 = %r13 - (%r13 mod 16)
12293 - mov %r13, %r12
12294 - and $(3<<4), %r12
12295 + mov %r13, %r15
12296 + and $(3<<4), %r15
12297 jz _initial_num_blocks_is_0_decrypt
12298 - cmp $(2<<4), %r12
12299 + cmp $(2<<4), %r15
12300 jb _initial_num_blocks_is_1_decrypt
12301 je _initial_num_blocks_is_2_decrypt
12302 _initial_num_blocks_is_3_decrypt:
12303 @@ -1361,16 +1362,16 @@ _zero_cipher_left_decrypt:
12304 sub $16, %r11
12305 add %r13, %r11
12306 movdqu (%arg3,%r11,1), %xmm1 # receive the last <16 byte block
12307 - lea SHIFT_MASK+16(%rip), %r12
12308 - sub %r13, %r12
12309 + lea SHIFT_MASK+16(%rip), %r15
12310 + sub %r13, %r15
12311 # adjust the shuffle mask pointer to be able to shift 16-%r13 bytes
12312 # (%r13 is the number of bytes in plaintext mod 16)
12313 - movdqu (%r12), %xmm2 # get the appropriate shuffle mask
12314 + movdqu (%r15), %xmm2 # get the appropriate shuffle mask
12315 PSHUFB_XMM %xmm2, %xmm1 # right shift 16-%r13 butes
12316
12317 movdqa %xmm1, %xmm2
12318 pxor %xmm1, %xmm0 # Ciphertext XOR E(K, Yn)
12319 - movdqu ALL_F-SHIFT_MASK(%r12), %xmm1
12320 + movdqu ALL_F-SHIFT_MASK(%r15), %xmm1
12321 # get the appropriate mask to mask out top 16-%r13 bytes of %xmm0
12322 pand %xmm1, %xmm0 # mask out top 16-%r13 bytes of %xmm0
12323 pand %xmm1, %xmm2
12324 @@ -1399,9 +1400,9 @@ _less_than_8_bytes_left_decrypt:
12325 sub $1, %r13
12326 jne _less_than_8_bytes_left_decrypt
12327 _multiple_of_16_bytes_decrypt:
12328 - mov arg8, %r12 # %r13 = aadLen (number of bytes)
12329 - shl $3, %r12 # convert into number of bits
12330 - movd %r12d, %xmm15 # len(A) in %xmm15
12331 + mov arg8, %r15 # %r13 = aadLen (number of bytes)
12332 + shl $3, %r15 # convert into number of bits
12333 + movd %r15d, %xmm15 # len(A) in %xmm15
12334 shl $3, %arg4 # len(C) in bits (*128)
12335 MOVQ_R64_XMM %arg4, %xmm1
12336 pslldq $8, %xmm15 # %xmm15 = len(A)||0x0000000000000000
12337 @@ -1440,7 +1441,8 @@ _return_T_done_decrypt:
12338 mov %r14, %rsp
12339 pop %r14
12340 pop %r13
12341 - pop %r12
12342 + pop %r15
12343 + pax_force_retaddr
12344 ret
12345 ENDPROC(aesni_gcm_dec)
12346
12347 @@ -1529,7 +1531,7 @@ ENDPROC(aesni_gcm_dec)
12348 * poly = x^128 + x^127 + x^126 + x^121 + 1
12349 ***************************************************************************/
12350 ENTRY(aesni_gcm_enc)
12351 - push %r12
12352 + push %r15
12353 push %r13
12354 push %r14
12355 mov %rsp, %r14
12356 @@ -1539,8 +1541,8 @@ ENTRY(aesni_gcm_enc)
12357 #
12358 sub $VARIABLE_OFFSET, %rsp
12359 and $~63, %rsp
12360 - mov %arg6, %r12
12361 - movdqu (%r12), %xmm13
12362 + mov %arg6, %r15
12363 + movdqu (%r15), %xmm13
12364 movdqa SHUF_MASK(%rip), %xmm2
12365 PSHUFB_XMM %xmm2, %xmm13
12366
12367 @@ -1564,13 +1566,13 @@ ENTRY(aesni_gcm_enc)
12368 movdqa %xmm13, HashKey(%rsp)
12369 mov %arg4, %r13 # %xmm13 holds HashKey<<1 (mod poly)
12370 and $-16, %r13
12371 - mov %r13, %r12
12372 + mov %r13, %r15
12373
12374 # Encrypt first few blocks
12375
12376 - and $(3<<4), %r12
12377 + and $(3<<4), %r15
12378 jz _initial_num_blocks_is_0_encrypt
12379 - cmp $(2<<4), %r12
12380 + cmp $(2<<4), %r15
12381 jb _initial_num_blocks_is_1_encrypt
12382 je _initial_num_blocks_is_2_encrypt
12383 _initial_num_blocks_is_3_encrypt:
12384 @@ -1623,14 +1625,14 @@ _zero_cipher_left_encrypt:
12385 sub $16, %r11
12386 add %r13, %r11
12387 movdqu (%arg3,%r11,1), %xmm1 # receive the last <16 byte blocks
12388 - lea SHIFT_MASK+16(%rip), %r12
12389 - sub %r13, %r12
12390 + lea SHIFT_MASK+16(%rip), %r15
12391 + sub %r13, %r15
12392 # adjust the shuffle mask pointer to be able to shift 16-r13 bytes
12393 # (%r13 is the number of bytes in plaintext mod 16)
12394 - movdqu (%r12), %xmm2 # get the appropriate shuffle mask
12395 + movdqu (%r15), %xmm2 # get the appropriate shuffle mask
12396 PSHUFB_XMM %xmm2, %xmm1 # shift right 16-r13 byte
12397 pxor %xmm1, %xmm0 # Plaintext XOR Encrypt(K, Yn)
12398 - movdqu ALL_F-SHIFT_MASK(%r12), %xmm1
12399 + movdqu ALL_F-SHIFT_MASK(%r15), %xmm1
12400 # get the appropriate mask to mask out top 16-r13 bytes of xmm0
12401 pand %xmm1, %xmm0 # mask out top 16-r13 bytes of xmm0
12402 movdqa SHUF_MASK(%rip), %xmm10
12403 @@ -1663,9 +1665,9 @@ _less_than_8_bytes_left_encrypt:
12404 sub $1, %r13
12405 jne _less_than_8_bytes_left_encrypt
12406 _multiple_of_16_bytes_encrypt:
12407 - mov arg8, %r12 # %r12 = addLen (number of bytes)
12408 - shl $3, %r12
12409 - movd %r12d, %xmm15 # len(A) in %xmm15
12410 + mov arg8, %r15 # %r15 = addLen (number of bytes)
12411 + shl $3, %r15
12412 + movd %r15d, %xmm15 # len(A) in %xmm15
12413 shl $3, %arg4 # len(C) in bits (*128)
12414 MOVQ_R64_XMM %arg4, %xmm1
12415 pslldq $8, %xmm15 # %xmm15 = len(A)||0x0000000000000000
12416 @@ -1704,7 +1706,8 @@ _return_T_done_encrypt:
12417 mov %r14, %rsp
12418 pop %r14
12419 pop %r13
12420 - pop %r12
12421 + pop %r15
12422 + pax_force_retaddr
12423 ret
12424 ENDPROC(aesni_gcm_enc)
12425
12426 @@ -1722,6 +1725,7 @@ _key_expansion_256a:
12427 pxor %xmm1, %xmm0
12428 movaps %xmm0, (TKEYP)
12429 add $0x10, TKEYP
12430 + pax_force_retaddr
12431 ret
12432 ENDPROC(_key_expansion_128)
12433 ENDPROC(_key_expansion_256a)
12434 @@ -1748,6 +1752,7 @@ _key_expansion_192a:
12435 shufps $0b01001110, %xmm2, %xmm1
12436 movaps %xmm1, 0x10(TKEYP)
12437 add $0x20, TKEYP
12438 + pax_force_retaddr
12439 ret
12440 ENDPROC(_key_expansion_192a)
12441
12442 @@ -1768,6 +1773,7 @@ _key_expansion_192b:
12443
12444 movaps %xmm0, (TKEYP)
12445 add $0x10, TKEYP
12446 + pax_force_retaddr
12447 ret
12448 ENDPROC(_key_expansion_192b)
12449
12450 @@ -1781,6 +1787,7 @@ _key_expansion_256b:
12451 pxor %xmm1, %xmm2
12452 movaps %xmm2, (TKEYP)
12453 add $0x10, TKEYP
12454 + pax_force_retaddr
12455 ret
12456 ENDPROC(_key_expansion_256b)
12457
12458 @@ -1894,6 +1901,7 @@ ENTRY(aesni_set_key)
12459 #ifndef __x86_64__
12460 popl KEYP
12461 #endif
12462 + pax_force_retaddr
12463 ret
12464 ENDPROC(aesni_set_key)
12465
12466 @@ -1916,6 +1924,7 @@ ENTRY(aesni_enc)
12467 popl KLEN
12468 popl KEYP
12469 #endif
12470 + pax_force_retaddr
12471 ret
12472 ENDPROC(aesni_enc)
12473
12474 @@ -1974,6 +1983,7 @@ _aesni_enc1:
12475 AESENC KEY STATE
12476 movaps 0x70(TKEYP), KEY
12477 AESENCLAST KEY STATE
12478 + pax_force_retaddr
12479 ret
12480 ENDPROC(_aesni_enc1)
12481
12482 @@ -2083,6 +2093,7 @@ _aesni_enc4:
12483 AESENCLAST KEY STATE2
12484 AESENCLAST KEY STATE3
12485 AESENCLAST KEY STATE4
12486 + pax_force_retaddr
12487 ret
12488 ENDPROC(_aesni_enc4)
12489
12490 @@ -2106,6 +2117,7 @@ ENTRY(aesni_dec)
12491 popl KLEN
12492 popl KEYP
12493 #endif
12494 + pax_force_retaddr
12495 ret
12496 ENDPROC(aesni_dec)
12497
12498 @@ -2164,6 +2176,7 @@ _aesni_dec1:
12499 AESDEC KEY STATE
12500 movaps 0x70(TKEYP), KEY
12501 AESDECLAST KEY STATE
12502 + pax_force_retaddr
12503 ret
12504 ENDPROC(_aesni_dec1)
12505
12506 @@ -2273,6 +2286,7 @@ _aesni_dec4:
12507 AESDECLAST KEY STATE2
12508 AESDECLAST KEY STATE3
12509 AESDECLAST KEY STATE4
12510 + pax_force_retaddr
12511 ret
12512 ENDPROC(_aesni_dec4)
12513
12514 @@ -2331,6 +2345,7 @@ ENTRY(aesni_ecb_enc)
12515 popl KEYP
12516 popl LEN
12517 #endif
12518 + pax_force_retaddr
12519 ret
12520 ENDPROC(aesni_ecb_enc)
12521
12522 @@ -2390,6 +2405,7 @@ ENTRY(aesni_ecb_dec)
12523 popl KEYP
12524 popl LEN
12525 #endif
12526 + pax_force_retaddr
12527 ret
12528 ENDPROC(aesni_ecb_dec)
12529
12530 @@ -2432,6 +2448,7 @@ ENTRY(aesni_cbc_enc)
12531 popl LEN
12532 popl IVP
12533 #endif
12534 + pax_force_retaddr
12535 ret
12536 ENDPROC(aesni_cbc_enc)
12537
12538 @@ -2523,6 +2540,7 @@ ENTRY(aesni_cbc_dec)
12539 popl LEN
12540 popl IVP
12541 #endif
12542 + pax_force_retaddr
12543 ret
12544 ENDPROC(aesni_cbc_dec)
12545
12546 @@ -2550,6 +2568,7 @@ _aesni_inc_init:
12547 mov $1, TCTR_LOW
12548 MOVQ_R64_XMM TCTR_LOW INC
12549 MOVQ_R64_XMM CTR TCTR_LOW
12550 + pax_force_retaddr
12551 ret
12552 ENDPROC(_aesni_inc_init)
12553
12554 @@ -2579,6 +2598,7 @@ _aesni_inc:
12555 .Linc_low:
12556 movaps CTR, IV
12557 PSHUFB_XMM BSWAP_MASK IV
12558 + pax_force_retaddr
12559 ret
12560 ENDPROC(_aesni_inc)
12561
12562 @@ -2640,6 +2660,7 @@ ENTRY(aesni_ctr_enc)
12563 .Lctr_enc_ret:
12564 movups IV, (IVP)
12565 .Lctr_enc_just_ret:
12566 + pax_force_retaddr
12567 ret
12568 ENDPROC(aesni_ctr_enc)
12569
12570 @@ -2766,6 +2787,7 @@ ENTRY(aesni_xts_crypt8)
12571 pxor INC, STATE4
12572 movdqu STATE4, 0x70(OUTP)
12573
12574 + pax_force_retaddr
12575 ret
12576 ENDPROC(aesni_xts_crypt8)
12577
12578 diff --git a/arch/x86/crypto/blowfish-x86_64-asm_64.S b/arch/x86/crypto/blowfish-x86_64-asm_64.S
12579 index 246c670..466e2d6 100644
12580 --- a/arch/x86/crypto/blowfish-x86_64-asm_64.S
12581 +++ b/arch/x86/crypto/blowfish-x86_64-asm_64.S
12582 @@ -21,6 +21,7 @@
12583 */
12584
12585 #include <linux/linkage.h>
12586 +#include <asm/alternative-asm.h>
12587
12588 .file "blowfish-x86_64-asm.S"
12589 .text
12590 @@ -149,9 +150,11 @@ ENTRY(__blowfish_enc_blk)
12591 jnz .L__enc_xor;
12592
12593 write_block();
12594 + pax_force_retaddr
12595 ret;
12596 .L__enc_xor:
12597 xor_block();
12598 + pax_force_retaddr
12599 ret;
12600 ENDPROC(__blowfish_enc_blk)
12601
12602 @@ -183,6 +186,7 @@ ENTRY(blowfish_dec_blk)
12603
12604 movq %r11, %rbp;
12605
12606 + pax_force_retaddr
12607 ret;
12608 ENDPROC(blowfish_dec_blk)
12609
12610 @@ -334,6 +338,7 @@ ENTRY(__blowfish_enc_blk_4way)
12611
12612 popq %rbx;
12613 popq %rbp;
12614 + pax_force_retaddr
12615 ret;
12616
12617 .L__enc_xor4:
12618 @@ -341,6 +346,7 @@ ENTRY(__blowfish_enc_blk_4way)
12619
12620 popq %rbx;
12621 popq %rbp;
12622 + pax_force_retaddr
12623 ret;
12624 ENDPROC(__blowfish_enc_blk_4way)
12625
12626 @@ -375,5 +381,6 @@ ENTRY(blowfish_dec_blk_4way)
12627 popq %rbx;
12628 popq %rbp;
12629
12630 + pax_force_retaddr
12631 ret;
12632 ENDPROC(blowfish_dec_blk_4way)
12633 diff --git a/arch/x86/crypto/camellia-aesni-avx-asm_64.S b/arch/x86/crypto/camellia-aesni-avx-asm_64.S
12634 index ce71f92..1dce7ec 100644
12635 --- a/arch/x86/crypto/camellia-aesni-avx-asm_64.S
12636 +++ b/arch/x86/crypto/camellia-aesni-avx-asm_64.S
12637 @@ -16,6 +16,7 @@
12638 */
12639
12640 #include <linux/linkage.h>
12641 +#include <asm/alternative-asm.h>
12642
12643 #define CAMELLIA_TABLE_BYTE_LEN 272
12644
12645 @@ -191,6 +192,7 @@ roundsm16_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd:
12646 roundsm16(%xmm0, %xmm1, %xmm2, %xmm3, %xmm4, %xmm5, %xmm6, %xmm7,
12647 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14, %xmm15,
12648 %rcx, (%r9));
12649 + pax_force_retaddr
12650 ret;
12651 ENDPROC(roundsm16_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd)
12652
12653 @@ -199,6 +201,7 @@ roundsm16_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab:
12654 roundsm16(%xmm4, %xmm5, %xmm6, %xmm7, %xmm0, %xmm1, %xmm2, %xmm3,
12655 %xmm12, %xmm13, %xmm14, %xmm15, %xmm8, %xmm9, %xmm10, %xmm11,
12656 %rax, (%r9));
12657 + pax_force_retaddr
12658 ret;
12659 ENDPROC(roundsm16_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab)
12660
12661 @@ -780,6 +783,7 @@ __camellia_enc_blk16:
12662 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14,
12663 %xmm15, (key_table)(CTX, %r8, 8), (%rax), 1 * 16(%rax));
12664
12665 + pax_force_retaddr
12666 ret;
12667
12668 .align 8
12669 @@ -865,6 +869,7 @@ __camellia_dec_blk16:
12670 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14,
12671 %xmm15, (key_table)(CTX), (%rax), 1 * 16(%rax));
12672
12673 + pax_force_retaddr
12674 ret;
12675
12676 .align 8
12677 @@ -904,6 +909,7 @@ ENTRY(camellia_ecb_enc_16way)
12678 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12679 %xmm8, %rsi);
12680
12681 + pax_force_retaddr
12682 ret;
12683 ENDPROC(camellia_ecb_enc_16way)
12684
12685 @@ -932,6 +938,7 @@ ENTRY(camellia_ecb_dec_16way)
12686 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12687 %xmm8, %rsi);
12688
12689 + pax_force_retaddr
12690 ret;
12691 ENDPROC(camellia_ecb_dec_16way)
12692
12693 @@ -981,6 +988,7 @@ ENTRY(camellia_cbc_dec_16way)
12694 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12695 %xmm8, %rsi);
12696
12697 + pax_force_retaddr
12698 ret;
12699 ENDPROC(camellia_cbc_dec_16way)
12700
12701 @@ -1092,6 +1100,7 @@ ENTRY(camellia_ctr_16way)
12702 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12703 %xmm8, %rsi);
12704
12705 + pax_force_retaddr
12706 ret;
12707 ENDPROC(camellia_ctr_16way)
12708
12709 @@ -1234,6 +1243,7 @@ camellia_xts_crypt_16way:
12710 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12711 %xmm8, %rsi);
12712
12713 + pax_force_retaddr
12714 ret;
12715 ENDPROC(camellia_xts_crypt_16way)
12716
12717 diff --git a/arch/x86/crypto/camellia-aesni-avx2-asm_64.S b/arch/x86/crypto/camellia-aesni-avx2-asm_64.S
12718 index 0e0b886..5a3123c 100644
12719 --- a/arch/x86/crypto/camellia-aesni-avx2-asm_64.S
12720 +++ b/arch/x86/crypto/camellia-aesni-avx2-asm_64.S
12721 @@ -11,6 +11,7 @@
12722 */
12723
12724 #include <linux/linkage.h>
12725 +#include <asm/alternative-asm.h>
12726
12727 #define CAMELLIA_TABLE_BYTE_LEN 272
12728
12729 @@ -230,6 +231,7 @@ roundsm32_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd:
12730 roundsm32(%ymm0, %ymm1, %ymm2, %ymm3, %ymm4, %ymm5, %ymm6, %ymm7,
12731 %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14, %ymm15,
12732 %rcx, (%r9));
12733 + pax_force_retaddr
12734 ret;
12735 ENDPROC(roundsm32_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd)
12736
12737 @@ -238,6 +240,7 @@ roundsm32_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab:
12738 roundsm32(%ymm4, %ymm5, %ymm6, %ymm7, %ymm0, %ymm1, %ymm2, %ymm3,
12739 %ymm12, %ymm13, %ymm14, %ymm15, %ymm8, %ymm9, %ymm10, %ymm11,
12740 %rax, (%r9));
12741 + pax_force_retaddr
12742 ret;
12743 ENDPROC(roundsm32_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab)
12744
12745 @@ -820,6 +823,7 @@ __camellia_enc_blk32:
12746 %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14,
12747 %ymm15, (key_table)(CTX, %r8, 8), (%rax), 1 * 32(%rax));
12748
12749 + pax_force_retaddr
12750 ret;
12751
12752 .align 8
12753 @@ -905,6 +909,7 @@ __camellia_dec_blk32:
12754 %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14,
12755 %ymm15, (key_table)(CTX), (%rax), 1 * 32(%rax));
12756
12757 + pax_force_retaddr
12758 ret;
12759
12760 .align 8
12761 @@ -948,6 +953,7 @@ ENTRY(camellia_ecb_enc_32way)
12762
12763 vzeroupper;
12764
12765 + pax_force_retaddr
12766 ret;
12767 ENDPROC(camellia_ecb_enc_32way)
12768
12769 @@ -980,6 +986,7 @@ ENTRY(camellia_ecb_dec_32way)
12770
12771 vzeroupper;
12772
12773 + pax_force_retaddr
12774 ret;
12775 ENDPROC(camellia_ecb_dec_32way)
12776
12777 @@ -1046,6 +1053,7 @@ ENTRY(camellia_cbc_dec_32way)
12778
12779 vzeroupper;
12780
12781 + pax_force_retaddr
12782 ret;
12783 ENDPROC(camellia_cbc_dec_32way)
12784
12785 @@ -1184,6 +1192,7 @@ ENTRY(camellia_ctr_32way)
12786
12787 vzeroupper;
12788
12789 + pax_force_retaddr
12790 ret;
12791 ENDPROC(camellia_ctr_32way)
12792
12793 @@ -1349,6 +1358,7 @@ camellia_xts_crypt_32way:
12794
12795 vzeroupper;
12796
12797 + pax_force_retaddr
12798 ret;
12799 ENDPROC(camellia_xts_crypt_32way)
12800
12801 diff --git a/arch/x86/crypto/camellia-x86_64-asm_64.S b/arch/x86/crypto/camellia-x86_64-asm_64.S
12802 index 310319c..db3d7b5 100644
12803 --- a/arch/x86/crypto/camellia-x86_64-asm_64.S
12804 +++ b/arch/x86/crypto/camellia-x86_64-asm_64.S
12805 @@ -21,6 +21,7 @@
12806 */
12807
12808 #include <linux/linkage.h>
12809 +#include <asm/alternative-asm.h>
12810
12811 .file "camellia-x86_64-asm_64.S"
12812 .text
12813 @@ -228,12 +229,14 @@ ENTRY(__camellia_enc_blk)
12814 enc_outunpack(mov, RT1);
12815
12816 movq RRBP, %rbp;
12817 + pax_force_retaddr
12818 ret;
12819
12820 .L__enc_xor:
12821 enc_outunpack(xor, RT1);
12822
12823 movq RRBP, %rbp;
12824 + pax_force_retaddr
12825 ret;
12826 ENDPROC(__camellia_enc_blk)
12827
12828 @@ -272,6 +275,7 @@ ENTRY(camellia_dec_blk)
12829 dec_outunpack();
12830
12831 movq RRBP, %rbp;
12832 + pax_force_retaddr
12833 ret;
12834 ENDPROC(camellia_dec_blk)
12835
12836 @@ -463,6 +467,7 @@ ENTRY(__camellia_enc_blk_2way)
12837
12838 movq RRBP, %rbp;
12839 popq %rbx;
12840 + pax_force_retaddr
12841 ret;
12842
12843 .L__enc2_xor:
12844 @@ -470,6 +475,7 @@ ENTRY(__camellia_enc_blk_2way)
12845
12846 movq RRBP, %rbp;
12847 popq %rbx;
12848 + pax_force_retaddr
12849 ret;
12850 ENDPROC(__camellia_enc_blk_2way)
12851
12852 @@ -510,5 +516,6 @@ ENTRY(camellia_dec_blk_2way)
12853
12854 movq RRBP, %rbp;
12855 movq RXOR, %rbx;
12856 + pax_force_retaddr
12857 ret;
12858 ENDPROC(camellia_dec_blk_2way)
12859 diff --git a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
12860 index c35fd5d..2d8c7db 100644
12861 --- a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
12862 +++ b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
12863 @@ -24,6 +24,7 @@
12864 */
12865
12866 #include <linux/linkage.h>
12867 +#include <asm/alternative-asm.h>
12868
12869 .file "cast5-avx-x86_64-asm_64.S"
12870
12871 @@ -281,6 +282,7 @@ __cast5_enc_blk16:
12872 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
12873 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
12874
12875 + pax_force_retaddr
12876 ret;
12877 ENDPROC(__cast5_enc_blk16)
12878
12879 @@ -352,6 +354,7 @@ __cast5_dec_blk16:
12880 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
12881 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
12882
12883 + pax_force_retaddr
12884 ret;
12885
12886 .L__skip_dec:
12887 @@ -388,6 +391,7 @@ ENTRY(cast5_ecb_enc_16way)
12888 vmovdqu RR4, (6*4*4)(%r11);
12889 vmovdqu RL4, (7*4*4)(%r11);
12890
12891 + pax_force_retaddr
12892 ret;
12893 ENDPROC(cast5_ecb_enc_16way)
12894
12895 @@ -420,6 +424,7 @@ ENTRY(cast5_ecb_dec_16way)
12896 vmovdqu RR4, (6*4*4)(%r11);
12897 vmovdqu RL4, (7*4*4)(%r11);
12898
12899 + pax_force_retaddr
12900 ret;
12901 ENDPROC(cast5_ecb_dec_16way)
12902
12903 @@ -430,10 +435,10 @@ ENTRY(cast5_cbc_dec_16way)
12904 * %rdx: src
12905 */
12906
12907 - pushq %r12;
12908 + pushq %r14;
12909
12910 movq %rsi, %r11;
12911 - movq %rdx, %r12;
12912 + movq %rdx, %r14;
12913
12914 vmovdqu (0*16)(%rdx), RL1;
12915 vmovdqu (1*16)(%rdx), RR1;
12916 @@ -447,16 +452,16 @@ ENTRY(cast5_cbc_dec_16way)
12917 call __cast5_dec_blk16;
12918
12919 /* xor with src */
12920 - vmovq (%r12), RX;
12921 + vmovq (%r14), RX;
12922 vpshufd $0x4f, RX, RX;
12923 vpxor RX, RR1, RR1;
12924 - vpxor 0*16+8(%r12), RL1, RL1;
12925 - vpxor 1*16+8(%r12), RR2, RR2;
12926 - vpxor 2*16+8(%r12), RL2, RL2;
12927 - vpxor 3*16+8(%r12), RR3, RR3;
12928 - vpxor 4*16+8(%r12), RL3, RL3;
12929 - vpxor 5*16+8(%r12), RR4, RR4;
12930 - vpxor 6*16+8(%r12), RL4, RL4;
12931 + vpxor 0*16+8(%r14), RL1, RL1;
12932 + vpxor 1*16+8(%r14), RR2, RR2;
12933 + vpxor 2*16+8(%r14), RL2, RL2;
12934 + vpxor 3*16+8(%r14), RR3, RR3;
12935 + vpxor 4*16+8(%r14), RL3, RL3;
12936 + vpxor 5*16+8(%r14), RR4, RR4;
12937 + vpxor 6*16+8(%r14), RL4, RL4;
12938
12939 vmovdqu RR1, (0*16)(%r11);
12940 vmovdqu RL1, (1*16)(%r11);
12941 @@ -467,8 +472,9 @@ ENTRY(cast5_cbc_dec_16way)
12942 vmovdqu RR4, (6*16)(%r11);
12943 vmovdqu RL4, (7*16)(%r11);
12944
12945 - popq %r12;
12946 + popq %r14;
12947
12948 + pax_force_retaddr
12949 ret;
12950 ENDPROC(cast5_cbc_dec_16way)
12951
12952 @@ -480,10 +486,10 @@ ENTRY(cast5_ctr_16way)
12953 * %rcx: iv (big endian, 64bit)
12954 */
12955
12956 - pushq %r12;
12957 + pushq %r14;
12958
12959 movq %rsi, %r11;
12960 - movq %rdx, %r12;
12961 + movq %rdx, %r14;
12962
12963 vpcmpeqd RTMP, RTMP, RTMP;
12964 vpsrldq $8, RTMP, RTMP; /* low: -1, high: 0 */
12965 @@ -523,14 +529,14 @@ ENTRY(cast5_ctr_16way)
12966 call __cast5_enc_blk16;
12967
12968 /* dst = src ^ iv */
12969 - vpxor (0*16)(%r12), RR1, RR1;
12970 - vpxor (1*16)(%r12), RL1, RL1;
12971 - vpxor (2*16)(%r12), RR2, RR2;
12972 - vpxor (3*16)(%r12), RL2, RL2;
12973 - vpxor (4*16)(%r12), RR3, RR3;
12974 - vpxor (5*16)(%r12), RL3, RL3;
12975 - vpxor (6*16)(%r12), RR4, RR4;
12976 - vpxor (7*16)(%r12), RL4, RL4;
12977 + vpxor (0*16)(%r14), RR1, RR1;
12978 + vpxor (1*16)(%r14), RL1, RL1;
12979 + vpxor (2*16)(%r14), RR2, RR2;
12980 + vpxor (3*16)(%r14), RL2, RL2;
12981 + vpxor (4*16)(%r14), RR3, RR3;
12982 + vpxor (5*16)(%r14), RL3, RL3;
12983 + vpxor (6*16)(%r14), RR4, RR4;
12984 + vpxor (7*16)(%r14), RL4, RL4;
12985 vmovdqu RR1, (0*16)(%r11);
12986 vmovdqu RL1, (1*16)(%r11);
12987 vmovdqu RR2, (2*16)(%r11);
12988 @@ -540,7 +546,8 @@ ENTRY(cast5_ctr_16way)
12989 vmovdqu RR4, (6*16)(%r11);
12990 vmovdqu RL4, (7*16)(%r11);
12991
12992 - popq %r12;
12993 + popq %r14;
12994
12995 + pax_force_retaddr
12996 ret;
12997 ENDPROC(cast5_ctr_16way)
12998 diff --git a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
12999 index e3531f8..e123f35 100644
13000 --- a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
13001 +++ b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
13002 @@ -24,6 +24,7 @@
13003 */
13004
13005 #include <linux/linkage.h>
13006 +#include <asm/alternative-asm.h>
13007 #include "glue_helper-asm-avx.S"
13008
13009 .file "cast6-avx-x86_64-asm_64.S"
13010 @@ -295,6 +296,7 @@ __cast6_enc_blk8:
13011 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
13012 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
13013
13014 + pax_force_retaddr
13015 ret;
13016 ENDPROC(__cast6_enc_blk8)
13017
13018 @@ -340,6 +342,7 @@ __cast6_dec_blk8:
13019 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
13020 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
13021
13022 + pax_force_retaddr
13023 ret;
13024 ENDPROC(__cast6_dec_blk8)
13025
13026 @@ -358,6 +361,7 @@ ENTRY(cast6_ecb_enc_8way)
13027
13028 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13029
13030 + pax_force_retaddr
13031 ret;
13032 ENDPROC(cast6_ecb_enc_8way)
13033
13034 @@ -376,6 +380,7 @@ ENTRY(cast6_ecb_dec_8way)
13035
13036 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13037
13038 + pax_force_retaddr
13039 ret;
13040 ENDPROC(cast6_ecb_dec_8way)
13041
13042 @@ -386,19 +391,20 @@ ENTRY(cast6_cbc_dec_8way)
13043 * %rdx: src
13044 */
13045
13046 - pushq %r12;
13047 + pushq %r14;
13048
13049 movq %rsi, %r11;
13050 - movq %rdx, %r12;
13051 + movq %rdx, %r14;
13052
13053 load_8way(%rdx, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13054
13055 call __cast6_dec_blk8;
13056
13057 - store_cbc_8way(%r12, %r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13058 + store_cbc_8way(%r14, %r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13059
13060 - popq %r12;
13061 + popq %r14;
13062
13063 + pax_force_retaddr
13064 ret;
13065 ENDPROC(cast6_cbc_dec_8way)
13066
13067 @@ -410,20 +416,21 @@ ENTRY(cast6_ctr_8way)
13068 * %rcx: iv (little endian, 128bit)
13069 */
13070
13071 - pushq %r12;
13072 + pushq %r14;
13073
13074 movq %rsi, %r11;
13075 - movq %rdx, %r12;
13076 + movq %rdx, %r14;
13077
13078 load_ctr_8way(%rcx, .Lbswap128_mask, RA1, RB1, RC1, RD1, RA2, RB2, RC2,
13079 RD2, RX, RKR, RKM);
13080
13081 call __cast6_enc_blk8;
13082
13083 - store_ctr_8way(%r12, %r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13084 + store_ctr_8way(%r14, %r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13085
13086 - popq %r12;
13087 + popq %r14;
13088
13089 + pax_force_retaddr
13090 ret;
13091 ENDPROC(cast6_ctr_8way)
13092
13093 @@ -446,6 +453,7 @@ ENTRY(cast6_xts_enc_8way)
13094 /* dst <= regs xor IVs(in dst) */
13095 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13096
13097 + pax_force_retaddr
13098 ret;
13099 ENDPROC(cast6_xts_enc_8way)
13100
13101 @@ -468,5 +476,6 @@ ENTRY(cast6_xts_dec_8way)
13102 /* dst <= regs xor IVs(in dst) */
13103 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13104
13105 + pax_force_retaddr
13106 ret;
13107 ENDPROC(cast6_xts_dec_8way)
13108 diff --git a/arch/x86/crypto/crc32c-pcl-intel-asm_64.S b/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
13109 index dbc4339..de6e120 100644
13110 --- a/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
13111 +++ b/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
13112 @@ -45,6 +45,7 @@
13113
13114 #include <asm/inst.h>
13115 #include <linux/linkage.h>
13116 +#include <asm/alternative-asm.h>
13117
13118 ## ISCSI CRC 32 Implementation with crc32 and pclmulqdq Instruction
13119
13120 @@ -312,6 +313,7 @@ do_return:
13121 popq %rsi
13122 popq %rdi
13123 popq %rbx
13124 + pax_force_retaddr
13125 ret
13126
13127 ################################################################
13128 diff --git a/arch/x86/crypto/ghash-clmulni-intel_asm.S b/arch/x86/crypto/ghash-clmulni-intel_asm.S
13129 index 586f41a..d02851e 100644
13130 --- a/arch/x86/crypto/ghash-clmulni-intel_asm.S
13131 +++ b/arch/x86/crypto/ghash-clmulni-intel_asm.S
13132 @@ -18,6 +18,7 @@
13133
13134 #include <linux/linkage.h>
13135 #include <asm/inst.h>
13136 +#include <asm/alternative-asm.h>
13137
13138 .data
13139
13140 @@ -93,6 +94,7 @@ __clmul_gf128mul_ble:
13141 psrlq $1, T2
13142 pxor T2, T1
13143 pxor T1, DATA
13144 + pax_force_retaddr
13145 ret
13146 ENDPROC(__clmul_gf128mul_ble)
13147
13148 @@ -105,6 +107,7 @@ ENTRY(clmul_ghash_mul)
13149 call __clmul_gf128mul_ble
13150 PSHUFB_XMM BSWAP DATA
13151 movups DATA, (%rdi)
13152 + pax_force_retaddr
13153 ret
13154 ENDPROC(clmul_ghash_mul)
13155
13156 @@ -132,6 +135,7 @@ ENTRY(clmul_ghash_update)
13157 PSHUFB_XMM BSWAP DATA
13158 movups DATA, (%rdi)
13159 .Lupdate_just_ret:
13160 + pax_force_retaddr
13161 ret
13162 ENDPROC(clmul_ghash_update)
13163
13164 @@ -157,5 +161,6 @@ ENTRY(clmul_ghash_setkey)
13165 pand .Lpoly, %xmm1
13166 pxor %xmm1, %xmm0
13167 movups %xmm0, (%rdi)
13168 + pax_force_retaddr
13169 ret
13170 ENDPROC(clmul_ghash_setkey)
13171 diff --git a/arch/x86/crypto/salsa20-x86_64-asm_64.S b/arch/x86/crypto/salsa20-x86_64-asm_64.S
13172 index 9279e0b..c4b3d2c 100644
13173 --- a/arch/x86/crypto/salsa20-x86_64-asm_64.S
13174 +++ b/arch/x86/crypto/salsa20-x86_64-asm_64.S
13175 @@ -1,4 +1,5 @@
13176 #include <linux/linkage.h>
13177 +#include <asm/alternative-asm.h>
13178
13179 # enter salsa20_encrypt_bytes
13180 ENTRY(salsa20_encrypt_bytes)
13181 @@ -789,6 +790,7 @@ ENTRY(salsa20_encrypt_bytes)
13182 add %r11,%rsp
13183 mov %rdi,%rax
13184 mov %rsi,%rdx
13185 + pax_force_retaddr
13186 ret
13187 # bytesatleast65:
13188 ._bytesatleast65:
13189 @@ -889,6 +891,7 @@ ENTRY(salsa20_keysetup)
13190 add %r11,%rsp
13191 mov %rdi,%rax
13192 mov %rsi,%rdx
13193 + pax_force_retaddr
13194 ret
13195 ENDPROC(salsa20_keysetup)
13196
13197 @@ -914,5 +917,6 @@ ENTRY(salsa20_ivsetup)
13198 add %r11,%rsp
13199 mov %rdi,%rax
13200 mov %rsi,%rdx
13201 + pax_force_retaddr
13202 ret
13203 ENDPROC(salsa20_ivsetup)
13204 diff --git a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
13205 index 2f202f4..d9164d6 100644
13206 --- a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
13207 +++ b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
13208 @@ -24,6 +24,7 @@
13209 */
13210
13211 #include <linux/linkage.h>
13212 +#include <asm/alternative-asm.h>
13213 #include "glue_helper-asm-avx.S"
13214
13215 .file "serpent-avx-x86_64-asm_64.S"
13216 @@ -618,6 +619,7 @@ __serpent_enc_blk8_avx:
13217 write_blocks(RA1, RB1, RC1, RD1, RK0, RK1, RK2);
13218 write_blocks(RA2, RB2, RC2, RD2, RK0, RK1, RK2);
13219
13220 + pax_force_retaddr
13221 ret;
13222 ENDPROC(__serpent_enc_blk8_avx)
13223
13224 @@ -672,6 +674,7 @@ __serpent_dec_blk8_avx:
13225 write_blocks(RC1, RD1, RB1, RE1, RK0, RK1, RK2);
13226 write_blocks(RC2, RD2, RB2, RE2, RK0, RK1, RK2);
13227
13228 + pax_force_retaddr
13229 ret;
13230 ENDPROC(__serpent_dec_blk8_avx)
13231
13232 @@ -688,6 +691,7 @@ ENTRY(serpent_ecb_enc_8way_avx)
13233
13234 store_8way(%rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13235
13236 + pax_force_retaddr
13237 ret;
13238 ENDPROC(serpent_ecb_enc_8way_avx)
13239
13240 @@ -704,6 +708,7 @@ ENTRY(serpent_ecb_dec_8way_avx)
13241
13242 store_8way(%rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
13243
13244 + pax_force_retaddr
13245 ret;
13246 ENDPROC(serpent_ecb_dec_8way_avx)
13247
13248 @@ -720,6 +725,7 @@ ENTRY(serpent_cbc_dec_8way_avx)
13249
13250 store_cbc_8way(%rdx, %rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
13251
13252 + pax_force_retaddr
13253 ret;
13254 ENDPROC(serpent_cbc_dec_8way_avx)
13255
13256 @@ -738,6 +744,7 @@ ENTRY(serpent_ctr_8way_avx)
13257
13258 store_ctr_8way(%rdx, %rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13259
13260 + pax_force_retaddr
13261 ret;
13262 ENDPROC(serpent_ctr_8way_avx)
13263
13264 @@ -758,6 +765,7 @@ ENTRY(serpent_xts_enc_8way_avx)
13265 /* dst <= regs xor IVs(in dst) */
13266 store_xts_8way(%rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13267
13268 + pax_force_retaddr
13269 ret;
13270 ENDPROC(serpent_xts_enc_8way_avx)
13271
13272 @@ -778,5 +786,6 @@ ENTRY(serpent_xts_dec_8way_avx)
13273 /* dst <= regs xor IVs(in dst) */
13274 store_xts_8way(%rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
13275
13276 + pax_force_retaddr
13277 ret;
13278 ENDPROC(serpent_xts_dec_8way_avx)
13279 diff --git a/arch/x86/crypto/serpent-avx2-asm_64.S b/arch/x86/crypto/serpent-avx2-asm_64.S
13280 index b222085..abd483c 100644
13281 --- a/arch/x86/crypto/serpent-avx2-asm_64.S
13282 +++ b/arch/x86/crypto/serpent-avx2-asm_64.S
13283 @@ -15,6 +15,7 @@
13284 */
13285
13286 #include <linux/linkage.h>
13287 +#include <asm/alternative-asm.h>
13288 #include "glue_helper-asm-avx2.S"
13289
13290 .file "serpent-avx2-asm_64.S"
13291 @@ -610,6 +611,7 @@ __serpent_enc_blk16:
13292 write_blocks(RA1, RB1, RC1, RD1, RK0, RK1, RK2);
13293 write_blocks(RA2, RB2, RC2, RD2, RK0, RK1, RK2);
13294
13295 + pax_force_retaddr
13296 ret;
13297 ENDPROC(__serpent_enc_blk16)
13298
13299 @@ -664,6 +666,7 @@ __serpent_dec_blk16:
13300 write_blocks(RC1, RD1, RB1, RE1, RK0, RK1, RK2);
13301 write_blocks(RC2, RD2, RB2, RE2, RK0, RK1, RK2);
13302
13303 + pax_force_retaddr
13304 ret;
13305 ENDPROC(__serpent_dec_blk16)
13306
13307 @@ -684,6 +687,7 @@ ENTRY(serpent_ecb_enc_16way)
13308
13309 vzeroupper;
13310
13311 + pax_force_retaddr
13312 ret;
13313 ENDPROC(serpent_ecb_enc_16way)
13314
13315 @@ -704,6 +708,7 @@ ENTRY(serpent_ecb_dec_16way)
13316
13317 vzeroupper;
13318
13319 + pax_force_retaddr
13320 ret;
13321 ENDPROC(serpent_ecb_dec_16way)
13322
13323 @@ -725,6 +730,7 @@ ENTRY(serpent_cbc_dec_16way)
13324
13325 vzeroupper;
13326
13327 + pax_force_retaddr
13328 ret;
13329 ENDPROC(serpent_cbc_dec_16way)
13330
13331 @@ -748,6 +754,7 @@ ENTRY(serpent_ctr_16way)
13332
13333 vzeroupper;
13334
13335 + pax_force_retaddr
13336 ret;
13337 ENDPROC(serpent_ctr_16way)
13338
13339 @@ -772,6 +779,7 @@ ENTRY(serpent_xts_enc_16way)
13340
13341 vzeroupper;
13342
13343 + pax_force_retaddr
13344 ret;
13345 ENDPROC(serpent_xts_enc_16way)
13346
13347 @@ -796,5 +804,6 @@ ENTRY(serpent_xts_dec_16way)
13348
13349 vzeroupper;
13350
13351 + pax_force_retaddr
13352 ret;
13353 ENDPROC(serpent_xts_dec_16way)
13354 diff --git a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
13355 index acc066c..1559cc4 100644
13356 --- a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
13357 +++ b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
13358 @@ -25,6 +25,7 @@
13359 */
13360
13361 #include <linux/linkage.h>
13362 +#include <asm/alternative-asm.h>
13363
13364 .file "serpent-sse2-x86_64-asm_64.S"
13365 .text
13366 @@ -690,12 +691,14 @@ ENTRY(__serpent_enc_blk_8way)
13367 write_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
13368 write_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
13369
13370 + pax_force_retaddr
13371 ret;
13372
13373 .L__enc_xor8:
13374 xor_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
13375 xor_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
13376
13377 + pax_force_retaddr
13378 ret;
13379 ENDPROC(__serpent_enc_blk_8way)
13380
13381 @@ -750,5 +753,6 @@ ENTRY(serpent_dec_blk_8way)
13382 write_blocks(%rsi, RC1, RD1, RB1, RE1, RK0, RK1, RK2);
13383 write_blocks(%rax, RC2, RD2, RB2, RE2, RK0, RK1, RK2);
13384
13385 + pax_force_retaddr
13386 ret;
13387 ENDPROC(serpent_dec_blk_8way)
13388 diff --git a/arch/x86/crypto/sha1_ssse3_asm.S b/arch/x86/crypto/sha1_ssse3_asm.S
13389 index a410950..9dfe7ad 100644
13390 --- a/arch/x86/crypto/sha1_ssse3_asm.S
13391 +++ b/arch/x86/crypto/sha1_ssse3_asm.S
13392 @@ -29,6 +29,7 @@
13393 */
13394
13395 #include <linux/linkage.h>
13396 +#include <asm/alternative-asm.h>
13397
13398 #define CTX %rdi // arg1
13399 #define BUF %rsi // arg2
13400 @@ -75,9 +76,9 @@
13401
13402 push %rbx
13403 push %rbp
13404 - push %r12
13405 + push %r14
13406
13407 - mov %rsp, %r12
13408 + mov %rsp, %r14
13409 sub $64, %rsp # allocate workspace
13410 and $~15, %rsp # align stack
13411
13412 @@ -99,11 +100,12 @@
13413 xor %rax, %rax
13414 rep stosq
13415
13416 - mov %r12, %rsp # deallocate workspace
13417 + mov %r14, %rsp # deallocate workspace
13418
13419 - pop %r12
13420 + pop %r14
13421 pop %rbp
13422 pop %rbx
13423 + pax_force_retaddr
13424 ret
13425
13426 ENDPROC(\name)
13427 diff --git a/arch/x86/crypto/sha256-avx-asm.S b/arch/x86/crypto/sha256-avx-asm.S
13428 index 642f156..51a513c 100644
13429 --- a/arch/x86/crypto/sha256-avx-asm.S
13430 +++ b/arch/x86/crypto/sha256-avx-asm.S
13431 @@ -49,6 +49,7 @@
13432
13433 #ifdef CONFIG_AS_AVX
13434 #include <linux/linkage.h>
13435 +#include <asm/alternative-asm.h>
13436
13437 ## assume buffers not aligned
13438 #define VMOVDQ vmovdqu
13439 @@ -460,6 +461,7 @@ done_hash:
13440 popq %r13
13441 popq %rbp
13442 popq %rbx
13443 + pax_force_retaddr
13444 ret
13445 ENDPROC(sha256_transform_avx)
13446
13447 diff --git a/arch/x86/crypto/sha256-avx2-asm.S b/arch/x86/crypto/sha256-avx2-asm.S
13448 index 9e86944..3795e6a 100644
13449 --- a/arch/x86/crypto/sha256-avx2-asm.S
13450 +++ b/arch/x86/crypto/sha256-avx2-asm.S
13451 @@ -50,6 +50,7 @@
13452
13453 #ifdef CONFIG_AS_AVX2
13454 #include <linux/linkage.h>
13455 +#include <asm/alternative-asm.h>
13456
13457 ## assume buffers not aligned
13458 #define VMOVDQ vmovdqu
13459 @@ -720,6 +721,7 @@ done_hash:
13460 popq %r12
13461 popq %rbp
13462 popq %rbx
13463 + pax_force_retaddr
13464 ret
13465 ENDPROC(sha256_transform_rorx)
13466
13467 diff --git a/arch/x86/crypto/sha256-ssse3-asm.S b/arch/x86/crypto/sha256-ssse3-asm.S
13468 index f833b74..8c62a9e 100644
13469 --- a/arch/x86/crypto/sha256-ssse3-asm.S
13470 +++ b/arch/x86/crypto/sha256-ssse3-asm.S
13471 @@ -47,6 +47,7 @@
13472 ########################################################################
13473
13474 #include <linux/linkage.h>
13475 +#include <asm/alternative-asm.h>
13476
13477 ## assume buffers not aligned
13478 #define MOVDQ movdqu
13479 @@ -471,6 +472,7 @@ done_hash:
13480 popq %rbp
13481 popq %rbx
13482
13483 + pax_force_retaddr
13484 ret
13485 ENDPROC(sha256_transform_ssse3)
13486
13487 diff --git a/arch/x86/crypto/sha512-avx-asm.S b/arch/x86/crypto/sha512-avx-asm.S
13488 index 974dde9..a823ff9 100644
13489 --- a/arch/x86/crypto/sha512-avx-asm.S
13490 +++ b/arch/x86/crypto/sha512-avx-asm.S
13491 @@ -49,6 +49,7 @@
13492
13493 #ifdef CONFIG_AS_AVX
13494 #include <linux/linkage.h>
13495 +#include <asm/alternative-asm.h>
13496
13497 .text
13498
13499 @@ -364,6 +365,7 @@ updateblock:
13500 mov frame_RSPSAVE(%rsp), %rsp
13501
13502 nowork:
13503 + pax_force_retaddr
13504 ret
13505 ENDPROC(sha512_transform_avx)
13506
13507 diff --git a/arch/x86/crypto/sha512-avx2-asm.S b/arch/x86/crypto/sha512-avx2-asm.S
13508 index 568b961..ed20c37 100644
13509 --- a/arch/x86/crypto/sha512-avx2-asm.S
13510 +++ b/arch/x86/crypto/sha512-avx2-asm.S
13511 @@ -51,6 +51,7 @@
13512
13513 #ifdef CONFIG_AS_AVX2
13514 #include <linux/linkage.h>
13515 +#include <asm/alternative-asm.h>
13516
13517 .text
13518
13519 @@ -678,6 +679,7 @@ done_hash:
13520
13521 # Restore Stack Pointer
13522 mov frame_RSPSAVE(%rsp), %rsp
13523 + pax_force_retaddr
13524 ret
13525 ENDPROC(sha512_transform_rorx)
13526
13527 diff --git a/arch/x86/crypto/sha512-ssse3-asm.S b/arch/x86/crypto/sha512-ssse3-asm.S
13528 index fb56855..6edd768 100644
13529 --- a/arch/x86/crypto/sha512-ssse3-asm.S
13530 +++ b/arch/x86/crypto/sha512-ssse3-asm.S
13531 @@ -48,6 +48,7 @@
13532 ########################################################################
13533
13534 #include <linux/linkage.h>
13535 +#include <asm/alternative-asm.h>
13536
13537 .text
13538
13539 @@ -363,6 +364,7 @@ updateblock:
13540 mov frame_RSPSAVE(%rsp), %rsp
13541
13542 nowork:
13543 + pax_force_retaddr
13544 ret
13545 ENDPROC(sha512_transform_ssse3)
13546
13547 diff --git a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
13548 index 0505813..b067311 100644
13549 --- a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
13550 +++ b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
13551 @@ -24,6 +24,7 @@
13552 */
13553
13554 #include <linux/linkage.h>
13555 +#include <asm/alternative-asm.h>
13556 #include "glue_helper-asm-avx.S"
13557
13558 .file "twofish-avx-x86_64-asm_64.S"
13559 @@ -284,6 +285,7 @@ __twofish_enc_blk8:
13560 outunpack_blocks(RC1, RD1, RA1, RB1, RK1, RX0, RY0, RK2);
13561 outunpack_blocks(RC2, RD2, RA2, RB2, RK1, RX0, RY0, RK2);
13562
13563 + pax_force_retaddr
13564 ret;
13565 ENDPROC(__twofish_enc_blk8)
13566
13567 @@ -324,6 +326,7 @@ __twofish_dec_blk8:
13568 outunpack_blocks(RA1, RB1, RC1, RD1, RK1, RX0, RY0, RK2);
13569 outunpack_blocks(RA2, RB2, RC2, RD2, RK1, RX0, RY0, RK2);
13570
13571 + pax_force_retaddr
13572 ret;
13573 ENDPROC(__twofish_dec_blk8)
13574
13575 @@ -342,6 +345,7 @@ ENTRY(twofish_ecb_enc_8way)
13576
13577 store_8way(%r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
13578
13579 + pax_force_retaddr
13580 ret;
13581 ENDPROC(twofish_ecb_enc_8way)
13582
13583 @@ -360,6 +364,7 @@ ENTRY(twofish_ecb_dec_8way)
13584
13585 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13586
13587 + pax_force_retaddr
13588 ret;
13589 ENDPROC(twofish_ecb_dec_8way)
13590
13591 @@ -370,19 +375,20 @@ ENTRY(twofish_cbc_dec_8way)
13592 * %rdx: src
13593 */
13594
13595 - pushq %r12;
13596 + pushq %r14;
13597
13598 movq %rsi, %r11;
13599 - movq %rdx, %r12;
13600 + movq %rdx, %r14;
13601
13602 load_8way(%rdx, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
13603
13604 call __twofish_dec_blk8;
13605
13606 - store_cbc_8way(%r12, %r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13607 + store_cbc_8way(%r14, %r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13608
13609 - popq %r12;
13610 + popq %r14;
13611
13612 + pax_force_retaddr
13613 ret;
13614 ENDPROC(twofish_cbc_dec_8way)
13615
13616 @@ -394,20 +400,21 @@ ENTRY(twofish_ctr_8way)
13617 * %rcx: iv (little endian, 128bit)
13618 */
13619
13620 - pushq %r12;
13621 + pushq %r14;
13622
13623 movq %rsi, %r11;
13624 - movq %rdx, %r12;
13625 + movq %rdx, %r14;
13626
13627 load_ctr_8way(%rcx, .Lbswap128_mask, RA1, RB1, RC1, RD1, RA2, RB2, RC2,
13628 RD2, RX0, RX1, RY0);
13629
13630 call __twofish_enc_blk8;
13631
13632 - store_ctr_8way(%r12, %r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
13633 + store_ctr_8way(%r14, %r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
13634
13635 - popq %r12;
13636 + popq %r14;
13637
13638 + pax_force_retaddr
13639 ret;
13640 ENDPROC(twofish_ctr_8way)
13641
13642 @@ -430,6 +437,7 @@ ENTRY(twofish_xts_enc_8way)
13643 /* dst <= regs xor IVs(in dst) */
13644 store_xts_8way(%r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
13645
13646 + pax_force_retaddr
13647 ret;
13648 ENDPROC(twofish_xts_enc_8way)
13649
13650 @@ -452,5 +460,6 @@ ENTRY(twofish_xts_dec_8way)
13651 /* dst <= regs xor IVs(in dst) */
13652 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13653
13654 + pax_force_retaddr
13655 ret;
13656 ENDPROC(twofish_xts_dec_8way)
13657 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
13658 index 1c3b7ce..02f578d 100644
13659 --- a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
13660 +++ b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
13661 @@ -21,6 +21,7 @@
13662 */
13663
13664 #include <linux/linkage.h>
13665 +#include <asm/alternative-asm.h>
13666
13667 .file "twofish-x86_64-asm-3way.S"
13668 .text
13669 @@ -258,6 +259,7 @@ ENTRY(__twofish_enc_blk_3way)
13670 popq %r13;
13671 popq %r14;
13672 popq %r15;
13673 + pax_force_retaddr
13674 ret;
13675
13676 .L__enc_xor3:
13677 @@ -269,6 +271,7 @@ ENTRY(__twofish_enc_blk_3way)
13678 popq %r13;
13679 popq %r14;
13680 popq %r15;
13681 + pax_force_retaddr
13682 ret;
13683 ENDPROC(__twofish_enc_blk_3way)
13684
13685 @@ -308,5 +311,6 @@ ENTRY(twofish_dec_blk_3way)
13686 popq %r13;
13687 popq %r14;
13688 popq %r15;
13689 + pax_force_retaddr
13690 ret;
13691 ENDPROC(twofish_dec_blk_3way)
13692 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64.S b/arch/x86/crypto/twofish-x86_64-asm_64.S
13693 index a039d21..524b8b2 100644
13694 --- a/arch/x86/crypto/twofish-x86_64-asm_64.S
13695 +++ b/arch/x86/crypto/twofish-x86_64-asm_64.S
13696 @@ -22,6 +22,7 @@
13697
13698 #include <linux/linkage.h>
13699 #include <asm/asm-offsets.h>
13700 +#include <asm/alternative-asm.h>
13701
13702 #define a_offset 0
13703 #define b_offset 4
13704 @@ -265,6 +266,7 @@ ENTRY(twofish_enc_blk)
13705
13706 popq R1
13707 movq $1,%rax
13708 + pax_force_retaddr
13709 ret
13710 ENDPROC(twofish_enc_blk)
13711
13712 @@ -317,5 +319,6 @@ ENTRY(twofish_dec_blk)
13713
13714 popq R1
13715 movq $1,%rax
13716 + pax_force_retaddr
13717 ret
13718 ENDPROC(twofish_dec_blk)
13719 diff --git a/arch/x86/ia32/ia32_aout.c b/arch/x86/ia32/ia32_aout.c
13720 index bae3aba..c1788c1 100644
13721 --- a/arch/x86/ia32/ia32_aout.c
13722 +++ b/arch/x86/ia32/ia32_aout.c
13723 @@ -159,6 +159,8 @@ static int aout_core_dump(long signr, struct pt_regs *regs, struct file *file,
13724 unsigned long dump_start, dump_size;
13725 struct user32 dump;
13726
13727 + memset(&dump, 0, sizeof(dump));
13728 +
13729 fs = get_fs();
13730 set_fs(KERNEL_DS);
13731 has_dumped = 1;
13732 diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c
13733 index 665a730..8e7a67a 100644
13734 --- a/arch/x86/ia32/ia32_signal.c
13735 +++ b/arch/x86/ia32/ia32_signal.c
13736 @@ -338,7 +338,7 @@ static void __user *get_sigframe(struct ksignal *ksig, struct pt_regs *regs,
13737 sp -= frame_size;
13738 /* Align the stack pointer according to the i386 ABI,
13739 * i.e. so that on function entry ((sp + 4) & 15) == 0. */
13740 - sp = ((sp + 4) & -16ul) - 4;
13741 + sp = ((sp - 12) & -16ul) - 4;
13742 return (void __user *) sp;
13743 }
13744
13745 @@ -396,7 +396,7 @@ int ia32_setup_frame(int sig, struct ksignal *ksig,
13746 * These are actually not used anymore, but left because some
13747 * gdb versions depend on them as a marker.
13748 */
13749 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
13750 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
13751 } put_user_catch(err);
13752
13753 if (err)
13754 @@ -438,7 +438,7 @@ int ia32_setup_rt_frame(int sig, struct ksignal *ksig,
13755 0xb8,
13756 __NR_ia32_rt_sigreturn,
13757 0x80cd,
13758 - 0,
13759 + 0
13760 };
13761
13762 frame = get_sigframe(ksig, regs, sizeof(*frame), &fpstate);
13763 @@ -461,16 +461,18 @@ int ia32_setup_rt_frame(int sig, struct ksignal *ksig,
13764
13765 if (ksig->ka.sa.sa_flags & SA_RESTORER)
13766 restorer = ksig->ka.sa.sa_restorer;
13767 + else if (current->mm->context.vdso)
13768 + /* Return stub is in 32bit vsyscall page */
13769 + restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
13770 else
13771 - restorer = VDSO32_SYMBOL(current->mm->context.vdso,
13772 - rt_sigreturn);
13773 + restorer = &frame->retcode;
13774 put_user_ex(ptr_to_compat(restorer), &frame->pretcode);
13775
13776 /*
13777 * Not actually used anymore, but left because some gdb
13778 * versions need it.
13779 */
13780 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
13781 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
13782 } put_user_catch(err);
13783
13784 err |= copy_siginfo_to_user32(&frame->info, &ksig->info);
13785 diff --git a/arch/x86/ia32/ia32entry.S b/arch/x86/ia32/ia32entry.S
13786 index 4299eb0..c0687a7 100644
13787 --- a/arch/x86/ia32/ia32entry.S
13788 +++ b/arch/x86/ia32/ia32entry.S
13789 @@ -15,8 +15,10 @@
13790 #include <asm/irqflags.h>
13791 #include <asm/asm.h>
13792 #include <asm/smap.h>
13793 +#include <asm/pgtable.h>
13794 #include <linux/linkage.h>
13795 #include <linux/err.h>
13796 +#include <asm/alternative-asm.h>
13797
13798 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
13799 #include <linux/elf-em.h>
13800 @@ -62,12 +64,12 @@
13801 */
13802 .macro LOAD_ARGS32 offset, _r9=0
13803 .if \_r9
13804 - movl \offset+16(%rsp),%r9d
13805 + movl \offset+R9(%rsp),%r9d
13806 .endif
13807 - movl \offset+40(%rsp),%ecx
13808 - movl \offset+48(%rsp),%edx
13809 - movl \offset+56(%rsp),%esi
13810 - movl \offset+64(%rsp),%edi
13811 + movl \offset+RCX(%rsp),%ecx
13812 + movl \offset+RDX(%rsp),%edx
13813 + movl \offset+RSI(%rsp),%esi
13814 + movl \offset+RDI(%rsp),%edi
13815 movl %eax,%eax /* zero extension */
13816 .endm
13817
13818 @@ -96,6 +98,32 @@ ENTRY(native_irq_enable_sysexit)
13819 ENDPROC(native_irq_enable_sysexit)
13820 #endif
13821
13822 + .macro pax_enter_kernel_user
13823 + pax_set_fptr_mask
13824 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13825 + call pax_enter_kernel_user
13826 +#endif
13827 + .endm
13828 +
13829 + .macro pax_exit_kernel_user
13830 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13831 + call pax_exit_kernel_user
13832 +#endif
13833 +#ifdef CONFIG_PAX_RANDKSTACK
13834 + pushq %rax
13835 + pushq %r11
13836 + call pax_randomize_kstack
13837 + popq %r11
13838 + popq %rax
13839 +#endif
13840 + .endm
13841 +
13842 + .macro pax_erase_kstack
13843 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
13844 + call pax_erase_kstack
13845 +#endif
13846 + .endm
13847 +
13848 /*
13849 * 32bit SYSENTER instruction entry.
13850 *
13851 @@ -122,12 +150,6 @@ ENTRY(ia32_sysenter_target)
13852 CFI_REGISTER rsp,rbp
13853 SWAPGS_UNSAFE_STACK
13854 movq PER_CPU_VAR(kernel_stack), %rsp
13855 - addq $(KERNEL_STACK_OFFSET),%rsp
13856 - /*
13857 - * No need to follow this irqs on/off section: the syscall
13858 - * disabled irqs, here we enable it straight after entry:
13859 - */
13860 - ENABLE_INTERRUPTS(CLBR_NONE)
13861 movl %ebp,%ebp /* zero extension */
13862 pushq_cfi $__USER32_DS
13863 /*CFI_REL_OFFSET ss,0*/
13864 @@ -135,24 +157,49 @@ ENTRY(ia32_sysenter_target)
13865 CFI_REL_OFFSET rsp,0
13866 pushfq_cfi
13867 /*CFI_REL_OFFSET rflags,0*/
13868 - movl TI_sysenter_return+THREAD_INFO(%rsp,3*8-KERNEL_STACK_OFFSET),%r10d
13869 - CFI_REGISTER rip,r10
13870 + orl $X86_EFLAGS_IF,(%rsp)
13871 + GET_THREAD_INFO(%r11)
13872 + movl TI_sysenter_return(%r11), %r11d
13873 + CFI_REGISTER rip,r11
13874 pushq_cfi $__USER32_CS
13875 /*CFI_REL_OFFSET cs,0*/
13876 movl %eax, %eax
13877 - pushq_cfi %r10
13878 + pushq_cfi %r11
13879 CFI_REL_OFFSET rip,0
13880 pushq_cfi %rax
13881 cld
13882 SAVE_ARGS 0,1,0
13883 + pax_enter_kernel_user
13884 +
13885 +#ifdef CONFIG_PAX_RANDKSTACK
13886 + pax_erase_kstack
13887 +#endif
13888 +
13889 + /*
13890 + * No need to follow this irqs on/off section: the syscall
13891 + * disabled irqs, here we enable it straight after entry:
13892 + */
13893 + ENABLE_INTERRUPTS(CLBR_NONE)
13894 /* no need to do an access_ok check here because rbp has been
13895 32bit zero extended */
13896 +
13897 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13898 + addq pax_user_shadow_base,%rbp
13899 + ASM_PAX_OPEN_USERLAND
13900 +#endif
13901 +
13902 ASM_STAC
13903 1: movl (%rbp),%ebp
13904 _ASM_EXTABLE(1b,ia32_badarg)
13905 ASM_CLAC
13906 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13907 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13908 +
13909 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13910 + ASM_PAX_CLOSE_USERLAND
13911 +#endif
13912 +
13913 + GET_THREAD_INFO(%r11)
13914 + orl $TS_COMPAT,TI_status(%r11)
13915 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
13916 CFI_REMEMBER_STATE
13917 jnz sysenter_tracesys
13918 cmpq $(IA32_NR_syscalls-1),%rax
13919 @@ -162,15 +209,18 @@ sysenter_do_call:
13920 sysenter_dispatch:
13921 call *ia32_sys_call_table(,%rax,8)
13922 movq %rax,RAX-ARGOFFSET(%rsp)
13923 + GET_THREAD_INFO(%r11)
13924 DISABLE_INTERRUPTS(CLBR_NONE)
13925 TRACE_IRQS_OFF
13926 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13927 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
13928 jnz sysexit_audit
13929 sysexit_from_sys_call:
13930 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13931 + pax_exit_kernel_user
13932 + pax_erase_kstack
13933 + andl $~TS_COMPAT,TI_status(%r11)
13934 /* clear IF, that popfq doesn't enable interrupts early */
13935 - andl $~0x200,EFLAGS-R11(%rsp)
13936 - movl RIP-R11(%rsp),%edx /* User %eip */
13937 + andl $~X86_EFLAGS_IF,EFLAGS(%rsp)
13938 + movl RIP(%rsp),%edx /* User %eip */
13939 CFI_REGISTER rip,rdx
13940 RESTORE_ARGS 0,24,0,0,0,0
13941 xorq %r8,%r8
13942 @@ -193,6 +243,9 @@ sysexit_from_sys_call:
13943 movl %eax,%esi /* 2nd arg: syscall number */
13944 movl $AUDIT_ARCH_I386,%edi /* 1st arg: audit arch */
13945 call __audit_syscall_entry
13946 +
13947 + pax_erase_kstack
13948 +
13949 movl RAX-ARGOFFSET(%rsp),%eax /* reload syscall number */
13950 cmpq $(IA32_NR_syscalls-1),%rax
13951 ja ia32_badsys
13952 @@ -204,7 +257,7 @@ sysexit_from_sys_call:
13953 .endm
13954
13955 .macro auditsys_exit exit
13956 - testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13957 + testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
13958 jnz ia32_ret_from_sys_call
13959 TRACE_IRQS_ON
13960 ENABLE_INTERRUPTS(CLBR_NONE)
13961 @@ -215,11 +268,12 @@ sysexit_from_sys_call:
13962 1: setbe %al /* 1 if error, 0 if not */
13963 movzbl %al,%edi /* zero-extend that into %edi */
13964 call __audit_syscall_exit
13965 + GET_THREAD_INFO(%r11)
13966 movq RAX-ARGOFFSET(%rsp),%rax /* reload syscall return value */
13967 movl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),%edi
13968 DISABLE_INTERRUPTS(CLBR_NONE)
13969 TRACE_IRQS_OFF
13970 - testl %edi,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13971 + testl %edi,TI_flags(%r11)
13972 jz \exit
13973 CLEAR_RREGS -ARGOFFSET
13974 jmp int_with_check
13975 @@ -237,7 +291,7 @@ sysexit_audit:
13976
13977 sysenter_tracesys:
13978 #ifdef CONFIG_AUDITSYSCALL
13979 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13980 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
13981 jz sysenter_auditsys
13982 #endif
13983 SAVE_REST
13984 @@ -249,6 +303,9 @@ sysenter_tracesys:
13985 RESTORE_REST
13986 cmpq $(IA32_NR_syscalls-1),%rax
13987 ja int_ret_from_sys_call /* sysenter_tracesys has set RAX(%rsp) */
13988 +
13989 + pax_erase_kstack
13990 +
13991 jmp sysenter_do_call
13992 CFI_ENDPROC
13993 ENDPROC(ia32_sysenter_target)
13994 @@ -276,19 +333,25 @@ ENDPROC(ia32_sysenter_target)
13995 ENTRY(ia32_cstar_target)
13996 CFI_STARTPROC32 simple
13997 CFI_SIGNAL_FRAME
13998 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
13999 + CFI_DEF_CFA rsp,0
14000 CFI_REGISTER rip,rcx
14001 /*CFI_REGISTER rflags,r11*/
14002 SWAPGS_UNSAFE_STACK
14003 movl %esp,%r8d
14004 CFI_REGISTER rsp,r8
14005 movq PER_CPU_VAR(kernel_stack),%rsp
14006 + SAVE_ARGS 8*6,0,0
14007 + pax_enter_kernel_user
14008 +
14009 +#ifdef CONFIG_PAX_RANDKSTACK
14010 + pax_erase_kstack
14011 +#endif
14012 +
14013 /*
14014 * No need to follow this irqs on/off section: the syscall
14015 * disabled irqs and here we enable it straight after entry:
14016 */
14017 ENABLE_INTERRUPTS(CLBR_NONE)
14018 - SAVE_ARGS 8,0,0
14019 movl %eax,%eax /* zero extension */
14020 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
14021 movq %rcx,RIP-ARGOFFSET(%rsp)
14022 @@ -304,12 +367,25 @@ ENTRY(ia32_cstar_target)
14023 /* no need to do an access_ok check here because r8 has been
14024 32bit zero extended */
14025 /* hardware stack frame is complete now */
14026 +
14027 +#ifdef CONFIG_PAX_MEMORY_UDEREF
14028 + ASM_PAX_OPEN_USERLAND
14029 + movq pax_user_shadow_base,%r8
14030 + addq RSP-ARGOFFSET(%rsp),%r8
14031 +#endif
14032 +
14033 ASM_STAC
14034 1: movl (%r8),%r9d
14035 _ASM_EXTABLE(1b,ia32_badarg)
14036 ASM_CLAC
14037 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
14038 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
14039 +
14040 +#ifdef CONFIG_PAX_MEMORY_UDEREF
14041 + ASM_PAX_CLOSE_USERLAND
14042 +#endif
14043 +
14044 + GET_THREAD_INFO(%r11)
14045 + orl $TS_COMPAT,TI_status(%r11)
14046 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
14047 CFI_REMEMBER_STATE
14048 jnz cstar_tracesys
14049 cmpq $IA32_NR_syscalls-1,%rax
14050 @@ -319,13 +395,16 @@ cstar_do_call:
14051 cstar_dispatch:
14052 call *ia32_sys_call_table(,%rax,8)
14053 movq %rax,RAX-ARGOFFSET(%rsp)
14054 + GET_THREAD_INFO(%r11)
14055 DISABLE_INTERRUPTS(CLBR_NONE)
14056 TRACE_IRQS_OFF
14057 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
14058 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
14059 jnz sysretl_audit
14060 sysretl_from_sys_call:
14061 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
14062 - RESTORE_ARGS 0,-ARG_SKIP,0,0,0
14063 + pax_exit_kernel_user
14064 + pax_erase_kstack
14065 + andl $~TS_COMPAT,TI_status(%r11)
14066 + RESTORE_ARGS 0,-ORIG_RAX,0,0,0
14067 movl RIP-ARGOFFSET(%rsp),%ecx
14068 CFI_REGISTER rip,rcx
14069 movl EFLAGS-ARGOFFSET(%rsp),%r11d
14070 @@ -352,7 +431,7 @@ sysretl_audit:
14071
14072 cstar_tracesys:
14073 #ifdef CONFIG_AUDITSYSCALL
14074 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
14075 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
14076 jz cstar_auditsys
14077 #endif
14078 xchgl %r9d,%ebp
14079 @@ -366,11 +445,19 @@ cstar_tracesys:
14080 xchgl %ebp,%r9d
14081 cmpq $(IA32_NR_syscalls-1),%rax
14082 ja int_ret_from_sys_call /* cstar_tracesys has set RAX(%rsp) */
14083 +
14084 + pax_erase_kstack
14085 +
14086 jmp cstar_do_call
14087 END(ia32_cstar_target)
14088
14089 ia32_badarg:
14090 ASM_CLAC
14091 +
14092 +#ifdef CONFIG_PAX_MEMORY_UDEREF
14093 + ASM_PAX_CLOSE_USERLAND
14094 +#endif
14095 +
14096 movq $-EFAULT,%rax
14097 jmp ia32_sysret
14098 CFI_ENDPROC
14099 @@ -407,19 +494,26 @@ ENTRY(ia32_syscall)
14100 CFI_REL_OFFSET rip,RIP-RIP
14101 PARAVIRT_ADJUST_EXCEPTION_FRAME
14102 SWAPGS
14103 - /*
14104 - * No need to follow this irqs on/off section: the syscall
14105 - * disabled irqs and here we enable it straight after entry:
14106 - */
14107 - ENABLE_INTERRUPTS(CLBR_NONE)
14108 movl %eax,%eax
14109 pushq_cfi %rax
14110 cld
14111 /* note the registers are not zero extended to the sf.
14112 this could be a problem. */
14113 SAVE_ARGS 0,1,0
14114 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
14115 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
14116 + pax_enter_kernel_user
14117 +
14118 +#ifdef CONFIG_PAX_RANDKSTACK
14119 + pax_erase_kstack
14120 +#endif
14121 +
14122 + /*
14123 + * No need to follow this irqs on/off section: the syscall
14124 + * disabled irqs and here we enable it straight after entry:
14125 + */
14126 + ENABLE_INTERRUPTS(CLBR_NONE)
14127 + GET_THREAD_INFO(%r11)
14128 + orl $TS_COMPAT,TI_status(%r11)
14129 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
14130 jnz ia32_tracesys
14131 cmpq $(IA32_NR_syscalls-1),%rax
14132 ja ia32_badsys
14133 @@ -442,6 +536,9 @@ ia32_tracesys:
14134 RESTORE_REST
14135 cmpq $(IA32_NR_syscalls-1),%rax
14136 ja int_ret_from_sys_call /* ia32_tracesys has set RAX(%rsp) */
14137 +
14138 + pax_erase_kstack
14139 +
14140 jmp ia32_do_call
14141 END(ia32_syscall)
14142
14143 diff --git a/arch/x86/ia32/sys_ia32.c b/arch/x86/ia32/sys_ia32.c
14144 index 8e0ceec..af13504 100644
14145 --- a/arch/x86/ia32/sys_ia32.c
14146 +++ b/arch/x86/ia32/sys_ia32.c
14147 @@ -69,8 +69,8 @@ asmlinkage long sys32_ftruncate64(unsigned int fd, unsigned long offset_low,
14148 */
14149 static int cp_stat64(struct stat64 __user *ubuf, struct kstat *stat)
14150 {
14151 - typeof(ubuf->st_uid) uid = 0;
14152 - typeof(ubuf->st_gid) gid = 0;
14153 + typeof(((struct stat64 *)0)->st_uid) uid = 0;
14154 + typeof(((struct stat64 *)0)->st_gid) gid = 0;
14155 SET_UID(uid, from_kuid_munged(current_user_ns(), stat->uid));
14156 SET_GID(gid, from_kgid_munged(current_user_ns(), stat->gid));
14157 if (!access_ok(VERIFY_WRITE, ubuf, sizeof(struct stat64)) ||
14158 diff --git a/arch/x86/include/asm/alternative-asm.h b/arch/x86/include/asm/alternative-asm.h
14159 index 372231c..51b537d 100644
14160 --- a/arch/x86/include/asm/alternative-asm.h
14161 +++ b/arch/x86/include/asm/alternative-asm.h
14162 @@ -18,6 +18,45 @@
14163 .endm
14164 #endif
14165
14166 +#ifdef KERNEXEC_PLUGIN
14167 + .macro pax_force_retaddr_bts rip=0
14168 + btsq $63,\rip(%rsp)
14169 + .endm
14170 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
14171 + .macro pax_force_retaddr rip=0, reload=0
14172 + btsq $63,\rip(%rsp)
14173 + .endm
14174 + .macro pax_force_fptr ptr
14175 + btsq $63,\ptr
14176 + .endm
14177 + .macro pax_set_fptr_mask
14178 + .endm
14179 +#endif
14180 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
14181 + .macro pax_force_retaddr rip=0, reload=0
14182 + .if \reload
14183 + pax_set_fptr_mask
14184 + .endif
14185 + orq %r12,\rip(%rsp)
14186 + .endm
14187 + .macro pax_force_fptr ptr
14188 + orq %r12,\ptr
14189 + .endm
14190 + .macro pax_set_fptr_mask
14191 + movabs $0x8000000000000000,%r12
14192 + .endm
14193 +#endif
14194 +#else
14195 + .macro pax_force_retaddr rip=0, reload=0
14196 + .endm
14197 + .macro pax_force_fptr ptr
14198 + .endm
14199 + .macro pax_force_retaddr_bts rip=0
14200 + .endm
14201 + .macro pax_set_fptr_mask
14202 + .endm
14203 +#endif
14204 +
14205 .macro altinstruction_entry orig alt feature orig_len alt_len
14206 .long \orig - .
14207 .long \alt - .
14208 diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h
14209 index 0a3f9c9..c9d081d 100644
14210 --- a/arch/x86/include/asm/alternative.h
14211 +++ b/arch/x86/include/asm/alternative.h
14212 @@ -106,7 +106,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
14213 ".pushsection .discard,\"aw\",@progbits\n" \
14214 DISCARD_ENTRY(1) \
14215 ".popsection\n" \
14216 - ".pushsection .altinstr_replacement, \"ax\"\n" \
14217 + ".pushsection .altinstr_replacement, \"a\"\n" \
14218 ALTINSTR_REPLACEMENT(newinstr, feature, 1) \
14219 ".popsection"
14220
14221 @@ -120,7 +120,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
14222 DISCARD_ENTRY(1) \
14223 DISCARD_ENTRY(2) \
14224 ".popsection\n" \
14225 - ".pushsection .altinstr_replacement, \"ax\"\n" \
14226 + ".pushsection .altinstr_replacement, \"a\"\n" \
14227 ALTINSTR_REPLACEMENT(newinstr1, feature1, 1) \
14228 ALTINSTR_REPLACEMENT(newinstr2, feature2, 2) \
14229 ".popsection"
14230 diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
14231 index 1d2091a..f5074c1 100644
14232 --- a/arch/x86/include/asm/apic.h
14233 +++ b/arch/x86/include/asm/apic.h
14234 @@ -45,7 +45,7 @@ static inline void generic_apic_probe(void)
14235
14236 #ifdef CONFIG_X86_LOCAL_APIC
14237
14238 -extern unsigned int apic_verbosity;
14239 +extern int apic_verbosity;
14240 extern int local_apic_timer_c2_ok;
14241
14242 extern int disable_apic;
14243 diff --git a/arch/x86/include/asm/apm.h b/arch/x86/include/asm/apm.h
14244 index 20370c6..a2eb9b0 100644
14245 --- a/arch/x86/include/asm/apm.h
14246 +++ b/arch/x86/include/asm/apm.h
14247 @@ -34,7 +34,7 @@ static inline void apm_bios_call_asm(u32 func, u32 ebx_in, u32 ecx_in,
14248 __asm__ __volatile__(APM_DO_ZERO_SEGS
14249 "pushl %%edi\n\t"
14250 "pushl %%ebp\n\t"
14251 - "lcall *%%cs:apm_bios_entry\n\t"
14252 + "lcall *%%ss:apm_bios_entry\n\t"
14253 "setc %%al\n\t"
14254 "popl %%ebp\n\t"
14255 "popl %%edi\n\t"
14256 @@ -58,7 +58,7 @@ static inline u8 apm_bios_call_simple_asm(u32 func, u32 ebx_in,
14257 __asm__ __volatile__(APM_DO_ZERO_SEGS
14258 "pushl %%edi\n\t"
14259 "pushl %%ebp\n\t"
14260 - "lcall *%%cs:apm_bios_entry\n\t"
14261 + "lcall *%%ss:apm_bios_entry\n\t"
14262 "setc %%bl\n\t"
14263 "popl %%ebp\n\t"
14264 "popl %%edi\n\t"
14265 diff --git a/arch/x86/include/asm/atomic.h b/arch/x86/include/asm/atomic.h
14266 index 722aa3b..c392d85 100644
14267 --- a/arch/x86/include/asm/atomic.h
14268 +++ b/arch/x86/include/asm/atomic.h
14269 @@ -22,7 +22,18 @@
14270 */
14271 static inline int atomic_read(const atomic_t *v)
14272 {
14273 - return (*(volatile int *)&(v)->counter);
14274 + return (*(volatile const int *)&(v)->counter);
14275 +}
14276 +
14277 +/**
14278 + * atomic_read_unchecked - read atomic variable
14279 + * @v: pointer of type atomic_unchecked_t
14280 + *
14281 + * Atomically reads the value of @v.
14282 + */
14283 +static inline int __intentional_overflow(-1) atomic_read_unchecked(const atomic_unchecked_t *v)
14284 +{
14285 + return (*(volatile const int *)&(v)->counter);
14286 }
14287
14288 /**
14289 @@ -38,6 +49,18 @@ static inline void atomic_set(atomic_t *v, int i)
14290 }
14291
14292 /**
14293 + * atomic_set_unchecked - set atomic variable
14294 + * @v: pointer of type atomic_unchecked_t
14295 + * @i: required value
14296 + *
14297 + * Atomically sets the value of @v to @i.
14298 + */
14299 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
14300 +{
14301 + v->counter = i;
14302 +}
14303 +
14304 +/**
14305 * atomic_add - add integer to atomic variable
14306 * @i: integer value to add
14307 * @v: pointer of type atomic_t
14308 @@ -46,7 +69,29 @@ static inline void atomic_set(atomic_t *v, int i)
14309 */
14310 static inline void atomic_add(int i, atomic_t *v)
14311 {
14312 - asm volatile(LOCK_PREFIX "addl %1,%0"
14313 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
14314 +
14315 +#ifdef CONFIG_PAX_REFCOUNT
14316 + "jno 0f\n"
14317 + LOCK_PREFIX "subl %1,%0\n"
14318 + "int $4\n0:\n"
14319 + _ASM_EXTABLE(0b, 0b)
14320 +#endif
14321 +
14322 + : "+m" (v->counter)
14323 + : "ir" (i));
14324 +}
14325 +
14326 +/**
14327 + * atomic_add_unchecked - add integer to atomic variable
14328 + * @i: integer value to add
14329 + * @v: pointer of type atomic_unchecked_t
14330 + *
14331 + * Atomically adds @i to @v.
14332 + */
14333 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
14334 +{
14335 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
14336 : "+m" (v->counter)
14337 : "ir" (i));
14338 }
14339 @@ -60,7 +105,29 @@ static inline void atomic_add(int i, atomic_t *v)
14340 */
14341 static inline void atomic_sub(int i, atomic_t *v)
14342 {
14343 - asm volatile(LOCK_PREFIX "subl %1,%0"
14344 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
14345 +
14346 +#ifdef CONFIG_PAX_REFCOUNT
14347 + "jno 0f\n"
14348 + LOCK_PREFIX "addl %1,%0\n"
14349 + "int $4\n0:\n"
14350 + _ASM_EXTABLE(0b, 0b)
14351 +#endif
14352 +
14353 + : "+m" (v->counter)
14354 + : "ir" (i));
14355 +}
14356 +
14357 +/**
14358 + * atomic_sub_unchecked - subtract integer from atomic variable
14359 + * @i: integer value to subtract
14360 + * @v: pointer of type atomic_unchecked_t
14361 + *
14362 + * Atomically subtracts @i from @v.
14363 + */
14364 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
14365 +{
14366 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
14367 : "+m" (v->counter)
14368 : "ir" (i));
14369 }
14370 @@ -78,7 +145,16 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
14371 {
14372 unsigned char c;
14373
14374 - asm volatile(LOCK_PREFIX "subl %2,%0; sete %1"
14375 + asm volatile(LOCK_PREFIX "subl %2,%0\n"
14376 +
14377 +#ifdef CONFIG_PAX_REFCOUNT
14378 + "jno 0f\n"
14379 + LOCK_PREFIX "addl %2,%0\n"
14380 + "int $4\n0:\n"
14381 + _ASM_EXTABLE(0b, 0b)
14382 +#endif
14383 +
14384 + "sete %1\n"
14385 : "+m" (v->counter), "=qm" (c)
14386 : "ir" (i) : "memory");
14387 return c;
14388 @@ -92,7 +168,27 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
14389 */
14390 static inline void atomic_inc(atomic_t *v)
14391 {
14392 - asm volatile(LOCK_PREFIX "incl %0"
14393 + asm volatile(LOCK_PREFIX "incl %0\n"
14394 +
14395 +#ifdef CONFIG_PAX_REFCOUNT
14396 + "jno 0f\n"
14397 + LOCK_PREFIX "decl %0\n"
14398 + "int $4\n0:\n"
14399 + _ASM_EXTABLE(0b, 0b)
14400 +#endif
14401 +
14402 + : "+m" (v->counter));
14403 +}
14404 +
14405 +/**
14406 + * atomic_inc_unchecked - increment atomic variable
14407 + * @v: pointer of type atomic_unchecked_t
14408 + *
14409 + * Atomically increments @v by 1.
14410 + */
14411 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
14412 +{
14413 + asm volatile(LOCK_PREFIX "incl %0\n"
14414 : "+m" (v->counter));
14415 }
14416
14417 @@ -104,7 +200,27 @@ static inline void atomic_inc(atomic_t *v)
14418 */
14419 static inline void atomic_dec(atomic_t *v)
14420 {
14421 - asm volatile(LOCK_PREFIX "decl %0"
14422 + asm volatile(LOCK_PREFIX "decl %0\n"
14423 +
14424 +#ifdef CONFIG_PAX_REFCOUNT
14425 + "jno 0f\n"
14426 + LOCK_PREFIX "incl %0\n"
14427 + "int $4\n0:\n"
14428 + _ASM_EXTABLE(0b, 0b)
14429 +#endif
14430 +
14431 + : "+m" (v->counter));
14432 +}
14433 +
14434 +/**
14435 + * atomic_dec_unchecked - decrement atomic variable
14436 + * @v: pointer of type atomic_unchecked_t
14437 + *
14438 + * Atomically decrements @v by 1.
14439 + */
14440 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
14441 +{
14442 + asm volatile(LOCK_PREFIX "decl %0\n"
14443 : "+m" (v->counter));
14444 }
14445
14446 @@ -120,7 +236,16 @@ static inline int atomic_dec_and_test(atomic_t *v)
14447 {
14448 unsigned char c;
14449
14450 - asm volatile(LOCK_PREFIX "decl %0; sete %1"
14451 + asm volatile(LOCK_PREFIX "decl %0\n"
14452 +
14453 +#ifdef CONFIG_PAX_REFCOUNT
14454 + "jno 0f\n"
14455 + LOCK_PREFIX "incl %0\n"
14456 + "int $4\n0:\n"
14457 + _ASM_EXTABLE(0b, 0b)
14458 +#endif
14459 +
14460 + "sete %1\n"
14461 : "+m" (v->counter), "=qm" (c)
14462 : : "memory");
14463 return c != 0;
14464 @@ -138,7 +263,35 @@ static inline int atomic_inc_and_test(atomic_t *v)
14465 {
14466 unsigned char c;
14467
14468 - asm volatile(LOCK_PREFIX "incl %0; sete %1"
14469 + asm volatile(LOCK_PREFIX "incl %0\n"
14470 +
14471 +#ifdef CONFIG_PAX_REFCOUNT
14472 + "jno 0f\n"
14473 + LOCK_PREFIX "decl %0\n"
14474 + "int $4\n0:\n"
14475 + _ASM_EXTABLE(0b, 0b)
14476 +#endif
14477 +
14478 + "sete %1\n"
14479 + : "+m" (v->counter), "=qm" (c)
14480 + : : "memory");
14481 + return c != 0;
14482 +}
14483 +
14484 +/**
14485 + * atomic_inc_and_test_unchecked - increment and test
14486 + * @v: pointer of type atomic_unchecked_t
14487 + *
14488 + * Atomically increments @v by 1
14489 + * and returns true if the result is zero, or false for all
14490 + * other cases.
14491 + */
14492 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
14493 +{
14494 + unsigned char c;
14495 +
14496 + asm volatile(LOCK_PREFIX "incl %0\n"
14497 + "sete %1\n"
14498 : "+m" (v->counter), "=qm" (c)
14499 : : "memory");
14500 return c != 0;
14501 @@ -157,7 +310,16 @@ static inline int atomic_add_negative(int i, atomic_t *v)
14502 {
14503 unsigned char c;
14504
14505 - asm volatile(LOCK_PREFIX "addl %2,%0; sets %1"
14506 + asm volatile(LOCK_PREFIX "addl %2,%0\n"
14507 +
14508 +#ifdef CONFIG_PAX_REFCOUNT
14509 + "jno 0f\n"
14510 + LOCK_PREFIX "subl %2,%0\n"
14511 + "int $4\n0:\n"
14512 + _ASM_EXTABLE(0b, 0b)
14513 +#endif
14514 +
14515 + "sets %1\n"
14516 : "+m" (v->counter), "=qm" (c)
14517 : "ir" (i) : "memory");
14518 return c;
14519 @@ -172,6 +334,18 @@ static inline int atomic_add_negative(int i, atomic_t *v)
14520 */
14521 static inline int atomic_add_return(int i, atomic_t *v)
14522 {
14523 + return i + xadd_check_overflow(&v->counter, i);
14524 +}
14525 +
14526 +/**
14527 + * atomic_add_return_unchecked - add integer and return
14528 + * @i: integer value to add
14529 + * @v: pointer of type atomic_unchecked_t
14530 + *
14531 + * Atomically adds @i to @v and returns @i + @v
14532 + */
14533 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
14534 +{
14535 return i + xadd(&v->counter, i);
14536 }
14537
14538 @@ -188,9 +362,18 @@ static inline int atomic_sub_return(int i, atomic_t *v)
14539 }
14540
14541 #define atomic_inc_return(v) (atomic_add_return(1, v))
14542 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
14543 +{
14544 + return atomic_add_return_unchecked(1, v);
14545 +}
14546 #define atomic_dec_return(v) (atomic_sub_return(1, v))
14547
14548 -static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
14549 +static inline int __intentional_overflow(-1) atomic_cmpxchg(atomic_t *v, int old, int new)
14550 +{
14551 + return cmpxchg(&v->counter, old, new);
14552 +}
14553 +
14554 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
14555 {
14556 return cmpxchg(&v->counter, old, new);
14557 }
14558 @@ -200,6 +383,11 @@ static inline int atomic_xchg(atomic_t *v, int new)
14559 return xchg(&v->counter, new);
14560 }
14561
14562 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
14563 +{
14564 + return xchg(&v->counter, new);
14565 +}
14566 +
14567 /**
14568 * __atomic_add_unless - add unless the number is already a given value
14569 * @v: pointer of type atomic_t
14570 @@ -209,14 +397,27 @@ static inline int atomic_xchg(atomic_t *v, int new)
14571 * Atomically adds @a to @v, so long as @v was not already @u.
14572 * Returns the old value of @v.
14573 */
14574 -static inline int __atomic_add_unless(atomic_t *v, int a, int u)
14575 +static inline int __intentional_overflow(-1) __atomic_add_unless(atomic_t *v, int a, int u)
14576 {
14577 - int c, old;
14578 + int c, old, new;
14579 c = atomic_read(v);
14580 for (;;) {
14581 - if (unlikely(c == (u)))
14582 + if (unlikely(c == u))
14583 break;
14584 - old = atomic_cmpxchg((v), c, c + (a));
14585 +
14586 + asm volatile("addl %2,%0\n"
14587 +
14588 +#ifdef CONFIG_PAX_REFCOUNT
14589 + "jno 0f\n"
14590 + "subl %2,%0\n"
14591 + "int $4\n0:\n"
14592 + _ASM_EXTABLE(0b, 0b)
14593 +#endif
14594 +
14595 + : "=r" (new)
14596 + : "0" (c), "ir" (a));
14597 +
14598 + old = atomic_cmpxchg(v, c, new);
14599 if (likely(old == c))
14600 break;
14601 c = old;
14602 @@ -225,6 +426,49 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
14603 }
14604
14605 /**
14606 + * atomic_inc_not_zero_hint - increment if not null
14607 + * @v: pointer of type atomic_t
14608 + * @hint: probable value of the atomic before the increment
14609 + *
14610 + * This version of atomic_inc_not_zero() gives a hint of probable
14611 + * value of the atomic. This helps processor to not read the memory
14612 + * before doing the atomic read/modify/write cycle, lowering
14613 + * number of bus transactions on some arches.
14614 + *
14615 + * Returns: 0 if increment was not done, 1 otherwise.
14616 + */
14617 +#define atomic_inc_not_zero_hint atomic_inc_not_zero_hint
14618 +static inline int atomic_inc_not_zero_hint(atomic_t *v, int hint)
14619 +{
14620 + int val, c = hint, new;
14621 +
14622 + /* sanity test, should be removed by compiler if hint is a constant */
14623 + if (!hint)
14624 + return __atomic_add_unless(v, 1, 0);
14625 +
14626 + do {
14627 + asm volatile("incl %0\n"
14628 +
14629 +#ifdef CONFIG_PAX_REFCOUNT
14630 + "jno 0f\n"
14631 + "decl %0\n"
14632 + "int $4\n0:\n"
14633 + _ASM_EXTABLE(0b, 0b)
14634 +#endif
14635 +
14636 + : "=r" (new)
14637 + : "0" (c));
14638 +
14639 + val = atomic_cmpxchg(v, c, new);
14640 + if (val == c)
14641 + return 1;
14642 + c = val;
14643 + } while (c);
14644 +
14645 + return 0;
14646 +}
14647 +
14648 +/**
14649 * atomic_inc_short - increment of a short integer
14650 * @v: pointer to type int
14651 *
14652 @@ -253,14 +497,37 @@ static inline void atomic_or_long(unsigned long *v1, unsigned long v2)
14653 #endif
14654
14655 /* These are x86-specific, used by some header files */
14656 -#define atomic_clear_mask(mask, addr) \
14657 - asm volatile(LOCK_PREFIX "andl %0,%1" \
14658 - : : "r" (~(mask)), "m" (*(addr)) : "memory")
14659 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
14660 +{
14661 + asm volatile(LOCK_PREFIX "andl %1,%0"
14662 + : "+m" (v->counter)
14663 + : "r" (~(mask))
14664 + : "memory");
14665 +}
14666
14667 -#define atomic_set_mask(mask, addr) \
14668 - asm volatile(LOCK_PREFIX "orl %0,%1" \
14669 - : : "r" ((unsigned)(mask)), "m" (*(addr)) \
14670 - : "memory")
14671 +static inline void atomic_clear_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
14672 +{
14673 + asm volatile(LOCK_PREFIX "andl %1,%0"
14674 + : "+m" (v->counter)
14675 + : "r" (~(mask))
14676 + : "memory");
14677 +}
14678 +
14679 +static inline void atomic_set_mask(unsigned int mask, atomic_t *v)
14680 +{
14681 + asm volatile(LOCK_PREFIX "orl %1,%0"
14682 + : "+m" (v->counter)
14683 + : "r" (mask)
14684 + : "memory");
14685 +}
14686 +
14687 +static inline void atomic_set_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
14688 +{
14689 + asm volatile(LOCK_PREFIX "orl %1,%0"
14690 + : "+m" (v->counter)
14691 + : "r" (mask)
14692 + : "memory");
14693 +}
14694
14695 /* Atomic operations are already serializing on x86 */
14696 #define smp_mb__before_atomic_dec() barrier()
14697 diff --git a/arch/x86/include/asm/atomic64_32.h b/arch/x86/include/asm/atomic64_32.h
14698 index b154de7..bf18a5a 100644
14699 --- a/arch/x86/include/asm/atomic64_32.h
14700 +++ b/arch/x86/include/asm/atomic64_32.h
14701 @@ -12,6 +12,14 @@ typedef struct {
14702 u64 __aligned(8) counter;
14703 } atomic64_t;
14704
14705 +#ifdef CONFIG_PAX_REFCOUNT
14706 +typedef struct {
14707 + u64 __aligned(8) counter;
14708 +} atomic64_unchecked_t;
14709 +#else
14710 +typedef atomic64_t atomic64_unchecked_t;
14711 +#endif
14712 +
14713 #define ATOMIC64_INIT(val) { (val) }
14714
14715 #define __ATOMIC64_DECL(sym) void atomic64_##sym(atomic64_t *, ...)
14716 @@ -37,21 +45,31 @@ typedef struct {
14717 ATOMIC64_DECL_ONE(sym##_386)
14718
14719 ATOMIC64_DECL_ONE(add_386);
14720 +ATOMIC64_DECL_ONE(add_unchecked_386);
14721 ATOMIC64_DECL_ONE(sub_386);
14722 +ATOMIC64_DECL_ONE(sub_unchecked_386);
14723 ATOMIC64_DECL_ONE(inc_386);
14724 +ATOMIC64_DECL_ONE(inc_unchecked_386);
14725 ATOMIC64_DECL_ONE(dec_386);
14726 +ATOMIC64_DECL_ONE(dec_unchecked_386);
14727 #endif
14728
14729 #define alternative_atomic64(f, out, in...) \
14730 __alternative_atomic64(f, f, ASM_OUTPUT2(out), ## in)
14731
14732 ATOMIC64_DECL(read);
14733 +ATOMIC64_DECL(read_unchecked);
14734 ATOMIC64_DECL(set);
14735 +ATOMIC64_DECL(set_unchecked);
14736 ATOMIC64_DECL(xchg);
14737 ATOMIC64_DECL(add_return);
14738 +ATOMIC64_DECL(add_return_unchecked);
14739 ATOMIC64_DECL(sub_return);
14740 +ATOMIC64_DECL(sub_return_unchecked);
14741 ATOMIC64_DECL(inc_return);
14742 +ATOMIC64_DECL(inc_return_unchecked);
14743 ATOMIC64_DECL(dec_return);
14744 +ATOMIC64_DECL(dec_return_unchecked);
14745 ATOMIC64_DECL(dec_if_positive);
14746 ATOMIC64_DECL(inc_not_zero);
14747 ATOMIC64_DECL(add_unless);
14748 @@ -77,6 +95,21 @@ static inline long long atomic64_cmpxchg(atomic64_t *v, long long o, long long n
14749 }
14750
14751 /**
14752 + * atomic64_cmpxchg_unchecked - cmpxchg atomic64 variable
14753 + * @p: pointer to type atomic64_unchecked_t
14754 + * @o: expected value
14755 + * @n: new value
14756 + *
14757 + * Atomically sets @v to @n if it was equal to @o and returns
14758 + * the old value.
14759 + */
14760 +
14761 +static inline long long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long long o, long long n)
14762 +{
14763 + return cmpxchg64(&v->counter, o, n);
14764 +}
14765 +
14766 +/**
14767 * atomic64_xchg - xchg atomic64 variable
14768 * @v: pointer to type atomic64_t
14769 * @n: value to assign
14770 @@ -112,6 +145,22 @@ static inline void atomic64_set(atomic64_t *v, long long i)
14771 }
14772
14773 /**
14774 + * atomic64_set_unchecked - set atomic64 variable
14775 + * @v: pointer to type atomic64_unchecked_t
14776 + * @n: value to assign
14777 + *
14778 + * Atomically sets the value of @v to @n.
14779 + */
14780 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long long i)
14781 +{
14782 + unsigned high = (unsigned)(i >> 32);
14783 + unsigned low = (unsigned)i;
14784 + alternative_atomic64(set, /* no output */,
14785 + "S" (v), "b" (low), "c" (high)
14786 + : "eax", "edx", "memory");
14787 +}
14788 +
14789 +/**
14790 * atomic64_read - read atomic64 variable
14791 * @v: pointer to type atomic64_t
14792 *
14793 @@ -125,6 +174,19 @@ static inline long long atomic64_read(const atomic64_t *v)
14794 }
14795
14796 /**
14797 + * atomic64_read_unchecked - read atomic64 variable
14798 + * @v: pointer to type atomic64_unchecked_t
14799 + *
14800 + * Atomically reads the value of @v and returns it.
14801 + */
14802 +static inline long long __intentional_overflow(-1) atomic64_read_unchecked(atomic64_unchecked_t *v)
14803 +{
14804 + long long r;
14805 + alternative_atomic64(read, "=&A" (r), "c" (v) : "memory");
14806 + return r;
14807 + }
14808 +
14809 +/**
14810 * atomic64_add_return - add and return
14811 * @i: integer value to add
14812 * @v: pointer to type atomic64_t
14813 @@ -139,6 +201,21 @@ static inline long long atomic64_add_return(long long i, atomic64_t *v)
14814 return i;
14815 }
14816
14817 +/**
14818 + * atomic64_add_return_unchecked - add and return
14819 + * @i: integer value to add
14820 + * @v: pointer to type atomic64_unchecked_t
14821 + *
14822 + * Atomically adds @i to @v and returns @i + *@v
14823 + */
14824 +static inline long long atomic64_add_return_unchecked(long long i, atomic64_unchecked_t *v)
14825 +{
14826 + alternative_atomic64(add_return_unchecked,
14827 + ASM_OUTPUT2("+A" (i), "+c" (v)),
14828 + ASM_NO_INPUT_CLOBBER("memory"));
14829 + return i;
14830 +}
14831 +
14832 /*
14833 * Other variants with different arithmetic operators:
14834 */
14835 @@ -158,6 +235,14 @@ static inline long long atomic64_inc_return(atomic64_t *v)
14836 return a;
14837 }
14838
14839 +static inline long long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
14840 +{
14841 + long long a;
14842 + alternative_atomic64(inc_return_unchecked, "=&A" (a),
14843 + "S" (v) : "memory", "ecx");
14844 + return a;
14845 +}
14846 +
14847 static inline long long atomic64_dec_return(atomic64_t *v)
14848 {
14849 long long a;
14850 @@ -182,6 +267,21 @@ static inline long long atomic64_add(long long i, atomic64_t *v)
14851 }
14852
14853 /**
14854 + * atomic64_add_unchecked - add integer to atomic64 variable
14855 + * @i: integer value to add
14856 + * @v: pointer to type atomic64_unchecked_t
14857 + *
14858 + * Atomically adds @i to @v.
14859 + */
14860 +static inline long long atomic64_add_unchecked(long long i, atomic64_unchecked_t *v)
14861 +{
14862 + __alternative_atomic64(add_unchecked, add_return_unchecked,
14863 + ASM_OUTPUT2("+A" (i), "+c" (v)),
14864 + ASM_NO_INPUT_CLOBBER("memory"));
14865 + return i;
14866 +}
14867 +
14868 +/**
14869 * atomic64_sub - subtract the atomic64 variable
14870 * @i: integer value to subtract
14871 * @v: pointer to type atomic64_t
14872 diff --git a/arch/x86/include/asm/atomic64_64.h b/arch/x86/include/asm/atomic64_64.h
14873 index 0e1cbfc..a891fc7 100644
14874 --- a/arch/x86/include/asm/atomic64_64.h
14875 +++ b/arch/x86/include/asm/atomic64_64.h
14876 @@ -18,7 +18,19 @@
14877 */
14878 static inline long atomic64_read(const atomic64_t *v)
14879 {
14880 - return (*(volatile long *)&(v)->counter);
14881 + return (*(volatile const long *)&(v)->counter);
14882 +}
14883 +
14884 +/**
14885 + * atomic64_read_unchecked - read atomic64 variable
14886 + * @v: pointer of type atomic64_unchecked_t
14887 + *
14888 + * Atomically reads the value of @v.
14889 + * Doesn't imply a read memory barrier.
14890 + */
14891 +static inline long __intentional_overflow(-1) atomic64_read_unchecked(const atomic64_unchecked_t *v)
14892 +{
14893 + return (*(volatile const long *)&(v)->counter);
14894 }
14895
14896 /**
14897 @@ -34,6 +46,18 @@ static inline void atomic64_set(atomic64_t *v, long i)
14898 }
14899
14900 /**
14901 + * atomic64_set_unchecked - set atomic64 variable
14902 + * @v: pointer to type atomic64_unchecked_t
14903 + * @i: required value
14904 + *
14905 + * Atomically sets the value of @v to @i.
14906 + */
14907 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
14908 +{
14909 + v->counter = i;
14910 +}
14911 +
14912 +/**
14913 * atomic64_add - add integer to atomic64 variable
14914 * @i: integer value to add
14915 * @v: pointer to type atomic64_t
14916 @@ -42,6 +66,28 @@ static inline void atomic64_set(atomic64_t *v, long i)
14917 */
14918 static inline void atomic64_add(long i, atomic64_t *v)
14919 {
14920 + asm volatile(LOCK_PREFIX "addq %1,%0\n"
14921 +
14922 +#ifdef CONFIG_PAX_REFCOUNT
14923 + "jno 0f\n"
14924 + LOCK_PREFIX "subq %1,%0\n"
14925 + "int $4\n0:\n"
14926 + _ASM_EXTABLE(0b, 0b)
14927 +#endif
14928 +
14929 + : "=m" (v->counter)
14930 + : "er" (i), "m" (v->counter));
14931 +}
14932 +
14933 +/**
14934 + * atomic64_add_unchecked - add integer to atomic64 variable
14935 + * @i: integer value to add
14936 + * @v: pointer to type atomic64_unchecked_t
14937 + *
14938 + * Atomically adds @i to @v.
14939 + */
14940 +static inline void atomic64_add_unchecked(long i, atomic64_unchecked_t *v)
14941 +{
14942 asm volatile(LOCK_PREFIX "addq %1,%0"
14943 : "=m" (v->counter)
14944 : "er" (i), "m" (v->counter));
14945 @@ -56,7 +102,29 @@ static inline void atomic64_add(long i, atomic64_t *v)
14946 */
14947 static inline void atomic64_sub(long i, atomic64_t *v)
14948 {
14949 - asm volatile(LOCK_PREFIX "subq %1,%0"
14950 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
14951 +
14952 +#ifdef CONFIG_PAX_REFCOUNT
14953 + "jno 0f\n"
14954 + LOCK_PREFIX "addq %1,%0\n"
14955 + "int $4\n0:\n"
14956 + _ASM_EXTABLE(0b, 0b)
14957 +#endif
14958 +
14959 + : "=m" (v->counter)
14960 + : "er" (i), "m" (v->counter));
14961 +}
14962 +
14963 +/**
14964 + * atomic64_sub_unchecked - subtract the atomic64 variable
14965 + * @i: integer value to subtract
14966 + * @v: pointer to type atomic64_unchecked_t
14967 + *
14968 + * Atomically subtracts @i from @v.
14969 + */
14970 +static inline void atomic64_sub_unchecked(long i, atomic64_unchecked_t *v)
14971 +{
14972 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
14973 : "=m" (v->counter)
14974 : "er" (i), "m" (v->counter));
14975 }
14976 @@ -74,7 +142,16 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
14977 {
14978 unsigned char c;
14979
14980 - asm volatile(LOCK_PREFIX "subq %2,%0; sete %1"
14981 + asm volatile(LOCK_PREFIX "subq %2,%0\n"
14982 +
14983 +#ifdef CONFIG_PAX_REFCOUNT
14984 + "jno 0f\n"
14985 + LOCK_PREFIX "addq %2,%0\n"
14986 + "int $4\n0:\n"
14987 + _ASM_EXTABLE(0b, 0b)
14988 +#endif
14989 +
14990 + "sete %1\n"
14991 : "=m" (v->counter), "=qm" (c)
14992 : "er" (i), "m" (v->counter) : "memory");
14993 return c;
14994 @@ -88,6 +165,27 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
14995 */
14996 static inline void atomic64_inc(atomic64_t *v)
14997 {
14998 + asm volatile(LOCK_PREFIX "incq %0\n"
14999 +
15000 +#ifdef CONFIG_PAX_REFCOUNT
15001 + "jno 0f\n"
15002 + LOCK_PREFIX "decq %0\n"
15003 + "int $4\n0:\n"
15004 + _ASM_EXTABLE(0b, 0b)
15005 +#endif
15006 +
15007 + : "=m" (v->counter)
15008 + : "m" (v->counter));
15009 +}
15010 +
15011 +/**
15012 + * atomic64_inc_unchecked - increment atomic64 variable
15013 + * @v: pointer to type atomic64_unchecked_t
15014 + *
15015 + * Atomically increments @v by 1.
15016 + */
15017 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
15018 +{
15019 asm volatile(LOCK_PREFIX "incq %0"
15020 : "=m" (v->counter)
15021 : "m" (v->counter));
15022 @@ -101,7 +199,28 @@ static inline void atomic64_inc(atomic64_t *v)
15023 */
15024 static inline void atomic64_dec(atomic64_t *v)
15025 {
15026 - asm volatile(LOCK_PREFIX "decq %0"
15027 + asm volatile(LOCK_PREFIX "decq %0\n"
15028 +
15029 +#ifdef CONFIG_PAX_REFCOUNT
15030 + "jno 0f\n"
15031 + LOCK_PREFIX "incq %0\n"
15032 + "int $4\n0:\n"
15033 + _ASM_EXTABLE(0b, 0b)
15034 +#endif
15035 +
15036 + : "=m" (v->counter)
15037 + : "m" (v->counter));
15038 +}
15039 +
15040 +/**
15041 + * atomic64_dec_unchecked - decrement atomic64 variable
15042 + * @v: pointer to type atomic64_t
15043 + *
15044 + * Atomically decrements @v by 1.
15045 + */
15046 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
15047 +{
15048 + asm volatile(LOCK_PREFIX "decq %0\n"
15049 : "=m" (v->counter)
15050 : "m" (v->counter));
15051 }
15052 @@ -118,7 +237,16 @@ static inline int atomic64_dec_and_test(atomic64_t *v)
15053 {
15054 unsigned char c;
15055
15056 - asm volatile(LOCK_PREFIX "decq %0; sete %1"
15057 + asm volatile(LOCK_PREFIX "decq %0\n"
15058 +
15059 +#ifdef CONFIG_PAX_REFCOUNT
15060 + "jno 0f\n"
15061 + LOCK_PREFIX "incq %0\n"
15062 + "int $4\n0:\n"
15063 + _ASM_EXTABLE(0b, 0b)
15064 +#endif
15065 +
15066 + "sete %1\n"
15067 : "=m" (v->counter), "=qm" (c)
15068 : "m" (v->counter) : "memory");
15069 return c != 0;
15070 @@ -136,7 +264,16 @@ static inline int atomic64_inc_and_test(atomic64_t *v)
15071 {
15072 unsigned char c;
15073
15074 - asm volatile(LOCK_PREFIX "incq %0; sete %1"
15075 + asm volatile(LOCK_PREFIX "incq %0\n"
15076 +
15077 +#ifdef CONFIG_PAX_REFCOUNT
15078 + "jno 0f\n"
15079 + LOCK_PREFIX "decq %0\n"
15080 + "int $4\n0:\n"
15081 + _ASM_EXTABLE(0b, 0b)
15082 +#endif
15083 +
15084 + "sete %1\n"
15085 : "=m" (v->counter), "=qm" (c)
15086 : "m" (v->counter) : "memory");
15087 return c != 0;
15088 @@ -155,7 +292,16 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
15089 {
15090 unsigned char c;
15091
15092 - asm volatile(LOCK_PREFIX "addq %2,%0; sets %1"
15093 + asm volatile(LOCK_PREFIX "addq %2,%0\n"
15094 +
15095 +#ifdef CONFIG_PAX_REFCOUNT
15096 + "jno 0f\n"
15097 + LOCK_PREFIX "subq %2,%0\n"
15098 + "int $4\n0:\n"
15099 + _ASM_EXTABLE(0b, 0b)
15100 +#endif
15101 +
15102 + "sets %1\n"
15103 : "=m" (v->counter), "=qm" (c)
15104 : "er" (i), "m" (v->counter) : "memory");
15105 return c;
15106 @@ -170,6 +316,18 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
15107 */
15108 static inline long atomic64_add_return(long i, atomic64_t *v)
15109 {
15110 + return i + xadd_check_overflow(&v->counter, i);
15111 +}
15112 +
15113 +/**
15114 + * atomic64_add_return_unchecked - add and return
15115 + * @i: integer value to add
15116 + * @v: pointer to type atomic64_unchecked_t
15117 + *
15118 + * Atomically adds @i to @v and returns @i + @v
15119 + */
15120 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
15121 +{
15122 return i + xadd(&v->counter, i);
15123 }
15124
15125 @@ -179,6 +337,10 @@ static inline long atomic64_sub_return(long i, atomic64_t *v)
15126 }
15127
15128 #define atomic64_inc_return(v) (atomic64_add_return(1, (v)))
15129 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
15130 +{
15131 + return atomic64_add_return_unchecked(1, v);
15132 +}
15133 #define atomic64_dec_return(v) (atomic64_sub_return(1, (v)))
15134
15135 static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
15136 @@ -186,6 +348,11 @@ static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
15137 return cmpxchg(&v->counter, old, new);
15138 }
15139
15140 +static inline long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long old, long new)
15141 +{
15142 + return cmpxchg(&v->counter, old, new);
15143 +}
15144 +
15145 static inline long atomic64_xchg(atomic64_t *v, long new)
15146 {
15147 return xchg(&v->counter, new);
15148 @@ -202,17 +369,30 @@ static inline long atomic64_xchg(atomic64_t *v, long new)
15149 */
15150 static inline int atomic64_add_unless(atomic64_t *v, long a, long u)
15151 {
15152 - long c, old;
15153 + long c, old, new;
15154 c = atomic64_read(v);
15155 for (;;) {
15156 - if (unlikely(c == (u)))
15157 + if (unlikely(c == u))
15158 break;
15159 - old = atomic64_cmpxchg((v), c, c + (a));
15160 +
15161 + asm volatile("add %2,%0\n"
15162 +
15163 +#ifdef CONFIG_PAX_REFCOUNT
15164 + "jno 0f\n"
15165 + "sub %2,%0\n"
15166 + "int $4\n0:\n"
15167 + _ASM_EXTABLE(0b, 0b)
15168 +#endif
15169 +
15170 + : "=r" (new)
15171 + : "0" (c), "ir" (a));
15172 +
15173 + old = atomic64_cmpxchg(v, c, new);
15174 if (likely(old == c))
15175 break;
15176 c = old;
15177 }
15178 - return c != (u);
15179 + return c != u;
15180 }
15181
15182 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
15183 diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h
15184 index 41639ce..ebce552 100644
15185 --- a/arch/x86/include/asm/bitops.h
15186 +++ b/arch/x86/include/asm/bitops.h
15187 @@ -48,7 +48,7 @@
15188 * a mask operation on a byte.
15189 */
15190 #define IS_IMMEDIATE(nr) (__builtin_constant_p(nr))
15191 -#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((void *)(addr) + ((nr)>>3))
15192 +#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((volatile void *)(addr) + ((nr)>>3))
15193 #define CONST_MASK(nr) (1 << ((nr) & 7))
15194
15195 /**
15196 @@ -361,7 +361,7 @@ static int test_bit(int nr, const volatile unsigned long *addr);
15197 *
15198 * Undefined if no bit exists, so code should check against 0 first.
15199 */
15200 -static inline unsigned long __ffs(unsigned long word)
15201 +static inline unsigned long __intentional_overflow(-1) __ffs(unsigned long word)
15202 {
15203 asm("rep; bsf %1,%0"
15204 : "=r" (word)
15205 @@ -375,7 +375,7 @@ static inline unsigned long __ffs(unsigned long word)
15206 *
15207 * Undefined if no zero exists, so code should check against ~0UL first.
15208 */
15209 -static inline unsigned long ffz(unsigned long word)
15210 +static inline unsigned long __intentional_overflow(-1) ffz(unsigned long word)
15211 {
15212 asm("rep; bsf %1,%0"
15213 : "=r" (word)
15214 @@ -389,7 +389,7 @@ static inline unsigned long ffz(unsigned long word)
15215 *
15216 * Undefined if no set bit exists, so code should check against 0 first.
15217 */
15218 -static inline unsigned long __fls(unsigned long word)
15219 +static inline unsigned long __intentional_overflow(-1) __fls(unsigned long word)
15220 {
15221 asm("bsr %1,%0"
15222 : "=r" (word)
15223 @@ -452,7 +452,7 @@ static inline int ffs(int x)
15224 * set bit if value is nonzero. The last (most significant) bit is
15225 * at position 32.
15226 */
15227 -static inline int fls(int x)
15228 +static inline int __intentional_overflow(-1) fls(int x)
15229 {
15230 int r;
15231
15232 @@ -494,7 +494,7 @@ static inline int fls(int x)
15233 * at position 64.
15234 */
15235 #ifdef CONFIG_X86_64
15236 -static __always_inline int fls64(__u64 x)
15237 +static __always_inline long fls64(__u64 x)
15238 {
15239 int bitpos = -1;
15240 /*
15241 diff --git a/arch/x86/include/asm/boot.h b/arch/x86/include/asm/boot.h
15242 index 4fa687a..60f2d39 100644
15243 --- a/arch/x86/include/asm/boot.h
15244 +++ b/arch/x86/include/asm/boot.h
15245 @@ -6,10 +6,15 @@
15246 #include <uapi/asm/boot.h>
15247
15248 /* Physical address where kernel should be loaded. */
15249 -#define LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
15250 +#define ____LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
15251 + (CONFIG_PHYSICAL_ALIGN - 1)) \
15252 & ~(CONFIG_PHYSICAL_ALIGN - 1))
15253
15254 +#ifndef __ASSEMBLY__
15255 +extern unsigned char __LOAD_PHYSICAL_ADDR[];
15256 +#define LOAD_PHYSICAL_ADDR ((unsigned long)__LOAD_PHYSICAL_ADDR)
15257 +#endif
15258 +
15259 /* Minimum kernel alignment, as a power of two */
15260 #ifdef CONFIG_X86_64
15261 #define MIN_KERNEL_ALIGN_LG2 PMD_SHIFT
15262 diff --git a/arch/x86/include/asm/cache.h b/arch/x86/include/asm/cache.h
15263 index 48f99f1..d78ebf9 100644
15264 --- a/arch/x86/include/asm/cache.h
15265 +++ b/arch/x86/include/asm/cache.h
15266 @@ -5,12 +5,13 @@
15267
15268 /* L1 cache line size */
15269 #define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
15270 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
15271 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
15272
15273 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
15274 +#define __read_only __attribute__((__section__(".data..read_only")))
15275
15276 #define INTERNODE_CACHE_SHIFT CONFIG_X86_INTERNODE_CACHE_SHIFT
15277 -#define INTERNODE_CACHE_BYTES (1 << INTERNODE_CACHE_SHIFT)
15278 +#define INTERNODE_CACHE_BYTES (_AC(1,UL) << INTERNODE_CACHE_SHIFT)
15279
15280 #ifdef CONFIG_X86_VSMP
15281 #ifdef CONFIG_SMP
15282 diff --git a/arch/x86/include/asm/cacheflush.h b/arch/x86/include/asm/cacheflush.h
15283 index 9863ee3..4a1f8e1 100644
15284 --- a/arch/x86/include/asm/cacheflush.h
15285 +++ b/arch/x86/include/asm/cacheflush.h
15286 @@ -27,7 +27,7 @@ static inline unsigned long get_page_memtype(struct page *pg)
15287 unsigned long pg_flags = pg->flags & _PGMT_MASK;
15288
15289 if (pg_flags == _PGMT_DEFAULT)
15290 - return -1;
15291 + return ~0UL;
15292 else if (pg_flags == _PGMT_WC)
15293 return _PAGE_CACHE_WC;
15294 else if (pg_flags == _PGMT_UC_MINUS)
15295 diff --git a/arch/x86/include/asm/calling.h b/arch/x86/include/asm/calling.h
15296 index 0fa6750..cb7b2c3 100644
15297 --- a/arch/x86/include/asm/calling.h
15298 +++ b/arch/x86/include/asm/calling.h
15299 @@ -80,103 +80,113 @@ For 32-bit we have the following conventions - kernel is built with
15300 #define RSP 152
15301 #define SS 160
15302
15303 -#define ARGOFFSET R11
15304 -#define SWFRAME ORIG_RAX
15305 +#define ARGOFFSET R15
15306
15307 .macro SAVE_ARGS addskip=0, save_rcx=1, save_r891011=1
15308 - subq $9*8+\addskip, %rsp
15309 - CFI_ADJUST_CFA_OFFSET 9*8+\addskip
15310 - movq_cfi rdi, 8*8
15311 - movq_cfi rsi, 7*8
15312 - movq_cfi rdx, 6*8
15313 + subq $ORIG_RAX-ARGOFFSET+\addskip, %rsp
15314 + CFI_ADJUST_CFA_OFFSET ORIG_RAX-ARGOFFSET+\addskip
15315 + movq_cfi rdi, RDI
15316 + movq_cfi rsi, RSI
15317 + movq_cfi rdx, RDX
15318
15319 .if \save_rcx
15320 - movq_cfi rcx, 5*8
15321 + movq_cfi rcx, RCX
15322 .endif
15323
15324 - movq_cfi rax, 4*8
15325 + movq_cfi rax, RAX
15326
15327 .if \save_r891011
15328 - movq_cfi r8, 3*8
15329 - movq_cfi r9, 2*8
15330 - movq_cfi r10, 1*8
15331 - movq_cfi r11, 0*8
15332 + movq_cfi r8, R8
15333 + movq_cfi r9, R9
15334 + movq_cfi r10, R10
15335 + movq_cfi r11, R11
15336 .endif
15337
15338 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
15339 + movq_cfi r12, R12
15340 +#endif
15341 +
15342 .endm
15343
15344 -#define ARG_SKIP (9*8)
15345 +#define ARG_SKIP ORIG_RAX
15346
15347 .macro RESTORE_ARGS rstor_rax=1, addskip=0, rstor_rcx=1, rstor_r11=1, \
15348 rstor_r8910=1, rstor_rdx=1
15349 +
15350 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
15351 + movq_cfi_restore R12, r12
15352 +#endif
15353 +
15354 .if \rstor_r11
15355 - movq_cfi_restore 0*8, r11
15356 + movq_cfi_restore R11, r11
15357 .endif
15358
15359 .if \rstor_r8910
15360 - movq_cfi_restore 1*8, r10
15361 - movq_cfi_restore 2*8, r9
15362 - movq_cfi_restore 3*8, r8
15363 + movq_cfi_restore R10, r10
15364 + movq_cfi_restore R9, r9
15365 + movq_cfi_restore R8, r8
15366 .endif
15367
15368 .if \rstor_rax
15369 - movq_cfi_restore 4*8, rax
15370 + movq_cfi_restore RAX, rax
15371 .endif
15372
15373 .if \rstor_rcx
15374 - movq_cfi_restore 5*8, rcx
15375 + movq_cfi_restore RCX, rcx
15376 .endif
15377
15378 .if \rstor_rdx
15379 - movq_cfi_restore 6*8, rdx
15380 + movq_cfi_restore RDX, rdx
15381 .endif
15382
15383 - movq_cfi_restore 7*8, rsi
15384 - movq_cfi_restore 8*8, rdi
15385 + movq_cfi_restore RSI, rsi
15386 + movq_cfi_restore RDI, rdi
15387
15388 - .if ARG_SKIP+\addskip > 0
15389 - addq $ARG_SKIP+\addskip, %rsp
15390 - CFI_ADJUST_CFA_OFFSET -(ARG_SKIP+\addskip)
15391 + .if ORIG_RAX+\addskip > 0
15392 + addq $ORIG_RAX+\addskip, %rsp
15393 + CFI_ADJUST_CFA_OFFSET -(ORIG_RAX+\addskip)
15394 .endif
15395 .endm
15396
15397 - .macro LOAD_ARGS offset, skiprax=0
15398 - movq \offset(%rsp), %r11
15399 - movq \offset+8(%rsp), %r10
15400 - movq \offset+16(%rsp), %r9
15401 - movq \offset+24(%rsp), %r8
15402 - movq \offset+40(%rsp), %rcx
15403 - movq \offset+48(%rsp), %rdx
15404 - movq \offset+56(%rsp), %rsi
15405 - movq \offset+64(%rsp), %rdi
15406 + .macro LOAD_ARGS skiprax=0
15407 + movq R11(%rsp), %r11
15408 + movq R10(%rsp), %r10
15409 + movq R9(%rsp), %r9
15410 + movq R8(%rsp), %r8
15411 + movq RCX(%rsp), %rcx
15412 + movq RDX(%rsp), %rdx
15413 + movq RSI(%rsp), %rsi
15414 + movq RDI(%rsp), %rdi
15415 .if \skiprax
15416 .else
15417 - movq \offset+72(%rsp), %rax
15418 + movq RAX(%rsp), %rax
15419 .endif
15420 .endm
15421
15422 -#define REST_SKIP (6*8)
15423 -
15424 .macro SAVE_REST
15425 - subq $REST_SKIP, %rsp
15426 - CFI_ADJUST_CFA_OFFSET REST_SKIP
15427 - movq_cfi rbx, 5*8
15428 - movq_cfi rbp, 4*8
15429 - movq_cfi r12, 3*8
15430 - movq_cfi r13, 2*8
15431 - movq_cfi r14, 1*8
15432 - movq_cfi r15, 0*8
15433 + movq_cfi rbx, RBX
15434 + movq_cfi rbp, RBP
15435 +
15436 +#ifndef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
15437 + movq_cfi r12, R12
15438 +#endif
15439 +
15440 + movq_cfi r13, R13
15441 + movq_cfi r14, R14
15442 + movq_cfi r15, R15
15443 .endm
15444
15445 .macro RESTORE_REST
15446 - movq_cfi_restore 0*8, r15
15447 - movq_cfi_restore 1*8, r14
15448 - movq_cfi_restore 2*8, r13
15449 - movq_cfi_restore 3*8, r12
15450 - movq_cfi_restore 4*8, rbp
15451 - movq_cfi_restore 5*8, rbx
15452 - addq $REST_SKIP, %rsp
15453 - CFI_ADJUST_CFA_OFFSET -(REST_SKIP)
15454 + movq_cfi_restore R15, r15
15455 + movq_cfi_restore R14, r14
15456 + movq_cfi_restore R13, r13
15457 +
15458 +#ifndef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
15459 + movq_cfi_restore R12, r12
15460 +#endif
15461 +
15462 + movq_cfi_restore RBP, rbp
15463 + movq_cfi_restore RBX, rbx
15464 .endm
15465
15466 .macro SAVE_ALL
15467 diff --git a/arch/x86/include/asm/checksum_32.h b/arch/x86/include/asm/checksum_32.h
15468 index f50de69..2b0a458 100644
15469 --- a/arch/x86/include/asm/checksum_32.h
15470 +++ b/arch/x86/include/asm/checksum_32.h
15471 @@ -31,6 +31,14 @@ asmlinkage __wsum csum_partial_copy_generic(const void *src, void *dst,
15472 int len, __wsum sum,
15473 int *src_err_ptr, int *dst_err_ptr);
15474
15475 +asmlinkage __wsum csum_partial_copy_generic_to_user(const void *src, void *dst,
15476 + int len, __wsum sum,
15477 + int *src_err_ptr, int *dst_err_ptr);
15478 +
15479 +asmlinkage __wsum csum_partial_copy_generic_from_user(const void *src, void *dst,
15480 + int len, __wsum sum,
15481 + int *src_err_ptr, int *dst_err_ptr);
15482 +
15483 /*
15484 * Note: when you get a NULL pointer exception here this means someone
15485 * passed in an incorrect kernel address to one of these functions.
15486 @@ -53,7 +61,7 @@ static inline __wsum csum_partial_copy_from_user(const void __user *src,
15487
15488 might_sleep();
15489 stac();
15490 - ret = csum_partial_copy_generic((__force void *)src, dst,
15491 + ret = csum_partial_copy_generic_from_user((__force void *)src, dst,
15492 len, sum, err_ptr, NULL);
15493 clac();
15494
15495 @@ -187,7 +195,7 @@ static inline __wsum csum_and_copy_to_user(const void *src,
15496 might_sleep();
15497 if (access_ok(VERIFY_WRITE, dst, len)) {
15498 stac();
15499 - ret = csum_partial_copy_generic(src, (__force void *)dst,
15500 + ret = csum_partial_copy_generic_to_user(src, (__force void *)dst,
15501 len, sum, NULL, err_ptr);
15502 clac();
15503 return ret;
15504 diff --git a/arch/x86/include/asm/cmpxchg.h b/arch/x86/include/asm/cmpxchg.h
15505 index d47786a..ce1b05d 100644
15506 --- a/arch/x86/include/asm/cmpxchg.h
15507 +++ b/arch/x86/include/asm/cmpxchg.h
15508 @@ -14,8 +14,12 @@ extern void __cmpxchg_wrong_size(void)
15509 __compiletime_error("Bad argument size for cmpxchg");
15510 extern void __xadd_wrong_size(void)
15511 __compiletime_error("Bad argument size for xadd");
15512 +extern void __xadd_check_overflow_wrong_size(void)
15513 + __compiletime_error("Bad argument size for xadd_check_overflow");
15514 extern void __add_wrong_size(void)
15515 __compiletime_error("Bad argument size for add");
15516 +extern void __add_check_overflow_wrong_size(void)
15517 + __compiletime_error("Bad argument size for add_check_overflow");
15518
15519 /*
15520 * Constants for operation sizes. On 32-bit, the 64-bit size it set to
15521 @@ -67,6 +71,34 @@ extern void __add_wrong_size(void)
15522 __ret; \
15523 })
15524
15525 +#define __xchg_op_check_overflow(ptr, arg, op, lock) \
15526 + ({ \
15527 + __typeof__ (*(ptr)) __ret = (arg); \
15528 + switch (sizeof(*(ptr))) { \
15529 + case __X86_CASE_L: \
15530 + asm volatile (lock #op "l %0, %1\n" \
15531 + "jno 0f\n" \
15532 + "mov %0,%1\n" \
15533 + "int $4\n0:\n" \
15534 + _ASM_EXTABLE(0b, 0b) \
15535 + : "+r" (__ret), "+m" (*(ptr)) \
15536 + : : "memory", "cc"); \
15537 + break; \
15538 + case __X86_CASE_Q: \
15539 + asm volatile (lock #op "q %q0, %1\n" \
15540 + "jno 0f\n" \
15541 + "mov %0,%1\n" \
15542 + "int $4\n0:\n" \
15543 + _ASM_EXTABLE(0b, 0b) \
15544 + : "+r" (__ret), "+m" (*(ptr)) \
15545 + : : "memory", "cc"); \
15546 + break; \
15547 + default: \
15548 + __ ## op ## _check_overflow_wrong_size(); \
15549 + } \
15550 + __ret; \
15551 + })
15552 +
15553 /*
15554 * Note: no "lock" prefix even on SMP: xchg always implies lock anyway.
15555 * Since this is generally used to protect other memory information, we
15556 @@ -167,6 +199,9 @@ extern void __add_wrong_size(void)
15557 #define xadd_sync(ptr, inc) __xadd((ptr), (inc), "lock; ")
15558 #define xadd_local(ptr, inc) __xadd((ptr), (inc), "")
15559
15560 +#define __xadd_check_overflow(ptr, inc, lock) __xchg_op_check_overflow((ptr), (inc), xadd, lock)
15561 +#define xadd_check_overflow(ptr, inc) __xadd_check_overflow((ptr), (inc), LOCK_PREFIX)
15562 +
15563 #define __add(ptr, inc, lock) \
15564 ({ \
15565 __typeof__ (*(ptr)) __ret = (inc); \
15566 diff --git a/arch/x86/include/asm/compat.h b/arch/x86/include/asm/compat.h
15567 index 59c6c40..5e0b22c 100644
15568 --- a/arch/x86/include/asm/compat.h
15569 +++ b/arch/x86/include/asm/compat.h
15570 @@ -41,7 +41,7 @@ typedef s64 __attribute__((aligned(4))) compat_s64;
15571 typedef u32 compat_uint_t;
15572 typedef u32 compat_ulong_t;
15573 typedef u64 __attribute__((aligned(4))) compat_u64;
15574 -typedef u32 compat_uptr_t;
15575 +typedef u32 __user compat_uptr_t;
15576
15577 struct compat_timespec {
15578 compat_time_t tv_sec;
15579 diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h
15580 index 89270b4..f0abf8e 100644
15581 --- a/arch/x86/include/asm/cpufeature.h
15582 +++ b/arch/x86/include/asm/cpufeature.h
15583 @@ -203,7 +203,7 @@
15584 #define X86_FEATURE_DECODEASSISTS (8*32+12) /* AMD Decode Assists support */
15585 #define X86_FEATURE_PAUSEFILTER (8*32+13) /* AMD filtered pause intercept */
15586 #define X86_FEATURE_PFTHRESHOLD (8*32+14) /* AMD pause filter threshold */
15587 -
15588 +#define X86_FEATURE_STRONGUDEREF (8*32+31) /* PaX PCID based strong UDEREF */
15589
15590 /* Intel-defined CPU features, CPUID level 0x00000007:0 (ebx), word 9 */
15591 #define X86_FEATURE_FSGSBASE (9*32+ 0) /* {RD/WR}{FS/GS}BASE instructions*/
15592 @@ -211,7 +211,7 @@
15593 #define X86_FEATURE_BMI1 (9*32+ 3) /* 1st group bit manipulation extensions */
15594 #define X86_FEATURE_HLE (9*32+ 4) /* Hardware Lock Elision */
15595 #define X86_FEATURE_AVX2 (9*32+ 5) /* AVX2 instructions */
15596 -#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Protection */
15597 +#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Prevention */
15598 #define X86_FEATURE_BMI2 (9*32+ 8) /* 2nd group bit manipulation extensions */
15599 #define X86_FEATURE_ERMS (9*32+ 9) /* Enhanced REP MOVSB/STOSB */
15600 #define X86_FEATURE_INVPCID (9*32+10) /* Invalidate Processor Context ID */
15601 @@ -353,6 +353,7 @@ extern const char * const x86_power_flags[32];
15602 #undef cpu_has_centaur_mcr
15603 #define cpu_has_centaur_mcr 0
15604
15605 +#define cpu_has_pcid boot_cpu_has(X86_FEATURE_PCID)
15606 #endif /* CONFIG_X86_64 */
15607
15608 #if __GNUC__ >= 4
15609 @@ -405,7 +406,8 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
15610
15611 #ifdef CONFIG_X86_DEBUG_STATIC_CPU_HAS
15612 t_warn:
15613 - warn_pre_alternatives();
15614 + if (bit != X86_FEATURE_PCID && bit != X86_FEATURE_INVPCID)
15615 + warn_pre_alternatives();
15616 return false;
15617 #endif
15618
15619 @@ -425,7 +427,7 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
15620 ".section .discard,\"aw\",@progbits\n"
15621 " .byte 0xff + (4f-3f) - (2b-1b)\n" /* size check */
15622 ".previous\n"
15623 - ".section .altinstr_replacement,\"ax\"\n"
15624 + ".section .altinstr_replacement,\"a\"\n"
15625 "3: movb $1,%0\n"
15626 "4:\n"
15627 ".previous\n"
15628 @@ -462,7 +464,7 @@ static __always_inline __pure bool _static_cpu_has_safe(u16 bit)
15629 " .byte 2b - 1b\n" /* src len */
15630 " .byte 4f - 3f\n" /* repl len */
15631 ".previous\n"
15632 - ".section .altinstr_replacement,\"ax\"\n"
15633 + ".section .altinstr_replacement,\"a\"\n"
15634 "3: .byte 0xe9\n .long %l[t_no] - 2b\n"
15635 "4:\n"
15636 ".previous\n"
15637 @@ -495,7 +497,7 @@ static __always_inline __pure bool _static_cpu_has_safe(u16 bit)
15638 ".section .discard,\"aw\",@progbits\n"
15639 " .byte 0xff + (4f-3f) - (2b-1b)\n" /* size check */
15640 ".previous\n"
15641 - ".section .altinstr_replacement,\"ax\"\n"
15642 + ".section .altinstr_replacement,\"a\"\n"
15643 "3: movb $0,%0\n"
15644 "4:\n"
15645 ".previous\n"
15646 @@ -509,7 +511,7 @@ static __always_inline __pure bool _static_cpu_has_safe(u16 bit)
15647 ".section .discard,\"aw\",@progbits\n"
15648 " .byte 0xff + (6f-5f) - (4b-3b)\n" /* size check */
15649 ".previous\n"
15650 - ".section .altinstr_replacement,\"ax\"\n"
15651 + ".section .altinstr_replacement,\"a\"\n"
15652 "5: movb $1,%0\n"
15653 "6:\n"
15654 ".previous\n"
15655 diff --git a/arch/x86/include/asm/desc.h b/arch/x86/include/asm/desc.h
15656 index b90e5df..b462c91 100644
15657 --- a/arch/x86/include/asm/desc.h
15658 +++ b/arch/x86/include/asm/desc.h
15659 @@ -4,6 +4,7 @@
15660 #include <asm/desc_defs.h>
15661 #include <asm/ldt.h>
15662 #include <asm/mmu.h>
15663 +#include <asm/pgtable.h>
15664
15665 #include <linux/smp.h>
15666 #include <linux/percpu.h>
15667 @@ -17,6 +18,7 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
15668
15669 desc->type = (info->read_exec_only ^ 1) << 1;
15670 desc->type |= info->contents << 2;
15671 + desc->type |= info->seg_not_present ^ 1;
15672
15673 desc->s = 1;
15674 desc->dpl = 0x3;
15675 @@ -35,19 +37,14 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
15676 }
15677
15678 extern struct desc_ptr idt_descr;
15679 -extern gate_desc idt_table[];
15680 -extern struct desc_ptr debug_idt_descr;
15681 -extern gate_desc debug_idt_table[];
15682 -
15683 -struct gdt_page {
15684 - struct desc_struct gdt[GDT_ENTRIES];
15685 -} __attribute__((aligned(PAGE_SIZE)));
15686 -
15687 -DECLARE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page);
15688 +extern gate_desc idt_table[IDT_ENTRIES];
15689 +extern const struct desc_ptr debug_idt_descr;
15690 +extern gate_desc debug_idt_table[IDT_ENTRIES];
15691
15692 +extern struct desc_struct cpu_gdt_table[NR_CPUS][PAGE_SIZE / sizeof(struct desc_struct)];
15693 static inline struct desc_struct *get_cpu_gdt_table(unsigned int cpu)
15694 {
15695 - return per_cpu(gdt_page, cpu).gdt;
15696 + return cpu_gdt_table[cpu];
15697 }
15698
15699 #ifdef CONFIG_X86_64
15700 @@ -72,8 +69,14 @@ static inline void pack_gate(gate_desc *gate, unsigned char type,
15701 unsigned long base, unsigned dpl, unsigned flags,
15702 unsigned short seg)
15703 {
15704 - gate->a = (seg << 16) | (base & 0xffff);
15705 - gate->b = (base & 0xffff0000) | (((0x80 | type | (dpl << 5)) & 0xff) << 8);
15706 + gate->gate.offset_low = base;
15707 + gate->gate.seg = seg;
15708 + gate->gate.reserved = 0;
15709 + gate->gate.type = type;
15710 + gate->gate.s = 0;
15711 + gate->gate.dpl = dpl;
15712 + gate->gate.p = 1;
15713 + gate->gate.offset_high = base >> 16;
15714 }
15715
15716 #endif
15717 @@ -118,12 +121,16 @@ static inline void paravirt_free_ldt(struct desc_struct *ldt, unsigned entries)
15718
15719 static inline void native_write_idt_entry(gate_desc *idt, int entry, const gate_desc *gate)
15720 {
15721 + pax_open_kernel();
15722 memcpy(&idt[entry], gate, sizeof(*gate));
15723 + pax_close_kernel();
15724 }
15725
15726 static inline void native_write_ldt_entry(struct desc_struct *ldt, int entry, const void *desc)
15727 {
15728 + pax_open_kernel();
15729 memcpy(&ldt[entry], desc, 8);
15730 + pax_close_kernel();
15731 }
15732
15733 static inline void
15734 @@ -137,7 +144,9 @@ native_write_gdt_entry(struct desc_struct *gdt, int entry, const void *desc, int
15735 default: size = sizeof(*gdt); break;
15736 }
15737
15738 + pax_open_kernel();
15739 memcpy(&gdt[entry], desc, size);
15740 + pax_close_kernel();
15741 }
15742
15743 static inline void pack_descriptor(struct desc_struct *desc, unsigned long base,
15744 @@ -210,7 +219,9 @@ static inline void native_set_ldt(const void *addr, unsigned int entries)
15745
15746 static inline void native_load_tr_desc(void)
15747 {
15748 + pax_open_kernel();
15749 asm volatile("ltr %w0"::"q" (GDT_ENTRY_TSS*8));
15750 + pax_close_kernel();
15751 }
15752
15753 static inline void native_load_gdt(const struct desc_ptr *dtr)
15754 @@ -247,8 +258,10 @@ static inline void native_load_tls(struct thread_struct *t, unsigned int cpu)
15755 struct desc_struct *gdt = get_cpu_gdt_table(cpu);
15756 unsigned int i;
15757
15758 + pax_open_kernel();
15759 for (i = 0; i < GDT_ENTRY_TLS_ENTRIES; i++)
15760 gdt[GDT_ENTRY_TLS_MIN + i] = t->tls_array[i];
15761 + pax_close_kernel();
15762 }
15763
15764 #define _LDT_empty(info) \
15765 @@ -287,7 +300,7 @@ static inline void load_LDT(mm_context_t *pc)
15766 preempt_enable();
15767 }
15768
15769 -static inline unsigned long get_desc_base(const struct desc_struct *desc)
15770 +static inline unsigned long __intentional_overflow(-1) get_desc_base(const struct desc_struct *desc)
15771 {
15772 return (unsigned)(desc->base0 | ((desc->base1) << 16) | ((desc->base2) << 24));
15773 }
15774 @@ -311,7 +324,7 @@ static inline void set_desc_limit(struct desc_struct *desc, unsigned long limit)
15775 }
15776
15777 #ifdef CONFIG_X86_64
15778 -static inline void set_nmi_gate(int gate, void *addr)
15779 +static inline void set_nmi_gate(int gate, const void *addr)
15780 {
15781 gate_desc s;
15782
15783 @@ -321,8 +334,8 @@ static inline void set_nmi_gate(int gate, void *addr)
15784 #endif
15785
15786 #ifdef CONFIG_TRACING
15787 -extern struct desc_ptr trace_idt_descr;
15788 -extern gate_desc trace_idt_table[];
15789 +extern const struct desc_ptr trace_idt_descr;
15790 +extern gate_desc trace_idt_table[IDT_ENTRIES];
15791 static inline void write_trace_idt_entry(int entry, const gate_desc *gate)
15792 {
15793 write_idt_entry(trace_idt_table, entry, gate);
15794 @@ -333,7 +346,7 @@ static inline void write_trace_idt_entry(int entry, const gate_desc *gate)
15795 }
15796 #endif
15797
15798 -static inline void _set_gate(int gate, unsigned type, void *addr,
15799 +static inline void _set_gate(int gate, unsigned type, const void *addr,
15800 unsigned dpl, unsigned ist, unsigned seg)
15801 {
15802 gate_desc s;
15803 @@ -353,7 +366,7 @@ static inline void _set_gate(int gate, unsigned type, void *addr,
15804 * Pentium F0 0F bugfix can have resulted in the mapped
15805 * IDT being write-protected.
15806 */
15807 -static inline void set_intr_gate(unsigned int n, void *addr)
15808 +static inline void set_intr_gate(unsigned int n, const void *addr)
15809 {
15810 BUG_ON((unsigned)n > 0xFF);
15811 _set_gate(n, GATE_INTERRUPT, addr, 0, 0, __KERNEL_CS);
15812 @@ -410,19 +423,19 @@ static inline void __alloc_intr_gate(unsigned int n, void *addr)
15813 /*
15814 * This routine sets up an interrupt gate at directory privilege level 3.
15815 */
15816 -static inline void set_system_intr_gate(unsigned int n, void *addr)
15817 +static inline void set_system_intr_gate(unsigned int n, const void *addr)
15818 {
15819 BUG_ON((unsigned)n > 0xFF);
15820 _set_gate(n, GATE_INTERRUPT, addr, 0x3, 0, __KERNEL_CS);
15821 }
15822
15823 -static inline void set_system_trap_gate(unsigned int n, void *addr)
15824 +static inline void set_system_trap_gate(unsigned int n, const void *addr)
15825 {
15826 BUG_ON((unsigned)n > 0xFF);
15827 _set_gate(n, GATE_TRAP, addr, 0x3, 0, __KERNEL_CS);
15828 }
15829
15830 -static inline void set_trap_gate(unsigned int n, void *addr)
15831 +static inline void set_trap_gate(unsigned int n, const void *addr)
15832 {
15833 BUG_ON((unsigned)n > 0xFF);
15834 _set_gate(n, GATE_TRAP, addr, 0, 0, __KERNEL_CS);
15835 @@ -431,16 +444,16 @@ static inline void set_trap_gate(unsigned int n, void *addr)
15836 static inline void set_task_gate(unsigned int n, unsigned int gdt_entry)
15837 {
15838 BUG_ON((unsigned)n > 0xFF);
15839 - _set_gate(n, GATE_TASK, (void *)0, 0, 0, (gdt_entry<<3));
15840 + _set_gate(n, GATE_TASK, (const void *)0, 0, 0, (gdt_entry<<3));
15841 }
15842
15843 -static inline void set_intr_gate_ist(int n, void *addr, unsigned ist)
15844 +static inline void set_intr_gate_ist(int n, const void *addr, unsigned ist)
15845 {
15846 BUG_ON((unsigned)n > 0xFF);
15847 _set_gate(n, GATE_INTERRUPT, addr, 0, ist, __KERNEL_CS);
15848 }
15849
15850 -static inline void set_system_intr_gate_ist(int n, void *addr, unsigned ist)
15851 +static inline void set_system_intr_gate_ist(int n, const void *addr, unsigned ist)
15852 {
15853 BUG_ON((unsigned)n > 0xFF);
15854 _set_gate(n, GATE_INTERRUPT, addr, 0x3, ist, __KERNEL_CS);
15855 @@ -512,4 +525,17 @@ static inline void load_current_idt(void)
15856 else
15857 load_idt((const struct desc_ptr *)&idt_descr);
15858 }
15859 +
15860 +#ifdef CONFIG_X86_32
15861 +static inline void set_user_cs(unsigned long base, unsigned long limit, int cpu)
15862 +{
15863 + struct desc_struct d;
15864 +
15865 + if (likely(limit))
15866 + limit = (limit - 1UL) >> PAGE_SHIFT;
15867 + pack_descriptor(&d, base, limit, 0xFB, 0xC);
15868 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_DEFAULT_USER_CS, &d, DESCTYPE_S);
15869 +}
15870 +#endif
15871 +
15872 #endif /* _ASM_X86_DESC_H */
15873 diff --git a/arch/x86/include/asm/desc_defs.h b/arch/x86/include/asm/desc_defs.h
15874 index 278441f..b95a174 100644
15875 --- a/arch/x86/include/asm/desc_defs.h
15876 +++ b/arch/x86/include/asm/desc_defs.h
15877 @@ -31,6 +31,12 @@ struct desc_struct {
15878 unsigned base1: 8, type: 4, s: 1, dpl: 2, p: 1;
15879 unsigned limit: 4, avl: 1, l: 1, d: 1, g: 1, base2: 8;
15880 };
15881 + struct {
15882 + u16 offset_low;
15883 + u16 seg;
15884 + unsigned reserved: 8, type: 4, s: 1, dpl: 2, p: 1;
15885 + unsigned offset_high: 16;
15886 + } gate;
15887 };
15888 } __attribute__((packed));
15889
15890 diff --git a/arch/x86/include/asm/div64.h b/arch/x86/include/asm/div64.h
15891 index ced283a..ffe04cc 100644
15892 --- a/arch/x86/include/asm/div64.h
15893 +++ b/arch/x86/include/asm/div64.h
15894 @@ -39,7 +39,7 @@
15895 __mod; \
15896 })
15897
15898 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
15899 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
15900 {
15901 union {
15902 u64 v64;
15903 diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h
15904 index 9c999c1..3860cb8 100644
15905 --- a/arch/x86/include/asm/elf.h
15906 +++ b/arch/x86/include/asm/elf.h
15907 @@ -243,7 +243,25 @@ extern int force_personality32;
15908 the loader. We need to make sure that it is out of the way of the program
15909 that it will "exec", and that there is sufficient room for the brk. */
15910
15911 +#ifdef CONFIG_PAX_SEGMEXEC
15912 +#define ELF_ET_DYN_BASE ((current->mm->pax_flags & MF_PAX_SEGMEXEC) ? SEGMEXEC_TASK_SIZE/3*2 : TASK_SIZE/3*2)
15913 +#else
15914 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
15915 +#endif
15916 +
15917 +#ifdef CONFIG_PAX_ASLR
15918 +#ifdef CONFIG_X86_32
15919 +#define PAX_ELF_ET_DYN_BASE 0x10000000UL
15920 +
15921 +#define PAX_DELTA_MMAP_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
15922 +#define PAX_DELTA_STACK_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
15923 +#else
15924 +#define PAX_ELF_ET_DYN_BASE 0x400000UL
15925 +
15926 +#define PAX_DELTA_MMAP_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
15927 +#define PAX_DELTA_STACK_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
15928 +#endif
15929 +#endif
15930
15931 /* This yields a mask that user programs can use to figure out what
15932 instruction set this CPU supports. This could be done in user space,
15933 @@ -296,16 +314,12 @@ do { \
15934
15935 #define ARCH_DLINFO \
15936 do { \
15937 - if (vdso_enabled) \
15938 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
15939 - (unsigned long)current->mm->context.vdso); \
15940 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
15941 } while (0)
15942
15943 #define ARCH_DLINFO_X32 \
15944 do { \
15945 - if (vdso_enabled) \
15946 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
15947 - (unsigned long)current->mm->context.vdso); \
15948 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
15949 } while (0)
15950
15951 #define AT_SYSINFO 32
15952 @@ -320,7 +334,7 @@ else \
15953
15954 #endif /* !CONFIG_X86_32 */
15955
15956 -#define VDSO_CURRENT_BASE ((unsigned long)current->mm->context.vdso)
15957 +#define VDSO_CURRENT_BASE (current->mm->context.vdso)
15958
15959 #define VDSO_ENTRY \
15960 ((unsigned long)VDSO32_SYMBOL(VDSO_CURRENT_BASE, vsyscall))
15961 @@ -336,9 +350,6 @@ extern int x32_setup_additional_pages(struct linux_binprm *bprm,
15962 extern int syscall32_setup_pages(struct linux_binprm *, int exstack);
15963 #define compat_arch_setup_additional_pages syscall32_setup_pages
15964
15965 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
15966 -#define arch_randomize_brk arch_randomize_brk
15967 -
15968 /*
15969 * True on X86_32 or when emulating IA32 on X86_64
15970 */
15971 diff --git a/arch/x86/include/asm/emergency-restart.h b/arch/x86/include/asm/emergency-restart.h
15972 index 77a99ac..39ff7f5 100644
15973 --- a/arch/x86/include/asm/emergency-restart.h
15974 +++ b/arch/x86/include/asm/emergency-restart.h
15975 @@ -1,6 +1,6 @@
15976 #ifndef _ASM_X86_EMERGENCY_RESTART_H
15977 #define _ASM_X86_EMERGENCY_RESTART_H
15978
15979 -extern void machine_emergency_restart(void);
15980 +extern void machine_emergency_restart(void) __noreturn;
15981
15982 #endif /* _ASM_X86_EMERGENCY_RESTART_H */
15983 diff --git a/arch/x86/include/asm/fpu-internal.h b/arch/x86/include/asm/fpu-internal.h
15984 index 4d0bda7..221da4d 100644
15985 --- a/arch/x86/include/asm/fpu-internal.h
15986 +++ b/arch/x86/include/asm/fpu-internal.h
15987 @@ -124,8 +124,11 @@ static inline void sanitize_i387_state(struct task_struct *tsk)
15988 #define user_insn(insn, output, input...) \
15989 ({ \
15990 int err; \
15991 + pax_open_userland(); \
15992 asm volatile(ASM_STAC "\n" \
15993 - "1:" #insn "\n\t" \
15994 + "1:" \
15995 + __copyuser_seg \
15996 + #insn "\n\t" \
15997 "2: " ASM_CLAC "\n" \
15998 ".section .fixup,\"ax\"\n" \
15999 "3: movl $-1,%[err]\n" \
16000 @@ -134,6 +137,7 @@ static inline void sanitize_i387_state(struct task_struct *tsk)
16001 _ASM_EXTABLE(1b, 3b) \
16002 : [err] "=r" (err), output \
16003 : "0"(0), input); \
16004 + pax_close_userland(); \
16005 err; \
16006 })
16007
16008 @@ -298,7 +302,7 @@ static inline int restore_fpu_checking(struct task_struct *tsk)
16009 "emms\n\t" /* clear stack tags */
16010 "fildl %P[addr]", /* set F?P to defined value */
16011 X86_FEATURE_FXSAVE_LEAK,
16012 - [addr] "m" (tsk->thread.fpu.has_fpu));
16013 + [addr] "m" (init_tss[raw_smp_processor_id()].x86_tss.sp0));
16014
16015 return fpu_restore_checking(&tsk->thread.fpu);
16016 }
16017 diff --git a/arch/x86/include/asm/futex.h b/arch/x86/include/asm/futex.h
16018 index be27ba1..04a8801 100644
16019 --- a/arch/x86/include/asm/futex.h
16020 +++ b/arch/x86/include/asm/futex.h
16021 @@ -12,6 +12,7 @@
16022 #include <asm/smap.h>
16023
16024 #define __futex_atomic_op1(insn, ret, oldval, uaddr, oparg) \
16025 + typecheck(u32 __user *, uaddr); \
16026 asm volatile("\t" ASM_STAC "\n" \
16027 "1:\t" insn "\n" \
16028 "2:\t" ASM_CLAC "\n" \
16029 @@ -20,15 +21,16 @@
16030 "\tjmp\t2b\n" \
16031 "\t.previous\n" \
16032 _ASM_EXTABLE(1b, 3b) \
16033 - : "=r" (oldval), "=r" (ret), "+m" (*uaddr) \
16034 + : "=r" (oldval), "=r" (ret), "+m" (*(u32 __user *)____m(uaddr)) \
16035 : "i" (-EFAULT), "0" (oparg), "1" (0))
16036
16037 #define __futex_atomic_op2(insn, ret, oldval, uaddr, oparg) \
16038 + typecheck(u32 __user *, uaddr); \
16039 asm volatile("\t" ASM_STAC "\n" \
16040 "1:\tmovl %2, %0\n" \
16041 "\tmovl\t%0, %3\n" \
16042 "\t" insn "\n" \
16043 - "2:\t" LOCK_PREFIX "cmpxchgl %3, %2\n" \
16044 + "2:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %3, %2\n" \
16045 "\tjnz\t1b\n" \
16046 "3:\t" ASM_CLAC "\n" \
16047 "\t.section .fixup,\"ax\"\n" \
16048 @@ -38,7 +40,7 @@
16049 _ASM_EXTABLE(1b, 4b) \
16050 _ASM_EXTABLE(2b, 4b) \
16051 : "=&a" (oldval), "=&r" (ret), \
16052 - "+m" (*uaddr), "=&r" (tem) \
16053 + "+m" (*(u32 __user *)____m(uaddr)), "=&r" (tem) \
16054 : "r" (oparg), "i" (-EFAULT), "1" (0))
16055
16056 static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
16057 @@ -57,12 +59,13 @@ static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
16058
16059 pagefault_disable();
16060
16061 + pax_open_userland();
16062 switch (op) {
16063 case FUTEX_OP_SET:
16064 - __futex_atomic_op1("xchgl %0, %2", ret, oldval, uaddr, oparg);
16065 + __futex_atomic_op1(__copyuser_seg"xchgl %0, %2", ret, oldval, uaddr, oparg);
16066 break;
16067 case FUTEX_OP_ADD:
16068 - __futex_atomic_op1(LOCK_PREFIX "xaddl %0, %2", ret, oldval,
16069 + __futex_atomic_op1(LOCK_PREFIX __copyuser_seg"xaddl %0, %2", ret, oldval,
16070 uaddr, oparg);
16071 break;
16072 case FUTEX_OP_OR:
16073 @@ -77,6 +80,7 @@ static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
16074 default:
16075 ret = -ENOSYS;
16076 }
16077 + pax_close_userland();
16078
16079 pagefault_enable();
16080
16081 @@ -115,18 +119,20 @@ static inline int futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
16082 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
16083 return -EFAULT;
16084
16085 + pax_open_userland();
16086 asm volatile("\t" ASM_STAC "\n"
16087 - "1:\t" LOCK_PREFIX "cmpxchgl %4, %2\n"
16088 + "1:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %4, %2\n"
16089 "2:\t" ASM_CLAC "\n"
16090 "\t.section .fixup, \"ax\"\n"
16091 "3:\tmov %3, %0\n"
16092 "\tjmp 2b\n"
16093 "\t.previous\n"
16094 _ASM_EXTABLE(1b, 3b)
16095 - : "+r" (ret), "=a" (oldval), "+m" (*uaddr)
16096 + : "+r" (ret), "=a" (oldval), "+m" (*(u32 __user *)____m(uaddr))
16097 : "i" (-EFAULT), "r" (newval), "1" (oldval)
16098 : "memory"
16099 );
16100 + pax_close_userland();
16101
16102 *uval = oldval;
16103 return ret;
16104 diff --git a/arch/x86/include/asm/hw_irq.h b/arch/x86/include/asm/hw_irq.h
16105 index 92b3bae..3866449 100644
16106 --- a/arch/x86/include/asm/hw_irq.h
16107 +++ b/arch/x86/include/asm/hw_irq.h
16108 @@ -165,8 +165,8 @@ extern void setup_ioapic_dest(void);
16109 extern void enable_IO_APIC(void);
16110
16111 /* Statistics */
16112 -extern atomic_t irq_err_count;
16113 -extern atomic_t irq_mis_count;
16114 +extern atomic_unchecked_t irq_err_count;
16115 +extern atomic_unchecked_t irq_mis_count;
16116
16117 /* EISA */
16118 extern void eisa_set_level_irq(unsigned int irq);
16119 diff --git a/arch/x86/include/asm/i8259.h b/arch/x86/include/asm/i8259.h
16120 index a203659..9889f1c 100644
16121 --- a/arch/x86/include/asm/i8259.h
16122 +++ b/arch/x86/include/asm/i8259.h
16123 @@ -62,7 +62,7 @@ struct legacy_pic {
16124 void (*init)(int auto_eoi);
16125 int (*irq_pending)(unsigned int irq);
16126 void (*make_irq)(unsigned int irq);
16127 -};
16128 +} __do_const;
16129
16130 extern struct legacy_pic *legacy_pic;
16131 extern struct legacy_pic null_legacy_pic;
16132 diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
16133 index 34f69cb..6d95446 100644
16134 --- a/arch/x86/include/asm/io.h
16135 +++ b/arch/x86/include/asm/io.h
16136 @@ -51,12 +51,12 @@ static inline void name(type val, volatile void __iomem *addr) \
16137 "m" (*(volatile type __force *)addr) barrier); }
16138
16139 build_mmio_read(readb, "b", unsigned char, "=q", :"memory")
16140 -build_mmio_read(readw, "w", unsigned short, "=r", :"memory")
16141 -build_mmio_read(readl, "l", unsigned int, "=r", :"memory")
16142 +build_mmio_read(__intentional_overflow(-1) readw, "w", unsigned short, "=r", :"memory")
16143 +build_mmio_read(__intentional_overflow(-1) readl, "l", unsigned int, "=r", :"memory")
16144
16145 build_mmio_read(__readb, "b", unsigned char, "=q", )
16146 -build_mmio_read(__readw, "w", unsigned short, "=r", )
16147 -build_mmio_read(__readl, "l", unsigned int, "=r", )
16148 +build_mmio_read(__intentional_overflow(-1) __readw, "w", unsigned short, "=r", )
16149 +build_mmio_read(__intentional_overflow(-1) __readl, "l", unsigned int, "=r", )
16150
16151 build_mmio_write(writeb, "b", unsigned char, "q", :"memory")
16152 build_mmio_write(writew, "w", unsigned short, "r", :"memory")
16153 @@ -184,7 +184,7 @@ static inline void __iomem *ioremap(resource_size_t offset, unsigned long size)
16154 return ioremap_nocache(offset, size);
16155 }
16156
16157 -extern void iounmap(volatile void __iomem *addr);
16158 +extern void iounmap(const volatile void __iomem *addr);
16159
16160 extern void set_iounmap_nonlazy(void);
16161
16162 @@ -194,6 +194,17 @@ extern void set_iounmap_nonlazy(void);
16163
16164 #include <linux/vmalloc.h>
16165
16166 +#define ARCH_HAS_VALID_PHYS_ADDR_RANGE
16167 +static inline int valid_phys_addr_range(unsigned long addr, size_t count)
16168 +{
16169 + return ((addr + count + PAGE_SIZE - 1) >> PAGE_SHIFT) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
16170 +}
16171 +
16172 +static inline int valid_mmap_phys_addr_range(unsigned long pfn, size_t count)
16173 +{
16174 + return (pfn + (count >> PAGE_SHIFT)) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
16175 +}
16176 +
16177 /*
16178 * Convert a virtual cached pointer to an uncached pointer
16179 */
16180 diff --git a/arch/x86/include/asm/irqflags.h b/arch/x86/include/asm/irqflags.h
16181 index bba3cf8..06bc8da 100644
16182 --- a/arch/x86/include/asm/irqflags.h
16183 +++ b/arch/x86/include/asm/irqflags.h
16184 @@ -141,6 +141,11 @@ static inline notrace unsigned long arch_local_irq_save(void)
16185 sti; \
16186 sysexit
16187
16188 +#define GET_CR0_INTO_RDI mov %cr0, %rdi
16189 +#define SET_RDI_INTO_CR0 mov %rdi, %cr0
16190 +#define GET_CR3_INTO_RDI mov %cr3, %rdi
16191 +#define SET_RDI_INTO_CR3 mov %rdi, %cr3
16192 +
16193 #else
16194 #define INTERRUPT_RETURN iret
16195 #define ENABLE_INTERRUPTS_SYSEXIT sti; sysexit
16196 diff --git a/arch/x86/include/asm/kprobes.h b/arch/x86/include/asm/kprobes.h
16197 index 9454c16..e4100e3 100644
16198 --- a/arch/x86/include/asm/kprobes.h
16199 +++ b/arch/x86/include/asm/kprobes.h
16200 @@ -38,13 +38,8 @@ typedef u8 kprobe_opcode_t;
16201 #define RELATIVEJUMP_SIZE 5
16202 #define RELATIVECALL_OPCODE 0xe8
16203 #define RELATIVE_ADDR_SIZE 4
16204 -#define MAX_STACK_SIZE 64
16205 -#define MIN_STACK_SIZE(ADDR) \
16206 - (((MAX_STACK_SIZE) < (((unsigned long)current_thread_info()) + \
16207 - THREAD_SIZE - (unsigned long)(ADDR))) \
16208 - ? (MAX_STACK_SIZE) \
16209 - : (((unsigned long)current_thread_info()) + \
16210 - THREAD_SIZE - (unsigned long)(ADDR)))
16211 +#define MAX_STACK_SIZE 64UL
16212 +#define MIN_STACK_SIZE(ADDR) min(MAX_STACK_SIZE, current->thread.sp0 - (unsigned long)(ADDR))
16213
16214 #define flush_insn_slot(p) do { } while (0)
16215
16216 diff --git a/arch/x86/include/asm/local.h b/arch/x86/include/asm/local.h
16217 index 2d89e39..baee879 100644
16218 --- a/arch/x86/include/asm/local.h
16219 +++ b/arch/x86/include/asm/local.h
16220 @@ -10,33 +10,97 @@ typedef struct {
16221 atomic_long_t a;
16222 } local_t;
16223
16224 +typedef struct {
16225 + atomic_long_unchecked_t a;
16226 +} local_unchecked_t;
16227 +
16228 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
16229
16230 #define local_read(l) atomic_long_read(&(l)->a)
16231 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
16232 #define local_set(l, i) atomic_long_set(&(l)->a, (i))
16233 +#define local_set_unchecked(l, i) atomic_long_set_unchecked(&(l)->a, (i))
16234
16235 static inline void local_inc(local_t *l)
16236 {
16237 - asm volatile(_ASM_INC "%0"
16238 + asm volatile(_ASM_INC "%0\n"
16239 +
16240 +#ifdef CONFIG_PAX_REFCOUNT
16241 + "jno 0f\n"
16242 + _ASM_DEC "%0\n"
16243 + "int $4\n0:\n"
16244 + _ASM_EXTABLE(0b, 0b)
16245 +#endif
16246 +
16247 + : "+m" (l->a.counter));
16248 +}
16249 +
16250 +static inline void local_inc_unchecked(local_unchecked_t *l)
16251 +{
16252 + asm volatile(_ASM_INC "%0\n"
16253 : "+m" (l->a.counter));
16254 }
16255
16256 static inline void local_dec(local_t *l)
16257 {
16258 - asm volatile(_ASM_DEC "%0"
16259 + asm volatile(_ASM_DEC "%0\n"
16260 +
16261 +#ifdef CONFIG_PAX_REFCOUNT
16262 + "jno 0f\n"
16263 + _ASM_INC "%0\n"
16264 + "int $4\n0:\n"
16265 + _ASM_EXTABLE(0b, 0b)
16266 +#endif
16267 +
16268 + : "+m" (l->a.counter));
16269 +}
16270 +
16271 +static inline void local_dec_unchecked(local_unchecked_t *l)
16272 +{
16273 + asm volatile(_ASM_DEC "%0\n"
16274 : "+m" (l->a.counter));
16275 }
16276
16277 static inline void local_add(long i, local_t *l)
16278 {
16279 - asm volatile(_ASM_ADD "%1,%0"
16280 + asm volatile(_ASM_ADD "%1,%0\n"
16281 +
16282 +#ifdef CONFIG_PAX_REFCOUNT
16283 + "jno 0f\n"
16284 + _ASM_SUB "%1,%0\n"
16285 + "int $4\n0:\n"
16286 + _ASM_EXTABLE(0b, 0b)
16287 +#endif
16288 +
16289 + : "+m" (l->a.counter)
16290 + : "ir" (i));
16291 +}
16292 +
16293 +static inline void local_add_unchecked(long i, local_unchecked_t *l)
16294 +{
16295 + asm volatile(_ASM_ADD "%1,%0\n"
16296 : "+m" (l->a.counter)
16297 : "ir" (i));
16298 }
16299
16300 static inline void local_sub(long i, local_t *l)
16301 {
16302 - asm volatile(_ASM_SUB "%1,%0"
16303 + asm volatile(_ASM_SUB "%1,%0\n"
16304 +
16305 +#ifdef CONFIG_PAX_REFCOUNT
16306 + "jno 0f\n"
16307 + _ASM_ADD "%1,%0\n"
16308 + "int $4\n0:\n"
16309 + _ASM_EXTABLE(0b, 0b)
16310 +#endif
16311 +
16312 + : "+m" (l->a.counter)
16313 + : "ir" (i));
16314 +}
16315 +
16316 +static inline void local_sub_unchecked(long i, local_unchecked_t *l)
16317 +{
16318 + asm volatile(_ASM_SUB "%1,%0\n"
16319 : "+m" (l->a.counter)
16320 : "ir" (i));
16321 }
16322 @@ -54,7 +118,16 @@ static inline int local_sub_and_test(long i, local_t *l)
16323 {
16324 unsigned char c;
16325
16326 - asm volatile(_ASM_SUB "%2,%0; sete %1"
16327 + asm volatile(_ASM_SUB "%2,%0\n"
16328 +
16329 +#ifdef CONFIG_PAX_REFCOUNT
16330 + "jno 0f\n"
16331 + _ASM_ADD "%2,%0\n"
16332 + "int $4\n0:\n"
16333 + _ASM_EXTABLE(0b, 0b)
16334 +#endif
16335 +
16336 + "sete %1\n"
16337 : "+m" (l->a.counter), "=qm" (c)
16338 : "ir" (i) : "memory");
16339 return c;
16340 @@ -72,7 +145,16 @@ static inline int local_dec_and_test(local_t *l)
16341 {
16342 unsigned char c;
16343
16344 - asm volatile(_ASM_DEC "%0; sete %1"
16345 + asm volatile(_ASM_DEC "%0\n"
16346 +
16347 +#ifdef CONFIG_PAX_REFCOUNT
16348 + "jno 0f\n"
16349 + _ASM_INC "%0\n"
16350 + "int $4\n0:\n"
16351 + _ASM_EXTABLE(0b, 0b)
16352 +#endif
16353 +
16354 + "sete %1\n"
16355 : "+m" (l->a.counter), "=qm" (c)
16356 : : "memory");
16357 return c != 0;
16358 @@ -90,7 +172,16 @@ static inline int local_inc_and_test(local_t *l)
16359 {
16360 unsigned char c;
16361
16362 - asm volatile(_ASM_INC "%0; sete %1"
16363 + asm volatile(_ASM_INC "%0\n"
16364 +
16365 +#ifdef CONFIG_PAX_REFCOUNT
16366 + "jno 0f\n"
16367 + _ASM_DEC "%0\n"
16368 + "int $4\n0:\n"
16369 + _ASM_EXTABLE(0b, 0b)
16370 +#endif
16371 +
16372 + "sete %1\n"
16373 : "+m" (l->a.counter), "=qm" (c)
16374 : : "memory");
16375 return c != 0;
16376 @@ -109,7 +200,16 @@ static inline int local_add_negative(long i, local_t *l)
16377 {
16378 unsigned char c;
16379
16380 - asm volatile(_ASM_ADD "%2,%0; sets %1"
16381 + asm volatile(_ASM_ADD "%2,%0\n"
16382 +
16383 +#ifdef CONFIG_PAX_REFCOUNT
16384 + "jno 0f\n"
16385 + _ASM_SUB "%2,%0\n"
16386 + "int $4\n0:\n"
16387 + _ASM_EXTABLE(0b, 0b)
16388 +#endif
16389 +
16390 + "sets %1\n"
16391 : "+m" (l->a.counter), "=qm" (c)
16392 : "ir" (i) : "memory");
16393 return c;
16394 @@ -125,6 +225,30 @@ static inline int local_add_negative(long i, local_t *l)
16395 static inline long local_add_return(long i, local_t *l)
16396 {
16397 long __i = i;
16398 + asm volatile(_ASM_XADD "%0, %1\n"
16399 +
16400 +#ifdef CONFIG_PAX_REFCOUNT
16401 + "jno 0f\n"
16402 + _ASM_MOV "%0,%1\n"
16403 + "int $4\n0:\n"
16404 + _ASM_EXTABLE(0b, 0b)
16405 +#endif
16406 +
16407 + : "+r" (i), "+m" (l->a.counter)
16408 + : : "memory");
16409 + return i + __i;
16410 +}
16411 +
16412 +/**
16413 + * local_add_return_unchecked - add and return
16414 + * @i: integer value to add
16415 + * @l: pointer to type local_unchecked_t
16416 + *
16417 + * Atomically adds @i to @l and returns @i + @l
16418 + */
16419 +static inline long local_add_return_unchecked(long i, local_unchecked_t *l)
16420 +{
16421 + long __i = i;
16422 asm volatile(_ASM_XADD "%0, %1;"
16423 : "+r" (i), "+m" (l->a.counter)
16424 : : "memory");
16425 @@ -141,6 +265,8 @@ static inline long local_sub_return(long i, local_t *l)
16426
16427 #define local_cmpxchg(l, o, n) \
16428 (cmpxchg_local(&((l)->a.counter), (o), (n)))
16429 +#define local_cmpxchg_unchecked(l, o, n) \
16430 + (cmpxchg_local(&((l)->a.counter), (o), (n)))
16431 /* Always has a lock prefix */
16432 #define local_xchg(l, n) (xchg(&((l)->a.counter), (n)))
16433
16434 diff --git a/arch/x86/include/asm/mman.h b/arch/x86/include/asm/mman.h
16435 new file mode 100644
16436 index 0000000..2bfd3ba
16437 --- /dev/null
16438 +++ b/arch/x86/include/asm/mman.h
16439 @@ -0,0 +1,15 @@
16440 +#ifndef _X86_MMAN_H
16441 +#define _X86_MMAN_H
16442 +
16443 +#include <uapi/asm/mman.h>
16444 +
16445 +#ifdef __KERNEL__
16446 +#ifndef __ASSEMBLY__
16447 +#ifdef CONFIG_X86_32
16448 +#define arch_mmap_check i386_mmap_check
16449 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags);
16450 +#endif
16451 +#endif
16452 +#endif
16453 +
16454 +#endif /* X86_MMAN_H */
16455 diff --git a/arch/x86/include/asm/mmu.h b/arch/x86/include/asm/mmu.h
16456 index 5f55e69..e20bfb1 100644
16457 --- a/arch/x86/include/asm/mmu.h
16458 +++ b/arch/x86/include/asm/mmu.h
16459 @@ -9,7 +9,7 @@
16460 * we put the segment information here.
16461 */
16462 typedef struct {
16463 - void *ldt;
16464 + struct desc_struct *ldt;
16465 int size;
16466
16467 #ifdef CONFIG_X86_64
16468 @@ -18,7 +18,19 @@ typedef struct {
16469 #endif
16470
16471 struct mutex lock;
16472 - void *vdso;
16473 + unsigned long vdso;
16474 +
16475 +#ifdef CONFIG_X86_32
16476 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
16477 + unsigned long user_cs_base;
16478 + unsigned long user_cs_limit;
16479 +
16480 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
16481 + cpumask_t cpu_user_cs_mask;
16482 +#endif
16483 +
16484 +#endif
16485 +#endif
16486 } mm_context_t;
16487
16488 #ifdef CONFIG_SMP
16489 diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h
16490 index be12c53..4d24039 100644
16491 --- a/arch/x86/include/asm/mmu_context.h
16492 +++ b/arch/x86/include/asm/mmu_context.h
16493 @@ -24,6 +24,20 @@ void destroy_context(struct mm_struct *mm);
16494
16495 static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
16496 {
16497 +
16498 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
16499 + if (!(static_cpu_has(X86_FEATURE_PCID))) {
16500 + unsigned int i;
16501 + pgd_t *pgd;
16502 +
16503 + pax_open_kernel();
16504 + pgd = get_cpu_pgd(smp_processor_id(), kernel);
16505 + for (i = USER_PGD_PTRS; i < 2 * USER_PGD_PTRS; ++i)
16506 + set_pgd_batched(pgd+i, native_make_pgd(0));
16507 + pax_close_kernel();
16508 + }
16509 +#endif
16510 +
16511 #ifdef CONFIG_SMP
16512 if (this_cpu_read(cpu_tlbstate.state) == TLBSTATE_OK)
16513 this_cpu_write(cpu_tlbstate.state, TLBSTATE_LAZY);
16514 @@ -34,16 +48,59 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
16515 struct task_struct *tsk)
16516 {
16517 unsigned cpu = smp_processor_id();
16518 +#if defined(CONFIG_X86_32) && defined(CONFIG_SMP) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
16519 + int tlbstate = TLBSTATE_OK;
16520 +#endif
16521
16522 if (likely(prev != next)) {
16523 #ifdef CONFIG_SMP
16524 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
16525 + tlbstate = this_cpu_read(cpu_tlbstate.state);
16526 +#endif
16527 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
16528 this_cpu_write(cpu_tlbstate.active_mm, next);
16529 #endif
16530 cpumask_set_cpu(cpu, mm_cpumask(next));
16531
16532 /* Re-load page tables */
16533 +#ifdef CONFIG_PAX_PER_CPU_PGD
16534 + pax_open_kernel();
16535 +
16536 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
16537 + if (static_cpu_has(X86_FEATURE_PCID))
16538 + __clone_user_pgds(get_cpu_pgd(cpu, user), next->pgd);
16539 + else
16540 +#endif
16541 +
16542 + __clone_user_pgds(get_cpu_pgd(cpu, kernel), next->pgd);
16543 + __shadow_user_pgds(get_cpu_pgd(cpu, kernel) + USER_PGD_PTRS, next->pgd);
16544 + pax_close_kernel();
16545 + 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));
16546 +
16547 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
16548 + if (static_cpu_has(X86_FEATURE_PCID)) {
16549 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
16550 + u64 descriptor[2];
16551 + descriptor[0] = PCID_USER;
16552 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_CONTEXT) : "memory");
16553 + if (!static_cpu_has(X86_FEATURE_STRONGUDEREF)) {
16554 + descriptor[0] = PCID_KERNEL;
16555 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_CONTEXT) : "memory");
16556 + }
16557 + } else {
16558 + write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER);
16559 + if (static_cpu_has(X86_FEATURE_STRONGUDEREF))
16560 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
16561 + else
16562 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL);
16563 + }
16564 + } else
16565 +#endif
16566 +
16567 + load_cr3(get_cpu_pgd(cpu, kernel));
16568 +#else
16569 load_cr3(next->pgd);
16570 +#endif
16571
16572 /* Stop flush ipis for the previous mm */
16573 cpumask_clear_cpu(cpu, mm_cpumask(prev));
16574 @@ -51,9 +108,67 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
16575 /* Load the LDT, if the LDT is different: */
16576 if (unlikely(prev->context.ldt != next->context.ldt))
16577 load_LDT_nolock(&next->context);
16578 +
16579 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
16580 + if (!(__supported_pte_mask & _PAGE_NX)) {
16581 + smp_mb__before_clear_bit();
16582 + cpu_clear(cpu, prev->context.cpu_user_cs_mask);
16583 + smp_mb__after_clear_bit();
16584 + cpu_set(cpu, next->context.cpu_user_cs_mask);
16585 + }
16586 +#endif
16587 +
16588 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
16589 + if (unlikely(prev->context.user_cs_base != next->context.user_cs_base ||
16590 + prev->context.user_cs_limit != next->context.user_cs_limit))
16591 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
16592 +#ifdef CONFIG_SMP
16593 + else if (unlikely(tlbstate != TLBSTATE_OK))
16594 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
16595 +#endif
16596 +#endif
16597 +
16598 }
16599 + else {
16600 +
16601 +#ifdef CONFIG_PAX_PER_CPU_PGD
16602 + pax_open_kernel();
16603 +
16604 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
16605 + if (static_cpu_has(X86_FEATURE_PCID))
16606 + __clone_user_pgds(get_cpu_pgd(cpu, user), next->pgd);
16607 + else
16608 +#endif
16609 +
16610 + __clone_user_pgds(get_cpu_pgd(cpu, kernel), next->pgd);
16611 + __shadow_user_pgds(get_cpu_pgd(cpu, kernel) + USER_PGD_PTRS, next->pgd);
16612 + pax_close_kernel();
16613 + 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));
16614 +
16615 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
16616 + if (static_cpu_has(X86_FEATURE_PCID)) {
16617 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
16618 + u64 descriptor[2];
16619 + descriptor[0] = PCID_USER;
16620 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_CONTEXT) : "memory");
16621 + if (!static_cpu_has(X86_FEATURE_STRONGUDEREF)) {
16622 + descriptor[0] = PCID_KERNEL;
16623 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_CONTEXT) : "memory");
16624 + }
16625 + } else {
16626 + write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER);
16627 + if (static_cpu_has(X86_FEATURE_STRONGUDEREF))
16628 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
16629 + else
16630 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL);
16631 + }
16632 + } else
16633 +#endif
16634 +
16635 + load_cr3(get_cpu_pgd(cpu, kernel));
16636 +#endif
16637 +
16638 #ifdef CONFIG_SMP
16639 - else {
16640 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
16641 BUG_ON(this_cpu_read(cpu_tlbstate.active_mm) != next);
16642
16643 @@ -70,11 +185,28 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
16644 * tlb flush IPI delivery. We must reload CR3
16645 * to make sure to use no freed page tables.
16646 */
16647 +
16648 +#ifndef CONFIG_PAX_PER_CPU_PGD
16649 load_cr3(next->pgd);
16650 +#endif
16651 +
16652 load_LDT_nolock(&next->context);
16653 +
16654 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
16655 + if (!(__supported_pte_mask & _PAGE_NX))
16656 + cpu_set(cpu, next->context.cpu_user_cs_mask);
16657 +#endif
16658 +
16659 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
16660 +#ifdef CONFIG_PAX_PAGEEXEC
16661 + if (!((next->pax_flags & MF_PAX_PAGEEXEC) && (__supported_pte_mask & _PAGE_NX)))
16662 +#endif
16663 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
16664 +#endif
16665 +
16666 }
16667 +#endif
16668 }
16669 -#endif
16670 }
16671
16672 #define activate_mm(prev, next) \
16673 diff --git a/arch/x86/include/asm/module.h b/arch/x86/include/asm/module.h
16674 index e3b7819..b257c64 100644
16675 --- a/arch/x86/include/asm/module.h
16676 +++ b/arch/x86/include/asm/module.h
16677 @@ -5,6 +5,7 @@
16678
16679 #ifdef CONFIG_X86_64
16680 /* X86_64 does not define MODULE_PROC_FAMILY */
16681 +#define MODULE_PROC_FAMILY ""
16682 #elif defined CONFIG_M486
16683 #define MODULE_PROC_FAMILY "486 "
16684 #elif defined CONFIG_M586
16685 @@ -57,8 +58,20 @@
16686 #error unknown processor family
16687 #endif
16688
16689 -#ifdef CONFIG_X86_32
16690 -# define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY
16691 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
16692 +#define MODULE_PAX_KERNEXEC "KERNEXEC_BTS "
16693 +#elif defined(CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR)
16694 +#define MODULE_PAX_KERNEXEC "KERNEXEC_OR "
16695 +#else
16696 +#define MODULE_PAX_KERNEXEC ""
16697 #endif
16698
16699 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16700 +#define MODULE_PAX_UDEREF "UDEREF "
16701 +#else
16702 +#define MODULE_PAX_UDEREF ""
16703 +#endif
16704 +
16705 +#define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY MODULE_PAX_KERNEXEC MODULE_PAX_UDEREF
16706 +
16707 #endif /* _ASM_X86_MODULE_H */
16708 diff --git a/arch/x86/include/asm/nmi.h b/arch/x86/include/asm/nmi.h
16709 index 86f9301..b365cda 100644
16710 --- a/arch/x86/include/asm/nmi.h
16711 +++ b/arch/x86/include/asm/nmi.h
16712 @@ -40,11 +40,11 @@ struct nmiaction {
16713 nmi_handler_t handler;
16714 unsigned long flags;
16715 const char *name;
16716 -};
16717 +} __do_const;
16718
16719 #define register_nmi_handler(t, fn, fg, n, init...) \
16720 ({ \
16721 - static struct nmiaction init fn##_na = { \
16722 + static const struct nmiaction init fn##_na = { \
16723 .handler = (fn), \
16724 .name = (n), \
16725 .flags = (fg), \
16726 @@ -52,7 +52,7 @@ struct nmiaction {
16727 __register_nmi_handler((t), &fn##_na); \
16728 })
16729
16730 -int __register_nmi_handler(unsigned int, struct nmiaction *);
16731 +int __register_nmi_handler(unsigned int, const struct nmiaction *);
16732
16733 void unregister_nmi_handler(unsigned int, const char *);
16734
16735 diff --git a/arch/x86/include/asm/page.h b/arch/x86/include/asm/page.h
16736 index c878924..21f4889 100644
16737 --- a/arch/x86/include/asm/page.h
16738 +++ b/arch/x86/include/asm/page.h
16739 @@ -52,6 +52,7 @@ static inline void copy_user_page(void *to, void *from, unsigned long vaddr,
16740 __phys_addr_symbol(__phys_reloc_hide((unsigned long)(x)))
16741
16742 #define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET))
16743 +#define __early_va(x) ((void *)((unsigned long)(x)+__START_KERNEL_map - phys_base))
16744
16745 #define __boot_va(x) __va(x)
16746 #define __boot_pa(x) __pa(x)
16747 diff --git a/arch/x86/include/asm/page_64.h b/arch/x86/include/asm/page_64.h
16748 index 0f1ddee..e2fc3d1 100644
16749 --- a/arch/x86/include/asm/page_64.h
16750 +++ b/arch/x86/include/asm/page_64.h
16751 @@ -7,9 +7,9 @@
16752
16753 /* duplicated to the one in bootmem.h */
16754 extern unsigned long max_pfn;
16755 -extern unsigned long phys_base;
16756 +extern const unsigned long phys_base;
16757
16758 -static inline unsigned long __phys_addr_nodebug(unsigned long x)
16759 +static inline unsigned long __intentional_overflow(-1) __phys_addr_nodebug(unsigned long x)
16760 {
16761 unsigned long y = x - __START_KERNEL_map;
16762
16763 diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
16764 index 401f350..dee5d13 100644
16765 --- a/arch/x86/include/asm/paravirt.h
16766 +++ b/arch/x86/include/asm/paravirt.h
16767 @@ -560,7 +560,7 @@ static inline pmd_t __pmd(pmdval_t val)
16768 return (pmd_t) { ret };
16769 }
16770
16771 -static inline pmdval_t pmd_val(pmd_t pmd)
16772 +static inline __intentional_overflow(-1) pmdval_t pmd_val(pmd_t pmd)
16773 {
16774 pmdval_t ret;
16775
16776 @@ -626,6 +626,18 @@ static inline void set_pgd(pgd_t *pgdp, pgd_t pgd)
16777 val);
16778 }
16779
16780 +static inline void set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
16781 +{
16782 + pgdval_t val = native_pgd_val(pgd);
16783 +
16784 + if (sizeof(pgdval_t) > sizeof(long))
16785 + PVOP_VCALL3(pv_mmu_ops.set_pgd_batched, pgdp,
16786 + val, (u64)val >> 32);
16787 + else
16788 + PVOP_VCALL2(pv_mmu_ops.set_pgd_batched, pgdp,
16789 + val);
16790 +}
16791 +
16792 static inline void pgd_clear(pgd_t *pgdp)
16793 {
16794 set_pgd(pgdp, __pgd(0));
16795 @@ -710,6 +722,21 @@ static inline void __set_fixmap(unsigned /* enum fixed_addresses */ idx,
16796 pv_mmu_ops.set_fixmap(idx, phys, flags);
16797 }
16798
16799 +#ifdef CONFIG_PAX_KERNEXEC
16800 +static inline unsigned long pax_open_kernel(void)
16801 +{
16802 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_open_kernel);
16803 +}
16804 +
16805 +static inline unsigned long pax_close_kernel(void)
16806 +{
16807 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_close_kernel);
16808 +}
16809 +#else
16810 +static inline unsigned long pax_open_kernel(void) { return 0; }
16811 +static inline unsigned long pax_close_kernel(void) { return 0; }
16812 +#endif
16813 +
16814 #if defined(CONFIG_SMP) && defined(CONFIG_PARAVIRT_SPINLOCKS)
16815
16816 static __always_inline void __ticket_lock_spinning(struct arch_spinlock *lock,
16817 @@ -906,7 +933,7 @@ extern void default_banner(void);
16818
16819 #define PARA_PATCH(struct, off) ((PARAVIRT_PATCH_##struct + (off)) / 4)
16820 #define PARA_SITE(ptype, clobbers, ops) _PVSITE(ptype, clobbers, ops, .long, 4)
16821 -#define PARA_INDIRECT(addr) *%cs:addr
16822 +#define PARA_INDIRECT(addr) *%ss:addr
16823 #endif
16824
16825 #define INTERRUPT_RETURN \
16826 @@ -981,6 +1008,21 @@ extern void default_banner(void);
16827 PARA_SITE(PARA_PATCH(pv_cpu_ops, PV_CPU_irq_enable_sysexit), \
16828 CLBR_NONE, \
16829 jmp PARA_INDIRECT(pv_cpu_ops+PV_CPU_irq_enable_sysexit))
16830 +
16831 +#define GET_CR0_INTO_RDI \
16832 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0); \
16833 + mov %rax,%rdi
16834 +
16835 +#define SET_RDI_INTO_CR0 \
16836 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
16837 +
16838 +#define GET_CR3_INTO_RDI \
16839 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_read_cr3); \
16840 + mov %rax,%rdi
16841 +
16842 +#define SET_RDI_INTO_CR3 \
16843 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_write_cr3)
16844 +
16845 #endif /* CONFIG_X86_32 */
16846
16847 #endif /* __ASSEMBLY__ */
16848 diff --git a/arch/x86/include/asm/paravirt_types.h b/arch/x86/include/asm/paravirt_types.h
16849 index aab8f67..2531748 100644
16850 --- a/arch/x86/include/asm/paravirt_types.h
16851 +++ b/arch/x86/include/asm/paravirt_types.h
16852 @@ -84,7 +84,7 @@ struct pv_init_ops {
16853 */
16854 unsigned (*patch)(u8 type, u16 clobber, void *insnbuf,
16855 unsigned long addr, unsigned len);
16856 -};
16857 +} __no_const;
16858
16859
16860 struct pv_lazy_ops {
16861 @@ -98,7 +98,7 @@ struct pv_time_ops {
16862 unsigned long long (*sched_clock)(void);
16863 unsigned long long (*steal_clock)(int cpu);
16864 unsigned long (*get_tsc_khz)(void);
16865 -};
16866 +} __no_const;
16867
16868 struct pv_cpu_ops {
16869 /* hooks for various privileged instructions */
16870 @@ -192,7 +192,7 @@ struct pv_cpu_ops {
16871
16872 void (*start_context_switch)(struct task_struct *prev);
16873 void (*end_context_switch)(struct task_struct *next);
16874 -};
16875 +} __no_const;
16876
16877 struct pv_irq_ops {
16878 /*
16879 @@ -223,7 +223,7 @@ struct pv_apic_ops {
16880 unsigned long start_eip,
16881 unsigned long start_esp);
16882 #endif
16883 -};
16884 +} __no_const;
16885
16886 struct pv_mmu_ops {
16887 unsigned long (*read_cr2)(void);
16888 @@ -313,6 +313,7 @@ struct pv_mmu_ops {
16889 struct paravirt_callee_save make_pud;
16890
16891 void (*set_pgd)(pgd_t *pudp, pgd_t pgdval);
16892 + void (*set_pgd_batched)(pgd_t *pudp, pgd_t pgdval);
16893 #endif /* PAGETABLE_LEVELS == 4 */
16894 #endif /* PAGETABLE_LEVELS >= 3 */
16895
16896 @@ -324,6 +325,12 @@ struct pv_mmu_ops {
16897 an mfn. We can tell which is which from the index. */
16898 void (*set_fixmap)(unsigned /* enum fixed_addresses */ idx,
16899 phys_addr_t phys, pgprot_t flags);
16900 +
16901 +#ifdef CONFIG_PAX_KERNEXEC
16902 + unsigned long (*pax_open_kernel)(void);
16903 + unsigned long (*pax_close_kernel)(void);
16904 +#endif
16905 +
16906 };
16907
16908 struct arch_spinlock;
16909 diff --git a/arch/x86/include/asm/pgalloc.h b/arch/x86/include/asm/pgalloc.h
16910 index b4389a4..7024269 100644
16911 --- a/arch/x86/include/asm/pgalloc.h
16912 +++ b/arch/x86/include/asm/pgalloc.h
16913 @@ -63,6 +63,13 @@ static inline void pmd_populate_kernel(struct mm_struct *mm,
16914 pmd_t *pmd, pte_t *pte)
16915 {
16916 paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
16917 + set_pmd(pmd, __pmd(__pa(pte) | _KERNPG_TABLE));
16918 +}
16919 +
16920 +static inline void pmd_populate_user(struct mm_struct *mm,
16921 + pmd_t *pmd, pte_t *pte)
16922 +{
16923 + paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
16924 set_pmd(pmd, __pmd(__pa(pte) | _PAGE_TABLE));
16925 }
16926
16927 @@ -99,12 +106,22 @@ static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd,
16928
16929 #ifdef CONFIG_X86_PAE
16930 extern void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd);
16931 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
16932 +{
16933 + pud_populate(mm, pudp, pmd);
16934 +}
16935 #else /* !CONFIG_X86_PAE */
16936 static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
16937 {
16938 paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
16939 set_pud(pud, __pud(_PAGE_TABLE | __pa(pmd)));
16940 }
16941 +
16942 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
16943 +{
16944 + paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
16945 + set_pud(pud, __pud(_KERNPG_TABLE | __pa(pmd)));
16946 +}
16947 #endif /* CONFIG_X86_PAE */
16948
16949 #if PAGETABLE_LEVELS > 3
16950 @@ -114,6 +131,12 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
16951 set_pgd(pgd, __pgd(_PAGE_TABLE | __pa(pud)));
16952 }
16953
16954 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
16955 +{
16956 + paravirt_alloc_pud(mm, __pa(pud) >> PAGE_SHIFT);
16957 + set_pgd(pgd, __pgd(_KERNPG_TABLE | __pa(pud)));
16958 +}
16959 +
16960 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
16961 {
16962 return (pud_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
16963 diff --git a/arch/x86/include/asm/pgtable-2level.h b/arch/x86/include/asm/pgtable-2level.h
16964 index 3bf2dd0..23d2a9f 100644
16965 --- a/arch/x86/include/asm/pgtable-2level.h
16966 +++ b/arch/x86/include/asm/pgtable-2level.h
16967 @@ -18,7 +18,9 @@ static inline void native_set_pte(pte_t *ptep , pte_t pte)
16968
16969 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
16970 {
16971 + pax_open_kernel();
16972 *pmdp = pmd;
16973 + pax_close_kernel();
16974 }
16975
16976 static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
16977 diff --git a/arch/x86/include/asm/pgtable-3level.h b/arch/x86/include/asm/pgtable-3level.h
16978 index 81bb91b..9392125 100644
16979 --- a/arch/x86/include/asm/pgtable-3level.h
16980 +++ b/arch/x86/include/asm/pgtable-3level.h
16981 @@ -92,12 +92,16 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
16982
16983 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
16984 {
16985 + pax_open_kernel();
16986 set_64bit((unsigned long long *)(pmdp), native_pmd_val(pmd));
16987 + pax_close_kernel();
16988 }
16989
16990 static inline void native_set_pud(pud_t *pudp, pud_t pud)
16991 {
16992 + pax_open_kernel();
16993 set_64bit((unsigned long long *)(pudp), native_pud_val(pud));
16994 + pax_close_kernel();
16995 }
16996
16997 /*
16998 diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
16999 index 3d19994..732a48c 100644
17000 --- a/arch/x86/include/asm/pgtable.h
17001 +++ b/arch/x86/include/asm/pgtable.h
17002 @@ -45,6 +45,7 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
17003
17004 #ifndef __PAGETABLE_PUD_FOLDED
17005 #define set_pgd(pgdp, pgd) native_set_pgd(pgdp, pgd)
17006 +#define set_pgd_batched(pgdp, pgd) native_set_pgd_batched(pgdp, pgd)
17007 #define pgd_clear(pgd) native_pgd_clear(pgd)
17008 #endif
17009
17010 @@ -82,12 +83,51 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
17011
17012 #define arch_end_context_switch(prev) do {} while(0)
17013
17014 +#define pax_open_kernel() native_pax_open_kernel()
17015 +#define pax_close_kernel() native_pax_close_kernel()
17016 #endif /* CONFIG_PARAVIRT */
17017
17018 +#define __HAVE_ARCH_PAX_OPEN_KERNEL
17019 +#define __HAVE_ARCH_PAX_CLOSE_KERNEL
17020 +
17021 +#ifdef CONFIG_PAX_KERNEXEC
17022 +static inline unsigned long native_pax_open_kernel(void)
17023 +{
17024 + unsigned long cr0;
17025 +
17026 + preempt_disable();
17027 + barrier();
17028 + cr0 = read_cr0() ^ X86_CR0_WP;
17029 + BUG_ON(cr0 & X86_CR0_WP);
17030 + write_cr0(cr0);
17031 + return cr0 ^ X86_CR0_WP;
17032 +}
17033 +
17034 +static inline unsigned long native_pax_close_kernel(void)
17035 +{
17036 + unsigned long cr0;
17037 +
17038 + cr0 = read_cr0() ^ X86_CR0_WP;
17039 + BUG_ON(!(cr0 & X86_CR0_WP));
17040 + write_cr0(cr0);
17041 + barrier();
17042 + preempt_enable_no_resched();
17043 + return cr0 ^ X86_CR0_WP;
17044 +}
17045 +#else
17046 +static inline unsigned long native_pax_open_kernel(void) { return 0; }
17047 +static inline unsigned long native_pax_close_kernel(void) { return 0; }
17048 +#endif
17049 +
17050 /*
17051 * The following only work if pte_present() is true.
17052 * Undefined behaviour if not..
17053 */
17054 +static inline int pte_user(pte_t pte)
17055 +{
17056 + return pte_val(pte) & _PAGE_USER;
17057 +}
17058 +
17059 static inline int pte_dirty(pte_t pte)
17060 {
17061 return pte_flags(pte) & _PAGE_DIRTY;
17062 @@ -148,6 +188,11 @@ static inline unsigned long pud_pfn(pud_t pud)
17063 return (pud_val(pud) & PTE_PFN_MASK) >> PAGE_SHIFT;
17064 }
17065
17066 +static inline unsigned long pgd_pfn(pgd_t pgd)
17067 +{
17068 + return (pgd_val(pgd) & PTE_PFN_MASK) >> PAGE_SHIFT;
17069 +}
17070 +
17071 #define pte_page(pte) pfn_to_page(pte_pfn(pte))
17072
17073 static inline int pmd_large(pmd_t pte)
17074 @@ -201,9 +246,29 @@ static inline pte_t pte_wrprotect(pte_t pte)
17075 return pte_clear_flags(pte, _PAGE_RW);
17076 }
17077
17078 +static inline pte_t pte_mkread(pte_t pte)
17079 +{
17080 + return __pte(pte_val(pte) | _PAGE_USER);
17081 +}
17082 +
17083 static inline pte_t pte_mkexec(pte_t pte)
17084 {
17085 - return pte_clear_flags(pte, _PAGE_NX);
17086 +#ifdef CONFIG_X86_PAE
17087 + if (__supported_pte_mask & _PAGE_NX)
17088 + return pte_clear_flags(pte, _PAGE_NX);
17089 + else
17090 +#endif
17091 + return pte_set_flags(pte, _PAGE_USER);
17092 +}
17093 +
17094 +static inline pte_t pte_exprotect(pte_t pte)
17095 +{
17096 +#ifdef CONFIG_X86_PAE
17097 + if (__supported_pte_mask & _PAGE_NX)
17098 + return pte_set_flags(pte, _PAGE_NX);
17099 + else
17100 +#endif
17101 + return pte_clear_flags(pte, _PAGE_USER);
17102 }
17103
17104 static inline pte_t pte_mkdirty(pte_t pte)
17105 @@ -430,6 +495,16 @@ pte_t *populate_extra_pte(unsigned long vaddr);
17106 #endif
17107
17108 #ifndef __ASSEMBLY__
17109 +
17110 +#ifdef CONFIG_PAX_PER_CPU_PGD
17111 +extern pgd_t cpu_pgd[NR_CPUS][2][PTRS_PER_PGD];
17112 +enum cpu_pgd_type {kernel = 0, user = 1};
17113 +static inline pgd_t *get_cpu_pgd(unsigned int cpu, enum cpu_pgd_type type)
17114 +{
17115 + return cpu_pgd[cpu][type];
17116 +}
17117 +#endif
17118 +
17119 #include <linux/mm_types.h>
17120 #include <linux/mmdebug.h>
17121 #include <linux/log2.h>
17122 @@ -563,7 +638,7 @@ static inline unsigned long pud_page_vaddr(pud_t pud)
17123 * Currently stuck as a macro due to indirect forward reference to
17124 * linux/mmzone.h's __section_mem_map_addr() definition:
17125 */
17126 -#define pud_page(pud) pfn_to_page(pud_val(pud) >> PAGE_SHIFT)
17127 +#define pud_page(pud) pfn_to_page((pud_val(pud) & PTE_PFN_MASK) >> PAGE_SHIFT)
17128
17129 /* Find an entry in the second-level page table.. */
17130 static inline pmd_t *pmd_offset(pud_t *pud, unsigned long address)
17131 @@ -603,7 +678,7 @@ static inline unsigned long pgd_page_vaddr(pgd_t pgd)
17132 * Currently stuck as a macro due to indirect forward reference to
17133 * linux/mmzone.h's __section_mem_map_addr() definition:
17134 */
17135 -#define pgd_page(pgd) pfn_to_page(pgd_val(pgd) >> PAGE_SHIFT)
17136 +#define pgd_page(pgd) pfn_to_page((pgd_val(pgd) & PTE_PFN_MASK) >> PAGE_SHIFT)
17137
17138 /* to find an entry in a page-table-directory. */
17139 static inline unsigned long pud_index(unsigned long address)
17140 @@ -618,7 +693,7 @@ static inline pud_t *pud_offset(pgd_t *pgd, unsigned long address)
17141
17142 static inline int pgd_bad(pgd_t pgd)
17143 {
17144 - return (pgd_flags(pgd) & ~_PAGE_USER) != _KERNPG_TABLE;
17145 + return (pgd_flags(pgd) & ~(_PAGE_USER | _PAGE_NX)) != _KERNPG_TABLE;
17146 }
17147
17148 static inline int pgd_none(pgd_t pgd)
17149 @@ -641,7 +716,12 @@ static inline int pgd_none(pgd_t pgd)
17150 * pgd_offset() returns a (pgd_t *)
17151 * pgd_index() is used get the offset into the pgd page's array of pgd_t's;
17152 */
17153 -#define pgd_offset(mm, address) ((mm)->pgd + pgd_index((address)))
17154 +#define pgd_offset(mm, address) ((mm)->pgd + pgd_index(address))
17155 +
17156 +#ifdef CONFIG_PAX_PER_CPU_PGD
17157 +#define pgd_offset_cpu(cpu, type, address) (get_cpu_pgd(cpu, type) + pgd_index(address))
17158 +#endif
17159 +
17160 /*
17161 * a shortcut which implies the use of the kernel's pgd, instead
17162 * of a process's
17163 @@ -652,6 +732,23 @@ static inline int pgd_none(pgd_t pgd)
17164 #define KERNEL_PGD_BOUNDARY pgd_index(PAGE_OFFSET)
17165 #define KERNEL_PGD_PTRS (PTRS_PER_PGD - KERNEL_PGD_BOUNDARY)
17166
17167 +#ifdef CONFIG_X86_32
17168 +#define USER_PGD_PTRS KERNEL_PGD_BOUNDARY
17169 +#else
17170 +#define TASK_SIZE_MAX_SHIFT CONFIG_TASK_SIZE_MAX_SHIFT
17171 +#define USER_PGD_PTRS (_AC(1,UL) << (TASK_SIZE_MAX_SHIFT - PGDIR_SHIFT))
17172 +
17173 +#ifdef CONFIG_PAX_MEMORY_UDEREF
17174 +#ifdef __ASSEMBLY__
17175 +#define pax_user_shadow_base pax_user_shadow_base(%rip)
17176 +#else
17177 +extern unsigned long pax_user_shadow_base;
17178 +extern pgdval_t clone_pgd_mask;
17179 +#endif
17180 +#endif
17181 +
17182 +#endif
17183 +
17184 #ifndef __ASSEMBLY__
17185
17186 extern int direct_gbpages;
17187 @@ -818,11 +915,24 @@ static inline void pmdp_set_wrprotect(struct mm_struct *mm,
17188 * dst and src can be on the same page, but the range must not overlap,
17189 * and must not cross a page boundary.
17190 */
17191 -static inline void clone_pgd_range(pgd_t *dst, pgd_t *src, int count)
17192 +static inline void clone_pgd_range(pgd_t *dst, const pgd_t *src, int count)
17193 {
17194 - memcpy(dst, src, count * sizeof(pgd_t));
17195 + pax_open_kernel();
17196 + while (count--)
17197 + *dst++ = *src++;
17198 + pax_close_kernel();
17199 }
17200
17201 +#ifdef CONFIG_PAX_PER_CPU_PGD
17202 +extern void __clone_user_pgds(pgd_t *dst, const pgd_t *src);
17203 +#endif
17204 +
17205 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17206 +extern void __shadow_user_pgds(pgd_t *dst, const pgd_t *src);
17207 +#else
17208 +static inline void __shadow_user_pgds(pgd_t *dst, const pgd_t *src) {}
17209 +#endif
17210 +
17211 #define PTE_SHIFT ilog2(PTRS_PER_PTE)
17212 static inline int page_level_shift(enum pg_level level)
17213 {
17214 diff --git a/arch/x86/include/asm/pgtable_32.h b/arch/x86/include/asm/pgtable_32.h
17215 index 9ee3221..b979c6b 100644
17216 --- a/arch/x86/include/asm/pgtable_32.h
17217 +++ b/arch/x86/include/asm/pgtable_32.h
17218 @@ -25,9 +25,6 @@
17219 struct mm_struct;
17220 struct vm_area_struct;
17221
17222 -extern pgd_t swapper_pg_dir[1024];
17223 -extern pgd_t initial_page_table[1024];
17224 -
17225 static inline void pgtable_cache_init(void) { }
17226 static inline void check_pgt_cache(void) { }
17227 void paging_init(void);
17228 @@ -48,6 +45,12 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
17229 # include <asm/pgtable-2level.h>
17230 #endif
17231
17232 +extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
17233 +extern pgd_t initial_page_table[PTRS_PER_PGD];
17234 +#ifdef CONFIG_X86_PAE
17235 +extern pmd_t swapper_pm_dir[PTRS_PER_PGD][PTRS_PER_PMD];
17236 +#endif
17237 +
17238 #if defined(CONFIG_HIGHPTE)
17239 #define pte_offset_map(dir, address) \
17240 ((pte_t *)kmap_atomic(pmd_page(*(dir))) + \
17241 @@ -62,12 +65,17 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
17242 /* Clear a kernel PTE and flush it from the TLB */
17243 #define kpte_clear_flush(ptep, vaddr) \
17244 do { \
17245 + pax_open_kernel(); \
17246 pte_clear(&init_mm, (vaddr), (ptep)); \
17247 + pax_close_kernel(); \
17248 __flush_tlb_one((vaddr)); \
17249 } while (0)
17250
17251 #endif /* !__ASSEMBLY__ */
17252
17253 +#define HAVE_ARCH_UNMAPPED_AREA
17254 +#define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN
17255 +
17256 /*
17257 * kern_addr_valid() is (1) for FLATMEM and (0) for
17258 * SPARSEMEM and DISCONTIGMEM
17259 diff --git a/arch/x86/include/asm/pgtable_32_types.h b/arch/x86/include/asm/pgtable_32_types.h
17260 index ed5903b..c7fe163 100644
17261 --- a/arch/x86/include/asm/pgtable_32_types.h
17262 +++ b/arch/x86/include/asm/pgtable_32_types.h
17263 @@ -8,7 +8,7 @@
17264 */
17265 #ifdef CONFIG_X86_PAE
17266 # include <asm/pgtable-3level_types.h>
17267 -# define PMD_SIZE (1UL << PMD_SHIFT)
17268 +# define PMD_SIZE (_AC(1, UL) << PMD_SHIFT)
17269 # define PMD_MASK (~(PMD_SIZE - 1))
17270 #else
17271 # include <asm/pgtable-2level_types.h>
17272 @@ -46,6 +46,19 @@ extern bool __vmalloc_start_set; /* set once high_memory is set */
17273 # define VMALLOC_END (FIXADDR_START - 2 * PAGE_SIZE)
17274 #endif
17275
17276 +#ifdef CONFIG_PAX_KERNEXEC
17277 +#ifndef __ASSEMBLY__
17278 +extern unsigned char MODULES_EXEC_VADDR[];
17279 +extern unsigned char MODULES_EXEC_END[];
17280 +#endif
17281 +#include <asm/boot.h>
17282 +#define ktla_ktva(addr) (addr + LOAD_PHYSICAL_ADDR + PAGE_OFFSET)
17283 +#define ktva_ktla(addr) (addr - LOAD_PHYSICAL_ADDR - PAGE_OFFSET)
17284 +#else
17285 +#define ktla_ktva(addr) (addr)
17286 +#define ktva_ktla(addr) (addr)
17287 +#endif
17288 +
17289 #define MODULES_VADDR VMALLOC_START
17290 #define MODULES_END VMALLOC_END
17291 #define MODULES_LEN (MODULES_VADDR - MODULES_END)
17292 diff --git a/arch/x86/include/asm/pgtable_64.h b/arch/x86/include/asm/pgtable_64.h
17293 index e22c1db..23a625a 100644
17294 --- a/arch/x86/include/asm/pgtable_64.h
17295 +++ b/arch/x86/include/asm/pgtable_64.h
17296 @@ -16,10 +16,14 @@
17297
17298 extern pud_t level3_kernel_pgt[512];
17299 extern pud_t level3_ident_pgt[512];
17300 +extern pud_t level3_vmalloc_start_pgt[512];
17301 +extern pud_t level3_vmalloc_end_pgt[512];
17302 +extern pud_t level3_vmemmap_pgt[512];
17303 +extern pud_t level2_vmemmap_pgt[512];
17304 extern pmd_t level2_kernel_pgt[512];
17305 extern pmd_t level2_fixmap_pgt[512];
17306 -extern pmd_t level2_ident_pgt[512];
17307 -extern pgd_t init_level4_pgt[];
17308 +extern pmd_t level2_ident_pgt[512*2];
17309 +extern pgd_t init_level4_pgt[512];
17310
17311 #define swapper_pg_dir init_level4_pgt
17312
17313 @@ -61,7 +65,9 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
17314
17315 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
17316 {
17317 + pax_open_kernel();
17318 *pmdp = pmd;
17319 + pax_close_kernel();
17320 }
17321
17322 static inline void native_pmd_clear(pmd_t *pmd)
17323 @@ -97,7 +103,9 @@ static inline pmd_t native_pmdp_get_and_clear(pmd_t *xp)
17324
17325 static inline void native_set_pud(pud_t *pudp, pud_t pud)
17326 {
17327 + pax_open_kernel();
17328 *pudp = pud;
17329 + pax_close_kernel();
17330 }
17331
17332 static inline void native_pud_clear(pud_t *pud)
17333 @@ -107,6 +115,13 @@ static inline void native_pud_clear(pud_t *pud)
17334
17335 static inline void native_set_pgd(pgd_t *pgdp, pgd_t pgd)
17336 {
17337 + pax_open_kernel();
17338 + *pgdp = pgd;
17339 + pax_close_kernel();
17340 +}
17341 +
17342 +static inline void native_set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
17343 +{
17344 *pgdp = pgd;
17345 }
17346
17347 diff --git a/arch/x86/include/asm/pgtable_64_types.h b/arch/x86/include/asm/pgtable_64_types.h
17348 index 2d88344..4679fc3 100644
17349 --- a/arch/x86/include/asm/pgtable_64_types.h
17350 +++ b/arch/x86/include/asm/pgtable_64_types.h
17351 @@ -61,6 +61,11 @@ typedef struct { pteval_t pte; } pte_t;
17352 #define MODULES_VADDR _AC(0xffffffffa0000000, UL)
17353 #define MODULES_END _AC(0xffffffffff000000, UL)
17354 #define MODULES_LEN (MODULES_END - MODULES_VADDR)
17355 +#define MODULES_EXEC_VADDR MODULES_VADDR
17356 +#define MODULES_EXEC_END MODULES_END
17357 +
17358 +#define ktla_ktva(addr) (addr)
17359 +#define ktva_ktla(addr) (addr)
17360
17361 #define EARLY_DYNAMIC_PAGE_TABLES 64
17362
17363 diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h
17364 index 0ecac25..306c276 100644
17365 --- a/arch/x86/include/asm/pgtable_types.h
17366 +++ b/arch/x86/include/asm/pgtable_types.h
17367 @@ -16,13 +16,12 @@
17368 #define _PAGE_BIT_PSE 7 /* 4 MB (or 2MB) page */
17369 #define _PAGE_BIT_PAT 7 /* on 4KB pages */
17370 #define _PAGE_BIT_GLOBAL 8 /* Global TLB entry PPro+ */
17371 -#define _PAGE_BIT_UNUSED1 9 /* available for programmer */
17372 +#define _PAGE_BIT_SPECIAL 9 /* special mappings, no associated struct page */
17373 #define _PAGE_BIT_IOMAP 10 /* flag used to indicate IO mapping */
17374 #define _PAGE_BIT_HIDDEN 11 /* hidden by kmemcheck */
17375 #define _PAGE_BIT_PAT_LARGE 12 /* On 2MB or 1GB pages */
17376 -#define _PAGE_BIT_SPECIAL _PAGE_BIT_UNUSED1
17377 -#define _PAGE_BIT_CPA_TEST _PAGE_BIT_UNUSED1
17378 -#define _PAGE_BIT_SPLITTING _PAGE_BIT_UNUSED1 /* only valid on a PSE pmd */
17379 +#define _PAGE_BIT_CPA_TEST _PAGE_BIT_SPECIAL
17380 +#define _PAGE_BIT_SPLITTING _PAGE_BIT_SPECIAL /* only valid on a PSE pmd */
17381 #define _PAGE_BIT_NX 63 /* No execute: only valid after cpuid check */
17382
17383 /* If _PAGE_BIT_PRESENT is clear, we use these: */
17384 @@ -40,7 +39,6 @@
17385 #define _PAGE_DIRTY (_AT(pteval_t, 1) << _PAGE_BIT_DIRTY)
17386 #define _PAGE_PSE (_AT(pteval_t, 1) << _PAGE_BIT_PSE)
17387 #define _PAGE_GLOBAL (_AT(pteval_t, 1) << _PAGE_BIT_GLOBAL)
17388 -#define _PAGE_UNUSED1 (_AT(pteval_t, 1) << _PAGE_BIT_UNUSED1)
17389 #define _PAGE_IOMAP (_AT(pteval_t, 1) << _PAGE_BIT_IOMAP)
17390 #define _PAGE_PAT (_AT(pteval_t, 1) << _PAGE_BIT_PAT)
17391 #define _PAGE_PAT_LARGE (_AT(pteval_t, 1) << _PAGE_BIT_PAT_LARGE)
17392 @@ -87,8 +85,10 @@
17393
17394 #if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
17395 #define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_NX)
17396 -#else
17397 +#elif defined(CONFIG_KMEMCHECK)
17398 #define _PAGE_NX (_AT(pteval_t, 0))
17399 +#else
17400 +#define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_HIDDEN)
17401 #endif
17402
17403 #define _PAGE_FILE (_AT(pteval_t, 1) << _PAGE_BIT_FILE)
17404 @@ -146,6 +146,9 @@
17405 #define PAGE_READONLY_EXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | \
17406 _PAGE_ACCESSED)
17407
17408 +#define PAGE_READONLY_NOEXEC PAGE_READONLY
17409 +#define PAGE_SHARED_NOEXEC PAGE_SHARED
17410 +
17411 #define __PAGE_KERNEL_EXEC \
17412 (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_GLOBAL)
17413 #define __PAGE_KERNEL (__PAGE_KERNEL_EXEC | _PAGE_NX)
17414 @@ -156,7 +159,7 @@
17415 #define __PAGE_KERNEL_WC (__PAGE_KERNEL | _PAGE_CACHE_WC)
17416 #define __PAGE_KERNEL_NOCACHE (__PAGE_KERNEL | _PAGE_PCD | _PAGE_PWT)
17417 #define __PAGE_KERNEL_UC_MINUS (__PAGE_KERNEL | _PAGE_PCD)
17418 -#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RX | _PAGE_USER)
17419 +#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RO | _PAGE_USER)
17420 #define __PAGE_KERNEL_VVAR (__PAGE_KERNEL_RO | _PAGE_USER)
17421 #define __PAGE_KERNEL_VVAR_NOCACHE (__PAGE_KERNEL_VVAR | _PAGE_PCD | _PAGE_PWT)
17422 #define __PAGE_KERNEL_LARGE (__PAGE_KERNEL | _PAGE_PSE)
17423 @@ -218,8 +221,8 @@
17424 * bits are combined, this will alow user to access the high address mapped
17425 * VDSO in the presence of CONFIG_COMPAT_VDSO
17426 */
17427 -#define PTE_IDENT_ATTR 0x003 /* PRESENT+RW */
17428 -#define PDE_IDENT_ATTR 0x067 /* PRESENT+RW+USER+DIRTY+ACCESSED */
17429 +#define PTE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
17430 +#define PDE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
17431 #define PGD_IDENT_ATTR 0x001 /* PRESENT (no other attributes) */
17432 #endif
17433
17434 @@ -257,7 +260,17 @@ static inline pgdval_t pgd_flags(pgd_t pgd)
17435 {
17436 return native_pgd_val(pgd) & PTE_FLAGS_MASK;
17437 }
17438 +#endif
17439
17440 +#if PAGETABLE_LEVELS == 3
17441 +#include <asm-generic/pgtable-nopud.h>
17442 +#endif
17443 +
17444 +#if PAGETABLE_LEVELS == 2
17445 +#include <asm-generic/pgtable-nopmd.h>
17446 +#endif
17447 +
17448 +#ifndef __ASSEMBLY__
17449 #if PAGETABLE_LEVELS > 3
17450 typedef struct { pudval_t pud; } pud_t;
17451
17452 @@ -271,8 +284,6 @@ static inline pudval_t native_pud_val(pud_t pud)
17453 return pud.pud;
17454 }
17455 #else
17456 -#include <asm-generic/pgtable-nopud.h>
17457 -
17458 static inline pudval_t native_pud_val(pud_t pud)
17459 {
17460 return native_pgd_val(pud.pgd);
17461 @@ -292,8 +303,6 @@ static inline pmdval_t native_pmd_val(pmd_t pmd)
17462 return pmd.pmd;
17463 }
17464 #else
17465 -#include <asm-generic/pgtable-nopmd.h>
17466 -
17467 static inline pmdval_t native_pmd_val(pmd_t pmd)
17468 {
17469 return native_pgd_val(pmd.pud.pgd);
17470 @@ -333,7 +342,6 @@ typedef struct page *pgtable_t;
17471
17472 extern pteval_t __supported_pte_mask;
17473 extern void set_nx(void);
17474 -extern int nx_enabled;
17475
17476 #define pgprot_writecombine pgprot_writecombine
17477 extern pgprot_t pgprot_writecombine(pgprot_t prot);
17478 diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
17479 index 987c75e..2723054 100644
17480 --- a/arch/x86/include/asm/processor.h
17481 +++ b/arch/x86/include/asm/processor.h
17482 @@ -199,9 +199,21 @@ static inline void native_cpuid(unsigned int *eax, unsigned int *ebx,
17483 : "memory");
17484 }
17485
17486 +/* invpcid (%rdx),%rax */
17487 +#define __ASM_INVPCID ".byte 0x66,0x0f,0x38,0x82,0x02"
17488 +
17489 +#define INVPCID_SINGLE_ADDRESS 0UL
17490 +#define INVPCID_SINGLE_CONTEXT 1UL
17491 +#define INVPCID_ALL_GLOBAL 2UL
17492 +#define INVPCID_ALL_MONGLOBAL 3UL
17493 +
17494 +#define PCID_KERNEL 0UL
17495 +#define PCID_USER 1UL
17496 +#define PCID_NOFLUSH (1UL << 63)
17497 +
17498 static inline void load_cr3(pgd_t *pgdir)
17499 {
17500 - write_cr3(__pa(pgdir));
17501 + write_cr3(__pa(pgdir) | PCID_KERNEL);
17502 }
17503
17504 #ifdef CONFIG_X86_32
17505 @@ -283,7 +295,7 @@ struct tss_struct {
17506
17507 } ____cacheline_aligned;
17508
17509 -DECLARE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss);
17510 +extern struct tss_struct init_tss[NR_CPUS];
17511
17512 /*
17513 * Save the original ist values for checking stack pointers during debugging
17514 @@ -453,6 +465,7 @@ struct thread_struct {
17515 unsigned short ds;
17516 unsigned short fsindex;
17517 unsigned short gsindex;
17518 + unsigned short ss;
17519 #endif
17520 #ifdef CONFIG_X86_32
17521 unsigned long ip;
17522 @@ -553,29 +566,8 @@ static inline void load_sp0(struct tss_struct *tss,
17523 extern unsigned long mmu_cr4_features;
17524 extern u32 *trampoline_cr4_features;
17525
17526 -static inline void set_in_cr4(unsigned long mask)
17527 -{
17528 - unsigned long cr4;
17529 -
17530 - mmu_cr4_features |= mask;
17531 - if (trampoline_cr4_features)
17532 - *trampoline_cr4_features = mmu_cr4_features;
17533 - cr4 = read_cr4();
17534 - cr4 |= mask;
17535 - write_cr4(cr4);
17536 -}
17537 -
17538 -static inline void clear_in_cr4(unsigned long mask)
17539 -{
17540 - unsigned long cr4;
17541 -
17542 - mmu_cr4_features &= ~mask;
17543 - if (trampoline_cr4_features)
17544 - *trampoline_cr4_features = mmu_cr4_features;
17545 - cr4 = read_cr4();
17546 - cr4 &= ~mask;
17547 - write_cr4(cr4);
17548 -}
17549 +extern void set_in_cr4(unsigned long mask);
17550 +extern void clear_in_cr4(unsigned long mask);
17551
17552 typedef struct {
17553 unsigned long seg;
17554 @@ -824,11 +816,18 @@ static inline void spin_lock_prefetch(const void *x)
17555 */
17556 #define TASK_SIZE PAGE_OFFSET
17557 #define TASK_SIZE_MAX TASK_SIZE
17558 +
17559 +#ifdef CONFIG_PAX_SEGMEXEC
17560 +#define SEGMEXEC_TASK_SIZE (TASK_SIZE / 2)
17561 +#define STACK_TOP ((current->mm->pax_flags & MF_PAX_SEGMEXEC)?SEGMEXEC_TASK_SIZE:TASK_SIZE)
17562 +#else
17563 #define STACK_TOP TASK_SIZE
17564 -#define STACK_TOP_MAX STACK_TOP
17565 +#endif
17566 +
17567 +#define STACK_TOP_MAX TASK_SIZE
17568
17569 #define INIT_THREAD { \
17570 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
17571 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
17572 .vm86_info = NULL, \
17573 .sysenter_cs = __KERNEL_CS, \
17574 .io_bitmap_ptr = NULL, \
17575 @@ -842,7 +841,7 @@ static inline void spin_lock_prefetch(const void *x)
17576 */
17577 #define INIT_TSS { \
17578 .x86_tss = { \
17579 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
17580 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
17581 .ss0 = __KERNEL_DS, \
17582 .ss1 = __KERNEL_CS, \
17583 .io_bitmap_base = INVALID_IO_BITMAP_OFFSET, \
17584 @@ -853,11 +852,7 @@ static inline void spin_lock_prefetch(const void *x)
17585 extern unsigned long thread_saved_pc(struct task_struct *tsk);
17586
17587 #define THREAD_SIZE_LONGS (THREAD_SIZE/sizeof(unsigned long))
17588 -#define KSTK_TOP(info) \
17589 -({ \
17590 - unsigned long *__ptr = (unsigned long *)(info); \
17591 - (unsigned long)(&__ptr[THREAD_SIZE_LONGS]); \
17592 -})
17593 +#define KSTK_TOP(info) ((container_of(info, struct task_struct, tinfo))->thread.sp0)
17594
17595 /*
17596 * The below -8 is to reserve 8 bytes on top of the ring0 stack.
17597 @@ -872,7 +867,7 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
17598 #define task_pt_regs(task) \
17599 ({ \
17600 struct pt_regs *__regs__; \
17601 - __regs__ = (struct pt_regs *)(KSTK_TOP(task_stack_page(task))-8); \
17602 + __regs__ = (struct pt_regs *)((task)->thread.sp0); \
17603 __regs__ - 1; \
17604 })
17605
17606 @@ -882,13 +877,13 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
17607 /*
17608 * User space process size. 47bits minus one guard page.
17609 */
17610 -#define TASK_SIZE_MAX ((1UL << 47) - PAGE_SIZE)
17611 +#define TASK_SIZE_MAX ((1UL << TASK_SIZE_MAX_SHIFT) - PAGE_SIZE)
17612
17613 /* This decides where the kernel will search for a free chunk of vm
17614 * space during mmap's.
17615 */
17616 #define IA32_PAGE_OFFSET ((current->personality & ADDR_LIMIT_3GB) ? \
17617 - 0xc0000000 : 0xFFFFe000)
17618 + 0xc0000000 : 0xFFFFf000)
17619
17620 #define TASK_SIZE (test_thread_flag(TIF_ADDR32) ? \
17621 IA32_PAGE_OFFSET : TASK_SIZE_MAX)
17622 @@ -899,11 +894,11 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
17623 #define STACK_TOP_MAX TASK_SIZE_MAX
17624
17625 #define INIT_THREAD { \
17626 - .sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
17627 + .sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
17628 }
17629
17630 #define INIT_TSS { \
17631 - .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
17632 + .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
17633 }
17634
17635 /*
17636 @@ -931,6 +926,10 @@ extern void start_thread(struct pt_regs *regs, unsigned long new_ip,
17637 */
17638 #define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE / 3))
17639
17640 +#ifdef CONFIG_PAX_SEGMEXEC
17641 +#define SEGMEXEC_TASK_UNMAPPED_BASE (PAGE_ALIGN(SEGMEXEC_TASK_SIZE / 3))
17642 +#endif
17643 +
17644 #define KSTK_EIP(task) (task_pt_regs(task)->ip)
17645
17646 /* Get/set a process' ability to use the timestamp counter instruction */
17647 @@ -957,7 +956,7 @@ static inline uint32_t hypervisor_cpuid_base(const char *sig, uint32_t leaves)
17648 return 0;
17649 }
17650
17651 -extern unsigned long arch_align_stack(unsigned long sp);
17652 +#define arch_align_stack(x) ((x) & ~0xfUL)
17653 extern void free_init_pages(char *what, unsigned long begin, unsigned long end);
17654
17655 void default_idle(void);
17656 @@ -967,6 +966,6 @@ bool xen_set_default_idle(void);
17657 #define xen_set_default_idle 0
17658 #endif
17659
17660 -void stop_this_cpu(void *dummy);
17661 +void stop_this_cpu(void *dummy) __noreturn;
17662 void df_debug(struct pt_regs *regs, long error_code);
17663 #endif /* _ASM_X86_PROCESSOR_H */
17664 diff --git a/arch/x86/include/asm/ptrace.h b/arch/x86/include/asm/ptrace.h
17665 index 942a086..6c26446 100644
17666 --- a/arch/x86/include/asm/ptrace.h
17667 +++ b/arch/x86/include/asm/ptrace.h
17668 @@ -85,28 +85,29 @@ static inline unsigned long regs_return_value(struct pt_regs *regs)
17669 }
17670
17671 /*
17672 - * user_mode_vm(regs) determines whether a register set came from user mode.
17673 + * user_mode(regs) determines whether a register set came from user mode.
17674 * This is true if V8086 mode was enabled OR if the register set was from
17675 * protected mode with RPL-3 CS value. This tricky test checks that with
17676 * one comparison. Many places in the kernel can bypass this full check
17677 - * if they have already ruled out V8086 mode, so user_mode(regs) can be used.
17678 + * if they have already ruled out V8086 mode, so user_mode_novm(regs) can
17679 + * be used.
17680 */
17681 -static inline int user_mode(struct pt_regs *regs)
17682 +static inline int user_mode_novm(struct pt_regs *regs)
17683 {
17684 #ifdef CONFIG_X86_32
17685 return (regs->cs & SEGMENT_RPL_MASK) == USER_RPL;
17686 #else
17687 - return !!(regs->cs & 3);
17688 + return !!(regs->cs & SEGMENT_RPL_MASK);
17689 #endif
17690 }
17691
17692 -static inline int user_mode_vm(struct pt_regs *regs)
17693 +static inline int user_mode(struct pt_regs *regs)
17694 {
17695 #ifdef CONFIG_X86_32
17696 return ((regs->cs & SEGMENT_RPL_MASK) | (regs->flags & X86_VM_MASK)) >=
17697 USER_RPL;
17698 #else
17699 - return user_mode(regs);
17700 + return user_mode_novm(regs);
17701 #endif
17702 }
17703
17704 @@ -122,15 +123,16 @@ static inline int v8086_mode(struct pt_regs *regs)
17705 #ifdef CONFIG_X86_64
17706 static inline bool user_64bit_mode(struct pt_regs *regs)
17707 {
17708 + unsigned long cs = regs->cs & 0xffff;
17709 #ifndef CONFIG_PARAVIRT
17710 /*
17711 * On non-paravirt systems, this is the only long mode CPL 3
17712 * selector. We do not allow long mode selectors in the LDT.
17713 */
17714 - return regs->cs == __USER_CS;
17715 + return cs == __USER_CS;
17716 #else
17717 /* Headers are too twisted for this to go in paravirt.h. */
17718 - return regs->cs == __USER_CS || regs->cs == pv_info.extra_user_64bit_cs;
17719 + return cs == __USER_CS || cs == pv_info.extra_user_64bit_cs;
17720 #endif
17721 }
17722
17723 @@ -181,9 +183,11 @@ static inline unsigned long regs_get_register(struct pt_regs *regs,
17724 * Traps from the kernel do not save sp and ss.
17725 * Use the helper function to retrieve sp.
17726 */
17727 - if (offset == offsetof(struct pt_regs, sp) &&
17728 - regs->cs == __KERNEL_CS)
17729 - return kernel_stack_pointer(regs);
17730 + if (offset == offsetof(struct pt_regs, sp)) {
17731 + unsigned long cs = regs->cs & 0xffff;
17732 + if (cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS)
17733 + return kernel_stack_pointer(regs);
17734 + }
17735 #endif
17736 return *(unsigned long *)((unsigned long)regs + offset);
17737 }
17738 diff --git a/arch/x86/include/asm/realmode.h b/arch/x86/include/asm/realmode.h
17739 index 9c6b890..5305f53 100644
17740 --- a/arch/x86/include/asm/realmode.h
17741 +++ b/arch/x86/include/asm/realmode.h
17742 @@ -22,16 +22,14 @@ struct real_mode_header {
17743 #endif
17744 /* APM/BIOS reboot */
17745 u32 machine_real_restart_asm;
17746 -#ifdef CONFIG_X86_64
17747 u32 machine_real_restart_seg;
17748 -#endif
17749 };
17750
17751 /* This must match data at trampoline_32/64.S */
17752 struct trampoline_header {
17753 #ifdef CONFIG_X86_32
17754 u32 start;
17755 - u16 gdt_pad;
17756 + u16 boot_cs;
17757 u16 gdt_limit;
17758 u32 gdt_base;
17759 #else
17760 diff --git a/arch/x86/include/asm/reboot.h b/arch/x86/include/asm/reboot.h
17761 index a82c4f1..ac45053 100644
17762 --- a/arch/x86/include/asm/reboot.h
17763 +++ b/arch/x86/include/asm/reboot.h
17764 @@ -6,13 +6,13 @@
17765 struct pt_regs;
17766
17767 struct machine_ops {
17768 - void (*restart)(char *cmd);
17769 - void (*halt)(void);
17770 - void (*power_off)(void);
17771 + void (* __noreturn restart)(char *cmd);
17772 + void (* __noreturn halt)(void);
17773 + void (* __noreturn power_off)(void);
17774 void (*shutdown)(void);
17775 void (*crash_shutdown)(struct pt_regs *);
17776 - void (*emergency_restart)(void);
17777 -};
17778 + void (* __noreturn emergency_restart)(void);
17779 +} __no_const;
17780
17781 extern struct machine_ops machine_ops;
17782
17783 diff --git a/arch/x86/include/asm/rwsem.h b/arch/x86/include/asm/rwsem.h
17784 index cad82c9..2e5c5c1 100644
17785 --- a/arch/x86/include/asm/rwsem.h
17786 +++ b/arch/x86/include/asm/rwsem.h
17787 @@ -64,6 +64,14 @@ static inline void __down_read(struct rw_semaphore *sem)
17788 {
17789 asm volatile("# beginning down_read\n\t"
17790 LOCK_PREFIX _ASM_INC "(%1)\n\t"
17791 +
17792 +#ifdef CONFIG_PAX_REFCOUNT
17793 + "jno 0f\n"
17794 + LOCK_PREFIX _ASM_DEC "(%1)\n"
17795 + "int $4\n0:\n"
17796 + _ASM_EXTABLE(0b, 0b)
17797 +#endif
17798 +
17799 /* adds 0x00000001 */
17800 " jns 1f\n"
17801 " call call_rwsem_down_read_failed\n"
17802 @@ -85,6 +93,14 @@ static inline int __down_read_trylock(struct rw_semaphore *sem)
17803 "1:\n\t"
17804 " mov %1,%2\n\t"
17805 " add %3,%2\n\t"
17806 +
17807 +#ifdef CONFIG_PAX_REFCOUNT
17808 + "jno 0f\n"
17809 + "sub %3,%2\n"
17810 + "int $4\n0:\n"
17811 + _ASM_EXTABLE(0b, 0b)
17812 +#endif
17813 +
17814 " jle 2f\n\t"
17815 LOCK_PREFIX " cmpxchg %2,%0\n\t"
17816 " jnz 1b\n\t"
17817 @@ -104,6 +120,14 @@ static inline void __down_write_nested(struct rw_semaphore *sem, int subclass)
17818 long tmp;
17819 asm volatile("# beginning down_write\n\t"
17820 LOCK_PREFIX " xadd %1,(%2)\n\t"
17821 +
17822 +#ifdef CONFIG_PAX_REFCOUNT
17823 + "jno 0f\n"
17824 + "mov %1,(%2)\n"
17825 + "int $4\n0:\n"
17826 + _ASM_EXTABLE(0b, 0b)
17827 +#endif
17828 +
17829 /* adds 0xffff0001, returns the old value */
17830 " test " __ASM_SEL(%w1,%k1) "," __ASM_SEL(%w1,%k1) "\n\t"
17831 /* was the active mask 0 before? */
17832 @@ -155,6 +179,14 @@ static inline void __up_read(struct rw_semaphore *sem)
17833 long tmp;
17834 asm volatile("# beginning __up_read\n\t"
17835 LOCK_PREFIX " xadd %1,(%2)\n\t"
17836 +
17837 +#ifdef CONFIG_PAX_REFCOUNT
17838 + "jno 0f\n"
17839 + "mov %1,(%2)\n"
17840 + "int $4\n0:\n"
17841 + _ASM_EXTABLE(0b, 0b)
17842 +#endif
17843 +
17844 /* subtracts 1, returns the old value */
17845 " jns 1f\n\t"
17846 " call call_rwsem_wake\n" /* expects old value in %edx */
17847 @@ -173,6 +205,14 @@ static inline void __up_write(struct rw_semaphore *sem)
17848 long tmp;
17849 asm volatile("# beginning __up_write\n\t"
17850 LOCK_PREFIX " xadd %1,(%2)\n\t"
17851 +
17852 +#ifdef CONFIG_PAX_REFCOUNT
17853 + "jno 0f\n"
17854 + "mov %1,(%2)\n"
17855 + "int $4\n0:\n"
17856 + _ASM_EXTABLE(0b, 0b)
17857 +#endif
17858 +
17859 /* subtracts 0xffff0001, returns the old value */
17860 " jns 1f\n\t"
17861 " call call_rwsem_wake\n" /* expects old value in %edx */
17862 @@ -190,6 +230,14 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
17863 {
17864 asm volatile("# beginning __downgrade_write\n\t"
17865 LOCK_PREFIX _ASM_ADD "%2,(%1)\n\t"
17866 +
17867 +#ifdef CONFIG_PAX_REFCOUNT
17868 + "jno 0f\n"
17869 + LOCK_PREFIX _ASM_SUB "%2,(%1)\n"
17870 + "int $4\n0:\n"
17871 + _ASM_EXTABLE(0b, 0b)
17872 +#endif
17873 +
17874 /*
17875 * transitions 0xZZZZ0001 -> 0xYYYY0001 (i386)
17876 * 0xZZZZZZZZ00000001 -> 0xYYYYYYYY00000001 (x86_64)
17877 @@ -208,7 +256,15 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
17878 */
17879 static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
17880 {
17881 - asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0"
17882 + asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0\n"
17883 +
17884 +#ifdef CONFIG_PAX_REFCOUNT
17885 + "jno 0f\n"
17886 + LOCK_PREFIX _ASM_SUB "%1,%0\n"
17887 + "int $4\n0:\n"
17888 + _ASM_EXTABLE(0b, 0b)
17889 +#endif
17890 +
17891 : "+m" (sem->count)
17892 : "er" (delta));
17893 }
17894 @@ -218,7 +274,7 @@ static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
17895 */
17896 static inline long rwsem_atomic_update(long delta, struct rw_semaphore *sem)
17897 {
17898 - return delta + xadd(&sem->count, delta);
17899 + return delta + xadd_check_overflow(&sem->count, delta);
17900 }
17901
17902 #endif /* __KERNEL__ */
17903 diff --git a/arch/x86/include/asm/segment.h b/arch/x86/include/asm/segment.h
17904 index c48a950..bc40804 100644
17905 --- a/arch/x86/include/asm/segment.h
17906 +++ b/arch/x86/include/asm/segment.h
17907 @@ -64,10 +64,15 @@
17908 * 26 - ESPFIX small SS
17909 * 27 - per-cpu [ offset to per-cpu data area ]
17910 * 28 - stack_canary-20 [ for stack protector ]
17911 - * 29 - unused
17912 - * 30 - unused
17913 + * 29 - PCI BIOS CS
17914 + * 30 - PCI BIOS DS
17915 * 31 - TSS for double fault handler
17916 */
17917 +#define GDT_ENTRY_KERNEXEC_EFI_CS (1)
17918 +#define GDT_ENTRY_KERNEXEC_EFI_DS (2)
17919 +#define __KERNEXEC_EFI_CS (GDT_ENTRY_KERNEXEC_EFI_CS*8)
17920 +#define __KERNEXEC_EFI_DS (GDT_ENTRY_KERNEXEC_EFI_DS*8)
17921 +
17922 #define GDT_ENTRY_TLS_MIN 6
17923 #define GDT_ENTRY_TLS_MAX (GDT_ENTRY_TLS_MIN + GDT_ENTRY_TLS_ENTRIES - 1)
17924
17925 @@ -79,6 +84,8 @@
17926
17927 #define GDT_ENTRY_KERNEL_CS (GDT_ENTRY_KERNEL_BASE+0)
17928
17929 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS (4)
17930 +
17931 #define GDT_ENTRY_KERNEL_DS (GDT_ENTRY_KERNEL_BASE+1)
17932
17933 #define GDT_ENTRY_TSS (GDT_ENTRY_KERNEL_BASE+4)
17934 @@ -104,6 +111,12 @@
17935 #define __KERNEL_STACK_CANARY 0
17936 #endif
17937
17938 +#define GDT_ENTRY_PCIBIOS_CS (GDT_ENTRY_KERNEL_BASE+17)
17939 +#define __PCIBIOS_CS (GDT_ENTRY_PCIBIOS_CS * 8)
17940 +
17941 +#define GDT_ENTRY_PCIBIOS_DS (GDT_ENTRY_KERNEL_BASE+18)
17942 +#define __PCIBIOS_DS (GDT_ENTRY_PCIBIOS_DS * 8)
17943 +
17944 #define GDT_ENTRY_DOUBLEFAULT_TSS 31
17945
17946 /*
17947 @@ -141,7 +154,7 @@
17948 */
17949
17950 /* Matches PNP_CS32 and PNP_CS16 (they must be consecutive) */
17951 -#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xf4) == GDT_ENTRY_PNPBIOS_BASE * 8)
17952 +#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xFFFCU) == PNP_CS32 || ((x) & 0xFFFCU) == PNP_CS16)
17953
17954
17955 #else
17956 @@ -165,6 +178,8 @@
17957 #define __USER32_CS (GDT_ENTRY_DEFAULT_USER32_CS*8+3)
17958 #define __USER32_DS __USER_DS
17959
17960 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS 7
17961 +
17962 #define GDT_ENTRY_TSS 8 /* needs two entries */
17963 #define GDT_ENTRY_LDT 10 /* needs two entries */
17964 #define GDT_ENTRY_TLS_MIN 12
17965 @@ -173,6 +188,8 @@
17966 #define GDT_ENTRY_PER_CPU 15 /* Abused to load per CPU data from limit */
17967 #define __PER_CPU_SEG (GDT_ENTRY_PER_CPU * 8 + 3)
17968
17969 +#define GDT_ENTRY_UDEREF_KERNEL_DS 16
17970 +
17971 /* TLS indexes for 64bit - hardcoded in arch_prctl */
17972 #define FS_TLS 0
17973 #define GS_TLS 1
17974 @@ -180,12 +197,14 @@
17975 #define GS_TLS_SEL ((GDT_ENTRY_TLS_MIN+GS_TLS)*8 + 3)
17976 #define FS_TLS_SEL ((GDT_ENTRY_TLS_MIN+FS_TLS)*8 + 3)
17977
17978 -#define GDT_ENTRIES 16
17979 +#define GDT_ENTRIES 17
17980
17981 #endif
17982
17983 #define __KERNEL_CS (GDT_ENTRY_KERNEL_CS*8)
17984 +#define __KERNEXEC_KERNEL_CS (GDT_ENTRY_KERNEXEC_KERNEL_CS*8)
17985 #define __KERNEL_DS (GDT_ENTRY_KERNEL_DS*8)
17986 +#define __UDEREF_KERNEL_DS (GDT_ENTRY_UDEREF_KERNEL_DS*8)
17987 #define __USER_DS (GDT_ENTRY_DEFAULT_USER_DS*8+3)
17988 #define __USER_CS (GDT_ENTRY_DEFAULT_USER_CS*8+3)
17989 #ifndef CONFIG_PARAVIRT
17990 @@ -265,7 +284,7 @@ static inline unsigned long get_limit(unsigned long segment)
17991 {
17992 unsigned long __limit;
17993 asm("lsll %1,%0" : "=r" (__limit) : "r" (segment));
17994 - return __limit + 1;
17995 + return __limit;
17996 }
17997
17998 #endif /* !__ASSEMBLY__ */
17999 diff --git a/arch/x86/include/asm/smap.h b/arch/x86/include/asm/smap.h
18000 index 8d3120f..352b440 100644
18001 --- a/arch/x86/include/asm/smap.h
18002 +++ b/arch/x86/include/asm/smap.h
18003 @@ -25,11 +25,40 @@
18004
18005 #include <asm/alternative-asm.h>
18006
18007 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18008 +#define ASM_PAX_OPEN_USERLAND \
18009 + 661: jmp 663f; \
18010 + .pushsection .altinstr_replacement, "a" ; \
18011 + 662: pushq %rax; nop; \
18012 + .popsection ; \
18013 + .pushsection .altinstructions, "a" ; \
18014 + altinstruction_entry 661b, 662b, X86_FEATURE_STRONGUDEREF, 2, 2;\
18015 + .popsection ; \
18016 + call __pax_open_userland; \
18017 + popq %rax; \
18018 + 663:
18019 +
18020 +#define ASM_PAX_CLOSE_USERLAND \
18021 + 661: jmp 663f; \
18022 + .pushsection .altinstr_replacement, "a" ; \
18023 + 662: pushq %rax; nop; \
18024 + .popsection; \
18025 + .pushsection .altinstructions, "a" ; \
18026 + altinstruction_entry 661b, 662b, X86_FEATURE_STRONGUDEREF, 2, 2;\
18027 + .popsection; \
18028 + call __pax_close_userland; \
18029 + popq %rax; \
18030 + 663:
18031 +#else
18032 +#define ASM_PAX_OPEN_USERLAND
18033 +#define ASM_PAX_CLOSE_USERLAND
18034 +#endif
18035 +
18036 #ifdef CONFIG_X86_SMAP
18037
18038 #define ASM_CLAC \
18039 661: ASM_NOP3 ; \
18040 - .pushsection .altinstr_replacement, "ax" ; \
18041 + .pushsection .altinstr_replacement, "a" ; \
18042 662: __ASM_CLAC ; \
18043 .popsection ; \
18044 .pushsection .altinstructions, "a" ; \
18045 @@ -38,7 +67,7 @@
18046
18047 #define ASM_STAC \
18048 661: ASM_NOP3 ; \
18049 - .pushsection .altinstr_replacement, "ax" ; \
18050 + .pushsection .altinstr_replacement, "a" ; \
18051 662: __ASM_STAC ; \
18052 .popsection ; \
18053 .pushsection .altinstructions, "a" ; \
18054 @@ -56,6 +85,37 @@
18055
18056 #include <asm/alternative.h>
18057
18058 +#define __HAVE_ARCH_PAX_OPEN_USERLAND
18059 +#define __HAVE_ARCH_PAX_CLOSE_USERLAND
18060 +
18061 +extern void __pax_open_userland(void);
18062 +static __always_inline unsigned long pax_open_userland(void)
18063 +{
18064 +
18065 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18066 + asm volatile(ALTERNATIVE(ASM_NOP5, "call %P[open]", X86_FEATURE_STRONGUDEREF)
18067 + :
18068 + : [open] "i" (__pax_open_userland)
18069 + : "memory", "rax");
18070 +#endif
18071 +
18072 + return 0;
18073 +}
18074 +
18075 +extern void __pax_close_userland(void);
18076 +static __always_inline unsigned long pax_close_userland(void)
18077 +{
18078 +
18079 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18080 + asm volatile(ALTERNATIVE(ASM_NOP5, "call %P[close]", X86_FEATURE_STRONGUDEREF)
18081 + :
18082 + : [close] "i" (__pax_close_userland)
18083 + : "memory", "rax");
18084 +#endif
18085 +
18086 + return 0;
18087 +}
18088 +
18089 #ifdef CONFIG_X86_SMAP
18090
18091 static __always_inline void clac(void)
18092 diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h
18093 index 4137890..03fa172 100644
18094 --- a/arch/x86/include/asm/smp.h
18095 +++ b/arch/x86/include/asm/smp.h
18096 @@ -36,7 +36,7 @@ DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_core_map);
18097 /* cpus sharing the last level cache: */
18098 DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_llc_shared_map);
18099 DECLARE_PER_CPU_READ_MOSTLY(u16, cpu_llc_id);
18100 -DECLARE_PER_CPU_READ_MOSTLY(int, cpu_number);
18101 +DECLARE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
18102
18103 static inline struct cpumask *cpu_sibling_mask(int cpu)
18104 {
18105 @@ -79,7 +79,7 @@ struct smp_ops {
18106
18107 void (*send_call_func_ipi)(const struct cpumask *mask);
18108 void (*send_call_func_single_ipi)(int cpu);
18109 -};
18110 +} __no_const;
18111
18112 /* Globals due to paravirt */
18113 extern void set_cpu_sibling_map(int cpu);
18114 @@ -191,14 +191,8 @@ extern unsigned disabled_cpus;
18115 extern int safe_smp_processor_id(void);
18116
18117 #elif defined(CONFIG_X86_64_SMP)
18118 -#define raw_smp_processor_id() (this_cpu_read(cpu_number))
18119 -
18120 -#define stack_smp_processor_id() \
18121 -({ \
18122 - struct thread_info *ti; \
18123 - __asm__("andq %%rsp,%0; ":"=r" (ti) : "0" (CURRENT_MASK)); \
18124 - ti->cpu; \
18125 -})
18126 +#define raw_smp_processor_id() (this_cpu_read(cpu_number))
18127 +#define stack_smp_processor_id() raw_smp_processor_id()
18128 #define safe_smp_processor_id() smp_processor_id()
18129
18130 #endif
18131 diff --git a/arch/x86/include/asm/spinlock.h b/arch/x86/include/asm/spinlock.h
18132 index bf156de..1a782ab 100644
18133 --- a/arch/x86/include/asm/spinlock.h
18134 +++ b/arch/x86/include/asm/spinlock.h
18135 @@ -223,6 +223,14 @@ static inline int arch_write_can_lock(arch_rwlock_t *lock)
18136 static inline void arch_read_lock(arch_rwlock_t *rw)
18137 {
18138 asm volatile(LOCK_PREFIX READ_LOCK_SIZE(dec) " (%0)\n\t"
18139 +
18140 +#ifdef CONFIG_PAX_REFCOUNT
18141 + "jno 0f\n"
18142 + LOCK_PREFIX READ_LOCK_SIZE(inc) " (%0)\n"
18143 + "int $4\n0:\n"
18144 + _ASM_EXTABLE(0b, 0b)
18145 +#endif
18146 +
18147 "jns 1f\n"
18148 "call __read_lock_failed\n\t"
18149 "1:\n"
18150 @@ -232,6 +240,14 @@ static inline void arch_read_lock(arch_rwlock_t *rw)
18151 static inline void arch_write_lock(arch_rwlock_t *rw)
18152 {
18153 asm volatile(LOCK_PREFIX WRITE_LOCK_SUB(%1) "(%0)\n\t"
18154 +
18155 +#ifdef CONFIG_PAX_REFCOUNT
18156 + "jno 0f\n"
18157 + LOCK_PREFIX WRITE_LOCK_ADD(%1) "(%0)\n"
18158 + "int $4\n0:\n"
18159 + _ASM_EXTABLE(0b, 0b)
18160 +#endif
18161 +
18162 "jz 1f\n"
18163 "call __write_lock_failed\n\t"
18164 "1:\n"
18165 @@ -261,13 +277,29 @@ static inline int arch_write_trylock(arch_rwlock_t *lock)
18166
18167 static inline void arch_read_unlock(arch_rwlock_t *rw)
18168 {
18169 - asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0"
18170 + asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0\n"
18171 +
18172 +#ifdef CONFIG_PAX_REFCOUNT
18173 + "jno 0f\n"
18174 + LOCK_PREFIX READ_LOCK_SIZE(dec) " %0\n"
18175 + "int $4\n0:\n"
18176 + _ASM_EXTABLE(0b, 0b)
18177 +#endif
18178 +
18179 :"+m" (rw->lock) : : "memory");
18180 }
18181
18182 static inline void arch_write_unlock(arch_rwlock_t *rw)
18183 {
18184 - asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0"
18185 + asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0\n"
18186 +
18187 +#ifdef CONFIG_PAX_REFCOUNT
18188 + "jno 0f\n"
18189 + LOCK_PREFIX WRITE_LOCK_SUB(%1) "%0\n"
18190 + "int $4\n0:\n"
18191 + _ASM_EXTABLE(0b, 0b)
18192 +#endif
18193 +
18194 : "+m" (rw->write) : "i" (RW_LOCK_BIAS) : "memory");
18195 }
18196
18197 diff --git a/arch/x86/include/asm/stackprotector.h b/arch/x86/include/asm/stackprotector.h
18198 index 6a99859..03cb807 100644
18199 --- a/arch/x86/include/asm/stackprotector.h
18200 +++ b/arch/x86/include/asm/stackprotector.h
18201 @@ -47,7 +47,7 @@
18202 * head_32 for boot CPU and setup_per_cpu_areas() for others.
18203 */
18204 #define GDT_STACK_CANARY_INIT \
18205 - [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x18),
18206 + [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x17),
18207
18208 /*
18209 * Initialize the stackprotector canary value.
18210 @@ -112,7 +112,7 @@ static inline void setup_stack_canary_segment(int cpu)
18211
18212 static inline void load_stack_canary_segment(void)
18213 {
18214 -#ifdef CONFIG_X86_32
18215 +#if defined(CONFIG_X86_32) && !defined(CONFIG_PAX_MEMORY_UDEREF)
18216 asm volatile ("mov %0, %%gs" : : "r" (0));
18217 #endif
18218 }
18219 diff --git a/arch/x86/include/asm/stacktrace.h b/arch/x86/include/asm/stacktrace.h
18220 index 70bbe39..4ae2bd4 100644
18221 --- a/arch/x86/include/asm/stacktrace.h
18222 +++ b/arch/x86/include/asm/stacktrace.h
18223 @@ -11,28 +11,20 @@
18224
18225 extern int kstack_depth_to_print;
18226
18227 -struct thread_info;
18228 +struct task_struct;
18229 struct stacktrace_ops;
18230
18231 -typedef unsigned long (*walk_stack_t)(struct thread_info *tinfo,
18232 - unsigned long *stack,
18233 - unsigned long bp,
18234 - const struct stacktrace_ops *ops,
18235 - void *data,
18236 - unsigned long *end,
18237 - int *graph);
18238 +typedef unsigned long walk_stack_t(struct task_struct *task,
18239 + void *stack_start,
18240 + unsigned long *stack,
18241 + unsigned long bp,
18242 + const struct stacktrace_ops *ops,
18243 + void *data,
18244 + unsigned long *end,
18245 + int *graph);
18246
18247 -extern unsigned long
18248 -print_context_stack(struct thread_info *tinfo,
18249 - unsigned long *stack, unsigned long bp,
18250 - const struct stacktrace_ops *ops, void *data,
18251 - unsigned long *end, int *graph);
18252 -
18253 -extern unsigned long
18254 -print_context_stack_bp(struct thread_info *tinfo,
18255 - unsigned long *stack, unsigned long bp,
18256 - const struct stacktrace_ops *ops, void *data,
18257 - unsigned long *end, int *graph);
18258 +extern walk_stack_t print_context_stack;
18259 +extern walk_stack_t print_context_stack_bp;
18260
18261 /* Generic stack tracer with callbacks */
18262
18263 @@ -40,7 +32,7 @@ struct stacktrace_ops {
18264 void (*address)(void *data, unsigned long address, int reliable);
18265 /* On negative return stop dumping */
18266 int (*stack)(void *data, char *name);
18267 - walk_stack_t walk_stack;
18268 + walk_stack_t *walk_stack;
18269 };
18270
18271 void dump_trace(struct task_struct *tsk, struct pt_regs *regs,
18272 diff --git a/arch/x86/include/asm/switch_to.h b/arch/x86/include/asm/switch_to.h
18273 index d7f3b3b..3cc39f1 100644
18274 --- a/arch/x86/include/asm/switch_to.h
18275 +++ b/arch/x86/include/asm/switch_to.h
18276 @@ -108,7 +108,7 @@ do { \
18277 "call __switch_to\n\t" \
18278 "movq "__percpu_arg([current_task])",%%rsi\n\t" \
18279 __switch_canary \
18280 - "movq %P[thread_info](%%rsi),%%r8\n\t" \
18281 + "movq "__percpu_arg([thread_info])",%%r8\n\t" \
18282 "movq %%rax,%%rdi\n\t" \
18283 "testl %[_tif_fork],%P[ti_flags](%%r8)\n\t" \
18284 "jnz ret_from_fork\n\t" \
18285 @@ -119,7 +119,7 @@ do { \
18286 [threadrsp] "i" (offsetof(struct task_struct, thread.sp)), \
18287 [ti_flags] "i" (offsetof(struct thread_info, flags)), \
18288 [_tif_fork] "i" (_TIF_FORK), \
18289 - [thread_info] "i" (offsetof(struct task_struct, stack)), \
18290 + [thread_info] "m" (current_tinfo), \
18291 [current_task] "m" (current_task) \
18292 __switch_canary_iparam \
18293 : "memory", "cc" __EXTRA_CLOBBER)
18294 diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h
18295 index 2781119..618b59b 100644
18296 --- a/arch/x86/include/asm/thread_info.h
18297 +++ b/arch/x86/include/asm/thread_info.h
18298 @@ -10,6 +10,7 @@
18299 #include <linux/compiler.h>
18300 #include <asm/page.h>
18301 #include <asm/types.h>
18302 +#include <asm/percpu.h>
18303
18304 /*
18305 * low level task data that entry.S needs immediate access to
18306 @@ -23,7 +24,6 @@ struct exec_domain;
18307 #include <linux/atomic.h>
18308
18309 struct thread_info {
18310 - struct task_struct *task; /* main task structure */
18311 struct exec_domain *exec_domain; /* execution domain */
18312 __u32 flags; /* low level flags */
18313 __u32 status; /* thread synchronous flags */
18314 @@ -33,19 +33,13 @@ struct thread_info {
18315 mm_segment_t addr_limit;
18316 struct restart_block restart_block;
18317 void __user *sysenter_return;
18318 -#ifdef CONFIG_X86_32
18319 - unsigned long previous_esp; /* ESP of the previous stack in
18320 - case of nested (IRQ) stacks
18321 - */
18322 - __u8 supervisor_stack[0];
18323 -#endif
18324 + unsigned long lowest_stack;
18325 unsigned int sig_on_uaccess_error:1;
18326 unsigned int uaccess_err:1; /* uaccess failed */
18327 };
18328
18329 -#define INIT_THREAD_INFO(tsk) \
18330 +#define INIT_THREAD_INFO \
18331 { \
18332 - .task = &tsk, \
18333 .exec_domain = &default_exec_domain, \
18334 .flags = 0, \
18335 .cpu = 0, \
18336 @@ -56,7 +50,7 @@ struct thread_info {
18337 }, \
18338 }
18339
18340 -#define init_thread_info (init_thread_union.thread_info)
18341 +#define init_thread_info (init_thread_union.stack)
18342 #define init_stack (init_thread_union.stack)
18343
18344 #else /* !__ASSEMBLY__ */
18345 @@ -96,6 +90,7 @@ struct thread_info {
18346 #define TIF_SYSCALL_TRACEPOINT 28 /* syscall tracepoint instrumentation */
18347 #define TIF_ADDR32 29 /* 32-bit address space on 64 bits */
18348 #define TIF_X32 30 /* 32-bit native x86-64 binary */
18349 +#define TIF_GRSEC_SETXID 31 /* update credentials on syscall entry/exit */
18350
18351 #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
18352 #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
18353 @@ -119,17 +114,18 @@ struct thread_info {
18354 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
18355 #define _TIF_ADDR32 (1 << TIF_ADDR32)
18356 #define _TIF_X32 (1 << TIF_X32)
18357 +#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
18358
18359 /* work to do in syscall_trace_enter() */
18360 #define _TIF_WORK_SYSCALL_ENTRY \
18361 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_EMU | _TIF_SYSCALL_AUDIT | \
18362 _TIF_SECCOMP | _TIF_SINGLESTEP | _TIF_SYSCALL_TRACEPOINT | \
18363 - _TIF_NOHZ)
18364 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
18365
18366 /* work to do in syscall_trace_leave() */
18367 #define _TIF_WORK_SYSCALL_EXIT \
18368 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_SINGLESTEP | \
18369 - _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ)
18370 + _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ | _TIF_GRSEC_SETXID)
18371
18372 /* work to do on interrupt/exception return */
18373 #define _TIF_WORK_MASK \
18374 @@ -140,7 +136,7 @@ struct thread_info {
18375 /* work to do on any return to user space */
18376 #define _TIF_ALLWORK_MASK \
18377 ((0x0000FFFF & ~_TIF_SECCOMP) | _TIF_SYSCALL_TRACEPOINT | \
18378 - _TIF_NOHZ)
18379 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
18380
18381 /* Only used for 64 bit */
18382 #define _TIF_DO_NOTIFY_MASK \
18383 @@ -156,45 +152,40 @@ struct thread_info {
18384
18385 #define PREEMPT_ACTIVE 0x10000000
18386
18387 -#ifdef CONFIG_X86_32
18388 -
18389 -#define STACK_WARN (THREAD_SIZE/8)
18390 -/*
18391 - * macros/functions for gaining access to the thread information structure
18392 - *
18393 - * preempt_count needs to be 1 initially, until the scheduler is functional.
18394 - */
18395 -#ifndef __ASSEMBLY__
18396 -
18397 -
18398 -/* how to get the current stack pointer from C */
18399 -register unsigned long current_stack_pointer asm("esp") __used;
18400 -
18401 -/* how to get the thread information struct from C */
18402 -static inline struct thread_info *current_thread_info(void)
18403 -{
18404 - return (struct thread_info *)
18405 - (current_stack_pointer & ~(THREAD_SIZE - 1));
18406 -}
18407 -
18408 -#else /* !__ASSEMBLY__ */
18409 -
18410 +#ifdef __ASSEMBLY__
18411 /* how to get the thread information struct from ASM */
18412 #define GET_THREAD_INFO(reg) \
18413 - movl $-THREAD_SIZE, reg; \
18414 - andl %esp, reg
18415 + mov PER_CPU_VAR(current_tinfo), reg
18416
18417 /* use this one if reg already contains %esp */
18418 -#define GET_THREAD_INFO_WITH_ESP(reg) \
18419 - andl $-THREAD_SIZE, reg
18420 +#define GET_THREAD_INFO_WITH_ESP(reg) GET_THREAD_INFO(reg)
18421 +#else
18422 +/* how to get the thread information struct from C */
18423 +DECLARE_PER_CPU(struct thread_info *, current_tinfo);
18424 +
18425 +static __always_inline struct thread_info *current_thread_info(void)
18426 +{
18427 + return this_cpu_read_stable(current_tinfo);
18428 +}
18429 +#endif
18430 +
18431 +#ifdef CONFIG_X86_32
18432 +
18433 +#define STACK_WARN (THREAD_SIZE/8)
18434 +/*
18435 + * macros/functions for gaining access to the thread information structure
18436 + *
18437 + * preempt_count needs to be 1 initially, until the scheduler is functional.
18438 + */
18439 +#ifndef __ASSEMBLY__
18440 +
18441 +/* how to get the current stack pointer from C */
18442 +register unsigned long current_stack_pointer asm("esp") __used;
18443
18444 #endif
18445
18446 #else /* X86_32 */
18447
18448 -#include <asm/percpu.h>
18449 -#define KERNEL_STACK_OFFSET (5*8)
18450 -
18451 /*
18452 * macros/functions for gaining access to the thread information structure
18453 * preempt_count needs to be 1 initially, until the scheduler is functional.
18454 @@ -202,27 +193,8 @@ static inline struct thread_info *current_thread_info(void)
18455 #ifndef __ASSEMBLY__
18456 DECLARE_PER_CPU(unsigned long, kernel_stack);
18457
18458 -static inline struct thread_info *current_thread_info(void)
18459 -{
18460 - struct thread_info *ti;
18461 - ti = (void *)(this_cpu_read_stable(kernel_stack) +
18462 - KERNEL_STACK_OFFSET - THREAD_SIZE);
18463 - return ti;
18464 -}
18465 -
18466 -#else /* !__ASSEMBLY__ */
18467 -
18468 -/* how to get the thread information struct from ASM */
18469 -#define GET_THREAD_INFO(reg) \
18470 - movq PER_CPU_VAR(kernel_stack),reg ; \
18471 - subq $(THREAD_SIZE-KERNEL_STACK_OFFSET),reg
18472 -
18473 -/*
18474 - * Same if PER_CPU_VAR(kernel_stack) is, perhaps with some offset, already in
18475 - * a certain register (to be used in assembler memory operands).
18476 - */
18477 -#define THREAD_INFO(reg, off) KERNEL_STACK_OFFSET+(off)-THREAD_SIZE(reg)
18478 -
18479 +/* how to get the current stack pointer from C */
18480 +register unsigned long current_stack_pointer asm("rsp") __used;
18481 #endif
18482
18483 #endif /* !X86_32 */
18484 @@ -281,5 +253,12 @@ static inline bool is_ia32_task(void)
18485 extern void arch_task_cache_init(void);
18486 extern int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src);
18487 extern void arch_release_task_struct(struct task_struct *tsk);
18488 +
18489 +#define __HAVE_THREAD_FUNCTIONS
18490 +#define task_thread_info(task) (&(task)->tinfo)
18491 +#define task_stack_page(task) ((task)->stack)
18492 +#define setup_thread_stack(p, org) do {} while (0)
18493 +#define end_of_stack(p) ((unsigned long *)task_stack_page(p) + 1)
18494 +
18495 #endif
18496 #endif /* _ASM_X86_THREAD_INFO_H */
18497 diff --git a/arch/x86/include/asm/tlbflush.h b/arch/x86/include/asm/tlbflush.h
18498 index e6d90ba..0897f44 100644
18499 --- a/arch/x86/include/asm/tlbflush.h
18500 +++ b/arch/x86/include/asm/tlbflush.h
18501 @@ -17,18 +17,44 @@
18502
18503 static inline void __native_flush_tlb(void)
18504 {
18505 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
18506 + u64 descriptor[2];
18507 +
18508 + descriptor[0] = PCID_KERNEL;
18509 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_ALL_MONGLOBAL) : "memory");
18510 + return;
18511 + }
18512 +
18513 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18514 + if (static_cpu_has(X86_FEATURE_PCID)) {
18515 + unsigned int cpu = raw_get_cpu();
18516 +
18517 + native_write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER);
18518 + native_write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL);
18519 + raw_put_cpu_no_resched();
18520 + return;
18521 + }
18522 +#endif
18523 +
18524 native_write_cr3(native_read_cr3());
18525 }
18526
18527 static inline void __native_flush_tlb_global_irq_disabled(void)
18528 {
18529 - unsigned long cr4;
18530 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
18531 + u64 descriptor[2];
18532
18533 - cr4 = native_read_cr4();
18534 - /* clear PGE */
18535 - native_write_cr4(cr4 & ~X86_CR4_PGE);
18536 - /* write old PGE again and flush TLBs */
18537 - native_write_cr4(cr4);
18538 + descriptor[0] = PCID_KERNEL;
18539 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_ALL_GLOBAL) : "memory");
18540 + } else {
18541 + unsigned long cr4;
18542 +
18543 + cr4 = native_read_cr4();
18544 + /* clear PGE */
18545 + native_write_cr4(cr4 & ~X86_CR4_PGE);
18546 + /* write old PGE again and flush TLBs */
18547 + native_write_cr4(cr4);
18548 + }
18549 }
18550
18551 static inline void __native_flush_tlb_global(void)
18552 @@ -49,6 +75,42 @@ static inline void __native_flush_tlb_global(void)
18553
18554 static inline void __native_flush_tlb_single(unsigned long addr)
18555 {
18556 +
18557 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
18558 + u64 descriptor[2];
18559 +
18560 + descriptor[0] = PCID_KERNEL;
18561 + descriptor[1] = addr;
18562 +
18563 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18564 + if (!static_cpu_has(X86_FEATURE_STRONGUDEREF) || addr >= TASK_SIZE_MAX) {
18565 + if (addr < TASK_SIZE_MAX)
18566 + descriptor[1] += pax_user_shadow_base;
18567 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_ADDRESS) : "memory");
18568 + }
18569 +
18570 + descriptor[0] = PCID_USER;
18571 + descriptor[1] = addr;
18572 +#endif
18573 +
18574 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_ADDRESS) : "memory");
18575 + return;
18576 + }
18577 +
18578 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18579 + if (static_cpu_has(X86_FEATURE_PCID)) {
18580 + unsigned int cpu = raw_get_cpu();
18581 +
18582 + native_write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER | PCID_NOFLUSH);
18583 + asm volatile("invlpg (%0)" ::"r" (addr) : "memory");
18584 + native_write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
18585 + raw_put_cpu_no_resched();
18586 +
18587 + if (!static_cpu_has(X86_FEATURE_STRONGUDEREF) && addr < TASK_SIZE_MAX)
18588 + addr += pax_user_shadow_base;
18589 + }
18590 +#endif
18591 +
18592 asm volatile("invlpg (%0)" ::"r" (addr) : "memory");
18593 }
18594
18595 diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
18596 index 5838fa9..f7ae572 100644
18597 --- a/arch/x86/include/asm/uaccess.h
18598 +++ b/arch/x86/include/asm/uaccess.h
18599 @@ -7,6 +7,7 @@
18600 #include <linux/compiler.h>
18601 #include <linux/thread_info.h>
18602 #include <linux/string.h>
18603 +#include <linux/sched.h>
18604 #include <asm/asm.h>
18605 #include <asm/page.h>
18606 #include <asm/smap.h>
18607 @@ -29,7 +30,12 @@
18608
18609 #define get_ds() (KERNEL_DS)
18610 #define get_fs() (current_thread_info()->addr_limit)
18611 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
18612 +void __set_fs(mm_segment_t x);
18613 +void set_fs(mm_segment_t x);
18614 +#else
18615 #define set_fs(x) (current_thread_info()->addr_limit = (x))
18616 +#endif
18617
18618 #define segment_eq(a, b) ((a).seg == (b).seg)
18619
18620 @@ -77,8 +83,33 @@
18621 * checks that the pointer is in the user space range - after calling
18622 * this function, memory access functions may still return -EFAULT.
18623 */
18624 -#define access_ok(type, addr, size) \
18625 - (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
18626 +#define __access_ok(type, addr, size) (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
18627 +#define access_ok(type, addr, size) \
18628 +({ \
18629 + long __size = size; \
18630 + unsigned long __addr = (unsigned long)addr; \
18631 + unsigned long __addr_ao = __addr & PAGE_MASK; \
18632 + unsigned long __end_ao = __addr + __size - 1; \
18633 + bool __ret_ao = __range_not_ok(__addr, __size, user_addr_max()) == 0;\
18634 + if (__ret_ao && unlikely((__end_ao ^ __addr_ao) & PAGE_MASK)) { \
18635 + while(__addr_ao <= __end_ao) { \
18636 + char __c_ao; \
18637 + __addr_ao += PAGE_SIZE; \
18638 + if (__size > PAGE_SIZE) \
18639 + cond_resched(); \
18640 + if (__get_user(__c_ao, (char __user *)__addr)) \
18641 + break; \
18642 + if (type != VERIFY_WRITE) { \
18643 + __addr = __addr_ao; \
18644 + continue; \
18645 + } \
18646 + if (__put_user(__c_ao, (char __user *)__addr)) \
18647 + break; \
18648 + __addr = __addr_ao; \
18649 + } \
18650 + } \
18651 + __ret_ao; \
18652 +})
18653
18654 /*
18655 * The exception table consists of pairs of addresses relative to the
18656 @@ -168,10 +199,12 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
18657 register __inttype(*(ptr)) __val_gu asm("%"_ASM_DX); \
18658 __chk_user_ptr(ptr); \
18659 might_fault(); \
18660 + pax_open_userland(); \
18661 asm volatile("call __get_user_%P3" \
18662 : "=a" (__ret_gu), "=r" (__val_gu) \
18663 : "0" (ptr), "i" (sizeof(*(ptr)))); \
18664 (x) = (__typeof__(*(ptr))) __val_gu; \
18665 + pax_close_userland(); \
18666 __ret_gu; \
18667 })
18668
18669 @@ -179,13 +212,21 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
18670 asm volatile("call __put_user_" #size : "=a" (__ret_pu) \
18671 : "0" ((typeof(*(ptr)))(x)), "c" (ptr) : "ebx")
18672
18673 -
18674 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
18675 +#define __copyuser_seg "gs;"
18676 +#define __COPYUSER_SET_ES "pushl %%gs; popl %%es\n"
18677 +#define __COPYUSER_RESTORE_ES "pushl %%ss; popl %%es\n"
18678 +#else
18679 +#define __copyuser_seg
18680 +#define __COPYUSER_SET_ES
18681 +#define __COPYUSER_RESTORE_ES
18682 +#endif
18683
18684 #ifdef CONFIG_X86_32
18685 #define __put_user_asm_u64(x, addr, err, errret) \
18686 asm volatile(ASM_STAC "\n" \
18687 - "1: movl %%eax,0(%2)\n" \
18688 - "2: movl %%edx,4(%2)\n" \
18689 + "1: "__copyuser_seg"movl %%eax,0(%2)\n" \
18690 + "2: "__copyuser_seg"movl %%edx,4(%2)\n" \
18691 "3: " ASM_CLAC "\n" \
18692 ".section .fixup,\"ax\"\n" \
18693 "4: movl %3,%0\n" \
18694 @@ -198,8 +239,8 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
18695
18696 #define __put_user_asm_ex_u64(x, addr) \
18697 asm volatile(ASM_STAC "\n" \
18698 - "1: movl %%eax,0(%1)\n" \
18699 - "2: movl %%edx,4(%1)\n" \
18700 + "1: "__copyuser_seg"movl %%eax,0(%1)\n" \
18701 + "2: "__copyuser_seg"movl %%edx,4(%1)\n" \
18702 "3: " ASM_CLAC "\n" \
18703 _ASM_EXTABLE_EX(1b, 2b) \
18704 _ASM_EXTABLE_EX(2b, 3b) \
18705 @@ -249,7 +290,8 @@ extern void __put_user_8(void);
18706 __typeof__(*(ptr)) __pu_val; \
18707 __chk_user_ptr(ptr); \
18708 might_fault(); \
18709 - __pu_val = x; \
18710 + __pu_val = (x); \
18711 + pax_open_userland(); \
18712 switch (sizeof(*(ptr))) { \
18713 case 1: \
18714 __put_user_x(1, __pu_val, ptr, __ret_pu); \
18715 @@ -267,6 +309,7 @@ extern void __put_user_8(void);
18716 __put_user_x(X, __pu_val, ptr, __ret_pu); \
18717 break; \
18718 } \
18719 + pax_close_userland(); \
18720 __ret_pu; \
18721 })
18722
18723 @@ -347,8 +390,10 @@ do { \
18724 } while (0)
18725
18726 #define __get_user_asm(x, addr, err, itype, rtype, ltype, errret) \
18727 +do { \
18728 + pax_open_userland(); \
18729 asm volatile(ASM_STAC "\n" \
18730 - "1: mov"itype" %2,%"rtype"1\n" \
18731 + "1: "__copyuser_seg"mov"itype" %2,%"rtype"1\n"\
18732 "2: " ASM_CLAC "\n" \
18733 ".section .fixup,\"ax\"\n" \
18734 "3: mov %3,%0\n" \
18735 @@ -356,8 +401,10 @@ do { \
18736 " jmp 2b\n" \
18737 ".previous\n" \
18738 _ASM_EXTABLE(1b, 3b) \
18739 - : "=r" (err), ltype(x) \
18740 - : "m" (__m(addr)), "i" (errret), "0" (err))
18741 + : "=r" (err), ltype (x) \
18742 + : "m" (__m(addr)), "i" (errret), "0" (err)); \
18743 + pax_close_userland(); \
18744 +} while (0)
18745
18746 #define __get_user_size_ex(x, ptr, size) \
18747 do { \
18748 @@ -381,7 +428,7 @@ do { \
18749 } while (0)
18750
18751 #define __get_user_asm_ex(x, addr, itype, rtype, ltype) \
18752 - asm volatile("1: mov"itype" %1,%"rtype"0\n" \
18753 + asm volatile("1: "__copyuser_seg"mov"itype" %1,%"rtype"0\n"\
18754 "2:\n" \
18755 _ASM_EXTABLE_EX(1b, 2b) \
18756 : ltype(x) : "m" (__m(addr)))
18757 @@ -398,13 +445,24 @@ do { \
18758 int __gu_err; \
18759 unsigned long __gu_val; \
18760 __get_user_size(__gu_val, (ptr), (size), __gu_err, -EFAULT); \
18761 - (x) = (__force __typeof__(*(ptr)))__gu_val; \
18762 + (x) = (__typeof__(*(ptr)))__gu_val; \
18763 __gu_err; \
18764 })
18765
18766 /* FIXME: this hack is definitely wrong -AK */
18767 struct __large_struct { unsigned long buf[100]; };
18768 -#define __m(x) (*(struct __large_struct __user *)(x))
18769 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18770 +#define ____m(x) \
18771 +({ \
18772 + unsigned long ____x = (unsigned long)(x); \
18773 + if (____x < pax_user_shadow_base) \
18774 + ____x += pax_user_shadow_base; \
18775 + (typeof(x))____x; \
18776 +})
18777 +#else
18778 +#define ____m(x) (x)
18779 +#endif
18780 +#define __m(x) (*(struct __large_struct __user *)____m(x))
18781
18782 /*
18783 * Tell gcc we read from memory instead of writing: this is because
18784 @@ -412,8 +470,10 @@ struct __large_struct { unsigned long buf[100]; };
18785 * aliasing issues.
18786 */
18787 #define __put_user_asm(x, addr, err, itype, rtype, ltype, errret) \
18788 +do { \
18789 + pax_open_userland(); \
18790 asm volatile(ASM_STAC "\n" \
18791 - "1: mov"itype" %"rtype"1,%2\n" \
18792 + "1: "__copyuser_seg"mov"itype" %"rtype"1,%2\n"\
18793 "2: " ASM_CLAC "\n" \
18794 ".section .fixup,\"ax\"\n" \
18795 "3: mov %3,%0\n" \
18796 @@ -421,10 +481,12 @@ struct __large_struct { unsigned long buf[100]; };
18797 ".previous\n" \
18798 _ASM_EXTABLE(1b, 3b) \
18799 : "=r"(err) \
18800 - : ltype(x), "m" (__m(addr)), "i" (errret), "0" (err))
18801 + : ltype (x), "m" (__m(addr)), "i" (errret), "0" (err));\
18802 + pax_close_userland(); \
18803 +} while (0)
18804
18805 #define __put_user_asm_ex(x, addr, itype, rtype, ltype) \
18806 - asm volatile("1: mov"itype" %"rtype"0,%1\n" \
18807 + asm volatile("1: "__copyuser_seg"mov"itype" %"rtype"0,%1\n"\
18808 "2:\n" \
18809 _ASM_EXTABLE_EX(1b, 2b) \
18810 : : ltype(x), "m" (__m(addr)))
18811 @@ -434,11 +496,13 @@ struct __large_struct { unsigned long buf[100]; };
18812 */
18813 #define uaccess_try do { \
18814 current_thread_info()->uaccess_err = 0; \
18815 + pax_open_userland(); \
18816 stac(); \
18817 barrier();
18818
18819 #define uaccess_catch(err) \
18820 clac(); \
18821 + pax_close_userland(); \
18822 (err) |= (current_thread_info()->uaccess_err ? -EFAULT : 0); \
18823 } while (0)
18824
18825 @@ -463,8 +527,12 @@ struct __large_struct { unsigned long buf[100]; };
18826 * On error, the variable @x is set to zero.
18827 */
18828
18829 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18830 +#define __get_user(x, ptr) get_user((x), (ptr))
18831 +#else
18832 #define __get_user(x, ptr) \
18833 __get_user_nocheck((x), (ptr), sizeof(*(ptr)))
18834 +#endif
18835
18836 /**
18837 * __put_user: - Write a simple value into user space, with less checking.
18838 @@ -486,8 +554,12 @@ struct __large_struct { unsigned long buf[100]; };
18839 * Returns zero on success, or -EFAULT on error.
18840 */
18841
18842 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18843 +#define __put_user(x, ptr) put_user((x), (ptr))
18844 +#else
18845 #define __put_user(x, ptr) \
18846 __put_user_nocheck((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr)))
18847 +#endif
18848
18849 #define __get_user_unaligned __get_user
18850 #define __put_user_unaligned __put_user
18851 @@ -505,7 +577,7 @@ struct __large_struct { unsigned long buf[100]; };
18852 #define get_user_ex(x, ptr) do { \
18853 unsigned long __gue_val; \
18854 __get_user_size_ex((__gue_val), (ptr), (sizeof(*(ptr)))); \
18855 - (x) = (__force __typeof__(*(ptr)))__gue_val; \
18856 + (x) = (__typeof__(*(ptr)))__gue_val; \
18857 } while (0)
18858
18859 #define put_user_try uaccess_try
18860 diff --git a/arch/x86/include/asm/uaccess_32.h b/arch/x86/include/asm/uaccess_32.h
18861 index 7f760a9..b596b9a 100644
18862 --- a/arch/x86/include/asm/uaccess_32.h
18863 +++ b/arch/x86/include/asm/uaccess_32.h
18864 @@ -43,6 +43,11 @@ unsigned long __must_check __copy_from_user_ll_nocache_nozero
18865 static __always_inline unsigned long __must_check
18866 __copy_to_user_inatomic(void __user *to, const void *from, unsigned long n)
18867 {
18868 + if ((long)n < 0)
18869 + return n;
18870 +
18871 + check_object_size(from, n, true);
18872 +
18873 if (__builtin_constant_p(n)) {
18874 unsigned long ret;
18875
18876 @@ -82,12 +87,16 @@ static __always_inline unsigned long __must_check
18877 __copy_to_user(void __user *to, const void *from, unsigned long n)
18878 {
18879 might_fault();
18880 +
18881 return __copy_to_user_inatomic(to, from, n);
18882 }
18883
18884 static __always_inline unsigned long
18885 __copy_from_user_inatomic(void *to, const void __user *from, unsigned long n)
18886 {
18887 + if ((long)n < 0)
18888 + return n;
18889 +
18890 /* Avoid zeroing the tail if the copy fails..
18891 * If 'n' is constant and 1, 2, or 4, we do still zero on a failure,
18892 * but as the zeroing behaviour is only significant when n is not
18893 @@ -137,6 +146,12 @@ static __always_inline unsigned long
18894 __copy_from_user(void *to, const void __user *from, unsigned long n)
18895 {
18896 might_fault();
18897 +
18898 + if ((long)n < 0)
18899 + return n;
18900 +
18901 + check_object_size(to, n, false);
18902 +
18903 if (__builtin_constant_p(n)) {
18904 unsigned long ret;
18905
18906 @@ -159,6 +174,10 @@ static __always_inline unsigned long __copy_from_user_nocache(void *to,
18907 const void __user *from, unsigned long n)
18908 {
18909 might_fault();
18910 +
18911 + if ((long)n < 0)
18912 + return n;
18913 +
18914 if (__builtin_constant_p(n)) {
18915 unsigned long ret;
18916
18917 @@ -181,15 +200,19 @@ static __always_inline unsigned long
18918 __copy_from_user_inatomic_nocache(void *to, const void __user *from,
18919 unsigned long n)
18920 {
18921 - return __copy_from_user_ll_nocache_nozero(to, from, n);
18922 + if ((long)n < 0)
18923 + return n;
18924 +
18925 + return __copy_from_user_ll_nocache_nozero(to, from, n);
18926 }
18927
18928 -unsigned long __must_check copy_to_user(void __user *to,
18929 - const void *from, unsigned long n);
18930 -unsigned long __must_check _copy_from_user(void *to,
18931 - const void __user *from,
18932 - unsigned long n);
18933 -
18934 +extern void copy_to_user_overflow(void)
18935 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
18936 + __compiletime_error("copy_to_user() buffer size is not provably correct")
18937 +#else
18938 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
18939 +#endif
18940 +;
18941
18942 extern void copy_from_user_overflow(void)
18943 #ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
18944 @@ -199,17 +222,60 @@ extern void copy_from_user_overflow(void)
18945 #endif
18946 ;
18947
18948 -static inline unsigned long __must_check copy_from_user(void *to,
18949 - const void __user *from,
18950 - unsigned long n)
18951 +/**
18952 + * copy_to_user: - Copy a block of data into user space.
18953 + * @to: Destination address, in user space.
18954 + * @from: Source address, in kernel space.
18955 + * @n: Number of bytes to copy.
18956 + *
18957 + * Context: User context only. This function may sleep.
18958 + *
18959 + * Copy data from kernel space to user space.
18960 + *
18961 + * Returns number of bytes that could not be copied.
18962 + * On success, this will be zero.
18963 + */
18964 +static inline unsigned long __must_check
18965 +copy_to_user(void __user *to, const void *from, unsigned long n)
18966 {
18967 - int sz = __compiletime_object_size(to);
18968 + size_t sz = __compiletime_object_size(from);
18969
18970 - if (likely(sz == -1 || sz >= n))
18971 - n = _copy_from_user(to, from, n);
18972 - else
18973 + if (unlikely(sz != (size_t)-1 && sz < n))
18974 + copy_to_user_overflow();
18975 + else if (access_ok(VERIFY_WRITE, to, n))
18976 + n = __copy_to_user(to, from, n);
18977 + return n;
18978 +}
18979 +
18980 +/**
18981 + * copy_from_user: - Copy a block of data from user space.
18982 + * @to: Destination address, in kernel space.
18983 + * @from: Source address, in user space.
18984 + * @n: Number of bytes to copy.
18985 + *
18986 + * Context: User context only. This function may sleep.
18987 + *
18988 + * Copy data from user space to kernel space.
18989 + *
18990 + * Returns number of bytes that could not be copied.
18991 + * On success, this will be zero.
18992 + *
18993 + * If some data could not be copied, this function will pad the copied
18994 + * data to the requested size using zero bytes.
18995 + */
18996 +static inline unsigned long __must_check
18997 +copy_from_user(void *to, const void __user *from, unsigned long n)
18998 +{
18999 + size_t sz = __compiletime_object_size(to);
19000 +
19001 + check_object_size(to, n, false);
19002 +
19003 + if (unlikely(sz != (size_t)-1 && sz < n))
19004 copy_from_user_overflow();
19005 -
19006 + else if (access_ok(VERIFY_READ, from, n))
19007 + n = __copy_from_user(to, from, n);
19008 + else if ((long)n > 0)
19009 + memset(to, 0, n);
19010 return n;
19011 }
19012
19013 diff --git a/arch/x86/include/asm/uaccess_64.h b/arch/x86/include/asm/uaccess_64.h
19014 index 4f7923d..201b58d 100644
19015 --- a/arch/x86/include/asm/uaccess_64.h
19016 +++ b/arch/x86/include/asm/uaccess_64.h
19017 @@ -10,6 +10,9 @@
19018 #include <asm/alternative.h>
19019 #include <asm/cpufeature.h>
19020 #include <asm/page.h>
19021 +#include <asm/pgtable.h>
19022 +
19023 +#define set_fs(x) (current_thread_info()->addr_limit = (x))
19024
19025 /*
19026 * Copy To/From Userspace
19027 @@ -17,14 +20,14 @@
19028
19029 /* Handles exceptions in both to and from, but doesn't do access_ok */
19030 __must_check unsigned long
19031 -copy_user_enhanced_fast_string(void *to, const void *from, unsigned len);
19032 +copy_user_enhanced_fast_string(void *to, const void *from, unsigned len) __size_overflow(3);
19033 __must_check unsigned long
19034 -copy_user_generic_string(void *to, const void *from, unsigned len);
19035 +copy_user_generic_string(void *to, const void *from, unsigned len) __size_overflow(3);
19036 __must_check unsigned long
19037 -copy_user_generic_unrolled(void *to, const void *from, unsigned len);
19038 +copy_user_generic_unrolled(void *to, const void *from, unsigned len) __size_overflow(3);
19039
19040 -static __always_inline __must_check unsigned long
19041 -copy_user_generic(void *to, const void *from, unsigned len)
19042 +static __always_inline __must_check unsigned long
19043 +copy_user_generic(void *to, const void *from, unsigned long len)
19044 {
19045 unsigned ret;
19046
19047 @@ -45,138 +48,200 @@ copy_user_generic(void *to, const void *from, unsigned len)
19048 return ret;
19049 }
19050
19051 +static __always_inline __must_check unsigned long
19052 +__copy_to_user(void __user *to, const void *from, unsigned long len);
19053 +static __always_inline __must_check unsigned long
19054 +__copy_from_user(void *to, const void __user *from, unsigned long len);
19055 __must_check unsigned long
19056 -_copy_to_user(void __user *to, const void *from, unsigned len);
19057 -__must_check unsigned long
19058 -_copy_from_user(void *to, const void __user *from, unsigned len);
19059 -__must_check unsigned long
19060 -copy_in_user(void __user *to, const void __user *from, unsigned len);
19061 +copy_in_user(void __user *to, const void __user *from, unsigned long len);
19062 +
19063 +extern void copy_to_user_overflow(void)
19064 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
19065 + __compiletime_error("copy_to_user() buffer size is not provably correct")
19066 +#else
19067 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
19068 +#endif
19069 +;
19070 +
19071 +extern void copy_from_user_overflow(void)
19072 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
19073 + __compiletime_error("copy_from_user() buffer size is not provably correct")
19074 +#else
19075 + __compiletime_warning("copy_from_user() buffer size is not provably correct")
19076 +#endif
19077 +;
19078
19079 static inline unsigned long __must_check copy_from_user(void *to,
19080 const void __user *from,
19081 unsigned long n)
19082 {
19083 - int sz = __compiletime_object_size(to);
19084 -
19085 might_fault();
19086 - if (likely(sz == -1 || sz >= n))
19087 - n = _copy_from_user(to, from, n);
19088 -#ifdef CONFIG_DEBUG_VM
19089 - else
19090 - WARN(1, "Buffer overflow detected!\n");
19091 -#endif
19092 +
19093 + check_object_size(to, n, false);
19094 +
19095 + if (access_ok(VERIFY_READ, from, n))
19096 + n = __copy_from_user(to, from, n);
19097 + else if (n < INT_MAX)
19098 + memset(to, 0, n);
19099 return n;
19100 }
19101
19102 static __always_inline __must_check
19103 -int copy_to_user(void __user *dst, const void *src, unsigned size)
19104 +int copy_to_user(void __user *dst, const void *src, unsigned long size)
19105 {
19106 might_fault();
19107
19108 - return _copy_to_user(dst, src, size);
19109 + if (access_ok(VERIFY_WRITE, dst, size))
19110 + size = __copy_to_user(dst, src, size);
19111 + return size;
19112 }
19113
19114 static __always_inline __must_check
19115 -int __copy_from_user(void *dst, const void __user *src, unsigned size)
19116 +unsigned long __copy_from_user(void *dst, const void __user *src, unsigned long size)
19117 {
19118 - int ret = 0;
19119 + size_t sz = __compiletime_object_size(dst);
19120 + unsigned ret = 0;
19121
19122 might_fault();
19123 +
19124 + if (size > INT_MAX)
19125 + return size;
19126 +
19127 + check_object_size(dst, size, false);
19128 +
19129 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19130 + if (!__access_ok(VERIFY_READ, src, size))
19131 + return size;
19132 +#endif
19133 +
19134 + if (unlikely(sz != (size_t)-1 && sz < size)) {
19135 + copy_from_user_overflow();
19136 + return size;
19137 + }
19138 +
19139 if (!__builtin_constant_p(size))
19140 - return copy_user_generic(dst, (__force void *)src, size);
19141 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
19142 switch (size) {
19143 - case 1:__get_user_asm(*(u8 *)dst, (u8 __user *)src,
19144 + case 1:__get_user_asm(*(u8 *)dst, (const u8 __user *)src,
19145 ret, "b", "b", "=q", 1);
19146 return ret;
19147 - case 2:__get_user_asm(*(u16 *)dst, (u16 __user *)src,
19148 + case 2:__get_user_asm(*(u16 *)dst, (const u16 __user *)src,
19149 ret, "w", "w", "=r", 2);
19150 return ret;
19151 - case 4:__get_user_asm(*(u32 *)dst, (u32 __user *)src,
19152 + case 4:__get_user_asm(*(u32 *)dst, (const u32 __user *)src,
19153 ret, "l", "k", "=r", 4);
19154 return ret;
19155 - case 8:__get_user_asm(*(u64 *)dst, (u64 __user *)src,
19156 + case 8:__get_user_asm(*(u64 *)dst, (const u64 __user *)src,
19157 ret, "q", "", "=r", 8);
19158 return ret;
19159 case 10:
19160 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
19161 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
19162 ret, "q", "", "=r", 10);
19163 if (unlikely(ret))
19164 return ret;
19165 __get_user_asm(*(u16 *)(8 + (char *)dst),
19166 - (u16 __user *)(8 + (char __user *)src),
19167 + (const u16 __user *)(8 + (const char __user *)src),
19168 ret, "w", "w", "=r", 2);
19169 return ret;
19170 case 16:
19171 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
19172 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
19173 ret, "q", "", "=r", 16);
19174 if (unlikely(ret))
19175 return ret;
19176 __get_user_asm(*(u64 *)(8 + (char *)dst),
19177 - (u64 __user *)(8 + (char __user *)src),
19178 + (const u64 __user *)(8 + (const char __user *)src),
19179 ret, "q", "", "=r", 8);
19180 return ret;
19181 default:
19182 - return copy_user_generic(dst, (__force void *)src, size);
19183 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
19184 }
19185 }
19186
19187 static __always_inline __must_check
19188 -int __copy_to_user(void __user *dst, const void *src, unsigned size)
19189 +unsigned long __copy_to_user(void __user *dst, const void *src, unsigned long size)
19190 {
19191 - int ret = 0;
19192 + size_t sz = __compiletime_object_size(src);
19193 + unsigned ret = 0;
19194
19195 might_fault();
19196 +
19197 + if (size > INT_MAX)
19198 + return size;
19199 +
19200 + check_object_size(src, size, true);
19201 +
19202 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19203 + if (!__access_ok(VERIFY_WRITE, dst, size))
19204 + return size;
19205 +#endif
19206 +
19207 + if (unlikely(sz != (size_t)-1 && sz < size)) {
19208 + copy_to_user_overflow();
19209 + return size;
19210 + }
19211 +
19212 if (!__builtin_constant_p(size))
19213 - return copy_user_generic((__force void *)dst, src, size);
19214 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
19215 switch (size) {
19216 - case 1:__put_user_asm(*(u8 *)src, (u8 __user *)dst,
19217 + case 1:__put_user_asm(*(const u8 *)src, (u8 __user *)dst,
19218 ret, "b", "b", "iq", 1);
19219 return ret;
19220 - case 2:__put_user_asm(*(u16 *)src, (u16 __user *)dst,
19221 + case 2:__put_user_asm(*(const u16 *)src, (u16 __user *)dst,
19222 ret, "w", "w", "ir", 2);
19223 return ret;
19224 - case 4:__put_user_asm(*(u32 *)src, (u32 __user *)dst,
19225 + case 4:__put_user_asm(*(const u32 *)src, (u32 __user *)dst,
19226 ret, "l", "k", "ir", 4);
19227 return ret;
19228 - case 8:__put_user_asm(*(u64 *)src, (u64 __user *)dst,
19229 + case 8:__put_user_asm(*(const u64 *)src, (u64 __user *)dst,
19230 ret, "q", "", "er", 8);
19231 return ret;
19232 case 10:
19233 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
19234 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
19235 ret, "q", "", "er", 10);
19236 if (unlikely(ret))
19237 return ret;
19238 asm("":::"memory");
19239 - __put_user_asm(4[(u16 *)src], 4 + (u16 __user *)dst,
19240 + __put_user_asm(4[(const u16 *)src], 4 + (u16 __user *)dst,
19241 ret, "w", "w", "ir", 2);
19242 return ret;
19243 case 16:
19244 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
19245 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
19246 ret, "q", "", "er", 16);
19247 if (unlikely(ret))
19248 return ret;
19249 asm("":::"memory");
19250 - __put_user_asm(1[(u64 *)src], 1 + (u64 __user *)dst,
19251 + __put_user_asm(1[(const u64 *)src], 1 + (u64 __user *)dst,
19252 ret, "q", "", "er", 8);
19253 return ret;
19254 default:
19255 - return copy_user_generic((__force void *)dst, src, size);
19256 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
19257 }
19258 }
19259
19260 static __always_inline __must_check
19261 -int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
19262 +unsigned long __copy_in_user(void __user *dst, const void __user *src, unsigned long size)
19263 {
19264 - int ret = 0;
19265 + unsigned ret = 0;
19266
19267 might_fault();
19268 +
19269 + if (size > INT_MAX)
19270 + return size;
19271 +
19272 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19273 + if (!__access_ok(VERIFY_READ, src, size))
19274 + return size;
19275 + if (!__access_ok(VERIFY_WRITE, dst, size))
19276 + return size;
19277 +#endif
19278 +
19279 if (!__builtin_constant_p(size))
19280 - return copy_user_generic((__force void *)dst,
19281 - (__force void *)src, size);
19282 + return copy_user_generic((__force_kernel void *)____m(dst),
19283 + (__force_kernel const void *)____m(src), size);
19284 switch (size) {
19285 case 1: {
19286 u8 tmp;
19287 - __get_user_asm(tmp, (u8 __user *)src,
19288 + __get_user_asm(tmp, (const u8 __user *)src,
19289 ret, "b", "b", "=q", 1);
19290 if (likely(!ret))
19291 __put_user_asm(tmp, (u8 __user *)dst,
19292 @@ -185,7 +250,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
19293 }
19294 case 2: {
19295 u16 tmp;
19296 - __get_user_asm(tmp, (u16 __user *)src,
19297 + __get_user_asm(tmp, (const u16 __user *)src,
19298 ret, "w", "w", "=r", 2);
19299 if (likely(!ret))
19300 __put_user_asm(tmp, (u16 __user *)dst,
19301 @@ -195,7 +260,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
19302
19303 case 4: {
19304 u32 tmp;
19305 - __get_user_asm(tmp, (u32 __user *)src,
19306 + __get_user_asm(tmp, (const u32 __user *)src,
19307 ret, "l", "k", "=r", 4);
19308 if (likely(!ret))
19309 __put_user_asm(tmp, (u32 __user *)dst,
19310 @@ -204,7 +269,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
19311 }
19312 case 8: {
19313 u64 tmp;
19314 - __get_user_asm(tmp, (u64 __user *)src,
19315 + __get_user_asm(tmp, (const u64 __user *)src,
19316 ret, "q", "", "=r", 8);
19317 if (likely(!ret))
19318 __put_user_asm(tmp, (u64 __user *)dst,
19319 @@ -212,41 +277,74 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
19320 return ret;
19321 }
19322 default:
19323 - return copy_user_generic((__force void *)dst,
19324 - (__force void *)src, size);
19325 + return copy_user_generic((__force_kernel void *)____m(dst),
19326 + (__force_kernel const void *)____m(src), size);
19327 }
19328 }
19329
19330 -static __must_check __always_inline int
19331 -__copy_from_user_inatomic(void *dst, const void __user *src, unsigned size)
19332 +static __must_check __always_inline unsigned long
19333 +__copy_from_user_inatomic(void *dst, const void __user *src, unsigned long size)
19334 {
19335 - return copy_user_generic(dst, (__force const void *)src, size);
19336 + if (size > INT_MAX)
19337 + return size;
19338 +
19339 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19340 + if (!__access_ok(VERIFY_READ, src, size))
19341 + return size;
19342 +#endif
19343 +
19344 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
19345 }
19346
19347 -static __must_check __always_inline int
19348 -__copy_to_user_inatomic(void __user *dst, const void *src, unsigned size)
19349 +static __must_check __always_inline unsigned long
19350 +__copy_to_user_inatomic(void __user *dst, const void *src, unsigned long size)
19351 {
19352 - return copy_user_generic((__force void *)dst, src, size);
19353 + if (size > INT_MAX)
19354 + return size;
19355 +
19356 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19357 + if (!__access_ok(VERIFY_WRITE, dst, size))
19358 + return size;
19359 +#endif
19360 +
19361 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
19362 }
19363
19364 -extern long __copy_user_nocache(void *dst, const void __user *src,
19365 - unsigned size, int zerorest);
19366 +extern unsigned long __copy_user_nocache(void *dst, const void __user *src,
19367 + unsigned long size, int zerorest);
19368
19369 -static inline int
19370 -__copy_from_user_nocache(void *dst, const void __user *src, unsigned size)
19371 +static inline unsigned long
19372 +__copy_from_user_nocache(void *dst, const void __user *src, unsigned long size)
19373 {
19374 might_fault();
19375 +
19376 + if (size > INT_MAX)
19377 + return size;
19378 +
19379 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19380 + if (!__access_ok(VERIFY_READ, src, size))
19381 + return size;
19382 +#endif
19383 +
19384 return __copy_user_nocache(dst, src, size, 1);
19385 }
19386
19387 -static inline int
19388 +static inline unsigned long
19389 __copy_from_user_inatomic_nocache(void *dst, const void __user *src,
19390 - unsigned size)
19391 + unsigned long size)
19392 {
19393 + if (size > INT_MAX)
19394 + return size;
19395 +
19396 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19397 + if (!__access_ok(VERIFY_READ, src, size))
19398 + return size;
19399 +#endif
19400 +
19401 return __copy_user_nocache(dst, src, size, 0);
19402 }
19403
19404 unsigned long
19405 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest);
19406 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest) __size_overflow(3);
19407
19408 #endif /* _ASM_X86_UACCESS_64_H */
19409 diff --git a/arch/x86/include/asm/word-at-a-time.h b/arch/x86/include/asm/word-at-a-time.h
19410 index 5b238981..77fdd78 100644
19411 --- a/arch/x86/include/asm/word-at-a-time.h
19412 +++ b/arch/x86/include/asm/word-at-a-time.h
19413 @@ -11,7 +11,7 @@
19414 * and shift, for example.
19415 */
19416 struct word_at_a_time {
19417 - const unsigned long one_bits, high_bits;
19418 + unsigned long one_bits, high_bits;
19419 };
19420
19421 #define WORD_AT_A_TIME_CONSTANTS { REPEAT_BYTE(0x01), REPEAT_BYTE(0x80) }
19422 diff --git a/arch/x86/include/asm/x86_init.h b/arch/x86/include/asm/x86_init.h
19423 index 828a156..650e625 100644
19424 --- a/arch/x86/include/asm/x86_init.h
19425 +++ b/arch/x86/include/asm/x86_init.h
19426 @@ -129,7 +129,7 @@ struct x86_init_ops {
19427 struct x86_init_timers timers;
19428 struct x86_init_iommu iommu;
19429 struct x86_init_pci pci;
19430 -};
19431 +} __no_const;
19432
19433 /**
19434 * struct x86_cpuinit_ops - platform specific cpu hotplug setups
19435 @@ -140,7 +140,7 @@ struct x86_cpuinit_ops {
19436 void (*setup_percpu_clockev)(void);
19437 void (*early_percpu_clock_init)(void);
19438 void (*fixup_cpu_id)(struct cpuinfo_x86 *c, int node);
19439 -};
19440 +} __no_const;
19441
19442 struct timespec;
19443
19444 @@ -168,7 +168,7 @@ struct x86_platform_ops {
19445 void (*save_sched_clock_state)(void);
19446 void (*restore_sched_clock_state)(void);
19447 void (*apic_post_init)(void);
19448 -};
19449 +} __no_const;
19450
19451 struct pci_dev;
19452 struct msi_msg;
19453 @@ -182,7 +182,7 @@ struct x86_msi_ops {
19454 void (*teardown_msi_irqs)(struct pci_dev *dev);
19455 void (*restore_msi_irqs)(struct pci_dev *dev, int irq);
19456 int (*setup_hpet_msi)(unsigned int irq, unsigned int id);
19457 -};
19458 +} __no_const;
19459
19460 struct IO_APIC_route_entry;
19461 struct io_apic_irq_attr;
19462 @@ -203,7 +203,7 @@ struct x86_io_apic_ops {
19463 unsigned int destination, int vector,
19464 struct io_apic_irq_attr *attr);
19465 void (*eoi_ioapic_pin)(int apic, int pin, int vector);
19466 -};
19467 +} __no_const;
19468
19469 extern struct x86_init_ops x86_init;
19470 extern struct x86_cpuinit_ops x86_cpuinit;
19471 diff --git a/arch/x86/include/asm/xen/page.h b/arch/x86/include/asm/xen/page.h
19472 index b913915..4f5a581 100644
19473 --- a/arch/x86/include/asm/xen/page.h
19474 +++ b/arch/x86/include/asm/xen/page.h
19475 @@ -56,7 +56,7 @@ extern int m2p_remove_override(struct page *page,
19476 extern struct page *m2p_find_override(unsigned long mfn);
19477 extern unsigned long m2p_find_override_pfn(unsigned long mfn, unsigned long pfn);
19478
19479 -static inline unsigned long pfn_to_mfn(unsigned long pfn)
19480 +static inline unsigned long __intentional_overflow(-1) pfn_to_mfn(unsigned long pfn)
19481 {
19482 unsigned long mfn;
19483
19484 diff --git a/arch/x86/include/asm/xsave.h b/arch/x86/include/asm/xsave.h
19485 index 0415cda..3b22adc 100644
19486 --- a/arch/x86/include/asm/xsave.h
19487 +++ b/arch/x86/include/asm/xsave.h
19488 @@ -70,8 +70,11 @@ static inline int xsave_user(struct xsave_struct __user *buf)
19489 if (unlikely(err))
19490 return -EFAULT;
19491
19492 + pax_open_userland();
19493 __asm__ __volatile__(ASM_STAC "\n"
19494 - "1: .byte " REX_PREFIX "0x0f,0xae,0x27\n"
19495 + "1:"
19496 + __copyuser_seg
19497 + ".byte " REX_PREFIX "0x0f,0xae,0x27\n"
19498 "2: " ASM_CLAC "\n"
19499 ".section .fixup,\"ax\"\n"
19500 "3: movl $-1,%[err]\n"
19501 @@ -81,18 +84,22 @@ static inline int xsave_user(struct xsave_struct __user *buf)
19502 : [err] "=r" (err)
19503 : "D" (buf), "a" (-1), "d" (-1), "0" (0)
19504 : "memory");
19505 + pax_close_userland();
19506 return err;
19507 }
19508
19509 static inline int xrestore_user(struct xsave_struct __user *buf, u64 mask)
19510 {
19511 int err;
19512 - struct xsave_struct *xstate = ((__force struct xsave_struct *)buf);
19513 + struct xsave_struct *xstate = ((__force_kernel struct xsave_struct *)buf);
19514 u32 lmask = mask;
19515 u32 hmask = mask >> 32;
19516
19517 + pax_open_userland();
19518 __asm__ __volatile__(ASM_STAC "\n"
19519 - "1: .byte " REX_PREFIX "0x0f,0xae,0x2f\n"
19520 + "1:"
19521 + __copyuser_seg
19522 + ".byte " REX_PREFIX "0x0f,0xae,0x2f\n"
19523 "2: " ASM_CLAC "\n"
19524 ".section .fixup,\"ax\"\n"
19525 "3: movl $-1,%[err]\n"
19526 @@ -102,6 +109,7 @@ static inline int xrestore_user(struct xsave_struct __user *buf, u64 mask)
19527 : [err] "=r" (err)
19528 : "D" (xstate), "a" (lmask), "d" (hmask), "0" (0)
19529 : "memory"); /* memory required? */
19530 + pax_close_userland();
19531 return err;
19532 }
19533
19534 diff --git a/arch/x86/include/uapi/asm/e820.h b/arch/x86/include/uapi/asm/e820.h
19535 index bbae024..e1528f9 100644
19536 --- a/arch/x86/include/uapi/asm/e820.h
19537 +++ b/arch/x86/include/uapi/asm/e820.h
19538 @@ -63,7 +63,7 @@ struct e820map {
19539 #define ISA_START_ADDRESS 0xa0000
19540 #define ISA_END_ADDRESS 0x100000
19541
19542 -#define BIOS_BEGIN 0x000a0000
19543 +#define BIOS_BEGIN 0x000c0000
19544 #define BIOS_END 0x00100000
19545
19546 #define BIOS_ROM_BASE 0xffe00000
19547 diff --git a/arch/x86/include/uapi/asm/ptrace-abi.h b/arch/x86/include/uapi/asm/ptrace-abi.h
19548 index 7b0a55a..ad115bf 100644
19549 --- a/arch/x86/include/uapi/asm/ptrace-abi.h
19550 +++ b/arch/x86/include/uapi/asm/ptrace-abi.h
19551 @@ -49,7 +49,6 @@
19552 #define EFLAGS 144
19553 #define RSP 152
19554 #define SS 160
19555 -#define ARGOFFSET R11
19556 #endif /* __ASSEMBLY__ */
19557
19558 /* top of stack page */
19559 diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
19560 index a5408b9..5133813 100644
19561 --- a/arch/x86/kernel/Makefile
19562 +++ b/arch/x86/kernel/Makefile
19563 @@ -24,7 +24,7 @@ obj-y += time.o ioport.o ldt.o dumpstack.o nmi.o
19564 obj-y += setup.o x86_init.o i8259.o irqinit.o jump_label.o
19565 obj-$(CONFIG_IRQ_WORK) += irq_work.o
19566 obj-y += probe_roms.o
19567 -obj-$(CONFIG_X86_32) += i386_ksyms_32.o
19568 +obj-$(CONFIG_X86_32) += sys_i386_32.o i386_ksyms_32.o
19569 obj-$(CONFIG_X86_64) += sys_x86_64.o x8664_ksyms_64.o
19570 obj-y += syscall_$(BITS).o
19571 obj-$(CONFIG_X86_64) += vsyscall_64.o
19572 diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
19573 index 40c7660..f709f4b 100644
19574 --- a/arch/x86/kernel/acpi/boot.c
19575 +++ b/arch/x86/kernel/acpi/boot.c
19576 @@ -1365,7 +1365,7 @@ static int __init dmi_ignore_irq0_timer_override(const struct dmi_system_id *d)
19577 * If your system is blacklisted here, but you find that acpi=force
19578 * works for you, please contact linux-acpi@vger.kernel.org
19579 */
19580 -static struct dmi_system_id __initdata acpi_dmi_table[] = {
19581 +static const struct dmi_system_id __initconst acpi_dmi_table[] = {
19582 /*
19583 * Boxes that need ACPI disabled
19584 */
19585 @@ -1440,7 +1440,7 @@ static struct dmi_system_id __initdata acpi_dmi_table[] = {
19586 };
19587
19588 /* second table for DMI checks that should run after early-quirks */
19589 -static struct dmi_system_id __initdata acpi_dmi_table_late[] = {
19590 +static const struct dmi_system_id __initconst acpi_dmi_table_late[] = {
19591 /*
19592 * HP laptops which use a DSDT reporting as HP/SB400/10000,
19593 * which includes some code which overrides all temperature
19594 diff --git a/arch/x86/kernel/acpi/sleep.c b/arch/x86/kernel/acpi/sleep.c
19595 index 3312010..a65ca7b 100644
19596 --- a/arch/x86/kernel/acpi/sleep.c
19597 +++ b/arch/x86/kernel/acpi/sleep.c
19598 @@ -88,8 +88,12 @@ int x86_acpi_suspend_lowlevel(void)
19599 #else /* CONFIG_64BIT */
19600 #ifdef CONFIG_SMP
19601 stack_start = (unsigned long)temp_stack + sizeof(temp_stack);
19602 +
19603 + pax_open_kernel();
19604 early_gdt_descr.address =
19605 (unsigned long)get_cpu_gdt_table(smp_processor_id());
19606 + pax_close_kernel();
19607 +
19608 initial_gs = per_cpu_offset(smp_processor_id());
19609 #endif
19610 initial_code = (unsigned long)wakeup_long64;
19611 diff --git a/arch/x86/kernel/acpi/wakeup_32.S b/arch/x86/kernel/acpi/wakeup_32.S
19612 index d1daa66..59fecba 100644
19613 --- a/arch/x86/kernel/acpi/wakeup_32.S
19614 +++ b/arch/x86/kernel/acpi/wakeup_32.S
19615 @@ -29,13 +29,11 @@ wakeup_pmode_return:
19616 # and restore the stack ... but you need gdt for this to work
19617 movl saved_context_esp, %esp
19618
19619 - movl %cs:saved_magic, %eax
19620 - cmpl $0x12345678, %eax
19621 + cmpl $0x12345678, saved_magic
19622 jne bogus_magic
19623
19624 # jump to place where we left off
19625 - movl saved_eip, %eax
19626 - jmp *%eax
19627 + jmp *(saved_eip)
19628
19629 bogus_magic:
19630 jmp bogus_magic
19631 diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
19632 index 15e8563..323cbe1 100644
19633 --- a/arch/x86/kernel/alternative.c
19634 +++ b/arch/x86/kernel/alternative.c
19635 @@ -269,6 +269,13 @@ void __init_or_module apply_alternatives(struct alt_instr *start,
19636 */
19637 for (a = start; a < end; a++) {
19638 instr = (u8 *)&a->instr_offset + a->instr_offset;
19639 +
19640 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
19641 + instr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
19642 + if (instr < (u8 *)_text || (u8 *)_einittext <= instr)
19643 + instr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
19644 +#endif
19645 +
19646 replacement = (u8 *)&a->repl_offset + a->repl_offset;
19647 BUG_ON(a->replacementlen > a->instrlen);
19648 BUG_ON(a->instrlen > sizeof(insnbuf));
19649 @@ -300,10 +307,16 @@ static void alternatives_smp_lock(const s32 *start, const s32 *end,
19650 for (poff = start; poff < end; poff++) {
19651 u8 *ptr = (u8 *)poff + *poff;
19652
19653 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
19654 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
19655 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
19656 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
19657 +#endif
19658 +
19659 if (!*poff || ptr < text || ptr >= text_end)
19660 continue;
19661 /* turn DS segment override prefix into lock prefix */
19662 - if (*ptr == 0x3e)
19663 + if (*ktla_ktva(ptr) == 0x3e)
19664 text_poke(ptr, ((unsigned char []){0xf0}), 1);
19665 }
19666 mutex_unlock(&text_mutex);
19667 @@ -318,10 +331,16 @@ static void alternatives_smp_unlock(const s32 *start, const s32 *end,
19668 for (poff = start; poff < end; poff++) {
19669 u8 *ptr = (u8 *)poff + *poff;
19670
19671 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
19672 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
19673 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
19674 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
19675 +#endif
19676 +
19677 if (!*poff || ptr < text || ptr >= text_end)
19678 continue;
19679 /* turn lock prefix into DS segment override prefix */
19680 - if (*ptr == 0xf0)
19681 + if (*ktla_ktva(ptr) == 0xf0)
19682 text_poke(ptr, ((unsigned char []){0x3E}), 1);
19683 }
19684 mutex_unlock(&text_mutex);
19685 @@ -469,7 +488,7 @@ void __init_or_module apply_paravirt(struct paravirt_patch_site *start,
19686
19687 BUG_ON(p->len > MAX_PATCH_LEN);
19688 /* prep the buffer with the original instructions */
19689 - memcpy(insnbuf, p->instr, p->len);
19690 + memcpy(insnbuf, ktla_ktva(p->instr), p->len);
19691 used = pv_init_ops.patch(p->instrtype, p->clobbers, insnbuf,
19692 (unsigned long)p->instr, p->len);
19693
19694 @@ -516,7 +535,7 @@ void __init alternative_instructions(void)
19695 if (!uniproc_patched || num_possible_cpus() == 1)
19696 free_init_pages("SMP alternatives",
19697 (unsigned long)__smp_locks,
19698 - (unsigned long)__smp_locks_end);
19699 + PAGE_ALIGN((unsigned long)__smp_locks_end));
19700 #endif
19701
19702 apply_paravirt(__parainstructions, __parainstructions_end);
19703 @@ -536,13 +555,17 @@ void __init alternative_instructions(void)
19704 * instructions. And on the local CPU you need to be protected again NMI or MCE
19705 * handlers seeing an inconsistent instruction while you patch.
19706 */
19707 -void *__init_or_module text_poke_early(void *addr, const void *opcode,
19708 +void *__kprobes text_poke_early(void *addr, const void *opcode,
19709 size_t len)
19710 {
19711 unsigned long flags;
19712 local_irq_save(flags);
19713 - memcpy(addr, opcode, len);
19714 +
19715 + pax_open_kernel();
19716 + memcpy(ktla_ktva(addr), opcode, len);
19717 sync_core();
19718 + pax_close_kernel();
19719 +
19720 local_irq_restore(flags);
19721 /* Could also do a CLFLUSH here to speed up CPU recovery; but
19722 that causes hangs on some VIA CPUs. */
19723 @@ -564,36 +587,22 @@ void *__init_or_module text_poke_early(void *addr, const void *opcode,
19724 */
19725 void *__kprobes text_poke(void *addr, const void *opcode, size_t len)
19726 {
19727 - unsigned long flags;
19728 - char *vaddr;
19729 + unsigned char *vaddr = ktla_ktva(addr);
19730 struct page *pages[2];
19731 - int i;
19732 + size_t i;
19733
19734 if (!core_kernel_text((unsigned long)addr)) {
19735 - pages[0] = vmalloc_to_page(addr);
19736 - pages[1] = vmalloc_to_page(addr + PAGE_SIZE);
19737 + pages[0] = vmalloc_to_page(vaddr);
19738 + pages[1] = vmalloc_to_page(vaddr + PAGE_SIZE);
19739 } else {
19740 - pages[0] = virt_to_page(addr);
19741 + pages[0] = virt_to_page(vaddr);
19742 WARN_ON(!PageReserved(pages[0]));
19743 - pages[1] = virt_to_page(addr + PAGE_SIZE);
19744 + pages[1] = virt_to_page(vaddr + PAGE_SIZE);
19745 }
19746 BUG_ON(!pages[0]);
19747 - local_irq_save(flags);
19748 - set_fixmap(FIX_TEXT_POKE0, page_to_phys(pages[0]));
19749 - if (pages[1])
19750 - set_fixmap(FIX_TEXT_POKE1, page_to_phys(pages[1]));
19751 - vaddr = (char *)fix_to_virt(FIX_TEXT_POKE0);
19752 - memcpy(&vaddr[(unsigned long)addr & ~PAGE_MASK], opcode, len);
19753 - clear_fixmap(FIX_TEXT_POKE0);
19754 - if (pages[1])
19755 - clear_fixmap(FIX_TEXT_POKE1);
19756 - local_flush_tlb();
19757 - sync_core();
19758 - /* Could also do a CLFLUSH here to speed up CPU recovery; but
19759 - that causes hangs on some VIA CPUs. */
19760 + text_poke_early(addr, opcode, len);
19761 for (i = 0; i < len; i++)
19762 - BUG_ON(((char *)addr)[i] != ((char *)opcode)[i]);
19763 - local_irq_restore(flags);
19764 + BUG_ON((vaddr)[i] != ((const unsigned char *)opcode)[i]);
19765 return addr;
19766 }
19767
19768 @@ -613,7 +622,7 @@ int poke_int3_handler(struct pt_regs *regs)
19769 if (likely(!bp_patching_in_progress))
19770 return 0;
19771
19772 - if (user_mode_vm(regs) || regs->ip != (unsigned long)bp_int3_addr)
19773 + if (user_mode(regs) || regs->ip != (unsigned long)bp_int3_addr)
19774 return 0;
19775
19776 /* set up the specified breakpoint handler */
19777 @@ -647,7 +656,7 @@ int poke_int3_handler(struct pt_regs *regs)
19778 */
19779 void *text_poke_bp(void *addr, const void *opcode, size_t len, void *handler)
19780 {
19781 - unsigned char int3 = 0xcc;
19782 + const unsigned char int3 = 0xcc;
19783
19784 bp_int3_handler = handler;
19785 bp_int3_addr = (u8 *)addr + sizeof(int3);
19786 diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
19787 index a7eb82d..f6e52d4 100644
19788 --- a/arch/x86/kernel/apic/apic.c
19789 +++ b/arch/x86/kernel/apic/apic.c
19790 @@ -190,7 +190,7 @@ int first_system_vector = 0xfe;
19791 /*
19792 * Debug level, exported for io_apic.c
19793 */
19794 -unsigned int apic_verbosity;
19795 +int apic_verbosity;
19796
19797 int pic_mode;
19798
19799 @@ -1985,7 +1985,7 @@ static inline void __smp_error_interrupt(struct pt_regs *regs)
19800 apic_write(APIC_ESR, 0);
19801 v1 = apic_read(APIC_ESR);
19802 ack_APIC_irq();
19803 - atomic_inc(&irq_err_count);
19804 + atomic_inc_unchecked(&irq_err_count);
19805
19806 apic_printk(APIC_DEBUG, KERN_DEBUG "APIC error on CPU%d: %02x(%02x)",
19807 smp_processor_id(), v0 , v1);
19808 diff --git a/arch/x86/kernel/apic/apic_flat_64.c b/arch/x86/kernel/apic/apic_flat_64.c
19809 index 00c77cf..2dc6a2d 100644
19810 --- a/arch/x86/kernel/apic/apic_flat_64.c
19811 +++ b/arch/x86/kernel/apic/apic_flat_64.c
19812 @@ -157,7 +157,7 @@ static int flat_probe(void)
19813 return 1;
19814 }
19815
19816 -static struct apic apic_flat = {
19817 +static struct apic apic_flat __read_only = {
19818 .name = "flat",
19819 .probe = flat_probe,
19820 .acpi_madt_oem_check = flat_acpi_madt_oem_check,
19821 @@ -271,7 +271,7 @@ static int physflat_probe(void)
19822 return 0;
19823 }
19824
19825 -static struct apic apic_physflat = {
19826 +static struct apic apic_physflat __read_only = {
19827
19828 .name = "physical flat",
19829 .probe = physflat_probe,
19830 diff --git a/arch/x86/kernel/apic/apic_noop.c b/arch/x86/kernel/apic/apic_noop.c
19831 index e145f28..2752888 100644
19832 --- a/arch/x86/kernel/apic/apic_noop.c
19833 +++ b/arch/x86/kernel/apic/apic_noop.c
19834 @@ -119,7 +119,7 @@ static void noop_apic_write(u32 reg, u32 v)
19835 WARN_ON_ONCE(cpu_has_apic && !disable_apic);
19836 }
19837
19838 -struct apic apic_noop = {
19839 +struct apic apic_noop __read_only = {
19840 .name = "noop",
19841 .probe = noop_probe,
19842 .acpi_madt_oem_check = NULL,
19843 diff --git a/arch/x86/kernel/apic/bigsmp_32.c b/arch/x86/kernel/apic/bigsmp_32.c
19844 index d50e364..543bee3 100644
19845 --- a/arch/x86/kernel/apic/bigsmp_32.c
19846 +++ b/arch/x86/kernel/apic/bigsmp_32.c
19847 @@ -152,7 +152,7 @@ static int probe_bigsmp(void)
19848 return dmi_bigsmp;
19849 }
19850
19851 -static struct apic apic_bigsmp = {
19852 +static struct apic apic_bigsmp __read_only = {
19853
19854 .name = "bigsmp",
19855 .probe = probe_bigsmp,
19856 diff --git a/arch/x86/kernel/apic/es7000_32.c b/arch/x86/kernel/apic/es7000_32.c
19857 index c552247..587a316 100644
19858 --- a/arch/x86/kernel/apic/es7000_32.c
19859 +++ b/arch/x86/kernel/apic/es7000_32.c
19860 @@ -608,8 +608,7 @@ static int es7000_mps_oem_check_cluster(struct mpc_table *mpc, char *oem,
19861 return ret && es7000_apic_is_cluster();
19862 }
19863
19864 -/* We've been warned by a false positive warning.Use __refdata to keep calm. */
19865 -static struct apic __refdata apic_es7000_cluster = {
19866 +static struct apic apic_es7000_cluster __read_only = {
19867
19868 .name = "es7000",
19869 .probe = probe_es7000,
19870 @@ -675,7 +674,7 @@ static struct apic __refdata apic_es7000_cluster = {
19871 .x86_32_early_logical_apicid = es7000_early_logical_apicid,
19872 };
19873
19874 -static struct apic __refdata apic_es7000 = {
19875 +static struct apic apic_es7000 __read_only = {
19876
19877 .name = "es7000",
19878 .probe = probe_es7000,
19879 diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
19880 index e63a5bd..c0babf8 100644
19881 --- a/arch/x86/kernel/apic/io_apic.c
19882 +++ b/arch/x86/kernel/apic/io_apic.c
19883 @@ -1060,7 +1060,7 @@ int IO_APIC_get_PCI_irq_vector(int bus, int slot, int pin,
19884 }
19885 EXPORT_SYMBOL(IO_APIC_get_PCI_irq_vector);
19886
19887 -void lock_vector_lock(void)
19888 +void lock_vector_lock(void) __acquires(vector_lock)
19889 {
19890 /* Used to the online set of cpus does not change
19891 * during assign_irq_vector.
19892 @@ -1068,7 +1068,7 @@ void lock_vector_lock(void)
19893 raw_spin_lock(&vector_lock);
19894 }
19895
19896 -void unlock_vector_lock(void)
19897 +void unlock_vector_lock(void) __releases(vector_lock)
19898 {
19899 raw_spin_unlock(&vector_lock);
19900 }
19901 @@ -2367,7 +2367,7 @@ static void ack_apic_edge(struct irq_data *data)
19902 ack_APIC_irq();
19903 }
19904
19905 -atomic_t irq_mis_count;
19906 +atomic_unchecked_t irq_mis_count;
19907
19908 #ifdef CONFIG_GENERIC_PENDING_IRQ
19909 static bool io_apic_level_ack_pending(struct irq_cfg *cfg)
19910 @@ -2508,7 +2508,7 @@ static void ack_apic_level(struct irq_data *data)
19911 * at the cpu.
19912 */
19913 if (!(v & (1 << (i & 0x1f)))) {
19914 - atomic_inc(&irq_mis_count);
19915 + atomic_inc_unchecked(&irq_mis_count);
19916
19917 eoi_ioapic_irq(irq, cfg);
19918 }
19919 diff --git a/arch/x86/kernel/apic/numaq_32.c b/arch/x86/kernel/apic/numaq_32.c
19920 index 1e42e8f..daacf44 100644
19921 --- a/arch/x86/kernel/apic/numaq_32.c
19922 +++ b/arch/x86/kernel/apic/numaq_32.c
19923 @@ -455,8 +455,7 @@ static void numaq_setup_portio_remap(void)
19924 (u_long) xquad_portio, (u_long) num_quads*XQUAD_PORTIO_QUAD);
19925 }
19926
19927 -/* Use __refdata to keep false positive warning calm. */
19928 -static struct apic __refdata apic_numaq = {
19929 +static struct apic apic_numaq __read_only = {
19930
19931 .name = "NUMAQ",
19932 .probe = probe_numaq,
19933 diff --git a/arch/x86/kernel/apic/probe_32.c b/arch/x86/kernel/apic/probe_32.c
19934 index eb35ef9..f184a21 100644
19935 --- a/arch/x86/kernel/apic/probe_32.c
19936 +++ b/arch/x86/kernel/apic/probe_32.c
19937 @@ -72,7 +72,7 @@ static int probe_default(void)
19938 return 1;
19939 }
19940
19941 -static struct apic apic_default = {
19942 +static struct apic apic_default __read_only = {
19943
19944 .name = "default",
19945 .probe = probe_default,
19946 diff --git a/arch/x86/kernel/apic/summit_32.c b/arch/x86/kernel/apic/summit_32.c
19947 index 77c95c0..434f8a4 100644
19948 --- a/arch/x86/kernel/apic/summit_32.c
19949 +++ b/arch/x86/kernel/apic/summit_32.c
19950 @@ -486,7 +486,7 @@ void setup_summit(void)
19951 }
19952 #endif
19953
19954 -static struct apic apic_summit = {
19955 +static struct apic apic_summit __read_only = {
19956
19957 .name = "summit",
19958 .probe = probe_summit,
19959 diff --git a/arch/x86/kernel/apic/x2apic_cluster.c b/arch/x86/kernel/apic/x2apic_cluster.c
19960 index 140e29d..d88bc95 100644
19961 --- a/arch/x86/kernel/apic/x2apic_cluster.c
19962 +++ b/arch/x86/kernel/apic/x2apic_cluster.c
19963 @@ -183,7 +183,7 @@ update_clusterinfo(struct notifier_block *nfb, unsigned long action, void *hcpu)
19964 return notifier_from_errno(err);
19965 }
19966
19967 -static struct notifier_block __refdata x2apic_cpu_notifier = {
19968 +static struct notifier_block x2apic_cpu_notifier = {
19969 .notifier_call = update_clusterinfo,
19970 };
19971
19972 @@ -235,7 +235,7 @@ static void cluster_vector_allocation_domain(int cpu, struct cpumask *retmask,
19973 cpumask_and(retmask, mask, per_cpu(cpus_in_cluster, cpu));
19974 }
19975
19976 -static struct apic apic_x2apic_cluster = {
19977 +static struct apic apic_x2apic_cluster __read_only = {
19978
19979 .name = "cluster x2apic",
19980 .probe = x2apic_cluster_probe,
19981 diff --git a/arch/x86/kernel/apic/x2apic_phys.c b/arch/x86/kernel/apic/x2apic_phys.c
19982 index 562a76d..a003c0f 100644
19983 --- a/arch/x86/kernel/apic/x2apic_phys.c
19984 +++ b/arch/x86/kernel/apic/x2apic_phys.c
19985 @@ -89,7 +89,7 @@ static int x2apic_phys_probe(void)
19986 return apic == &apic_x2apic_phys;
19987 }
19988
19989 -static struct apic apic_x2apic_phys = {
19990 +static struct apic apic_x2apic_phys __read_only = {
19991
19992 .name = "physical x2apic",
19993 .probe = x2apic_phys_probe,
19994 diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c
19995 index a419814..1dd34a0 100644
19996 --- a/arch/x86/kernel/apic/x2apic_uv_x.c
19997 +++ b/arch/x86/kernel/apic/x2apic_uv_x.c
19998 @@ -357,7 +357,7 @@ static int uv_probe(void)
19999 return apic == &apic_x2apic_uv_x;
20000 }
20001
20002 -static struct apic __refdata apic_x2apic_uv_x = {
20003 +static struct apic apic_x2apic_uv_x __read_only = {
20004
20005 .name = "UV large system",
20006 .probe = uv_probe,
20007 diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c
20008 index 3ab0343..814c4787 100644
20009 --- a/arch/x86/kernel/apm_32.c
20010 +++ b/arch/x86/kernel/apm_32.c
20011 @@ -433,7 +433,7 @@ static DEFINE_MUTEX(apm_mutex);
20012 * This is for buggy BIOS's that refer to (real mode) segment 0x40
20013 * even though they are called in protected mode.
20014 */
20015 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
20016 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
20017 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
20018
20019 static const char driver_version[] = "1.16ac"; /* no spaces */
20020 @@ -611,7 +611,10 @@ static long __apm_bios_call(void *_call)
20021 BUG_ON(cpu != 0);
20022 gdt = get_cpu_gdt_table(cpu);
20023 save_desc_40 = gdt[0x40 / 8];
20024 +
20025 + pax_open_kernel();
20026 gdt[0x40 / 8] = bad_bios_desc;
20027 + pax_close_kernel();
20028
20029 apm_irq_save(flags);
20030 APM_DO_SAVE_SEGS;
20031 @@ -620,7 +623,11 @@ static long __apm_bios_call(void *_call)
20032 &call->esi);
20033 APM_DO_RESTORE_SEGS;
20034 apm_irq_restore(flags);
20035 +
20036 + pax_open_kernel();
20037 gdt[0x40 / 8] = save_desc_40;
20038 + pax_close_kernel();
20039 +
20040 put_cpu();
20041
20042 return call->eax & 0xff;
20043 @@ -687,7 +694,10 @@ static long __apm_bios_call_simple(void *_call)
20044 BUG_ON(cpu != 0);
20045 gdt = get_cpu_gdt_table(cpu);
20046 save_desc_40 = gdt[0x40 / 8];
20047 +
20048 + pax_open_kernel();
20049 gdt[0x40 / 8] = bad_bios_desc;
20050 + pax_close_kernel();
20051
20052 apm_irq_save(flags);
20053 APM_DO_SAVE_SEGS;
20054 @@ -695,7 +705,11 @@ static long __apm_bios_call_simple(void *_call)
20055 &call->eax);
20056 APM_DO_RESTORE_SEGS;
20057 apm_irq_restore(flags);
20058 +
20059 + pax_open_kernel();
20060 gdt[0x40 / 8] = save_desc_40;
20061 + pax_close_kernel();
20062 +
20063 put_cpu();
20064 return error;
20065 }
20066 @@ -2362,12 +2376,15 @@ static int __init apm_init(void)
20067 * code to that CPU.
20068 */
20069 gdt = get_cpu_gdt_table(0);
20070 +
20071 + pax_open_kernel();
20072 set_desc_base(&gdt[APM_CS >> 3],
20073 (unsigned long)__va((unsigned long)apm_info.bios.cseg << 4));
20074 set_desc_base(&gdt[APM_CS_16 >> 3],
20075 (unsigned long)__va((unsigned long)apm_info.bios.cseg_16 << 4));
20076 set_desc_base(&gdt[APM_DS >> 3],
20077 (unsigned long)__va((unsigned long)apm_info.bios.dseg << 4));
20078 + pax_close_kernel();
20079
20080 proc_create("apm", 0, NULL, &apm_file_ops);
20081
20082 diff --git a/arch/x86/kernel/asm-offsets.c b/arch/x86/kernel/asm-offsets.c
20083 index 2861082..6d4718e 100644
20084 --- a/arch/x86/kernel/asm-offsets.c
20085 +++ b/arch/x86/kernel/asm-offsets.c
20086 @@ -33,6 +33,8 @@ void common(void) {
20087 OFFSET(TI_status, thread_info, status);
20088 OFFSET(TI_addr_limit, thread_info, addr_limit);
20089 OFFSET(TI_preempt_count, thread_info, preempt_count);
20090 + OFFSET(TI_lowest_stack, thread_info, lowest_stack);
20091 + DEFINE(TI_task_thread_sp0, offsetof(struct task_struct, thread.sp0) - offsetof(struct task_struct, tinfo));
20092
20093 BLANK();
20094 OFFSET(crypto_tfm_ctx_offset, crypto_tfm, __crt_ctx);
20095 @@ -53,8 +55,26 @@ void common(void) {
20096 OFFSET(PV_CPU_irq_enable_sysexit, pv_cpu_ops, irq_enable_sysexit);
20097 OFFSET(PV_CPU_read_cr0, pv_cpu_ops, read_cr0);
20098 OFFSET(PV_MMU_read_cr2, pv_mmu_ops, read_cr2);
20099 +
20100 +#ifdef CONFIG_PAX_KERNEXEC
20101 + OFFSET(PV_CPU_write_cr0, pv_cpu_ops, write_cr0);
20102 #endif
20103
20104 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20105 + OFFSET(PV_MMU_read_cr3, pv_mmu_ops, read_cr3);
20106 + OFFSET(PV_MMU_write_cr3, pv_mmu_ops, write_cr3);
20107 +#ifdef CONFIG_X86_64
20108 + OFFSET(PV_MMU_set_pgd_batched, pv_mmu_ops, set_pgd_batched);
20109 +#endif
20110 +#endif
20111 +
20112 +#endif
20113 +
20114 + BLANK();
20115 + DEFINE(PAGE_SIZE_asm, PAGE_SIZE);
20116 + DEFINE(PAGE_SHIFT_asm, PAGE_SHIFT);
20117 + DEFINE(THREAD_SIZE_asm, THREAD_SIZE);
20118 +
20119 #ifdef CONFIG_XEN
20120 BLANK();
20121 OFFSET(XEN_vcpu_info_mask, vcpu_info, evtchn_upcall_mask);
20122 diff --git a/arch/x86/kernel/asm-offsets_64.c b/arch/x86/kernel/asm-offsets_64.c
20123 index e7c798b..2b2019b 100644
20124 --- a/arch/x86/kernel/asm-offsets_64.c
20125 +++ b/arch/x86/kernel/asm-offsets_64.c
20126 @@ -77,6 +77,7 @@ int main(void)
20127 BLANK();
20128 #undef ENTRY
20129
20130 + DEFINE(TSS_size, sizeof(struct tss_struct));
20131 OFFSET(TSS_ist, tss_struct, x86_tss.ist);
20132 BLANK();
20133
20134 diff --git a/arch/x86/kernel/cpu/Makefile b/arch/x86/kernel/cpu/Makefile
20135 index 47b56a7..efc2bc6 100644
20136 --- a/arch/x86/kernel/cpu/Makefile
20137 +++ b/arch/x86/kernel/cpu/Makefile
20138 @@ -8,10 +8,6 @@ CFLAGS_REMOVE_common.o = -pg
20139 CFLAGS_REMOVE_perf_event.o = -pg
20140 endif
20141
20142 -# Make sure load_percpu_segment has no stackprotector
20143 -nostackp := $(call cc-option, -fno-stack-protector)
20144 -CFLAGS_common.o := $(nostackp)
20145 -
20146 obj-y := intel_cacheinfo.o scattered.o topology.o
20147 obj-y += proc.o capflags.o powerflags.o common.o
20148 obj-y += rdrand.o
20149 diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
20150 index 903a264..fc955f3 100644
20151 --- a/arch/x86/kernel/cpu/amd.c
20152 +++ b/arch/x86/kernel/cpu/amd.c
20153 @@ -743,7 +743,7 @@ static void init_amd(struct cpuinfo_x86 *c)
20154 static unsigned int amd_size_cache(struct cpuinfo_x86 *c, unsigned int size)
20155 {
20156 /* AMD errata T13 (order #21922) */
20157 - if ((c->x86 == 6)) {
20158 + if (c->x86 == 6) {
20159 /* Duron Rev A0 */
20160 if (c->x86_model == 3 && c->x86_mask == 0)
20161 size = 64;
20162 diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
20163 index 2793d1f..b4f313a 100644
20164 --- a/arch/x86/kernel/cpu/common.c
20165 +++ b/arch/x86/kernel/cpu/common.c
20166 @@ -88,60 +88,6 @@ static const struct cpu_dev default_cpu = {
20167
20168 static const struct cpu_dev *this_cpu = &default_cpu;
20169
20170 -DEFINE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page) = { .gdt = {
20171 -#ifdef CONFIG_X86_64
20172 - /*
20173 - * We need valid kernel segments for data and code in long mode too
20174 - * IRET will check the segment types kkeil 2000/10/28
20175 - * Also sysret mandates a special GDT layout
20176 - *
20177 - * TLS descriptors are currently at a different place compared to i386.
20178 - * Hopefully nobody expects them at a fixed place (Wine?)
20179 - */
20180 - [GDT_ENTRY_KERNEL32_CS] = GDT_ENTRY_INIT(0xc09b, 0, 0xfffff),
20181 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xa09b, 0, 0xfffff),
20182 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc093, 0, 0xfffff),
20183 - [GDT_ENTRY_DEFAULT_USER32_CS] = GDT_ENTRY_INIT(0xc0fb, 0, 0xfffff),
20184 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f3, 0, 0xfffff),
20185 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xa0fb, 0, 0xfffff),
20186 -#else
20187 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xc09a, 0, 0xfffff),
20188 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
20189 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xc0fa, 0, 0xfffff),
20190 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f2, 0, 0xfffff),
20191 - /*
20192 - * Segments used for calling PnP BIOS have byte granularity.
20193 - * They code segments and data segments have fixed 64k limits,
20194 - * the transfer segment sizes are set at run time.
20195 - */
20196 - /* 32-bit code */
20197 - [GDT_ENTRY_PNPBIOS_CS32] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
20198 - /* 16-bit code */
20199 - [GDT_ENTRY_PNPBIOS_CS16] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
20200 - /* 16-bit data */
20201 - [GDT_ENTRY_PNPBIOS_DS] = GDT_ENTRY_INIT(0x0092, 0, 0xffff),
20202 - /* 16-bit data */
20203 - [GDT_ENTRY_PNPBIOS_TS1] = GDT_ENTRY_INIT(0x0092, 0, 0),
20204 - /* 16-bit data */
20205 - [GDT_ENTRY_PNPBIOS_TS2] = GDT_ENTRY_INIT(0x0092, 0, 0),
20206 - /*
20207 - * The APM segments have byte granularity and their bases
20208 - * are set at run time. All have 64k limits.
20209 - */
20210 - /* 32-bit code */
20211 - [GDT_ENTRY_APMBIOS_BASE] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
20212 - /* 16-bit code */
20213 - [GDT_ENTRY_APMBIOS_BASE+1] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
20214 - /* data */
20215 - [GDT_ENTRY_APMBIOS_BASE+2] = GDT_ENTRY_INIT(0x4092, 0, 0xffff),
20216 -
20217 - [GDT_ENTRY_ESPFIX_SS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
20218 - [GDT_ENTRY_PERCPU] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
20219 - GDT_STACK_CANARY_INIT
20220 -#endif
20221 -} };
20222 -EXPORT_PER_CPU_SYMBOL_GPL(gdt_page);
20223 -
20224 static int __init x86_xsave_setup(char *s)
20225 {
20226 setup_clear_cpu_cap(X86_FEATURE_XSAVE);
20227 @@ -288,6 +234,59 @@ static __always_inline void setup_smap(struct cpuinfo_x86 *c)
20228 set_in_cr4(X86_CR4_SMAP);
20229 }
20230
20231 +#ifdef CONFIG_X86_64
20232 +static __init int setup_disable_pcid(char *arg)
20233 +{
20234 + setup_clear_cpu_cap(X86_FEATURE_PCID);
20235 + setup_clear_cpu_cap(X86_FEATURE_INVPCID);
20236 +
20237 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20238 + if (clone_pgd_mask != ~(pgdval_t)0UL)
20239 + pax_user_shadow_base = 1UL << TASK_SIZE_MAX_SHIFT;
20240 +#endif
20241 +
20242 + return 1;
20243 +}
20244 +__setup("nopcid", setup_disable_pcid);
20245 +
20246 +static void setup_pcid(struct cpuinfo_x86 *c)
20247 +{
20248 + if (!cpu_has(c, X86_FEATURE_PCID)) {
20249 + clear_cpu_cap(c, X86_FEATURE_INVPCID);
20250 +
20251 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20252 + if (clone_pgd_mask != ~(pgdval_t)0UL) {
20253 + pax_open_kernel();
20254 + pax_user_shadow_base = 1UL << TASK_SIZE_MAX_SHIFT;
20255 + pax_close_kernel();
20256 + printk("PAX: slow and weak UDEREF enabled\n");
20257 + } else
20258 + printk("PAX: UDEREF disabled\n");
20259 +#endif
20260 +
20261 + return;
20262 + }
20263 +
20264 + printk("PAX: PCID detected\n");
20265 + set_in_cr4(X86_CR4_PCIDE);
20266 +
20267 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20268 + pax_open_kernel();
20269 + clone_pgd_mask = ~(pgdval_t)0UL;
20270 + pax_close_kernel();
20271 + if (pax_user_shadow_base)
20272 + printk("PAX: weak UDEREF enabled\n");
20273 + else {
20274 + set_cpu_cap(c, X86_FEATURE_STRONGUDEREF);
20275 + printk("PAX: strong UDEREF enabled\n");
20276 + }
20277 +#endif
20278 +
20279 + if (cpu_has(c, X86_FEATURE_INVPCID))
20280 + printk("PAX: INVPCID detected\n");
20281 +}
20282 +#endif
20283 +
20284 /*
20285 * Some CPU features depend on higher CPUID levels, which may not always
20286 * be available due to CPUID level capping or broken virtualization
20287 @@ -386,7 +385,7 @@ void switch_to_new_gdt(int cpu)
20288 {
20289 struct desc_ptr gdt_descr;
20290
20291 - gdt_descr.address = (long)get_cpu_gdt_table(cpu);
20292 + gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
20293 gdt_descr.size = GDT_SIZE - 1;
20294 load_gdt(&gdt_descr);
20295 /* Reload the per-cpu base */
20296 @@ -875,6 +874,10 @@ static void identify_cpu(struct cpuinfo_x86 *c)
20297 setup_smep(c);
20298 setup_smap(c);
20299
20300 +#ifdef CONFIG_X86_64
20301 + setup_pcid(c);
20302 +#endif
20303 +
20304 /*
20305 * The vendor-specific functions might have changed features.
20306 * Now we do "generic changes."
20307 @@ -883,6 +886,10 @@ static void identify_cpu(struct cpuinfo_x86 *c)
20308 /* Filter out anything that depends on CPUID levels we don't have */
20309 filter_cpuid_features(c, true);
20310
20311 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
20312 + setup_clear_cpu_cap(X86_FEATURE_SEP);
20313 +#endif
20314 +
20315 /* If the model name is still unset, do table lookup. */
20316 if (!c->x86_model_id[0]) {
20317 const char *p;
20318 @@ -1070,10 +1077,12 @@ static __init int setup_disablecpuid(char *arg)
20319 }
20320 __setup("clearcpuid=", setup_disablecpuid);
20321
20322 +DEFINE_PER_CPU(struct thread_info *, current_tinfo) = &init_task.tinfo;
20323 +EXPORT_PER_CPU_SYMBOL(current_tinfo);
20324 +
20325 #ifdef CONFIG_X86_64
20326 -struct desc_ptr idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) idt_table };
20327 -struct desc_ptr debug_idt_descr = { NR_VECTORS * 16 - 1,
20328 - (unsigned long) debug_idt_table };
20329 +struct desc_ptr idt_descr __read_only = { NR_VECTORS * 16 - 1, (unsigned long) idt_table };
20330 +const struct desc_ptr debug_idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) debug_idt_table };
20331
20332 DEFINE_PER_CPU_FIRST(union irq_stack_union,
20333 irq_stack_union) __aligned(PAGE_SIZE) __visible;
20334 @@ -1087,7 +1096,7 @@ DEFINE_PER_CPU(struct task_struct *, current_task) ____cacheline_aligned =
20335 EXPORT_PER_CPU_SYMBOL(current_task);
20336
20337 DEFINE_PER_CPU(unsigned long, kernel_stack) =
20338 - (unsigned long)&init_thread_union - KERNEL_STACK_OFFSET + THREAD_SIZE;
20339 + (unsigned long)&init_thread_union - 16 + THREAD_SIZE;
20340 EXPORT_PER_CPU_SYMBOL(kernel_stack);
20341
20342 DEFINE_PER_CPU(char *, irq_stack_ptr) =
20343 @@ -1232,7 +1241,7 @@ void cpu_init(void)
20344 load_ucode_ap();
20345
20346 cpu = stack_smp_processor_id();
20347 - t = &per_cpu(init_tss, cpu);
20348 + t = init_tss + cpu;
20349 oist = &per_cpu(orig_ist, cpu);
20350
20351 #ifdef CONFIG_NUMA
20352 @@ -1267,7 +1276,6 @@ void cpu_init(void)
20353 wrmsrl(MSR_KERNEL_GS_BASE, 0);
20354 barrier();
20355
20356 - x86_configure_nx();
20357 enable_x2apic();
20358
20359 /*
20360 @@ -1319,7 +1327,7 @@ void cpu_init(void)
20361 {
20362 int cpu = smp_processor_id();
20363 struct task_struct *curr = current;
20364 - struct tss_struct *t = &per_cpu(init_tss, cpu);
20365 + struct tss_struct *t = init_tss + cpu;
20366 struct thread_struct *thread = &curr->thread;
20367
20368 show_ucode_info_early();
20369 diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c
20370 index 1414c90..1159406 100644
20371 --- a/arch/x86/kernel/cpu/intel_cacheinfo.c
20372 +++ b/arch/x86/kernel/cpu/intel_cacheinfo.c
20373 @@ -1014,6 +1014,22 @@ static struct attribute *default_attrs[] = {
20374 };
20375
20376 #ifdef CONFIG_AMD_NB
20377 +static struct attribute *default_attrs_amd_nb[] = {
20378 + &type.attr,
20379 + &level.attr,
20380 + &coherency_line_size.attr,
20381 + &physical_line_partition.attr,
20382 + &ways_of_associativity.attr,
20383 + &number_of_sets.attr,
20384 + &size.attr,
20385 + &shared_cpu_map.attr,
20386 + &shared_cpu_list.attr,
20387 + NULL,
20388 + NULL,
20389 + NULL,
20390 + NULL
20391 +};
20392 +
20393 static struct attribute **amd_l3_attrs(void)
20394 {
20395 static struct attribute **attrs;
20396 @@ -1024,18 +1040,7 @@ static struct attribute **amd_l3_attrs(void)
20397
20398 n = ARRAY_SIZE(default_attrs);
20399
20400 - if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE))
20401 - n += 2;
20402 -
20403 - if (amd_nb_has_feature(AMD_NB_L3_PARTITIONING))
20404 - n += 1;
20405 -
20406 - attrs = kzalloc(n * sizeof (struct attribute *), GFP_KERNEL);
20407 - if (attrs == NULL)
20408 - return attrs = default_attrs;
20409 -
20410 - for (n = 0; default_attrs[n]; n++)
20411 - attrs[n] = default_attrs[n];
20412 + attrs = default_attrs_amd_nb;
20413
20414 if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE)) {
20415 attrs[n++] = &cache_disable_0.attr;
20416 @@ -1086,6 +1091,13 @@ static struct kobj_type ktype_cache = {
20417 .default_attrs = default_attrs,
20418 };
20419
20420 +#ifdef CONFIG_AMD_NB
20421 +static struct kobj_type ktype_cache_amd_nb = {
20422 + .sysfs_ops = &sysfs_ops,
20423 + .default_attrs = default_attrs_amd_nb,
20424 +};
20425 +#endif
20426 +
20427 static struct kobj_type ktype_percpu_entry = {
20428 .sysfs_ops = &sysfs_ops,
20429 };
20430 @@ -1151,20 +1163,26 @@ static int cache_add_dev(struct device *dev)
20431 return retval;
20432 }
20433
20434 +#ifdef CONFIG_AMD_NB
20435 + amd_l3_attrs();
20436 +#endif
20437 +
20438 for (i = 0; i < num_cache_leaves; i++) {
20439 + struct kobj_type *ktype;
20440 +
20441 this_object = INDEX_KOBJECT_PTR(cpu, i);
20442 this_object->cpu = cpu;
20443 this_object->index = i;
20444
20445 this_leaf = CPUID4_INFO_IDX(cpu, i);
20446
20447 - ktype_cache.default_attrs = default_attrs;
20448 + ktype = &ktype_cache;
20449 #ifdef CONFIG_AMD_NB
20450 if (this_leaf->base.nb)
20451 - ktype_cache.default_attrs = amd_l3_attrs();
20452 + ktype = &ktype_cache_amd_nb;
20453 #endif
20454 retval = kobject_init_and_add(&(this_object->kobj),
20455 - &ktype_cache,
20456 + ktype,
20457 per_cpu(ici_cache_kobject, cpu),
20458 "index%1lu", i);
20459 if (unlikely(retval)) {
20460 diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
20461 index b3218cd..99a75de 100644
20462 --- a/arch/x86/kernel/cpu/mcheck/mce.c
20463 +++ b/arch/x86/kernel/cpu/mcheck/mce.c
20464 @@ -45,6 +45,7 @@
20465 #include <asm/processor.h>
20466 #include <asm/mce.h>
20467 #include <asm/msr.h>
20468 +#include <asm/local.h>
20469
20470 #include "mce-internal.h"
20471
20472 @@ -258,7 +259,7 @@ static void print_mce(struct mce *m)
20473 !(m->mcgstatus & MCG_STATUS_EIPV) ? " !INEXACT!" : "",
20474 m->cs, m->ip);
20475
20476 - if (m->cs == __KERNEL_CS)
20477 + if (m->cs == __KERNEL_CS || m->cs == __KERNEXEC_KERNEL_CS)
20478 print_symbol("{%s}", m->ip);
20479 pr_cont("\n");
20480 }
20481 @@ -291,10 +292,10 @@ static void print_mce(struct mce *m)
20482
20483 #define PANIC_TIMEOUT 5 /* 5 seconds */
20484
20485 -static atomic_t mce_paniced;
20486 +static atomic_unchecked_t mce_paniced;
20487
20488 static int fake_panic;
20489 -static atomic_t mce_fake_paniced;
20490 +static atomic_unchecked_t mce_fake_paniced;
20491
20492 /* Panic in progress. Enable interrupts and wait for final IPI */
20493 static void wait_for_panic(void)
20494 @@ -318,7 +319,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
20495 /*
20496 * Make sure only one CPU runs in machine check panic
20497 */
20498 - if (atomic_inc_return(&mce_paniced) > 1)
20499 + if (atomic_inc_return_unchecked(&mce_paniced) > 1)
20500 wait_for_panic();
20501 barrier();
20502
20503 @@ -326,7 +327,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
20504 console_verbose();
20505 } else {
20506 /* Don't log too much for fake panic */
20507 - if (atomic_inc_return(&mce_fake_paniced) > 1)
20508 + if (atomic_inc_return_unchecked(&mce_fake_paniced) > 1)
20509 return;
20510 }
20511 /* First print corrected ones that are still unlogged */
20512 @@ -365,7 +366,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
20513 if (!fake_panic) {
20514 if (panic_timeout == 0)
20515 panic_timeout = mca_cfg.panic_timeout;
20516 - panic(msg);
20517 + panic("%s", msg);
20518 } else
20519 pr_emerg(HW_ERR "Fake kernel panic: %s\n", msg);
20520 }
20521 @@ -695,7 +696,7 @@ static int mce_timed_out(u64 *t)
20522 * might have been modified by someone else.
20523 */
20524 rmb();
20525 - if (atomic_read(&mce_paniced))
20526 + if (atomic_read_unchecked(&mce_paniced))
20527 wait_for_panic();
20528 if (!mca_cfg.monarch_timeout)
20529 goto out;
20530 @@ -1666,7 +1667,7 @@ static void unexpected_machine_check(struct pt_regs *regs, long error_code)
20531 }
20532
20533 /* Call the installed machine check handler for this CPU setup. */
20534 -void (*machine_check_vector)(struct pt_regs *, long error_code) =
20535 +void (*machine_check_vector)(struct pt_regs *, long error_code) __read_only =
20536 unexpected_machine_check;
20537
20538 /*
20539 @@ -1689,7 +1690,9 @@ void mcheck_cpu_init(struct cpuinfo_x86 *c)
20540 return;
20541 }
20542
20543 + pax_open_kernel();
20544 machine_check_vector = do_machine_check;
20545 + pax_close_kernel();
20546
20547 __mcheck_cpu_init_generic();
20548 __mcheck_cpu_init_vendor(c);
20549 @@ -1703,7 +1706,7 @@ void mcheck_cpu_init(struct cpuinfo_x86 *c)
20550 */
20551
20552 static DEFINE_SPINLOCK(mce_chrdev_state_lock);
20553 -static int mce_chrdev_open_count; /* #times opened */
20554 +static local_t mce_chrdev_open_count; /* #times opened */
20555 static int mce_chrdev_open_exclu; /* already open exclusive? */
20556
20557 static int mce_chrdev_open(struct inode *inode, struct file *file)
20558 @@ -1711,7 +1714,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
20559 spin_lock(&mce_chrdev_state_lock);
20560
20561 if (mce_chrdev_open_exclu ||
20562 - (mce_chrdev_open_count && (file->f_flags & O_EXCL))) {
20563 + (local_read(&mce_chrdev_open_count) && (file->f_flags & O_EXCL))) {
20564 spin_unlock(&mce_chrdev_state_lock);
20565
20566 return -EBUSY;
20567 @@ -1719,7 +1722,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
20568
20569 if (file->f_flags & O_EXCL)
20570 mce_chrdev_open_exclu = 1;
20571 - mce_chrdev_open_count++;
20572 + local_inc(&mce_chrdev_open_count);
20573
20574 spin_unlock(&mce_chrdev_state_lock);
20575
20576 @@ -1730,7 +1733,7 @@ static int mce_chrdev_release(struct inode *inode, struct file *file)
20577 {
20578 spin_lock(&mce_chrdev_state_lock);
20579
20580 - mce_chrdev_open_count--;
20581 + local_dec(&mce_chrdev_open_count);
20582 mce_chrdev_open_exclu = 0;
20583
20584 spin_unlock(&mce_chrdev_state_lock);
20585 @@ -2404,7 +2407,7 @@ static __init void mce_init_banks(void)
20586
20587 for (i = 0; i < mca_cfg.banks; i++) {
20588 struct mce_bank *b = &mce_banks[i];
20589 - struct device_attribute *a = &b->attr;
20590 + device_attribute_no_const *a = &b->attr;
20591
20592 sysfs_attr_init(&a->attr);
20593 a->attr.name = b->attrname;
20594 @@ -2472,7 +2475,7 @@ struct dentry *mce_get_debugfs_dir(void)
20595 static void mce_reset(void)
20596 {
20597 cpu_missing = 0;
20598 - atomic_set(&mce_fake_paniced, 0);
20599 + atomic_set_unchecked(&mce_fake_paniced, 0);
20600 atomic_set(&mce_executing, 0);
20601 atomic_set(&mce_callin, 0);
20602 atomic_set(&global_nwo, 0);
20603 diff --git a/arch/x86/kernel/cpu/mcheck/p5.c b/arch/x86/kernel/cpu/mcheck/p5.c
20604 index 1c044b1..37a2a43 100644
20605 --- a/arch/x86/kernel/cpu/mcheck/p5.c
20606 +++ b/arch/x86/kernel/cpu/mcheck/p5.c
20607 @@ -11,6 +11,7 @@
20608 #include <asm/processor.h>
20609 #include <asm/mce.h>
20610 #include <asm/msr.h>
20611 +#include <asm/pgtable.h>
20612
20613 /* By default disabled */
20614 int mce_p5_enabled __read_mostly;
20615 @@ -49,7 +50,9 @@ void intel_p5_mcheck_init(struct cpuinfo_x86 *c)
20616 if (!cpu_has(c, X86_FEATURE_MCE))
20617 return;
20618
20619 + pax_open_kernel();
20620 machine_check_vector = pentium_machine_check;
20621 + pax_close_kernel();
20622 /* Make sure the vector pointer is visible before we enable MCEs: */
20623 wmb();
20624
20625 diff --git a/arch/x86/kernel/cpu/mcheck/winchip.c b/arch/x86/kernel/cpu/mcheck/winchip.c
20626 index e9a701a..35317d6 100644
20627 --- a/arch/x86/kernel/cpu/mcheck/winchip.c
20628 +++ b/arch/x86/kernel/cpu/mcheck/winchip.c
20629 @@ -10,6 +10,7 @@
20630 #include <asm/processor.h>
20631 #include <asm/mce.h>
20632 #include <asm/msr.h>
20633 +#include <asm/pgtable.h>
20634
20635 /* Machine check handler for WinChip C6: */
20636 static void winchip_machine_check(struct pt_regs *regs, long error_code)
20637 @@ -23,7 +24,9 @@ void winchip_mcheck_init(struct cpuinfo_x86 *c)
20638 {
20639 u32 lo, hi;
20640
20641 + pax_open_kernel();
20642 machine_check_vector = winchip_machine_check;
20643 + pax_close_kernel();
20644 /* Make sure the vector pointer is visible before we enable MCEs: */
20645 wmb();
20646
20647 diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c
20648 index f961de9..8a9d332 100644
20649 --- a/arch/x86/kernel/cpu/mtrr/main.c
20650 +++ b/arch/x86/kernel/cpu/mtrr/main.c
20651 @@ -66,7 +66,7 @@ static DEFINE_MUTEX(mtrr_mutex);
20652 u64 size_or_mask, size_and_mask;
20653 static bool mtrr_aps_delayed_init;
20654
20655 -static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM];
20656 +static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM] __read_only;
20657
20658 const struct mtrr_ops *mtrr_if;
20659
20660 diff --git a/arch/x86/kernel/cpu/mtrr/mtrr.h b/arch/x86/kernel/cpu/mtrr/mtrr.h
20661 index df5e41f..816c719 100644
20662 --- a/arch/x86/kernel/cpu/mtrr/mtrr.h
20663 +++ b/arch/x86/kernel/cpu/mtrr/mtrr.h
20664 @@ -25,7 +25,7 @@ struct mtrr_ops {
20665 int (*validate_add_page)(unsigned long base, unsigned long size,
20666 unsigned int type);
20667 int (*have_wrcomb)(void);
20668 -};
20669 +} __do_const;
20670
20671 extern int generic_get_free_region(unsigned long base, unsigned long size,
20672 int replace_reg);
20673 diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
20674 index 8a87a32..682a22a 100644
20675 --- a/arch/x86/kernel/cpu/perf_event.c
20676 +++ b/arch/x86/kernel/cpu/perf_event.c
20677 @@ -1348,7 +1348,7 @@ static void __init pmu_check_apic(void)
20678 pr_info("no hardware sampling interrupt available.\n");
20679 }
20680
20681 -static struct attribute_group x86_pmu_format_group = {
20682 +static attribute_group_no_const x86_pmu_format_group = {
20683 .name = "format",
20684 .attrs = NULL,
20685 };
20686 @@ -1447,7 +1447,7 @@ static struct attribute *events_attr[] = {
20687 NULL,
20688 };
20689
20690 -static struct attribute_group x86_pmu_events_group = {
20691 +static attribute_group_no_const x86_pmu_events_group = {
20692 .name = "events",
20693 .attrs = events_attr,
20694 };
20695 @@ -1958,7 +1958,7 @@ static unsigned long get_segment_base(unsigned int segment)
20696 if (idx > GDT_ENTRIES)
20697 return 0;
20698
20699 - desc = __this_cpu_ptr(&gdt_page.gdt[0]);
20700 + desc = get_cpu_gdt_table(smp_processor_id());
20701 }
20702
20703 return get_desc_base(desc + idx);
20704 @@ -2048,7 +2048,7 @@ perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs)
20705 break;
20706
20707 perf_callchain_store(entry, frame.return_address);
20708 - fp = frame.next_frame;
20709 + fp = (const void __force_user *)frame.next_frame;
20710 }
20711 }
20712
20713 diff --git a/arch/x86/kernel/cpu/perf_event_amd_iommu.c b/arch/x86/kernel/cpu/perf_event_amd_iommu.c
20714 index 639d128..e92d7e5 100644
20715 --- a/arch/x86/kernel/cpu/perf_event_amd_iommu.c
20716 +++ b/arch/x86/kernel/cpu/perf_event_amd_iommu.c
20717 @@ -405,7 +405,7 @@ static void perf_iommu_del(struct perf_event *event, int flags)
20718 static __init int _init_events_attrs(struct perf_amd_iommu *perf_iommu)
20719 {
20720 struct attribute **attrs;
20721 - struct attribute_group *attr_group;
20722 + attribute_group_no_const *attr_group;
20723 int i = 0, j;
20724
20725 while (amd_iommu_v2_event_descs[i].attr.attr.name)
20726 diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
20727 index f31a165..7b46cd8 100644
20728 --- a/arch/x86/kernel/cpu/perf_event_intel.c
20729 +++ b/arch/x86/kernel/cpu/perf_event_intel.c
20730 @@ -2247,10 +2247,10 @@ __init int intel_pmu_init(void)
20731 * v2 and above have a perf capabilities MSR
20732 */
20733 if (version > 1) {
20734 - u64 capabilities;
20735 + u64 capabilities = x86_pmu.intel_cap.capabilities;
20736
20737 - rdmsrl(MSR_IA32_PERF_CAPABILITIES, capabilities);
20738 - x86_pmu.intel_cap.capabilities = capabilities;
20739 + if (rdmsrl_safe(MSR_IA32_PERF_CAPABILITIES, &x86_pmu.intel_cap.capabilities))
20740 + x86_pmu.intel_cap.capabilities = capabilities;
20741 }
20742
20743 intel_ds_init();
20744 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.c b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
20745 index 4118f9f..f91d0ab 100644
20746 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.c
20747 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
20748 @@ -3204,7 +3204,7 @@ static void __init uncore_types_exit(struct intel_uncore_type **types)
20749 static int __init uncore_type_init(struct intel_uncore_type *type)
20750 {
20751 struct intel_uncore_pmu *pmus;
20752 - struct attribute_group *attr_group;
20753 + attribute_group_no_const *attr_group;
20754 struct attribute **attrs;
20755 int i, j;
20756
20757 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.h b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
20758 index a80ab71..4089da5 100644
20759 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.h
20760 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
20761 @@ -498,7 +498,7 @@ struct intel_uncore_box {
20762 struct uncore_event_desc {
20763 struct kobj_attribute attr;
20764 const char *config;
20765 -};
20766 +} __do_const;
20767
20768 #define INTEL_UNCORE_EVENT_DESC(_name, _config) \
20769 { \
20770 diff --git a/arch/x86/kernel/cpuid.c b/arch/x86/kernel/cpuid.c
20771 index 7d9481c..99c7e4b 100644
20772 --- a/arch/x86/kernel/cpuid.c
20773 +++ b/arch/x86/kernel/cpuid.c
20774 @@ -170,7 +170,7 @@ static int cpuid_class_cpu_callback(struct notifier_block *nfb,
20775 return notifier_from_errno(err);
20776 }
20777
20778 -static struct notifier_block __refdata cpuid_class_cpu_notifier =
20779 +static struct notifier_block cpuid_class_cpu_notifier =
20780 {
20781 .notifier_call = cpuid_class_cpu_callback,
20782 };
20783 diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c
20784 index 18677a9..f67c45b 100644
20785 --- a/arch/x86/kernel/crash.c
20786 +++ b/arch/x86/kernel/crash.c
20787 @@ -58,10 +58,8 @@ static void kdump_nmi_callback(int cpu, struct pt_regs *regs)
20788 {
20789 #ifdef CONFIG_X86_32
20790 struct pt_regs fixed_regs;
20791 -#endif
20792
20793 -#ifdef CONFIG_X86_32
20794 - if (!user_mode_vm(regs)) {
20795 + if (!user_mode(regs)) {
20796 crash_fixup_ss_esp(&fixed_regs, regs);
20797 regs = &fixed_regs;
20798 }
20799 diff --git a/arch/x86/kernel/crash_dump_64.c b/arch/x86/kernel/crash_dump_64.c
20800 index afa64ad..dce67dd 100644
20801 --- a/arch/x86/kernel/crash_dump_64.c
20802 +++ b/arch/x86/kernel/crash_dump_64.c
20803 @@ -36,7 +36,7 @@ ssize_t copy_oldmem_page(unsigned long pfn, char *buf,
20804 return -ENOMEM;
20805
20806 if (userbuf) {
20807 - if (copy_to_user(buf, vaddr + offset, csize)) {
20808 + if (copy_to_user((char __force_user *)buf, vaddr + offset, csize)) {
20809 iounmap(vaddr);
20810 return -EFAULT;
20811 }
20812 diff --git a/arch/x86/kernel/doublefault.c b/arch/x86/kernel/doublefault.c
20813 index 5d3fe8d..02e1429 100644
20814 --- a/arch/x86/kernel/doublefault.c
20815 +++ b/arch/x86/kernel/doublefault.c
20816 @@ -13,7 +13,7 @@
20817
20818 #define DOUBLEFAULT_STACKSIZE (1024)
20819 static unsigned long doublefault_stack[DOUBLEFAULT_STACKSIZE];
20820 -#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE)
20821 +#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE-2)
20822
20823 #define ptr_ok(x) ((x) > PAGE_OFFSET && (x) < PAGE_OFFSET + MAXMEM)
20824
20825 @@ -23,7 +23,7 @@ static void doublefault_fn(void)
20826 unsigned long gdt, tss;
20827
20828 native_store_gdt(&gdt_desc);
20829 - gdt = gdt_desc.address;
20830 + gdt = (unsigned long)gdt_desc.address;
20831
20832 printk(KERN_EMERG "PANIC: double fault, gdt at %08lx [%d bytes]\n", gdt, gdt_desc.size);
20833
20834 @@ -60,10 +60,10 @@ struct tss_struct doublefault_tss __cacheline_aligned = {
20835 /* 0x2 bit is always set */
20836 .flags = X86_EFLAGS_SF | 0x2,
20837 .sp = STACK_START,
20838 - .es = __USER_DS,
20839 + .es = __KERNEL_DS,
20840 .cs = __KERNEL_CS,
20841 .ss = __KERNEL_DS,
20842 - .ds = __USER_DS,
20843 + .ds = __KERNEL_DS,
20844 .fs = __KERNEL_PERCPU,
20845
20846 .__cr3 = __pa_nodebug(swapper_pg_dir),
20847 diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
20848 index deb6421..76bbc12 100644
20849 --- a/arch/x86/kernel/dumpstack.c
20850 +++ b/arch/x86/kernel/dumpstack.c
20851 @@ -2,6 +2,9 @@
20852 * Copyright (C) 1991, 1992 Linus Torvalds
20853 * Copyright (C) 2000, 2001, 2002 Andi Kleen, SuSE Labs
20854 */
20855 +#ifdef CONFIG_GRKERNSEC_HIDESYM
20856 +#define __INCLUDED_BY_HIDESYM 1
20857 +#endif
20858 #include <linux/kallsyms.h>
20859 #include <linux/kprobes.h>
20860 #include <linux/uaccess.h>
20861 @@ -35,16 +38,14 @@ void printk_address(unsigned long address, int reliable)
20862 static void
20863 print_ftrace_graph_addr(unsigned long addr, void *data,
20864 const struct stacktrace_ops *ops,
20865 - struct thread_info *tinfo, int *graph)
20866 + struct task_struct *task, int *graph)
20867 {
20868 - struct task_struct *task;
20869 unsigned long ret_addr;
20870 int index;
20871
20872 if (addr != (unsigned long)return_to_handler)
20873 return;
20874
20875 - task = tinfo->task;
20876 index = task->curr_ret_stack;
20877
20878 if (!task->ret_stack || index < *graph)
20879 @@ -61,7 +62,7 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
20880 static inline void
20881 print_ftrace_graph_addr(unsigned long addr, void *data,
20882 const struct stacktrace_ops *ops,
20883 - struct thread_info *tinfo, int *graph)
20884 + struct task_struct *task, int *graph)
20885 { }
20886 #endif
20887
20888 @@ -72,10 +73,8 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
20889 * severe exception (double fault, nmi, stack fault, debug, mce) hardware stack
20890 */
20891
20892 -static inline int valid_stack_ptr(struct thread_info *tinfo,
20893 - void *p, unsigned int size, void *end)
20894 +static inline int valid_stack_ptr(void *t, void *p, unsigned int size, void *end)
20895 {
20896 - void *t = tinfo;
20897 if (end) {
20898 if (p < end && p >= (end-THREAD_SIZE))
20899 return 1;
20900 @@ -86,14 +85,14 @@ static inline int valid_stack_ptr(struct thread_info *tinfo,
20901 }
20902
20903 unsigned long
20904 -print_context_stack(struct thread_info *tinfo,
20905 +print_context_stack(struct task_struct *task, void *stack_start,
20906 unsigned long *stack, unsigned long bp,
20907 const struct stacktrace_ops *ops, void *data,
20908 unsigned long *end, int *graph)
20909 {
20910 struct stack_frame *frame = (struct stack_frame *)bp;
20911
20912 - while (valid_stack_ptr(tinfo, stack, sizeof(*stack), end)) {
20913 + while (valid_stack_ptr(stack_start, stack, sizeof(*stack), end)) {
20914 unsigned long addr;
20915
20916 addr = *stack;
20917 @@ -105,7 +104,7 @@ print_context_stack(struct thread_info *tinfo,
20918 } else {
20919 ops->address(data, addr, 0);
20920 }
20921 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
20922 + print_ftrace_graph_addr(addr, data, ops, task, graph);
20923 }
20924 stack++;
20925 }
20926 @@ -114,7 +113,7 @@ print_context_stack(struct thread_info *tinfo,
20927 EXPORT_SYMBOL_GPL(print_context_stack);
20928
20929 unsigned long
20930 -print_context_stack_bp(struct thread_info *tinfo,
20931 +print_context_stack_bp(struct task_struct *task, void *stack_start,
20932 unsigned long *stack, unsigned long bp,
20933 const struct stacktrace_ops *ops, void *data,
20934 unsigned long *end, int *graph)
20935 @@ -122,7 +121,7 @@ print_context_stack_bp(struct thread_info *tinfo,
20936 struct stack_frame *frame = (struct stack_frame *)bp;
20937 unsigned long *ret_addr = &frame->return_address;
20938
20939 - while (valid_stack_ptr(tinfo, ret_addr, sizeof(*ret_addr), end)) {
20940 + while (valid_stack_ptr(stack_start, ret_addr, sizeof(*ret_addr), end)) {
20941 unsigned long addr = *ret_addr;
20942
20943 if (!__kernel_text_address(addr))
20944 @@ -131,7 +130,7 @@ print_context_stack_bp(struct thread_info *tinfo,
20945 ops->address(data, addr, 1);
20946 frame = frame->next_frame;
20947 ret_addr = &frame->return_address;
20948 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
20949 + print_ftrace_graph_addr(addr, data, ops, task, graph);
20950 }
20951
20952 return (unsigned long)frame;
20953 @@ -150,7 +149,7 @@ static int print_trace_stack(void *data, char *name)
20954 static void print_trace_address(void *data, unsigned long addr, int reliable)
20955 {
20956 touch_nmi_watchdog();
20957 - printk(data);
20958 + printk("%s", (char *)data);
20959 printk_address(addr, reliable);
20960 }
20961
20962 @@ -219,6 +218,8 @@ unsigned __kprobes long oops_begin(void)
20963 }
20964 EXPORT_SYMBOL_GPL(oops_begin);
20965
20966 +extern void gr_handle_kernel_exploit(void);
20967 +
20968 void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
20969 {
20970 if (regs && kexec_should_crash(current))
20971 @@ -240,7 +241,10 @@ void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
20972 panic("Fatal exception in interrupt");
20973 if (panic_on_oops)
20974 panic("Fatal exception");
20975 - do_exit(signr);
20976 +
20977 + gr_handle_kernel_exploit();
20978 +
20979 + do_group_exit(signr);
20980 }
20981
20982 int __kprobes __die(const char *str, struct pt_regs *regs, long err)
20983 @@ -268,7 +272,7 @@ int __kprobes __die(const char *str, struct pt_regs *regs, long err)
20984 print_modules();
20985 show_regs(regs);
20986 #ifdef CONFIG_X86_32
20987 - if (user_mode_vm(regs)) {
20988 + if (user_mode(regs)) {
20989 sp = regs->sp;
20990 ss = regs->ss & 0xffff;
20991 } else {
20992 @@ -296,7 +300,7 @@ void die(const char *str, struct pt_regs *regs, long err)
20993 unsigned long flags = oops_begin();
20994 int sig = SIGSEGV;
20995
20996 - if (!user_mode_vm(regs))
20997 + if (!user_mode(regs))
20998 report_bug(regs->ip, regs);
20999
21000 if (__die(str, regs, err))
21001 diff --git a/arch/x86/kernel/dumpstack_32.c b/arch/x86/kernel/dumpstack_32.c
21002 index f2a1770..540657f 100644
21003 --- a/arch/x86/kernel/dumpstack_32.c
21004 +++ b/arch/x86/kernel/dumpstack_32.c
21005 @@ -38,15 +38,13 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
21006 bp = stack_frame(task, regs);
21007
21008 for (;;) {
21009 - struct thread_info *context;
21010 + void *stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
21011
21012 - context = (struct thread_info *)
21013 - ((unsigned long)stack & (~(THREAD_SIZE - 1)));
21014 - bp = ops->walk_stack(context, stack, bp, ops, data, NULL, &graph);
21015 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
21016
21017 - stack = (unsigned long *)context->previous_esp;
21018 - if (!stack)
21019 + if (stack_start == task_stack_page(task))
21020 break;
21021 + stack = *(unsigned long **)stack_start;
21022 if (ops->stack(data, "IRQ") < 0)
21023 break;
21024 touch_nmi_watchdog();
21025 @@ -87,27 +85,28 @@ void show_regs(struct pt_regs *regs)
21026 int i;
21027
21028 show_regs_print_info(KERN_EMERG);
21029 - __show_regs(regs, !user_mode_vm(regs));
21030 + __show_regs(regs, !user_mode(regs));
21031
21032 /*
21033 * When in-kernel, we also print out the stack and code at the
21034 * time of the fault..
21035 */
21036 - if (!user_mode_vm(regs)) {
21037 + if (!user_mode(regs)) {
21038 unsigned int code_prologue = code_bytes * 43 / 64;
21039 unsigned int code_len = code_bytes;
21040 unsigned char c;
21041 u8 *ip;
21042 + unsigned long cs_base = get_desc_base(&get_cpu_gdt_table(0)[(0xffff & regs->cs) >> 3]);
21043
21044 pr_emerg("Stack:\n");
21045 show_stack_log_lvl(NULL, regs, &regs->sp, 0, KERN_EMERG);
21046
21047 pr_emerg("Code:");
21048
21049 - ip = (u8 *)regs->ip - code_prologue;
21050 + ip = (u8 *)regs->ip - code_prologue + cs_base;
21051 if (ip < (u8 *)PAGE_OFFSET || probe_kernel_address(ip, c)) {
21052 /* try starting at IP */
21053 - ip = (u8 *)regs->ip;
21054 + ip = (u8 *)regs->ip + cs_base;
21055 code_len = code_len - code_prologue + 1;
21056 }
21057 for (i = 0; i < code_len; i++, ip++) {
21058 @@ -116,7 +115,7 @@ void show_regs(struct pt_regs *regs)
21059 pr_cont(" Bad EIP value.");
21060 break;
21061 }
21062 - if (ip == (u8 *)regs->ip)
21063 + if (ip == (u8 *)regs->ip + cs_base)
21064 pr_cont(" <%02x>", c);
21065 else
21066 pr_cont(" %02x", c);
21067 @@ -129,6 +128,7 @@ int is_valid_bugaddr(unsigned long ip)
21068 {
21069 unsigned short ud2;
21070
21071 + ip = ktla_ktva(ip);
21072 if (ip < PAGE_OFFSET)
21073 return 0;
21074 if (probe_kernel_address((unsigned short *)ip, ud2))
21075 @@ -136,3 +136,15 @@ int is_valid_bugaddr(unsigned long ip)
21076
21077 return ud2 == 0x0b0f;
21078 }
21079 +
21080 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
21081 +void pax_check_alloca(unsigned long size)
21082 +{
21083 + unsigned long sp = (unsigned long)&sp, stack_left;
21084 +
21085 + /* all kernel stacks are of the same size */
21086 + stack_left = sp & (THREAD_SIZE - 1);
21087 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
21088 +}
21089 +EXPORT_SYMBOL(pax_check_alloca);
21090 +#endif
21091 diff --git a/arch/x86/kernel/dumpstack_64.c b/arch/x86/kernel/dumpstack_64.c
21092 index addb207..99635fa 100644
21093 --- a/arch/x86/kernel/dumpstack_64.c
21094 +++ b/arch/x86/kernel/dumpstack_64.c
21095 @@ -119,9 +119,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
21096 unsigned long *irq_stack_end =
21097 (unsigned long *)per_cpu(irq_stack_ptr, cpu);
21098 unsigned used = 0;
21099 - struct thread_info *tinfo;
21100 int graph = 0;
21101 unsigned long dummy;
21102 + void *stack_start;
21103
21104 if (!task)
21105 task = current;
21106 @@ -142,10 +142,10 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
21107 * current stack address. If the stacks consist of nested
21108 * exceptions
21109 */
21110 - tinfo = task_thread_info(task);
21111 for (;;) {
21112 char *id;
21113 unsigned long *estack_end;
21114 +
21115 estack_end = in_exception_stack(cpu, (unsigned long)stack,
21116 &used, &id);
21117
21118 @@ -153,7 +153,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
21119 if (ops->stack(data, id) < 0)
21120 break;
21121
21122 - bp = ops->walk_stack(tinfo, stack, bp, ops,
21123 + bp = ops->walk_stack(task, estack_end - EXCEPTION_STKSZ, stack, bp, ops,
21124 data, estack_end, &graph);
21125 ops->stack(data, "<EOE>");
21126 /*
21127 @@ -161,6 +161,8 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
21128 * second-to-last pointer (index -2 to end) in the
21129 * exception stack:
21130 */
21131 + if ((u16)estack_end[-1] != __KERNEL_DS)
21132 + goto out;
21133 stack = (unsigned long *) estack_end[-2];
21134 continue;
21135 }
21136 @@ -172,7 +174,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
21137 if (in_irq_stack(stack, irq_stack, irq_stack_end)) {
21138 if (ops->stack(data, "IRQ") < 0)
21139 break;
21140 - bp = ops->walk_stack(tinfo, stack, bp,
21141 + bp = ops->walk_stack(task, irq_stack, stack, bp,
21142 ops, data, irq_stack_end, &graph);
21143 /*
21144 * We link to the next stack (which would be
21145 @@ -191,7 +193,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
21146 /*
21147 * This handles the process stack:
21148 */
21149 - bp = ops->walk_stack(tinfo, stack, bp, ops, data, NULL, &graph);
21150 + stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
21151 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
21152 +out:
21153 put_cpu();
21154 }
21155 EXPORT_SYMBOL(dump_trace);
21156 @@ -300,3 +304,50 @@ int is_valid_bugaddr(unsigned long ip)
21157
21158 return ud2 == 0x0b0f;
21159 }
21160 +
21161 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
21162 +void pax_check_alloca(unsigned long size)
21163 +{
21164 + unsigned long sp = (unsigned long)&sp, stack_start, stack_end;
21165 + unsigned cpu, used;
21166 + char *id;
21167 +
21168 + /* check the process stack first */
21169 + stack_start = (unsigned long)task_stack_page(current);
21170 + stack_end = stack_start + THREAD_SIZE;
21171 + if (likely(stack_start <= sp && sp < stack_end)) {
21172 + unsigned long stack_left = sp & (THREAD_SIZE - 1);
21173 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
21174 + return;
21175 + }
21176 +
21177 + cpu = get_cpu();
21178 +
21179 + /* check the irq stacks */
21180 + stack_end = (unsigned long)per_cpu(irq_stack_ptr, cpu);
21181 + stack_start = stack_end - IRQ_STACK_SIZE;
21182 + if (stack_start <= sp && sp < stack_end) {
21183 + unsigned long stack_left = sp & (IRQ_STACK_SIZE - 1);
21184 + put_cpu();
21185 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
21186 + return;
21187 + }
21188 +
21189 + /* check the exception stacks */
21190 + used = 0;
21191 + stack_end = (unsigned long)in_exception_stack(cpu, sp, &used, &id);
21192 + stack_start = stack_end - EXCEPTION_STKSZ;
21193 + if (stack_end && stack_start <= sp && sp < stack_end) {
21194 + unsigned long stack_left = sp & (EXCEPTION_STKSZ - 1);
21195 + put_cpu();
21196 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
21197 + return;
21198 + }
21199 +
21200 + put_cpu();
21201 +
21202 + /* unknown stack */
21203 + BUG();
21204 +}
21205 +EXPORT_SYMBOL(pax_check_alloca);
21206 +#endif
21207 diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
21208 index 174da5f..5e55606 100644
21209 --- a/arch/x86/kernel/e820.c
21210 +++ b/arch/x86/kernel/e820.c
21211 @@ -803,8 +803,8 @@ unsigned long __init e820_end_of_low_ram_pfn(void)
21212
21213 static void early_panic(char *msg)
21214 {
21215 - early_printk(msg);
21216 - panic(msg);
21217 + early_printk("%s", msg);
21218 + panic("%s", msg);
21219 }
21220
21221 static int userdef __initdata;
21222 diff --git a/arch/x86/kernel/early_printk.c b/arch/x86/kernel/early_printk.c
21223 index d15f575..d692043 100644
21224 --- a/arch/x86/kernel/early_printk.c
21225 +++ b/arch/x86/kernel/early_printk.c
21226 @@ -7,6 +7,7 @@
21227 #include <linux/pci_regs.h>
21228 #include <linux/pci_ids.h>
21229 #include <linux/errno.h>
21230 +#include <linux/sched.h>
21231 #include <asm/io.h>
21232 #include <asm/processor.h>
21233 #include <asm/fcntl.h>
21234 diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
21235 index f0dcb0c..9f39b80 100644
21236 --- a/arch/x86/kernel/entry_32.S
21237 +++ b/arch/x86/kernel/entry_32.S
21238 @@ -177,13 +177,153 @@
21239 /*CFI_REL_OFFSET gs, PT_GS*/
21240 .endm
21241 .macro SET_KERNEL_GS reg
21242 +
21243 +#ifdef CONFIG_CC_STACKPROTECTOR
21244 movl $(__KERNEL_STACK_CANARY), \reg
21245 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
21246 + movl $(__USER_DS), \reg
21247 +#else
21248 + xorl \reg, \reg
21249 +#endif
21250 +
21251 movl \reg, %gs
21252 .endm
21253
21254 #endif /* CONFIG_X86_32_LAZY_GS */
21255
21256 -.macro SAVE_ALL
21257 +.macro pax_enter_kernel
21258 +#ifdef CONFIG_PAX_KERNEXEC
21259 + call pax_enter_kernel
21260 +#endif
21261 +.endm
21262 +
21263 +.macro pax_exit_kernel
21264 +#ifdef CONFIG_PAX_KERNEXEC
21265 + call pax_exit_kernel
21266 +#endif
21267 +.endm
21268 +
21269 +#ifdef CONFIG_PAX_KERNEXEC
21270 +ENTRY(pax_enter_kernel)
21271 +#ifdef CONFIG_PARAVIRT
21272 + pushl %eax
21273 + pushl %ecx
21274 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0)
21275 + mov %eax, %esi
21276 +#else
21277 + mov %cr0, %esi
21278 +#endif
21279 + bts $16, %esi
21280 + jnc 1f
21281 + mov %cs, %esi
21282 + cmp $__KERNEL_CS, %esi
21283 + jz 3f
21284 + ljmp $__KERNEL_CS, $3f
21285 +1: ljmp $__KERNEXEC_KERNEL_CS, $2f
21286 +2:
21287 +#ifdef CONFIG_PARAVIRT
21288 + mov %esi, %eax
21289 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
21290 +#else
21291 + mov %esi, %cr0
21292 +#endif
21293 +3:
21294 +#ifdef CONFIG_PARAVIRT
21295 + popl %ecx
21296 + popl %eax
21297 +#endif
21298 + ret
21299 +ENDPROC(pax_enter_kernel)
21300 +
21301 +ENTRY(pax_exit_kernel)
21302 +#ifdef CONFIG_PARAVIRT
21303 + pushl %eax
21304 + pushl %ecx
21305 +#endif
21306 + mov %cs, %esi
21307 + cmp $__KERNEXEC_KERNEL_CS, %esi
21308 + jnz 2f
21309 +#ifdef CONFIG_PARAVIRT
21310 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0);
21311 + mov %eax, %esi
21312 +#else
21313 + mov %cr0, %esi
21314 +#endif
21315 + btr $16, %esi
21316 + ljmp $__KERNEL_CS, $1f
21317 +1:
21318 +#ifdef CONFIG_PARAVIRT
21319 + mov %esi, %eax
21320 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0);
21321 +#else
21322 + mov %esi, %cr0
21323 +#endif
21324 +2:
21325 +#ifdef CONFIG_PARAVIRT
21326 + popl %ecx
21327 + popl %eax
21328 +#endif
21329 + ret
21330 +ENDPROC(pax_exit_kernel)
21331 +#endif
21332 +
21333 + .macro pax_erase_kstack
21334 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
21335 + call pax_erase_kstack
21336 +#endif
21337 + .endm
21338 +
21339 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
21340 +/*
21341 + * ebp: thread_info
21342 + */
21343 +ENTRY(pax_erase_kstack)
21344 + pushl %edi
21345 + pushl %ecx
21346 + pushl %eax
21347 +
21348 + mov TI_lowest_stack(%ebp), %edi
21349 + mov $-0xBEEF, %eax
21350 + std
21351 +
21352 +1: mov %edi, %ecx
21353 + and $THREAD_SIZE_asm - 1, %ecx
21354 + shr $2, %ecx
21355 + repne scasl
21356 + jecxz 2f
21357 +
21358 + cmp $2*16, %ecx
21359 + jc 2f
21360 +
21361 + mov $2*16, %ecx
21362 + repe scasl
21363 + jecxz 2f
21364 + jne 1b
21365 +
21366 +2: cld
21367 + mov %esp, %ecx
21368 + sub %edi, %ecx
21369 +
21370 + cmp $THREAD_SIZE_asm, %ecx
21371 + jb 3f
21372 + ud2
21373 +3:
21374 +
21375 + shr $2, %ecx
21376 + rep stosl
21377 +
21378 + mov TI_task_thread_sp0(%ebp), %edi
21379 + sub $128, %edi
21380 + mov %edi, TI_lowest_stack(%ebp)
21381 +
21382 + popl %eax
21383 + popl %ecx
21384 + popl %edi
21385 + ret
21386 +ENDPROC(pax_erase_kstack)
21387 +#endif
21388 +
21389 +.macro __SAVE_ALL _DS
21390 cld
21391 PUSH_GS
21392 pushl_cfi %fs
21393 @@ -206,7 +346,7 @@
21394 CFI_REL_OFFSET ecx, 0
21395 pushl_cfi %ebx
21396 CFI_REL_OFFSET ebx, 0
21397 - movl $(__USER_DS), %edx
21398 + movl $\_DS, %edx
21399 movl %edx, %ds
21400 movl %edx, %es
21401 movl $(__KERNEL_PERCPU), %edx
21402 @@ -214,6 +354,15 @@
21403 SET_KERNEL_GS %edx
21404 .endm
21405
21406 +.macro SAVE_ALL
21407 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
21408 + __SAVE_ALL __KERNEL_DS
21409 + pax_enter_kernel
21410 +#else
21411 + __SAVE_ALL __USER_DS
21412 +#endif
21413 +.endm
21414 +
21415 .macro RESTORE_INT_REGS
21416 popl_cfi %ebx
21417 CFI_RESTORE ebx
21418 @@ -297,7 +446,7 @@ ENTRY(ret_from_fork)
21419 popfl_cfi
21420 jmp syscall_exit
21421 CFI_ENDPROC
21422 -END(ret_from_fork)
21423 +ENDPROC(ret_from_fork)
21424
21425 ENTRY(ret_from_kernel_thread)
21426 CFI_STARTPROC
21427 @@ -344,7 +493,15 @@ ret_from_intr:
21428 andl $SEGMENT_RPL_MASK, %eax
21429 #endif
21430 cmpl $USER_RPL, %eax
21431 +
21432 +#ifdef CONFIG_PAX_KERNEXEC
21433 + jae resume_userspace
21434 +
21435 + pax_exit_kernel
21436 + jmp resume_kernel
21437 +#else
21438 jb resume_kernel # not returning to v8086 or userspace
21439 +#endif
21440
21441 ENTRY(resume_userspace)
21442 LOCKDEP_SYS_EXIT
21443 @@ -356,8 +513,8 @@ ENTRY(resume_userspace)
21444 andl $_TIF_WORK_MASK, %ecx # is there any work to be done on
21445 # int/exception return?
21446 jne work_pending
21447 - jmp restore_all
21448 -END(ret_from_exception)
21449 + jmp restore_all_pax
21450 +ENDPROC(ret_from_exception)
21451
21452 #ifdef CONFIG_PREEMPT
21453 ENTRY(resume_kernel)
21454 @@ -372,7 +529,7 @@ need_resched:
21455 jz restore_all
21456 call preempt_schedule_irq
21457 jmp need_resched
21458 -END(resume_kernel)
21459 +ENDPROC(resume_kernel)
21460 #endif
21461 CFI_ENDPROC
21462 /*
21463 @@ -406,30 +563,45 @@ sysenter_past_esp:
21464 /*CFI_REL_OFFSET cs, 0*/
21465 /*
21466 * Push current_thread_info()->sysenter_return to the stack.
21467 - * A tiny bit of offset fixup is necessary - 4*4 means the 4 words
21468 - * pushed above; +8 corresponds to copy_thread's esp0 setting.
21469 */
21470 - pushl_cfi ((TI_sysenter_return)-THREAD_SIZE+8+4*4)(%esp)
21471 + pushl_cfi $0
21472 CFI_REL_OFFSET eip, 0
21473
21474 pushl_cfi %eax
21475 SAVE_ALL
21476 + GET_THREAD_INFO(%ebp)
21477 + movl TI_sysenter_return(%ebp),%ebp
21478 + movl %ebp,PT_EIP(%esp)
21479 ENABLE_INTERRUPTS(CLBR_NONE)
21480
21481 /*
21482 * Load the potential sixth argument from user stack.
21483 * Careful about security.
21484 */
21485 + movl PT_OLDESP(%esp),%ebp
21486 +
21487 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21488 + mov PT_OLDSS(%esp),%ds
21489 +1: movl %ds:(%ebp),%ebp
21490 + push %ss
21491 + pop %ds
21492 +#else
21493 cmpl $__PAGE_OFFSET-3,%ebp
21494 jae syscall_fault
21495 ASM_STAC
21496 1: movl (%ebp),%ebp
21497 ASM_CLAC
21498 +#endif
21499 +
21500 movl %ebp,PT_EBP(%esp)
21501 _ASM_EXTABLE(1b,syscall_fault)
21502
21503 GET_THREAD_INFO(%ebp)
21504
21505 +#ifdef CONFIG_PAX_RANDKSTACK
21506 + pax_erase_kstack
21507 +#endif
21508 +
21509 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
21510 jnz sysenter_audit
21511 sysenter_do_call:
21512 @@ -444,12 +616,24 @@ sysenter_do_call:
21513 testl $_TIF_ALLWORK_MASK, %ecx
21514 jne sysexit_audit
21515 sysenter_exit:
21516 +
21517 +#ifdef CONFIG_PAX_RANDKSTACK
21518 + pushl_cfi %eax
21519 + movl %esp, %eax
21520 + call pax_randomize_kstack
21521 + popl_cfi %eax
21522 +#endif
21523 +
21524 + pax_erase_kstack
21525 +
21526 /* if something modifies registers it must also disable sysexit */
21527 movl PT_EIP(%esp), %edx
21528 movl PT_OLDESP(%esp), %ecx
21529 xorl %ebp,%ebp
21530 TRACE_IRQS_ON
21531 1: mov PT_FS(%esp), %fs
21532 +2: mov PT_DS(%esp), %ds
21533 +3: mov PT_ES(%esp), %es
21534 PTGS_TO_GS
21535 ENABLE_INTERRUPTS_SYSEXIT
21536
21537 @@ -466,6 +650,9 @@ sysenter_audit:
21538 movl %eax,%edx /* 2nd arg: syscall number */
21539 movl $AUDIT_ARCH_I386,%eax /* 1st arg: audit arch */
21540 call __audit_syscall_entry
21541 +
21542 + pax_erase_kstack
21543 +
21544 pushl_cfi %ebx
21545 movl PT_EAX(%esp),%eax /* reload syscall number */
21546 jmp sysenter_do_call
21547 @@ -491,10 +678,16 @@ sysexit_audit:
21548
21549 CFI_ENDPROC
21550 .pushsection .fixup,"ax"
21551 -2: movl $0,PT_FS(%esp)
21552 +4: movl $0,PT_FS(%esp)
21553 + jmp 1b
21554 +5: movl $0,PT_DS(%esp)
21555 + jmp 1b
21556 +6: movl $0,PT_ES(%esp)
21557 jmp 1b
21558 .popsection
21559 - _ASM_EXTABLE(1b,2b)
21560 + _ASM_EXTABLE(1b,4b)
21561 + _ASM_EXTABLE(2b,5b)
21562 + _ASM_EXTABLE(3b,6b)
21563 PTGS_TO_GS_EX
21564 ENDPROC(ia32_sysenter_target)
21565
21566 @@ -509,6 +702,11 @@ ENTRY(system_call)
21567 pushl_cfi %eax # save orig_eax
21568 SAVE_ALL
21569 GET_THREAD_INFO(%ebp)
21570 +
21571 +#ifdef CONFIG_PAX_RANDKSTACK
21572 + pax_erase_kstack
21573 +#endif
21574 +
21575 # system call tracing in operation / emulation
21576 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
21577 jnz syscall_trace_entry
21578 @@ -527,6 +725,15 @@ syscall_exit:
21579 testl $_TIF_ALLWORK_MASK, %ecx # current->work
21580 jne syscall_exit_work
21581
21582 +restore_all_pax:
21583 +
21584 +#ifdef CONFIG_PAX_RANDKSTACK
21585 + movl %esp, %eax
21586 + call pax_randomize_kstack
21587 +#endif
21588 +
21589 + pax_erase_kstack
21590 +
21591 restore_all:
21592 TRACE_IRQS_IRET
21593 restore_all_notrace:
21594 @@ -583,14 +790,34 @@ ldt_ss:
21595 * compensating for the offset by changing to the ESPFIX segment with
21596 * a base address that matches for the difference.
21597 */
21598 -#define GDT_ESPFIX_SS PER_CPU_VAR(gdt_page) + (GDT_ENTRY_ESPFIX_SS * 8)
21599 +#define GDT_ESPFIX_SS (GDT_ENTRY_ESPFIX_SS * 8)(%ebx)
21600 mov %esp, %edx /* load kernel esp */
21601 mov PT_OLDESP(%esp), %eax /* load userspace esp */
21602 mov %dx, %ax /* eax: new kernel esp */
21603 sub %eax, %edx /* offset (low word is 0) */
21604 +#ifdef CONFIG_SMP
21605 + movl PER_CPU_VAR(cpu_number), %ebx
21606 + shll $PAGE_SHIFT_asm, %ebx
21607 + addl $cpu_gdt_table, %ebx
21608 +#else
21609 + movl $cpu_gdt_table, %ebx
21610 +#endif
21611 shr $16, %edx
21612 - mov %dl, GDT_ESPFIX_SS + 4 /* bits 16..23 */
21613 - mov %dh, GDT_ESPFIX_SS + 7 /* bits 24..31 */
21614 +
21615 +#ifdef CONFIG_PAX_KERNEXEC
21616 + mov %cr0, %esi
21617 + btr $16, %esi
21618 + mov %esi, %cr0
21619 +#endif
21620 +
21621 + mov %dl, 4 + GDT_ESPFIX_SS /* bits 16..23 */
21622 + mov %dh, 7 + GDT_ESPFIX_SS /* bits 24..31 */
21623 +
21624 +#ifdef CONFIG_PAX_KERNEXEC
21625 + bts $16, %esi
21626 + mov %esi, %cr0
21627 +#endif
21628 +
21629 pushl_cfi $__ESPFIX_SS
21630 pushl_cfi %eax /* new kernel esp */
21631 /* Disable interrupts, but do not irqtrace this section: we
21632 @@ -619,20 +846,18 @@ work_resched:
21633 movl TI_flags(%ebp), %ecx
21634 andl $_TIF_WORK_MASK, %ecx # is there any work to be done other
21635 # than syscall tracing?
21636 - jz restore_all
21637 + jz restore_all_pax
21638 testb $_TIF_NEED_RESCHED, %cl
21639 jnz work_resched
21640
21641 work_notifysig: # deal with pending signals and
21642 # notify-resume requests
21643 + movl %esp, %eax
21644 #ifdef CONFIG_VM86
21645 testl $X86_EFLAGS_VM, PT_EFLAGS(%esp)
21646 - movl %esp, %eax
21647 jne work_notifysig_v86 # returning to kernel-space or
21648 # vm86-space
21649 1:
21650 -#else
21651 - movl %esp, %eax
21652 #endif
21653 TRACE_IRQS_ON
21654 ENABLE_INTERRUPTS(CLBR_NONE)
21655 @@ -653,7 +878,7 @@ work_notifysig_v86:
21656 movl %eax, %esp
21657 jmp 1b
21658 #endif
21659 -END(work_pending)
21660 +ENDPROC(work_pending)
21661
21662 # perform syscall exit tracing
21663 ALIGN
21664 @@ -661,11 +886,14 @@ syscall_trace_entry:
21665 movl $-ENOSYS,PT_EAX(%esp)
21666 movl %esp, %eax
21667 call syscall_trace_enter
21668 +
21669 + pax_erase_kstack
21670 +
21671 /* What it returned is what we'll actually use. */
21672 cmpl $(NR_syscalls), %eax
21673 jnae syscall_call
21674 jmp syscall_exit
21675 -END(syscall_trace_entry)
21676 +ENDPROC(syscall_trace_entry)
21677
21678 # perform syscall exit tracing
21679 ALIGN
21680 @@ -678,21 +906,25 @@ syscall_exit_work:
21681 movl %esp, %eax
21682 call syscall_trace_leave
21683 jmp resume_userspace
21684 -END(syscall_exit_work)
21685 +ENDPROC(syscall_exit_work)
21686 CFI_ENDPROC
21687
21688 RING0_INT_FRAME # can't unwind into user space anyway
21689 syscall_fault:
21690 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21691 + push %ss
21692 + pop %ds
21693 +#endif
21694 ASM_CLAC
21695 GET_THREAD_INFO(%ebp)
21696 movl $-EFAULT,PT_EAX(%esp)
21697 jmp resume_userspace
21698 -END(syscall_fault)
21699 +ENDPROC(syscall_fault)
21700
21701 syscall_badsys:
21702 movl $-ENOSYS,PT_EAX(%esp)
21703 jmp resume_userspace
21704 -END(syscall_badsys)
21705 +ENDPROC(syscall_badsys)
21706 CFI_ENDPROC
21707 /*
21708 * End of kprobes section
21709 @@ -708,8 +940,15 @@ END(syscall_badsys)
21710 * normal stack and adjusts ESP with the matching offset.
21711 */
21712 /* fixup the stack */
21713 - mov GDT_ESPFIX_SS + 4, %al /* bits 16..23 */
21714 - mov GDT_ESPFIX_SS + 7, %ah /* bits 24..31 */
21715 +#ifdef CONFIG_SMP
21716 + movl PER_CPU_VAR(cpu_number), %ebx
21717 + shll $PAGE_SHIFT_asm, %ebx
21718 + addl $cpu_gdt_table, %ebx
21719 +#else
21720 + movl $cpu_gdt_table, %ebx
21721 +#endif
21722 + mov 4 + GDT_ESPFIX_SS, %al /* bits 16..23 */
21723 + mov 7 + GDT_ESPFIX_SS, %ah /* bits 24..31 */
21724 shl $16, %eax
21725 addl %esp, %eax /* the adjusted stack pointer */
21726 pushl_cfi $__KERNEL_DS
21727 @@ -762,7 +1001,7 @@ vector=vector+1
21728 .endr
21729 2: jmp common_interrupt
21730 .endr
21731 -END(irq_entries_start)
21732 +ENDPROC(irq_entries_start)
21733
21734 .previous
21735 END(interrupt)
21736 @@ -823,7 +1062,7 @@ ENTRY(coprocessor_error)
21737 pushl_cfi $do_coprocessor_error
21738 jmp error_code
21739 CFI_ENDPROC
21740 -END(coprocessor_error)
21741 +ENDPROC(coprocessor_error)
21742
21743 ENTRY(simd_coprocessor_error)
21744 RING0_INT_FRAME
21745 @@ -836,7 +1075,7 @@ ENTRY(simd_coprocessor_error)
21746 .section .altinstructions,"a"
21747 altinstruction_entry 661b, 663f, X86_FEATURE_XMM, 662b-661b, 664f-663f
21748 .previous
21749 -.section .altinstr_replacement,"ax"
21750 +.section .altinstr_replacement,"a"
21751 663: pushl $do_simd_coprocessor_error
21752 664:
21753 .previous
21754 @@ -845,7 +1084,7 @@ ENTRY(simd_coprocessor_error)
21755 #endif
21756 jmp error_code
21757 CFI_ENDPROC
21758 -END(simd_coprocessor_error)
21759 +ENDPROC(simd_coprocessor_error)
21760
21761 ENTRY(device_not_available)
21762 RING0_INT_FRAME
21763 @@ -854,18 +1093,18 @@ ENTRY(device_not_available)
21764 pushl_cfi $do_device_not_available
21765 jmp error_code
21766 CFI_ENDPROC
21767 -END(device_not_available)
21768 +ENDPROC(device_not_available)
21769
21770 #ifdef CONFIG_PARAVIRT
21771 ENTRY(native_iret)
21772 iret
21773 _ASM_EXTABLE(native_iret, iret_exc)
21774 -END(native_iret)
21775 +ENDPROC(native_iret)
21776
21777 ENTRY(native_irq_enable_sysexit)
21778 sti
21779 sysexit
21780 -END(native_irq_enable_sysexit)
21781 +ENDPROC(native_irq_enable_sysexit)
21782 #endif
21783
21784 ENTRY(overflow)
21785 @@ -875,7 +1114,7 @@ ENTRY(overflow)
21786 pushl_cfi $do_overflow
21787 jmp error_code
21788 CFI_ENDPROC
21789 -END(overflow)
21790 +ENDPROC(overflow)
21791
21792 ENTRY(bounds)
21793 RING0_INT_FRAME
21794 @@ -884,7 +1123,7 @@ ENTRY(bounds)
21795 pushl_cfi $do_bounds
21796 jmp error_code
21797 CFI_ENDPROC
21798 -END(bounds)
21799 +ENDPROC(bounds)
21800
21801 ENTRY(invalid_op)
21802 RING0_INT_FRAME
21803 @@ -893,7 +1132,7 @@ ENTRY(invalid_op)
21804 pushl_cfi $do_invalid_op
21805 jmp error_code
21806 CFI_ENDPROC
21807 -END(invalid_op)
21808 +ENDPROC(invalid_op)
21809
21810 ENTRY(coprocessor_segment_overrun)
21811 RING0_INT_FRAME
21812 @@ -902,7 +1141,7 @@ ENTRY(coprocessor_segment_overrun)
21813 pushl_cfi $do_coprocessor_segment_overrun
21814 jmp error_code
21815 CFI_ENDPROC
21816 -END(coprocessor_segment_overrun)
21817 +ENDPROC(coprocessor_segment_overrun)
21818
21819 ENTRY(invalid_TSS)
21820 RING0_EC_FRAME
21821 @@ -910,7 +1149,7 @@ ENTRY(invalid_TSS)
21822 pushl_cfi $do_invalid_TSS
21823 jmp error_code
21824 CFI_ENDPROC
21825 -END(invalid_TSS)
21826 +ENDPROC(invalid_TSS)
21827
21828 ENTRY(segment_not_present)
21829 RING0_EC_FRAME
21830 @@ -918,7 +1157,7 @@ ENTRY(segment_not_present)
21831 pushl_cfi $do_segment_not_present
21832 jmp error_code
21833 CFI_ENDPROC
21834 -END(segment_not_present)
21835 +ENDPROC(segment_not_present)
21836
21837 ENTRY(stack_segment)
21838 RING0_EC_FRAME
21839 @@ -926,7 +1165,7 @@ ENTRY(stack_segment)
21840 pushl_cfi $do_stack_segment
21841 jmp error_code
21842 CFI_ENDPROC
21843 -END(stack_segment)
21844 +ENDPROC(stack_segment)
21845
21846 ENTRY(alignment_check)
21847 RING0_EC_FRAME
21848 @@ -934,7 +1173,7 @@ ENTRY(alignment_check)
21849 pushl_cfi $do_alignment_check
21850 jmp error_code
21851 CFI_ENDPROC
21852 -END(alignment_check)
21853 +ENDPROC(alignment_check)
21854
21855 ENTRY(divide_error)
21856 RING0_INT_FRAME
21857 @@ -943,7 +1182,7 @@ ENTRY(divide_error)
21858 pushl_cfi $do_divide_error
21859 jmp error_code
21860 CFI_ENDPROC
21861 -END(divide_error)
21862 +ENDPROC(divide_error)
21863
21864 #ifdef CONFIG_X86_MCE
21865 ENTRY(machine_check)
21866 @@ -953,7 +1192,7 @@ ENTRY(machine_check)
21867 pushl_cfi machine_check_vector
21868 jmp error_code
21869 CFI_ENDPROC
21870 -END(machine_check)
21871 +ENDPROC(machine_check)
21872 #endif
21873
21874 ENTRY(spurious_interrupt_bug)
21875 @@ -963,7 +1202,7 @@ ENTRY(spurious_interrupt_bug)
21876 pushl_cfi $do_spurious_interrupt_bug
21877 jmp error_code
21878 CFI_ENDPROC
21879 -END(spurious_interrupt_bug)
21880 +ENDPROC(spurious_interrupt_bug)
21881 /*
21882 * End of kprobes section
21883 */
21884 @@ -1073,7 +1312,7 @@ BUILD_INTERRUPT3(hyperv_callback_vector, HYPERVISOR_CALLBACK_VECTOR,
21885
21886 ENTRY(mcount)
21887 ret
21888 -END(mcount)
21889 +ENDPROC(mcount)
21890
21891 ENTRY(ftrace_caller)
21892 cmpl $0, function_trace_stop
21893 @@ -1106,7 +1345,7 @@ ftrace_graph_call:
21894 .globl ftrace_stub
21895 ftrace_stub:
21896 ret
21897 -END(ftrace_caller)
21898 +ENDPROC(ftrace_caller)
21899
21900 ENTRY(ftrace_regs_caller)
21901 pushf /* push flags before compare (in cs location) */
21902 @@ -1210,7 +1449,7 @@ trace:
21903 popl %ecx
21904 popl %eax
21905 jmp ftrace_stub
21906 -END(mcount)
21907 +ENDPROC(mcount)
21908 #endif /* CONFIG_DYNAMIC_FTRACE */
21909 #endif /* CONFIG_FUNCTION_TRACER */
21910
21911 @@ -1228,7 +1467,7 @@ ENTRY(ftrace_graph_caller)
21912 popl %ecx
21913 popl %eax
21914 ret
21915 -END(ftrace_graph_caller)
21916 +ENDPROC(ftrace_graph_caller)
21917
21918 .globl return_to_handler
21919 return_to_handler:
21920 @@ -1284,15 +1523,18 @@ error_code:
21921 movl $-1, PT_ORIG_EAX(%esp) # no syscall to restart
21922 REG_TO_PTGS %ecx
21923 SET_KERNEL_GS %ecx
21924 - movl $(__USER_DS), %ecx
21925 + movl $(__KERNEL_DS), %ecx
21926 movl %ecx, %ds
21927 movl %ecx, %es
21928 +
21929 + pax_enter_kernel
21930 +
21931 TRACE_IRQS_OFF
21932 movl %esp,%eax # pt_regs pointer
21933 call *%edi
21934 jmp ret_from_exception
21935 CFI_ENDPROC
21936 -END(page_fault)
21937 +ENDPROC(page_fault)
21938
21939 /*
21940 * Debug traps and NMI can happen at the one SYSENTER instruction
21941 @@ -1335,7 +1577,7 @@ debug_stack_correct:
21942 call do_debug
21943 jmp ret_from_exception
21944 CFI_ENDPROC
21945 -END(debug)
21946 +ENDPROC(debug)
21947
21948 /*
21949 * NMI is doubly nasty. It can happen _while_ we're handling
21950 @@ -1373,6 +1615,9 @@ nmi_stack_correct:
21951 xorl %edx,%edx # zero error code
21952 movl %esp,%eax # pt_regs pointer
21953 call do_nmi
21954 +
21955 + pax_exit_kernel
21956 +
21957 jmp restore_all_notrace
21958 CFI_ENDPROC
21959
21960 @@ -1409,12 +1654,15 @@ nmi_espfix_stack:
21961 FIXUP_ESPFIX_STACK # %eax == %esp
21962 xorl %edx,%edx # zero error code
21963 call do_nmi
21964 +
21965 + pax_exit_kernel
21966 +
21967 RESTORE_REGS
21968 lss 12+4(%esp), %esp # back to espfix stack
21969 CFI_ADJUST_CFA_OFFSET -24
21970 jmp irq_return
21971 CFI_ENDPROC
21972 -END(nmi)
21973 +ENDPROC(nmi)
21974
21975 ENTRY(int3)
21976 RING0_INT_FRAME
21977 @@ -1427,14 +1675,14 @@ ENTRY(int3)
21978 call do_int3
21979 jmp ret_from_exception
21980 CFI_ENDPROC
21981 -END(int3)
21982 +ENDPROC(int3)
21983
21984 ENTRY(general_protection)
21985 RING0_EC_FRAME
21986 pushl_cfi $do_general_protection
21987 jmp error_code
21988 CFI_ENDPROC
21989 -END(general_protection)
21990 +ENDPROC(general_protection)
21991
21992 #ifdef CONFIG_KVM_GUEST
21993 ENTRY(async_page_fault)
21994 @@ -1443,7 +1691,7 @@ ENTRY(async_page_fault)
21995 pushl_cfi $do_async_page_fault
21996 jmp error_code
21997 CFI_ENDPROC
21998 -END(async_page_fault)
21999 +ENDPROC(async_page_fault)
22000 #endif
22001
22002 /*
22003 diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
22004 index b077f4c..8e0df9f 100644
22005 --- a/arch/x86/kernel/entry_64.S
22006 +++ b/arch/x86/kernel/entry_64.S
22007 @@ -59,6 +59,8 @@
22008 #include <asm/context_tracking.h>
22009 #include <asm/smap.h>
22010 #include <linux/err.h>
22011 +#include <asm/pgtable.h>
22012 +#include <asm/alternative-asm.h>
22013
22014 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
22015 #include <linux/elf-em.h>
22016 @@ -80,8 +82,9 @@
22017 #ifdef CONFIG_DYNAMIC_FTRACE
22018
22019 ENTRY(function_hook)
22020 + pax_force_retaddr
22021 retq
22022 -END(function_hook)
22023 +ENDPROC(function_hook)
22024
22025 /* skip is set if stack has been adjusted */
22026 .macro ftrace_caller_setup skip=0
22027 @@ -122,8 +125,9 @@ GLOBAL(ftrace_graph_call)
22028 #endif
22029
22030 GLOBAL(ftrace_stub)
22031 + pax_force_retaddr
22032 retq
22033 -END(ftrace_caller)
22034 +ENDPROC(ftrace_caller)
22035
22036 ENTRY(ftrace_regs_caller)
22037 /* Save the current flags before compare (in SS location)*/
22038 @@ -191,7 +195,7 @@ ftrace_restore_flags:
22039 popfq
22040 jmp ftrace_stub
22041
22042 -END(ftrace_regs_caller)
22043 +ENDPROC(ftrace_regs_caller)
22044
22045
22046 #else /* ! CONFIG_DYNAMIC_FTRACE */
22047 @@ -212,6 +216,7 @@ ENTRY(function_hook)
22048 #endif
22049
22050 GLOBAL(ftrace_stub)
22051 + pax_force_retaddr
22052 retq
22053
22054 trace:
22055 @@ -225,12 +230,13 @@ trace:
22056 #endif
22057 subq $MCOUNT_INSN_SIZE, %rdi
22058
22059 + pax_force_fptr ftrace_trace_function
22060 call *ftrace_trace_function
22061
22062 MCOUNT_RESTORE_FRAME
22063
22064 jmp ftrace_stub
22065 -END(function_hook)
22066 +ENDPROC(function_hook)
22067 #endif /* CONFIG_DYNAMIC_FTRACE */
22068 #endif /* CONFIG_FUNCTION_TRACER */
22069
22070 @@ -252,8 +258,9 @@ ENTRY(ftrace_graph_caller)
22071
22072 MCOUNT_RESTORE_FRAME
22073
22074 + pax_force_retaddr
22075 retq
22076 -END(ftrace_graph_caller)
22077 +ENDPROC(ftrace_graph_caller)
22078
22079 GLOBAL(return_to_handler)
22080 subq $24, %rsp
22081 @@ -269,7 +276,9 @@ GLOBAL(return_to_handler)
22082 movq 8(%rsp), %rdx
22083 movq (%rsp), %rax
22084 addq $24, %rsp
22085 + pax_force_fptr %rdi
22086 jmp *%rdi
22087 +ENDPROC(return_to_handler)
22088 #endif
22089
22090
22091 @@ -284,6 +293,430 @@ ENTRY(native_usergs_sysret64)
22092 ENDPROC(native_usergs_sysret64)
22093 #endif /* CONFIG_PARAVIRT */
22094
22095 + .macro ljmpq sel, off
22096 +#if defined(CONFIG_MPSC) || defined(CONFIG_MCORE2) || defined (CONFIG_MATOM)
22097 + .byte 0x48; ljmp *1234f(%rip)
22098 + .pushsection .rodata
22099 + .align 16
22100 + 1234: .quad \off; .word \sel
22101 + .popsection
22102 +#else
22103 + pushq $\sel
22104 + pushq $\off
22105 + lretq
22106 +#endif
22107 + .endm
22108 +
22109 + .macro pax_enter_kernel
22110 + pax_set_fptr_mask
22111 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
22112 + call pax_enter_kernel
22113 +#endif
22114 + .endm
22115 +
22116 + .macro pax_exit_kernel
22117 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
22118 + call pax_exit_kernel
22119 +#endif
22120 +
22121 + .endm
22122 +
22123 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
22124 +ENTRY(pax_enter_kernel)
22125 + pushq %rdi
22126 +
22127 +#ifdef CONFIG_PARAVIRT
22128 + PV_SAVE_REGS(CLBR_RDI)
22129 +#endif
22130 +
22131 +#ifdef CONFIG_PAX_KERNEXEC
22132 + GET_CR0_INTO_RDI
22133 + bts $16,%rdi
22134 + jnc 3f
22135 + mov %cs,%edi
22136 + cmp $__KERNEL_CS,%edi
22137 + jnz 2f
22138 +1:
22139 +#endif
22140 +
22141 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22142 + 661: jmp 111f
22143 + .pushsection .altinstr_replacement, "a"
22144 + 662: ASM_NOP2
22145 + .popsection
22146 + .pushsection .altinstructions, "a"
22147 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
22148 + .popsection
22149 + GET_CR3_INTO_RDI
22150 + cmp $0,%dil
22151 + jnz 112f
22152 + mov $__KERNEL_DS,%edi
22153 + mov %edi,%ss
22154 + jmp 111f
22155 +112: cmp $1,%dil
22156 + jz 113f
22157 + ud2
22158 +113: sub $4097,%rdi
22159 + bts $63,%rdi
22160 + SET_RDI_INTO_CR3
22161 + mov $__UDEREF_KERNEL_DS,%edi
22162 + mov %edi,%ss
22163 +111:
22164 +#endif
22165 +
22166 +#ifdef CONFIG_PARAVIRT
22167 + PV_RESTORE_REGS(CLBR_RDI)
22168 +#endif
22169 +
22170 + popq %rdi
22171 + pax_force_retaddr
22172 + retq
22173 +
22174 +#ifdef CONFIG_PAX_KERNEXEC
22175 +2: ljmpq __KERNEL_CS,1b
22176 +3: ljmpq __KERNEXEC_KERNEL_CS,4f
22177 +4: SET_RDI_INTO_CR0
22178 + jmp 1b
22179 +#endif
22180 +ENDPROC(pax_enter_kernel)
22181 +
22182 +ENTRY(pax_exit_kernel)
22183 + pushq %rdi
22184 +
22185 +#ifdef CONFIG_PARAVIRT
22186 + PV_SAVE_REGS(CLBR_RDI)
22187 +#endif
22188 +
22189 +#ifdef CONFIG_PAX_KERNEXEC
22190 + mov %cs,%rdi
22191 + cmp $__KERNEXEC_KERNEL_CS,%edi
22192 + jz 2f
22193 + GET_CR0_INTO_RDI
22194 + bts $16,%rdi
22195 + jnc 4f
22196 +1:
22197 +#endif
22198 +
22199 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22200 + 661: jmp 111f
22201 + .pushsection .altinstr_replacement, "a"
22202 + 662: ASM_NOP2
22203 + .popsection
22204 + .pushsection .altinstructions, "a"
22205 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
22206 + .popsection
22207 + mov %ss,%edi
22208 + cmp $__UDEREF_KERNEL_DS,%edi
22209 + jnz 111f
22210 + GET_CR3_INTO_RDI
22211 + cmp $0,%dil
22212 + jz 112f
22213 + ud2
22214 +112: add $4097,%rdi
22215 + bts $63,%rdi
22216 + SET_RDI_INTO_CR3
22217 + mov $__KERNEL_DS,%edi
22218 + mov %edi,%ss
22219 +111:
22220 +#endif
22221 +
22222 +#ifdef CONFIG_PARAVIRT
22223 + PV_RESTORE_REGS(CLBR_RDI);
22224 +#endif
22225 +
22226 + popq %rdi
22227 + pax_force_retaddr
22228 + retq
22229 +
22230 +#ifdef CONFIG_PAX_KERNEXEC
22231 +2: GET_CR0_INTO_RDI
22232 + btr $16,%rdi
22233 + jnc 4f
22234 + ljmpq __KERNEL_CS,3f
22235 +3: SET_RDI_INTO_CR0
22236 + jmp 1b
22237 +4: ud2
22238 + jmp 4b
22239 +#endif
22240 +ENDPROC(pax_exit_kernel)
22241 +#endif
22242 +
22243 + .macro pax_enter_kernel_user
22244 + pax_set_fptr_mask
22245 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22246 + call pax_enter_kernel_user
22247 +#endif
22248 + .endm
22249 +
22250 + .macro pax_exit_kernel_user
22251 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22252 + call pax_exit_kernel_user
22253 +#endif
22254 +#ifdef CONFIG_PAX_RANDKSTACK
22255 + pushq %rax
22256 + pushq %r11
22257 + call pax_randomize_kstack
22258 + popq %r11
22259 + popq %rax
22260 +#endif
22261 + .endm
22262 +
22263 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22264 +ENTRY(pax_enter_kernel_user)
22265 + pushq %rdi
22266 + pushq %rbx
22267 +
22268 +#ifdef CONFIG_PARAVIRT
22269 + PV_SAVE_REGS(CLBR_RDI)
22270 +#endif
22271 +
22272 + 661: jmp 111f
22273 + .pushsection .altinstr_replacement, "a"
22274 + 662: ASM_NOP2
22275 + .popsection
22276 + .pushsection .altinstructions, "a"
22277 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
22278 + .popsection
22279 + GET_CR3_INTO_RDI
22280 + cmp $1,%dil
22281 + jnz 4f
22282 + sub $4097,%rdi
22283 + bts $63,%rdi
22284 + SET_RDI_INTO_CR3
22285 + jmp 3f
22286 +111:
22287 +
22288 + GET_CR3_INTO_RDI
22289 + mov %rdi,%rbx
22290 + add $__START_KERNEL_map,%rbx
22291 + sub phys_base(%rip),%rbx
22292 +
22293 +#ifdef CONFIG_PARAVIRT
22294 + cmpl $0, pv_info+PARAVIRT_enabled
22295 + jz 1f
22296 + pushq %rdi
22297 + i = 0
22298 + .rept USER_PGD_PTRS
22299 + mov i*8(%rbx),%rsi
22300 + mov $0,%sil
22301 + lea i*8(%rbx),%rdi
22302 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
22303 + i = i + 1
22304 + .endr
22305 + popq %rdi
22306 + jmp 2f
22307 +1:
22308 +#endif
22309 +
22310 + i = 0
22311 + .rept USER_PGD_PTRS
22312 + movb $0,i*8(%rbx)
22313 + i = i + 1
22314 + .endr
22315 +
22316 +2: SET_RDI_INTO_CR3
22317 +
22318 +#ifdef CONFIG_PAX_KERNEXEC
22319 + GET_CR0_INTO_RDI
22320 + bts $16,%rdi
22321 + SET_RDI_INTO_CR0
22322 +#endif
22323 +
22324 +3:
22325 +
22326 +#ifdef CONFIG_PARAVIRT
22327 + PV_RESTORE_REGS(CLBR_RDI)
22328 +#endif
22329 +
22330 + popq %rbx
22331 + popq %rdi
22332 + pax_force_retaddr
22333 + retq
22334 +4: ud2
22335 +ENDPROC(pax_enter_kernel_user)
22336 +
22337 +ENTRY(pax_exit_kernel_user)
22338 + pushq %rdi
22339 + pushq %rbx
22340 +
22341 +#ifdef CONFIG_PARAVIRT
22342 + PV_SAVE_REGS(CLBR_RDI)
22343 +#endif
22344 +
22345 + GET_CR3_INTO_RDI
22346 + 661: jmp 1f
22347 + .pushsection .altinstr_replacement, "a"
22348 + 662: ASM_NOP2
22349 + .popsection
22350 + .pushsection .altinstructions, "a"
22351 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
22352 + .popsection
22353 + cmp $0,%dil
22354 + jnz 3f
22355 + add $4097,%rdi
22356 + bts $63,%rdi
22357 + SET_RDI_INTO_CR3
22358 + jmp 2f
22359 +1:
22360 +
22361 + mov %rdi,%rbx
22362 +
22363 +#ifdef CONFIG_PAX_KERNEXEC
22364 + GET_CR0_INTO_RDI
22365 + btr $16,%rdi
22366 + jnc 3f
22367 + SET_RDI_INTO_CR0
22368 +#endif
22369 +
22370 + add $__START_KERNEL_map,%rbx
22371 + sub phys_base(%rip),%rbx
22372 +
22373 +#ifdef CONFIG_PARAVIRT
22374 + cmpl $0, pv_info+PARAVIRT_enabled
22375 + jz 1f
22376 + i = 0
22377 + .rept USER_PGD_PTRS
22378 + mov i*8(%rbx),%rsi
22379 + mov $0x67,%sil
22380 + lea i*8(%rbx),%rdi
22381 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
22382 + i = i + 1
22383 + .endr
22384 + jmp 2f
22385 +1:
22386 +#endif
22387 +
22388 + i = 0
22389 + .rept USER_PGD_PTRS
22390 + movb $0x67,i*8(%rbx)
22391 + i = i + 1
22392 + .endr
22393 +2:
22394 +
22395 +#ifdef CONFIG_PARAVIRT
22396 + PV_RESTORE_REGS(CLBR_RDI)
22397 +#endif
22398 +
22399 + popq %rbx
22400 + popq %rdi
22401 + pax_force_retaddr
22402 + retq
22403 +3: ud2
22404 +ENDPROC(pax_exit_kernel_user)
22405 +#endif
22406 +
22407 + .macro pax_enter_kernel_nmi
22408 + pax_set_fptr_mask
22409 +
22410 +#ifdef CONFIG_PAX_KERNEXEC
22411 + GET_CR0_INTO_RDI
22412 + bts $16,%rdi
22413 + jc 110f
22414 + SET_RDI_INTO_CR0
22415 + or $2,%ebx
22416 +110:
22417 +#endif
22418 +
22419 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22420 + 661: jmp 111f
22421 + .pushsection .altinstr_replacement, "a"
22422 + 662: ASM_NOP2
22423 + .popsection
22424 + .pushsection .altinstructions, "a"
22425 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
22426 + .popsection
22427 + GET_CR3_INTO_RDI
22428 + cmp $0,%dil
22429 + jz 111f
22430 + sub $4097,%rdi
22431 + or $4,%ebx
22432 + bts $63,%rdi
22433 + SET_RDI_INTO_CR3
22434 + mov $__UDEREF_KERNEL_DS,%edi
22435 + mov %edi,%ss
22436 +111:
22437 +#endif
22438 + .endm
22439 +
22440 + .macro pax_exit_kernel_nmi
22441 +#ifdef CONFIG_PAX_KERNEXEC
22442 + btr $1,%ebx
22443 + jnc 110f
22444 + GET_CR0_INTO_RDI
22445 + btr $16,%rdi
22446 + SET_RDI_INTO_CR0
22447 +110:
22448 +#endif
22449 +
22450 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22451 + btr $2,%ebx
22452 + jnc 111f
22453 + GET_CR3_INTO_RDI
22454 + add $4097,%rdi
22455 + bts $63,%rdi
22456 + SET_RDI_INTO_CR3
22457 + mov $__KERNEL_DS,%edi
22458 + mov %edi,%ss
22459 +111:
22460 +#endif
22461 + .endm
22462 +
22463 + .macro pax_erase_kstack
22464 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
22465 + call pax_erase_kstack
22466 +#endif
22467 + .endm
22468 +
22469 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
22470 +ENTRY(pax_erase_kstack)
22471 + pushq %rdi
22472 + pushq %rcx
22473 + pushq %rax
22474 + pushq %r11
22475 +
22476 + GET_THREAD_INFO(%r11)
22477 + mov TI_lowest_stack(%r11), %rdi
22478 + mov $-0xBEEF, %rax
22479 + std
22480 +
22481 +1: mov %edi, %ecx
22482 + and $THREAD_SIZE_asm - 1, %ecx
22483 + shr $3, %ecx
22484 + repne scasq
22485 + jecxz 2f
22486 +
22487 + cmp $2*8, %ecx
22488 + jc 2f
22489 +
22490 + mov $2*8, %ecx
22491 + repe scasq
22492 + jecxz 2f
22493 + jne 1b
22494 +
22495 +2: cld
22496 + mov %esp, %ecx
22497 + sub %edi, %ecx
22498 +
22499 + cmp $THREAD_SIZE_asm, %rcx
22500 + jb 3f
22501 + ud2
22502 +3:
22503 +
22504 + shr $3, %ecx
22505 + rep stosq
22506 +
22507 + mov TI_task_thread_sp0(%r11), %rdi
22508 + sub $256, %rdi
22509 + mov %rdi, TI_lowest_stack(%r11)
22510 +
22511 + popq %r11
22512 + popq %rax
22513 + popq %rcx
22514 + popq %rdi
22515 + pax_force_retaddr
22516 + ret
22517 +ENDPROC(pax_erase_kstack)
22518 +#endif
22519
22520 .macro TRACE_IRQS_IRETQ offset=ARGOFFSET
22521 #ifdef CONFIG_TRACE_IRQFLAGS
22522 @@ -320,7 +753,7 @@ ENDPROC(native_usergs_sysret64)
22523 .endm
22524
22525 .macro TRACE_IRQS_IRETQ_DEBUG offset=ARGOFFSET
22526 - bt $9,EFLAGS-\offset(%rsp) /* interrupts off? */
22527 + bt $X86_EFLAGS_IF_BIT,EFLAGS-\offset(%rsp) /* interrupts off? */
22528 jnc 1f
22529 TRACE_IRQS_ON_DEBUG
22530 1:
22531 @@ -358,27 +791,6 @@ ENDPROC(native_usergs_sysret64)
22532 movq \tmp,R11+\offset(%rsp)
22533 .endm
22534
22535 - .macro FAKE_STACK_FRAME child_rip
22536 - /* push in order ss, rsp, eflags, cs, rip */
22537 - xorl %eax, %eax
22538 - pushq_cfi $__KERNEL_DS /* ss */
22539 - /*CFI_REL_OFFSET ss,0*/
22540 - pushq_cfi %rax /* rsp */
22541 - CFI_REL_OFFSET rsp,0
22542 - pushq_cfi $(X86_EFLAGS_IF|X86_EFLAGS_FIXED) /* eflags - interrupts on */
22543 - /*CFI_REL_OFFSET rflags,0*/
22544 - pushq_cfi $__KERNEL_CS /* cs */
22545 - /*CFI_REL_OFFSET cs,0*/
22546 - pushq_cfi \child_rip /* rip */
22547 - CFI_REL_OFFSET rip,0
22548 - pushq_cfi %rax /* orig rax */
22549 - .endm
22550 -
22551 - .macro UNFAKE_STACK_FRAME
22552 - addq $8*6, %rsp
22553 - CFI_ADJUST_CFA_OFFSET -(6*8)
22554 - .endm
22555 -
22556 /*
22557 * initial frame state for interrupts (and exceptions without error code)
22558 */
22559 @@ -445,25 +857,26 @@ ENDPROC(native_usergs_sysret64)
22560 /* save partial stack frame */
22561 .macro SAVE_ARGS_IRQ
22562 cld
22563 - /* start from rbp in pt_regs and jump over */
22564 - movq_cfi rdi, (RDI-RBP)
22565 - movq_cfi rsi, (RSI-RBP)
22566 - movq_cfi rdx, (RDX-RBP)
22567 - movq_cfi rcx, (RCX-RBP)
22568 - movq_cfi rax, (RAX-RBP)
22569 - movq_cfi r8, (R8-RBP)
22570 - movq_cfi r9, (R9-RBP)
22571 - movq_cfi r10, (R10-RBP)
22572 - movq_cfi r11, (R11-RBP)
22573 + /* start from r15 in pt_regs and jump over */
22574 + movq_cfi rdi, RDI
22575 + movq_cfi rsi, RSI
22576 + movq_cfi rdx, RDX
22577 + movq_cfi rcx, RCX
22578 + movq_cfi rax, RAX
22579 + movq_cfi r8, R8
22580 + movq_cfi r9, R9
22581 + movq_cfi r10, R10
22582 + movq_cfi r11, R11
22583 + movq_cfi r12, R12
22584
22585 /* Save rbp so that we can unwind from get_irq_regs() */
22586 - movq_cfi rbp, 0
22587 + movq_cfi rbp, RBP
22588
22589 /* Save previous stack value */
22590 movq %rsp, %rsi
22591
22592 - leaq -RBP(%rsp),%rdi /* arg1 for handler */
22593 - testl $3, CS-RBP(%rsi)
22594 + movq %rsp,%rdi /* arg1 for handler */
22595 + testb $3, CS(%rsi)
22596 je 1f
22597 SWAPGS
22598 /*
22599 @@ -514,9 +927,10 @@ ENTRY(save_paranoid)
22600 js 1f /* negative -> in kernel */
22601 SWAPGS
22602 xorl %ebx,%ebx
22603 -1: ret
22604 +1: pax_force_retaddr_bts
22605 + ret
22606 CFI_ENDPROC
22607 -END(save_paranoid)
22608 +ENDPROC(save_paranoid)
22609 .popsection
22610
22611 /*
22612 @@ -538,7 +952,7 @@ ENTRY(ret_from_fork)
22613
22614 RESTORE_REST
22615
22616 - testl $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
22617 + testb $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
22618 jz 1f
22619
22620 testl $_TIF_IA32, TI_flags(%rcx) # 32-bit compat task needs IRET
22621 @@ -548,15 +962,13 @@ ENTRY(ret_from_fork)
22622 jmp ret_from_sys_call # go to the SYSRET fastpath
22623
22624 1:
22625 - subq $REST_SKIP, %rsp # leave space for volatiles
22626 - CFI_ADJUST_CFA_OFFSET REST_SKIP
22627 movq %rbp, %rdi
22628 call *%rbx
22629 movl $0, RAX(%rsp)
22630 RESTORE_REST
22631 jmp int_ret_from_sys_call
22632 CFI_ENDPROC
22633 -END(ret_from_fork)
22634 +ENDPROC(ret_from_fork)
22635
22636 /*
22637 * System call entry. Up to 6 arguments in registers are supported.
22638 @@ -593,7 +1005,7 @@ END(ret_from_fork)
22639 ENTRY(system_call)
22640 CFI_STARTPROC simple
22641 CFI_SIGNAL_FRAME
22642 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
22643 + CFI_DEF_CFA rsp,0
22644 CFI_REGISTER rip,rcx
22645 /*CFI_REGISTER rflags,r11*/
22646 SWAPGS_UNSAFE_STACK
22647 @@ -606,16 +1018,23 @@ GLOBAL(system_call_after_swapgs)
22648
22649 movq %rsp,PER_CPU_VAR(old_rsp)
22650 movq PER_CPU_VAR(kernel_stack),%rsp
22651 + SAVE_ARGS 8*6,0
22652 + pax_enter_kernel_user
22653 +
22654 +#ifdef CONFIG_PAX_RANDKSTACK
22655 + pax_erase_kstack
22656 +#endif
22657 +
22658 /*
22659 * No need to follow this irqs off/on section - it's straight
22660 * and short:
22661 */
22662 ENABLE_INTERRUPTS(CLBR_NONE)
22663 - SAVE_ARGS 8,0
22664 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
22665 movq %rcx,RIP-ARGOFFSET(%rsp)
22666 CFI_REL_OFFSET rip,RIP-ARGOFFSET
22667 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
22668 + GET_THREAD_INFO(%rcx)
22669 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%rcx)
22670 jnz tracesys
22671 system_call_fastpath:
22672 #if __SYSCALL_MASK == ~0
22673 @@ -639,10 +1058,13 @@ sysret_check:
22674 LOCKDEP_SYS_EXIT
22675 DISABLE_INTERRUPTS(CLBR_NONE)
22676 TRACE_IRQS_OFF
22677 - movl TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET),%edx
22678 + GET_THREAD_INFO(%rcx)
22679 + movl TI_flags(%rcx),%edx
22680 andl %edi,%edx
22681 jnz sysret_careful
22682 CFI_REMEMBER_STATE
22683 + pax_exit_kernel_user
22684 + pax_erase_kstack
22685 /*
22686 * sysretq will re-enable interrupts:
22687 */
22688 @@ -701,6 +1123,9 @@ auditsys:
22689 movq %rax,%rsi /* 2nd arg: syscall number */
22690 movl $AUDIT_ARCH_X86_64,%edi /* 1st arg: audit arch */
22691 call __audit_syscall_entry
22692 +
22693 + pax_erase_kstack
22694 +
22695 LOAD_ARGS 0 /* reload call-clobbered registers */
22696 jmp system_call_fastpath
22697
22698 @@ -722,7 +1147,7 @@ sysret_audit:
22699 /* Do syscall tracing */
22700 tracesys:
22701 #ifdef CONFIG_AUDITSYSCALL
22702 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
22703 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%rcx)
22704 jz auditsys
22705 #endif
22706 SAVE_REST
22707 @@ -730,12 +1155,15 @@ tracesys:
22708 FIXUP_TOP_OF_STACK %rdi
22709 movq %rsp,%rdi
22710 call syscall_trace_enter
22711 +
22712 + pax_erase_kstack
22713 +
22714 /*
22715 * Reload arg registers from stack in case ptrace changed them.
22716 * We don't reload %rax because syscall_trace_enter() returned
22717 * the value it wants us to use in the table lookup.
22718 */
22719 - LOAD_ARGS ARGOFFSET, 1
22720 + LOAD_ARGS 1
22721 RESTORE_REST
22722 #if __SYSCALL_MASK == ~0
22723 cmpq $__NR_syscall_max,%rax
22724 @@ -765,7 +1193,9 @@ GLOBAL(int_with_check)
22725 andl %edi,%edx
22726 jnz int_careful
22727 andl $~TS_COMPAT,TI_status(%rcx)
22728 - jmp retint_swapgs
22729 + pax_exit_kernel_user
22730 + pax_erase_kstack
22731 + jmp retint_swapgs_pax
22732
22733 /* Either reschedule or signal or syscall exit tracking needed. */
22734 /* First do a reschedule test. */
22735 @@ -811,7 +1241,7 @@ int_restore_rest:
22736 TRACE_IRQS_OFF
22737 jmp int_with_check
22738 CFI_ENDPROC
22739 -END(system_call)
22740 +ENDPROC(system_call)
22741
22742 .macro FORK_LIKE func
22743 ENTRY(stub_\func)
22744 @@ -824,9 +1254,10 @@ ENTRY(stub_\func)
22745 DEFAULT_FRAME 0 8 /* offset 8: return address */
22746 call sys_\func
22747 RESTORE_TOP_OF_STACK %r11, 8
22748 - ret $REST_SKIP /* pop extended registers */
22749 + pax_force_retaddr
22750 + ret
22751 CFI_ENDPROC
22752 -END(stub_\func)
22753 +ENDPROC(stub_\func)
22754 .endm
22755
22756 .macro FIXED_FRAME label,func
22757 @@ -836,9 +1267,10 @@ ENTRY(\label)
22758 FIXUP_TOP_OF_STACK %r11, 8-ARGOFFSET
22759 call \func
22760 RESTORE_TOP_OF_STACK %r11, 8-ARGOFFSET
22761 + pax_force_retaddr
22762 ret
22763 CFI_ENDPROC
22764 -END(\label)
22765 +ENDPROC(\label)
22766 .endm
22767
22768 FORK_LIKE clone
22769 @@ -846,19 +1278,6 @@ END(\label)
22770 FORK_LIKE vfork
22771 FIXED_FRAME stub_iopl, sys_iopl
22772
22773 -ENTRY(ptregscall_common)
22774 - DEFAULT_FRAME 1 8 /* offset 8: return address */
22775 - RESTORE_TOP_OF_STACK %r11, 8
22776 - movq_cfi_restore R15+8, r15
22777 - movq_cfi_restore R14+8, r14
22778 - movq_cfi_restore R13+8, r13
22779 - movq_cfi_restore R12+8, r12
22780 - movq_cfi_restore RBP+8, rbp
22781 - movq_cfi_restore RBX+8, rbx
22782 - ret $REST_SKIP /* pop extended registers */
22783 - CFI_ENDPROC
22784 -END(ptregscall_common)
22785 -
22786 ENTRY(stub_execve)
22787 CFI_STARTPROC
22788 addq $8, %rsp
22789 @@ -870,7 +1289,7 @@ ENTRY(stub_execve)
22790 RESTORE_REST
22791 jmp int_ret_from_sys_call
22792 CFI_ENDPROC
22793 -END(stub_execve)
22794 +ENDPROC(stub_execve)
22795
22796 /*
22797 * sigreturn is special because it needs to restore all registers on return.
22798 @@ -887,7 +1306,7 @@ ENTRY(stub_rt_sigreturn)
22799 RESTORE_REST
22800 jmp int_ret_from_sys_call
22801 CFI_ENDPROC
22802 -END(stub_rt_sigreturn)
22803 +ENDPROC(stub_rt_sigreturn)
22804
22805 #ifdef CONFIG_X86_X32_ABI
22806 ENTRY(stub_x32_rt_sigreturn)
22807 @@ -901,7 +1320,7 @@ ENTRY(stub_x32_rt_sigreturn)
22808 RESTORE_REST
22809 jmp int_ret_from_sys_call
22810 CFI_ENDPROC
22811 -END(stub_x32_rt_sigreturn)
22812 +ENDPROC(stub_x32_rt_sigreturn)
22813
22814 ENTRY(stub_x32_execve)
22815 CFI_STARTPROC
22816 @@ -915,7 +1334,7 @@ ENTRY(stub_x32_execve)
22817 RESTORE_REST
22818 jmp int_ret_from_sys_call
22819 CFI_ENDPROC
22820 -END(stub_x32_execve)
22821 +ENDPROC(stub_x32_execve)
22822
22823 #endif
22824
22825 @@ -952,7 +1371,7 @@ vector=vector+1
22826 2: jmp common_interrupt
22827 .endr
22828 CFI_ENDPROC
22829 -END(irq_entries_start)
22830 +ENDPROC(irq_entries_start)
22831
22832 .previous
22833 END(interrupt)
22834 @@ -969,9 +1388,19 @@ END(interrupt)
22835 /* 0(%rsp): ~(interrupt number) */
22836 .macro interrupt func
22837 /* reserve pt_regs for scratch regs and rbp */
22838 - subq $ORIG_RAX-RBP, %rsp
22839 - CFI_ADJUST_CFA_OFFSET ORIG_RAX-RBP
22840 + subq $ORIG_RAX, %rsp
22841 + CFI_ADJUST_CFA_OFFSET ORIG_RAX
22842 SAVE_ARGS_IRQ
22843 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22844 + testb $3, CS(%rdi)
22845 + jnz 1f
22846 + pax_enter_kernel
22847 + jmp 2f
22848 +1: pax_enter_kernel_user
22849 +2:
22850 +#else
22851 + pax_enter_kernel
22852 +#endif
22853 call \func
22854 .endm
22855
22856 @@ -997,14 +1426,14 @@ ret_from_intr:
22857
22858 /* Restore saved previous stack */
22859 popq %rsi
22860 - CFI_DEF_CFA rsi,SS+8-RBP /* reg/off reset after def_cfa_expr */
22861 - leaq ARGOFFSET-RBP(%rsi), %rsp
22862 + CFI_DEF_CFA rsi,SS+8 /* reg/off reset after def_cfa_expr */
22863 + movq %rsi, %rsp
22864 CFI_DEF_CFA_REGISTER rsp
22865 - CFI_ADJUST_CFA_OFFSET RBP-ARGOFFSET
22866 + CFI_ADJUST_CFA_OFFSET -ARGOFFSET
22867
22868 exit_intr:
22869 GET_THREAD_INFO(%rcx)
22870 - testl $3,CS-ARGOFFSET(%rsp)
22871 + testb $3,CS-ARGOFFSET(%rsp)
22872 je retint_kernel
22873
22874 /* Interrupt came from user space */
22875 @@ -1026,12 +1455,16 @@ retint_swapgs: /* return to user-space */
22876 * The iretq could re-enable interrupts:
22877 */
22878 DISABLE_INTERRUPTS(CLBR_ANY)
22879 + pax_exit_kernel_user
22880 +retint_swapgs_pax:
22881 TRACE_IRQS_IRETQ
22882 SWAPGS
22883 jmp restore_args
22884
22885 retint_restore_args: /* return to kernel space */
22886 DISABLE_INTERRUPTS(CLBR_ANY)
22887 + pax_exit_kernel
22888 + pax_force_retaddr (RIP-ARGOFFSET)
22889 /*
22890 * The iretq could re-enable interrupts:
22891 */
22892 @@ -1114,7 +1547,7 @@ ENTRY(retint_kernel)
22893 #endif
22894
22895 CFI_ENDPROC
22896 -END(common_interrupt)
22897 +ENDPROC(common_interrupt)
22898 /*
22899 * End of kprobes section
22900 */
22901 @@ -1132,7 +1565,7 @@ ENTRY(\sym)
22902 interrupt \do_sym
22903 jmp ret_from_intr
22904 CFI_ENDPROC
22905 -END(\sym)
22906 +ENDPROC(\sym)
22907 .endm
22908
22909 #ifdef CONFIG_TRACING
22910 @@ -1215,12 +1648,22 @@ ENTRY(\sym)
22911 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
22912 call error_entry
22913 DEFAULT_FRAME 0
22914 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22915 + testb $3, CS(%rsp)
22916 + jnz 1f
22917 + pax_enter_kernel
22918 + jmp 2f
22919 +1: pax_enter_kernel_user
22920 +2:
22921 +#else
22922 + pax_enter_kernel
22923 +#endif
22924 movq %rsp,%rdi /* pt_regs pointer */
22925 xorl %esi,%esi /* no error code */
22926 call \do_sym
22927 jmp error_exit /* %ebx: no swapgs flag */
22928 CFI_ENDPROC
22929 -END(\sym)
22930 +ENDPROC(\sym)
22931 .endm
22932
22933 .macro paranoidzeroentry sym do_sym
22934 @@ -1233,15 +1676,25 @@ ENTRY(\sym)
22935 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
22936 call save_paranoid
22937 TRACE_IRQS_OFF
22938 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22939 + testb $3, CS(%rsp)
22940 + jnz 1f
22941 + pax_enter_kernel
22942 + jmp 2f
22943 +1: pax_enter_kernel_user
22944 +2:
22945 +#else
22946 + pax_enter_kernel
22947 +#endif
22948 movq %rsp,%rdi /* pt_regs pointer */
22949 xorl %esi,%esi /* no error code */
22950 call \do_sym
22951 jmp paranoid_exit /* %ebx: no swapgs flag */
22952 CFI_ENDPROC
22953 -END(\sym)
22954 +ENDPROC(\sym)
22955 .endm
22956
22957 -#define INIT_TSS_IST(x) PER_CPU_VAR(init_tss) + (TSS_ist + ((x) - 1) * 8)
22958 +#define INIT_TSS_IST(x) (TSS_ist + ((x) - 1) * 8)(%r13)
22959 .macro paranoidzeroentry_ist sym do_sym ist
22960 ENTRY(\sym)
22961 INTR_FRAME
22962 @@ -1252,14 +1705,30 @@ ENTRY(\sym)
22963 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
22964 call save_paranoid
22965 TRACE_IRQS_OFF_DEBUG
22966 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22967 + testb $3, CS(%rsp)
22968 + jnz 1f
22969 + pax_enter_kernel
22970 + jmp 2f
22971 +1: pax_enter_kernel_user
22972 +2:
22973 +#else
22974 + pax_enter_kernel
22975 +#endif
22976 movq %rsp,%rdi /* pt_regs pointer */
22977 xorl %esi,%esi /* no error code */
22978 +#ifdef CONFIG_SMP
22979 + imul $TSS_size, PER_CPU_VAR(cpu_number), %r13d
22980 + lea init_tss(%r13), %r13
22981 +#else
22982 + lea init_tss(%rip), %r13
22983 +#endif
22984 subq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
22985 call \do_sym
22986 addq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
22987 jmp paranoid_exit /* %ebx: no swapgs flag */
22988 CFI_ENDPROC
22989 -END(\sym)
22990 +ENDPROC(\sym)
22991 .endm
22992
22993 .macro errorentry sym do_sym
22994 @@ -1271,13 +1740,23 @@ ENTRY(\sym)
22995 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
22996 call error_entry
22997 DEFAULT_FRAME 0
22998 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22999 + testb $3, CS(%rsp)
23000 + jnz 1f
23001 + pax_enter_kernel
23002 + jmp 2f
23003 +1: pax_enter_kernel_user
23004 +2:
23005 +#else
23006 + pax_enter_kernel
23007 +#endif
23008 movq %rsp,%rdi /* pt_regs pointer */
23009 movq ORIG_RAX(%rsp),%rsi /* get error code */
23010 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
23011 call \do_sym
23012 jmp error_exit /* %ebx: no swapgs flag */
23013 CFI_ENDPROC
23014 -END(\sym)
23015 +ENDPROC(\sym)
23016 .endm
23017
23018 /* error code is on the stack already */
23019 @@ -1291,13 +1770,23 @@ ENTRY(\sym)
23020 call save_paranoid
23021 DEFAULT_FRAME 0
23022 TRACE_IRQS_OFF
23023 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23024 + testb $3, CS(%rsp)
23025 + jnz 1f
23026 + pax_enter_kernel
23027 + jmp 2f
23028 +1: pax_enter_kernel_user
23029 +2:
23030 +#else
23031 + pax_enter_kernel
23032 +#endif
23033 movq %rsp,%rdi /* pt_regs pointer */
23034 movq ORIG_RAX(%rsp),%rsi /* get error code */
23035 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
23036 call \do_sym
23037 jmp paranoid_exit /* %ebx: no swapgs flag */
23038 CFI_ENDPROC
23039 -END(\sym)
23040 +ENDPROC(\sym)
23041 .endm
23042
23043 zeroentry divide_error do_divide_error
23044 @@ -1327,9 +1816,10 @@ gs_change:
23045 2: mfence /* workaround */
23046 SWAPGS
23047 popfq_cfi
23048 + pax_force_retaddr
23049 ret
23050 CFI_ENDPROC
23051 -END(native_load_gs_index)
23052 +ENDPROC(native_load_gs_index)
23053
23054 _ASM_EXTABLE(gs_change,bad_gs)
23055 .section .fixup,"ax"
23056 @@ -1357,9 +1847,10 @@ ENTRY(call_softirq)
23057 CFI_DEF_CFA_REGISTER rsp
23058 CFI_ADJUST_CFA_OFFSET -8
23059 decl PER_CPU_VAR(irq_count)
23060 + pax_force_retaddr
23061 ret
23062 CFI_ENDPROC
23063 -END(call_softirq)
23064 +ENDPROC(call_softirq)
23065
23066 #ifdef CONFIG_XEN
23067 zeroentry xen_hypervisor_callback xen_do_hypervisor_callback
23068 @@ -1397,7 +1888,7 @@ ENTRY(xen_do_hypervisor_callback) # do_hypervisor_callback(struct *pt_regs)
23069 decl PER_CPU_VAR(irq_count)
23070 jmp error_exit
23071 CFI_ENDPROC
23072 -END(xen_do_hypervisor_callback)
23073 +ENDPROC(xen_do_hypervisor_callback)
23074
23075 /*
23076 * Hypervisor uses this for application faults while it executes.
23077 @@ -1456,7 +1947,7 @@ ENTRY(xen_failsafe_callback)
23078 SAVE_ALL
23079 jmp error_exit
23080 CFI_ENDPROC
23081 -END(xen_failsafe_callback)
23082 +ENDPROC(xen_failsafe_callback)
23083
23084 apicinterrupt3 HYPERVISOR_CALLBACK_VECTOR \
23085 xen_hvm_callback_vector xen_evtchn_do_upcall
23086 @@ -1508,18 +1999,33 @@ ENTRY(paranoid_exit)
23087 DEFAULT_FRAME
23088 DISABLE_INTERRUPTS(CLBR_NONE)
23089 TRACE_IRQS_OFF_DEBUG
23090 - testl %ebx,%ebx /* swapgs needed? */
23091 + testl $1,%ebx /* swapgs needed? */
23092 jnz paranoid_restore
23093 - testl $3,CS(%rsp)
23094 + testb $3,CS(%rsp)
23095 jnz paranoid_userspace
23096 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23097 + pax_exit_kernel
23098 + TRACE_IRQS_IRETQ 0
23099 + SWAPGS_UNSAFE_STACK
23100 + RESTORE_ALL 8
23101 + pax_force_retaddr_bts
23102 + jmp irq_return
23103 +#endif
23104 paranoid_swapgs:
23105 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23106 + pax_exit_kernel_user
23107 +#else
23108 + pax_exit_kernel
23109 +#endif
23110 TRACE_IRQS_IRETQ 0
23111 SWAPGS_UNSAFE_STACK
23112 RESTORE_ALL 8
23113 jmp irq_return
23114 paranoid_restore:
23115 + pax_exit_kernel
23116 TRACE_IRQS_IRETQ_DEBUG 0
23117 RESTORE_ALL 8
23118 + pax_force_retaddr_bts
23119 jmp irq_return
23120 paranoid_userspace:
23121 GET_THREAD_INFO(%rcx)
23122 @@ -1548,7 +2054,7 @@ paranoid_schedule:
23123 TRACE_IRQS_OFF
23124 jmp paranoid_userspace
23125 CFI_ENDPROC
23126 -END(paranoid_exit)
23127 +ENDPROC(paranoid_exit)
23128
23129 /*
23130 * Exception entry point. This expects an error code/orig_rax on the stack.
23131 @@ -1575,12 +2081,13 @@ ENTRY(error_entry)
23132 movq_cfi r14, R14+8
23133 movq_cfi r15, R15+8
23134 xorl %ebx,%ebx
23135 - testl $3,CS+8(%rsp)
23136 + testb $3,CS+8(%rsp)
23137 je error_kernelspace
23138 error_swapgs:
23139 SWAPGS
23140 error_sti:
23141 TRACE_IRQS_OFF
23142 + pax_force_retaddr_bts
23143 ret
23144
23145 /*
23146 @@ -1607,7 +2114,7 @@ bstep_iret:
23147 movq %rcx,RIP+8(%rsp)
23148 jmp error_swapgs
23149 CFI_ENDPROC
23150 -END(error_entry)
23151 +ENDPROC(error_entry)
23152
23153
23154 /* ebx: no swapgs flag (1: don't need swapgs, 0: need it) */
23155 @@ -1618,7 +2125,7 @@ ENTRY(error_exit)
23156 DISABLE_INTERRUPTS(CLBR_NONE)
23157 TRACE_IRQS_OFF
23158 GET_THREAD_INFO(%rcx)
23159 - testl %eax,%eax
23160 + testl $1,%eax
23161 jne retint_kernel
23162 LOCKDEP_SYS_EXIT_IRQ
23163 movl TI_flags(%rcx),%edx
23164 @@ -1627,7 +2134,7 @@ ENTRY(error_exit)
23165 jnz retint_careful
23166 jmp retint_swapgs
23167 CFI_ENDPROC
23168 -END(error_exit)
23169 +ENDPROC(error_exit)
23170
23171 /*
23172 * Test if a given stack is an NMI stack or not.
23173 @@ -1685,9 +2192,11 @@ ENTRY(nmi)
23174 * If %cs was not the kernel segment, then the NMI triggered in user
23175 * space, which means it is definitely not nested.
23176 */
23177 + cmpl $__KERNEXEC_KERNEL_CS, 16(%rsp)
23178 + je 1f
23179 cmpl $__KERNEL_CS, 16(%rsp)
23180 jne first_nmi
23181 -
23182 +1:
23183 /*
23184 * Check the special variable on the stack to see if NMIs are
23185 * executing.
23186 @@ -1721,8 +2230,7 @@ nested_nmi:
23187
23188 1:
23189 /* Set up the interrupted NMIs stack to jump to repeat_nmi */
23190 - leaq -1*8(%rsp), %rdx
23191 - movq %rdx, %rsp
23192 + subq $8, %rsp
23193 CFI_ADJUST_CFA_OFFSET 1*8
23194 leaq -10*8(%rsp), %rdx
23195 pushq_cfi $__KERNEL_DS
23196 @@ -1740,6 +2248,7 @@ nested_nmi_out:
23197 CFI_RESTORE rdx
23198
23199 /* No need to check faults here */
23200 +# pax_force_retaddr_bts
23201 INTERRUPT_RETURN
23202
23203 CFI_RESTORE_STATE
23204 @@ -1852,9 +2361,11 @@ end_repeat_nmi:
23205 * NMI itself takes a page fault, the page fault that was preempted
23206 * will read the information from the NMI page fault and not the
23207 * origin fault. Save it off and restore it if it changes.
23208 - * Use the r12 callee-saved register.
23209 + * Use the r13 callee-saved register.
23210 */
23211 - movq %cr2, %r12
23212 + movq %cr2, %r13
23213 +
23214 + pax_enter_kernel_nmi
23215
23216 /* paranoidentry do_nmi, 0; without TRACE_IRQS_OFF */
23217 movq %rsp,%rdi
23218 @@ -1863,31 +2374,36 @@ end_repeat_nmi:
23219
23220 /* Did the NMI take a page fault? Restore cr2 if it did */
23221 movq %cr2, %rcx
23222 - cmpq %rcx, %r12
23223 + cmpq %rcx, %r13
23224 je 1f
23225 - movq %r12, %cr2
23226 + movq %r13, %cr2
23227 1:
23228
23229 - testl %ebx,%ebx /* swapgs needed? */
23230 + testl $1,%ebx /* swapgs needed? */
23231 jnz nmi_restore
23232 nmi_swapgs:
23233 SWAPGS_UNSAFE_STACK
23234 nmi_restore:
23235 + pax_exit_kernel_nmi
23236 /* Pop the extra iret frame at once */
23237 RESTORE_ALL 6*8
23238 + testb $3, 8(%rsp)
23239 + jnz 1f
23240 + pax_force_retaddr_bts
23241 +1:
23242
23243 /* Clear the NMI executing stack variable */
23244 movq $0, 5*8(%rsp)
23245 jmp irq_return
23246 CFI_ENDPROC
23247 -END(nmi)
23248 +ENDPROC(nmi)
23249
23250 ENTRY(ignore_sysret)
23251 CFI_STARTPROC
23252 mov $-ENOSYS,%eax
23253 sysret
23254 CFI_ENDPROC
23255 -END(ignore_sysret)
23256 +ENDPROC(ignore_sysret)
23257
23258 /*
23259 * End of kprobes section
23260 diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
23261 index d4bdd25..912664c 100644
23262 --- a/arch/x86/kernel/ftrace.c
23263 +++ b/arch/x86/kernel/ftrace.c
23264 @@ -105,6 +105,8 @@ ftrace_modify_code_direct(unsigned long ip, unsigned const char *old_code,
23265 {
23266 unsigned char replaced[MCOUNT_INSN_SIZE];
23267
23268 + ip = ktla_ktva(ip);
23269 +
23270 /*
23271 * Note: Due to modules and __init, code can
23272 * disappear and change, we need to protect against faulting
23273 @@ -227,7 +229,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
23274 unsigned char old[MCOUNT_INSN_SIZE], *new;
23275 int ret;
23276
23277 - memcpy(old, &ftrace_call, MCOUNT_INSN_SIZE);
23278 + memcpy(old, (void *)ktla_ktva((unsigned long)ftrace_call), MCOUNT_INSN_SIZE);
23279 new = ftrace_call_replace(ip, (unsigned long)func);
23280
23281 /* See comment above by declaration of modifying_ftrace_code */
23282 @@ -238,7 +240,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
23283 /* Also update the regs callback function */
23284 if (!ret) {
23285 ip = (unsigned long)(&ftrace_regs_call);
23286 - memcpy(old, &ftrace_regs_call, MCOUNT_INSN_SIZE);
23287 + memcpy(old, ktla_ktva((void *)&ftrace_regs_call), MCOUNT_INSN_SIZE);
23288 new = ftrace_call_replace(ip, (unsigned long)func);
23289 ret = ftrace_modify_code(ip, old, new);
23290 }
23291 @@ -291,7 +293,7 @@ static int ftrace_write(unsigned long ip, const char *val, int size)
23292 * kernel identity mapping to modify code.
23293 */
23294 if (within(ip, (unsigned long)_text, (unsigned long)_etext))
23295 - ip = (unsigned long)__va(__pa_symbol(ip));
23296 + ip = (unsigned long)__va(__pa_symbol(ktla_ktva(ip)));
23297
23298 return probe_kernel_write((void *)ip, val, size);
23299 }
23300 @@ -301,7 +303,7 @@ static int add_break(unsigned long ip, const char *old)
23301 unsigned char replaced[MCOUNT_INSN_SIZE];
23302 unsigned char brk = BREAKPOINT_INSTRUCTION;
23303
23304 - if (probe_kernel_read(replaced, (void *)ip, MCOUNT_INSN_SIZE))
23305 + if (probe_kernel_read(replaced, (void *)ktla_ktva(ip), MCOUNT_INSN_SIZE))
23306 return -EFAULT;
23307
23308 /* Make sure it is what we expect it to be */
23309 @@ -649,7 +651,7 @@ ftrace_modify_code(unsigned long ip, unsigned const char *old_code,
23310 return ret;
23311
23312 fail_update:
23313 - probe_kernel_write((void *)ip, &old_code[0], 1);
23314 + probe_kernel_write((void *)ktla_ktva(ip), &old_code[0], 1);
23315 goto out;
23316 }
23317
23318 @@ -682,6 +684,8 @@ static int ftrace_mod_jmp(unsigned long ip,
23319 {
23320 unsigned char code[MCOUNT_INSN_SIZE];
23321
23322 + ip = ktla_ktva(ip);
23323 +
23324 if (probe_kernel_read(code, (void *)ip, MCOUNT_INSN_SIZE))
23325 return -EFAULT;
23326
23327 diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c
23328 index 1be8e43..d9b9ef6 100644
23329 --- a/arch/x86/kernel/head64.c
23330 +++ b/arch/x86/kernel/head64.c
23331 @@ -67,12 +67,12 @@ again:
23332 pgd = *pgd_p;
23333
23334 /*
23335 - * The use of __START_KERNEL_map rather than __PAGE_OFFSET here is
23336 - * critical -- __PAGE_OFFSET would point us back into the dynamic
23337 + * The use of __early_va rather than __va here is critical:
23338 + * __va would point us back into the dynamic
23339 * range and we might end up looping forever...
23340 */
23341 if (pgd)
23342 - pud_p = (pudval_t *)((pgd & PTE_PFN_MASK) + __START_KERNEL_map - phys_base);
23343 + pud_p = (pudval_t *)(__early_va(pgd & PTE_PFN_MASK));
23344 else {
23345 if (next_early_pgt >= EARLY_DYNAMIC_PAGE_TABLES) {
23346 reset_early_page_tables();
23347 @@ -82,13 +82,13 @@ again:
23348 pud_p = (pudval_t *)early_dynamic_pgts[next_early_pgt++];
23349 for (i = 0; i < PTRS_PER_PUD; i++)
23350 pud_p[i] = 0;
23351 - *pgd_p = (pgdval_t)pud_p - __START_KERNEL_map + phys_base + _KERNPG_TABLE;
23352 + *pgd_p = (pgdval_t)__pa(pud_p) + _KERNPG_TABLE;
23353 }
23354 pud_p += pud_index(address);
23355 pud = *pud_p;
23356
23357 if (pud)
23358 - pmd_p = (pmdval_t *)((pud & PTE_PFN_MASK) + __START_KERNEL_map - phys_base);
23359 + pmd_p = (pmdval_t *)(__early_va(pud & PTE_PFN_MASK));
23360 else {
23361 if (next_early_pgt >= EARLY_DYNAMIC_PAGE_TABLES) {
23362 reset_early_page_tables();
23363 @@ -98,7 +98,7 @@ again:
23364 pmd_p = (pmdval_t *)early_dynamic_pgts[next_early_pgt++];
23365 for (i = 0; i < PTRS_PER_PMD; i++)
23366 pmd_p[i] = 0;
23367 - *pud_p = (pudval_t)pmd_p - __START_KERNEL_map + phys_base + _KERNPG_TABLE;
23368 + *pud_p = (pudval_t)__pa(pmd_p) + _KERNPG_TABLE;
23369 }
23370 pmd = (physaddr & PMD_MASK) + early_pmd_flags;
23371 pmd_p[pmd_index(address)] = pmd;
23372 @@ -175,7 +175,6 @@ asmlinkage void __init x86_64_start_kernel(char * real_mode_data)
23373 if (console_loglevel == 10)
23374 early_printk("Kernel alive\n");
23375
23376 - clear_page(init_level4_pgt);
23377 /* set init_level4_pgt kernel high mapping*/
23378 init_level4_pgt[511] = early_level4_pgt[511];
23379
23380 diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S
23381 index 81ba276..30c5411 100644
23382 --- a/arch/x86/kernel/head_32.S
23383 +++ b/arch/x86/kernel/head_32.S
23384 @@ -26,6 +26,12 @@
23385 /* Physical address */
23386 #define pa(X) ((X) - __PAGE_OFFSET)
23387
23388 +#ifdef CONFIG_PAX_KERNEXEC
23389 +#define ta(X) (X)
23390 +#else
23391 +#define ta(X) ((X) - __PAGE_OFFSET)
23392 +#endif
23393 +
23394 /*
23395 * References to members of the new_cpu_data structure.
23396 */
23397 @@ -55,11 +61,7 @@
23398 * and small than max_low_pfn, otherwise will waste some page table entries
23399 */
23400
23401 -#if PTRS_PER_PMD > 1
23402 -#define PAGE_TABLE_SIZE(pages) (((pages) / PTRS_PER_PMD) + PTRS_PER_PGD)
23403 -#else
23404 -#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PGD)
23405 -#endif
23406 +#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PTE)
23407
23408 /* Number of possible pages in the lowmem region */
23409 LOWMEM_PAGES = (((1<<32) - __PAGE_OFFSET) >> PAGE_SHIFT)
23410 @@ -78,6 +80,12 @@ INIT_MAP_SIZE = PAGE_TABLE_SIZE(KERNEL_PAGES) * PAGE_SIZE
23411 RESERVE_BRK(pagetables, INIT_MAP_SIZE)
23412
23413 /*
23414 + * Real beginning of normal "text" segment
23415 + */
23416 +ENTRY(stext)
23417 +ENTRY(_stext)
23418 +
23419 +/*
23420 * 32-bit kernel entrypoint; only used by the boot CPU. On entry,
23421 * %esi points to the real-mode code as a 32-bit pointer.
23422 * CS and DS must be 4 GB flat segments, but we don't depend on
23423 @@ -85,6 +93,13 @@ RESERVE_BRK(pagetables, INIT_MAP_SIZE)
23424 * can.
23425 */
23426 __HEAD
23427 +
23428 +#ifdef CONFIG_PAX_KERNEXEC
23429 + jmp startup_32
23430 +/* PaX: fill first page in .text with int3 to catch NULL derefs in kernel mode */
23431 +.fill PAGE_SIZE-5,1,0xcc
23432 +#endif
23433 +
23434 ENTRY(startup_32)
23435 movl pa(stack_start),%ecx
23436
23437 @@ -106,6 +121,59 @@ ENTRY(startup_32)
23438 2:
23439 leal -__PAGE_OFFSET(%ecx),%esp
23440
23441 +#ifdef CONFIG_SMP
23442 + movl $pa(cpu_gdt_table),%edi
23443 + movl $__per_cpu_load,%eax
23444 + movw %ax,GDT_ENTRY_PERCPU * 8 + 2(%edi)
23445 + rorl $16,%eax
23446 + movb %al,GDT_ENTRY_PERCPU * 8 + 4(%edi)
23447 + movb %ah,GDT_ENTRY_PERCPU * 8 + 7(%edi)
23448 + movl $__per_cpu_end - 1,%eax
23449 + subl $__per_cpu_start,%eax
23450 + movw %ax,GDT_ENTRY_PERCPU * 8 + 0(%edi)
23451 +#endif
23452 +
23453 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23454 + movl $NR_CPUS,%ecx
23455 + movl $pa(cpu_gdt_table),%edi
23456 +1:
23457 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c09700),GDT_ENTRY_KERNEL_DS * 8 + 4(%edi)
23458 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0fb00),GDT_ENTRY_DEFAULT_USER_CS * 8 + 4(%edi)
23459 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0f300),GDT_ENTRY_DEFAULT_USER_DS * 8 + 4(%edi)
23460 + addl $PAGE_SIZE_asm,%edi
23461 + loop 1b
23462 +#endif
23463 +
23464 +#ifdef CONFIG_PAX_KERNEXEC
23465 + movl $pa(boot_gdt),%edi
23466 + movl $__LOAD_PHYSICAL_ADDR,%eax
23467 + movw %ax,GDT_ENTRY_BOOT_CS * 8 + 2(%edi)
23468 + rorl $16,%eax
23469 + movb %al,GDT_ENTRY_BOOT_CS * 8 + 4(%edi)
23470 + movb %ah,GDT_ENTRY_BOOT_CS * 8 + 7(%edi)
23471 + rorl $16,%eax
23472 +
23473 + ljmp $(__BOOT_CS),$1f
23474 +1:
23475 +
23476 + movl $NR_CPUS,%ecx
23477 + movl $pa(cpu_gdt_table),%edi
23478 + addl $__PAGE_OFFSET,%eax
23479 +1:
23480 + movb $0xc0,GDT_ENTRY_KERNEL_CS * 8 + 6(%edi)
23481 + movb $0xc0,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 6(%edi)
23482 + movw %ax,GDT_ENTRY_KERNEL_CS * 8 + 2(%edi)
23483 + movw %ax,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 2(%edi)
23484 + rorl $16,%eax
23485 + movb %al,GDT_ENTRY_KERNEL_CS * 8 + 4(%edi)
23486 + movb %al,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 4(%edi)
23487 + movb %ah,GDT_ENTRY_KERNEL_CS * 8 + 7(%edi)
23488 + movb %ah,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 7(%edi)
23489 + rorl $16,%eax
23490 + addl $PAGE_SIZE_asm,%edi
23491 + loop 1b
23492 +#endif
23493 +
23494 /*
23495 * Clear BSS first so that there are no surprises...
23496 */
23497 @@ -201,8 +269,11 @@ ENTRY(startup_32)
23498 movl %eax, pa(max_pfn_mapped)
23499
23500 /* Do early initialization of the fixmap area */
23501 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
23502 - movl %eax,pa(initial_pg_pmd+0x1000*KPMDS-8)
23503 +#ifdef CONFIG_COMPAT_VDSO
23504 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_pg_pmd+0x1000*KPMDS-8)
23505 +#else
23506 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_pg_pmd+0x1000*KPMDS-8)
23507 +#endif
23508 #else /* Not PAE */
23509
23510 page_pde_offset = (__PAGE_OFFSET >> 20);
23511 @@ -232,8 +303,11 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
23512 movl %eax, pa(max_pfn_mapped)
23513
23514 /* Do early initialization of the fixmap area */
23515 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
23516 - movl %eax,pa(initial_page_table+0xffc)
23517 +#ifdef CONFIG_COMPAT_VDSO
23518 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_page_table+0xffc)
23519 +#else
23520 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_page_table+0xffc)
23521 +#endif
23522 #endif
23523
23524 #ifdef CONFIG_PARAVIRT
23525 @@ -247,9 +321,7 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
23526 cmpl $num_subarch_entries, %eax
23527 jae bad_subarch
23528
23529 - movl pa(subarch_entries)(,%eax,4), %eax
23530 - subl $__PAGE_OFFSET, %eax
23531 - jmp *%eax
23532 + jmp *pa(subarch_entries)(,%eax,4)
23533
23534 bad_subarch:
23535 WEAK(lguest_entry)
23536 @@ -261,10 +333,10 @@ WEAK(xen_entry)
23537 __INITDATA
23538
23539 subarch_entries:
23540 - .long default_entry /* normal x86/PC */
23541 - .long lguest_entry /* lguest hypervisor */
23542 - .long xen_entry /* Xen hypervisor */
23543 - .long default_entry /* Moorestown MID */
23544 + .long ta(default_entry) /* normal x86/PC */
23545 + .long ta(lguest_entry) /* lguest hypervisor */
23546 + .long ta(xen_entry) /* Xen hypervisor */
23547 + .long ta(default_entry) /* Moorestown MID */
23548 num_subarch_entries = (. - subarch_entries) / 4
23549 .previous
23550 #else
23551 @@ -354,6 +426,7 @@ default_entry:
23552 movl pa(mmu_cr4_features),%eax
23553 movl %eax,%cr4
23554
23555 +#ifdef CONFIG_X86_PAE
23556 testb $X86_CR4_PAE, %al # check if PAE is enabled
23557 jz enable_paging
23558
23559 @@ -382,6 +455,9 @@ default_entry:
23560 /* Make changes effective */
23561 wrmsr
23562
23563 + btsl $_PAGE_BIT_NX-32,pa(__supported_pte_mask+4)
23564 +#endif
23565 +
23566 enable_paging:
23567
23568 /*
23569 @@ -449,14 +525,20 @@ is486:
23570 1: movl $(__KERNEL_DS),%eax # reload all the segment registers
23571 movl %eax,%ss # after changing gdt.
23572
23573 - movl $(__USER_DS),%eax # DS/ES contains default USER segment
23574 +# movl $(__KERNEL_DS),%eax # DS/ES contains default KERNEL segment
23575 movl %eax,%ds
23576 movl %eax,%es
23577
23578 movl $(__KERNEL_PERCPU), %eax
23579 movl %eax,%fs # set this cpu's percpu
23580
23581 +#ifdef CONFIG_CC_STACKPROTECTOR
23582 movl $(__KERNEL_STACK_CANARY),%eax
23583 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
23584 + movl $(__USER_DS),%eax
23585 +#else
23586 + xorl %eax,%eax
23587 +#endif
23588 movl %eax,%gs
23589
23590 xorl %eax,%eax # Clear LDT
23591 @@ -512,8 +594,11 @@ setup_once:
23592 * relocation. Manually set base address in stack canary
23593 * segment descriptor.
23594 */
23595 - movl $gdt_page,%eax
23596 + movl $cpu_gdt_table,%eax
23597 movl $stack_canary,%ecx
23598 +#ifdef CONFIG_SMP
23599 + addl $__per_cpu_load,%ecx
23600 +#endif
23601 movw %cx, 8 * GDT_ENTRY_STACK_CANARY + 2(%eax)
23602 shrl $16, %ecx
23603 movb %cl, 8 * GDT_ENTRY_STACK_CANARY + 4(%eax)
23604 @@ -544,7 +629,7 @@ ENDPROC(early_idt_handlers)
23605 /* This is global to keep gas from relaxing the jumps */
23606 ENTRY(early_idt_handler)
23607 cld
23608 - cmpl $2,%ss:early_recursion_flag
23609 + cmpl $1,%ss:early_recursion_flag
23610 je hlt_loop
23611 incl %ss:early_recursion_flag
23612
23613 @@ -582,8 +667,8 @@ ENTRY(early_idt_handler)
23614 pushl (20+6*4)(%esp) /* trapno */
23615 pushl $fault_msg
23616 call printk
23617 -#endif
23618 call dump_stack
23619 +#endif
23620 hlt_loop:
23621 hlt
23622 jmp hlt_loop
23623 @@ -602,8 +687,11 @@ ENDPROC(early_idt_handler)
23624 /* This is the default interrupt "handler" :-) */
23625 ALIGN
23626 ignore_int:
23627 - cld
23628 #ifdef CONFIG_PRINTK
23629 + cmpl $2,%ss:early_recursion_flag
23630 + je hlt_loop
23631 + incl %ss:early_recursion_flag
23632 + cld
23633 pushl %eax
23634 pushl %ecx
23635 pushl %edx
23636 @@ -612,9 +700,6 @@ ignore_int:
23637 movl $(__KERNEL_DS),%eax
23638 movl %eax,%ds
23639 movl %eax,%es
23640 - cmpl $2,early_recursion_flag
23641 - je hlt_loop
23642 - incl early_recursion_flag
23643 pushl 16(%esp)
23644 pushl 24(%esp)
23645 pushl 32(%esp)
23646 @@ -648,29 +733,34 @@ ENTRY(setup_once_ref)
23647 /*
23648 * BSS section
23649 */
23650 -__PAGE_ALIGNED_BSS
23651 - .align PAGE_SIZE
23652 #ifdef CONFIG_X86_PAE
23653 +.section .initial_pg_pmd,"a",@progbits
23654 initial_pg_pmd:
23655 .fill 1024*KPMDS,4,0
23656 #else
23657 +.section .initial_page_table,"a",@progbits
23658 ENTRY(initial_page_table)
23659 .fill 1024,4,0
23660 #endif
23661 +.section .initial_pg_fixmap,"a",@progbits
23662 initial_pg_fixmap:
23663 .fill 1024,4,0
23664 +.section .empty_zero_page,"a",@progbits
23665 ENTRY(empty_zero_page)
23666 .fill 4096,1,0
23667 +.section .swapper_pg_dir,"a",@progbits
23668 ENTRY(swapper_pg_dir)
23669 +#ifdef CONFIG_X86_PAE
23670 + .fill 4,8,0
23671 +#else
23672 .fill 1024,4,0
23673 +#endif
23674
23675 /*
23676 * This starts the data section.
23677 */
23678 #ifdef CONFIG_X86_PAE
23679 -__PAGE_ALIGNED_DATA
23680 - /* Page-aligned for the benefit of paravirt? */
23681 - .align PAGE_SIZE
23682 +.section .initial_page_table,"a",@progbits
23683 ENTRY(initial_page_table)
23684 .long pa(initial_pg_pmd+PGD_IDENT_ATTR),0 /* low identity map */
23685 # if KPMDS == 3
23686 @@ -689,12 +779,20 @@ ENTRY(initial_page_table)
23687 # error "Kernel PMDs should be 1, 2 or 3"
23688 # endif
23689 .align PAGE_SIZE /* needs to be page-sized too */
23690 +
23691 +#ifdef CONFIG_PAX_PER_CPU_PGD
23692 +ENTRY(cpu_pgd)
23693 + .rept 2*NR_CPUS
23694 + .fill 4,8,0
23695 + .endr
23696 +#endif
23697 +
23698 #endif
23699
23700 .data
23701 .balign 4
23702 ENTRY(stack_start)
23703 - .long init_thread_union+THREAD_SIZE
23704 + .long init_thread_union+THREAD_SIZE-8
23705
23706 __INITRODATA
23707 int_msg:
23708 @@ -722,7 +820,7 @@ fault_msg:
23709 * segment size, and 32-bit linear address value:
23710 */
23711
23712 - .data
23713 +.section .rodata,"a",@progbits
23714 .globl boot_gdt_descr
23715 .globl idt_descr
23716
23717 @@ -731,7 +829,7 @@ fault_msg:
23718 .word 0 # 32 bit align gdt_desc.address
23719 boot_gdt_descr:
23720 .word __BOOT_DS+7
23721 - .long boot_gdt - __PAGE_OFFSET
23722 + .long pa(boot_gdt)
23723
23724 .word 0 # 32-bit align idt_desc.address
23725 idt_descr:
23726 @@ -742,7 +840,7 @@ idt_descr:
23727 .word 0 # 32 bit align gdt_desc.address
23728 ENTRY(early_gdt_descr)
23729 .word GDT_ENTRIES*8-1
23730 - .long gdt_page /* Overwritten for secondary CPUs */
23731 + .long cpu_gdt_table /* Overwritten for secondary CPUs */
23732
23733 /*
23734 * The boot_gdt must mirror the equivalent in setup.S and is
23735 @@ -751,5 +849,65 @@ ENTRY(early_gdt_descr)
23736 .align L1_CACHE_BYTES
23737 ENTRY(boot_gdt)
23738 .fill GDT_ENTRY_BOOT_CS,8,0
23739 - .quad 0x00cf9a000000ffff /* kernel 4GB code at 0x00000000 */
23740 - .quad 0x00cf92000000ffff /* kernel 4GB data at 0x00000000 */
23741 + .quad 0x00cf9b000000ffff /* kernel 4GB code at 0x00000000 */
23742 + .quad 0x00cf93000000ffff /* kernel 4GB data at 0x00000000 */
23743 +
23744 + .align PAGE_SIZE_asm
23745 +ENTRY(cpu_gdt_table)
23746 + .rept NR_CPUS
23747 + .quad 0x0000000000000000 /* NULL descriptor */
23748 + .quad 0x0000000000000000 /* 0x0b reserved */
23749 + .quad 0x0000000000000000 /* 0x13 reserved */
23750 + .quad 0x0000000000000000 /* 0x1b reserved */
23751 +
23752 +#ifdef CONFIG_PAX_KERNEXEC
23753 + .quad 0x00cf9b000000ffff /* 0x20 alternate kernel 4GB code at 0x00000000 */
23754 +#else
23755 + .quad 0x0000000000000000 /* 0x20 unused */
23756 +#endif
23757 +
23758 + .quad 0x0000000000000000 /* 0x28 unused */
23759 + .quad 0x0000000000000000 /* 0x33 TLS entry 1 */
23760 + .quad 0x0000000000000000 /* 0x3b TLS entry 2 */
23761 + .quad 0x0000000000000000 /* 0x43 TLS entry 3 */
23762 + .quad 0x0000000000000000 /* 0x4b reserved */
23763 + .quad 0x0000000000000000 /* 0x53 reserved */
23764 + .quad 0x0000000000000000 /* 0x5b reserved */
23765 +
23766 + .quad 0x00cf9b000000ffff /* 0x60 kernel 4GB code at 0x00000000 */
23767 + .quad 0x00cf93000000ffff /* 0x68 kernel 4GB data at 0x00000000 */
23768 + .quad 0x00cffb000000ffff /* 0x73 user 4GB code at 0x00000000 */
23769 + .quad 0x00cff3000000ffff /* 0x7b user 4GB data at 0x00000000 */
23770 +
23771 + .quad 0x0000000000000000 /* 0x80 TSS descriptor */
23772 + .quad 0x0000000000000000 /* 0x88 LDT descriptor */
23773 +
23774 + /*
23775 + * Segments used for calling PnP BIOS have byte granularity.
23776 + * The code segments and data segments have fixed 64k limits,
23777 + * the transfer segment sizes are set at run time.
23778 + */
23779 + .quad 0x00409b000000ffff /* 0x90 32-bit code */
23780 + .quad 0x00009b000000ffff /* 0x98 16-bit code */
23781 + .quad 0x000093000000ffff /* 0xa0 16-bit data */
23782 + .quad 0x0000930000000000 /* 0xa8 16-bit data */
23783 + .quad 0x0000930000000000 /* 0xb0 16-bit data */
23784 +
23785 + /*
23786 + * The APM segments have byte granularity and their bases
23787 + * are set at run time. All have 64k limits.
23788 + */
23789 + .quad 0x00409b000000ffff /* 0xb8 APM CS code */
23790 + .quad 0x00009b000000ffff /* 0xc0 APM CS 16 code (16 bit) */
23791 + .quad 0x004093000000ffff /* 0xc8 APM DS data */
23792 +
23793 + .quad 0x00c0930000000000 /* 0xd0 - ESPFIX SS */
23794 + .quad 0x0040930000000000 /* 0xd8 - PERCPU */
23795 + .quad 0x0040910000000017 /* 0xe0 - STACK_CANARY */
23796 + .quad 0x0000000000000000 /* 0xe8 - PCIBIOS_CS */
23797 + .quad 0x0000000000000000 /* 0xf0 - PCIBIOS_DS */
23798 + .quad 0x0000000000000000 /* 0xf8 - GDT entry 31: double-fault TSS */
23799 +
23800 + /* Be sure this is zeroed to avoid false validations in Xen */
23801 + .fill PAGE_SIZE_asm - GDT_SIZE,1,0
23802 + .endr
23803 diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
23804 index e1aabdb..fee4fee 100644
23805 --- a/arch/x86/kernel/head_64.S
23806 +++ b/arch/x86/kernel/head_64.S
23807 @@ -20,6 +20,8 @@
23808 #include <asm/processor-flags.h>
23809 #include <asm/percpu.h>
23810 #include <asm/nops.h>
23811 +#include <asm/cpufeature.h>
23812 +#include <asm/alternative-asm.h>
23813
23814 #ifdef CONFIG_PARAVIRT
23815 #include <asm/asm-offsets.h>
23816 @@ -41,6 +43,12 @@ L4_PAGE_OFFSET = pgd_index(__PAGE_OFFSET)
23817 L3_PAGE_OFFSET = pud_index(__PAGE_OFFSET)
23818 L4_START_KERNEL = pgd_index(__START_KERNEL_map)
23819 L3_START_KERNEL = pud_index(__START_KERNEL_map)
23820 +L4_VMALLOC_START = pgd_index(VMALLOC_START)
23821 +L3_VMALLOC_START = pud_index(VMALLOC_START)
23822 +L4_VMALLOC_END = pgd_index(VMALLOC_END)
23823 +L3_VMALLOC_END = pud_index(VMALLOC_END)
23824 +L4_VMEMMAP_START = pgd_index(VMEMMAP_START)
23825 +L3_VMEMMAP_START = pud_index(VMEMMAP_START)
23826
23827 .text
23828 __HEAD
23829 @@ -89,11 +97,24 @@ startup_64:
23830 * Fixup the physical addresses in the page table
23831 */
23832 addq %rbp, early_level4_pgt + (L4_START_KERNEL*8)(%rip)
23833 + addq %rbp, init_level4_pgt + (L4_PAGE_OFFSET*8)(%rip)
23834 + addq %rbp, init_level4_pgt + (L4_VMALLOC_START*8)(%rip)
23835 + addq %rbp, init_level4_pgt + (L4_VMALLOC_END*8)(%rip)
23836 + addq %rbp, init_level4_pgt + (L4_VMEMMAP_START*8)(%rip)
23837 + addq %rbp, init_level4_pgt + (L4_START_KERNEL*8)(%rip)
23838
23839 - addq %rbp, level3_kernel_pgt + (510*8)(%rip)
23840 - addq %rbp, level3_kernel_pgt + (511*8)(%rip)
23841 + addq %rbp, level3_ident_pgt + (0*8)(%rip)
23842 +#ifndef CONFIG_XEN
23843 + addq %rbp, level3_ident_pgt + (1*8)(%rip)
23844 +#endif
23845 +
23846 + addq %rbp, level3_vmemmap_pgt + (L3_VMEMMAP_START*8)(%rip)
23847 +
23848 + addq %rbp, level3_kernel_pgt + (L3_START_KERNEL*8)(%rip)
23849 + addq %rbp, level3_kernel_pgt + ((L3_START_KERNEL+1)*8)(%rip)
23850
23851 addq %rbp, level2_fixmap_pgt + (506*8)(%rip)
23852 + addq %rbp, level2_fixmap_pgt + (507*8)(%rip)
23853
23854 /*
23855 * Set up the identity mapping for the switchover. These
23856 @@ -177,8 +198,8 @@ ENTRY(secondary_startup_64)
23857 movq $(init_level4_pgt - __START_KERNEL_map), %rax
23858 1:
23859
23860 - /* Enable PAE mode and PGE */
23861 - movl $(X86_CR4_PAE | X86_CR4_PGE), %ecx
23862 + /* Enable PAE mode and PSE/PGE */
23863 + movl $(X86_CR4_PSE | X86_CR4_PAE | X86_CR4_PGE), %ecx
23864 movq %rcx, %cr4
23865
23866 /* Setup early boot stage 4 level pagetables. */
23867 @@ -199,10 +220,19 @@ ENTRY(secondary_startup_64)
23868 movl $MSR_EFER, %ecx
23869 rdmsr
23870 btsl $_EFER_SCE, %eax /* Enable System Call */
23871 - btl $20,%edi /* No Execute supported? */
23872 + btl $(X86_FEATURE_NX & 31),%edi /* No Execute supported? */
23873 jnc 1f
23874 btsl $_EFER_NX, %eax
23875 btsq $_PAGE_BIT_NX,early_pmd_flags(%rip)
23876 +#ifndef CONFIG_EFI
23877 + btsq $_PAGE_BIT_NX, init_level4_pgt + 8*L4_PAGE_OFFSET(%rip)
23878 +#endif
23879 + btsq $_PAGE_BIT_NX, init_level4_pgt + 8*L4_VMALLOC_START(%rip)
23880 + btsq $_PAGE_BIT_NX, init_level4_pgt + 8*L4_VMALLOC_END(%rip)
23881 + btsq $_PAGE_BIT_NX, init_level4_pgt + 8*L4_VMEMMAP_START(%rip)
23882 + btsq $_PAGE_BIT_NX, level2_fixmap_pgt + 8*506(%rip)
23883 + btsq $_PAGE_BIT_NX, level2_fixmap_pgt + 8*507(%rip)
23884 + btsq $_PAGE_BIT_NX, __supported_pte_mask(%rip)
23885 1: wrmsr /* Make changes effective */
23886
23887 /* Setup cr0 */
23888 @@ -282,6 +312,7 @@ ENTRY(secondary_startup_64)
23889 * REX.W + FF /5 JMP m16:64 Jump far, absolute indirect,
23890 * address given in m16:64.
23891 */
23892 + pax_set_fptr_mask
23893 movq initial_code(%rip),%rax
23894 pushq $0 # fake return address to stop unwinder
23895 pushq $__KERNEL_CS # set correct cs
23896 @@ -388,7 +419,7 @@ ENTRY(early_idt_handler)
23897 call dump_stack
23898 #ifdef CONFIG_KALLSYMS
23899 leaq early_idt_ripmsg(%rip),%rdi
23900 - movq 40(%rsp),%rsi # %rip again
23901 + movq 88(%rsp),%rsi # %rip again
23902 call __print_symbol
23903 #endif
23904 #endif /* EARLY_PRINTK */
23905 @@ -416,6 +447,7 @@ ENDPROC(early_idt_handler)
23906 early_recursion_flag:
23907 .long 0
23908
23909 + .section .rodata,"a",@progbits
23910 #ifdef CONFIG_EARLY_PRINTK
23911 early_idt_msg:
23912 .asciz "PANIC: early exception %02lx rip %lx:%lx error %lx cr2 %lx\n"
23913 @@ -443,29 +475,52 @@ NEXT_PAGE(early_level4_pgt)
23914 NEXT_PAGE(early_dynamic_pgts)
23915 .fill 512*EARLY_DYNAMIC_PAGE_TABLES,8,0
23916
23917 - .data
23918 + .section .rodata,"a",@progbits
23919
23920 -#ifndef CONFIG_XEN
23921 NEXT_PAGE(init_level4_pgt)
23922 - .fill 512,8,0
23923 -#else
23924 -NEXT_PAGE(init_level4_pgt)
23925 - .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
23926 .org init_level4_pgt + L4_PAGE_OFFSET*8, 0
23927 .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
23928 + .org init_level4_pgt + L4_VMALLOC_START*8, 0
23929 + .quad level3_vmalloc_start_pgt - __START_KERNEL_map + _KERNPG_TABLE
23930 + .org init_level4_pgt + L4_VMALLOC_END*8, 0
23931 + .quad level3_vmalloc_end_pgt - __START_KERNEL_map + _KERNPG_TABLE
23932 + .org init_level4_pgt + L4_VMEMMAP_START*8, 0
23933 + .quad level3_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
23934 .org init_level4_pgt + L4_START_KERNEL*8, 0
23935 /* (2^48-(2*1024*1024*1024))/(2^39) = 511 */
23936 .quad level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE
23937
23938 +#ifdef CONFIG_PAX_PER_CPU_PGD
23939 +NEXT_PAGE(cpu_pgd)
23940 + .rept 2*NR_CPUS
23941 + .fill 512,8,0
23942 + .endr
23943 +#endif
23944 +
23945 NEXT_PAGE(level3_ident_pgt)
23946 .quad level2_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
23947 +#ifdef CONFIG_XEN
23948 .fill 511, 8, 0
23949 +#else
23950 + .quad level2_ident_pgt + PAGE_SIZE - __START_KERNEL_map + _KERNPG_TABLE
23951 + .fill 510,8,0
23952 +#endif
23953 +
23954 +NEXT_PAGE(level3_vmalloc_start_pgt)
23955 + .fill 512,8,0
23956 +
23957 +NEXT_PAGE(level3_vmalloc_end_pgt)
23958 + .fill 512,8,0
23959 +
23960 +NEXT_PAGE(level3_vmemmap_pgt)
23961 + .fill L3_VMEMMAP_START,8,0
23962 + .quad level2_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
23963 +
23964 NEXT_PAGE(level2_ident_pgt)
23965 - /* Since I easily can, map the first 1G.
23966 + /* Since I easily can, map the first 2G.
23967 * Don't set NX because code runs from these pages.
23968 */
23969 - PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, PTRS_PER_PMD)
23970 -#endif
23971 + PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, 2*PTRS_PER_PMD)
23972
23973 NEXT_PAGE(level3_kernel_pgt)
23974 .fill L3_START_KERNEL,8,0
23975 @@ -473,6 +528,9 @@ NEXT_PAGE(level3_kernel_pgt)
23976 .quad level2_kernel_pgt - __START_KERNEL_map + _KERNPG_TABLE
23977 .quad level2_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
23978
23979 +NEXT_PAGE(level2_vmemmap_pgt)
23980 + .fill 512,8,0
23981 +
23982 NEXT_PAGE(level2_kernel_pgt)
23983 /*
23984 * 512 MB kernel mapping. We spend a full page on this pagetable
23985 @@ -490,28 +548,64 @@ NEXT_PAGE(level2_kernel_pgt)
23986 NEXT_PAGE(level2_fixmap_pgt)
23987 .fill 506,8,0
23988 .quad level1_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
23989 - /* 8MB reserved for vsyscalls + a 2MB hole = 4 + 1 entries */
23990 - .fill 5,8,0
23991 + .quad level1_vsyscall_pgt - __START_KERNEL_map + _PAGE_TABLE
23992 + /* 6MB reserved for vsyscalls + a 2MB hole = 3 + 1 entries */
23993 + .fill 4,8,0
23994
23995 NEXT_PAGE(level1_fixmap_pgt)
23996 .fill 512,8,0
23997
23998 +NEXT_PAGE(level1_vsyscall_pgt)
23999 + .fill 512,8,0
24000 +
24001 #undef PMDS
24002
24003 - .data
24004 + .align PAGE_SIZE
24005 +ENTRY(cpu_gdt_table)
24006 + .rept NR_CPUS
24007 + .quad 0x0000000000000000 /* NULL descriptor */
24008 + .quad 0x00cf9b000000ffff /* __KERNEL32_CS */
24009 + .quad 0x00af9b000000ffff /* __KERNEL_CS */
24010 + .quad 0x00cf93000000ffff /* __KERNEL_DS */
24011 + .quad 0x00cffb000000ffff /* __USER32_CS */
24012 + .quad 0x00cff3000000ffff /* __USER_DS, __USER32_DS */
24013 + .quad 0x00affb000000ffff /* __USER_CS */
24014 +
24015 +#ifdef CONFIG_PAX_KERNEXEC
24016 + .quad 0x00af9b000000ffff /* __KERNEXEC_KERNEL_CS */
24017 +#else
24018 + .quad 0x0 /* unused */
24019 +#endif
24020 +
24021 + .quad 0,0 /* TSS */
24022 + .quad 0,0 /* LDT */
24023 + .quad 0,0,0 /* three TLS descriptors */
24024 + .quad 0x0000f40000000000 /* node/CPU stored in limit */
24025 + /* asm/segment.h:GDT_ENTRIES must match this */
24026 +
24027 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24028 + .quad 0x00cf93000000ffff /* __UDEREF_KERNEL_DS */
24029 +#else
24030 + .quad 0x0 /* unused */
24031 +#endif
24032 +
24033 + /* zero the remaining page */
24034 + .fill PAGE_SIZE / 8 - GDT_ENTRIES,8,0
24035 + .endr
24036 +
24037 .align 16
24038 .globl early_gdt_descr
24039 early_gdt_descr:
24040 .word GDT_ENTRIES*8-1
24041 early_gdt_descr_base:
24042 - .quad INIT_PER_CPU_VAR(gdt_page)
24043 + .quad cpu_gdt_table
24044
24045 ENTRY(phys_base)
24046 /* This must match the first entry in level2_kernel_pgt */
24047 .quad 0x0000000000000000
24048
24049 #include "../../x86/xen/xen-head.S"
24050 -
24051 - __PAGE_ALIGNED_BSS
24052 +
24053 + .section .rodata,"a",@progbits
24054 NEXT_PAGE(empty_zero_page)
24055 .skip PAGE_SIZE
24056 diff --git a/arch/x86/kernel/i386_ksyms_32.c b/arch/x86/kernel/i386_ksyms_32.c
24057 index 0fa6912..b37438b 100644
24058 --- a/arch/x86/kernel/i386_ksyms_32.c
24059 +++ b/arch/x86/kernel/i386_ksyms_32.c
24060 @@ -20,8 +20,12 @@ extern void cmpxchg8b_emu(void);
24061 EXPORT_SYMBOL(cmpxchg8b_emu);
24062 #endif
24063
24064 +EXPORT_SYMBOL_GPL(cpu_gdt_table);
24065 +
24066 /* Networking helper routines. */
24067 EXPORT_SYMBOL(csum_partial_copy_generic);
24068 +EXPORT_SYMBOL(csum_partial_copy_generic_to_user);
24069 +EXPORT_SYMBOL(csum_partial_copy_generic_from_user);
24070
24071 EXPORT_SYMBOL(__get_user_1);
24072 EXPORT_SYMBOL(__get_user_2);
24073 @@ -37,3 +41,11 @@ EXPORT_SYMBOL(strstr);
24074
24075 EXPORT_SYMBOL(csum_partial);
24076 EXPORT_SYMBOL(empty_zero_page);
24077 +
24078 +#ifdef CONFIG_PAX_KERNEXEC
24079 +EXPORT_SYMBOL(__LOAD_PHYSICAL_ADDR);
24080 +#endif
24081 +
24082 +#ifdef CONFIG_PAX_PER_CPU_PGD
24083 +EXPORT_SYMBOL(cpu_pgd);
24084 +#endif
24085 diff --git a/arch/x86/kernel/i387.c b/arch/x86/kernel/i387.c
24086 index 5d576ab..1403a03 100644
24087 --- a/arch/x86/kernel/i387.c
24088 +++ b/arch/x86/kernel/i387.c
24089 @@ -51,7 +51,7 @@ static inline bool interrupted_kernel_fpu_idle(void)
24090 static inline bool interrupted_user_mode(void)
24091 {
24092 struct pt_regs *regs = get_irq_regs();
24093 - return regs && user_mode_vm(regs);
24094 + return regs && user_mode(regs);
24095 }
24096
24097 /*
24098 diff --git a/arch/x86/kernel/i8259.c b/arch/x86/kernel/i8259.c
24099 index 9a5c460..84868423 100644
24100 --- a/arch/x86/kernel/i8259.c
24101 +++ b/arch/x86/kernel/i8259.c
24102 @@ -110,7 +110,7 @@ static int i8259A_irq_pending(unsigned int irq)
24103 static void make_8259A_irq(unsigned int irq)
24104 {
24105 disable_irq_nosync(irq);
24106 - io_apic_irqs &= ~(1<<irq);
24107 + io_apic_irqs &= ~(1UL<<irq);
24108 irq_set_chip_and_handler_name(irq, &i8259A_chip, handle_level_irq,
24109 i8259A_chip.name);
24110 enable_irq(irq);
24111 @@ -209,7 +209,7 @@ spurious_8259A_irq:
24112 "spurious 8259A interrupt: IRQ%d.\n", irq);
24113 spurious_irq_mask |= irqmask;
24114 }
24115 - atomic_inc(&irq_err_count);
24116 + atomic_inc_unchecked(&irq_err_count);
24117 /*
24118 * Theoretically we do not have to handle this IRQ,
24119 * but in Linux this does not cause problems and is
24120 @@ -333,14 +333,16 @@ static void init_8259A(int auto_eoi)
24121 /* (slave's support for AEOI in flat mode is to be investigated) */
24122 outb_pic(SLAVE_ICW4_DEFAULT, PIC_SLAVE_IMR);
24123
24124 + pax_open_kernel();
24125 if (auto_eoi)
24126 /*
24127 * In AEOI mode we just have to mask the interrupt
24128 * when acking.
24129 */
24130 - i8259A_chip.irq_mask_ack = disable_8259A_irq;
24131 + *(void **)&i8259A_chip.irq_mask_ack = disable_8259A_irq;
24132 else
24133 - i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
24134 + *(void **)&i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
24135 + pax_close_kernel();
24136
24137 udelay(100); /* wait for 8259A to initialize */
24138
24139 diff --git a/arch/x86/kernel/io_delay.c b/arch/x86/kernel/io_delay.c
24140 index a979b5b..1d6db75 100644
24141 --- a/arch/x86/kernel/io_delay.c
24142 +++ b/arch/x86/kernel/io_delay.c
24143 @@ -58,7 +58,7 @@ static int __init dmi_io_delay_0xed_port(const struct dmi_system_id *id)
24144 * Quirk table for systems that misbehave (lock up, etc.) if port
24145 * 0x80 is used:
24146 */
24147 -static struct dmi_system_id __initdata io_delay_0xed_port_dmi_table[] = {
24148 +static const struct dmi_system_id __initconst io_delay_0xed_port_dmi_table[] = {
24149 {
24150 .callback = dmi_io_delay_0xed_port,
24151 .ident = "Compaq Presario V6000",
24152 diff --git a/arch/x86/kernel/ioport.c b/arch/x86/kernel/ioport.c
24153 index 4ddaf66..49d5c18 100644
24154 --- a/arch/x86/kernel/ioport.c
24155 +++ b/arch/x86/kernel/ioport.c
24156 @@ -6,6 +6,7 @@
24157 #include <linux/sched.h>
24158 #include <linux/kernel.h>
24159 #include <linux/capability.h>
24160 +#include <linux/security.h>
24161 #include <linux/errno.h>
24162 #include <linux/types.h>
24163 #include <linux/ioport.h>
24164 @@ -30,6 +31,12 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
24165 return -EINVAL;
24166 if (turn_on && !capable(CAP_SYS_RAWIO))
24167 return -EPERM;
24168 +#ifdef CONFIG_GRKERNSEC_IO
24169 + if (turn_on && grsec_disable_privio) {
24170 + gr_handle_ioperm();
24171 + return -ENODEV;
24172 + }
24173 +#endif
24174
24175 /*
24176 * If it's the first ioperm() call in this thread's lifetime, set the
24177 @@ -54,7 +61,7 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
24178 * because the ->io_bitmap_max value must match the bitmap
24179 * contents:
24180 */
24181 - tss = &per_cpu(init_tss, get_cpu());
24182 + tss = init_tss + get_cpu();
24183
24184 if (turn_on)
24185 bitmap_clear(t->io_bitmap_ptr, from, num);
24186 @@ -105,6 +112,12 @@ SYSCALL_DEFINE1(iopl, unsigned int, level)
24187 if (level > old) {
24188 if (!capable(CAP_SYS_RAWIO))
24189 return -EPERM;
24190 +#ifdef CONFIG_GRKERNSEC_IO
24191 + if (grsec_disable_privio) {
24192 + gr_handle_iopl();
24193 + return -ENODEV;
24194 + }
24195 +#endif
24196 }
24197 regs->flags = (regs->flags & ~X86_EFLAGS_IOPL) | (level << 12);
24198 t->iopl = level << 12;
24199 diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c
24200 index 22d0687..e07b2a5 100644
24201 --- a/arch/x86/kernel/irq.c
24202 +++ b/arch/x86/kernel/irq.c
24203 @@ -21,7 +21,7 @@
24204 #define CREATE_TRACE_POINTS
24205 #include <asm/trace/irq_vectors.h>
24206
24207 -atomic_t irq_err_count;
24208 +atomic_unchecked_t irq_err_count;
24209
24210 /* Function pointer for generic interrupt vector handling */
24211 void (*x86_platform_ipi_callback)(void) = NULL;
24212 @@ -125,9 +125,9 @@ int arch_show_interrupts(struct seq_file *p, int prec)
24213 seq_printf(p, "%10u ", per_cpu(mce_poll_count, j));
24214 seq_printf(p, " Machine check polls\n");
24215 #endif
24216 - seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
24217 + seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read_unchecked(&irq_err_count));
24218 #if defined(CONFIG_X86_IO_APIC)
24219 - seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read(&irq_mis_count));
24220 + seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read_unchecked(&irq_mis_count));
24221 #endif
24222 return 0;
24223 }
24224 @@ -167,7 +167,7 @@ u64 arch_irq_stat_cpu(unsigned int cpu)
24225
24226 u64 arch_irq_stat(void)
24227 {
24228 - u64 sum = atomic_read(&irq_err_count);
24229 + u64 sum = atomic_read_unchecked(&irq_err_count);
24230 return sum;
24231 }
24232
24233 diff --git a/arch/x86/kernel/irq_32.c b/arch/x86/kernel/irq_32.c
24234 index 4186755..784efa0 100644
24235 --- a/arch/x86/kernel/irq_32.c
24236 +++ b/arch/x86/kernel/irq_32.c
24237 @@ -39,7 +39,7 @@ static int check_stack_overflow(void)
24238 __asm__ __volatile__("andl %%esp,%0" :
24239 "=r" (sp) : "0" (THREAD_SIZE - 1));
24240
24241 - return sp < (sizeof(struct thread_info) + STACK_WARN);
24242 + return sp < STACK_WARN;
24243 }
24244
24245 static void print_stack_overflow(void)
24246 @@ -59,8 +59,8 @@ static inline void print_stack_overflow(void) { }
24247 * per-CPU IRQ handling contexts (thread information and stack)
24248 */
24249 union irq_ctx {
24250 - struct thread_info tinfo;
24251 - u32 stack[THREAD_SIZE/sizeof(u32)];
24252 + unsigned long previous_esp;
24253 + u32 stack[THREAD_SIZE/sizeof(u32)];
24254 } __attribute__((aligned(THREAD_SIZE)));
24255
24256 static DEFINE_PER_CPU(union irq_ctx *, hardirq_ctx);
24257 @@ -80,10 +80,9 @@ static void call_on_stack(void *func, void *stack)
24258 static inline int
24259 execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
24260 {
24261 - union irq_ctx *curctx, *irqctx;
24262 + union irq_ctx *irqctx;
24263 u32 *isp, arg1, arg2;
24264
24265 - curctx = (union irq_ctx *) current_thread_info();
24266 irqctx = __this_cpu_read(hardirq_ctx);
24267
24268 /*
24269 @@ -92,16 +91,16 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
24270 * handler) we can't do that and just have to keep using the
24271 * current stack (which is the irq stack already after all)
24272 */
24273 - if (unlikely(curctx == irqctx))
24274 + if (unlikely((void *)current_stack_pointer - (void *)irqctx < THREAD_SIZE))
24275 return 0;
24276
24277 /* build the stack frame on the IRQ stack */
24278 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
24279 - irqctx->tinfo.task = curctx->tinfo.task;
24280 - irqctx->tinfo.previous_esp = current_stack_pointer;
24281 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
24282 + irqctx->previous_esp = current_stack_pointer;
24283
24284 - /* Copy the preempt_count so that the [soft]irq checks work. */
24285 - irqctx->tinfo.preempt_count = curctx->tinfo.preempt_count;
24286 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24287 + __set_fs(MAKE_MM_SEG(0));
24288 +#endif
24289
24290 if (unlikely(overflow))
24291 call_on_stack(print_stack_overflow, isp);
24292 @@ -113,6 +112,11 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
24293 : "0" (irq), "1" (desc), "2" (isp),
24294 "D" (desc->handle_irq)
24295 : "memory", "cc", "ecx");
24296 +
24297 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24298 + __set_fs(current_thread_info()->addr_limit);
24299 +#endif
24300 +
24301 return 1;
24302 }
24303
24304 @@ -121,29 +125,14 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
24305 */
24306 void irq_ctx_init(int cpu)
24307 {
24308 - union irq_ctx *irqctx;
24309 -
24310 if (per_cpu(hardirq_ctx, cpu))
24311 return;
24312
24313 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
24314 - THREADINFO_GFP,
24315 - THREAD_SIZE_ORDER));
24316 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
24317 - irqctx->tinfo.cpu = cpu;
24318 - irqctx->tinfo.preempt_count = HARDIRQ_OFFSET;
24319 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
24320 + per_cpu(hardirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
24321 + per_cpu(softirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
24322
24323 - per_cpu(hardirq_ctx, cpu) = irqctx;
24324 -
24325 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
24326 - THREADINFO_GFP,
24327 - THREAD_SIZE_ORDER));
24328 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
24329 - irqctx->tinfo.cpu = cpu;
24330 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
24331 -
24332 - per_cpu(softirq_ctx, cpu) = irqctx;
24333 + printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
24334 + cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
24335
24336 printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
24337 cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
24338 @@ -152,7 +141,6 @@ void irq_ctx_init(int cpu)
24339 asmlinkage void do_softirq(void)
24340 {
24341 unsigned long flags;
24342 - struct thread_info *curctx;
24343 union irq_ctx *irqctx;
24344 u32 *isp;
24345
24346 @@ -162,15 +150,22 @@ asmlinkage void do_softirq(void)
24347 local_irq_save(flags);
24348
24349 if (local_softirq_pending()) {
24350 - curctx = current_thread_info();
24351 irqctx = __this_cpu_read(softirq_ctx);
24352 - irqctx->tinfo.task = curctx->task;
24353 - irqctx->tinfo.previous_esp = current_stack_pointer;
24354 + irqctx->previous_esp = current_stack_pointer;
24355
24356 /* build the stack frame on the softirq stack */
24357 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
24358 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
24359 +
24360 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24361 + __set_fs(MAKE_MM_SEG(0));
24362 +#endif
24363
24364 call_on_stack(__do_softirq, isp);
24365 +
24366 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24367 + __set_fs(current_thread_info()->addr_limit);
24368 +#endif
24369 +
24370 /*
24371 * Shouldn't happen, we returned above if in_interrupt():
24372 */
24373 @@ -191,7 +186,7 @@ bool handle_irq(unsigned irq, struct pt_regs *regs)
24374 if (unlikely(!desc))
24375 return false;
24376
24377 - if (user_mode_vm(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
24378 + if (user_mode(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
24379 if (unlikely(overflow))
24380 print_stack_overflow();
24381 desc->handle_irq(irq, desc);
24382 diff --git a/arch/x86/kernel/irq_64.c b/arch/x86/kernel/irq_64.c
24383 index d04d3ec..ea4b374 100644
24384 --- a/arch/x86/kernel/irq_64.c
24385 +++ b/arch/x86/kernel/irq_64.c
24386 @@ -44,7 +44,7 @@ static inline void stack_overflow_check(struct pt_regs *regs)
24387 u64 estack_top, estack_bottom;
24388 u64 curbase = (u64)task_stack_page(current);
24389
24390 - if (user_mode_vm(regs))
24391 + if (user_mode(regs))
24392 return;
24393
24394 if (regs->sp >= curbase + sizeof(struct thread_info) +
24395 diff --git a/arch/x86/kernel/jump_label.c b/arch/x86/kernel/jump_label.c
24396 index ee11b7d..4df4d0c 100644
24397 --- a/arch/x86/kernel/jump_label.c
24398 +++ b/arch/x86/kernel/jump_label.c
24399 @@ -49,7 +49,7 @@ static void __jump_label_transform(struct jump_entry *entry,
24400 * We are enabling this jump label. If it is not a nop
24401 * then something must have gone wrong.
24402 */
24403 - if (unlikely(memcmp((void *)entry->code, ideal_nop, 5) != 0))
24404 + if (unlikely(memcmp((void *)ktla_ktva(entry->code), ideal_nop, 5) != 0))
24405 bug_at((void *)entry->code, __LINE__);
24406
24407 code.jump = 0xe9;
24408 @@ -64,13 +64,13 @@ static void __jump_label_transform(struct jump_entry *entry,
24409 */
24410 if (init) {
24411 const unsigned char default_nop[] = { STATIC_KEY_INIT_NOP };
24412 - if (unlikely(memcmp((void *)entry->code, default_nop, 5) != 0))
24413 + if (unlikely(memcmp((void *)ktla_ktva(entry->code), default_nop, 5) != 0))
24414 bug_at((void *)entry->code, __LINE__);
24415 } else {
24416 code.jump = 0xe9;
24417 code.offset = entry->target -
24418 (entry->code + JUMP_LABEL_NOP_SIZE);
24419 - if (unlikely(memcmp((void *)entry->code, &code, 5) != 0))
24420 + if (unlikely(memcmp((void *)ktla_ktva(entry->code), &code, 5) != 0))
24421 bug_at((void *)entry->code, __LINE__);
24422 }
24423 memcpy(&code, ideal_nops[NOP_ATOMIC5], JUMP_LABEL_NOP_SIZE);
24424 diff --git a/arch/x86/kernel/kgdb.c b/arch/x86/kernel/kgdb.c
24425 index 836f832..a8bda67 100644
24426 --- a/arch/x86/kernel/kgdb.c
24427 +++ b/arch/x86/kernel/kgdb.c
24428 @@ -127,11 +127,11 @@ char *dbg_get_reg(int regno, void *mem, struct pt_regs *regs)
24429 #ifdef CONFIG_X86_32
24430 switch (regno) {
24431 case GDB_SS:
24432 - if (!user_mode_vm(regs))
24433 + if (!user_mode(regs))
24434 *(unsigned long *)mem = __KERNEL_DS;
24435 break;
24436 case GDB_SP:
24437 - if (!user_mode_vm(regs))
24438 + if (!user_mode(regs))
24439 *(unsigned long *)mem = kernel_stack_pointer(regs);
24440 break;
24441 case GDB_GS:
24442 @@ -229,7 +229,10 @@ static void kgdb_correct_hw_break(void)
24443 bp->attr.bp_addr = breakinfo[breakno].addr;
24444 bp->attr.bp_len = breakinfo[breakno].len;
24445 bp->attr.bp_type = breakinfo[breakno].type;
24446 - info->address = breakinfo[breakno].addr;
24447 + if (breakinfo[breakno].type == X86_BREAKPOINT_EXECUTE)
24448 + info->address = ktla_ktva(breakinfo[breakno].addr);
24449 + else
24450 + info->address = breakinfo[breakno].addr;
24451 info->len = breakinfo[breakno].len;
24452 info->type = breakinfo[breakno].type;
24453 val = arch_install_hw_breakpoint(bp);
24454 @@ -476,12 +479,12 @@ int kgdb_arch_handle_exception(int e_vector, int signo, int err_code,
24455 case 'k':
24456 /* clear the trace bit */
24457 linux_regs->flags &= ~X86_EFLAGS_TF;
24458 - atomic_set(&kgdb_cpu_doing_single_step, -1);
24459 + atomic_set_unchecked(&kgdb_cpu_doing_single_step, -1);
24460
24461 /* set the trace bit if we're stepping */
24462 if (remcomInBuffer[0] == 's') {
24463 linux_regs->flags |= X86_EFLAGS_TF;
24464 - atomic_set(&kgdb_cpu_doing_single_step,
24465 + atomic_set_unchecked(&kgdb_cpu_doing_single_step,
24466 raw_smp_processor_id());
24467 }
24468
24469 @@ -546,7 +549,7 @@ static int __kgdb_notify(struct die_args *args, unsigned long cmd)
24470
24471 switch (cmd) {
24472 case DIE_DEBUG:
24473 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
24474 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
24475 if (user_mode(regs))
24476 return single_step_cont(regs, args);
24477 break;
24478 @@ -751,11 +754,11 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
24479 #endif /* CONFIG_DEBUG_RODATA */
24480
24481 bpt->type = BP_BREAKPOINT;
24482 - err = probe_kernel_read(bpt->saved_instr, (char *)bpt->bpt_addr,
24483 + err = probe_kernel_read(bpt->saved_instr, ktla_ktva((char *)bpt->bpt_addr),
24484 BREAK_INSTR_SIZE);
24485 if (err)
24486 return err;
24487 - err = probe_kernel_write((char *)bpt->bpt_addr,
24488 + err = probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
24489 arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE);
24490 #ifdef CONFIG_DEBUG_RODATA
24491 if (!err)
24492 @@ -768,7 +771,7 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
24493 return -EBUSY;
24494 text_poke((void *)bpt->bpt_addr, arch_kgdb_ops.gdb_bpt_instr,
24495 BREAK_INSTR_SIZE);
24496 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
24497 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
24498 if (err)
24499 return err;
24500 if (memcmp(opc, arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE))
24501 @@ -793,13 +796,13 @@ int kgdb_arch_remove_breakpoint(struct kgdb_bkpt *bpt)
24502 if (mutex_is_locked(&text_mutex))
24503 goto knl_write;
24504 text_poke((void *)bpt->bpt_addr, bpt->saved_instr, BREAK_INSTR_SIZE);
24505 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
24506 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
24507 if (err || memcmp(opc, bpt->saved_instr, BREAK_INSTR_SIZE))
24508 goto knl_write;
24509 return err;
24510 knl_write:
24511 #endif /* CONFIG_DEBUG_RODATA */
24512 - return probe_kernel_write((char *)bpt->bpt_addr,
24513 + return probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
24514 (char *)bpt->saved_instr, BREAK_INSTR_SIZE);
24515 }
24516
24517 diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
24518 index 79a3f96..6ba030a 100644
24519 --- a/arch/x86/kernel/kprobes/core.c
24520 +++ b/arch/x86/kernel/kprobes/core.c
24521 @@ -119,9 +119,12 @@ static void __kprobes __synthesize_relative_insn(void *from, void *to, u8 op)
24522 s32 raddr;
24523 } __packed *insn;
24524
24525 - insn = (struct __arch_relative_insn *)from;
24526 + insn = (struct __arch_relative_insn *)ktla_ktva(from);
24527 +
24528 + pax_open_kernel();
24529 insn->raddr = (s32)((long)(to) - ((long)(from) + 5));
24530 insn->op = op;
24531 + pax_close_kernel();
24532 }
24533
24534 /* Insert a jump instruction at address 'from', which jumps to address 'to'.*/
24535 @@ -164,7 +167,7 @@ int __kprobes can_boost(kprobe_opcode_t *opcodes)
24536 kprobe_opcode_t opcode;
24537 kprobe_opcode_t *orig_opcodes = opcodes;
24538
24539 - if (search_exception_tables((unsigned long)opcodes))
24540 + if (search_exception_tables(ktva_ktla((unsigned long)opcodes)))
24541 return 0; /* Page fault may occur on this address. */
24542
24543 retry:
24544 @@ -238,9 +241,9 @@ __recover_probed_insn(kprobe_opcode_t *buf, unsigned long addr)
24545 * for the first byte, we can recover the original instruction
24546 * from it and kp->opcode.
24547 */
24548 - memcpy(buf, kp->addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
24549 + memcpy(buf, ktla_ktva(kp->addr), MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
24550 buf[0] = kp->opcode;
24551 - return (unsigned long)buf;
24552 + return ktva_ktla((unsigned long)buf);
24553 }
24554
24555 /*
24556 @@ -332,7 +335,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
24557 /* Another subsystem puts a breakpoint, failed to recover */
24558 if (insn.opcode.bytes[0] == BREAKPOINT_INSTRUCTION)
24559 return 0;
24560 + pax_open_kernel();
24561 memcpy(dest, insn.kaddr, insn.length);
24562 + pax_close_kernel();
24563
24564 #ifdef CONFIG_X86_64
24565 if (insn_rip_relative(&insn)) {
24566 @@ -359,7 +364,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
24567 return 0;
24568 }
24569 disp = (u8 *) dest + insn_offset_displacement(&insn);
24570 + pax_open_kernel();
24571 *(s32 *) disp = (s32) newdisp;
24572 + pax_close_kernel();
24573 }
24574 #endif
24575 return insn.length;
24576 @@ -498,7 +505,7 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
24577 * nor set current_kprobe, because it doesn't use single
24578 * stepping.
24579 */
24580 - regs->ip = (unsigned long)p->ainsn.insn;
24581 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
24582 preempt_enable_no_resched();
24583 return;
24584 }
24585 @@ -515,9 +522,9 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
24586 regs->flags &= ~X86_EFLAGS_IF;
24587 /* single step inline if the instruction is an int3 */
24588 if (p->opcode == BREAKPOINT_INSTRUCTION)
24589 - regs->ip = (unsigned long)p->addr;
24590 + regs->ip = ktla_ktva((unsigned long)p->addr);
24591 else
24592 - regs->ip = (unsigned long)p->ainsn.insn;
24593 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
24594 }
24595
24596 /*
24597 @@ -596,7 +603,7 @@ static int __kprobes kprobe_handler(struct pt_regs *regs)
24598 setup_singlestep(p, regs, kcb, 0);
24599 return 1;
24600 }
24601 - } else if (*addr != BREAKPOINT_INSTRUCTION) {
24602 + } else if (*(kprobe_opcode_t *)ktla_ktva((unsigned long)addr) != BREAKPOINT_INSTRUCTION) {
24603 /*
24604 * The breakpoint instruction was removed right
24605 * after we hit it. Another cpu has removed
24606 @@ -642,6 +649,9 @@ static void __used __kprobes kretprobe_trampoline_holder(void)
24607 " movq %rax, 152(%rsp)\n"
24608 RESTORE_REGS_STRING
24609 " popfq\n"
24610 +#ifdef KERNEXEC_PLUGIN
24611 + " btsq $63,(%rsp)\n"
24612 +#endif
24613 #else
24614 " pushf\n"
24615 SAVE_REGS_STRING
24616 @@ -779,7 +789,7 @@ static void __kprobes
24617 resume_execution(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *kcb)
24618 {
24619 unsigned long *tos = stack_addr(regs);
24620 - unsigned long copy_ip = (unsigned long)p->ainsn.insn;
24621 + unsigned long copy_ip = ktva_ktla((unsigned long)p->ainsn.insn);
24622 unsigned long orig_ip = (unsigned long)p->addr;
24623 kprobe_opcode_t *insn = p->ainsn.insn;
24624
24625 @@ -961,7 +971,7 @@ kprobe_exceptions_notify(struct notifier_block *self, unsigned long val, void *d
24626 struct die_args *args = data;
24627 int ret = NOTIFY_DONE;
24628
24629 - if (args->regs && user_mode_vm(args->regs))
24630 + if (args->regs && user_mode(args->regs))
24631 return ret;
24632
24633 switch (val) {
24634 diff --git a/arch/x86/kernel/kprobes/opt.c b/arch/x86/kernel/kprobes/opt.c
24635 index 898160b..758cde8 100644
24636 --- a/arch/x86/kernel/kprobes/opt.c
24637 +++ b/arch/x86/kernel/kprobes/opt.c
24638 @@ -79,6 +79,7 @@ found:
24639 /* Insert a move instruction which sets a pointer to eax/rdi (1st arg). */
24640 static void __kprobes synthesize_set_arg1(kprobe_opcode_t *addr, unsigned long val)
24641 {
24642 + pax_open_kernel();
24643 #ifdef CONFIG_X86_64
24644 *addr++ = 0x48;
24645 *addr++ = 0xbf;
24646 @@ -86,6 +87,7 @@ static void __kprobes synthesize_set_arg1(kprobe_opcode_t *addr, unsigned long v
24647 *addr++ = 0xb8;
24648 #endif
24649 *(unsigned long *)addr = val;
24650 + pax_close_kernel();
24651 }
24652
24653 asm (
24654 @@ -335,7 +337,7 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
24655 * Verify if the address gap is in 2GB range, because this uses
24656 * a relative jump.
24657 */
24658 - rel = (long)op->optinsn.insn - (long)op->kp.addr + RELATIVEJUMP_SIZE;
24659 + rel = (long)op->optinsn.insn - ktla_ktva((long)op->kp.addr) + RELATIVEJUMP_SIZE;
24660 if (abs(rel) > 0x7fffffff)
24661 return -ERANGE;
24662
24663 @@ -350,16 +352,18 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
24664 op->optinsn.size = ret;
24665
24666 /* Copy arch-dep-instance from template */
24667 - memcpy(buf, &optprobe_template_entry, TMPL_END_IDX);
24668 + pax_open_kernel();
24669 + memcpy(buf, ktla_ktva(&optprobe_template_entry), TMPL_END_IDX);
24670 + pax_close_kernel();
24671
24672 /* Set probe information */
24673 synthesize_set_arg1(buf + TMPL_MOVE_IDX, (unsigned long)op);
24674
24675 /* Set probe function call */
24676 - synthesize_relcall(buf + TMPL_CALL_IDX, optimized_callback);
24677 + synthesize_relcall(ktva_ktla(buf) + TMPL_CALL_IDX, optimized_callback);
24678
24679 /* Set returning jmp instruction at the tail of out-of-line buffer */
24680 - synthesize_reljump(buf + TMPL_END_IDX + op->optinsn.size,
24681 + synthesize_reljump(ktva_ktla(buf) + TMPL_END_IDX + op->optinsn.size,
24682 (u8 *)op->kp.addr + op->optinsn.size);
24683
24684 flush_icache_range((unsigned long) buf,
24685 @@ -384,7 +388,7 @@ void __kprobes arch_optimize_kprobes(struct list_head *oplist)
24686 WARN_ON(kprobe_disabled(&op->kp));
24687
24688 /* Backup instructions which will be replaced by jump address */
24689 - memcpy(op->optinsn.copied_insn, op->kp.addr + INT3_SIZE,
24690 + memcpy(op->optinsn.copied_insn, ktla_ktva(op->kp.addr) + INT3_SIZE,
24691 RELATIVE_ADDR_SIZE);
24692
24693 insn_buf[0] = RELATIVEJUMP_OPCODE;
24694 @@ -433,7 +437,7 @@ setup_detour_execution(struct kprobe *p, struct pt_regs *regs, int reenter)
24695 /* This kprobe is really able to run optimized path. */
24696 op = container_of(p, struct optimized_kprobe, kp);
24697 /* Detour through copied instructions */
24698 - regs->ip = (unsigned long)op->optinsn.insn + TMPL_END_IDX;
24699 + regs->ip = ktva_ktla((unsigned long)op->optinsn.insn) + TMPL_END_IDX;
24700 if (!reenter)
24701 reset_current_kprobe();
24702 preempt_enable_no_resched();
24703 diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c
24704 index ebc9873..1b9724b 100644
24705 --- a/arch/x86/kernel/ldt.c
24706 +++ b/arch/x86/kernel/ldt.c
24707 @@ -66,13 +66,13 @@ static int alloc_ldt(mm_context_t *pc, int mincount, int reload)
24708 if (reload) {
24709 #ifdef CONFIG_SMP
24710 preempt_disable();
24711 - load_LDT(pc);
24712 + load_LDT_nolock(pc);
24713 if (!cpumask_equal(mm_cpumask(current->mm),
24714 cpumask_of(smp_processor_id())))
24715 smp_call_function(flush_ldt, current->mm, 1);
24716 preempt_enable();
24717 #else
24718 - load_LDT(pc);
24719 + load_LDT_nolock(pc);
24720 #endif
24721 }
24722 if (oldsize) {
24723 @@ -94,7 +94,7 @@ static inline int copy_ldt(mm_context_t *new, mm_context_t *old)
24724 return err;
24725
24726 for (i = 0; i < old->size; i++)
24727 - write_ldt_entry(new->ldt, i, old->ldt + i * LDT_ENTRY_SIZE);
24728 + write_ldt_entry(new->ldt, i, old->ldt + i);
24729 return 0;
24730 }
24731
24732 @@ -115,6 +115,24 @@ int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
24733 retval = copy_ldt(&mm->context, &old_mm->context);
24734 mutex_unlock(&old_mm->context.lock);
24735 }
24736 +
24737 + if (tsk == current) {
24738 + mm->context.vdso = 0;
24739 +
24740 +#ifdef CONFIG_X86_32
24741 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
24742 + mm->context.user_cs_base = 0UL;
24743 + mm->context.user_cs_limit = ~0UL;
24744 +
24745 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
24746 + cpus_clear(mm->context.cpu_user_cs_mask);
24747 +#endif
24748 +
24749 +#endif
24750 +#endif
24751 +
24752 + }
24753 +
24754 return retval;
24755 }
24756
24757 @@ -229,6 +247,13 @@ static int write_ldt(void __user *ptr, unsigned long bytecount, int oldmode)
24758 }
24759 }
24760
24761 +#ifdef CONFIG_PAX_SEGMEXEC
24762 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (ldt_info.contents & MODIFY_LDT_CONTENTS_CODE)) {
24763 + error = -EINVAL;
24764 + goto out_unlock;
24765 + }
24766 +#endif
24767 +
24768 fill_ldt(&ldt, &ldt_info);
24769 if (oldmode)
24770 ldt.avl = 0;
24771 diff --git a/arch/x86/kernel/machine_kexec_32.c b/arch/x86/kernel/machine_kexec_32.c
24772 index 5b19e4d..6476a76 100644
24773 --- a/arch/x86/kernel/machine_kexec_32.c
24774 +++ b/arch/x86/kernel/machine_kexec_32.c
24775 @@ -26,7 +26,7 @@
24776 #include <asm/cacheflush.h>
24777 #include <asm/debugreg.h>
24778
24779 -static void set_idt(void *newidt, __u16 limit)
24780 +static void set_idt(struct desc_struct *newidt, __u16 limit)
24781 {
24782 struct desc_ptr curidt;
24783
24784 @@ -38,7 +38,7 @@ static void set_idt(void *newidt, __u16 limit)
24785 }
24786
24787
24788 -static void set_gdt(void *newgdt, __u16 limit)
24789 +static void set_gdt(struct desc_struct *newgdt, __u16 limit)
24790 {
24791 struct desc_ptr curgdt;
24792
24793 @@ -216,7 +216,7 @@ void machine_kexec(struct kimage *image)
24794 }
24795
24796 control_page = page_address(image->control_code_page);
24797 - memcpy(control_page, relocate_kernel, KEXEC_CONTROL_CODE_MAX_SIZE);
24798 + memcpy(control_page, (void *)ktla_ktva((unsigned long)relocate_kernel), KEXEC_CONTROL_CODE_MAX_SIZE);
24799
24800 relocate_kernel_ptr = control_page;
24801 page_list[PA_CONTROL_PAGE] = __pa(control_page);
24802 diff --git a/arch/x86/kernel/microcode_core.c b/arch/x86/kernel/microcode_core.c
24803 index 15c9876..0a43909 100644
24804 --- a/arch/x86/kernel/microcode_core.c
24805 +++ b/arch/x86/kernel/microcode_core.c
24806 @@ -513,7 +513,7 @@ mc_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu)
24807 return NOTIFY_OK;
24808 }
24809
24810 -static struct notifier_block __refdata mc_cpu_notifier = {
24811 +static struct notifier_block mc_cpu_notifier = {
24812 .notifier_call = mc_cpu_callback,
24813 };
24814
24815 diff --git a/arch/x86/kernel/microcode_intel.c b/arch/x86/kernel/microcode_intel.c
24816 index 5fb2ceb..3ae90bb 100644
24817 --- a/arch/x86/kernel/microcode_intel.c
24818 +++ b/arch/x86/kernel/microcode_intel.c
24819 @@ -293,13 +293,13 @@ static enum ucode_state request_microcode_fw(int cpu, struct device *device,
24820
24821 static int get_ucode_user(void *to, const void *from, size_t n)
24822 {
24823 - return copy_from_user(to, from, n);
24824 + return copy_from_user(to, (const void __force_user *)from, n);
24825 }
24826
24827 static enum ucode_state
24828 request_microcode_user(int cpu, const void __user *buf, size_t size)
24829 {
24830 - return generic_load_microcode(cpu, (void *)buf, size, &get_ucode_user);
24831 + return generic_load_microcode(cpu, (__force_kernel void *)buf, size, &get_ucode_user);
24832 }
24833
24834 static void microcode_fini_cpu(int cpu)
24835 diff --git a/arch/x86/kernel/module.c b/arch/x86/kernel/module.c
24836 index 216a4d7..228255a 100644
24837 --- a/arch/x86/kernel/module.c
24838 +++ b/arch/x86/kernel/module.c
24839 @@ -43,15 +43,60 @@ do { \
24840 } while (0)
24841 #endif
24842
24843 -void *module_alloc(unsigned long size)
24844 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
24845 {
24846 - if (PAGE_ALIGN(size) > MODULES_LEN)
24847 + if (!size || PAGE_ALIGN(size) > MODULES_LEN)
24848 return NULL;
24849 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
24850 - GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
24851 + GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, prot,
24852 -1, __builtin_return_address(0));
24853 }
24854
24855 +void *module_alloc(unsigned long size)
24856 +{
24857 +
24858 +#ifdef CONFIG_PAX_KERNEXEC
24859 + return __module_alloc(size, PAGE_KERNEL);
24860 +#else
24861 + return __module_alloc(size, PAGE_KERNEL_EXEC);
24862 +#endif
24863 +
24864 +}
24865 +
24866 +#ifdef CONFIG_PAX_KERNEXEC
24867 +#ifdef CONFIG_X86_32
24868 +void *module_alloc_exec(unsigned long size)
24869 +{
24870 + struct vm_struct *area;
24871 +
24872 + if (size == 0)
24873 + return NULL;
24874 +
24875 + area = __get_vm_area(size, VM_ALLOC, (unsigned long)&MODULES_EXEC_VADDR, (unsigned long)&MODULES_EXEC_END);
24876 + return area ? area->addr : NULL;
24877 +}
24878 +EXPORT_SYMBOL(module_alloc_exec);
24879 +
24880 +void module_free_exec(struct module *mod, void *module_region)
24881 +{
24882 + vunmap(module_region);
24883 +}
24884 +EXPORT_SYMBOL(module_free_exec);
24885 +#else
24886 +void module_free_exec(struct module *mod, void *module_region)
24887 +{
24888 + module_free(mod, module_region);
24889 +}
24890 +EXPORT_SYMBOL(module_free_exec);
24891 +
24892 +void *module_alloc_exec(unsigned long size)
24893 +{
24894 + return __module_alloc(size, PAGE_KERNEL_RX);
24895 +}
24896 +EXPORT_SYMBOL(module_alloc_exec);
24897 +#endif
24898 +#endif
24899 +
24900 #ifdef CONFIG_X86_32
24901 int apply_relocate(Elf32_Shdr *sechdrs,
24902 const char *strtab,
24903 @@ -62,14 +107,16 @@ int apply_relocate(Elf32_Shdr *sechdrs,
24904 unsigned int i;
24905 Elf32_Rel *rel = (void *)sechdrs[relsec].sh_addr;
24906 Elf32_Sym *sym;
24907 - uint32_t *location;
24908 + uint32_t *plocation, location;
24909
24910 DEBUGP("Applying relocate section %u to %u\n",
24911 relsec, sechdrs[relsec].sh_info);
24912 for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) {
24913 /* This is where to make the change */
24914 - location = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr
24915 - + rel[i].r_offset;
24916 + plocation = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr + rel[i].r_offset;
24917 + location = (uint32_t)plocation;
24918 + if (sechdrs[sechdrs[relsec].sh_info].sh_flags & SHF_EXECINSTR)
24919 + plocation = ktla_ktva((void *)plocation);
24920 /* This is the symbol it is referring to. Note that all
24921 undefined symbols have been resolved. */
24922 sym = (Elf32_Sym *)sechdrs[symindex].sh_addr
24923 @@ -78,11 +125,15 @@ int apply_relocate(Elf32_Shdr *sechdrs,
24924 switch (ELF32_R_TYPE(rel[i].r_info)) {
24925 case R_386_32:
24926 /* We add the value into the location given */
24927 - *location += sym->st_value;
24928 + pax_open_kernel();
24929 + *plocation += sym->st_value;
24930 + pax_close_kernel();
24931 break;
24932 case R_386_PC32:
24933 /* Add the value, subtract its position */
24934 - *location += sym->st_value - (uint32_t)location;
24935 + pax_open_kernel();
24936 + *plocation += sym->st_value - location;
24937 + pax_close_kernel();
24938 break;
24939 default:
24940 pr_err("%s: Unknown relocation: %u\n",
24941 @@ -127,21 +178,30 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
24942 case R_X86_64_NONE:
24943 break;
24944 case R_X86_64_64:
24945 + pax_open_kernel();
24946 *(u64 *)loc = val;
24947 + pax_close_kernel();
24948 break;
24949 case R_X86_64_32:
24950 + pax_open_kernel();
24951 *(u32 *)loc = val;
24952 + pax_close_kernel();
24953 if (val != *(u32 *)loc)
24954 goto overflow;
24955 break;
24956 case R_X86_64_32S:
24957 + pax_open_kernel();
24958 *(s32 *)loc = val;
24959 + pax_close_kernel();
24960 if ((s64)val != *(s32 *)loc)
24961 goto overflow;
24962 break;
24963 case R_X86_64_PC32:
24964 val -= (u64)loc;
24965 + pax_open_kernel();
24966 *(u32 *)loc = val;
24967 + pax_close_kernel();
24968 +
24969 #if 0
24970 if ((s64)val != *(s32 *)loc)
24971 goto overflow;
24972 diff --git a/arch/x86/kernel/msr.c b/arch/x86/kernel/msr.c
24973 index 88458fa..349f7a4 100644
24974 --- a/arch/x86/kernel/msr.c
24975 +++ b/arch/x86/kernel/msr.c
24976 @@ -233,7 +233,7 @@ static int msr_class_cpu_callback(struct notifier_block *nfb,
24977 return notifier_from_errno(err);
24978 }
24979
24980 -static struct notifier_block __refdata msr_class_cpu_notifier = {
24981 +static struct notifier_block msr_class_cpu_notifier = {
24982 .notifier_call = msr_class_cpu_callback,
24983 };
24984
24985 diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c
24986 index 6fcb49c..5b3f4ff 100644
24987 --- a/arch/x86/kernel/nmi.c
24988 +++ b/arch/x86/kernel/nmi.c
24989 @@ -138,7 +138,7 @@ static int __kprobes nmi_handle(unsigned int type, struct pt_regs *regs, bool b2
24990 return handled;
24991 }
24992
24993 -int __register_nmi_handler(unsigned int type, struct nmiaction *action)
24994 +int __register_nmi_handler(unsigned int type, const struct nmiaction *action)
24995 {
24996 struct nmi_desc *desc = nmi_to_desc(type);
24997 unsigned long flags;
24998 @@ -162,9 +162,9 @@ int __register_nmi_handler(unsigned int type, struct nmiaction *action)
24999 * event confuses some handlers (kdump uses this flag)
25000 */
25001 if (action->flags & NMI_FLAG_FIRST)
25002 - list_add_rcu(&action->list, &desc->head);
25003 + pax_list_add_rcu((struct list_head *)&action->list, &desc->head);
25004 else
25005 - list_add_tail_rcu(&action->list, &desc->head);
25006 + pax_list_add_tail_rcu((struct list_head *)&action->list, &desc->head);
25007
25008 spin_unlock_irqrestore(&desc->lock, flags);
25009 return 0;
25010 @@ -187,7 +187,7 @@ void unregister_nmi_handler(unsigned int type, const char *name)
25011 if (!strcmp(n->name, name)) {
25012 WARN(in_nmi(),
25013 "Trying to free NMI (%s) from NMI context!\n", n->name);
25014 - list_del_rcu(&n->list);
25015 + pax_list_del_rcu((struct list_head *)&n->list);
25016 break;
25017 }
25018 }
25019 @@ -512,6 +512,17 @@ static inline void nmi_nesting_postprocess(void)
25020 dotraplinkage notrace __kprobes void
25021 do_nmi(struct pt_regs *regs, long error_code)
25022 {
25023 +
25024 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
25025 + if (!user_mode(regs)) {
25026 + unsigned long cs = regs->cs & 0xFFFF;
25027 + unsigned long ip = ktva_ktla(regs->ip);
25028 +
25029 + if ((cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS) && ip <= (unsigned long)_etext)
25030 + regs->ip = ip;
25031 + }
25032 +#endif
25033 +
25034 nmi_nesting_preprocess(regs);
25035
25036 nmi_enter();
25037 diff --git a/arch/x86/kernel/nmi_selftest.c b/arch/x86/kernel/nmi_selftest.c
25038 index 6d9582e..f746287 100644
25039 --- a/arch/x86/kernel/nmi_selftest.c
25040 +++ b/arch/x86/kernel/nmi_selftest.c
25041 @@ -43,7 +43,7 @@ static void __init init_nmi_testsuite(void)
25042 {
25043 /* trap all the unknown NMIs we may generate */
25044 register_nmi_handler(NMI_UNKNOWN, nmi_unk_cb, 0, "nmi_selftest_unk",
25045 - __initdata);
25046 + __initconst);
25047 }
25048
25049 static void __init cleanup_nmi_testsuite(void)
25050 @@ -66,7 +66,7 @@ static void __init test_nmi_ipi(struct cpumask *mask)
25051 unsigned long timeout;
25052
25053 if (register_nmi_handler(NMI_LOCAL, test_nmi_ipi_callback,
25054 - NMI_FLAG_FIRST, "nmi_selftest", __initdata)) {
25055 + NMI_FLAG_FIRST, "nmi_selftest", __initconst)) {
25056 nmi_fail = FAILURE;
25057 return;
25058 }
25059 diff --git a/arch/x86/kernel/paravirt-spinlocks.c b/arch/x86/kernel/paravirt-spinlocks.c
25060 index bbb6c73..24a58ef 100644
25061 --- a/arch/x86/kernel/paravirt-spinlocks.c
25062 +++ b/arch/x86/kernel/paravirt-spinlocks.c
25063 @@ -8,7 +8,7 @@
25064
25065 #include <asm/paravirt.h>
25066
25067 -struct pv_lock_ops pv_lock_ops = {
25068 +struct pv_lock_ops pv_lock_ops __read_only = {
25069 #ifdef CONFIG_SMP
25070 .lock_spinning = __PV_IS_CALLEE_SAVE(paravirt_nop),
25071 .unlock_kick = paravirt_nop,
25072 diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
25073 index 1b10af8..0b58cbc 100644
25074 --- a/arch/x86/kernel/paravirt.c
25075 +++ b/arch/x86/kernel/paravirt.c
25076 @@ -55,6 +55,9 @@ u64 _paravirt_ident_64(u64 x)
25077 {
25078 return x;
25079 }
25080 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
25081 +PV_CALLEE_SAVE_REGS_THUNK(_paravirt_ident_64);
25082 +#endif
25083
25084 void __init default_banner(void)
25085 {
25086 @@ -142,15 +145,19 @@ unsigned paravirt_patch_default(u8 type, u16 clobbers, void *insnbuf,
25087 if (opfunc == NULL)
25088 /* If there's no function, patch it with a ud2a (BUG) */
25089 ret = paravirt_patch_insns(insnbuf, len, ud2a, ud2a+sizeof(ud2a));
25090 - else if (opfunc == _paravirt_nop)
25091 + else if (opfunc == (void *)_paravirt_nop)
25092 /* If the operation is a nop, then nop the callsite */
25093 ret = paravirt_patch_nop();
25094
25095 /* identity functions just return their single argument */
25096 - else if (opfunc == _paravirt_ident_32)
25097 + else if (opfunc == (void *)_paravirt_ident_32)
25098 ret = paravirt_patch_ident_32(insnbuf, len);
25099 - else if (opfunc == _paravirt_ident_64)
25100 + else if (opfunc == (void *)_paravirt_ident_64)
25101 ret = paravirt_patch_ident_64(insnbuf, len);
25102 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
25103 + else if (opfunc == (void *)__raw_callee_save__paravirt_ident_64)
25104 + ret = paravirt_patch_ident_64(insnbuf, len);
25105 +#endif
25106
25107 else if (type == PARAVIRT_PATCH(pv_cpu_ops.iret) ||
25108 type == PARAVIRT_PATCH(pv_cpu_ops.irq_enable_sysexit) ||
25109 @@ -175,7 +182,7 @@ unsigned paravirt_patch_insns(void *insnbuf, unsigned len,
25110 if (insn_len > len || start == NULL)
25111 insn_len = len;
25112 else
25113 - memcpy(insnbuf, start, insn_len);
25114 + memcpy(insnbuf, ktla_ktva(start), insn_len);
25115
25116 return insn_len;
25117 }
25118 @@ -299,7 +306,7 @@ enum paravirt_lazy_mode paravirt_get_lazy_mode(void)
25119 return this_cpu_read(paravirt_lazy_mode);
25120 }
25121
25122 -struct pv_info pv_info = {
25123 +struct pv_info pv_info __read_only = {
25124 .name = "bare hardware",
25125 .paravirt_enabled = 0,
25126 .kernel_rpl = 0,
25127 @@ -310,16 +317,16 @@ struct pv_info pv_info = {
25128 #endif
25129 };
25130
25131 -struct pv_init_ops pv_init_ops = {
25132 +struct pv_init_ops pv_init_ops __read_only = {
25133 .patch = native_patch,
25134 };
25135
25136 -struct pv_time_ops pv_time_ops = {
25137 +struct pv_time_ops pv_time_ops __read_only = {
25138 .sched_clock = native_sched_clock,
25139 .steal_clock = native_steal_clock,
25140 };
25141
25142 -__visible struct pv_irq_ops pv_irq_ops = {
25143 +__visible struct pv_irq_ops pv_irq_ops __read_only = {
25144 .save_fl = __PV_IS_CALLEE_SAVE(native_save_fl),
25145 .restore_fl = __PV_IS_CALLEE_SAVE(native_restore_fl),
25146 .irq_disable = __PV_IS_CALLEE_SAVE(native_irq_disable),
25147 @@ -331,7 +338,7 @@ __visible struct pv_irq_ops pv_irq_ops = {
25148 #endif
25149 };
25150
25151 -__visible struct pv_cpu_ops pv_cpu_ops = {
25152 +__visible struct pv_cpu_ops pv_cpu_ops __read_only = {
25153 .cpuid = native_cpuid,
25154 .get_debugreg = native_get_debugreg,
25155 .set_debugreg = native_set_debugreg,
25156 @@ -389,21 +396,26 @@ __visible struct pv_cpu_ops pv_cpu_ops = {
25157 .end_context_switch = paravirt_nop,
25158 };
25159
25160 -struct pv_apic_ops pv_apic_ops = {
25161 +struct pv_apic_ops pv_apic_ops __read_only= {
25162 #ifdef CONFIG_X86_LOCAL_APIC
25163 .startup_ipi_hook = paravirt_nop,
25164 #endif
25165 };
25166
25167 -#if defined(CONFIG_X86_32) && !defined(CONFIG_X86_PAE)
25168 +#ifdef CONFIG_X86_32
25169 +#ifdef CONFIG_X86_PAE
25170 +/* 64-bit pagetable entries */
25171 +#define PTE_IDENT PV_CALLEE_SAVE(_paravirt_ident_64)
25172 +#else
25173 /* 32-bit pagetable entries */
25174 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_32)
25175 +#endif
25176 #else
25177 /* 64-bit pagetable entries */
25178 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_64)
25179 #endif
25180
25181 -struct pv_mmu_ops pv_mmu_ops = {
25182 +struct pv_mmu_ops pv_mmu_ops __read_only = {
25183
25184 .read_cr2 = native_read_cr2,
25185 .write_cr2 = native_write_cr2,
25186 @@ -453,6 +465,7 @@ struct pv_mmu_ops pv_mmu_ops = {
25187 .make_pud = PTE_IDENT,
25188
25189 .set_pgd = native_set_pgd,
25190 + .set_pgd_batched = native_set_pgd_batched,
25191 #endif
25192 #endif /* PAGETABLE_LEVELS >= 3 */
25193
25194 @@ -473,6 +486,12 @@ struct pv_mmu_ops pv_mmu_ops = {
25195 },
25196
25197 .set_fixmap = native_set_fixmap,
25198 +
25199 +#ifdef CONFIG_PAX_KERNEXEC
25200 + .pax_open_kernel = native_pax_open_kernel,
25201 + .pax_close_kernel = native_pax_close_kernel,
25202 +#endif
25203 +
25204 };
25205
25206 EXPORT_SYMBOL_GPL(pv_time_ops);
25207 diff --git a/arch/x86/kernel/pci-calgary_64.c b/arch/x86/kernel/pci-calgary_64.c
25208 index 299d493..2ccb0ee 100644
25209 --- a/arch/x86/kernel/pci-calgary_64.c
25210 +++ b/arch/x86/kernel/pci-calgary_64.c
25211 @@ -1339,7 +1339,7 @@ static void __init get_tce_space_from_tar(void)
25212 tce_space = be64_to_cpu(readq(target));
25213 tce_space = tce_space & TAR_SW_BITS;
25214
25215 - tce_space = tce_space & (~specified_table_size);
25216 + tce_space = tce_space & (~(unsigned long)specified_table_size);
25217 info->tce_space = (u64 *)__va(tce_space);
25218 }
25219 }
25220 diff --git a/arch/x86/kernel/pci-iommu_table.c b/arch/x86/kernel/pci-iommu_table.c
25221 index 35ccf75..7a15747 100644
25222 --- a/arch/x86/kernel/pci-iommu_table.c
25223 +++ b/arch/x86/kernel/pci-iommu_table.c
25224 @@ -2,7 +2,7 @@
25225 #include <asm/iommu_table.h>
25226 #include <linux/string.h>
25227 #include <linux/kallsyms.h>
25228 -
25229 +#include <linux/sched.h>
25230
25231 #define DEBUG 1
25232
25233 diff --git a/arch/x86/kernel/pci-swiotlb.c b/arch/x86/kernel/pci-swiotlb.c
25234 index 6c483ba..d10ce2f 100644
25235 --- a/arch/x86/kernel/pci-swiotlb.c
25236 +++ b/arch/x86/kernel/pci-swiotlb.c
25237 @@ -32,7 +32,7 @@ static void x86_swiotlb_free_coherent(struct device *dev, size_t size,
25238 void *vaddr, dma_addr_t dma_addr,
25239 struct dma_attrs *attrs)
25240 {
25241 - swiotlb_free_coherent(dev, size, vaddr, dma_addr);
25242 + swiotlb_free_coherent(dev, size, vaddr, dma_addr, attrs);
25243 }
25244
25245 static struct dma_map_ops swiotlb_dma_ops = {
25246 diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
25247 index 3fb8d95..254dc51 100644
25248 --- a/arch/x86/kernel/process.c
25249 +++ b/arch/x86/kernel/process.c
25250 @@ -36,7 +36,8 @@
25251 * section. Since TSS's are completely CPU-local, we want them
25252 * on exact cacheline boundaries, to eliminate cacheline ping-pong.
25253 */
25254 -__visible DEFINE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss) = INIT_TSS;
25255 +struct tss_struct init_tss[NR_CPUS] __visible ____cacheline_internodealigned_in_smp = { [0 ... NR_CPUS-1] = INIT_TSS };
25256 +EXPORT_SYMBOL(init_tss);
25257
25258 #ifdef CONFIG_X86_64
25259 static DEFINE_PER_CPU(unsigned char, is_idle);
25260 @@ -92,7 +93,7 @@ void arch_task_cache_init(void)
25261 task_xstate_cachep =
25262 kmem_cache_create("task_xstate", xstate_size,
25263 __alignof__(union thread_xstate),
25264 - SLAB_PANIC | SLAB_NOTRACK, NULL);
25265 + SLAB_PANIC | SLAB_NOTRACK | SLAB_USERCOPY, NULL);
25266 }
25267
25268 /*
25269 @@ -105,7 +106,7 @@ void exit_thread(void)
25270 unsigned long *bp = t->io_bitmap_ptr;
25271
25272 if (bp) {
25273 - struct tss_struct *tss = &per_cpu(init_tss, get_cpu());
25274 + struct tss_struct *tss = init_tss + get_cpu();
25275
25276 t->io_bitmap_ptr = NULL;
25277 clear_thread_flag(TIF_IO_BITMAP);
25278 @@ -125,6 +126,9 @@ void flush_thread(void)
25279 {
25280 struct task_struct *tsk = current;
25281
25282 +#if defined(CONFIG_X86_32) && !defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_PAX_MEMORY_UDEREF)
25283 + loadsegment(gs, 0);
25284 +#endif
25285 flush_ptrace_hw_breakpoint(tsk);
25286 memset(tsk->thread.tls_array, 0, sizeof(tsk->thread.tls_array));
25287 drop_init_fpu(tsk);
25288 @@ -271,7 +275,7 @@ static void __exit_idle(void)
25289 void exit_idle(void)
25290 {
25291 /* idle loop has pid 0 */
25292 - if (current->pid)
25293 + if (task_pid_nr(current))
25294 return;
25295 __exit_idle();
25296 }
25297 @@ -327,7 +331,7 @@ bool xen_set_default_idle(void)
25298 return ret;
25299 }
25300 #endif
25301 -void stop_this_cpu(void *dummy)
25302 +__noreturn void stop_this_cpu(void *dummy)
25303 {
25304 local_irq_disable();
25305 /*
25306 @@ -456,16 +460,37 @@ static int __init idle_setup(char *str)
25307 }
25308 early_param("idle", idle_setup);
25309
25310 -unsigned long arch_align_stack(unsigned long sp)
25311 +#ifdef CONFIG_PAX_RANDKSTACK
25312 +void pax_randomize_kstack(struct pt_regs *regs)
25313 {
25314 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
25315 - sp -= get_random_int() % 8192;
25316 - return sp & ~0xf;
25317 -}
25318 + struct thread_struct *thread = &current->thread;
25319 + unsigned long time;
25320
25321 -unsigned long arch_randomize_brk(struct mm_struct *mm)
25322 -{
25323 - unsigned long range_end = mm->brk + 0x02000000;
25324 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
25325 -}
25326 + if (!randomize_va_space)
25327 + return;
25328 +
25329 + if (v8086_mode(regs))
25330 + return;
25331
25332 + rdtscl(time);
25333 +
25334 + /* P4 seems to return a 0 LSB, ignore it */
25335 +#ifdef CONFIG_MPENTIUM4
25336 + time &= 0x3EUL;
25337 + time <<= 2;
25338 +#elif defined(CONFIG_X86_64)
25339 + time &= 0xFUL;
25340 + time <<= 4;
25341 +#else
25342 + time &= 0x1FUL;
25343 + time <<= 3;
25344 +#endif
25345 +
25346 + thread->sp0 ^= time;
25347 + load_sp0(init_tss + smp_processor_id(), thread);
25348 +
25349 +#ifdef CONFIG_X86_64
25350 + this_cpu_write(kernel_stack, thread->sp0);
25351 +#endif
25352 +}
25353 +#endif
25354 diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c
25355 index 884f98f..ec23e04 100644
25356 --- a/arch/x86/kernel/process_32.c
25357 +++ b/arch/x86/kernel/process_32.c
25358 @@ -65,6 +65,7 @@ asmlinkage void ret_from_kernel_thread(void) __asm__("ret_from_kernel_thread");
25359 unsigned long thread_saved_pc(struct task_struct *tsk)
25360 {
25361 return ((unsigned long *)tsk->thread.sp)[3];
25362 +//XXX return tsk->thread.eip;
25363 }
25364
25365 void __show_regs(struct pt_regs *regs, int all)
25366 @@ -74,19 +75,18 @@ void __show_regs(struct pt_regs *regs, int all)
25367 unsigned long sp;
25368 unsigned short ss, gs;
25369
25370 - if (user_mode_vm(regs)) {
25371 + if (user_mode(regs)) {
25372 sp = regs->sp;
25373 ss = regs->ss & 0xffff;
25374 - gs = get_user_gs(regs);
25375 } else {
25376 sp = kernel_stack_pointer(regs);
25377 savesegment(ss, ss);
25378 - savesegment(gs, gs);
25379 }
25380 + gs = get_user_gs(regs);
25381
25382 printk(KERN_DEFAULT "EIP: %04x:[<%08lx>] EFLAGS: %08lx CPU: %d\n",
25383 (u16)regs->cs, regs->ip, regs->flags,
25384 - smp_processor_id());
25385 + raw_smp_processor_id());
25386 print_symbol("EIP is at %s\n", regs->ip);
25387
25388 printk(KERN_DEFAULT "EAX: %08lx EBX: %08lx ECX: %08lx EDX: %08lx\n",
25389 @@ -133,20 +133,21 @@ void release_thread(struct task_struct *dead_task)
25390 int copy_thread(unsigned long clone_flags, unsigned long sp,
25391 unsigned long arg, struct task_struct *p)
25392 {
25393 - struct pt_regs *childregs = task_pt_regs(p);
25394 + struct pt_regs *childregs = task_stack_page(p) + THREAD_SIZE - sizeof(struct pt_regs) - 8;
25395 struct task_struct *tsk;
25396 int err;
25397
25398 p->thread.sp = (unsigned long) childregs;
25399 p->thread.sp0 = (unsigned long) (childregs+1);
25400 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
25401
25402 if (unlikely(p->flags & PF_KTHREAD)) {
25403 /* kernel thread */
25404 memset(childregs, 0, sizeof(struct pt_regs));
25405 p->thread.ip = (unsigned long) ret_from_kernel_thread;
25406 - task_user_gs(p) = __KERNEL_STACK_CANARY;
25407 - childregs->ds = __USER_DS;
25408 - childregs->es = __USER_DS;
25409 + savesegment(gs, childregs->gs);
25410 + childregs->ds = __KERNEL_DS;
25411 + childregs->es = __KERNEL_DS;
25412 childregs->fs = __KERNEL_PERCPU;
25413 childregs->bx = sp; /* function */
25414 childregs->bp = arg;
25415 @@ -253,7 +254,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
25416 struct thread_struct *prev = &prev_p->thread,
25417 *next = &next_p->thread;
25418 int cpu = smp_processor_id();
25419 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
25420 + struct tss_struct *tss = init_tss + cpu;
25421 fpu_switch_t fpu;
25422
25423 /* never put a printk in __switch_to... printk() calls wake_up*() indirectly */
25424 @@ -277,6 +278,10 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
25425 */
25426 lazy_save_gs(prev->gs);
25427
25428 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25429 + __set_fs(task_thread_info(next_p)->addr_limit);
25430 +#endif
25431 +
25432 /*
25433 * Load the per-thread Thread-Local Storage descriptor.
25434 */
25435 @@ -307,6 +312,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
25436 */
25437 arch_end_context_switch(next_p);
25438
25439 + this_cpu_write(current_task, next_p);
25440 + this_cpu_write(current_tinfo, &next_p->tinfo);
25441 +
25442 /*
25443 * Restore %gs if needed (which is common)
25444 */
25445 @@ -315,8 +323,6 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
25446
25447 switch_fpu_finish(next_p, fpu);
25448
25449 - this_cpu_write(current_task, next_p);
25450 -
25451 return prev_p;
25452 }
25453
25454 @@ -346,4 +352,3 @@ unsigned long get_wchan(struct task_struct *p)
25455 } while (count++ < 16);
25456 return 0;
25457 }
25458 -
25459 diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
25460 index bb1dc51..08dda7f 100644
25461 --- a/arch/x86/kernel/process_64.c
25462 +++ b/arch/x86/kernel/process_64.c
25463 @@ -158,10 +158,11 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
25464 struct pt_regs *childregs;
25465 struct task_struct *me = current;
25466
25467 - p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE;
25468 + p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE - 16;
25469 childregs = task_pt_regs(p);
25470 p->thread.sp = (unsigned long) childregs;
25471 p->thread.usersp = me->thread.usersp;
25472 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
25473 set_tsk_thread_flag(p, TIF_FORK);
25474 p->fpu_counter = 0;
25475 p->thread.io_bitmap_ptr = NULL;
25476 @@ -172,6 +173,8 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
25477 p->thread.fs = p->thread.fsindex ? 0 : me->thread.fs;
25478 savesegment(es, p->thread.es);
25479 savesegment(ds, p->thread.ds);
25480 + savesegment(ss, p->thread.ss);
25481 + BUG_ON(p->thread.ss == __UDEREF_KERNEL_DS);
25482 memset(p->thread.ptrace_bps, 0, sizeof(p->thread.ptrace_bps));
25483
25484 if (unlikely(p->flags & PF_KTHREAD)) {
25485 @@ -280,7 +283,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
25486 struct thread_struct *prev = &prev_p->thread;
25487 struct thread_struct *next = &next_p->thread;
25488 int cpu = smp_processor_id();
25489 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
25490 + struct tss_struct *tss = init_tss + cpu;
25491 unsigned fsindex, gsindex;
25492 fpu_switch_t fpu;
25493
25494 @@ -303,6 +306,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
25495 if (unlikely(next->ds | prev->ds))
25496 loadsegment(ds, next->ds);
25497
25498 + savesegment(ss, prev->ss);
25499 + if (unlikely(next->ss != prev->ss))
25500 + loadsegment(ss, next->ss);
25501
25502 /* We must save %fs and %gs before load_TLS() because
25503 * %fs and %gs may be cleared by load_TLS().
25504 @@ -362,10 +368,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
25505 prev->usersp = this_cpu_read(old_rsp);
25506 this_cpu_write(old_rsp, next->usersp);
25507 this_cpu_write(current_task, next_p);
25508 + this_cpu_write(current_tinfo, &next_p->tinfo);
25509
25510 - this_cpu_write(kernel_stack,
25511 - (unsigned long)task_stack_page(next_p) +
25512 - THREAD_SIZE - KERNEL_STACK_OFFSET);
25513 + this_cpu_write(kernel_stack, next->sp0);
25514
25515 /*
25516 * Now maybe reload the debug registers and handle I/O bitmaps
25517 @@ -434,12 +439,11 @@ unsigned long get_wchan(struct task_struct *p)
25518 if (!p || p == current || p->state == TASK_RUNNING)
25519 return 0;
25520 stack = (unsigned long)task_stack_page(p);
25521 - if (p->thread.sp < stack || p->thread.sp >= stack+THREAD_SIZE)
25522 + if (p->thread.sp < stack || p->thread.sp > stack+THREAD_SIZE-16-sizeof(u64))
25523 return 0;
25524 fp = *(u64 *)(p->thread.sp);
25525 do {
25526 - if (fp < (unsigned long)stack ||
25527 - fp >= (unsigned long)stack+THREAD_SIZE)
25528 + if (fp < stack || fp > stack+THREAD_SIZE-16-sizeof(u64))
25529 return 0;
25530 ip = *(u64 *)(fp+8);
25531 if (!in_sched_functions(ip))
25532 diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
25533 index 7461f50..1334029 100644
25534 --- a/arch/x86/kernel/ptrace.c
25535 +++ b/arch/x86/kernel/ptrace.c
25536 @@ -184,14 +184,13 @@ unsigned long kernel_stack_pointer(struct pt_regs *regs)
25537 {
25538 unsigned long context = (unsigned long)regs & ~(THREAD_SIZE - 1);
25539 unsigned long sp = (unsigned long)&regs->sp;
25540 - struct thread_info *tinfo;
25541
25542 - if (context == (sp & ~(THREAD_SIZE - 1)))
25543 + if (context == ((sp + 8) & ~(THREAD_SIZE - 1)))
25544 return sp;
25545
25546 - tinfo = (struct thread_info *)context;
25547 - if (tinfo->previous_esp)
25548 - return tinfo->previous_esp;
25549 + sp = *(unsigned long *)context;
25550 + if (sp)
25551 + return sp;
25552
25553 return (unsigned long)regs;
25554 }
25555 @@ -588,7 +587,7 @@ static void ptrace_triggered(struct perf_event *bp,
25556 static unsigned long ptrace_get_dr7(struct perf_event *bp[])
25557 {
25558 int i;
25559 - int dr7 = 0;
25560 + unsigned long dr7 = 0;
25561 struct arch_hw_breakpoint *info;
25562
25563 for (i = 0; i < HBP_NUM; i++) {
25564 @@ -822,7 +821,7 @@ long arch_ptrace(struct task_struct *child, long request,
25565 unsigned long addr, unsigned long data)
25566 {
25567 int ret;
25568 - unsigned long __user *datap = (unsigned long __user *)data;
25569 + unsigned long __user *datap = (__force unsigned long __user *)data;
25570
25571 switch (request) {
25572 /* read the word at location addr in the USER area. */
25573 @@ -907,14 +906,14 @@ long arch_ptrace(struct task_struct *child, long request,
25574 if ((int) addr < 0)
25575 return -EIO;
25576 ret = do_get_thread_area(child, addr,
25577 - (struct user_desc __user *)data);
25578 + (__force struct user_desc __user *) data);
25579 break;
25580
25581 case PTRACE_SET_THREAD_AREA:
25582 if ((int) addr < 0)
25583 return -EIO;
25584 ret = do_set_thread_area(child, addr,
25585 - (struct user_desc __user *)data, 0);
25586 + (__force struct user_desc __user *) data, 0);
25587 break;
25588 #endif
25589
25590 @@ -1292,7 +1291,7 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
25591
25592 #ifdef CONFIG_X86_64
25593
25594 -static struct user_regset x86_64_regsets[] __read_mostly = {
25595 +static user_regset_no_const x86_64_regsets[] __read_only = {
25596 [REGSET_GENERAL] = {
25597 .core_note_type = NT_PRSTATUS,
25598 .n = sizeof(struct user_regs_struct) / sizeof(long),
25599 @@ -1333,7 +1332,7 @@ static const struct user_regset_view user_x86_64_view = {
25600 #endif /* CONFIG_X86_64 */
25601
25602 #if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION
25603 -static struct user_regset x86_32_regsets[] __read_mostly = {
25604 +static user_regset_no_const x86_32_regsets[] __read_only = {
25605 [REGSET_GENERAL] = {
25606 .core_note_type = NT_PRSTATUS,
25607 .n = sizeof(struct user_regs_struct32) / sizeof(u32),
25608 @@ -1386,7 +1385,7 @@ static const struct user_regset_view user_x86_32_view = {
25609 */
25610 u64 xstate_fx_sw_bytes[USER_XSTATE_FX_SW_WORDS];
25611
25612 -void update_regset_xstate_info(unsigned int size, u64 xstate_mask)
25613 +void __init update_regset_xstate_info(unsigned int size, u64 xstate_mask)
25614 {
25615 #ifdef CONFIG_X86_64
25616 x86_64_regsets[REGSET_XSTATE].n = size / sizeof(u64);
25617 @@ -1421,7 +1420,7 @@ static void fill_sigtrap_info(struct task_struct *tsk,
25618 memset(info, 0, sizeof(*info));
25619 info->si_signo = SIGTRAP;
25620 info->si_code = si_code;
25621 - info->si_addr = user_mode_vm(regs) ? (void __user *)regs->ip : NULL;
25622 + info->si_addr = user_mode(regs) ? (__force void __user *)regs->ip : NULL;
25623 }
25624
25625 void user_single_step_siginfo(struct task_struct *tsk,
25626 @@ -1450,6 +1449,10 @@ void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs,
25627 # define IS_IA32 0
25628 #endif
25629
25630 +#ifdef CONFIG_GRKERNSEC_SETXID
25631 +extern void gr_delayed_cred_worker(void);
25632 +#endif
25633 +
25634 /*
25635 * We must return the syscall number to actually look up in the table.
25636 * This can be -1L to skip running any syscall at all.
25637 @@ -1460,6 +1463,11 @@ long syscall_trace_enter(struct pt_regs *regs)
25638
25639 user_exit();
25640
25641 +#ifdef CONFIG_GRKERNSEC_SETXID
25642 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
25643 + gr_delayed_cred_worker();
25644 +#endif
25645 +
25646 /*
25647 * If we stepped into a sysenter/syscall insn, it trapped in
25648 * kernel mode; do_debug() cleared TF and set TIF_SINGLESTEP.
25649 @@ -1515,6 +1523,11 @@ void syscall_trace_leave(struct pt_regs *regs)
25650 */
25651 user_exit();
25652
25653 +#ifdef CONFIG_GRKERNSEC_SETXID
25654 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
25655 + gr_delayed_cred_worker();
25656 +#endif
25657 +
25658 audit_syscall_exit(regs);
25659
25660 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
25661 diff --git a/arch/x86/kernel/pvclock.c b/arch/x86/kernel/pvclock.c
25662 index a16bae3..1f65f25 100644
25663 --- a/arch/x86/kernel/pvclock.c
25664 +++ b/arch/x86/kernel/pvclock.c
25665 @@ -43,11 +43,11 @@ unsigned long pvclock_tsc_khz(struct pvclock_vcpu_time_info *src)
25666 return pv_tsc_khz;
25667 }
25668
25669 -static atomic64_t last_value = ATOMIC64_INIT(0);
25670 +static atomic64_unchecked_t last_value = ATOMIC64_INIT(0);
25671
25672 void pvclock_resume(void)
25673 {
25674 - atomic64_set(&last_value, 0);
25675 + atomic64_set_unchecked(&last_value, 0);
25676 }
25677
25678 u8 pvclock_read_flags(struct pvclock_vcpu_time_info *src)
25679 @@ -92,11 +92,11 @@ cycle_t pvclock_clocksource_read(struct pvclock_vcpu_time_info *src)
25680 * updating at the same time, and one of them could be slightly behind,
25681 * making the assumption that last_value always go forward fail to hold.
25682 */
25683 - last = atomic64_read(&last_value);
25684 + last = atomic64_read_unchecked(&last_value);
25685 do {
25686 if (ret < last)
25687 return last;
25688 - last = atomic64_cmpxchg(&last_value, last, ret);
25689 + last = atomic64_cmpxchg_unchecked(&last_value, last, ret);
25690 } while (unlikely(last != ret));
25691
25692 return ret;
25693 diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
25694 index 618ce26..ec7e21c 100644
25695 --- a/arch/x86/kernel/reboot.c
25696 +++ b/arch/x86/kernel/reboot.c
25697 @@ -68,6 +68,11 @@ static int __init set_bios_reboot(const struct dmi_system_id *d)
25698
25699 void __noreturn machine_real_restart(unsigned int type)
25700 {
25701 +
25702 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
25703 + struct desc_struct *gdt;
25704 +#endif
25705 +
25706 local_irq_disable();
25707
25708 /*
25709 @@ -95,7 +100,29 @@ void __noreturn machine_real_restart(unsigned int type)
25710
25711 /* Jump to the identity-mapped low memory code */
25712 #ifdef CONFIG_X86_32
25713 - asm volatile("jmpl *%0" : :
25714 +
25715 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
25716 + gdt = get_cpu_gdt_table(smp_processor_id());
25717 + pax_open_kernel();
25718 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25719 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
25720 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
25721 + loadsegment(ds, __KERNEL_DS);
25722 + loadsegment(es, __KERNEL_DS);
25723 + loadsegment(ss, __KERNEL_DS);
25724 +#endif
25725 +#ifdef CONFIG_PAX_KERNEXEC
25726 + gdt[GDT_ENTRY_KERNEL_CS].base0 = 0;
25727 + gdt[GDT_ENTRY_KERNEL_CS].base1 = 0;
25728 + gdt[GDT_ENTRY_KERNEL_CS].base2 = 0;
25729 + gdt[GDT_ENTRY_KERNEL_CS].limit0 = 0xffff;
25730 + gdt[GDT_ENTRY_KERNEL_CS].limit = 0xf;
25731 + gdt[GDT_ENTRY_KERNEL_CS].g = 1;
25732 +#endif
25733 + pax_close_kernel();
25734 +#endif
25735 +
25736 + asm volatile("ljmpl *%0" : :
25737 "rm" (real_mode_header->machine_real_restart_asm),
25738 "a" (type));
25739 #else
25740 @@ -466,7 +493,7 @@ void __attribute__((weak)) mach_reboot_fixups(void)
25741 * try to force a triple fault and then cycle between hitting the keyboard
25742 * controller and doing that
25743 */
25744 -static void native_machine_emergency_restart(void)
25745 +static void __noreturn native_machine_emergency_restart(void)
25746 {
25747 int i;
25748 int attempt = 0;
25749 @@ -575,13 +602,13 @@ void native_machine_shutdown(void)
25750 #endif
25751 }
25752
25753 -static void __machine_emergency_restart(int emergency)
25754 +static void __noreturn __machine_emergency_restart(int emergency)
25755 {
25756 reboot_emergency = emergency;
25757 machine_ops.emergency_restart();
25758 }
25759
25760 -static void native_machine_restart(char *__unused)
25761 +static void __noreturn native_machine_restart(char *__unused)
25762 {
25763 pr_notice("machine restart\n");
25764
25765 @@ -590,7 +617,7 @@ static void native_machine_restart(char *__unused)
25766 __machine_emergency_restart(0);
25767 }
25768
25769 -static void native_machine_halt(void)
25770 +static void __noreturn native_machine_halt(void)
25771 {
25772 /* Stop other cpus and apics */
25773 machine_shutdown();
25774 @@ -600,7 +627,7 @@ static void native_machine_halt(void)
25775 stop_this_cpu(NULL);
25776 }
25777
25778 -static void native_machine_power_off(void)
25779 +static void __noreturn native_machine_power_off(void)
25780 {
25781 if (pm_power_off) {
25782 if (!reboot_force)
25783 @@ -609,9 +636,10 @@ static void native_machine_power_off(void)
25784 }
25785 /* A fallback in case there is no PM info available */
25786 tboot_shutdown(TB_SHUTDOWN_HALT);
25787 + unreachable();
25788 }
25789
25790 -struct machine_ops machine_ops = {
25791 +struct machine_ops machine_ops __read_only = {
25792 .power_off = native_machine_power_off,
25793 .shutdown = native_machine_shutdown,
25794 .emergency_restart = native_machine_emergency_restart,
25795 diff --git a/arch/x86/kernel/reboot_fixups_32.c b/arch/x86/kernel/reboot_fixups_32.c
25796 index c8e41e9..64049ef 100644
25797 --- a/arch/x86/kernel/reboot_fixups_32.c
25798 +++ b/arch/x86/kernel/reboot_fixups_32.c
25799 @@ -57,7 +57,7 @@ struct device_fixup {
25800 unsigned int vendor;
25801 unsigned int device;
25802 void (*reboot_fixup)(struct pci_dev *);
25803 -};
25804 +} __do_const;
25805
25806 /*
25807 * PCI ids solely used for fixups_table go here
25808 diff --git a/arch/x86/kernel/relocate_kernel_64.S b/arch/x86/kernel/relocate_kernel_64.S
25809 index 3fd2c69..16ef367 100644
25810 --- a/arch/x86/kernel/relocate_kernel_64.S
25811 +++ b/arch/x86/kernel/relocate_kernel_64.S
25812 @@ -11,6 +11,7 @@
25813 #include <asm/kexec.h>
25814 #include <asm/processor-flags.h>
25815 #include <asm/pgtable_types.h>
25816 +#include <asm/alternative-asm.h>
25817
25818 /*
25819 * Must be relocatable PIC code callable as a C function
25820 @@ -96,8 +97,7 @@ relocate_kernel:
25821
25822 /* jump to identity mapped page */
25823 addq $(identity_mapped - relocate_kernel), %r8
25824 - pushq %r8
25825 - ret
25826 + jmp *%r8
25827
25828 identity_mapped:
25829 /* set return address to 0 if not preserving context */
25830 @@ -167,6 +167,7 @@ identity_mapped:
25831 xorl %r14d, %r14d
25832 xorl %r15d, %r15d
25833
25834 + pax_force_retaddr 0, 1
25835 ret
25836
25837 1:
25838 diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
25839 index f0de629..a4978a8f 100644
25840 --- a/arch/x86/kernel/setup.c
25841 +++ b/arch/x86/kernel/setup.c
25842 @@ -110,6 +110,7 @@
25843 #include <asm/mce.h>
25844 #include <asm/alternative.h>
25845 #include <asm/prom.h>
25846 +#include <asm/boot.h>
25847
25848 /*
25849 * max_low_pfn_mapped: highest direct mapped pfn under 4GB
25850 @@ -205,12 +206,50 @@ EXPORT_SYMBOL(boot_cpu_data);
25851 #endif
25852
25853
25854 -#if !defined(CONFIG_X86_PAE) || defined(CONFIG_X86_64)
25855 -__visible unsigned long mmu_cr4_features;
25856 +#ifdef CONFIG_X86_64
25857 +__visible unsigned long mmu_cr4_features __read_only = X86_CR4_PSE | X86_CR4_PAE | X86_CR4_PGE;
25858 +#elif defined(CONFIG_X86_PAE)
25859 +__visible unsigned long mmu_cr4_features __read_only = X86_CR4_PAE;
25860 #else
25861 -__visible unsigned long mmu_cr4_features = X86_CR4_PAE;
25862 +__visible unsigned long mmu_cr4_features __read_only;
25863 #endif
25864
25865 +void set_in_cr4(unsigned long mask)
25866 +{
25867 + unsigned long cr4 = read_cr4();
25868 +
25869 + if ((cr4 & mask) == mask && cr4 == mmu_cr4_features)
25870 + return;
25871 +
25872 + pax_open_kernel();
25873 + mmu_cr4_features |= mask;
25874 + pax_close_kernel();
25875 +
25876 + if (trampoline_cr4_features)
25877 + *trampoline_cr4_features = mmu_cr4_features;
25878 + cr4 |= mask;
25879 + write_cr4(cr4);
25880 +}
25881 +EXPORT_SYMBOL(set_in_cr4);
25882 +
25883 +void clear_in_cr4(unsigned long mask)
25884 +{
25885 + unsigned long cr4 = read_cr4();
25886 +
25887 + if (!(cr4 & mask) && cr4 == mmu_cr4_features)
25888 + return;
25889 +
25890 + pax_open_kernel();
25891 + mmu_cr4_features &= ~mask;
25892 + pax_close_kernel();
25893 +
25894 + if (trampoline_cr4_features)
25895 + *trampoline_cr4_features = mmu_cr4_features;
25896 + cr4 &= ~mask;
25897 + write_cr4(cr4);
25898 +}
25899 +EXPORT_SYMBOL(clear_in_cr4);
25900 +
25901 /* Boot loader ID and version as integers, for the benefit of proc_dointvec */
25902 int bootloader_type, bootloader_version;
25903
25904 @@ -768,7 +807,7 @@ static void __init trim_bios_range(void)
25905 * area (640->1Mb) as ram even though it is not.
25906 * take them out.
25907 */
25908 - e820_remove_range(BIOS_BEGIN, BIOS_END - BIOS_BEGIN, E820_RAM, 1);
25909 + e820_remove_range(ISA_START_ADDRESS, ISA_END_ADDRESS - ISA_START_ADDRESS, E820_RAM, 1);
25910
25911 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
25912 }
25913 @@ -776,7 +815,7 @@ static void __init trim_bios_range(void)
25914 /* called before trim_bios_range() to spare extra sanitize */
25915 static void __init e820_add_kernel_range(void)
25916 {
25917 - u64 start = __pa_symbol(_text);
25918 + u64 start = __pa_symbol(ktla_ktva(_text));
25919 u64 size = __pa_symbol(_end) - start;
25920
25921 /*
25922 @@ -838,8 +877,12 @@ static void __init trim_low_memory_range(void)
25923
25924 void __init setup_arch(char **cmdline_p)
25925 {
25926 +#ifdef CONFIG_X86_32
25927 + memblock_reserve(LOAD_PHYSICAL_ADDR, __pa_symbol(__bss_stop) - LOAD_PHYSICAL_ADDR);
25928 +#else
25929 memblock_reserve(__pa_symbol(_text),
25930 (unsigned long)__bss_stop - (unsigned long)_text);
25931 +#endif
25932
25933 early_reserve_initrd();
25934
25935 @@ -931,14 +974,14 @@ void __init setup_arch(char **cmdline_p)
25936
25937 if (!boot_params.hdr.root_flags)
25938 root_mountflags &= ~MS_RDONLY;
25939 - init_mm.start_code = (unsigned long) _text;
25940 - init_mm.end_code = (unsigned long) _etext;
25941 + init_mm.start_code = ktla_ktva((unsigned long) _text);
25942 + init_mm.end_code = ktla_ktva((unsigned long) _etext);
25943 init_mm.end_data = (unsigned long) _edata;
25944 init_mm.brk = _brk_end;
25945
25946 - code_resource.start = __pa_symbol(_text);
25947 - code_resource.end = __pa_symbol(_etext)-1;
25948 - data_resource.start = __pa_symbol(_etext);
25949 + code_resource.start = __pa_symbol(ktla_ktva(_text));
25950 + code_resource.end = __pa_symbol(ktla_ktva(_etext))-1;
25951 + data_resource.start = __pa_symbol(_sdata);
25952 data_resource.end = __pa_symbol(_edata)-1;
25953 bss_resource.start = __pa_symbol(__bss_start);
25954 bss_resource.end = __pa_symbol(__bss_stop)-1;
25955 diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.c
25956 index 5cdff03..80fa283 100644
25957 --- a/arch/x86/kernel/setup_percpu.c
25958 +++ b/arch/x86/kernel/setup_percpu.c
25959 @@ -21,19 +21,17 @@
25960 #include <asm/cpu.h>
25961 #include <asm/stackprotector.h>
25962
25963 -DEFINE_PER_CPU_READ_MOSTLY(int, cpu_number);
25964 +#ifdef CONFIG_SMP
25965 +DEFINE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
25966 EXPORT_PER_CPU_SYMBOL(cpu_number);
25967 +#endif
25968
25969 -#ifdef CONFIG_X86_64
25970 #define BOOT_PERCPU_OFFSET ((unsigned long)__per_cpu_load)
25971 -#else
25972 -#define BOOT_PERCPU_OFFSET 0
25973 -#endif
25974
25975 DEFINE_PER_CPU(unsigned long, this_cpu_off) = BOOT_PERCPU_OFFSET;
25976 EXPORT_PER_CPU_SYMBOL(this_cpu_off);
25977
25978 -unsigned long __per_cpu_offset[NR_CPUS] __read_mostly = {
25979 +unsigned long __per_cpu_offset[NR_CPUS] __read_only = {
25980 [0 ... NR_CPUS-1] = BOOT_PERCPU_OFFSET,
25981 };
25982 EXPORT_SYMBOL(__per_cpu_offset);
25983 @@ -66,7 +64,7 @@ static bool __init pcpu_need_numa(void)
25984 {
25985 #ifdef CONFIG_NEED_MULTIPLE_NODES
25986 pg_data_t *last = NULL;
25987 - unsigned int cpu;
25988 + int cpu;
25989
25990 for_each_possible_cpu(cpu) {
25991 int node = early_cpu_to_node(cpu);
25992 @@ -155,10 +153,10 @@ static inline void setup_percpu_segment(int cpu)
25993 {
25994 #ifdef CONFIG_X86_32
25995 struct desc_struct gdt;
25996 + unsigned long base = per_cpu_offset(cpu);
25997
25998 - pack_descriptor(&gdt, per_cpu_offset(cpu), 0xFFFFF,
25999 - 0x2 | DESCTYPE_S, 0x8);
26000 - gdt.s = 1;
26001 + pack_descriptor(&gdt, base, (VMALLOC_END - base - 1) >> PAGE_SHIFT,
26002 + 0x83 | DESCTYPE_S, 0xC);
26003 write_gdt_entry(get_cpu_gdt_table(cpu),
26004 GDT_ENTRY_PERCPU, &gdt, DESCTYPE_S);
26005 #endif
26006 @@ -219,6 +217,11 @@ void __init setup_per_cpu_areas(void)
26007 /* alrighty, percpu areas up and running */
26008 delta = (unsigned long)pcpu_base_addr - (unsigned long)__per_cpu_start;
26009 for_each_possible_cpu(cpu) {
26010 +#ifdef CONFIG_CC_STACKPROTECTOR
26011 +#ifdef CONFIG_X86_32
26012 + unsigned long canary = per_cpu(stack_canary.canary, cpu);
26013 +#endif
26014 +#endif
26015 per_cpu_offset(cpu) = delta + pcpu_unit_offsets[cpu];
26016 per_cpu(this_cpu_off, cpu) = per_cpu_offset(cpu);
26017 per_cpu(cpu_number, cpu) = cpu;
26018 @@ -259,6 +262,12 @@ void __init setup_per_cpu_areas(void)
26019 */
26020 set_cpu_numa_node(cpu, early_cpu_to_node(cpu));
26021 #endif
26022 +#ifdef CONFIG_CC_STACKPROTECTOR
26023 +#ifdef CONFIG_X86_32
26024 + if (!cpu)
26025 + per_cpu(stack_canary.canary, cpu) = canary;
26026 +#endif
26027 +#endif
26028 /*
26029 * Up to this point, the boot CPU has been using .init.data
26030 * area. Reload any changed state for the boot CPU.
26031 diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c
26032 index 9e5de68..16c53cb 100644
26033 --- a/arch/x86/kernel/signal.c
26034 +++ b/arch/x86/kernel/signal.c
26035 @@ -190,7 +190,7 @@ static unsigned long align_sigframe(unsigned long sp)
26036 * Align the stack pointer according to the i386 ABI,
26037 * i.e. so that on function entry ((sp + 4) & 15) == 0.
26038 */
26039 - sp = ((sp + 4) & -16ul) - 4;
26040 + sp = ((sp - 12) & -16ul) - 4;
26041 #else /* !CONFIG_X86_32 */
26042 sp = round_down(sp, 16) - 8;
26043 #endif
26044 @@ -298,9 +298,9 @@ __setup_frame(int sig, struct ksignal *ksig, sigset_t *set,
26045 }
26046
26047 if (current->mm->context.vdso)
26048 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
26049 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
26050 else
26051 - restorer = &frame->retcode;
26052 + restorer = (void __user *)&frame->retcode;
26053 if (ksig->ka.sa.sa_flags & SA_RESTORER)
26054 restorer = ksig->ka.sa.sa_restorer;
26055
26056 @@ -314,7 +314,7 @@ __setup_frame(int sig, struct ksignal *ksig, sigset_t *set,
26057 * reasons and because gdb uses it as a signature to notice
26058 * signal handler stack frames.
26059 */
26060 - err |= __put_user(*((u64 *)&retcode), (u64 *)frame->retcode);
26061 + err |= __put_user(*((u64 *)&retcode), (u64 __user *)frame->retcode);
26062
26063 if (err)
26064 return -EFAULT;
26065 @@ -361,7 +361,10 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
26066 save_altstack_ex(&frame->uc.uc_stack, regs->sp);
26067
26068 /* Set up to return from userspace. */
26069 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
26070 + if (current->mm->context.vdso)
26071 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
26072 + else
26073 + restorer = (void __user *)&frame->retcode;
26074 if (ksig->ka.sa.sa_flags & SA_RESTORER)
26075 restorer = ksig->ka.sa.sa_restorer;
26076 put_user_ex(restorer, &frame->pretcode);
26077 @@ -373,7 +376,7 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
26078 * reasons and because gdb uses it as a signature to notice
26079 * signal handler stack frames.
26080 */
26081 - put_user_ex(*((u64 *)&rt_retcode), (u64 *)frame->retcode);
26082 + put_user_ex(*((u64 *)&rt_retcode), (u64 __user *)frame->retcode);
26083 } put_user_catch(err);
26084
26085 err |= copy_siginfo_to_user(&frame->info, &ksig->info);
26086 @@ -609,7 +612,12 @@ setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)
26087 {
26088 int usig = signr_convert(ksig->sig);
26089 sigset_t *set = sigmask_to_save();
26090 - compat_sigset_t *cset = (compat_sigset_t *) set;
26091 + sigset_t sigcopy;
26092 + compat_sigset_t *cset;
26093 +
26094 + sigcopy = *set;
26095 +
26096 + cset = (compat_sigset_t *) &sigcopy;
26097
26098 /* Set up the stack frame */
26099 if (is_ia32_frame()) {
26100 @@ -620,7 +628,7 @@ setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)
26101 } else if (is_x32_frame()) {
26102 return x32_setup_rt_frame(ksig, cset, regs);
26103 } else {
26104 - return __setup_rt_frame(ksig->sig, ksig, set, regs);
26105 + return __setup_rt_frame(ksig->sig, ksig, &sigcopy, regs);
26106 }
26107 }
26108
26109 diff --git a/arch/x86/kernel/smp.c b/arch/x86/kernel/smp.c
26110 index 7c3a5a6..f0a8961 100644
26111 --- a/arch/x86/kernel/smp.c
26112 +++ b/arch/x86/kernel/smp.c
26113 @@ -341,7 +341,7 @@ static int __init nonmi_ipi_setup(char *str)
26114
26115 __setup("nonmi_ipi", nonmi_ipi_setup);
26116
26117 -struct smp_ops smp_ops = {
26118 +struct smp_ops smp_ops __read_only = {
26119 .smp_prepare_boot_cpu = native_smp_prepare_boot_cpu,
26120 .smp_prepare_cpus = native_smp_prepare_cpus,
26121 .smp_cpus_done = native_smp_cpus_done,
26122 diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
26123 index 6cacab6..750636a 100644
26124 --- a/arch/x86/kernel/smpboot.c
26125 +++ b/arch/x86/kernel/smpboot.c
26126 @@ -251,14 +251,18 @@ static void notrace start_secondary(void *unused)
26127
26128 enable_start_cpu0 = 0;
26129
26130 -#ifdef CONFIG_X86_32
26131 - /* switch away from the initial page table */
26132 - load_cr3(swapper_pg_dir);
26133 - __flush_tlb_all();
26134 -#endif
26135 -
26136 /* otherwise gcc will move up smp_processor_id before the cpu_init */
26137 barrier();
26138 +
26139 + /* switch away from the initial page table */
26140 +#ifdef CONFIG_PAX_PER_CPU_PGD
26141 + load_cr3(get_cpu_pgd(smp_processor_id(), kernel));
26142 + __flush_tlb_all();
26143 +#elif defined(CONFIG_X86_32)
26144 + load_cr3(swapper_pg_dir);
26145 + __flush_tlb_all();
26146 +#endif
26147 +
26148 /*
26149 * Check TSC synchronization with the BP:
26150 */
26151 @@ -749,6 +753,7 @@ static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
26152 idle->thread.sp = (unsigned long) (((struct pt_regs *)
26153 (THREAD_SIZE + task_stack_page(idle))) - 1);
26154 per_cpu(current_task, cpu) = idle;
26155 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
26156
26157 #ifdef CONFIG_X86_32
26158 /* Stack for startup_32 can be just as for start_secondary onwards */
26159 @@ -756,11 +761,13 @@ static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
26160 #else
26161 clear_tsk_thread_flag(idle, TIF_FORK);
26162 initial_gs = per_cpu_offset(cpu);
26163 - per_cpu(kernel_stack, cpu) =
26164 - (unsigned long)task_stack_page(idle) -
26165 - KERNEL_STACK_OFFSET + THREAD_SIZE;
26166 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
26167 #endif
26168 +
26169 + pax_open_kernel();
26170 early_gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
26171 + pax_close_kernel();
26172 +
26173 initial_code = (unsigned long)start_secondary;
26174 stack_start = idle->thread.sp;
26175
26176 @@ -909,6 +916,15 @@ int native_cpu_up(unsigned int cpu, struct task_struct *tidle)
26177 /* the FPU context is blank, nobody can own it */
26178 __cpu_disable_lazy_restore(cpu);
26179
26180 +#ifdef CONFIG_PAX_PER_CPU_PGD
26181 + clone_pgd_range(get_cpu_pgd(cpu, kernel) + KERNEL_PGD_BOUNDARY,
26182 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
26183 + KERNEL_PGD_PTRS);
26184 + clone_pgd_range(get_cpu_pgd(cpu, user) + KERNEL_PGD_BOUNDARY,
26185 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
26186 + KERNEL_PGD_PTRS);
26187 +#endif
26188 +
26189 err = do_boot_cpu(apicid, cpu, tidle);
26190 if (err) {
26191 pr_debug("do_boot_cpu failed %d\n", err);
26192 diff --git a/arch/x86/kernel/step.c b/arch/x86/kernel/step.c
26193 index 9b4d51d..5d28b58 100644
26194 --- a/arch/x86/kernel/step.c
26195 +++ b/arch/x86/kernel/step.c
26196 @@ -27,10 +27,10 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
26197 struct desc_struct *desc;
26198 unsigned long base;
26199
26200 - seg &= ~7UL;
26201 + seg >>= 3;
26202
26203 mutex_lock(&child->mm->context.lock);
26204 - if (unlikely((seg >> 3) >= child->mm->context.size))
26205 + if (unlikely(seg >= child->mm->context.size))
26206 addr = -1L; /* bogus selector, access would fault */
26207 else {
26208 desc = child->mm->context.ldt + seg;
26209 @@ -42,7 +42,8 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
26210 addr += base;
26211 }
26212 mutex_unlock(&child->mm->context.lock);
26213 - }
26214 + } else if (seg == __KERNEL_CS || seg == __KERNEXEC_KERNEL_CS)
26215 + addr = ktla_ktva(addr);
26216
26217 return addr;
26218 }
26219 @@ -53,6 +54,9 @@ static int is_setting_trap_flag(struct task_struct *child, struct pt_regs *regs)
26220 unsigned char opcode[15];
26221 unsigned long addr = convert_ip_to_linear(child, regs);
26222
26223 + if (addr == -EINVAL)
26224 + return 0;
26225 +
26226 copied = access_process_vm(child, addr, opcode, sizeof(opcode), 0);
26227 for (i = 0; i < copied; i++) {
26228 switch (opcode[i]) {
26229 diff --git a/arch/x86/kernel/sys_i386_32.c b/arch/x86/kernel/sys_i386_32.c
26230 new file mode 100644
26231 index 0000000..5877189
26232 --- /dev/null
26233 +++ b/arch/x86/kernel/sys_i386_32.c
26234 @@ -0,0 +1,189 @@
26235 +/*
26236 + * This file contains various random system calls that
26237 + * have a non-standard calling sequence on the Linux/i386
26238 + * platform.
26239 + */
26240 +
26241 +#include <linux/errno.h>
26242 +#include <linux/sched.h>
26243 +#include <linux/mm.h>
26244 +#include <linux/fs.h>
26245 +#include <linux/smp.h>
26246 +#include <linux/sem.h>
26247 +#include <linux/msg.h>
26248 +#include <linux/shm.h>
26249 +#include <linux/stat.h>
26250 +#include <linux/syscalls.h>
26251 +#include <linux/mman.h>
26252 +#include <linux/file.h>
26253 +#include <linux/utsname.h>
26254 +#include <linux/ipc.h>
26255 +#include <linux/elf.h>
26256 +
26257 +#include <linux/uaccess.h>
26258 +#include <linux/unistd.h>
26259 +
26260 +#include <asm/syscalls.h>
26261 +
26262 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags)
26263 +{
26264 + unsigned long pax_task_size = TASK_SIZE;
26265 +
26266 +#ifdef CONFIG_PAX_SEGMEXEC
26267 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
26268 + pax_task_size = SEGMEXEC_TASK_SIZE;
26269 +#endif
26270 +
26271 + if (flags & MAP_FIXED)
26272 + if (len > pax_task_size || addr > pax_task_size - len)
26273 + return -EINVAL;
26274 +
26275 + return 0;
26276 +}
26277 +
26278 +/*
26279 + * Align a virtual address to avoid aliasing in the I$ on AMD F15h.
26280 + */
26281 +static unsigned long get_align_mask(void)
26282 +{
26283 + if (va_align.flags < 0 || !(va_align.flags & ALIGN_VA_32))
26284 + return 0;
26285 +
26286 + if (!(current->flags & PF_RANDOMIZE))
26287 + return 0;
26288 +
26289 + return va_align.mask;
26290 +}
26291 +
26292 +unsigned long
26293 +arch_get_unmapped_area(struct file *filp, unsigned long addr,
26294 + unsigned long len, unsigned long pgoff, unsigned long flags)
26295 +{
26296 + struct mm_struct *mm = current->mm;
26297 + struct vm_area_struct *vma;
26298 + unsigned long pax_task_size = TASK_SIZE;
26299 + struct vm_unmapped_area_info info;
26300 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
26301 +
26302 +#ifdef CONFIG_PAX_SEGMEXEC
26303 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
26304 + pax_task_size = SEGMEXEC_TASK_SIZE;
26305 +#endif
26306 +
26307 + pax_task_size -= PAGE_SIZE;
26308 +
26309 + if (len > pax_task_size)
26310 + return -ENOMEM;
26311 +
26312 + if (flags & MAP_FIXED)
26313 + return addr;
26314 +
26315 +#ifdef CONFIG_PAX_RANDMMAP
26316 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
26317 +#endif
26318 +
26319 + if (addr) {
26320 + addr = PAGE_ALIGN(addr);
26321 + if (pax_task_size - len >= addr) {
26322 + vma = find_vma(mm, addr);
26323 + if (check_heap_stack_gap(vma, addr, len, offset))
26324 + return addr;
26325 + }
26326 + }
26327 +
26328 + info.flags = 0;
26329 + info.length = len;
26330 + info.align_mask = filp ? get_align_mask() : 0;
26331 + info.align_offset = pgoff << PAGE_SHIFT;
26332 + info.threadstack_offset = offset;
26333 +
26334 +#ifdef CONFIG_PAX_PAGEEXEC
26335 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE)) {
26336 + info.low_limit = 0x00110000UL;
26337 + info.high_limit = mm->start_code;
26338 +
26339 +#ifdef CONFIG_PAX_RANDMMAP
26340 + if (mm->pax_flags & MF_PAX_RANDMMAP)
26341 + info.low_limit += mm->delta_mmap & 0x03FFF000UL;
26342 +#endif
26343 +
26344 + if (info.low_limit < info.high_limit) {
26345 + addr = vm_unmapped_area(&info);
26346 + if (!IS_ERR_VALUE(addr))
26347 + return addr;
26348 + }
26349 + } else
26350 +#endif
26351 +
26352 + info.low_limit = mm->mmap_base;
26353 + info.high_limit = pax_task_size;
26354 +
26355 + return vm_unmapped_area(&info);
26356 +}
26357 +
26358 +unsigned long
26359 +arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
26360 + const unsigned long len, const unsigned long pgoff,
26361 + const unsigned long flags)
26362 +{
26363 + struct vm_area_struct *vma;
26364 + struct mm_struct *mm = current->mm;
26365 + unsigned long addr = addr0, pax_task_size = TASK_SIZE;
26366 + struct vm_unmapped_area_info info;
26367 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
26368 +
26369 +#ifdef CONFIG_PAX_SEGMEXEC
26370 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
26371 + pax_task_size = SEGMEXEC_TASK_SIZE;
26372 +#endif
26373 +
26374 + pax_task_size -= PAGE_SIZE;
26375 +
26376 + /* requested length too big for entire address space */
26377 + if (len > pax_task_size)
26378 + return -ENOMEM;
26379 +
26380 + if (flags & MAP_FIXED)
26381 + return addr;
26382 +
26383 +#ifdef CONFIG_PAX_PAGEEXEC
26384 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE))
26385 + goto bottomup;
26386 +#endif
26387 +
26388 +#ifdef CONFIG_PAX_RANDMMAP
26389 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
26390 +#endif
26391 +
26392 + /* requesting a specific address */
26393 + if (addr) {
26394 + addr = PAGE_ALIGN(addr);
26395 + if (pax_task_size - len >= addr) {
26396 + vma = find_vma(mm, addr);
26397 + if (check_heap_stack_gap(vma, addr, len, offset))
26398 + return addr;
26399 + }
26400 + }
26401 +
26402 + info.flags = VM_UNMAPPED_AREA_TOPDOWN;
26403 + info.length = len;
26404 + info.low_limit = PAGE_SIZE;
26405 + info.high_limit = mm->mmap_base;
26406 + info.align_mask = filp ? get_align_mask() : 0;
26407 + info.align_offset = pgoff << PAGE_SHIFT;
26408 + info.threadstack_offset = offset;
26409 +
26410 + addr = vm_unmapped_area(&info);
26411 + if (!(addr & ~PAGE_MASK))
26412 + return addr;
26413 + VM_BUG_ON(addr != -ENOMEM);
26414 +
26415 +bottomup:
26416 + /*
26417 + * A failed mmap() very likely causes application failure,
26418 + * so fall back to the bottom-up function here. This scenario
26419 + * can happen with large stack limits and large mmap()
26420 + * allocations.
26421 + */
26422 + return arch_get_unmapped_area(filp, addr0, len, pgoff, flags);
26423 +}
26424 diff --git a/arch/x86/kernel/sys_x86_64.c b/arch/x86/kernel/sys_x86_64.c
26425 index 30277e2..5664a29 100644
26426 --- a/arch/x86/kernel/sys_x86_64.c
26427 +++ b/arch/x86/kernel/sys_x86_64.c
26428 @@ -81,8 +81,8 @@ out:
26429 return error;
26430 }
26431
26432 -static void find_start_end(unsigned long flags, unsigned long *begin,
26433 - unsigned long *end)
26434 +static void find_start_end(struct mm_struct *mm, unsigned long flags,
26435 + unsigned long *begin, unsigned long *end)
26436 {
26437 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT)) {
26438 unsigned long new_begin;
26439 @@ -101,7 +101,7 @@ static void find_start_end(unsigned long flags, unsigned long *begin,
26440 *begin = new_begin;
26441 }
26442 } else {
26443 - *begin = current->mm->mmap_legacy_base;
26444 + *begin = mm->mmap_legacy_base;
26445 *end = TASK_SIZE;
26446 }
26447 }
26448 @@ -114,20 +114,24 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
26449 struct vm_area_struct *vma;
26450 struct vm_unmapped_area_info info;
26451 unsigned long begin, end;
26452 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
26453
26454 if (flags & MAP_FIXED)
26455 return addr;
26456
26457 - find_start_end(flags, &begin, &end);
26458 + find_start_end(mm, flags, &begin, &end);
26459
26460 if (len > end)
26461 return -ENOMEM;
26462
26463 +#ifdef CONFIG_PAX_RANDMMAP
26464 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
26465 +#endif
26466 +
26467 if (addr) {
26468 addr = PAGE_ALIGN(addr);
26469 vma = find_vma(mm, addr);
26470 - if (end - len >= addr &&
26471 - (!vma || addr + len <= vma->vm_start))
26472 + if (end - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
26473 return addr;
26474 }
26475
26476 @@ -137,6 +141,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
26477 info.high_limit = end;
26478 info.align_mask = filp ? get_align_mask() : 0;
26479 info.align_offset = pgoff << PAGE_SHIFT;
26480 + info.threadstack_offset = offset;
26481 return vm_unmapped_area(&info);
26482 }
26483
26484 @@ -149,6 +154,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
26485 struct mm_struct *mm = current->mm;
26486 unsigned long addr = addr0;
26487 struct vm_unmapped_area_info info;
26488 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
26489
26490 /* requested length too big for entire address space */
26491 if (len > TASK_SIZE)
26492 @@ -161,12 +167,15 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
26493 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT))
26494 goto bottomup;
26495
26496 +#ifdef CONFIG_PAX_RANDMMAP
26497 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
26498 +#endif
26499 +
26500 /* requesting a specific address */
26501 if (addr) {
26502 addr = PAGE_ALIGN(addr);
26503 vma = find_vma(mm, addr);
26504 - if (TASK_SIZE - len >= addr &&
26505 - (!vma || addr + len <= vma->vm_start))
26506 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
26507 return addr;
26508 }
26509
26510 @@ -176,6 +185,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
26511 info.high_limit = mm->mmap_base;
26512 info.align_mask = filp ? get_align_mask() : 0;
26513 info.align_offset = pgoff << PAGE_SHIFT;
26514 + info.threadstack_offset = offset;
26515 addr = vm_unmapped_area(&info);
26516 if (!(addr & ~PAGE_MASK))
26517 return addr;
26518 diff --git a/arch/x86/kernel/tboot.c b/arch/x86/kernel/tboot.c
26519 index 91a4496..1730bff 100644
26520 --- a/arch/x86/kernel/tboot.c
26521 +++ b/arch/x86/kernel/tboot.c
26522 @@ -221,7 +221,7 @@ static int tboot_setup_sleep(void)
26523
26524 void tboot_shutdown(u32 shutdown_type)
26525 {
26526 - void (*shutdown)(void);
26527 + void (* __noreturn shutdown)(void);
26528
26529 if (!tboot_enabled())
26530 return;
26531 @@ -243,7 +243,7 @@ void tboot_shutdown(u32 shutdown_type)
26532
26533 switch_to_tboot_pt();
26534
26535 - shutdown = (void(*)(void))(unsigned long)tboot->shutdown_entry;
26536 + shutdown = (void *)tboot->shutdown_entry;
26537 shutdown();
26538
26539 /* should not reach here */
26540 @@ -310,7 +310,7 @@ static int tboot_extended_sleep(u8 sleep_state, u32 val_a, u32 val_b)
26541 return -ENODEV;
26542 }
26543
26544 -static atomic_t ap_wfs_count;
26545 +static atomic_unchecked_t ap_wfs_count;
26546
26547 static int tboot_wait_for_aps(int num_aps)
26548 {
26549 @@ -334,9 +334,9 @@ static int tboot_cpu_callback(struct notifier_block *nfb, unsigned long action,
26550 {
26551 switch (action) {
26552 case CPU_DYING:
26553 - atomic_inc(&ap_wfs_count);
26554 + atomic_inc_unchecked(&ap_wfs_count);
26555 if (num_online_cpus() == 1)
26556 - if (tboot_wait_for_aps(atomic_read(&ap_wfs_count)))
26557 + if (tboot_wait_for_aps(atomic_read_unchecked(&ap_wfs_count)))
26558 return NOTIFY_BAD;
26559 break;
26560 }
26561 @@ -422,7 +422,7 @@ static __init int tboot_late_init(void)
26562
26563 tboot_create_trampoline();
26564
26565 - atomic_set(&ap_wfs_count, 0);
26566 + atomic_set_unchecked(&ap_wfs_count, 0);
26567 register_hotcpu_notifier(&tboot_cpu_notifier);
26568
26569 #ifdef CONFIG_DEBUG_FS
26570 diff --git a/arch/x86/kernel/time.c b/arch/x86/kernel/time.c
26571 index 24d3c91..d06b473 100644
26572 --- a/arch/x86/kernel/time.c
26573 +++ b/arch/x86/kernel/time.c
26574 @@ -30,9 +30,9 @@ unsigned long profile_pc(struct pt_regs *regs)
26575 {
26576 unsigned long pc = instruction_pointer(regs);
26577
26578 - if (!user_mode_vm(regs) && in_lock_functions(pc)) {
26579 + if (!user_mode(regs) && in_lock_functions(pc)) {
26580 #ifdef CONFIG_FRAME_POINTER
26581 - return *(unsigned long *)(regs->bp + sizeof(long));
26582 + return ktla_ktva(*(unsigned long *)(regs->bp + sizeof(long)));
26583 #else
26584 unsigned long *sp =
26585 (unsigned long *)kernel_stack_pointer(regs);
26586 @@ -41,11 +41,17 @@ unsigned long profile_pc(struct pt_regs *regs)
26587 * or above a saved flags. Eflags has bits 22-31 zero,
26588 * kernel addresses don't.
26589 */
26590 +
26591 +#ifdef CONFIG_PAX_KERNEXEC
26592 + return ktla_ktva(sp[0]);
26593 +#else
26594 if (sp[0] >> 22)
26595 return sp[0];
26596 if (sp[1] >> 22)
26597 return sp[1];
26598 #endif
26599 +
26600 +#endif
26601 }
26602 return pc;
26603 }
26604 diff --git a/arch/x86/kernel/tls.c b/arch/x86/kernel/tls.c
26605 index f7fec09..9991981 100644
26606 --- a/arch/x86/kernel/tls.c
26607 +++ b/arch/x86/kernel/tls.c
26608 @@ -84,6 +84,11 @@ int do_set_thread_area(struct task_struct *p, int idx,
26609 if (idx < GDT_ENTRY_TLS_MIN || idx > GDT_ENTRY_TLS_MAX)
26610 return -EINVAL;
26611
26612 +#ifdef CONFIG_PAX_SEGMEXEC
26613 + if ((p->mm->pax_flags & MF_PAX_SEGMEXEC) && (info.contents & MODIFY_LDT_CONTENTS_CODE))
26614 + return -EINVAL;
26615 +#endif
26616 +
26617 set_tls_desc(p, idx, &info, 1);
26618
26619 return 0;
26620 @@ -200,7 +205,7 @@ int regset_tls_set(struct task_struct *target, const struct user_regset *regset,
26621
26622 if (kbuf)
26623 info = kbuf;
26624 - else if (__copy_from_user(infobuf, ubuf, count))
26625 + else if (count > sizeof infobuf || __copy_from_user(infobuf, ubuf, count))
26626 return -EFAULT;
26627 else
26628 info = infobuf;
26629 diff --git a/arch/x86/kernel/tracepoint.c b/arch/x86/kernel/tracepoint.c
26630 index 1c113db..287b42e 100644
26631 --- a/arch/x86/kernel/tracepoint.c
26632 +++ b/arch/x86/kernel/tracepoint.c
26633 @@ -9,11 +9,11 @@
26634 #include <linux/atomic.h>
26635
26636 atomic_t trace_idt_ctr = ATOMIC_INIT(0);
26637 -struct desc_ptr trace_idt_descr = { NR_VECTORS * 16 - 1,
26638 +const struct desc_ptr trace_idt_descr = { NR_VECTORS * 16 - 1,
26639 (unsigned long) trace_idt_table };
26640
26641 /* No need to be aligned, but done to keep all IDTs defined the same way. */
26642 -gate_desc trace_idt_table[NR_VECTORS] __page_aligned_bss;
26643 +gate_desc trace_idt_table[NR_VECTORS] __page_aligned_rodata;
26644
26645 static int trace_irq_vector_refcount;
26646 static DEFINE_MUTEX(irq_vector_mutex);
26647 diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
26648 index 8c8093b..c93f581 100644
26649 --- a/arch/x86/kernel/traps.c
26650 +++ b/arch/x86/kernel/traps.c
26651 @@ -66,7 +66,7 @@
26652 #include <asm/proto.h>
26653
26654 /* No need to be aligned, but done to keep all IDTs defined the same way. */
26655 -gate_desc debug_idt_table[NR_VECTORS] __page_aligned_bss;
26656 +gate_desc debug_idt_table[NR_VECTORS] __page_aligned_rodata;
26657 #else
26658 #include <asm/processor-flags.h>
26659 #include <asm/setup.h>
26660 @@ -75,7 +75,7 @@ asmlinkage int system_call(void);
26661 #endif
26662
26663 /* Must be page-aligned because the real IDT is used in a fixmap. */
26664 -gate_desc idt_table[NR_VECTORS] __page_aligned_bss;
26665 +gate_desc idt_table[NR_VECTORS] __page_aligned_rodata;
26666
26667 DECLARE_BITMAP(used_vectors, NR_VECTORS);
26668 EXPORT_SYMBOL_GPL(used_vectors);
26669 @@ -107,11 +107,11 @@ static inline void preempt_conditional_cli(struct pt_regs *regs)
26670 }
26671
26672 static int __kprobes
26673 -do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
26674 +do_trap_no_signal(struct task_struct *tsk, int trapnr, const char *str,
26675 struct pt_regs *regs, long error_code)
26676 {
26677 #ifdef CONFIG_X86_32
26678 - if (regs->flags & X86_VM_MASK) {
26679 + if (v8086_mode(regs)) {
26680 /*
26681 * Traps 0, 1, 3, 4, and 5 should be forwarded to vm86.
26682 * On nmi (interrupt 2), do_trap should not be called.
26683 @@ -124,12 +124,24 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
26684 return -1;
26685 }
26686 #endif
26687 - if (!user_mode(regs)) {
26688 + if (!user_mode_novm(regs)) {
26689 if (!fixup_exception(regs)) {
26690 tsk->thread.error_code = error_code;
26691 tsk->thread.trap_nr = trapnr;
26692 +
26693 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
26694 + if (trapnr == 12 && ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS))
26695 + str = "PAX: suspicious stack segment fault";
26696 +#endif
26697 +
26698 die(str, regs, error_code);
26699 }
26700 +
26701 +#ifdef CONFIG_PAX_REFCOUNT
26702 + if (trapnr == 4)
26703 + pax_report_refcount_overflow(regs);
26704 +#endif
26705 +
26706 return 0;
26707 }
26708
26709 @@ -137,7 +149,7 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
26710 }
26711
26712 static void __kprobes
26713 -do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
26714 +do_trap(int trapnr, int signr, const char *str, struct pt_regs *regs,
26715 long error_code, siginfo_t *info)
26716 {
26717 struct task_struct *tsk = current;
26718 @@ -161,7 +173,7 @@ do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
26719 if (show_unhandled_signals && unhandled_signal(tsk, signr) &&
26720 printk_ratelimit()) {
26721 pr_info("%s[%d] trap %s ip:%lx sp:%lx error:%lx",
26722 - tsk->comm, tsk->pid, str,
26723 + tsk->comm, task_pid_nr(tsk), str,
26724 regs->ip, regs->sp, error_code);
26725 print_vma_addr(" in ", regs->ip);
26726 pr_cont("\n");
26727 @@ -277,7 +289,7 @@ do_general_protection(struct pt_regs *regs, long error_code)
26728 conditional_sti(regs);
26729
26730 #ifdef CONFIG_X86_32
26731 - if (regs->flags & X86_VM_MASK) {
26732 + if (v8086_mode(regs)) {
26733 local_irq_enable();
26734 handle_vm86_fault((struct kernel_vm86_regs *) regs, error_code);
26735 goto exit;
26736 @@ -285,18 +297,42 @@ do_general_protection(struct pt_regs *regs, long error_code)
26737 #endif
26738
26739 tsk = current;
26740 - if (!user_mode(regs)) {
26741 + if (!user_mode_novm(regs)) {
26742 if (fixup_exception(regs))
26743 goto exit;
26744
26745 tsk->thread.error_code = error_code;
26746 tsk->thread.trap_nr = X86_TRAP_GP;
26747 if (notify_die(DIE_GPF, "general protection fault", regs, error_code,
26748 - X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP)
26749 + X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP) {
26750 +
26751 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
26752 + if ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS)
26753 + die("PAX: suspicious general protection fault", regs, error_code);
26754 + else
26755 +#endif
26756 +
26757 die("general protection fault", regs, error_code);
26758 + }
26759 goto exit;
26760 }
26761
26762 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
26763 + if (!(__supported_pte_mask & _PAGE_NX) && tsk->mm && (tsk->mm->pax_flags & MF_PAX_PAGEEXEC)) {
26764 + struct mm_struct *mm = tsk->mm;
26765 + unsigned long limit;
26766 +
26767 + down_write(&mm->mmap_sem);
26768 + limit = mm->context.user_cs_limit;
26769 + if (limit < TASK_SIZE) {
26770 + track_exec_limit(mm, limit, TASK_SIZE, VM_EXEC);
26771 + up_write(&mm->mmap_sem);
26772 + return;
26773 + }
26774 + up_write(&mm->mmap_sem);
26775 + }
26776 +#endif
26777 +
26778 tsk->thread.error_code = error_code;
26779 tsk->thread.trap_nr = X86_TRAP_GP;
26780
26781 @@ -457,7 +493,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
26782 /* It's safe to allow irq's after DR6 has been saved */
26783 preempt_conditional_sti(regs);
26784
26785 - if (regs->flags & X86_VM_MASK) {
26786 + if (v8086_mode(regs)) {
26787 handle_vm86_trap((struct kernel_vm86_regs *) regs, error_code,
26788 X86_TRAP_DB);
26789 preempt_conditional_cli(regs);
26790 @@ -472,7 +508,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
26791 * We already checked v86 mode above, so we can check for kernel mode
26792 * by just checking the CPL of CS.
26793 */
26794 - if ((dr6 & DR_STEP) && !user_mode(regs)) {
26795 + if ((dr6 & DR_STEP) && !user_mode_novm(regs)) {
26796 tsk->thread.debugreg6 &= ~DR_STEP;
26797 set_tsk_thread_flag(tsk, TIF_SINGLESTEP);
26798 regs->flags &= ~X86_EFLAGS_TF;
26799 @@ -504,7 +540,7 @@ void math_error(struct pt_regs *regs, int error_code, int trapnr)
26800 return;
26801 conditional_sti(regs);
26802
26803 - if (!user_mode_vm(regs))
26804 + if (!user_mode(regs))
26805 {
26806 if (!fixup_exception(regs)) {
26807 task->thread.error_code = error_code;
26808 diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c
26809 index 2ed8459..7cf329f 100644
26810 --- a/arch/x86/kernel/uprobes.c
26811 +++ b/arch/x86/kernel/uprobes.c
26812 @@ -629,7 +629,7 @@ int arch_uprobe_exception_notify(struct notifier_block *self, unsigned long val,
26813 int ret = NOTIFY_DONE;
26814
26815 /* We are only interested in userspace traps */
26816 - if (regs && !user_mode_vm(regs))
26817 + if (regs && !user_mode(regs))
26818 return NOTIFY_DONE;
26819
26820 switch (val) {
26821 @@ -719,7 +719,7 @@ arch_uretprobe_hijack_return_addr(unsigned long trampoline_vaddr, struct pt_regs
26822
26823 if (ncopied != rasize) {
26824 pr_err("uprobe: return address clobbered: pid=%d, %%sp=%#lx, "
26825 - "%%ip=%#lx\n", current->pid, regs->sp, regs->ip);
26826 + "%%ip=%#lx\n", task_pid_nr(current), regs->sp, regs->ip);
26827
26828 force_sig_info(SIGSEGV, SEND_SIG_FORCED, current);
26829 }
26830 diff --git a/arch/x86/kernel/verify_cpu.S b/arch/x86/kernel/verify_cpu.S
26831 index b9242ba..50c5edd 100644
26832 --- a/arch/x86/kernel/verify_cpu.S
26833 +++ b/arch/x86/kernel/verify_cpu.S
26834 @@ -20,6 +20,7 @@
26835 * arch/x86/boot/compressed/head_64.S: Boot cpu verification
26836 * arch/x86/kernel/trampoline_64.S: secondary processor verification
26837 * arch/x86/kernel/head_32.S: processor startup
26838 + * arch/x86/kernel/acpi/realmode/wakeup.S: 32bit processor resume
26839 *
26840 * verify_cpu, returns the status of longmode and SSE in register %eax.
26841 * 0: Success 1: Failure
26842 diff --git a/arch/x86/kernel/vm86_32.c b/arch/x86/kernel/vm86_32.c
26843 index e8edcf5..27f9344 100644
26844 --- a/arch/x86/kernel/vm86_32.c
26845 +++ b/arch/x86/kernel/vm86_32.c
26846 @@ -44,6 +44,7 @@
26847 #include <linux/ptrace.h>
26848 #include <linux/audit.h>
26849 #include <linux/stddef.h>
26850 +#include <linux/grsecurity.h>
26851
26852 #include <asm/uaccess.h>
26853 #include <asm/io.h>
26854 @@ -150,7 +151,7 @@ struct pt_regs *save_v86_state(struct kernel_vm86_regs *regs)
26855 do_exit(SIGSEGV);
26856 }
26857
26858 - tss = &per_cpu(init_tss, get_cpu());
26859 + tss = init_tss + get_cpu();
26860 current->thread.sp0 = current->thread.saved_sp0;
26861 current->thread.sysenter_cs = __KERNEL_CS;
26862 load_sp0(tss, &current->thread);
26863 @@ -214,6 +215,14 @@ SYSCALL_DEFINE1(vm86old, struct vm86_struct __user *, v86)
26864
26865 if (tsk->thread.saved_sp0)
26866 return -EPERM;
26867 +
26868 +#ifdef CONFIG_GRKERNSEC_VM86
26869 + if (!capable(CAP_SYS_RAWIO)) {
26870 + gr_handle_vm86();
26871 + return -EPERM;
26872 + }
26873 +#endif
26874 +
26875 tmp = copy_vm86_regs_from_user(&info.regs, &v86->regs,
26876 offsetof(struct kernel_vm86_struct, vm86plus) -
26877 sizeof(info.regs));
26878 @@ -238,6 +247,13 @@ SYSCALL_DEFINE2(vm86, unsigned long, cmd, unsigned long, arg)
26879 int tmp;
26880 struct vm86plus_struct __user *v86;
26881
26882 +#ifdef CONFIG_GRKERNSEC_VM86
26883 + if (!capable(CAP_SYS_RAWIO)) {
26884 + gr_handle_vm86();
26885 + return -EPERM;
26886 + }
26887 +#endif
26888 +
26889 tsk = current;
26890 switch (cmd) {
26891 case VM86_REQUEST_IRQ:
26892 @@ -318,7 +334,7 @@ static void do_sys_vm86(struct kernel_vm86_struct *info, struct task_struct *tsk
26893 tsk->thread.saved_fs = info->regs32->fs;
26894 tsk->thread.saved_gs = get_user_gs(info->regs32);
26895
26896 - tss = &per_cpu(init_tss, get_cpu());
26897 + tss = init_tss + get_cpu();
26898 tsk->thread.sp0 = (unsigned long) &info->VM86_TSS_ESP0;
26899 if (cpu_has_sep)
26900 tsk->thread.sysenter_cs = 0;
26901 @@ -525,7 +541,7 @@ static void do_int(struct kernel_vm86_regs *regs, int i,
26902 goto cannot_handle;
26903 if (i == 0x21 && is_revectored(AH(regs), &KVM86->int21_revectored))
26904 goto cannot_handle;
26905 - intr_ptr = (unsigned long __user *) (i << 2);
26906 + intr_ptr = (__force unsigned long __user *) (i << 2);
26907 if (get_user(segoffs, intr_ptr))
26908 goto cannot_handle;
26909 if ((segoffs >> 16) == BIOSSEG)
26910 diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
26911 index 10c4f30..65408b9 100644
26912 --- a/arch/x86/kernel/vmlinux.lds.S
26913 +++ b/arch/x86/kernel/vmlinux.lds.S
26914 @@ -26,6 +26,13 @@
26915 #include <asm/page_types.h>
26916 #include <asm/cache.h>
26917 #include <asm/boot.h>
26918 +#include <asm/segment.h>
26919 +
26920 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
26921 +#define __KERNEL_TEXT_OFFSET (LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR)
26922 +#else
26923 +#define __KERNEL_TEXT_OFFSET 0
26924 +#endif
26925
26926 #undef i386 /* in case the preprocessor is a 32bit one */
26927
26928 @@ -69,30 +76,43 @@ jiffies_64 = jiffies;
26929
26930 PHDRS {
26931 text PT_LOAD FLAGS(5); /* R_E */
26932 +#ifdef CONFIG_X86_32
26933 + module PT_LOAD FLAGS(5); /* R_E */
26934 +#endif
26935 +#ifdef CONFIG_XEN
26936 + rodata PT_LOAD FLAGS(5); /* R_E */
26937 +#else
26938 + rodata PT_LOAD FLAGS(4); /* R__ */
26939 +#endif
26940 data PT_LOAD FLAGS(6); /* RW_ */
26941 -#ifdef CONFIG_X86_64
26942 + init.begin PT_LOAD FLAGS(6); /* RW_ */
26943 #ifdef CONFIG_SMP
26944 percpu PT_LOAD FLAGS(6); /* RW_ */
26945 #endif
26946 + text.init PT_LOAD FLAGS(5); /* R_E */
26947 + text.exit PT_LOAD FLAGS(5); /* R_E */
26948 init PT_LOAD FLAGS(7); /* RWE */
26949 -#endif
26950 note PT_NOTE FLAGS(0); /* ___ */
26951 }
26952
26953 SECTIONS
26954 {
26955 #ifdef CONFIG_X86_32
26956 - . = LOAD_OFFSET + LOAD_PHYSICAL_ADDR;
26957 - phys_startup_32 = startup_32 - LOAD_OFFSET;
26958 + . = LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR;
26959 #else
26960 - . = __START_KERNEL;
26961 - phys_startup_64 = startup_64 - LOAD_OFFSET;
26962 + . = __START_KERNEL;
26963 #endif
26964
26965 /* Text and read-only data */
26966 - .text : AT(ADDR(.text) - LOAD_OFFSET) {
26967 - _text = .;
26968 + .text (. - __KERNEL_TEXT_OFFSET): AT(ADDR(.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
26969 /* bootstrapping code */
26970 +#ifdef CONFIG_X86_32
26971 + phys_startup_32 = startup_32 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
26972 +#else
26973 + phys_startup_64 = startup_64 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
26974 +#endif
26975 + __LOAD_PHYSICAL_ADDR = . - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
26976 + _text = .;
26977 HEAD_TEXT
26978 . = ALIGN(8);
26979 _stext = .;
26980 @@ -104,13 +124,47 @@ SECTIONS
26981 IRQENTRY_TEXT
26982 *(.fixup)
26983 *(.gnu.warning)
26984 - /* End of text section */
26985 - _etext = .;
26986 } :text = 0x9090
26987
26988 - NOTES :text :note
26989 + . += __KERNEL_TEXT_OFFSET;
26990
26991 - EXCEPTION_TABLE(16) :text = 0x9090
26992 +#ifdef CONFIG_X86_32
26993 + . = ALIGN(PAGE_SIZE);
26994 + .module.text : AT(ADDR(.module.text) - LOAD_OFFSET) {
26995 +
26996 +#ifdef CONFIG_PAX_KERNEXEC
26997 + MODULES_EXEC_VADDR = .;
26998 + BYTE(0)
26999 + . += (CONFIG_PAX_KERNEXEC_MODULE_TEXT * 1024 * 1024);
27000 + . = ALIGN(HPAGE_SIZE) - 1;
27001 + MODULES_EXEC_END = .;
27002 +#endif
27003 +
27004 + } :module
27005 +#endif
27006 +
27007 + .text.end : AT(ADDR(.text.end) - LOAD_OFFSET) {
27008 + /* End of text section */
27009 + BYTE(0)
27010 + _etext = . - __KERNEL_TEXT_OFFSET;
27011 + }
27012 +
27013 +#ifdef CONFIG_X86_32
27014 + . = ALIGN(PAGE_SIZE);
27015 + .rodata.page_aligned : AT(ADDR(.rodata.page_aligned) - LOAD_OFFSET) {
27016 + . = ALIGN(PAGE_SIZE);
27017 + *(.empty_zero_page)
27018 + *(.initial_pg_fixmap)
27019 + *(.initial_pg_pmd)
27020 + *(.initial_page_table)
27021 + *(.swapper_pg_dir)
27022 + } :rodata
27023 +#endif
27024 +
27025 + . = ALIGN(PAGE_SIZE);
27026 + NOTES :rodata :note
27027 +
27028 + EXCEPTION_TABLE(16) :rodata
27029
27030 #if defined(CONFIG_DEBUG_RODATA)
27031 /* .text should occupy whole number of pages */
27032 @@ -122,16 +176,20 @@ SECTIONS
27033
27034 /* Data */
27035 .data : AT(ADDR(.data) - LOAD_OFFSET) {
27036 +
27037 +#ifdef CONFIG_PAX_KERNEXEC
27038 + . = ALIGN(HPAGE_SIZE);
27039 +#else
27040 + . = ALIGN(PAGE_SIZE);
27041 +#endif
27042 +
27043 /* Start of data section */
27044 _sdata = .;
27045
27046 /* init_task */
27047 INIT_TASK_DATA(THREAD_SIZE)
27048
27049 -#ifdef CONFIG_X86_32
27050 - /* 32 bit has nosave before _edata */
27051 NOSAVE_DATA
27052 -#endif
27053
27054 PAGE_ALIGNED_DATA(PAGE_SIZE)
27055
27056 @@ -172,12 +230,19 @@ SECTIONS
27057 #endif /* CONFIG_X86_64 */
27058
27059 /* Init code and data - will be freed after init */
27060 - . = ALIGN(PAGE_SIZE);
27061 .init.begin : AT(ADDR(.init.begin) - LOAD_OFFSET) {
27062 + BYTE(0)
27063 +
27064 +#ifdef CONFIG_PAX_KERNEXEC
27065 + . = ALIGN(HPAGE_SIZE);
27066 +#else
27067 + . = ALIGN(PAGE_SIZE);
27068 +#endif
27069 +
27070 __init_begin = .; /* paired with __init_end */
27071 - }
27072 + } :init.begin
27073
27074 -#if defined(CONFIG_X86_64) && defined(CONFIG_SMP)
27075 +#ifdef CONFIG_SMP
27076 /*
27077 * percpu offsets are zero-based on SMP. PERCPU_VADDR() changes the
27078 * output PHDR, so the next output section - .init.text - should
27079 @@ -186,12 +251,27 @@ SECTIONS
27080 PERCPU_VADDR(INTERNODE_CACHE_BYTES, 0, :percpu)
27081 #endif
27082
27083 - INIT_TEXT_SECTION(PAGE_SIZE)
27084 -#ifdef CONFIG_X86_64
27085 - :init
27086 -#endif
27087 + . = ALIGN(PAGE_SIZE);
27088 + init_begin = .;
27089 + .init.text (. - __KERNEL_TEXT_OFFSET): AT(init_begin - LOAD_OFFSET) {
27090 + VMLINUX_SYMBOL(_sinittext) = .;
27091 + INIT_TEXT
27092 + VMLINUX_SYMBOL(_einittext) = .;
27093 + . = ALIGN(PAGE_SIZE);
27094 + } :text.init
27095
27096 - INIT_DATA_SECTION(16)
27097 + /*
27098 + * .exit.text is discard at runtime, not link time, to deal with
27099 + * references from .altinstructions and .eh_frame
27100 + */
27101 + .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
27102 + EXIT_TEXT
27103 + . = ALIGN(16);
27104 + } :text.exit
27105 + . = init_begin + SIZEOF(.init.text) + SIZEOF(.exit.text);
27106 +
27107 + . = ALIGN(PAGE_SIZE);
27108 + INIT_DATA_SECTION(16) :init
27109
27110 .x86_cpu_dev.init : AT(ADDR(.x86_cpu_dev.init) - LOAD_OFFSET) {
27111 __x86_cpu_dev_start = .;
27112 @@ -253,19 +333,12 @@ SECTIONS
27113 }
27114
27115 . = ALIGN(8);
27116 - /*
27117 - * .exit.text is discard at runtime, not link time, to deal with
27118 - * references from .altinstructions and .eh_frame
27119 - */
27120 - .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) {
27121 - EXIT_TEXT
27122 - }
27123
27124 .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) {
27125 EXIT_DATA
27126 }
27127
27128 -#if !defined(CONFIG_X86_64) || !defined(CONFIG_SMP)
27129 +#ifndef CONFIG_SMP
27130 PERCPU_SECTION(INTERNODE_CACHE_BYTES)
27131 #endif
27132
27133 @@ -284,16 +357,10 @@ SECTIONS
27134 .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
27135 __smp_locks = .;
27136 *(.smp_locks)
27137 - . = ALIGN(PAGE_SIZE);
27138 __smp_locks_end = .;
27139 + . = ALIGN(PAGE_SIZE);
27140 }
27141
27142 -#ifdef CONFIG_X86_64
27143 - .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
27144 - NOSAVE_DATA
27145 - }
27146 -#endif
27147 -
27148 /* BSS */
27149 . = ALIGN(PAGE_SIZE);
27150 .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
27151 @@ -309,6 +376,7 @@ SECTIONS
27152 __brk_base = .;
27153 . += 64 * 1024; /* 64k alignment slop space */
27154 *(.brk_reservation) /* areas brk users have reserved */
27155 + . = ALIGN(HPAGE_SIZE);
27156 __brk_limit = .;
27157 }
27158
27159 @@ -335,13 +403,12 @@ SECTIONS
27160 * for the boot processor.
27161 */
27162 #define INIT_PER_CPU(x) init_per_cpu__##x = x + __per_cpu_load
27163 -INIT_PER_CPU(gdt_page);
27164 INIT_PER_CPU(irq_stack_union);
27165
27166 /*
27167 * Build-time check on the image size:
27168 */
27169 -. = ASSERT((_end - _text <= KERNEL_IMAGE_SIZE),
27170 +. = ASSERT((_end - _text - __KERNEL_TEXT_OFFSET <= KERNEL_IMAGE_SIZE),
27171 "kernel image bigger than KERNEL_IMAGE_SIZE");
27172
27173 #ifdef CONFIG_SMP
27174 diff --git a/arch/x86/kernel/vsyscall_64.c b/arch/x86/kernel/vsyscall_64.c
27175 index 1f96f93..d5c8f7a 100644
27176 --- a/arch/x86/kernel/vsyscall_64.c
27177 +++ b/arch/x86/kernel/vsyscall_64.c
27178 @@ -56,15 +56,13 @@
27179 DEFINE_VVAR(int, vgetcpu_mode);
27180 DEFINE_VVAR(struct vsyscall_gtod_data, vsyscall_gtod_data);
27181
27182 -static enum { EMULATE, NATIVE, NONE } vsyscall_mode = EMULATE;
27183 +static enum { EMULATE, NONE } vsyscall_mode = EMULATE;
27184
27185 static int __init vsyscall_setup(char *str)
27186 {
27187 if (str) {
27188 if (!strcmp("emulate", str))
27189 vsyscall_mode = EMULATE;
27190 - else if (!strcmp("native", str))
27191 - vsyscall_mode = NATIVE;
27192 else if (!strcmp("none", str))
27193 vsyscall_mode = NONE;
27194 else
27195 @@ -323,8 +321,7 @@ do_ret:
27196 return true;
27197
27198 sigsegv:
27199 - force_sig(SIGSEGV, current);
27200 - return true;
27201 + do_group_exit(SIGKILL);
27202 }
27203
27204 /*
27205 @@ -377,10 +374,7 @@ void __init map_vsyscall(void)
27206 extern char __vvar_page;
27207 unsigned long physaddr_vvar_page = __pa_symbol(&__vvar_page);
27208
27209 - __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall,
27210 - vsyscall_mode == NATIVE
27211 - ? PAGE_KERNEL_VSYSCALL
27212 - : PAGE_KERNEL_VVAR);
27213 + __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall, PAGE_KERNEL_VVAR);
27214 BUILD_BUG_ON((unsigned long)__fix_to_virt(VSYSCALL_FIRST_PAGE) !=
27215 (unsigned long)VSYSCALL_START);
27216
27217 diff --git a/arch/x86/kernel/x8664_ksyms_64.c b/arch/x86/kernel/x8664_ksyms_64.c
27218 index b014d94..e775258 100644
27219 --- a/arch/x86/kernel/x8664_ksyms_64.c
27220 +++ b/arch/x86/kernel/x8664_ksyms_64.c
27221 @@ -34,8 +34,6 @@ EXPORT_SYMBOL(copy_user_generic_string);
27222 EXPORT_SYMBOL(copy_user_generic_unrolled);
27223 EXPORT_SYMBOL(copy_user_enhanced_fast_string);
27224 EXPORT_SYMBOL(__copy_user_nocache);
27225 -EXPORT_SYMBOL(_copy_from_user);
27226 -EXPORT_SYMBOL(_copy_to_user);
27227
27228 EXPORT_SYMBOL(copy_page);
27229 EXPORT_SYMBOL(clear_page);
27230 @@ -66,3 +64,7 @@ EXPORT_SYMBOL(empty_zero_page);
27231 #ifndef CONFIG_PARAVIRT
27232 EXPORT_SYMBOL(native_load_gs_index);
27233 #endif
27234 +
27235 +#ifdef CONFIG_PAX_PER_CPU_PGD
27236 +EXPORT_SYMBOL(cpu_pgd);
27237 +#endif
27238 diff --git a/arch/x86/kernel/x86_init.c b/arch/x86/kernel/x86_init.c
27239 index 8ce0072..431a0e7 100644
27240 --- a/arch/x86/kernel/x86_init.c
27241 +++ b/arch/x86/kernel/x86_init.c
27242 @@ -93,7 +93,7 @@ struct x86_cpuinit_ops x86_cpuinit = {
27243 static void default_nmi_init(void) { };
27244 static int default_i8042_detect(void) { return 1; };
27245
27246 -struct x86_platform_ops x86_platform = {
27247 +struct x86_platform_ops x86_platform __read_only = {
27248 .calibrate_tsc = native_calibrate_tsc,
27249 .get_wallclock = mach_get_cmos_time,
27250 .set_wallclock = mach_set_rtc_mmss,
27251 @@ -109,7 +109,7 @@ struct x86_platform_ops x86_platform = {
27252 EXPORT_SYMBOL_GPL(x86_platform);
27253
27254 #if defined(CONFIG_PCI_MSI)
27255 -struct x86_msi_ops x86_msi = {
27256 +struct x86_msi_ops x86_msi __read_only = {
27257 .setup_msi_irqs = native_setup_msi_irqs,
27258 .compose_msi_msg = native_compose_msi_msg,
27259 .teardown_msi_irq = native_teardown_msi_irq,
27260 @@ -140,7 +140,7 @@ void arch_restore_msi_irqs(struct pci_dev *dev, int irq)
27261 }
27262 #endif
27263
27264 -struct x86_io_apic_ops x86_io_apic_ops = {
27265 +struct x86_io_apic_ops x86_io_apic_ops __read_only = {
27266 .init = native_io_apic_init_mappings,
27267 .read = native_io_apic_read,
27268 .write = native_io_apic_write,
27269 diff --git a/arch/x86/kernel/xsave.c b/arch/x86/kernel/xsave.c
27270 index 422fd82..c3687ca 100644
27271 --- a/arch/x86/kernel/xsave.c
27272 +++ b/arch/x86/kernel/xsave.c
27273 @@ -199,6 +199,7 @@ static inline int save_user_xstate(struct xsave_struct __user *buf)
27274 {
27275 int err;
27276
27277 + buf = (struct xsave_struct __user *)____m(buf);
27278 if (use_xsave())
27279 err = xsave_user(buf);
27280 else if (use_fxsr())
27281 @@ -311,6 +312,7 @@ sanitize_restored_xstate(struct task_struct *tsk,
27282 */
27283 static inline int restore_user_xstate(void __user *buf, u64 xbv, int fx_only)
27284 {
27285 + buf = (void __user *)____m(buf);
27286 if (use_xsave()) {
27287 if ((unsigned long)buf % 64 || fx_only) {
27288 u64 init_bv = pcntxt_mask & ~XSTATE_FPSSE;
27289 diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
27290 index b110fe6..d9c19f2 100644
27291 --- a/arch/x86/kvm/cpuid.c
27292 +++ b/arch/x86/kvm/cpuid.c
27293 @@ -124,15 +124,20 @@ int kvm_vcpu_ioctl_set_cpuid2(struct kvm_vcpu *vcpu,
27294 struct kvm_cpuid2 *cpuid,
27295 struct kvm_cpuid_entry2 __user *entries)
27296 {
27297 - int r;
27298 + int r, i;
27299
27300 r = -E2BIG;
27301 if (cpuid->nent > KVM_MAX_CPUID_ENTRIES)
27302 goto out;
27303 r = -EFAULT;
27304 - if (copy_from_user(&vcpu->arch.cpuid_entries, entries,
27305 - cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
27306 + if (!access_ok(VERIFY_READ, entries, cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
27307 goto out;
27308 + for (i = 0; i < cpuid->nent; ++i) {
27309 + struct kvm_cpuid_entry2 cpuid_entry;
27310 + if (__copy_from_user(&cpuid_entry, entries + i, sizeof(cpuid_entry)))
27311 + goto out;
27312 + vcpu->arch.cpuid_entries[i] = cpuid_entry;
27313 + }
27314 vcpu->arch.cpuid_nent = cpuid->nent;
27315 kvm_apic_set_version(vcpu);
27316 kvm_x86_ops->cpuid_update(vcpu);
27317 @@ -147,15 +152,19 @@ int kvm_vcpu_ioctl_get_cpuid2(struct kvm_vcpu *vcpu,
27318 struct kvm_cpuid2 *cpuid,
27319 struct kvm_cpuid_entry2 __user *entries)
27320 {
27321 - int r;
27322 + int r, i;
27323
27324 r = -E2BIG;
27325 if (cpuid->nent < vcpu->arch.cpuid_nent)
27326 goto out;
27327 r = -EFAULT;
27328 - if (copy_to_user(entries, &vcpu->arch.cpuid_entries,
27329 - vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
27330 + if (!access_ok(VERIFY_WRITE, entries, vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
27331 goto out;
27332 + for (i = 0; i < vcpu->arch.cpuid_nent; ++i) {
27333 + struct kvm_cpuid_entry2 cpuid_entry = vcpu->arch.cpuid_entries[i];
27334 + if (__copy_to_user(entries + i, &cpuid_entry, sizeof(cpuid_entry)))
27335 + goto out;
27336 + }
27337 return 0;
27338
27339 out:
27340 diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
27341 index dec48bf..f4d21f7 100644
27342 --- a/arch/x86/kvm/lapic.c
27343 +++ b/arch/x86/kvm/lapic.c
27344 @@ -55,7 +55,7 @@
27345 #define APIC_BUS_CYCLE_NS 1
27346
27347 /* #define apic_debug(fmt,arg...) printk(KERN_WARNING fmt,##arg) */
27348 -#define apic_debug(fmt, arg...)
27349 +#define apic_debug(fmt, arg...) do {} while (0)
27350
27351 #define APIC_LVT_NUM 6
27352 /* 14 is the version for Xeon and Pentium 8.4.8*/
27353 diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
27354 index ad75d77..a679d32 100644
27355 --- a/arch/x86/kvm/paging_tmpl.h
27356 +++ b/arch/x86/kvm/paging_tmpl.h
27357 @@ -331,7 +331,7 @@ retry_walk:
27358 if (unlikely(kvm_is_error_hva(host_addr)))
27359 goto error;
27360
27361 - ptep_user = (pt_element_t __user *)((void *)host_addr + offset);
27362 + ptep_user = (pt_element_t __force_user *)((void *)host_addr + offset);
27363 if (unlikely(__copy_from_user(&pte, ptep_user, sizeof(pte))))
27364 goto error;
27365 walker->ptep_user[walker->level - 1] = ptep_user;
27366 diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
27367 index c0bc803..6837a50 100644
27368 --- a/arch/x86/kvm/svm.c
27369 +++ b/arch/x86/kvm/svm.c
27370 @@ -3501,7 +3501,11 @@ static void reload_tss(struct kvm_vcpu *vcpu)
27371 int cpu = raw_smp_processor_id();
27372
27373 struct svm_cpu_data *sd = per_cpu(svm_data, cpu);
27374 +
27375 + pax_open_kernel();
27376 sd->tss_desc->type = 9; /* available 32/64-bit TSS */
27377 + pax_close_kernel();
27378 +
27379 load_TR_desc();
27380 }
27381
27382 @@ -3902,6 +3906,10 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu)
27383 #endif
27384 #endif
27385
27386 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
27387 + __set_fs(current_thread_info()->addr_limit);
27388 +#endif
27389 +
27390 reload_tss(vcpu);
27391
27392 local_irq_disable();
27393 diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
27394 index 2b2fce1..da76be4 100644
27395 --- a/arch/x86/kvm/vmx.c
27396 +++ b/arch/x86/kvm/vmx.c
27397 @@ -1316,12 +1316,12 @@ static void vmcs_write64(unsigned long field, u64 value)
27398 #endif
27399 }
27400
27401 -static void vmcs_clear_bits(unsigned long field, u32 mask)
27402 +static void vmcs_clear_bits(unsigned long field, unsigned long mask)
27403 {
27404 vmcs_writel(field, vmcs_readl(field) & ~mask);
27405 }
27406
27407 -static void vmcs_set_bits(unsigned long field, u32 mask)
27408 +static void vmcs_set_bits(unsigned long field, unsigned long mask)
27409 {
27410 vmcs_writel(field, vmcs_readl(field) | mask);
27411 }
27412 @@ -1522,7 +1522,11 @@ static void reload_tss(void)
27413 struct desc_struct *descs;
27414
27415 descs = (void *)gdt->address;
27416 +
27417 + pax_open_kernel();
27418 descs[GDT_ENTRY_TSS].type = 9; /* available TSS */
27419 + pax_close_kernel();
27420 +
27421 load_TR_desc();
27422 }
27423
27424 @@ -1746,6 +1750,10 @@ static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
27425 vmcs_writel(HOST_TR_BASE, kvm_read_tr_base()); /* 22.2.4 */
27426 vmcs_writel(HOST_GDTR_BASE, gdt->address); /* 22.2.4 */
27427
27428 +#ifdef CONFIG_PAX_PER_CPU_PGD
27429 + vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
27430 +#endif
27431 +
27432 rdmsrl(MSR_IA32_SYSENTER_ESP, sysenter_esp);
27433 vmcs_writel(HOST_IA32_SYSENTER_ESP, sysenter_esp); /* 22.2.3 */
27434 vmx->loaded_vmcs->cpu = cpu;
27435 @@ -2037,7 +2045,7 @@ static void setup_msrs(struct vcpu_vmx *vmx)
27436 * reads and returns guest's timestamp counter "register"
27437 * guest_tsc = host_tsc + tsc_offset -- 21.3
27438 */
27439 -static u64 guest_read_tsc(void)
27440 +static u64 __intentional_overflow(-1) guest_read_tsc(void)
27441 {
27442 u64 host_tsc, tsc_offset;
27443
27444 @@ -2982,8 +2990,11 @@ static __init int hardware_setup(void)
27445 if (!cpu_has_vmx_flexpriority())
27446 flexpriority_enabled = 0;
27447
27448 - if (!cpu_has_vmx_tpr_shadow())
27449 - kvm_x86_ops->update_cr8_intercept = NULL;
27450 + if (!cpu_has_vmx_tpr_shadow()) {
27451 + pax_open_kernel();
27452 + *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
27453 + pax_close_kernel();
27454 + }
27455
27456 if (enable_ept && !cpu_has_vmx_ept_2m_page())
27457 kvm_disable_largepages();
27458 @@ -2994,13 +3005,15 @@ static __init int hardware_setup(void)
27459 if (!cpu_has_vmx_apicv())
27460 enable_apicv = 0;
27461
27462 + pax_open_kernel();
27463 if (enable_apicv)
27464 - kvm_x86_ops->update_cr8_intercept = NULL;
27465 + *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
27466 else {
27467 - kvm_x86_ops->hwapic_irr_update = NULL;
27468 - kvm_x86_ops->deliver_posted_interrupt = NULL;
27469 - kvm_x86_ops->sync_pir_to_irr = vmx_sync_pir_to_irr_dummy;
27470 + *(void **)&kvm_x86_ops->hwapic_irr_update = NULL;
27471 + *(void **)&kvm_x86_ops->deliver_posted_interrupt = NULL;
27472 + *(void **)&kvm_x86_ops->sync_pir_to_irr = vmx_sync_pir_to_irr_dummy;
27473 }
27474 + pax_close_kernel();
27475
27476 if (nested)
27477 nested_vmx_setup_ctls_msrs();
27478 @@ -4127,7 +4140,10 @@ static void vmx_set_constant_host_state(struct vcpu_vmx *vmx)
27479
27480 vmcs_writel(HOST_CR0, read_cr0() & ~X86_CR0_TS); /* 22.2.3 */
27481 vmcs_writel(HOST_CR4, read_cr4()); /* 22.2.3, 22.2.5 */
27482 +
27483 +#ifndef CONFIG_PAX_PER_CPU_PGD
27484 vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
27485 +#endif
27486
27487 vmcs_write16(HOST_CS_SELECTOR, __KERNEL_CS); /* 22.2.4 */
27488 #ifdef CONFIG_X86_64
27489 @@ -4149,7 +4165,7 @@ static void vmx_set_constant_host_state(struct vcpu_vmx *vmx)
27490 vmcs_writel(HOST_IDTR_BASE, dt.address); /* 22.2.4 */
27491 vmx->host_idt_base = dt.address;
27492
27493 - vmcs_writel(HOST_RIP, vmx_return); /* 22.2.5 */
27494 + vmcs_writel(HOST_RIP, ktla_ktva(vmx_return)); /* 22.2.5 */
27495
27496 rdmsr(MSR_IA32_SYSENTER_CS, low32, high32);
27497 vmcs_write32(HOST_IA32_SYSENTER_CS, low32);
27498 @@ -7191,6 +7207,12 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
27499 "jmp 2f \n\t"
27500 "1: " __ex(ASM_VMX_VMRESUME) "\n\t"
27501 "2: "
27502 +
27503 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27504 + "ljmp %[cs],$3f\n\t"
27505 + "3: "
27506 +#endif
27507 +
27508 /* Save guest registers, load host registers, keep flags */
27509 "mov %0, %c[wordsize](%%" _ASM_SP ") \n\t"
27510 "pop %0 \n\t"
27511 @@ -7243,6 +7265,11 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
27512 #endif
27513 [cr2]"i"(offsetof(struct vcpu_vmx, vcpu.arch.cr2)),
27514 [wordsize]"i"(sizeof(ulong))
27515 +
27516 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27517 + ,[cs]"i"(__KERNEL_CS)
27518 +#endif
27519 +
27520 : "cc", "memory"
27521 #ifdef CONFIG_X86_64
27522 , "rax", "rbx", "rdi", "rsi"
27523 @@ -7256,7 +7283,7 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
27524 if (debugctlmsr)
27525 update_debugctlmsr(debugctlmsr);
27526
27527 -#ifndef CONFIG_X86_64
27528 +#ifdef CONFIG_X86_32
27529 /*
27530 * The sysexit path does not restore ds/es, so we must set them to
27531 * a reasonable value ourselves.
27532 @@ -7265,8 +7292,18 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
27533 * may be executed in interrupt context, which saves and restore segments
27534 * around it, nullifying its effect.
27535 */
27536 - loadsegment(ds, __USER_DS);
27537 - loadsegment(es, __USER_DS);
27538 + loadsegment(ds, __KERNEL_DS);
27539 + loadsegment(es, __KERNEL_DS);
27540 + loadsegment(ss, __KERNEL_DS);
27541 +
27542 +#ifdef CONFIG_PAX_KERNEXEC
27543 + loadsegment(fs, __KERNEL_PERCPU);
27544 +#endif
27545 +
27546 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27547 + __set_fs(current_thread_info()->addr_limit);
27548 +#endif
27549 +
27550 #endif
27551
27552 vcpu->arch.regs_avail = ~((1 << VCPU_REGS_RIP) | (1 << VCPU_REGS_RSP)
27553 diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
27554 index eb9b9c9..0f30b12 100644
27555 --- a/arch/x86/kvm/x86.c
27556 +++ b/arch/x86/kvm/x86.c
27557 @@ -1779,8 +1779,8 @@ static int xen_hvm_config(struct kvm_vcpu *vcpu, u64 data)
27558 {
27559 struct kvm *kvm = vcpu->kvm;
27560 int lm = is_long_mode(vcpu);
27561 - u8 *blob_addr = lm ? (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_64
27562 - : (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
27563 + u8 __user *blob_addr = lm ? (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_64
27564 + : (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
27565 u8 blob_size = lm ? kvm->arch.xen_hvm_config.blob_size_64
27566 : kvm->arch.xen_hvm_config.blob_size_32;
27567 u32 page_num = data & ~PAGE_MASK;
27568 @@ -2663,6 +2663,8 @@ long kvm_arch_dev_ioctl(struct file *filp,
27569 if (n < msr_list.nmsrs)
27570 goto out;
27571 r = -EFAULT;
27572 + if (num_msrs_to_save > ARRAY_SIZE(msrs_to_save))
27573 + goto out;
27574 if (copy_to_user(user_msr_list->indices, &msrs_to_save,
27575 num_msrs_to_save * sizeof(u32)))
27576 goto out;
27577 @@ -5461,7 +5463,7 @@ static struct notifier_block pvclock_gtod_notifier = {
27578 };
27579 #endif
27580
27581 -int kvm_arch_init(void *opaque)
27582 +int kvm_arch_init(const void *opaque)
27583 {
27584 int r;
27585 struct kvm_x86_ops *ops = opaque;
27586 diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c
27587 index bdf8532..f63c587 100644
27588 --- a/arch/x86/lguest/boot.c
27589 +++ b/arch/x86/lguest/boot.c
27590 @@ -1206,9 +1206,10 @@ static __init int early_put_chars(u32 vtermno, const char *buf, int count)
27591 * Rebooting also tells the Host we're finished, but the RESTART flag tells the
27592 * Launcher to reboot us.
27593 */
27594 -static void lguest_restart(char *reason)
27595 +static __noreturn void lguest_restart(char *reason)
27596 {
27597 hcall(LHCALL_SHUTDOWN, __pa(reason), LGUEST_SHUTDOWN_RESTART, 0, 0);
27598 + BUG();
27599 }
27600
27601 /*G:050
27602 diff --git a/arch/x86/lib/atomic64_386_32.S b/arch/x86/lib/atomic64_386_32.S
27603 index 00933d5..3a64af9 100644
27604 --- a/arch/x86/lib/atomic64_386_32.S
27605 +++ b/arch/x86/lib/atomic64_386_32.S
27606 @@ -48,6 +48,10 @@ BEGIN(read)
27607 movl (v), %eax
27608 movl 4(v), %edx
27609 RET_ENDP
27610 +BEGIN(read_unchecked)
27611 + movl (v), %eax
27612 + movl 4(v), %edx
27613 +RET_ENDP
27614 #undef v
27615
27616 #define v %esi
27617 @@ -55,6 +59,10 @@ BEGIN(set)
27618 movl %ebx, (v)
27619 movl %ecx, 4(v)
27620 RET_ENDP
27621 +BEGIN(set_unchecked)
27622 + movl %ebx, (v)
27623 + movl %ecx, 4(v)
27624 +RET_ENDP
27625 #undef v
27626
27627 #define v %esi
27628 @@ -70,6 +78,20 @@ RET_ENDP
27629 BEGIN(add)
27630 addl %eax, (v)
27631 adcl %edx, 4(v)
27632 +
27633 +#ifdef CONFIG_PAX_REFCOUNT
27634 + jno 0f
27635 + subl %eax, (v)
27636 + sbbl %edx, 4(v)
27637 + int $4
27638 +0:
27639 + _ASM_EXTABLE(0b, 0b)
27640 +#endif
27641 +
27642 +RET_ENDP
27643 +BEGIN(add_unchecked)
27644 + addl %eax, (v)
27645 + adcl %edx, 4(v)
27646 RET_ENDP
27647 #undef v
27648
27649 @@ -77,6 +99,24 @@ RET_ENDP
27650 BEGIN(add_return)
27651 addl (v), %eax
27652 adcl 4(v), %edx
27653 +
27654 +#ifdef CONFIG_PAX_REFCOUNT
27655 + into
27656 +1234:
27657 + _ASM_EXTABLE(1234b, 2f)
27658 +#endif
27659 +
27660 + movl %eax, (v)
27661 + movl %edx, 4(v)
27662 +
27663 +#ifdef CONFIG_PAX_REFCOUNT
27664 +2:
27665 +#endif
27666 +
27667 +RET_ENDP
27668 +BEGIN(add_return_unchecked)
27669 + addl (v), %eax
27670 + adcl 4(v), %edx
27671 movl %eax, (v)
27672 movl %edx, 4(v)
27673 RET_ENDP
27674 @@ -86,6 +126,20 @@ RET_ENDP
27675 BEGIN(sub)
27676 subl %eax, (v)
27677 sbbl %edx, 4(v)
27678 +
27679 +#ifdef CONFIG_PAX_REFCOUNT
27680 + jno 0f
27681 + addl %eax, (v)
27682 + adcl %edx, 4(v)
27683 + int $4
27684 +0:
27685 + _ASM_EXTABLE(0b, 0b)
27686 +#endif
27687 +
27688 +RET_ENDP
27689 +BEGIN(sub_unchecked)
27690 + subl %eax, (v)
27691 + sbbl %edx, 4(v)
27692 RET_ENDP
27693 #undef v
27694
27695 @@ -96,6 +150,27 @@ BEGIN(sub_return)
27696 sbbl $0, %edx
27697 addl (v), %eax
27698 adcl 4(v), %edx
27699 +
27700 +#ifdef CONFIG_PAX_REFCOUNT
27701 + into
27702 +1234:
27703 + _ASM_EXTABLE(1234b, 2f)
27704 +#endif
27705 +
27706 + movl %eax, (v)
27707 + movl %edx, 4(v)
27708 +
27709 +#ifdef CONFIG_PAX_REFCOUNT
27710 +2:
27711 +#endif
27712 +
27713 +RET_ENDP
27714 +BEGIN(sub_return_unchecked)
27715 + negl %edx
27716 + negl %eax
27717 + sbbl $0, %edx
27718 + addl (v), %eax
27719 + adcl 4(v), %edx
27720 movl %eax, (v)
27721 movl %edx, 4(v)
27722 RET_ENDP
27723 @@ -105,6 +180,20 @@ RET_ENDP
27724 BEGIN(inc)
27725 addl $1, (v)
27726 adcl $0, 4(v)
27727 +
27728 +#ifdef CONFIG_PAX_REFCOUNT
27729 + jno 0f
27730 + subl $1, (v)
27731 + sbbl $0, 4(v)
27732 + int $4
27733 +0:
27734 + _ASM_EXTABLE(0b, 0b)
27735 +#endif
27736 +
27737 +RET_ENDP
27738 +BEGIN(inc_unchecked)
27739 + addl $1, (v)
27740 + adcl $0, 4(v)
27741 RET_ENDP
27742 #undef v
27743
27744 @@ -114,6 +203,26 @@ BEGIN(inc_return)
27745 movl 4(v), %edx
27746 addl $1, %eax
27747 adcl $0, %edx
27748 +
27749 +#ifdef CONFIG_PAX_REFCOUNT
27750 + into
27751 +1234:
27752 + _ASM_EXTABLE(1234b, 2f)
27753 +#endif
27754 +
27755 + movl %eax, (v)
27756 + movl %edx, 4(v)
27757 +
27758 +#ifdef CONFIG_PAX_REFCOUNT
27759 +2:
27760 +#endif
27761 +
27762 +RET_ENDP
27763 +BEGIN(inc_return_unchecked)
27764 + movl (v), %eax
27765 + movl 4(v), %edx
27766 + addl $1, %eax
27767 + adcl $0, %edx
27768 movl %eax, (v)
27769 movl %edx, 4(v)
27770 RET_ENDP
27771 @@ -123,6 +232,20 @@ RET_ENDP
27772 BEGIN(dec)
27773 subl $1, (v)
27774 sbbl $0, 4(v)
27775 +
27776 +#ifdef CONFIG_PAX_REFCOUNT
27777 + jno 0f
27778 + addl $1, (v)
27779 + adcl $0, 4(v)
27780 + int $4
27781 +0:
27782 + _ASM_EXTABLE(0b, 0b)
27783 +#endif
27784 +
27785 +RET_ENDP
27786 +BEGIN(dec_unchecked)
27787 + subl $1, (v)
27788 + sbbl $0, 4(v)
27789 RET_ENDP
27790 #undef v
27791
27792 @@ -132,6 +255,26 @@ BEGIN(dec_return)
27793 movl 4(v), %edx
27794 subl $1, %eax
27795 sbbl $0, %edx
27796 +
27797 +#ifdef CONFIG_PAX_REFCOUNT
27798 + into
27799 +1234:
27800 + _ASM_EXTABLE(1234b, 2f)
27801 +#endif
27802 +
27803 + movl %eax, (v)
27804 + movl %edx, 4(v)
27805 +
27806 +#ifdef CONFIG_PAX_REFCOUNT
27807 +2:
27808 +#endif
27809 +
27810 +RET_ENDP
27811 +BEGIN(dec_return_unchecked)
27812 + movl (v), %eax
27813 + movl 4(v), %edx
27814 + subl $1, %eax
27815 + sbbl $0, %edx
27816 movl %eax, (v)
27817 movl %edx, 4(v)
27818 RET_ENDP
27819 @@ -143,6 +286,13 @@ BEGIN(add_unless)
27820 adcl %edx, %edi
27821 addl (v), %eax
27822 adcl 4(v), %edx
27823 +
27824 +#ifdef CONFIG_PAX_REFCOUNT
27825 + into
27826 +1234:
27827 + _ASM_EXTABLE(1234b, 2f)
27828 +#endif
27829 +
27830 cmpl %eax, %ecx
27831 je 3f
27832 1:
27833 @@ -168,6 +318,13 @@ BEGIN(inc_not_zero)
27834 1:
27835 addl $1, %eax
27836 adcl $0, %edx
27837 +
27838 +#ifdef CONFIG_PAX_REFCOUNT
27839 + into
27840 +1234:
27841 + _ASM_EXTABLE(1234b, 2f)
27842 +#endif
27843 +
27844 movl %eax, (v)
27845 movl %edx, 4(v)
27846 movl $1, %eax
27847 @@ -186,6 +343,13 @@ BEGIN(dec_if_positive)
27848 movl 4(v), %edx
27849 subl $1, %eax
27850 sbbl $0, %edx
27851 +
27852 +#ifdef CONFIG_PAX_REFCOUNT
27853 + into
27854 +1234:
27855 + _ASM_EXTABLE(1234b, 1f)
27856 +#endif
27857 +
27858 js 1f
27859 movl %eax, (v)
27860 movl %edx, 4(v)
27861 diff --git a/arch/x86/lib/atomic64_cx8_32.S b/arch/x86/lib/atomic64_cx8_32.S
27862 index f5cc9eb..51fa319 100644
27863 --- a/arch/x86/lib/atomic64_cx8_32.S
27864 +++ b/arch/x86/lib/atomic64_cx8_32.S
27865 @@ -35,10 +35,20 @@ ENTRY(atomic64_read_cx8)
27866 CFI_STARTPROC
27867
27868 read64 %ecx
27869 + pax_force_retaddr
27870 ret
27871 CFI_ENDPROC
27872 ENDPROC(atomic64_read_cx8)
27873
27874 +ENTRY(atomic64_read_unchecked_cx8)
27875 + CFI_STARTPROC
27876 +
27877 + read64 %ecx
27878 + pax_force_retaddr
27879 + ret
27880 + CFI_ENDPROC
27881 +ENDPROC(atomic64_read_unchecked_cx8)
27882 +
27883 ENTRY(atomic64_set_cx8)
27884 CFI_STARTPROC
27885
27886 @@ -48,10 +58,25 @@ ENTRY(atomic64_set_cx8)
27887 cmpxchg8b (%esi)
27888 jne 1b
27889
27890 + pax_force_retaddr
27891 ret
27892 CFI_ENDPROC
27893 ENDPROC(atomic64_set_cx8)
27894
27895 +ENTRY(atomic64_set_unchecked_cx8)
27896 + CFI_STARTPROC
27897 +
27898 +1:
27899 +/* we don't need LOCK_PREFIX since aligned 64-bit writes
27900 + * are atomic on 586 and newer */
27901 + cmpxchg8b (%esi)
27902 + jne 1b
27903 +
27904 + pax_force_retaddr
27905 + ret
27906 + CFI_ENDPROC
27907 +ENDPROC(atomic64_set_unchecked_cx8)
27908 +
27909 ENTRY(atomic64_xchg_cx8)
27910 CFI_STARTPROC
27911
27912 @@ -60,12 +85,13 @@ ENTRY(atomic64_xchg_cx8)
27913 cmpxchg8b (%esi)
27914 jne 1b
27915
27916 + pax_force_retaddr
27917 ret
27918 CFI_ENDPROC
27919 ENDPROC(atomic64_xchg_cx8)
27920
27921 -.macro addsub_return func ins insc
27922 -ENTRY(atomic64_\func\()_return_cx8)
27923 +.macro addsub_return func ins insc unchecked=""
27924 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
27925 CFI_STARTPROC
27926 SAVE ebp
27927 SAVE ebx
27928 @@ -82,27 +108,44 @@ ENTRY(atomic64_\func\()_return_cx8)
27929 movl %edx, %ecx
27930 \ins\()l %esi, %ebx
27931 \insc\()l %edi, %ecx
27932 +
27933 +.ifb \unchecked
27934 +#ifdef CONFIG_PAX_REFCOUNT
27935 + into
27936 +2:
27937 + _ASM_EXTABLE(2b, 3f)
27938 +#endif
27939 +.endif
27940 +
27941 LOCK_PREFIX
27942 cmpxchg8b (%ebp)
27943 jne 1b
27944 -
27945 -10:
27946 movl %ebx, %eax
27947 movl %ecx, %edx
27948 +
27949 +.ifb \unchecked
27950 +#ifdef CONFIG_PAX_REFCOUNT
27951 +3:
27952 +#endif
27953 +.endif
27954 +
27955 RESTORE edi
27956 RESTORE esi
27957 RESTORE ebx
27958 RESTORE ebp
27959 + pax_force_retaddr
27960 ret
27961 CFI_ENDPROC
27962 -ENDPROC(atomic64_\func\()_return_cx8)
27963 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
27964 .endm
27965
27966 addsub_return add add adc
27967 addsub_return sub sub sbb
27968 +addsub_return add add adc _unchecked
27969 +addsub_return sub sub sbb _unchecked
27970
27971 -.macro incdec_return func ins insc
27972 -ENTRY(atomic64_\func\()_return_cx8)
27973 +.macro incdec_return func ins insc unchecked=""
27974 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
27975 CFI_STARTPROC
27976 SAVE ebx
27977
27978 @@ -112,21 +155,39 @@ ENTRY(atomic64_\func\()_return_cx8)
27979 movl %edx, %ecx
27980 \ins\()l $1, %ebx
27981 \insc\()l $0, %ecx
27982 +
27983 +.ifb \unchecked
27984 +#ifdef CONFIG_PAX_REFCOUNT
27985 + into
27986 +2:
27987 + _ASM_EXTABLE(2b, 3f)
27988 +#endif
27989 +.endif
27990 +
27991 LOCK_PREFIX
27992 cmpxchg8b (%esi)
27993 jne 1b
27994
27995 -10:
27996 movl %ebx, %eax
27997 movl %ecx, %edx
27998 +
27999 +.ifb \unchecked
28000 +#ifdef CONFIG_PAX_REFCOUNT
28001 +3:
28002 +#endif
28003 +.endif
28004 +
28005 RESTORE ebx
28006 + pax_force_retaddr
28007 ret
28008 CFI_ENDPROC
28009 -ENDPROC(atomic64_\func\()_return_cx8)
28010 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
28011 .endm
28012
28013 incdec_return inc add adc
28014 incdec_return dec sub sbb
28015 +incdec_return inc add adc _unchecked
28016 +incdec_return dec sub sbb _unchecked
28017
28018 ENTRY(atomic64_dec_if_positive_cx8)
28019 CFI_STARTPROC
28020 @@ -138,6 +199,13 @@ ENTRY(atomic64_dec_if_positive_cx8)
28021 movl %edx, %ecx
28022 subl $1, %ebx
28023 sbb $0, %ecx
28024 +
28025 +#ifdef CONFIG_PAX_REFCOUNT
28026 + into
28027 +1234:
28028 + _ASM_EXTABLE(1234b, 2f)
28029 +#endif
28030 +
28031 js 2f
28032 LOCK_PREFIX
28033 cmpxchg8b (%esi)
28034 @@ -147,6 +215,7 @@ ENTRY(atomic64_dec_if_positive_cx8)
28035 movl %ebx, %eax
28036 movl %ecx, %edx
28037 RESTORE ebx
28038 + pax_force_retaddr
28039 ret
28040 CFI_ENDPROC
28041 ENDPROC(atomic64_dec_if_positive_cx8)
28042 @@ -171,6 +240,13 @@ ENTRY(atomic64_add_unless_cx8)
28043 movl %edx, %ecx
28044 addl %ebp, %ebx
28045 adcl %edi, %ecx
28046 +
28047 +#ifdef CONFIG_PAX_REFCOUNT
28048 + into
28049 +1234:
28050 + _ASM_EXTABLE(1234b, 3f)
28051 +#endif
28052 +
28053 LOCK_PREFIX
28054 cmpxchg8b (%esi)
28055 jne 1b
28056 @@ -181,6 +257,7 @@ ENTRY(atomic64_add_unless_cx8)
28057 CFI_ADJUST_CFA_OFFSET -8
28058 RESTORE ebx
28059 RESTORE ebp
28060 + pax_force_retaddr
28061 ret
28062 4:
28063 cmpl %edx, 4(%esp)
28064 @@ -203,6 +280,13 @@ ENTRY(atomic64_inc_not_zero_cx8)
28065 xorl %ecx, %ecx
28066 addl $1, %ebx
28067 adcl %edx, %ecx
28068 +
28069 +#ifdef CONFIG_PAX_REFCOUNT
28070 + into
28071 +1234:
28072 + _ASM_EXTABLE(1234b, 3f)
28073 +#endif
28074 +
28075 LOCK_PREFIX
28076 cmpxchg8b (%esi)
28077 jne 1b
28078 @@ -210,6 +294,7 @@ ENTRY(atomic64_inc_not_zero_cx8)
28079 movl $1, %eax
28080 3:
28081 RESTORE ebx
28082 + pax_force_retaddr
28083 ret
28084 CFI_ENDPROC
28085 ENDPROC(atomic64_inc_not_zero_cx8)
28086 diff --git a/arch/x86/lib/checksum_32.S b/arch/x86/lib/checksum_32.S
28087 index e78b8ee..7e173a8 100644
28088 --- a/arch/x86/lib/checksum_32.S
28089 +++ b/arch/x86/lib/checksum_32.S
28090 @@ -29,7 +29,8 @@
28091 #include <asm/dwarf2.h>
28092 #include <asm/errno.h>
28093 #include <asm/asm.h>
28094 -
28095 +#include <asm/segment.h>
28096 +
28097 /*
28098 * computes a partial checksum, e.g. for TCP/UDP fragments
28099 */
28100 @@ -293,9 +294,24 @@ unsigned int csum_partial_copy_generic (const char *src, char *dst,
28101
28102 #define ARGBASE 16
28103 #define FP 12
28104 -
28105 -ENTRY(csum_partial_copy_generic)
28106 +
28107 +ENTRY(csum_partial_copy_generic_to_user)
28108 CFI_STARTPROC
28109 +
28110 +#ifdef CONFIG_PAX_MEMORY_UDEREF
28111 + pushl_cfi %gs
28112 + popl_cfi %es
28113 + jmp csum_partial_copy_generic
28114 +#endif
28115 +
28116 +ENTRY(csum_partial_copy_generic_from_user)
28117 +
28118 +#ifdef CONFIG_PAX_MEMORY_UDEREF
28119 + pushl_cfi %gs
28120 + popl_cfi %ds
28121 +#endif
28122 +
28123 +ENTRY(csum_partial_copy_generic)
28124 subl $4,%esp
28125 CFI_ADJUST_CFA_OFFSET 4
28126 pushl_cfi %edi
28127 @@ -317,7 +333,7 @@ ENTRY(csum_partial_copy_generic)
28128 jmp 4f
28129 SRC(1: movw (%esi), %bx )
28130 addl $2, %esi
28131 -DST( movw %bx, (%edi) )
28132 +DST( movw %bx, %es:(%edi) )
28133 addl $2, %edi
28134 addw %bx, %ax
28135 adcl $0, %eax
28136 @@ -329,30 +345,30 @@ DST( movw %bx, (%edi) )
28137 SRC(1: movl (%esi), %ebx )
28138 SRC( movl 4(%esi), %edx )
28139 adcl %ebx, %eax
28140 -DST( movl %ebx, (%edi) )
28141 +DST( movl %ebx, %es:(%edi) )
28142 adcl %edx, %eax
28143 -DST( movl %edx, 4(%edi) )
28144 +DST( movl %edx, %es:4(%edi) )
28145
28146 SRC( movl 8(%esi), %ebx )
28147 SRC( movl 12(%esi), %edx )
28148 adcl %ebx, %eax
28149 -DST( movl %ebx, 8(%edi) )
28150 +DST( movl %ebx, %es:8(%edi) )
28151 adcl %edx, %eax
28152 -DST( movl %edx, 12(%edi) )
28153 +DST( movl %edx, %es:12(%edi) )
28154
28155 SRC( movl 16(%esi), %ebx )
28156 SRC( movl 20(%esi), %edx )
28157 adcl %ebx, %eax
28158 -DST( movl %ebx, 16(%edi) )
28159 +DST( movl %ebx, %es:16(%edi) )
28160 adcl %edx, %eax
28161 -DST( movl %edx, 20(%edi) )
28162 +DST( movl %edx, %es:20(%edi) )
28163
28164 SRC( movl 24(%esi), %ebx )
28165 SRC( movl 28(%esi), %edx )
28166 adcl %ebx, %eax
28167 -DST( movl %ebx, 24(%edi) )
28168 +DST( movl %ebx, %es:24(%edi) )
28169 adcl %edx, %eax
28170 -DST( movl %edx, 28(%edi) )
28171 +DST( movl %edx, %es:28(%edi) )
28172
28173 lea 32(%esi), %esi
28174 lea 32(%edi), %edi
28175 @@ -366,7 +382,7 @@ DST( movl %edx, 28(%edi) )
28176 shrl $2, %edx # This clears CF
28177 SRC(3: movl (%esi), %ebx )
28178 adcl %ebx, %eax
28179 -DST( movl %ebx, (%edi) )
28180 +DST( movl %ebx, %es:(%edi) )
28181 lea 4(%esi), %esi
28182 lea 4(%edi), %edi
28183 dec %edx
28184 @@ -378,12 +394,12 @@ DST( movl %ebx, (%edi) )
28185 jb 5f
28186 SRC( movw (%esi), %cx )
28187 leal 2(%esi), %esi
28188 -DST( movw %cx, (%edi) )
28189 +DST( movw %cx, %es:(%edi) )
28190 leal 2(%edi), %edi
28191 je 6f
28192 shll $16,%ecx
28193 SRC(5: movb (%esi), %cl )
28194 -DST( movb %cl, (%edi) )
28195 +DST( movb %cl, %es:(%edi) )
28196 6: addl %ecx, %eax
28197 adcl $0, %eax
28198 7:
28199 @@ -394,7 +410,7 @@ DST( movb %cl, (%edi) )
28200
28201 6001:
28202 movl ARGBASE+20(%esp), %ebx # src_err_ptr
28203 - movl $-EFAULT, (%ebx)
28204 + movl $-EFAULT, %ss:(%ebx)
28205
28206 # zero the complete destination - computing the rest
28207 # is too much work
28208 @@ -407,11 +423,15 @@ DST( movb %cl, (%edi) )
28209
28210 6002:
28211 movl ARGBASE+24(%esp), %ebx # dst_err_ptr
28212 - movl $-EFAULT,(%ebx)
28213 + movl $-EFAULT,%ss:(%ebx)
28214 jmp 5000b
28215
28216 .previous
28217
28218 + pushl_cfi %ss
28219 + popl_cfi %ds
28220 + pushl_cfi %ss
28221 + popl_cfi %es
28222 popl_cfi %ebx
28223 CFI_RESTORE ebx
28224 popl_cfi %esi
28225 @@ -421,26 +441,43 @@ DST( movb %cl, (%edi) )
28226 popl_cfi %ecx # equivalent to addl $4,%esp
28227 ret
28228 CFI_ENDPROC
28229 -ENDPROC(csum_partial_copy_generic)
28230 +ENDPROC(csum_partial_copy_generic_to_user)
28231
28232 #else
28233
28234 /* Version for PentiumII/PPro */
28235
28236 #define ROUND1(x) \
28237 + nop; nop; nop; \
28238 SRC(movl x(%esi), %ebx ) ; \
28239 addl %ebx, %eax ; \
28240 - DST(movl %ebx, x(%edi) ) ;
28241 + DST(movl %ebx, %es:x(%edi)) ;
28242
28243 #define ROUND(x) \
28244 + nop; nop; nop; \
28245 SRC(movl x(%esi), %ebx ) ; \
28246 adcl %ebx, %eax ; \
28247 - DST(movl %ebx, x(%edi) ) ;
28248 + DST(movl %ebx, %es:x(%edi)) ;
28249
28250 #define ARGBASE 12
28251 -
28252 -ENTRY(csum_partial_copy_generic)
28253 +
28254 +ENTRY(csum_partial_copy_generic_to_user)
28255 CFI_STARTPROC
28256 +
28257 +#ifdef CONFIG_PAX_MEMORY_UDEREF
28258 + pushl_cfi %gs
28259 + popl_cfi %es
28260 + jmp csum_partial_copy_generic
28261 +#endif
28262 +
28263 +ENTRY(csum_partial_copy_generic_from_user)
28264 +
28265 +#ifdef CONFIG_PAX_MEMORY_UDEREF
28266 + pushl_cfi %gs
28267 + popl_cfi %ds
28268 +#endif
28269 +
28270 +ENTRY(csum_partial_copy_generic)
28271 pushl_cfi %ebx
28272 CFI_REL_OFFSET ebx, 0
28273 pushl_cfi %edi
28274 @@ -461,7 +498,7 @@ ENTRY(csum_partial_copy_generic)
28275 subl %ebx, %edi
28276 lea -1(%esi),%edx
28277 andl $-32,%edx
28278 - lea 3f(%ebx,%ebx), %ebx
28279 + lea 3f(%ebx,%ebx,2), %ebx
28280 testl %esi, %esi
28281 jmp *%ebx
28282 1: addl $64,%esi
28283 @@ -482,19 +519,19 @@ ENTRY(csum_partial_copy_generic)
28284 jb 5f
28285 SRC( movw (%esi), %dx )
28286 leal 2(%esi), %esi
28287 -DST( movw %dx, (%edi) )
28288 +DST( movw %dx, %es:(%edi) )
28289 leal 2(%edi), %edi
28290 je 6f
28291 shll $16,%edx
28292 5:
28293 SRC( movb (%esi), %dl )
28294 -DST( movb %dl, (%edi) )
28295 +DST( movb %dl, %es:(%edi) )
28296 6: addl %edx, %eax
28297 adcl $0, %eax
28298 7:
28299 .section .fixup, "ax"
28300 6001: movl ARGBASE+20(%esp), %ebx # src_err_ptr
28301 - movl $-EFAULT, (%ebx)
28302 + movl $-EFAULT, %ss:(%ebx)
28303 # zero the complete destination (computing the rest is too much work)
28304 movl ARGBASE+8(%esp),%edi # dst
28305 movl ARGBASE+12(%esp),%ecx # len
28306 @@ -502,10 +539,17 @@ DST( movb %dl, (%edi) )
28307 rep; stosb
28308 jmp 7b
28309 6002: movl ARGBASE+24(%esp), %ebx # dst_err_ptr
28310 - movl $-EFAULT, (%ebx)
28311 + movl $-EFAULT, %ss:(%ebx)
28312 jmp 7b
28313 .previous
28314
28315 +#ifdef CONFIG_PAX_MEMORY_UDEREF
28316 + pushl_cfi %ss
28317 + popl_cfi %ds
28318 + pushl_cfi %ss
28319 + popl_cfi %es
28320 +#endif
28321 +
28322 popl_cfi %esi
28323 CFI_RESTORE esi
28324 popl_cfi %edi
28325 @@ -514,7 +558,7 @@ DST( movb %dl, (%edi) )
28326 CFI_RESTORE ebx
28327 ret
28328 CFI_ENDPROC
28329 -ENDPROC(csum_partial_copy_generic)
28330 +ENDPROC(csum_partial_copy_generic_to_user)
28331
28332 #undef ROUND
28333 #undef ROUND1
28334 diff --git a/arch/x86/lib/clear_page_64.S b/arch/x86/lib/clear_page_64.S
28335 index f2145cf..cea889d 100644
28336 --- a/arch/x86/lib/clear_page_64.S
28337 +++ b/arch/x86/lib/clear_page_64.S
28338 @@ -11,6 +11,7 @@ ENTRY(clear_page_c)
28339 movl $4096/8,%ecx
28340 xorl %eax,%eax
28341 rep stosq
28342 + pax_force_retaddr
28343 ret
28344 CFI_ENDPROC
28345 ENDPROC(clear_page_c)
28346 @@ -20,6 +21,7 @@ ENTRY(clear_page_c_e)
28347 movl $4096,%ecx
28348 xorl %eax,%eax
28349 rep stosb
28350 + pax_force_retaddr
28351 ret
28352 CFI_ENDPROC
28353 ENDPROC(clear_page_c_e)
28354 @@ -43,6 +45,7 @@ ENTRY(clear_page)
28355 leaq 64(%rdi),%rdi
28356 jnz .Lloop
28357 nop
28358 + pax_force_retaddr
28359 ret
28360 CFI_ENDPROC
28361 .Lclear_page_end:
28362 @@ -58,7 +61,7 @@ ENDPROC(clear_page)
28363
28364 #include <asm/cpufeature.h>
28365
28366 - .section .altinstr_replacement,"ax"
28367 + .section .altinstr_replacement,"a"
28368 1: .byte 0xeb /* jmp <disp8> */
28369 .byte (clear_page_c - clear_page) - (2f - 1b) /* offset */
28370 2: .byte 0xeb /* jmp <disp8> */
28371 diff --git a/arch/x86/lib/cmpxchg16b_emu.S b/arch/x86/lib/cmpxchg16b_emu.S
28372 index 1e572c5..2a162cd 100644
28373 --- a/arch/x86/lib/cmpxchg16b_emu.S
28374 +++ b/arch/x86/lib/cmpxchg16b_emu.S
28375 @@ -53,11 +53,13 @@ this_cpu_cmpxchg16b_emu:
28376
28377 popf
28378 mov $1, %al
28379 + pax_force_retaddr
28380 ret
28381
28382 not_same:
28383 popf
28384 xor %al,%al
28385 + pax_force_retaddr
28386 ret
28387
28388 CFI_ENDPROC
28389 diff --git a/arch/x86/lib/copy_page_64.S b/arch/x86/lib/copy_page_64.S
28390 index 176cca6..e0d658e 100644
28391 --- a/arch/x86/lib/copy_page_64.S
28392 +++ b/arch/x86/lib/copy_page_64.S
28393 @@ -9,6 +9,7 @@ copy_page_rep:
28394 CFI_STARTPROC
28395 movl $4096/8, %ecx
28396 rep movsq
28397 + pax_force_retaddr
28398 ret
28399 CFI_ENDPROC
28400 ENDPROC(copy_page_rep)
28401 @@ -24,8 +25,8 @@ ENTRY(copy_page)
28402 CFI_ADJUST_CFA_OFFSET 2*8
28403 movq %rbx, (%rsp)
28404 CFI_REL_OFFSET rbx, 0
28405 - movq %r12, 1*8(%rsp)
28406 - CFI_REL_OFFSET r12, 1*8
28407 + movq %r13, 1*8(%rsp)
28408 + CFI_REL_OFFSET r13, 1*8
28409
28410 movl $(4096/64)-5, %ecx
28411 .p2align 4
28412 @@ -38,7 +39,7 @@ ENTRY(copy_page)
28413 movq 0x8*4(%rsi), %r9
28414 movq 0x8*5(%rsi), %r10
28415 movq 0x8*6(%rsi), %r11
28416 - movq 0x8*7(%rsi), %r12
28417 + movq 0x8*7(%rsi), %r13
28418
28419 prefetcht0 5*64(%rsi)
28420
28421 @@ -49,7 +50,7 @@ ENTRY(copy_page)
28422 movq %r9, 0x8*4(%rdi)
28423 movq %r10, 0x8*5(%rdi)
28424 movq %r11, 0x8*6(%rdi)
28425 - movq %r12, 0x8*7(%rdi)
28426 + movq %r13, 0x8*7(%rdi)
28427
28428 leaq 64 (%rsi), %rsi
28429 leaq 64 (%rdi), %rdi
28430 @@ -68,7 +69,7 @@ ENTRY(copy_page)
28431 movq 0x8*4(%rsi), %r9
28432 movq 0x8*5(%rsi), %r10
28433 movq 0x8*6(%rsi), %r11
28434 - movq 0x8*7(%rsi), %r12
28435 + movq 0x8*7(%rsi), %r13
28436
28437 movq %rax, 0x8*0(%rdi)
28438 movq %rbx, 0x8*1(%rdi)
28439 @@ -77,7 +78,7 @@ ENTRY(copy_page)
28440 movq %r9, 0x8*4(%rdi)
28441 movq %r10, 0x8*5(%rdi)
28442 movq %r11, 0x8*6(%rdi)
28443 - movq %r12, 0x8*7(%rdi)
28444 + movq %r13, 0x8*7(%rdi)
28445
28446 leaq 64(%rdi), %rdi
28447 leaq 64(%rsi), %rsi
28448 @@ -85,10 +86,11 @@ ENTRY(copy_page)
28449
28450 movq (%rsp), %rbx
28451 CFI_RESTORE rbx
28452 - movq 1*8(%rsp), %r12
28453 - CFI_RESTORE r12
28454 + movq 1*8(%rsp), %r13
28455 + CFI_RESTORE r13
28456 addq $2*8, %rsp
28457 CFI_ADJUST_CFA_OFFSET -2*8
28458 + pax_force_retaddr
28459 ret
28460 .Lcopy_page_end:
28461 CFI_ENDPROC
28462 @@ -99,7 +101,7 @@ ENDPROC(copy_page)
28463
28464 #include <asm/cpufeature.h>
28465
28466 - .section .altinstr_replacement,"ax"
28467 + .section .altinstr_replacement,"a"
28468 1: .byte 0xeb /* jmp <disp8> */
28469 .byte (copy_page_rep - copy_page) - (2f - 1b) /* offset */
28470 2:
28471 diff --git a/arch/x86/lib/copy_user_64.S b/arch/x86/lib/copy_user_64.S
28472 index a30ca15..407412b 100644
28473 --- a/arch/x86/lib/copy_user_64.S
28474 +++ b/arch/x86/lib/copy_user_64.S
28475 @@ -18,31 +18,7 @@
28476 #include <asm/alternative-asm.h>
28477 #include <asm/asm.h>
28478 #include <asm/smap.h>
28479 -
28480 -/*
28481 - * By placing feature2 after feature1 in altinstructions section, we logically
28482 - * implement:
28483 - * If CPU has feature2, jmp to alt2 is used
28484 - * else if CPU has feature1, jmp to alt1 is used
28485 - * else jmp to orig is used.
28486 - */
28487 - .macro ALTERNATIVE_JUMP feature1,feature2,orig,alt1,alt2
28488 -0:
28489 - .byte 0xe9 /* 32bit jump */
28490 - .long \orig-1f /* by default jump to orig */
28491 -1:
28492 - .section .altinstr_replacement,"ax"
28493 -2: .byte 0xe9 /* near jump with 32bit immediate */
28494 - .long \alt1-1b /* offset */ /* or alternatively to alt1 */
28495 -3: .byte 0xe9 /* near jump with 32bit immediate */
28496 - .long \alt2-1b /* offset */ /* or alternatively to alt2 */
28497 - .previous
28498 -
28499 - .section .altinstructions,"a"
28500 - altinstruction_entry 0b,2b,\feature1,5,5
28501 - altinstruction_entry 0b,3b,\feature2,5,5
28502 - .previous
28503 - .endm
28504 +#include <asm/pgtable.h>
28505
28506 .macro ALIGN_DESTINATION
28507 #ifdef FIX_ALIGNMENT
28508 @@ -70,52 +46,6 @@
28509 #endif
28510 .endm
28511
28512 -/* Standard copy_to_user with segment limit checking */
28513 -ENTRY(_copy_to_user)
28514 - CFI_STARTPROC
28515 - GET_THREAD_INFO(%rax)
28516 - movq %rdi,%rcx
28517 - addq %rdx,%rcx
28518 - jc bad_to_user
28519 - cmpq TI_addr_limit(%rax),%rcx
28520 - ja bad_to_user
28521 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
28522 - copy_user_generic_unrolled,copy_user_generic_string, \
28523 - copy_user_enhanced_fast_string
28524 - CFI_ENDPROC
28525 -ENDPROC(_copy_to_user)
28526 -
28527 -/* Standard copy_from_user with segment limit checking */
28528 -ENTRY(_copy_from_user)
28529 - CFI_STARTPROC
28530 - GET_THREAD_INFO(%rax)
28531 - movq %rsi,%rcx
28532 - addq %rdx,%rcx
28533 - jc bad_from_user
28534 - cmpq TI_addr_limit(%rax),%rcx
28535 - ja bad_from_user
28536 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
28537 - copy_user_generic_unrolled,copy_user_generic_string, \
28538 - copy_user_enhanced_fast_string
28539 - CFI_ENDPROC
28540 -ENDPROC(_copy_from_user)
28541 -
28542 - .section .fixup,"ax"
28543 - /* must zero dest */
28544 -ENTRY(bad_from_user)
28545 -bad_from_user:
28546 - CFI_STARTPROC
28547 - movl %edx,%ecx
28548 - xorl %eax,%eax
28549 - rep
28550 - stosb
28551 -bad_to_user:
28552 - movl %edx,%eax
28553 - ret
28554 - CFI_ENDPROC
28555 -ENDPROC(bad_from_user)
28556 - .previous
28557 -
28558 /*
28559 * copy_user_generic_unrolled - memory copy with exception handling.
28560 * This version is for CPUs like P4 that don't have efficient micro
28561 @@ -131,6 +61,7 @@ ENDPROC(bad_from_user)
28562 */
28563 ENTRY(copy_user_generic_unrolled)
28564 CFI_STARTPROC
28565 + ASM_PAX_OPEN_USERLAND
28566 ASM_STAC
28567 cmpl $8,%edx
28568 jb 20f /* less then 8 bytes, go to byte copy loop */
28569 @@ -180,6 +111,8 @@ ENTRY(copy_user_generic_unrolled)
28570 jnz 21b
28571 23: xor %eax,%eax
28572 ASM_CLAC
28573 + ASM_PAX_CLOSE_USERLAND
28574 + pax_force_retaddr
28575 ret
28576
28577 .section .fixup,"ax"
28578 @@ -235,6 +168,7 @@ ENDPROC(copy_user_generic_unrolled)
28579 */
28580 ENTRY(copy_user_generic_string)
28581 CFI_STARTPROC
28582 + ASM_PAX_OPEN_USERLAND
28583 ASM_STAC
28584 andl %edx,%edx
28585 jz 4f
28586 @@ -251,6 +185,8 @@ ENTRY(copy_user_generic_string)
28587 movsb
28588 4: xorl %eax,%eax
28589 ASM_CLAC
28590 + ASM_PAX_CLOSE_USERLAND
28591 + pax_force_retaddr
28592 ret
28593
28594 .section .fixup,"ax"
28595 @@ -278,6 +214,7 @@ ENDPROC(copy_user_generic_string)
28596 */
28597 ENTRY(copy_user_enhanced_fast_string)
28598 CFI_STARTPROC
28599 + ASM_PAX_OPEN_USERLAND
28600 ASM_STAC
28601 andl %edx,%edx
28602 jz 2f
28603 @@ -286,6 +223,8 @@ ENTRY(copy_user_enhanced_fast_string)
28604 movsb
28605 2: xorl %eax,%eax
28606 ASM_CLAC
28607 + ASM_PAX_CLOSE_USERLAND
28608 + pax_force_retaddr
28609 ret
28610
28611 .section .fixup,"ax"
28612 diff --git a/arch/x86/lib/copy_user_nocache_64.S b/arch/x86/lib/copy_user_nocache_64.S
28613 index 6a4f43c..c70fb52 100644
28614 --- a/arch/x86/lib/copy_user_nocache_64.S
28615 +++ b/arch/x86/lib/copy_user_nocache_64.S
28616 @@ -8,6 +8,7 @@
28617
28618 #include <linux/linkage.h>
28619 #include <asm/dwarf2.h>
28620 +#include <asm/alternative-asm.h>
28621
28622 #define FIX_ALIGNMENT 1
28623
28624 @@ -16,6 +17,7 @@
28625 #include <asm/thread_info.h>
28626 #include <asm/asm.h>
28627 #include <asm/smap.h>
28628 +#include <asm/pgtable.h>
28629
28630 .macro ALIGN_DESTINATION
28631 #ifdef FIX_ALIGNMENT
28632 @@ -49,6 +51,16 @@
28633 */
28634 ENTRY(__copy_user_nocache)
28635 CFI_STARTPROC
28636 +
28637 +#ifdef CONFIG_PAX_MEMORY_UDEREF
28638 + mov pax_user_shadow_base,%rcx
28639 + cmp %rcx,%rsi
28640 + jae 1f
28641 + add %rcx,%rsi
28642 +1:
28643 +#endif
28644 +
28645 + ASM_PAX_OPEN_USERLAND
28646 ASM_STAC
28647 cmpl $8,%edx
28648 jb 20f /* less then 8 bytes, go to byte copy loop */
28649 @@ -98,7 +110,9 @@ ENTRY(__copy_user_nocache)
28650 jnz 21b
28651 23: xorl %eax,%eax
28652 ASM_CLAC
28653 + ASM_PAX_CLOSE_USERLAND
28654 sfence
28655 + pax_force_retaddr
28656 ret
28657
28658 .section .fixup,"ax"
28659 diff --git a/arch/x86/lib/csum-copy_64.S b/arch/x86/lib/csum-copy_64.S
28660 index 2419d5f..fe52d0e 100644
28661 --- a/arch/x86/lib/csum-copy_64.S
28662 +++ b/arch/x86/lib/csum-copy_64.S
28663 @@ -9,6 +9,7 @@
28664 #include <asm/dwarf2.h>
28665 #include <asm/errno.h>
28666 #include <asm/asm.h>
28667 +#include <asm/alternative-asm.h>
28668
28669 /*
28670 * Checksum copy with exception handling.
28671 @@ -56,8 +57,8 @@ ENTRY(csum_partial_copy_generic)
28672 CFI_ADJUST_CFA_OFFSET 7*8
28673 movq %rbx, 2*8(%rsp)
28674 CFI_REL_OFFSET rbx, 2*8
28675 - movq %r12, 3*8(%rsp)
28676 - CFI_REL_OFFSET r12, 3*8
28677 + movq %r15, 3*8(%rsp)
28678 + CFI_REL_OFFSET r15, 3*8
28679 movq %r14, 4*8(%rsp)
28680 CFI_REL_OFFSET r14, 4*8
28681 movq %r13, 5*8(%rsp)
28682 @@ -72,16 +73,16 @@ ENTRY(csum_partial_copy_generic)
28683 movl %edx, %ecx
28684
28685 xorl %r9d, %r9d
28686 - movq %rcx, %r12
28687 + movq %rcx, %r15
28688
28689 - shrq $6, %r12
28690 + shrq $6, %r15
28691 jz .Lhandle_tail /* < 64 */
28692
28693 clc
28694
28695 /* main loop. clear in 64 byte blocks */
28696 /* r9: zero, r8: temp2, rbx: temp1, rax: sum, rcx: saved length */
28697 - /* r11: temp3, rdx: temp4, r12 loopcnt */
28698 + /* r11: temp3, rdx: temp4, r15 loopcnt */
28699 /* r10: temp5, rbp: temp6, r14 temp7, r13 temp8 */
28700 .p2align 4
28701 .Lloop:
28702 @@ -115,7 +116,7 @@ ENTRY(csum_partial_copy_generic)
28703 adcq %r14, %rax
28704 adcq %r13, %rax
28705
28706 - decl %r12d
28707 + decl %r15d
28708
28709 dest
28710 movq %rbx, (%rsi)
28711 @@ -210,8 +211,8 @@ ENTRY(csum_partial_copy_generic)
28712 .Lende:
28713 movq 2*8(%rsp), %rbx
28714 CFI_RESTORE rbx
28715 - movq 3*8(%rsp), %r12
28716 - CFI_RESTORE r12
28717 + movq 3*8(%rsp), %r15
28718 + CFI_RESTORE r15
28719 movq 4*8(%rsp), %r14
28720 CFI_RESTORE r14
28721 movq 5*8(%rsp), %r13
28722 @@ -220,6 +221,7 @@ ENTRY(csum_partial_copy_generic)
28723 CFI_RESTORE rbp
28724 addq $7*8, %rsp
28725 CFI_ADJUST_CFA_OFFSET -7*8
28726 + pax_force_retaddr
28727 ret
28728 CFI_RESTORE_STATE
28729
28730 diff --git a/arch/x86/lib/csum-wrappers_64.c b/arch/x86/lib/csum-wrappers_64.c
28731 index 7609e0e..b449b98 100644
28732 --- a/arch/x86/lib/csum-wrappers_64.c
28733 +++ b/arch/x86/lib/csum-wrappers_64.c
28734 @@ -53,10 +53,12 @@ csum_partial_copy_from_user(const void __user *src, void *dst,
28735 len -= 2;
28736 }
28737 }
28738 + pax_open_userland();
28739 stac();
28740 - isum = csum_partial_copy_generic((__force const void *)src,
28741 + isum = csum_partial_copy_generic((const void __force_kernel *)____m(src),
28742 dst, len, isum, errp, NULL);
28743 clac();
28744 + pax_close_userland();
28745 if (unlikely(*errp))
28746 goto out_err;
28747
28748 @@ -110,10 +112,12 @@ csum_partial_copy_to_user(const void *src, void __user *dst,
28749 }
28750
28751 *errp = 0;
28752 + pax_open_userland();
28753 stac();
28754 - ret = csum_partial_copy_generic(src, (void __force *)dst,
28755 + ret = csum_partial_copy_generic(src, (void __force_kernel *)____m(dst),
28756 len, isum, NULL, errp);
28757 clac();
28758 + pax_close_userland();
28759 return ret;
28760 }
28761 EXPORT_SYMBOL(csum_partial_copy_to_user);
28762 diff --git a/arch/x86/lib/getuser.S b/arch/x86/lib/getuser.S
28763 index a451235..1daa956 100644
28764 --- a/arch/x86/lib/getuser.S
28765 +++ b/arch/x86/lib/getuser.S
28766 @@ -33,17 +33,40 @@
28767 #include <asm/thread_info.h>
28768 #include <asm/asm.h>
28769 #include <asm/smap.h>
28770 +#include <asm/segment.h>
28771 +#include <asm/pgtable.h>
28772 +#include <asm/alternative-asm.h>
28773 +
28774 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
28775 +#define __copyuser_seg gs;
28776 +#else
28777 +#define __copyuser_seg
28778 +#endif
28779
28780 .text
28781 ENTRY(__get_user_1)
28782 CFI_STARTPROC
28783 +
28784 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28785 GET_THREAD_INFO(%_ASM_DX)
28786 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28787 jae bad_get_user
28788 ASM_STAC
28789 -1: movzbl (%_ASM_AX),%edx
28790 +
28791 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28792 + mov pax_user_shadow_base,%_ASM_DX
28793 + cmp %_ASM_DX,%_ASM_AX
28794 + jae 1234f
28795 + add %_ASM_DX,%_ASM_AX
28796 +1234:
28797 +#endif
28798 +
28799 +#endif
28800 +
28801 +1: __copyuser_seg movzbl (%_ASM_AX),%edx
28802 xor %eax,%eax
28803 ASM_CLAC
28804 + pax_force_retaddr
28805 ret
28806 CFI_ENDPROC
28807 ENDPROC(__get_user_1)
28808 @@ -51,14 +74,28 @@ ENDPROC(__get_user_1)
28809 ENTRY(__get_user_2)
28810 CFI_STARTPROC
28811 add $1,%_ASM_AX
28812 +
28813 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28814 jc bad_get_user
28815 GET_THREAD_INFO(%_ASM_DX)
28816 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28817 jae bad_get_user
28818 ASM_STAC
28819 -2: movzwl -1(%_ASM_AX),%edx
28820 +
28821 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28822 + mov pax_user_shadow_base,%_ASM_DX
28823 + cmp %_ASM_DX,%_ASM_AX
28824 + jae 1234f
28825 + add %_ASM_DX,%_ASM_AX
28826 +1234:
28827 +#endif
28828 +
28829 +#endif
28830 +
28831 +2: __copyuser_seg movzwl -1(%_ASM_AX),%edx
28832 xor %eax,%eax
28833 ASM_CLAC
28834 + pax_force_retaddr
28835 ret
28836 CFI_ENDPROC
28837 ENDPROC(__get_user_2)
28838 @@ -66,14 +103,28 @@ ENDPROC(__get_user_2)
28839 ENTRY(__get_user_4)
28840 CFI_STARTPROC
28841 add $3,%_ASM_AX
28842 +
28843 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28844 jc bad_get_user
28845 GET_THREAD_INFO(%_ASM_DX)
28846 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28847 jae bad_get_user
28848 ASM_STAC
28849 -3: movl -3(%_ASM_AX),%edx
28850 +
28851 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28852 + mov pax_user_shadow_base,%_ASM_DX
28853 + cmp %_ASM_DX,%_ASM_AX
28854 + jae 1234f
28855 + add %_ASM_DX,%_ASM_AX
28856 +1234:
28857 +#endif
28858 +
28859 +#endif
28860 +
28861 +3: __copyuser_seg movl -3(%_ASM_AX),%edx
28862 xor %eax,%eax
28863 ASM_CLAC
28864 + pax_force_retaddr
28865 ret
28866 CFI_ENDPROC
28867 ENDPROC(__get_user_4)
28868 @@ -86,10 +137,20 @@ ENTRY(__get_user_8)
28869 GET_THREAD_INFO(%_ASM_DX)
28870 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28871 jae bad_get_user
28872 +
28873 +#ifdef CONFIG_PAX_MEMORY_UDEREF
28874 + mov pax_user_shadow_base,%_ASM_DX
28875 + cmp %_ASM_DX,%_ASM_AX
28876 + jae 1234f
28877 + add %_ASM_DX,%_ASM_AX
28878 +1234:
28879 +#endif
28880 +
28881 ASM_STAC
28882 4: movq -7(%_ASM_AX),%rdx
28883 xor %eax,%eax
28884 ASM_CLAC
28885 + pax_force_retaddr
28886 ret
28887 #else
28888 add $7,%_ASM_AX
28889 @@ -98,10 +159,11 @@ ENTRY(__get_user_8)
28890 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28891 jae bad_get_user_8
28892 ASM_STAC
28893 -4: movl -7(%_ASM_AX),%edx
28894 -5: movl -3(%_ASM_AX),%ecx
28895 +4: __copyuser_seg movl -7(%_ASM_AX),%edx
28896 +5: __copyuser_seg movl -3(%_ASM_AX),%ecx
28897 xor %eax,%eax
28898 ASM_CLAC
28899 + pax_force_retaddr
28900 ret
28901 #endif
28902 CFI_ENDPROC
28903 @@ -113,6 +175,7 @@ bad_get_user:
28904 xor %edx,%edx
28905 mov $(-EFAULT),%_ASM_AX
28906 ASM_CLAC
28907 + pax_force_retaddr
28908 ret
28909 CFI_ENDPROC
28910 END(bad_get_user)
28911 @@ -124,6 +187,7 @@ bad_get_user_8:
28912 xor %ecx,%ecx
28913 mov $(-EFAULT),%_ASM_AX
28914 ASM_CLAC
28915 + pax_force_retaddr
28916 ret
28917 CFI_ENDPROC
28918 END(bad_get_user_8)
28919 diff --git a/arch/x86/lib/insn.c b/arch/x86/lib/insn.c
28920 index 54fcffe..7be149e 100644
28921 --- a/arch/x86/lib/insn.c
28922 +++ b/arch/x86/lib/insn.c
28923 @@ -20,8 +20,10 @@
28924
28925 #ifdef __KERNEL__
28926 #include <linux/string.h>
28927 +#include <asm/pgtable_types.h>
28928 #else
28929 #include <string.h>
28930 +#define ktla_ktva(addr) addr
28931 #endif
28932 #include <asm/inat.h>
28933 #include <asm/insn.h>
28934 @@ -53,8 +55,8 @@
28935 void insn_init(struct insn *insn, const void *kaddr, int x86_64)
28936 {
28937 memset(insn, 0, sizeof(*insn));
28938 - insn->kaddr = kaddr;
28939 - insn->next_byte = kaddr;
28940 + insn->kaddr = ktla_ktva(kaddr);
28941 + insn->next_byte = ktla_ktva(kaddr);
28942 insn->x86_64 = x86_64 ? 1 : 0;
28943 insn->opnd_bytes = 4;
28944 if (x86_64)
28945 diff --git a/arch/x86/lib/iomap_copy_64.S b/arch/x86/lib/iomap_copy_64.S
28946 index 05a95e7..326f2fa 100644
28947 --- a/arch/x86/lib/iomap_copy_64.S
28948 +++ b/arch/x86/lib/iomap_copy_64.S
28949 @@ -17,6 +17,7 @@
28950
28951 #include <linux/linkage.h>
28952 #include <asm/dwarf2.h>
28953 +#include <asm/alternative-asm.h>
28954
28955 /*
28956 * override generic version in lib/iomap_copy.c
28957 @@ -25,6 +26,7 @@ ENTRY(__iowrite32_copy)
28958 CFI_STARTPROC
28959 movl %edx,%ecx
28960 rep movsd
28961 + pax_force_retaddr
28962 ret
28963 CFI_ENDPROC
28964 ENDPROC(__iowrite32_copy)
28965 diff --git a/arch/x86/lib/memcpy_64.S b/arch/x86/lib/memcpy_64.S
28966 index 56313a3..0db417e 100644
28967 --- a/arch/x86/lib/memcpy_64.S
28968 +++ b/arch/x86/lib/memcpy_64.S
28969 @@ -24,7 +24,7 @@
28970 * This gets patched over the unrolled variant (below) via the
28971 * alternative instructions framework:
28972 */
28973 - .section .altinstr_replacement, "ax", @progbits
28974 + .section .altinstr_replacement, "a", @progbits
28975 .Lmemcpy_c:
28976 movq %rdi, %rax
28977 movq %rdx, %rcx
28978 @@ -33,6 +33,7 @@
28979 rep movsq
28980 movl %edx, %ecx
28981 rep movsb
28982 + pax_force_retaddr
28983 ret
28984 .Lmemcpy_e:
28985 .previous
28986 @@ -44,11 +45,12 @@
28987 * This gets patched over the unrolled variant (below) via the
28988 * alternative instructions framework:
28989 */
28990 - .section .altinstr_replacement, "ax", @progbits
28991 + .section .altinstr_replacement, "a", @progbits
28992 .Lmemcpy_c_e:
28993 movq %rdi, %rax
28994 movq %rdx, %rcx
28995 rep movsb
28996 + pax_force_retaddr
28997 ret
28998 .Lmemcpy_e_e:
28999 .previous
29000 @@ -136,6 +138,7 @@ ENTRY(memcpy)
29001 movq %r9, 1*8(%rdi)
29002 movq %r10, -2*8(%rdi, %rdx)
29003 movq %r11, -1*8(%rdi, %rdx)
29004 + pax_force_retaddr
29005 retq
29006 .p2align 4
29007 .Lless_16bytes:
29008 @@ -148,6 +151,7 @@ ENTRY(memcpy)
29009 movq -1*8(%rsi, %rdx), %r9
29010 movq %r8, 0*8(%rdi)
29011 movq %r9, -1*8(%rdi, %rdx)
29012 + pax_force_retaddr
29013 retq
29014 .p2align 4
29015 .Lless_8bytes:
29016 @@ -161,6 +165,7 @@ ENTRY(memcpy)
29017 movl -4(%rsi, %rdx), %r8d
29018 movl %ecx, (%rdi)
29019 movl %r8d, -4(%rdi, %rdx)
29020 + pax_force_retaddr
29021 retq
29022 .p2align 4
29023 .Lless_3bytes:
29024 @@ -179,6 +184,7 @@ ENTRY(memcpy)
29025 movb %cl, (%rdi)
29026
29027 .Lend:
29028 + pax_force_retaddr
29029 retq
29030 CFI_ENDPROC
29031 ENDPROC(memcpy)
29032 diff --git a/arch/x86/lib/memmove_64.S b/arch/x86/lib/memmove_64.S
29033 index 65268a6..dd1de11 100644
29034 --- a/arch/x86/lib/memmove_64.S
29035 +++ b/arch/x86/lib/memmove_64.S
29036 @@ -202,14 +202,16 @@ ENTRY(memmove)
29037 movb (%rsi), %r11b
29038 movb %r11b, (%rdi)
29039 13:
29040 + pax_force_retaddr
29041 retq
29042 CFI_ENDPROC
29043
29044 - .section .altinstr_replacement,"ax"
29045 + .section .altinstr_replacement,"a"
29046 .Lmemmove_begin_forward_efs:
29047 /* Forward moving data. */
29048 movq %rdx, %rcx
29049 rep movsb
29050 + pax_force_retaddr
29051 retq
29052 .Lmemmove_end_forward_efs:
29053 .previous
29054 diff --git a/arch/x86/lib/memset_64.S b/arch/x86/lib/memset_64.S
29055 index 2dcb380..2eb79fe 100644
29056 --- a/arch/x86/lib/memset_64.S
29057 +++ b/arch/x86/lib/memset_64.S
29058 @@ -16,7 +16,7 @@
29059 *
29060 * rax original destination
29061 */
29062 - .section .altinstr_replacement, "ax", @progbits
29063 + .section .altinstr_replacement, "a", @progbits
29064 .Lmemset_c:
29065 movq %rdi,%r9
29066 movq %rdx,%rcx
29067 @@ -30,6 +30,7 @@
29068 movl %edx,%ecx
29069 rep stosb
29070 movq %r9,%rax
29071 + pax_force_retaddr
29072 ret
29073 .Lmemset_e:
29074 .previous
29075 @@ -45,13 +46,14 @@
29076 *
29077 * rax original destination
29078 */
29079 - .section .altinstr_replacement, "ax", @progbits
29080 + .section .altinstr_replacement, "a", @progbits
29081 .Lmemset_c_e:
29082 movq %rdi,%r9
29083 movb %sil,%al
29084 movq %rdx,%rcx
29085 rep stosb
29086 movq %r9,%rax
29087 + pax_force_retaddr
29088 ret
29089 .Lmemset_e_e:
29090 .previous
29091 @@ -118,6 +120,7 @@ ENTRY(__memset)
29092
29093 .Lende:
29094 movq %r10,%rax
29095 + pax_force_retaddr
29096 ret
29097
29098 CFI_RESTORE_STATE
29099 diff --git a/arch/x86/lib/mmx_32.c b/arch/x86/lib/mmx_32.c
29100 index c9f2d9b..e7fd2c0 100644
29101 --- a/arch/x86/lib/mmx_32.c
29102 +++ b/arch/x86/lib/mmx_32.c
29103 @@ -29,6 +29,7 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
29104 {
29105 void *p;
29106 int i;
29107 + unsigned long cr0;
29108
29109 if (unlikely(in_interrupt()))
29110 return __memcpy(to, from, len);
29111 @@ -39,44 +40,72 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
29112 kernel_fpu_begin();
29113
29114 __asm__ __volatile__ (
29115 - "1: prefetch (%0)\n" /* This set is 28 bytes */
29116 - " prefetch 64(%0)\n"
29117 - " prefetch 128(%0)\n"
29118 - " prefetch 192(%0)\n"
29119 - " prefetch 256(%0)\n"
29120 + "1: prefetch (%1)\n" /* This set is 28 bytes */
29121 + " prefetch 64(%1)\n"
29122 + " prefetch 128(%1)\n"
29123 + " prefetch 192(%1)\n"
29124 + " prefetch 256(%1)\n"
29125 "2: \n"
29126 ".section .fixup, \"ax\"\n"
29127 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
29128 + "3: \n"
29129 +
29130 +#ifdef CONFIG_PAX_KERNEXEC
29131 + " movl %%cr0, %0\n"
29132 + " movl %0, %%eax\n"
29133 + " andl $0xFFFEFFFF, %%eax\n"
29134 + " movl %%eax, %%cr0\n"
29135 +#endif
29136 +
29137 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
29138 +
29139 +#ifdef CONFIG_PAX_KERNEXEC
29140 + " movl %0, %%cr0\n"
29141 +#endif
29142 +
29143 " jmp 2b\n"
29144 ".previous\n"
29145 _ASM_EXTABLE(1b, 3b)
29146 - : : "r" (from));
29147 + : "=&r" (cr0) : "r" (from) : "ax");
29148
29149 for ( ; i > 5; i--) {
29150 __asm__ __volatile__ (
29151 - "1: prefetch 320(%0)\n"
29152 - "2: movq (%0), %%mm0\n"
29153 - " movq 8(%0), %%mm1\n"
29154 - " movq 16(%0), %%mm2\n"
29155 - " movq 24(%0), %%mm3\n"
29156 - " movq %%mm0, (%1)\n"
29157 - " movq %%mm1, 8(%1)\n"
29158 - " movq %%mm2, 16(%1)\n"
29159 - " movq %%mm3, 24(%1)\n"
29160 - " movq 32(%0), %%mm0\n"
29161 - " movq 40(%0), %%mm1\n"
29162 - " movq 48(%0), %%mm2\n"
29163 - " movq 56(%0), %%mm3\n"
29164 - " movq %%mm0, 32(%1)\n"
29165 - " movq %%mm1, 40(%1)\n"
29166 - " movq %%mm2, 48(%1)\n"
29167 - " movq %%mm3, 56(%1)\n"
29168 + "1: prefetch 320(%1)\n"
29169 + "2: movq (%1), %%mm0\n"
29170 + " movq 8(%1), %%mm1\n"
29171 + " movq 16(%1), %%mm2\n"
29172 + " movq 24(%1), %%mm3\n"
29173 + " movq %%mm0, (%2)\n"
29174 + " movq %%mm1, 8(%2)\n"
29175 + " movq %%mm2, 16(%2)\n"
29176 + " movq %%mm3, 24(%2)\n"
29177 + " movq 32(%1), %%mm0\n"
29178 + " movq 40(%1), %%mm1\n"
29179 + " movq 48(%1), %%mm2\n"
29180 + " movq 56(%1), %%mm3\n"
29181 + " movq %%mm0, 32(%2)\n"
29182 + " movq %%mm1, 40(%2)\n"
29183 + " movq %%mm2, 48(%2)\n"
29184 + " movq %%mm3, 56(%2)\n"
29185 ".section .fixup, \"ax\"\n"
29186 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
29187 + "3:\n"
29188 +
29189 +#ifdef CONFIG_PAX_KERNEXEC
29190 + " movl %%cr0, %0\n"
29191 + " movl %0, %%eax\n"
29192 + " andl $0xFFFEFFFF, %%eax\n"
29193 + " movl %%eax, %%cr0\n"
29194 +#endif
29195 +
29196 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
29197 +
29198 +#ifdef CONFIG_PAX_KERNEXEC
29199 + " movl %0, %%cr0\n"
29200 +#endif
29201 +
29202 " jmp 2b\n"
29203 ".previous\n"
29204 _ASM_EXTABLE(1b, 3b)
29205 - : : "r" (from), "r" (to) : "memory");
29206 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
29207
29208 from += 64;
29209 to += 64;
29210 @@ -158,6 +187,7 @@ static void fast_clear_page(void *page)
29211 static void fast_copy_page(void *to, void *from)
29212 {
29213 int i;
29214 + unsigned long cr0;
29215
29216 kernel_fpu_begin();
29217
29218 @@ -166,42 +196,70 @@ static void fast_copy_page(void *to, void *from)
29219 * but that is for later. -AV
29220 */
29221 __asm__ __volatile__(
29222 - "1: prefetch (%0)\n"
29223 - " prefetch 64(%0)\n"
29224 - " prefetch 128(%0)\n"
29225 - " prefetch 192(%0)\n"
29226 - " prefetch 256(%0)\n"
29227 + "1: prefetch (%1)\n"
29228 + " prefetch 64(%1)\n"
29229 + " prefetch 128(%1)\n"
29230 + " prefetch 192(%1)\n"
29231 + " prefetch 256(%1)\n"
29232 "2: \n"
29233 ".section .fixup, \"ax\"\n"
29234 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
29235 + "3: \n"
29236 +
29237 +#ifdef CONFIG_PAX_KERNEXEC
29238 + " movl %%cr0, %0\n"
29239 + " movl %0, %%eax\n"
29240 + " andl $0xFFFEFFFF, %%eax\n"
29241 + " movl %%eax, %%cr0\n"
29242 +#endif
29243 +
29244 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
29245 +
29246 +#ifdef CONFIG_PAX_KERNEXEC
29247 + " movl %0, %%cr0\n"
29248 +#endif
29249 +
29250 " jmp 2b\n"
29251 ".previous\n"
29252 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
29253 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
29254
29255 for (i = 0; i < (4096-320)/64; i++) {
29256 __asm__ __volatile__ (
29257 - "1: prefetch 320(%0)\n"
29258 - "2: movq (%0), %%mm0\n"
29259 - " movntq %%mm0, (%1)\n"
29260 - " movq 8(%0), %%mm1\n"
29261 - " movntq %%mm1, 8(%1)\n"
29262 - " movq 16(%0), %%mm2\n"
29263 - " movntq %%mm2, 16(%1)\n"
29264 - " movq 24(%0), %%mm3\n"
29265 - " movntq %%mm3, 24(%1)\n"
29266 - " movq 32(%0), %%mm4\n"
29267 - " movntq %%mm4, 32(%1)\n"
29268 - " movq 40(%0), %%mm5\n"
29269 - " movntq %%mm5, 40(%1)\n"
29270 - " movq 48(%0), %%mm6\n"
29271 - " movntq %%mm6, 48(%1)\n"
29272 - " movq 56(%0), %%mm7\n"
29273 - " movntq %%mm7, 56(%1)\n"
29274 + "1: prefetch 320(%1)\n"
29275 + "2: movq (%1), %%mm0\n"
29276 + " movntq %%mm0, (%2)\n"
29277 + " movq 8(%1), %%mm1\n"
29278 + " movntq %%mm1, 8(%2)\n"
29279 + " movq 16(%1), %%mm2\n"
29280 + " movntq %%mm2, 16(%2)\n"
29281 + " movq 24(%1), %%mm3\n"
29282 + " movntq %%mm3, 24(%2)\n"
29283 + " movq 32(%1), %%mm4\n"
29284 + " movntq %%mm4, 32(%2)\n"
29285 + " movq 40(%1), %%mm5\n"
29286 + " movntq %%mm5, 40(%2)\n"
29287 + " movq 48(%1), %%mm6\n"
29288 + " movntq %%mm6, 48(%2)\n"
29289 + " movq 56(%1), %%mm7\n"
29290 + " movntq %%mm7, 56(%2)\n"
29291 ".section .fixup, \"ax\"\n"
29292 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
29293 + "3:\n"
29294 +
29295 +#ifdef CONFIG_PAX_KERNEXEC
29296 + " movl %%cr0, %0\n"
29297 + " movl %0, %%eax\n"
29298 + " andl $0xFFFEFFFF, %%eax\n"
29299 + " movl %%eax, %%cr0\n"
29300 +#endif
29301 +
29302 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
29303 +
29304 +#ifdef CONFIG_PAX_KERNEXEC
29305 + " movl %0, %%cr0\n"
29306 +#endif
29307 +
29308 " jmp 2b\n"
29309 ".previous\n"
29310 - _ASM_EXTABLE(1b, 3b) : : "r" (from), "r" (to) : "memory");
29311 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
29312
29313 from += 64;
29314 to += 64;
29315 @@ -280,47 +338,76 @@ static void fast_clear_page(void *page)
29316 static void fast_copy_page(void *to, void *from)
29317 {
29318 int i;
29319 + unsigned long cr0;
29320
29321 kernel_fpu_begin();
29322
29323 __asm__ __volatile__ (
29324 - "1: prefetch (%0)\n"
29325 - " prefetch 64(%0)\n"
29326 - " prefetch 128(%0)\n"
29327 - " prefetch 192(%0)\n"
29328 - " prefetch 256(%0)\n"
29329 + "1: prefetch (%1)\n"
29330 + " prefetch 64(%1)\n"
29331 + " prefetch 128(%1)\n"
29332 + " prefetch 192(%1)\n"
29333 + " prefetch 256(%1)\n"
29334 "2: \n"
29335 ".section .fixup, \"ax\"\n"
29336 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
29337 + "3: \n"
29338 +
29339 +#ifdef CONFIG_PAX_KERNEXEC
29340 + " movl %%cr0, %0\n"
29341 + " movl %0, %%eax\n"
29342 + " andl $0xFFFEFFFF, %%eax\n"
29343 + " movl %%eax, %%cr0\n"
29344 +#endif
29345 +
29346 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
29347 +
29348 +#ifdef CONFIG_PAX_KERNEXEC
29349 + " movl %0, %%cr0\n"
29350 +#endif
29351 +
29352 " jmp 2b\n"
29353 ".previous\n"
29354 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
29355 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
29356
29357 for (i = 0; i < 4096/64; i++) {
29358 __asm__ __volatile__ (
29359 - "1: prefetch 320(%0)\n"
29360 - "2: movq (%0), %%mm0\n"
29361 - " movq 8(%0), %%mm1\n"
29362 - " movq 16(%0), %%mm2\n"
29363 - " movq 24(%0), %%mm3\n"
29364 - " movq %%mm0, (%1)\n"
29365 - " movq %%mm1, 8(%1)\n"
29366 - " movq %%mm2, 16(%1)\n"
29367 - " movq %%mm3, 24(%1)\n"
29368 - " movq 32(%0), %%mm0\n"
29369 - " movq 40(%0), %%mm1\n"
29370 - " movq 48(%0), %%mm2\n"
29371 - " movq 56(%0), %%mm3\n"
29372 - " movq %%mm0, 32(%1)\n"
29373 - " movq %%mm1, 40(%1)\n"
29374 - " movq %%mm2, 48(%1)\n"
29375 - " movq %%mm3, 56(%1)\n"
29376 + "1: prefetch 320(%1)\n"
29377 + "2: movq (%1), %%mm0\n"
29378 + " movq 8(%1), %%mm1\n"
29379 + " movq 16(%1), %%mm2\n"
29380 + " movq 24(%1), %%mm3\n"
29381 + " movq %%mm0, (%2)\n"
29382 + " movq %%mm1, 8(%2)\n"
29383 + " movq %%mm2, 16(%2)\n"
29384 + " movq %%mm3, 24(%2)\n"
29385 + " movq 32(%1), %%mm0\n"
29386 + " movq 40(%1), %%mm1\n"
29387 + " movq 48(%1), %%mm2\n"
29388 + " movq 56(%1), %%mm3\n"
29389 + " movq %%mm0, 32(%2)\n"
29390 + " movq %%mm1, 40(%2)\n"
29391 + " movq %%mm2, 48(%2)\n"
29392 + " movq %%mm3, 56(%2)\n"
29393 ".section .fixup, \"ax\"\n"
29394 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
29395 + "3:\n"
29396 +
29397 +#ifdef CONFIG_PAX_KERNEXEC
29398 + " movl %%cr0, %0\n"
29399 + " movl %0, %%eax\n"
29400 + " andl $0xFFFEFFFF, %%eax\n"
29401 + " movl %%eax, %%cr0\n"
29402 +#endif
29403 +
29404 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
29405 +
29406 +#ifdef CONFIG_PAX_KERNEXEC
29407 + " movl %0, %%cr0\n"
29408 +#endif
29409 +
29410 " jmp 2b\n"
29411 ".previous\n"
29412 _ASM_EXTABLE(1b, 3b)
29413 - : : "r" (from), "r" (to) : "memory");
29414 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
29415
29416 from += 64;
29417 to += 64;
29418 diff --git a/arch/x86/lib/msr-reg.S b/arch/x86/lib/msr-reg.S
29419 index f6d13ee..d789440 100644
29420 --- a/arch/x86/lib/msr-reg.S
29421 +++ b/arch/x86/lib/msr-reg.S
29422 @@ -3,6 +3,7 @@
29423 #include <asm/dwarf2.h>
29424 #include <asm/asm.h>
29425 #include <asm/msr.h>
29426 +#include <asm/alternative-asm.h>
29427
29428 #ifdef CONFIG_X86_64
29429 /*
29430 @@ -37,6 +38,7 @@ ENTRY(\op\()_safe_regs)
29431 movl %edi, 28(%r10)
29432 popq_cfi %rbp
29433 popq_cfi %rbx
29434 + pax_force_retaddr
29435 ret
29436 3:
29437 CFI_RESTORE_STATE
29438 diff --git a/arch/x86/lib/putuser.S b/arch/x86/lib/putuser.S
29439 index fc6ba17..d4d989d 100644
29440 --- a/arch/x86/lib/putuser.S
29441 +++ b/arch/x86/lib/putuser.S
29442 @@ -16,7 +16,9 @@
29443 #include <asm/errno.h>
29444 #include <asm/asm.h>
29445 #include <asm/smap.h>
29446 -
29447 +#include <asm/segment.h>
29448 +#include <asm/pgtable.h>
29449 +#include <asm/alternative-asm.h>
29450
29451 /*
29452 * __put_user_X
29453 @@ -30,57 +32,125 @@
29454 * as they get called from within inline assembly.
29455 */
29456
29457 -#define ENTER CFI_STARTPROC ; \
29458 - GET_THREAD_INFO(%_ASM_BX)
29459 -#define EXIT ASM_CLAC ; \
29460 - ret ; \
29461 +#define ENTER CFI_STARTPROC
29462 +#define EXIT ASM_CLAC ; \
29463 + pax_force_retaddr ; \
29464 + ret ; \
29465 CFI_ENDPROC
29466
29467 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29468 +#define _DEST %_ASM_CX,%_ASM_BX
29469 +#else
29470 +#define _DEST %_ASM_CX
29471 +#endif
29472 +
29473 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
29474 +#define __copyuser_seg gs;
29475 +#else
29476 +#define __copyuser_seg
29477 +#endif
29478 +
29479 .text
29480 ENTRY(__put_user_1)
29481 ENTER
29482 +
29483 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
29484 + GET_THREAD_INFO(%_ASM_BX)
29485 cmp TI_addr_limit(%_ASM_BX),%_ASM_CX
29486 jae bad_put_user
29487 ASM_STAC
29488 -1: movb %al,(%_ASM_CX)
29489 +
29490 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29491 + mov pax_user_shadow_base,%_ASM_BX
29492 + cmp %_ASM_BX,%_ASM_CX
29493 + jb 1234f
29494 + xor %ebx,%ebx
29495 +1234:
29496 +#endif
29497 +
29498 +#endif
29499 +
29500 +1: __copyuser_seg movb %al,(_DEST)
29501 xor %eax,%eax
29502 EXIT
29503 ENDPROC(__put_user_1)
29504
29505 ENTRY(__put_user_2)
29506 ENTER
29507 +
29508 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
29509 + GET_THREAD_INFO(%_ASM_BX)
29510 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
29511 sub $1,%_ASM_BX
29512 cmp %_ASM_BX,%_ASM_CX
29513 jae bad_put_user
29514 ASM_STAC
29515 -2: movw %ax,(%_ASM_CX)
29516 +
29517 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29518 + mov pax_user_shadow_base,%_ASM_BX
29519 + cmp %_ASM_BX,%_ASM_CX
29520 + jb 1234f
29521 + xor %ebx,%ebx
29522 +1234:
29523 +#endif
29524 +
29525 +#endif
29526 +
29527 +2: __copyuser_seg movw %ax,(_DEST)
29528 xor %eax,%eax
29529 EXIT
29530 ENDPROC(__put_user_2)
29531
29532 ENTRY(__put_user_4)
29533 ENTER
29534 +
29535 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
29536 + GET_THREAD_INFO(%_ASM_BX)
29537 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
29538 sub $3,%_ASM_BX
29539 cmp %_ASM_BX,%_ASM_CX
29540 jae bad_put_user
29541 ASM_STAC
29542 -3: movl %eax,(%_ASM_CX)
29543 +
29544 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29545 + mov pax_user_shadow_base,%_ASM_BX
29546 + cmp %_ASM_BX,%_ASM_CX
29547 + jb 1234f
29548 + xor %ebx,%ebx
29549 +1234:
29550 +#endif
29551 +
29552 +#endif
29553 +
29554 +3: __copyuser_seg movl %eax,(_DEST)
29555 xor %eax,%eax
29556 EXIT
29557 ENDPROC(__put_user_4)
29558
29559 ENTRY(__put_user_8)
29560 ENTER
29561 +
29562 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
29563 + GET_THREAD_INFO(%_ASM_BX)
29564 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
29565 sub $7,%_ASM_BX
29566 cmp %_ASM_BX,%_ASM_CX
29567 jae bad_put_user
29568 ASM_STAC
29569 -4: mov %_ASM_AX,(%_ASM_CX)
29570 +
29571 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29572 + mov pax_user_shadow_base,%_ASM_BX
29573 + cmp %_ASM_BX,%_ASM_CX
29574 + jb 1234f
29575 + xor %ebx,%ebx
29576 +1234:
29577 +#endif
29578 +
29579 +#endif
29580 +
29581 +4: __copyuser_seg mov %_ASM_AX,(_DEST)
29582 #ifdef CONFIG_X86_32
29583 -5: movl %edx,4(%_ASM_CX)
29584 +5: __copyuser_seg movl %edx,4(_DEST)
29585 #endif
29586 xor %eax,%eax
29587 EXIT
29588 diff --git a/arch/x86/lib/rwlock.S b/arch/x86/lib/rwlock.S
29589 index 1cad221..de671ee 100644
29590 --- a/arch/x86/lib/rwlock.S
29591 +++ b/arch/x86/lib/rwlock.S
29592 @@ -16,13 +16,34 @@ ENTRY(__write_lock_failed)
29593 FRAME
29594 0: LOCK_PREFIX
29595 WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
29596 +
29597 +#ifdef CONFIG_PAX_REFCOUNT
29598 + jno 1234f
29599 + LOCK_PREFIX
29600 + WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
29601 + int $4
29602 +1234:
29603 + _ASM_EXTABLE(1234b, 1234b)
29604 +#endif
29605 +
29606 1: rep; nop
29607 cmpl $WRITE_LOCK_CMP, (%__lock_ptr)
29608 jne 1b
29609 LOCK_PREFIX
29610 WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
29611 +
29612 +#ifdef CONFIG_PAX_REFCOUNT
29613 + jno 1234f
29614 + LOCK_PREFIX
29615 + WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
29616 + int $4
29617 +1234:
29618 + _ASM_EXTABLE(1234b, 1234b)
29619 +#endif
29620 +
29621 jnz 0b
29622 ENDFRAME
29623 + pax_force_retaddr
29624 ret
29625 CFI_ENDPROC
29626 END(__write_lock_failed)
29627 @@ -32,13 +53,34 @@ ENTRY(__read_lock_failed)
29628 FRAME
29629 0: LOCK_PREFIX
29630 READ_LOCK_SIZE(inc) (%__lock_ptr)
29631 +
29632 +#ifdef CONFIG_PAX_REFCOUNT
29633 + jno 1234f
29634 + LOCK_PREFIX
29635 + READ_LOCK_SIZE(dec) (%__lock_ptr)
29636 + int $4
29637 +1234:
29638 + _ASM_EXTABLE(1234b, 1234b)
29639 +#endif
29640 +
29641 1: rep; nop
29642 READ_LOCK_SIZE(cmp) $1, (%__lock_ptr)
29643 js 1b
29644 LOCK_PREFIX
29645 READ_LOCK_SIZE(dec) (%__lock_ptr)
29646 +
29647 +#ifdef CONFIG_PAX_REFCOUNT
29648 + jno 1234f
29649 + LOCK_PREFIX
29650 + READ_LOCK_SIZE(inc) (%__lock_ptr)
29651 + int $4
29652 +1234:
29653 + _ASM_EXTABLE(1234b, 1234b)
29654 +#endif
29655 +
29656 js 0b
29657 ENDFRAME
29658 + pax_force_retaddr
29659 ret
29660 CFI_ENDPROC
29661 END(__read_lock_failed)
29662 diff --git a/arch/x86/lib/rwsem.S b/arch/x86/lib/rwsem.S
29663 index 5dff5f0..cadebf4 100644
29664 --- a/arch/x86/lib/rwsem.S
29665 +++ b/arch/x86/lib/rwsem.S
29666 @@ -94,6 +94,7 @@ ENTRY(call_rwsem_down_read_failed)
29667 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
29668 CFI_RESTORE __ASM_REG(dx)
29669 restore_common_regs
29670 + pax_force_retaddr
29671 ret
29672 CFI_ENDPROC
29673 ENDPROC(call_rwsem_down_read_failed)
29674 @@ -104,6 +105,7 @@ ENTRY(call_rwsem_down_write_failed)
29675 movq %rax,%rdi
29676 call rwsem_down_write_failed
29677 restore_common_regs
29678 + pax_force_retaddr
29679 ret
29680 CFI_ENDPROC
29681 ENDPROC(call_rwsem_down_write_failed)
29682 @@ -117,7 +119,8 @@ ENTRY(call_rwsem_wake)
29683 movq %rax,%rdi
29684 call rwsem_wake
29685 restore_common_regs
29686 -1: ret
29687 +1: pax_force_retaddr
29688 + ret
29689 CFI_ENDPROC
29690 ENDPROC(call_rwsem_wake)
29691
29692 @@ -131,6 +134,7 @@ ENTRY(call_rwsem_downgrade_wake)
29693 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
29694 CFI_RESTORE __ASM_REG(dx)
29695 restore_common_regs
29696 + pax_force_retaddr
29697 ret
29698 CFI_ENDPROC
29699 ENDPROC(call_rwsem_downgrade_wake)
29700 diff --git a/arch/x86/lib/thunk_64.S b/arch/x86/lib/thunk_64.S
29701 index a63efd6..8149fbe 100644
29702 --- a/arch/x86/lib/thunk_64.S
29703 +++ b/arch/x86/lib/thunk_64.S
29704 @@ -8,6 +8,7 @@
29705 #include <linux/linkage.h>
29706 #include <asm/dwarf2.h>
29707 #include <asm/calling.h>
29708 +#include <asm/alternative-asm.h>
29709
29710 /* rdi: arg1 ... normal C conventions. rax is saved/restored. */
29711 .macro THUNK name, func, put_ret_addr_in_rdi=0
29712 @@ -15,11 +16,11 @@
29713 \name:
29714 CFI_STARTPROC
29715
29716 - /* this one pushes 9 elems, the next one would be %rIP */
29717 - SAVE_ARGS
29718 + /* this one pushes 15+1 elems, the next one would be %rIP */
29719 + SAVE_ARGS 8
29720
29721 .if \put_ret_addr_in_rdi
29722 - movq_cfi_restore 9*8, rdi
29723 + movq_cfi_restore RIP, rdi
29724 .endif
29725
29726 call \func
29727 @@ -38,8 +39,9 @@
29728
29729 /* SAVE_ARGS below is used only for the .cfi directives it contains. */
29730 CFI_STARTPROC
29731 - SAVE_ARGS
29732 + SAVE_ARGS 8
29733 restore:
29734 - RESTORE_ARGS
29735 + RESTORE_ARGS 1,8
29736 + pax_force_retaddr
29737 ret
29738 CFI_ENDPROC
29739 diff --git a/arch/x86/lib/usercopy_32.c b/arch/x86/lib/usercopy_32.c
29740 index 3eb18ac..4b22130 100644
29741 --- a/arch/x86/lib/usercopy_32.c
29742 +++ b/arch/x86/lib/usercopy_32.c
29743 @@ -42,11 +42,13 @@ do { \
29744 int __d0; \
29745 might_fault(); \
29746 __asm__ __volatile__( \
29747 + __COPYUSER_SET_ES \
29748 ASM_STAC "\n" \
29749 "0: rep; stosl\n" \
29750 " movl %2,%0\n" \
29751 "1: rep; stosb\n" \
29752 "2: " ASM_CLAC "\n" \
29753 + __COPYUSER_RESTORE_ES \
29754 ".section .fixup,\"ax\"\n" \
29755 "3: lea 0(%2,%0,4),%0\n" \
29756 " jmp 2b\n" \
29757 @@ -98,7 +100,7 @@ EXPORT_SYMBOL(__clear_user);
29758
29759 #ifdef CONFIG_X86_INTEL_USERCOPY
29760 static unsigned long
29761 -__copy_user_intel(void __user *to, const void *from, unsigned long size)
29762 +__generic_copy_to_user_intel(void __user *to, const void *from, unsigned long size)
29763 {
29764 int d0, d1;
29765 __asm__ __volatile__(
29766 @@ -110,36 +112,36 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
29767 " .align 2,0x90\n"
29768 "3: movl 0(%4), %%eax\n"
29769 "4: movl 4(%4), %%edx\n"
29770 - "5: movl %%eax, 0(%3)\n"
29771 - "6: movl %%edx, 4(%3)\n"
29772 + "5: "__copyuser_seg" movl %%eax, 0(%3)\n"
29773 + "6: "__copyuser_seg" movl %%edx, 4(%3)\n"
29774 "7: movl 8(%4), %%eax\n"
29775 "8: movl 12(%4),%%edx\n"
29776 - "9: movl %%eax, 8(%3)\n"
29777 - "10: movl %%edx, 12(%3)\n"
29778 + "9: "__copyuser_seg" movl %%eax, 8(%3)\n"
29779 + "10: "__copyuser_seg" movl %%edx, 12(%3)\n"
29780 "11: movl 16(%4), %%eax\n"
29781 "12: movl 20(%4), %%edx\n"
29782 - "13: movl %%eax, 16(%3)\n"
29783 - "14: movl %%edx, 20(%3)\n"
29784 + "13: "__copyuser_seg" movl %%eax, 16(%3)\n"
29785 + "14: "__copyuser_seg" movl %%edx, 20(%3)\n"
29786 "15: movl 24(%4), %%eax\n"
29787 "16: movl 28(%4), %%edx\n"
29788 - "17: movl %%eax, 24(%3)\n"
29789 - "18: movl %%edx, 28(%3)\n"
29790 + "17: "__copyuser_seg" movl %%eax, 24(%3)\n"
29791 + "18: "__copyuser_seg" movl %%edx, 28(%3)\n"
29792 "19: movl 32(%4), %%eax\n"
29793 "20: movl 36(%4), %%edx\n"
29794 - "21: movl %%eax, 32(%3)\n"
29795 - "22: movl %%edx, 36(%3)\n"
29796 + "21: "__copyuser_seg" movl %%eax, 32(%3)\n"
29797 + "22: "__copyuser_seg" movl %%edx, 36(%3)\n"
29798 "23: movl 40(%4), %%eax\n"
29799 "24: movl 44(%4), %%edx\n"
29800 - "25: movl %%eax, 40(%3)\n"
29801 - "26: movl %%edx, 44(%3)\n"
29802 + "25: "__copyuser_seg" movl %%eax, 40(%3)\n"
29803 + "26: "__copyuser_seg" movl %%edx, 44(%3)\n"
29804 "27: movl 48(%4), %%eax\n"
29805 "28: movl 52(%4), %%edx\n"
29806 - "29: movl %%eax, 48(%3)\n"
29807 - "30: movl %%edx, 52(%3)\n"
29808 + "29: "__copyuser_seg" movl %%eax, 48(%3)\n"
29809 + "30: "__copyuser_seg" movl %%edx, 52(%3)\n"
29810 "31: movl 56(%4), %%eax\n"
29811 "32: movl 60(%4), %%edx\n"
29812 - "33: movl %%eax, 56(%3)\n"
29813 - "34: movl %%edx, 60(%3)\n"
29814 + "33: "__copyuser_seg" movl %%eax, 56(%3)\n"
29815 + "34: "__copyuser_seg" movl %%edx, 60(%3)\n"
29816 " addl $-64, %0\n"
29817 " addl $64, %4\n"
29818 " addl $64, %3\n"
29819 @@ -149,10 +151,116 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
29820 " shrl $2, %0\n"
29821 " andl $3, %%eax\n"
29822 " cld\n"
29823 + __COPYUSER_SET_ES
29824 "99: rep; movsl\n"
29825 "36: movl %%eax, %0\n"
29826 "37: rep; movsb\n"
29827 "100:\n"
29828 + __COPYUSER_RESTORE_ES
29829 + ".section .fixup,\"ax\"\n"
29830 + "101: lea 0(%%eax,%0,4),%0\n"
29831 + " jmp 100b\n"
29832 + ".previous\n"
29833 + _ASM_EXTABLE(1b,100b)
29834 + _ASM_EXTABLE(2b,100b)
29835 + _ASM_EXTABLE(3b,100b)
29836 + _ASM_EXTABLE(4b,100b)
29837 + _ASM_EXTABLE(5b,100b)
29838 + _ASM_EXTABLE(6b,100b)
29839 + _ASM_EXTABLE(7b,100b)
29840 + _ASM_EXTABLE(8b,100b)
29841 + _ASM_EXTABLE(9b,100b)
29842 + _ASM_EXTABLE(10b,100b)
29843 + _ASM_EXTABLE(11b,100b)
29844 + _ASM_EXTABLE(12b,100b)
29845 + _ASM_EXTABLE(13b,100b)
29846 + _ASM_EXTABLE(14b,100b)
29847 + _ASM_EXTABLE(15b,100b)
29848 + _ASM_EXTABLE(16b,100b)
29849 + _ASM_EXTABLE(17b,100b)
29850 + _ASM_EXTABLE(18b,100b)
29851 + _ASM_EXTABLE(19b,100b)
29852 + _ASM_EXTABLE(20b,100b)
29853 + _ASM_EXTABLE(21b,100b)
29854 + _ASM_EXTABLE(22b,100b)
29855 + _ASM_EXTABLE(23b,100b)
29856 + _ASM_EXTABLE(24b,100b)
29857 + _ASM_EXTABLE(25b,100b)
29858 + _ASM_EXTABLE(26b,100b)
29859 + _ASM_EXTABLE(27b,100b)
29860 + _ASM_EXTABLE(28b,100b)
29861 + _ASM_EXTABLE(29b,100b)
29862 + _ASM_EXTABLE(30b,100b)
29863 + _ASM_EXTABLE(31b,100b)
29864 + _ASM_EXTABLE(32b,100b)
29865 + _ASM_EXTABLE(33b,100b)
29866 + _ASM_EXTABLE(34b,100b)
29867 + _ASM_EXTABLE(35b,100b)
29868 + _ASM_EXTABLE(36b,100b)
29869 + _ASM_EXTABLE(37b,100b)
29870 + _ASM_EXTABLE(99b,101b)
29871 + : "=&c"(size), "=&D" (d0), "=&S" (d1)
29872 + : "1"(to), "2"(from), "0"(size)
29873 + : "eax", "edx", "memory");
29874 + return size;
29875 +}
29876 +
29877 +static unsigned long
29878 +__generic_copy_from_user_intel(void *to, const void __user *from, unsigned long size)
29879 +{
29880 + int d0, d1;
29881 + __asm__ __volatile__(
29882 + " .align 2,0x90\n"
29883 + "1: "__copyuser_seg" movl 32(%4), %%eax\n"
29884 + " cmpl $67, %0\n"
29885 + " jbe 3f\n"
29886 + "2: "__copyuser_seg" movl 64(%4), %%eax\n"
29887 + " .align 2,0x90\n"
29888 + "3: "__copyuser_seg" movl 0(%4), %%eax\n"
29889 + "4: "__copyuser_seg" movl 4(%4), %%edx\n"
29890 + "5: movl %%eax, 0(%3)\n"
29891 + "6: movl %%edx, 4(%3)\n"
29892 + "7: "__copyuser_seg" movl 8(%4), %%eax\n"
29893 + "8: "__copyuser_seg" movl 12(%4),%%edx\n"
29894 + "9: movl %%eax, 8(%3)\n"
29895 + "10: movl %%edx, 12(%3)\n"
29896 + "11: "__copyuser_seg" movl 16(%4), %%eax\n"
29897 + "12: "__copyuser_seg" movl 20(%4), %%edx\n"
29898 + "13: movl %%eax, 16(%3)\n"
29899 + "14: movl %%edx, 20(%3)\n"
29900 + "15: "__copyuser_seg" movl 24(%4), %%eax\n"
29901 + "16: "__copyuser_seg" movl 28(%4), %%edx\n"
29902 + "17: movl %%eax, 24(%3)\n"
29903 + "18: movl %%edx, 28(%3)\n"
29904 + "19: "__copyuser_seg" movl 32(%4), %%eax\n"
29905 + "20: "__copyuser_seg" movl 36(%4), %%edx\n"
29906 + "21: movl %%eax, 32(%3)\n"
29907 + "22: movl %%edx, 36(%3)\n"
29908 + "23: "__copyuser_seg" movl 40(%4), %%eax\n"
29909 + "24: "__copyuser_seg" movl 44(%4), %%edx\n"
29910 + "25: movl %%eax, 40(%3)\n"
29911 + "26: movl %%edx, 44(%3)\n"
29912 + "27: "__copyuser_seg" movl 48(%4), %%eax\n"
29913 + "28: "__copyuser_seg" movl 52(%4), %%edx\n"
29914 + "29: movl %%eax, 48(%3)\n"
29915 + "30: movl %%edx, 52(%3)\n"
29916 + "31: "__copyuser_seg" movl 56(%4), %%eax\n"
29917 + "32: "__copyuser_seg" movl 60(%4), %%edx\n"
29918 + "33: movl %%eax, 56(%3)\n"
29919 + "34: movl %%edx, 60(%3)\n"
29920 + " addl $-64, %0\n"
29921 + " addl $64, %4\n"
29922 + " addl $64, %3\n"
29923 + " cmpl $63, %0\n"
29924 + " ja 1b\n"
29925 + "35: movl %0, %%eax\n"
29926 + " shrl $2, %0\n"
29927 + " andl $3, %%eax\n"
29928 + " cld\n"
29929 + "99: rep; "__copyuser_seg" movsl\n"
29930 + "36: movl %%eax, %0\n"
29931 + "37: rep; "__copyuser_seg" movsb\n"
29932 + "100:\n"
29933 ".section .fixup,\"ax\"\n"
29934 "101: lea 0(%%eax,%0,4),%0\n"
29935 " jmp 100b\n"
29936 @@ -207,41 +315,41 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
29937 int d0, d1;
29938 __asm__ __volatile__(
29939 " .align 2,0x90\n"
29940 - "0: movl 32(%4), %%eax\n"
29941 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
29942 " cmpl $67, %0\n"
29943 " jbe 2f\n"
29944 - "1: movl 64(%4), %%eax\n"
29945 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
29946 " .align 2,0x90\n"
29947 - "2: movl 0(%4), %%eax\n"
29948 - "21: movl 4(%4), %%edx\n"
29949 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
29950 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
29951 " movl %%eax, 0(%3)\n"
29952 " movl %%edx, 4(%3)\n"
29953 - "3: movl 8(%4), %%eax\n"
29954 - "31: movl 12(%4),%%edx\n"
29955 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
29956 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
29957 " movl %%eax, 8(%3)\n"
29958 " movl %%edx, 12(%3)\n"
29959 - "4: movl 16(%4), %%eax\n"
29960 - "41: movl 20(%4), %%edx\n"
29961 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
29962 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
29963 " movl %%eax, 16(%3)\n"
29964 " movl %%edx, 20(%3)\n"
29965 - "10: movl 24(%4), %%eax\n"
29966 - "51: movl 28(%4), %%edx\n"
29967 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
29968 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
29969 " movl %%eax, 24(%3)\n"
29970 " movl %%edx, 28(%3)\n"
29971 - "11: movl 32(%4), %%eax\n"
29972 - "61: movl 36(%4), %%edx\n"
29973 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
29974 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
29975 " movl %%eax, 32(%3)\n"
29976 " movl %%edx, 36(%3)\n"
29977 - "12: movl 40(%4), %%eax\n"
29978 - "71: movl 44(%4), %%edx\n"
29979 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
29980 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
29981 " movl %%eax, 40(%3)\n"
29982 " movl %%edx, 44(%3)\n"
29983 - "13: movl 48(%4), %%eax\n"
29984 - "81: movl 52(%4), %%edx\n"
29985 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
29986 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
29987 " movl %%eax, 48(%3)\n"
29988 " movl %%edx, 52(%3)\n"
29989 - "14: movl 56(%4), %%eax\n"
29990 - "91: movl 60(%4), %%edx\n"
29991 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
29992 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
29993 " movl %%eax, 56(%3)\n"
29994 " movl %%edx, 60(%3)\n"
29995 " addl $-64, %0\n"
29996 @@ -253,9 +361,9 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
29997 " shrl $2, %0\n"
29998 " andl $3, %%eax\n"
29999 " cld\n"
30000 - "6: rep; movsl\n"
30001 + "6: rep; "__copyuser_seg" movsl\n"
30002 " movl %%eax,%0\n"
30003 - "7: rep; movsb\n"
30004 + "7: rep; "__copyuser_seg" movsb\n"
30005 "8:\n"
30006 ".section .fixup,\"ax\"\n"
30007 "9: lea 0(%%eax,%0,4),%0\n"
30008 @@ -305,41 +413,41 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
30009
30010 __asm__ __volatile__(
30011 " .align 2,0x90\n"
30012 - "0: movl 32(%4), %%eax\n"
30013 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
30014 " cmpl $67, %0\n"
30015 " jbe 2f\n"
30016 - "1: movl 64(%4), %%eax\n"
30017 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
30018 " .align 2,0x90\n"
30019 - "2: movl 0(%4), %%eax\n"
30020 - "21: movl 4(%4), %%edx\n"
30021 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
30022 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
30023 " movnti %%eax, 0(%3)\n"
30024 " movnti %%edx, 4(%3)\n"
30025 - "3: movl 8(%4), %%eax\n"
30026 - "31: movl 12(%4),%%edx\n"
30027 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
30028 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
30029 " movnti %%eax, 8(%3)\n"
30030 " movnti %%edx, 12(%3)\n"
30031 - "4: movl 16(%4), %%eax\n"
30032 - "41: movl 20(%4), %%edx\n"
30033 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
30034 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
30035 " movnti %%eax, 16(%3)\n"
30036 " movnti %%edx, 20(%3)\n"
30037 - "10: movl 24(%4), %%eax\n"
30038 - "51: movl 28(%4), %%edx\n"
30039 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
30040 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
30041 " movnti %%eax, 24(%3)\n"
30042 " movnti %%edx, 28(%3)\n"
30043 - "11: movl 32(%4), %%eax\n"
30044 - "61: movl 36(%4), %%edx\n"
30045 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
30046 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
30047 " movnti %%eax, 32(%3)\n"
30048 " movnti %%edx, 36(%3)\n"
30049 - "12: movl 40(%4), %%eax\n"
30050 - "71: movl 44(%4), %%edx\n"
30051 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
30052 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
30053 " movnti %%eax, 40(%3)\n"
30054 " movnti %%edx, 44(%3)\n"
30055 - "13: movl 48(%4), %%eax\n"
30056 - "81: movl 52(%4), %%edx\n"
30057 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
30058 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
30059 " movnti %%eax, 48(%3)\n"
30060 " movnti %%edx, 52(%3)\n"
30061 - "14: movl 56(%4), %%eax\n"
30062 - "91: movl 60(%4), %%edx\n"
30063 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
30064 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
30065 " movnti %%eax, 56(%3)\n"
30066 " movnti %%edx, 60(%3)\n"
30067 " addl $-64, %0\n"
30068 @@ -352,9 +460,9 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
30069 " shrl $2, %0\n"
30070 " andl $3, %%eax\n"
30071 " cld\n"
30072 - "6: rep; movsl\n"
30073 + "6: rep; "__copyuser_seg" movsl\n"
30074 " movl %%eax,%0\n"
30075 - "7: rep; movsb\n"
30076 + "7: rep; "__copyuser_seg" movsb\n"
30077 "8:\n"
30078 ".section .fixup,\"ax\"\n"
30079 "9: lea 0(%%eax,%0,4),%0\n"
30080 @@ -399,41 +507,41 @@ static unsigned long __copy_user_intel_nocache(void *to,
30081
30082 __asm__ __volatile__(
30083 " .align 2,0x90\n"
30084 - "0: movl 32(%4), %%eax\n"
30085 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
30086 " cmpl $67, %0\n"
30087 " jbe 2f\n"
30088 - "1: movl 64(%4), %%eax\n"
30089 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
30090 " .align 2,0x90\n"
30091 - "2: movl 0(%4), %%eax\n"
30092 - "21: movl 4(%4), %%edx\n"
30093 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
30094 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
30095 " movnti %%eax, 0(%3)\n"
30096 " movnti %%edx, 4(%3)\n"
30097 - "3: movl 8(%4), %%eax\n"
30098 - "31: movl 12(%4),%%edx\n"
30099 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
30100 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
30101 " movnti %%eax, 8(%3)\n"
30102 " movnti %%edx, 12(%3)\n"
30103 - "4: movl 16(%4), %%eax\n"
30104 - "41: movl 20(%4), %%edx\n"
30105 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
30106 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
30107 " movnti %%eax, 16(%3)\n"
30108 " movnti %%edx, 20(%3)\n"
30109 - "10: movl 24(%4), %%eax\n"
30110 - "51: movl 28(%4), %%edx\n"
30111 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
30112 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
30113 " movnti %%eax, 24(%3)\n"
30114 " movnti %%edx, 28(%3)\n"
30115 - "11: movl 32(%4), %%eax\n"
30116 - "61: movl 36(%4), %%edx\n"
30117 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
30118 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
30119 " movnti %%eax, 32(%3)\n"
30120 " movnti %%edx, 36(%3)\n"
30121 - "12: movl 40(%4), %%eax\n"
30122 - "71: movl 44(%4), %%edx\n"
30123 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
30124 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
30125 " movnti %%eax, 40(%3)\n"
30126 " movnti %%edx, 44(%3)\n"
30127 - "13: movl 48(%4), %%eax\n"
30128 - "81: movl 52(%4), %%edx\n"
30129 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
30130 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
30131 " movnti %%eax, 48(%3)\n"
30132 " movnti %%edx, 52(%3)\n"
30133 - "14: movl 56(%4), %%eax\n"
30134 - "91: movl 60(%4), %%edx\n"
30135 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
30136 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
30137 " movnti %%eax, 56(%3)\n"
30138 " movnti %%edx, 60(%3)\n"
30139 " addl $-64, %0\n"
30140 @@ -446,9 +554,9 @@ static unsigned long __copy_user_intel_nocache(void *to,
30141 " shrl $2, %0\n"
30142 " andl $3, %%eax\n"
30143 " cld\n"
30144 - "6: rep; movsl\n"
30145 + "6: rep; "__copyuser_seg" movsl\n"
30146 " movl %%eax,%0\n"
30147 - "7: rep; movsb\n"
30148 + "7: rep; "__copyuser_seg" movsb\n"
30149 "8:\n"
30150 ".section .fixup,\"ax\"\n"
30151 "9: lea 0(%%eax,%0,4),%0\n"
30152 @@ -488,32 +596,36 @@ static unsigned long __copy_user_intel_nocache(void *to,
30153 */
30154 unsigned long __copy_user_zeroing_intel(void *to, const void __user *from,
30155 unsigned long size);
30156 -unsigned long __copy_user_intel(void __user *to, const void *from,
30157 +unsigned long __generic_copy_to_user_intel(void __user *to, const void *from,
30158 + unsigned long size);
30159 +unsigned long __generic_copy_from_user_intel(void *to, const void __user *from,
30160 unsigned long size);
30161 unsigned long __copy_user_zeroing_intel_nocache(void *to,
30162 const void __user *from, unsigned long size);
30163 #endif /* CONFIG_X86_INTEL_USERCOPY */
30164
30165 /* Generic arbitrary sized copy. */
30166 -#define __copy_user(to, from, size) \
30167 +#define __copy_user(to, from, size, prefix, set, restore) \
30168 do { \
30169 int __d0, __d1, __d2; \
30170 __asm__ __volatile__( \
30171 + set \
30172 " cmp $7,%0\n" \
30173 " jbe 1f\n" \
30174 " movl %1,%0\n" \
30175 " negl %0\n" \
30176 " andl $7,%0\n" \
30177 " subl %0,%3\n" \
30178 - "4: rep; movsb\n" \
30179 + "4: rep; "prefix"movsb\n" \
30180 " movl %3,%0\n" \
30181 " shrl $2,%0\n" \
30182 " andl $3,%3\n" \
30183 " .align 2,0x90\n" \
30184 - "0: rep; movsl\n" \
30185 + "0: rep; "prefix"movsl\n" \
30186 " movl %3,%0\n" \
30187 - "1: rep; movsb\n" \
30188 + "1: rep; "prefix"movsb\n" \
30189 "2:\n" \
30190 + restore \
30191 ".section .fixup,\"ax\"\n" \
30192 "5: addl %3,%0\n" \
30193 " jmp 2b\n" \
30194 @@ -538,14 +650,14 @@ do { \
30195 " negl %0\n" \
30196 " andl $7,%0\n" \
30197 " subl %0,%3\n" \
30198 - "4: rep; movsb\n" \
30199 + "4: rep; "__copyuser_seg"movsb\n" \
30200 " movl %3,%0\n" \
30201 " shrl $2,%0\n" \
30202 " andl $3,%3\n" \
30203 " .align 2,0x90\n" \
30204 - "0: rep; movsl\n" \
30205 + "0: rep; "__copyuser_seg"movsl\n" \
30206 " movl %3,%0\n" \
30207 - "1: rep; movsb\n" \
30208 + "1: rep; "__copyuser_seg"movsb\n" \
30209 "2:\n" \
30210 ".section .fixup,\"ax\"\n" \
30211 "5: addl %3,%0\n" \
30212 @@ -572,9 +684,9 @@ unsigned long __copy_to_user_ll(void __user *to, const void *from,
30213 {
30214 stac();
30215 if (movsl_is_ok(to, from, n))
30216 - __copy_user(to, from, n);
30217 + __copy_user(to, from, n, "", __COPYUSER_SET_ES, __COPYUSER_RESTORE_ES);
30218 else
30219 - n = __copy_user_intel(to, from, n);
30220 + n = __generic_copy_to_user_intel(to, from, n);
30221 clac();
30222 return n;
30223 }
30224 @@ -598,10 +710,9 @@ unsigned long __copy_from_user_ll_nozero(void *to, const void __user *from,
30225 {
30226 stac();
30227 if (movsl_is_ok(to, from, n))
30228 - __copy_user(to, from, n);
30229 + __copy_user(to, from, n, __copyuser_seg, "", "");
30230 else
30231 - n = __copy_user_intel((void __user *)to,
30232 - (const void *)from, n);
30233 + n = __generic_copy_from_user_intel(to, from, n);
30234 clac();
30235 return n;
30236 }
30237 @@ -632,60 +743,38 @@ unsigned long __copy_from_user_ll_nocache_nozero(void *to, const void __user *fr
30238 if (n > 64 && cpu_has_xmm2)
30239 n = __copy_user_intel_nocache(to, from, n);
30240 else
30241 - __copy_user(to, from, n);
30242 + __copy_user(to, from, n, __copyuser_seg, "", "");
30243 #else
30244 - __copy_user(to, from, n);
30245 + __copy_user(to, from, n, __copyuser_seg, "", "");
30246 #endif
30247 clac();
30248 return n;
30249 }
30250 EXPORT_SYMBOL(__copy_from_user_ll_nocache_nozero);
30251
30252 -/**
30253 - * copy_to_user: - Copy a block of data into user space.
30254 - * @to: Destination address, in user space.
30255 - * @from: Source address, in kernel space.
30256 - * @n: Number of bytes to copy.
30257 - *
30258 - * Context: User context only. This function may sleep.
30259 - *
30260 - * Copy data from kernel space to user space.
30261 - *
30262 - * Returns number of bytes that could not be copied.
30263 - * On success, this will be zero.
30264 - */
30265 -unsigned long
30266 -copy_to_user(void __user *to, const void *from, unsigned long n)
30267 +#ifdef CONFIG_PAX_MEMORY_UDEREF
30268 +void __set_fs(mm_segment_t x)
30269 {
30270 - if (access_ok(VERIFY_WRITE, to, n))
30271 - n = __copy_to_user(to, from, n);
30272 - return n;
30273 + switch (x.seg) {
30274 + case 0:
30275 + loadsegment(gs, 0);
30276 + break;
30277 + case TASK_SIZE_MAX:
30278 + loadsegment(gs, __USER_DS);
30279 + break;
30280 + case -1UL:
30281 + loadsegment(gs, __KERNEL_DS);
30282 + break;
30283 + default:
30284 + BUG();
30285 + }
30286 }
30287 -EXPORT_SYMBOL(copy_to_user);
30288 +EXPORT_SYMBOL(__set_fs);
30289
30290 -/**
30291 - * copy_from_user: - Copy a block of data from user space.
30292 - * @to: Destination address, in kernel space.
30293 - * @from: Source address, in user space.
30294 - * @n: Number of bytes to copy.
30295 - *
30296 - * Context: User context only. This function may sleep.
30297 - *
30298 - * Copy data from user space to kernel space.
30299 - *
30300 - * Returns number of bytes that could not be copied.
30301 - * On success, this will be zero.
30302 - *
30303 - * If some data could not be copied, this function will pad the copied
30304 - * data to the requested size using zero bytes.
30305 - */
30306 -unsigned long
30307 -_copy_from_user(void *to, const void __user *from, unsigned long n)
30308 +void set_fs(mm_segment_t x)
30309 {
30310 - if (access_ok(VERIFY_READ, from, n))
30311 - n = __copy_from_user(to, from, n);
30312 - else
30313 - memset(to, 0, n);
30314 - return n;
30315 + current_thread_info()->addr_limit = x;
30316 + __set_fs(x);
30317 }
30318 -EXPORT_SYMBOL(_copy_from_user);
30319 +EXPORT_SYMBOL(set_fs);
30320 +#endif
30321 diff --git a/arch/x86/lib/usercopy_64.c b/arch/x86/lib/usercopy_64.c
30322 index c905e89..01ab928 100644
30323 --- a/arch/x86/lib/usercopy_64.c
30324 +++ b/arch/x86/lib/usercopy_64.c
30325 @@ -18,6 +18,7 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
30326 might_fault();
30327 /* no memory constraint because it doesn't change any memory gcc knows
30328 about */
30329 + pax_open_userland();
30330 stac();
30331 asm volatile(
30332 " testq %[size8],%[size8]\n"
30333 @@ -39,9 +40,10 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
30334 _ASM_EXTABLE(0b,3b)
30335 _ASM_EXTABLE(1b,2b)
30336 : [size8] "=&c"(size), [dst] "=&D" (__d0)
30337 - : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(addr),
30338 + : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(____m(addr)),
30339 [zero] "r" (0UL), [eight] "r" (8UL));
30340 clac();
30341 + pax_close_userland();
30342 return size;
30343 }
30344 EXPORT_SYMBOL(__clear_user);
30345 @@ -54,12 +56,11 @@ unsigned long clear_user(void __user *to, unsigned long n)
30346 }
30347 EXPORT_SYMBOL(clear_user);
30348
30349 -unsigned long copy_in_user(void __user *to, const void __user *from, unsigned len)
30350 +unsigned long copy_in_user(void __user *to, const void __user *from, unsigned long len)
30351 {
30352 - if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len)) {
30353 - return copy_user_generic((__force void *)to, (__force void *)from, len);
30354 - }
30355 - return len;
30356 + if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len))
30357 + return copy_user_generic((void __force_kernel *)____m(to), (void __force_kernel *)____m(from), len);
30358 + return len;
30359 }
30360 EXPORT_SYMBOL(copy_in_user);
30361
30362 @@ -69,11 +70,13 @@ EXPORT_SYMBOL(copy_in_user);
30363 * it is not necessary to optimize tail handling.
30364 */
30365 __visible unsigned long
30366 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
30367 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest)
30368 {
30369 char c;
30370 unsigned zero_len;
30371
30372 + clac();
30373 + pax_close_userland();
30374 for (; len; --len, to++) {
30375 if (__get_user_nocheck(c, from++, sizeof(char)))
30376 break;
30377 @@ -84,6 +87,5 @@ copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
30378 for (c = 0, zero_len = len; zerorest && zero_len; --zero_len)
30379 if (__put_user_nocheck(c, to++, sizeof(char)))
30380 break;
30381 - clac();
30382 return len;
30383 }
30384 diff --git a/arch/x86/mm/Makefile b/arch/x86/mm/Makefile
30385 index 23d8e5f..9ccc13a 100644
30386 --- a/arch/x86/mm/Makefile
30387 +++ b/arch/x86/mm/Makefile
30388 @@ -28,3 +28,7 @@ obj-$(CONFIG_ACPI_NUMA) += srat.o
30389 obj-$(CONFIG_NUMA_EMU) += numa_emulation.o
30390
30391 obj-$(CONFIG_MEMTEST) += memtest.o
30392 +
30393 +quote:="
30394 +obj-$(CONFIG_X86_64) += uderef_64.o
30395 +CFLAGS_uderef_64.o := $(subst $(quote),,$(CONFIG_ARCH_HWEIGHT_CFLAGS))
30396 diff --git a/arch/x86/mm/extable.c b/arch/x86/mm/extable.c
30397 index 903ec1e..c4166b2 100644
30398 --- a/arch/x86/mm/extable.c
30399 +++ b/arch/x86/mm/extable.c
30400 @@ -6,12 +6,24 @@
30401 static inline unsigned long
30402 ex_insn_addr(const struct exception_table_entry *x)
30403 {
30404 - return (unsigned long)&x->insn + x->insn;
30405 + unsigned long reloc = 0;
30406 +
30407 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
30408 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
30409 +#endif
30410 +
30411 + return (unsigned long)&x->insn + x->insn + reloc;
30412 }
30413 static inline unsigned long
30414 ex_fixup_addr(const struct exception_table_entry *x)
30415 {
30416 - return (unsigned long)&x->fixup + x->fixup;
30417 + unsigned long reloc = 0;
30418 +
30419 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
30420 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
30421 +#endif
30422 +
30423 + return (unsigned long)&x->fixup + x->fixup + reloc;
30424 }
30425
30426 int fixup_exception(struct pt_regs *regs)
30427 @@ -20,7 +32,7 @@ int fixup_exception(struct pt_regs *regs)
30428 unsigned long new_ip;
30429
30430 #ifdef CONFIG_PNPBIOS
30431 - if (unlikely(SEGMENT_IS_PNP_CODE(regs->cs))) {
30432 + if (unlikely(!v8086_mode(regs) && SEGMENT_IS_PNP_CODE(regs->cs))) {
30433 extern u32 pnp_bios_fault_eip, pnp_bios_fault_esp;
30434 extern u32 pnp_bios_is_utter_crap;
30435 pnp_bios_is_utter_crap = 1;
30436 @@ -145,6 +157,13 @@ void sort_extable(struct exception_table_entry *start,
30437 i += 4;
30438 p->fixup -= i;
30439 i += 4;
30440 +
30441 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
30442 + BUILD_BUG_ON(!IS_ENABLED(CONFIG_BUILDTIME_EXTABLE_SORT));
30443 + p->insn -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
30444 + p->fixup -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
30445 +#endif
30446 +
30447 }
30448 }
30449
30450 diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
30451 index 3aaeffc..42ea9fb 100644
30452 --- a/arch/x86/mm/fault.c
30453 +++ b/arch/x86/mm/fault.c
30454 @@ -14,11 +14,18 @@
30455 #include <linux/hugetlb.h> /* hstate_index_to_shift */
30456 #include <linux/prefetch.h> /* prefetchw */
30457 #include <linux/context_tracking.h> /* exception_enter(), ... */
30458 +#include <linux/unistd.h>
30459 +#include <linux/compiler.h>
30460
30461 #include <asm/traps.h> /* dotraplinkage, ... */
30462 #include <asm/pgalloc.h> /* pgd_*(), ... */
30463 #include <asm/kmemcheck.h> /* kmemcheck_*(), ... */
30464 #include <asm/fixmap.h> /* VSYSCALL_START */
30465 +#include <asm/tlbflush.h>
30466 +
30467 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
30468 +#include <asm/stacktrace.h>
30469 +#endif
30470
30471 /*
30472 * Page fault error code bits:
30473 @@ -56,7 +63,7 @@ static inline int __kprobes notify_page_fault(struct pt_regs *regs)
30474 int ret = 0;
30475
30476 /* kprobe_running() needs smp_processor_id() */
30477 - if (kprobes_built_in() && !user_mode_vm(regs)) {
30478 + if (kprobes_built_in() && !user_mode(regs)) {
30479 preempt_disable();
30480 if (kprobe_running() && kprobe_fault_handler(regs, 14))
30481 ret = 1;
30482 @@ -117,7 +124,10 @@ check_prefetch_opcode(struct pt_regs *regs, unsigned char *instr,
30483 return !instr_lo || (instr_lo>>1) == 1;
30484 case 0x00:
30485 /* Prefetch instruction is 0x0F0D or 0x0F18 */
30486 - if (probe_kernel_address(instr, opcode))
30487 + if (user_mode(regs)) {
30488 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
30489 + return 0;
30490 + } else if (probe_kernel_address(instr, opcode))
30491 return 0;
30492
30493 *prefetch = (instr_lo == 0xF) &&
30494 @@ -151,7 +161,10 @@ is_prefetch(struct pt_regs *regs, unsigned long error_code, unsigned long addr)
30495 while (instr < max_instr) {
30496 unsigned char opcode;
30497
30498 - if (probe_kernel_address(instr, opcode))
30499 + if (user_mode(regs)) {
30500 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
30501 + break;
30502 + } else if (probe_kernel_address(instr, opcode))
30503 break;
30504
30505 instr++;
30506 @@ -182,6 +195,34 @@ force_sig_info_fault(int si_signo, int si_code, unsigned long address,
30507 force_sig_info(si_signo, &info, tsk);
30508 }
30509
30510 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
30511 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address);
30512 +#endif
30513 +
30514 +#ifdef CONFIG_PAX_EMUTRAMP
30515 +static int pax_handle_fetch_fault(struct pt_regs *regs);
30516 +#endif
30517 +
30518 +#ifdef CONFIG_PAX_PAGEEXEC
30519 +static inline pmd_t * pax_get_pmd(struct mm_struct *mm, unsigned long address)
30520 +{
30521 + pgd_t *pgd;
30522 + pud_t *pud;
30523 + pmd_t *pmd;
30524 +
30525 + pgd = pgd_offset(mm, address);
30526 + if (!pgd_present(*pgd))
30527 + return NULL;
30528 + pud = pud_offset(pgd, address);
30529 + if (!pud_present(*pud))
30530 + return NULL;
30531 + pmd = pmd_offset(pud, address);
30532 + if (!pmd_present(*pmd))
30533 + return NULL;
30534 + return pmd;
30535 +}
30536 +#endif
30537 +
30538 DEFINE_SPINLOCK(pgd_lock);
30539 LIST_HEAD(pgd_list);
30540
30541 @@ -232,10 +273,27 @@ void vmalloc_sync_all(void)
30542 for (address = VMALLOC_START & PMD_MASK;
30543 address >= TASK_SIZE && address < FIXADDR_TOP;
30544 address += PMD_SIZE) {
30545 +
30546 +#ifdef CONFIG_PAX_PER_CPU_PGD
30547 + unsigned long cpu;
30548 +#else
30549 struct page *page;
30550 +#endif
30551
30552 spin_lock(&pgd_lock);
30553 +
30554 +#ifdef CONFIG_PAX_PER_CPU_PGD
30555 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
30556 + pgd_t *pgd = get_cpu_pgd(cpu, user);
30557 + pmd_t *ret;
30558 +
30559 + ret = vmalloc_sync_one(pgd, address);
30560 + if (!ret)
30561 + break;
30562 + pgd = get_cpu_pgd(cpu, kernel);
30563 +#else
30564 list_for_each_entry(page, &pgd_list, lru) {
30565 + pgd_t *pgd;
30566 spinlock_t *pgt_lock;
30567 pmd_t *ret;
30568
30569 @@ -243,8 +301,14 @@ void vmalloc_sync_all(void)
30570 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
30571
30572 spin_lock(pgt_lock);
30573 - ret = vmalloc_sync_one(page_address(page), address);
30574 + pgd = page_address(page);
30575 +#endif
30576 +
30577 + ret = vmalloc_sync_one(pgd, address);
30578 +
30579 +#ifndef CONFIG_PAX_PER_CPU_PGD
30580 spin_unlock(pgt_lock);
30581 +#endif
30582
30583 if (!ret)
30584 break;
30585 @@ -278,6 +342,12 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
30586 * an interrupt in the middle of a task switch..
30587 */
30588 pgd_paddr = read_cr3();
30589 +
30590 +#ifdef CONFIG_PAX_PER_CPU_PGD
30591 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id(), kernel)) != (pgd_paddr & __PHYSICAL_MASK));
30592 + vmalloc_sync_one(__va(pgd_paddr + PAGE_SIZE), address);
30593 +#endif
30594 +
30595 pmd_k = vmalloc_sync_one(__va(pgd_paddr), address);
30596 if (!pmd_k)
30597 return -1;
30598 @@ -373,11 +443,25 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
30599 * happen within a race in page table update. In the later
30600 * case just flush:
30601 */
30602 - pgd = pgd_offset(current->active_mm, address);
30603 +
30604 pgd_ref = pgd_offset_k(address);
30605 if (pgd_none(*pgd_ref))
30606 return -1;
30607
30608 +#ifdef CONFIG_PAX_PER_CPU_PGD
30609 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id(), kernel)) != (read_cr3() & __PHYSICAL_MASK));
30610 + pgd = pgd_offset_cpu(smp_processor_id(), user, address);
30611 + if (pgd_none(*pgd)) {
30612 + set_pgd(pgd, *pgd_ref);
30613 + arch_flush_lazy_mmu_mode();
30614 + } else {
30615 + BUG_ON(pgd_page_vaddr(*pgd) != pgd_page_vaddr(*pgd_ref));
30616 + }
30617 + pgd = pgd_offset_cpu(smp_processor_id(), kernel, address);
30618 +#else
30619 + pgd = pgd_offset(current->active_mm, address);
30620 +#endif
30621 +
30622 if (pgd_none(*pgd)) {
30623 set_pgd(pgd, *pgd_ref);
30624 arch_flush_lazy_mmu_mode();
30625 @@ -543,7 +627,7 @@ static int is_errata93(struct pt_regs *regs, unsigned long address)
30626 static int is_errata100(struct pt_regs *regs, unsigned long address)
30627 {
30628 #ifdef CONFIG_X86_64
30629 - if ((regs->cs == __USER32_CS || (regs->cs & (1<<2))) && (address >> 32))
30630 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)) && (address >> 32))
30631 return 1;
30632 #endif
30633 return 0;
30634 @@ -570,7 +654,7 @@ static int is_f00f_bug(struct pt_regs *regs, unsigned long address)
30635 }
30636
30637 static const char nx_warning[] = KERN_CRIT
30638 -"kernel tried to execute NX-protected page - exploit attempt? (uid: %d)\n";
30639 +"kernel tried to execute NX-protected page - exploit attempt? (uid: %d, task: %s, pid: %d)\n";
30640
30641 static void
30642 show_fault_oops(struct pt_regs *regs, unsigned long error_code,
30643 @@ -579,15 +663,27 @@ show_fault_oops(struct pt_regs *regs, unsigned long error_code,
30644 if (!oops_may_print())
30645 return;
30646
30647 - if (error_code & PF_INSTR) {
30648 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR)) {
30649 unsigned int level;
30650
30651 pte_t *pte = lookup_address(address, &level);
30652
30653 if (pte && pte_present(*pte) && !pte_exec(*pte))
30654 - printk(nx_warning, from_kuid(&init_user_ns, current_uid()));
30655 + printk(nx_warning, from_kuid_munged(&init_user_ns, current_uid()), current->comm, task_pid_nr(current));
30656 }
30657
30658 +#ifdef CONFIG_PAX_KERNEXEC
30659 + if (init_mm.start_code <= address && address < init_mm.end_code) {
30660 + if (current->signal->curr_ip)
30661 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n",
30662 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
30663 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
30664 + else
30665 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
30666 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
30667 + }
30668 +#endif
30669 +
30670 printk(KERN_ALERT "BUG: unable to handle kernel ");
30671 if (address < PAGE_SIZE)
30672 printk(KERN_CONT "NULL pointer dereference");
30673 @@ -750,6 +846,22 @@ __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code,
30674 return;
30675 }
30676 #endif
30677 +
30678 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
30679 + if (pax_is_fetch_fault(regs, error_code, address)) {
30680 +
30681 +#ifdef CONFIG_PAX_EMUTRAMP
30682 + switch (pax_handle_fetch_fault(regs)) {
30683 + case 2:
30684 + return;
30685 + }
30686 +#endif
30687 +
30688 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
30689 + do_group_exit(SIGKILL);
30690 + }
30691 +#endif
30692 +
30693 /* Kernel addresses are always protection faults: */
30694 if (address >= TASK_SIZE)
30695 error_code |= PF_PROT;
30696 @@ -835,7 +947,7 @@ do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address,
30697 if (fault & (VM_FAULT_HWPOISON|VM_FAULT_HWPOISON_LARGE)) {
30698 printk(KERN_ERR
30699 "MCE: Killing %s:%d due to hardware memory corruption fault at %lx\n",
30700 - tsk->comm, tsk->pid, address);
30701 + tsk->comm, task_pid_nr(tsk), address);
30702 code = BUS_MCEERR_AR;
30703 }
30704 #endif
30705 @@ -889,6 +1001,99 @@ static int spurious_fault_check(unsigned long error_code, pte_t *pte)
30706 return 1;
30707 }
30708
30709 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
30710 +static int pax_handle_pageexec_fault(struct pt_regs *regs, struct mm_struct *mm, unsigned long address, unsigned long error_code)
30711 +{
30712 + pte_t *pte;
30713 + pmd_t *pmd;
30714 + spinlock_t *ptl;
30715 + unsigned char pte_mask;
30716 +
30717 + if ((__supported_pte_mask & _PAGE_NX) || (error_code & (PF_PROT|PF_USER)) != (PF_PROT|PF_USER) || v8086_mode(regs) ||
30718 + !(mm->pax_flags & MF_PAX_PAGEEXEC))
30719 + return 0;
30720 +
30721 + /* PaX: it's our fault, let's handle it if we can */
30722 +
30723 + /* PaX: take a look at read faults before acquiring any locks */
30724 + if (unlikely(!(error_code & PF_WRITE) && (regs->ip == address))) {
30725 + /* instruction fetch attempt from a protected page in user mode */
30726 + up_read(&mm->mmap_sem);
30727 +
30728 +#ifdef CONFIG_PAX_EMUTRAMP
30729 + switch (pax_handle_fetch_fault(regs)) {
30730 + case 2:
30731 + return 1;
30732 + }
30733 +#endif
30734 +
30735 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
30736 + do_group_exit(SIGKILL);
30737 + }
30738 +
30739 + pmd = pax_get_pmd(mm, address);
30740 + if (unlikely(!pmd))
30741 + return 0;
30742 +
30743 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
30744 + if (unlikely(!(pte_val(*pte) & _PAGE_PRESENT) || pte_user(*pte))) {
30745 + pte_unmap_unlock(pte, ptl);
30746 + return 0;
30747 + }
30748 +
30749 + if (unlikely((error_code & PF_WRITE) && !pte_write(*pte))) {
30750 + /* write attempt to a protected page in user mode */
30751 + pte_unmap_unlock(pte, ptl);
30752 + return 0;
30753 + }
30754 +
30755 +#ifdef CONFIG_SMP
30756 + if (likely(address > get_limit(regs->cs) && cpu_isset(smp_processor_id(), mm->context.cpu_user_cs_mask)))
30757 +#else
30758 + if (likely(address > get_limit(regs->cs)))
30759 +#endif
30760 + {
30761 + set_pte(pte, pte_mkread(*pte));
30762 + __flush_tlb_one(address);
30763 + pte_unmap_unlock(pte, ptl);
30764 + up_read(&mm->mmap_sem);
30765 + return 1;
30766 + }
30767 +
30768 + pte_mask = _PAGE_ACCESSED | _PAGE_USER | ((error_code & PF_WRITE) << (_PAGE_BIT_DIRTY-1));
30769 +
30770 + /*
30771 + * PaX: fill DTLB with user rights and retry
30772 + */
30773 + __asm__ __volatile__ (
30774 + "orb %2,(%1)\n"
30775 +#if defined(CONFIG_M586) || defined(CONFIG_M586TSC)
30776 +/*
30777 + * PaX: let this uncommented 'invlpg' remind us on the behaviour of Intel's
30778 + * (and AMD's) TLBs. namely, they do not cache PTEs that would raise *any*
30779 + * page fault when examined during a TLB load attempt. this is true not only
30780 + * for PTEs holding a non-present entry but also present entries that will
30781 + * raise a page fault (such as those set up by PaX, or the copy-on-write
30782 + * mechanism). in effect it means that we do *not* need to flush the TLBs
30783 + * for our target pages since their PTEs are simply not in the TLBs at all.
30784 +
30785 + * the best thing in omitting it is that we gain around 15-20% speed in the
30786 + * fast path of the page fault handler and can get rid of tracing since we
30787 + * can no longer flush unintended entries.
30788 + */
30789 + "invlpg (%0)\n"
30790 +#endif
30791 + __copyuser_seg"testb $0,(%0)\n"
30792 + "xorb %3,(%1)\n"
30793 + :
30794 + : "r" (address), "r" (pte), "q" (pte_mask), "i" (_PAGE_USER)
30795 + : "memory", "cc");
30796 + pte_unmap_unlock(pte, ptl);
30797 + up_read(&mm->mmap_sem);
30798 + return 1;
30799 +}
30800 +#endif
30801 +
30802 /*
30803 * Handle a spurious fault caused by a stale TLB entry.
30804 *
30805 @@ -955,6 +1160,9 @@ int show_unhandled_signals = 1;
30806 static inline int
30807 access_error(unsigned long error_code, struct vm_area_struct *vma)
30808 {
30809 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR) && !(vma->vm_flags & VM_EXEC))
30810 + return 1;
30811 +
30812 if (error_code & PF_WRITE) {
30813 /* write, present and write, not present: */
30814 if (unlikely(!(vma->vm_flags & VM_WRITE)))
30815 @@ -983,7 +1191,7 @@ static inline bool smap_violation(int error_code, struct pt_regs *regs)
30816 if (error_code & PF_USER)
30817 return false;
30818
30819 - if (!user_mode_vm(regs) && (regs->flags & X86_EFLAGS_AC))
30820 + if (!user_mode(regs) && (regs->flags & X86_EFLAGS_AC))
30821 return false;
30822
30823 return true;
30824 @@ -1010,6 +1218,22 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
30825 /* Get the faulting address: */
30826 address = read_cr2();
30827
30828 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
30829 + if (!user_mode(regs) && address < 2 * pax_user_shadow_base) {
30830 + if (!search_exception_tables(regs->ip)) {
30831 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
30832 + bad_area_nosemaphore(regs, error_code, address);
30833 + return;
30834 + }
30835 + if (address < pax_user_shadow_base) {
30836 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
30837 + printk(KERN_ERR "PAX: faulting IP: %pS\n", (void *)regs->ip);
30838 + show_trace_log_lvl(NULL, NULL, (void *)regs->sp, regs->bp, KERN_ERR);
30839 + } else
30840 + address -= pax_user_shadow_base;
30841 + }
30842 +#endif
30843 +
30844 /*
30845 * Detect and handle instructions that would cause a page fault for
30846 * both a tracked kernel page and a userspace page.
30847 @@ -1069,7 +1293,7 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
30848 * User-mode registers count as a user access even for any
30849 * potential system fault or CPU buglet:
30850 */
30851 - if (user_mode_vm(regs)) {
30852 + if (user_mode(regs)) {
30853 local_irq_enable();
30854 error_code |= PF_USER;
30855 flags |= FAULT_FLAG_USER;
30856 @@ -1135,6 +1359,11 @@ retry:
30857 might_sleep();
30858 }
30859
30860 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
30861 + if (pax_handle_pageexec_fault(regs, mm, address, error_code))
30862 + return;
30863 +#endif
30864 +
30865 vma = find_vma(mm, address);
30866 if (unlikely(!vma)) {
30867 bad_area(regs, error_code, address);
30868 @@ -1146,18 +1375,24 @@ retry:
30869 bad_area(regs, error_code, address);
30870 return;
30871 }
30872 - if (error_code & PF_USER) {
30873 - /*
30874 - * Accessing the stack below %sp is always a bug.
30875 - * The large cushion allows instructions like enter
30876 - * and pusha to work. ("enter $65535, $31" pushes
30877 - * 32 pointers and then decrements %sp by 65535.)
30878 - */
30879 - if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < regs->sp)) {
30880 - bad_area(regs, error_code, address);
30881 - return;
30882 - }
30883 + /*
30884 + * Accessing the stack below %sp is always a bug.
30885 + * The large cushion allows instructions like enter
30886 + * and pusha to work. ("enter $65535, $31" pushes
30887 + * 32 pointers and then decrements %sp by 65535.)
30888 + */
30889 + if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < task_pt_regs(tsk)->sp)) {
30890 + bad_area(regs, error_code, address);
30891 + return;
30892 }
30893 +
30894 +#ifdef CONFIG_PAX_SEGMEXEC
30895 + if (unlikely((mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end - SEGMEXEC_TASK_SIZE - 1 < address - SEGMEXEC_TASK_SIZE - 1)) {
30896 + bad_area(regs, error_code, address);
30897 + return;
30898 + }
30899 +#endif
30900 +
30901 if (unlikely(expand_stack(vma, address))) {
30902 bad_area(regs, error_code, address);
30903 return;
30904 @@ -1231,3 +1466,292 @@ do_page_fault(struct pt_regs *regs, unsigned long error_code)
30905 __do_page_fault(regs, error_code);
30906 exception_exit(prev_state);
30907 }
30908 +
30909 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
30910 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address)
30911 +{
30912 + struct mm_struct *mm = current->mm;
30913 + unsigned long ip = regs->ip;
30914 +
30915 + if (v8086_mode(regs))
30916 + ip = ((regs->cs & 0xffff) << 4) + (ip & 0xffff);
30917 +
30918 +#ifdef CONFIG_PAX_PAGEEXEC
30919 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
30920 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR))
30921 + return true;
30922 + if (!(error_code & (PF_PROT | PF_WRITE)) && ip == address)
30923 + return true;
30924 + return false;
30925 + }
30926 +#endif
30927 +
30928 +#ifdef CONFIG_PAX_SEGMEXEC
30929 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
30930 + if (!(error_code & (PF_PROT | PF_WRITE)) && (ip + SEGMEXEC_TASK_SIZE == address))
30931 + return true;
30932 + return false;
30933 + }
30934 +#endif
30935 +
30936 + return false;
30937 +}
30938 +#endif
30939 +
30940 +#ifdef CONFIG_PAX_EMUTRAMP
30941 +static int pax_handle_fetch_fault_32(struct pt_regs *regs)
30942 +{
30943 + int err;
30944 +
30945 + do { /* PaX: libffi trampoline emulation */
30946 + unsigned char mov, jmp;
30947 + unsigned int addr1, addr2;
30948 +
30949 +#ifdef CONFIG_X86_64
30950 + if ((regs->ip + 9) >> 32)
30951 + break;
30952 +#endif
30953 +
30954 + err = get_user(mov, (unsigned char __user *)regs->ip);
30955 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
30956 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
30957 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
30958 +
30959 + if (err)
30960 + break;
30961 +
30962 + if (mov == 0xB8 && jmp == 0xE9) {
30963 + regs->ax = addr1;
30964 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
30965 + return 2;
30966 + }
30967 + } while (0);
30968 +
30969 + do { /* PaX: gcc trampoline emulation #1 */
30970 + unsigned char mov1, mov2;
30971 + unsigned short jmp;
30972 + unsigned int addr1, addr2;
30973 +
30974 +#ifdef CONFIG_X86_64
30975 + if ((regs->ip + 11) >> 32)
30976 + break;
30977 +#endif
30978 +
30979 + err = get_user(mov1, (unsigned char __user *)regs->ip);
30980 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
30981 + err |= get_user(mov2, (unsigned char __user *)(regs->ip + 5));
30982 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
30983 + err |= get_user(jmp, (unsigned short __user *)(regs->ip + 10));
30984 +
30985 + if (err)
30986 + break;
30987 +
30988 + if (mov1 == 0xB9 && mov2 == 0xB8 && jmp == 0xE0FF) {
30989 + regs->cx = addr1;
30990 + regs->ax = addr2;
30991 + regs->ip = addr2;
30992 + return 2;
30993 + }
30994 + } while (0);
30995 +
30996 + do { /* PaX: gcc trampoline emulation #2 */
30997 + unsigned char mov, jmp;
30998 + unsigned int addr1, addr2;
30999 +
31000 +#ifdef CONFIG_X86_64
31001 + if ((regs->ip + 9) >> 32)
31002 + break;
31003 +#endif
31004 +
31005 + err = get_user(mov, (unsigned char __user *)regs->ip);
31006 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
31007 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
31008 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
31009 +
31010 + if (err)
31011 + break;
31012 +
31013 + if (mov == 0xB9 && jmp == 0xE9) {
31014 + regs->cx = addr1;
31015 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
31016 + return 2;
31017 + }
31018 + } while (0);
31019 +
31020 + return 1; /* PaX in action */
31021 +}
31022 +
31023 +#ifdef CONFIG_X86_64
31024 +static int pax_handle_fetch_fault_64(struct pt_regs *regs)
31025 +{
31026 + int err;
31027 +
31028 + do { /* PaX: libffi trampoline emulation */
31029 + unsigned short mov1, mov2, jmp1;
31030 + unsigned char stcclc, jmp2;
31031 + unsigned long addr1, addr2;
31032 +
31033 + err = get_user(mov1, (unsigned short __user *)regs->ip);
31034 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
31035 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
31036 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
31037 + err |= get_user(stcclc, (unsigned char __user *)(regs->ip + 20));
31038 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 21));
31039 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 23));
31040 +
31041 + if (err)
31042 + break;
31043 +
31044 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && (stcclc == 0xF8 || stcclc == 0xF9) && jmp1 == 0xFF49 && jmp2 == 0xE3) {
31045 + regs->r11 = addr1;
31046 + regs->r10 = addr2;
31047 + if (stcclc == 0xF8)
31048 + regs->flags &= ~X86_EFLAGS_CF;
31049 + else
31050 + regs->flags |= X86_EFLAGS_CF;
31051 + regs->ip = addr1;
31052 + return 2;
31053 + }
31054 + } while (0);
31055 +
31056 + do { /* PaX: gcc trampoline emulation #1 */
31057 + unsigned short mov1, mov2, jmp1;
31058 + unsigned char jmp2;
31059 + unsigned int addr1;
31060 + unsigned long addr2;
31061 +
31062 + err = get_user(mov1, (unsigned short __user *)regs->ip);
31063 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 2));
31064 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 6));
31065 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 8));
31066 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 16));
31067 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 18));
31068 +
31069 + if (err)
31070 + break;
31071 +
31072 + if (mov1 == 0xBB41 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
31073 + regs->r11 = addr1;
31074 + regs->r10 = addr2;
31075 + regs->ip = addr1;
31076 + return 2;
31077 + }
31078 + } while (0);
31079 +
31080 + do { /* PaX: gcc trampoline emulation #2 */
31081 + unsigned short mov1, mov2, jmp1;
31082 + unsigned char jmp2;
31083 + unsigned long addr1, addr2;
31084 +
31085 + err = get_user(mov1, (unsigned short __user *)regs->ip);
31086 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
31087 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
31088 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
31089 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 20));
31090 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 22));
31091 +
31092 + if (err)
31093 + break;
31094 +
31095 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
31096 + regs->r11 = addr1;
31097 + regs->r10 = addr2;
31098 + regs->ip = addr1;
31099 + return 2;
31100 + }
31101 + } while (0);
31102 +
31103 + return 1; /* PaX in action */
31104 +}
31105 +#endif
31106 +
31107 +/*
31108 + * PaX: decide what to do with offenders (regs->ip = fault address)
31109 + *
31110 + * returns 1 when task should be killed
31111 + * 2 when gcc trampoline was detected
31112 + */
31113 +static int pax_handle_fetch_fault(struct pt_regs *regs)
31114 +{
31115 + if (v8086_mode(regs))
31116 + return 1;
31117 +
31118 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
31119 + return 1;
31120 +
31121 +#ifdef CONFIG_X86_32
31122 + return pax_handle_fetch_fault_32(regs);
31123 +#else
31124 + if (regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))
31125 + return pax_handle_fetch_fault_32(regs);
31126 + else
31127 + return pax_handle_fetch_fault_64(regs);
31128 +#endif
31129 +}
31130 +#endif
31131 +
31132 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
31133 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
31134 +{
31135 + long i;
31136 +
31137 + printk(KERN_ERR "PAX: bytes at PC: ");
31138 + for (i = 0; i < 20; i++) {
31139 + unsigned char c;
31140 + if (get_user(c, (unsigned char __force_user *)pc+i))
31141 + printk(KERN_CONT "?? ");
31142 + else
31143 + printk(KERN_CONT "%02x ", c);
31144 + }
31145 + printk("\n");
31146 +
31147 + printk(KERN_ERR "PAX: bytes at SP-%lu: ", (unsigned long)sizeof(long));
31148 + for (i = -1; i < 80 / (long)sizeof(long); i++) {
31149 + unsigned long c;
31150 + if (get_user(c, (unsigned long __force_user *)sp+i)) {
31151 +#ifdef CONFIG_X86_32
31152 + printk(KERN_CONT "???????? ");
31153 +#else
31154 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)))
31155 + printk(KERN_CONT "???????? ???????? ");
31156 + else
31157 + printk(KERN_CONT "???????????????? ");
31158 +#endif
31159 + } else {
31160 +#ifdef CONFIG_X86_64
31161 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))) {
31162 + printk(KERN_CONT "%08x ", (unsigned int)c);
31163 + printk(KERN_CONT "%08x ", (unsigned int)(c >> 32));
31164 + } else
31165 +#endif
31166 + printk(KERN_CONT "%0*lx ", 2 * (int)sizeof(long), c);
31167 + }
31168 + }
31169 + printk("\n");
31170 +}
31171 +#endif
31172 +
31173 +/**
31174 + * probe_kernel_write(): safely attempt to write to a location
31175 + * @dst: address to write to
31176 + * @src: pointer to the data that shall be written
31177 + * @size: size of the data chunk
31178 + *
31179 + * Safely write to address @dst from the buffer at @src. If a kernel fault
31180 + * happens, handle that and return -EFAULT.
31181 + */
31182 +long notrace probe_kernel_write(void *dst, const void *src, size_t size)
31183 +{
31184 + long ret;
31185 + mm_segment_t old_fs = get_fs();
31186 +
31187 + set_fs(KERNEL_DS);
31188 + pagefault_disable();
31189 + pax_open_kernel();
31190 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
31191 + pax_close_kernel();
31192 + pagefault_enable();
31193 + set_fs(old_fs);
31194 +
31195 + return ret ? -EFAULT : 0;
31196 +}
31197 diff --git a/arch/x86/mm/gup.c b/arch/x86/mm/gup.c
31198 index dd74e46..0970b01 100644
31199 --- a/arch/x86/mm/gup.c
31200 +++ b/arch/x86/mm/gup.c
31201 @@ -255,7 +255,7 @@ int __get_user_pages_fast(unsigned long start, int nr_pages, int write,
31202 addr = start;
31203 len = (unsigned long) nr_pages << PAGE_SHIFT;
31204 end = start + len;
31205 - if (unlikely(!access_ok(write ? VERIFY_WRITE : VERIFY_READ,
31206 + if (unlikely(!__access_ok(write ? VERIFY_WRITE : VERIFY_READ,
31207 (void __user *)start, len)))
31208 return 0;
31209
31210 @@ -331,6 +331,10 @@ int get_user_pages_fast(unsigned long start, int nr_pages, int write,
31211 goto slow_irqon;
31212 #endif
31213
31214 + if (unlikely(!__access_ok(write ? VERIFY_WRITE : VERIFY_READ,
31215 + (void __user *)start, len)))
31216 + return 0;
31217 +
31218 /*
31219 * XXX: batch / limit 'nr', to avoid large irq off latency
31220 * needs some instrumenting to determine the common sizes used by
31221 diff --git a/arch/x86/mm/highmem_32.c b/arch/x86/mm/highmem_32.c
31222 index 4500142..53a363c 100644
31223 --- a/arch/x86/mm/highmem_32.c
31224 +++ b/arch/x86/mm/highmem_32.c
31225 @@ -45,7 +45,11 @@ void *kmap_atomic_prot(struct page *page, pgprot_t prot)
31226 idx = type + KM_TYPE_NR*smp_processor_id();
31227 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
31228 BUG_ON(!pte_none(*(kmap_pte-idx)));
31229 +
31230 + pax_open_kernel();
31231 set_pte(kmap_pte-idx, mk_pte(page, prot));
31232 + pax_close_kernel();
31233 +
31234 arch_flush_lazy_mmu_mode();
31235
31236 return (void *)vaddr;
31237 diff --git a/arch/x86/mm/hugetlbpage.c b/arch/x86/mm/hugetlbpage.c
31238 index 9d980d8..6bbfacb 100644
31239 --- a/arch/x86/mm/hugetlbpage.c
31240 +++ b/arch/x86/mm/hugetlbpage.c
31241 @@ -92,23 +92,30 @@ int pmd_huge_support(void)
31242 #ifdef HAVE_ARCH_HUGETLB_UNMAPPED_AREA
31243 static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
31244 unsigned long addr, unsigned long len,
31245 - unsigned long pgoff, unsigned long flags)
31246 + unsigned long pgoff, unsigned long flags, unsigned long offset)
31247 {
31248 struct hstate *h = hstate_file(file);
31249 struct vm_unmapped_area_info info;
31250 -
31251 +
31252 info.flags = 0;
31253 info.length = len;
31254 info.low_limit = TASK_UNMAPPED_BASE;
31255 +
31256 +#ifdef CONFIG_PAX_RANDMMAP
31257 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
31258 + info.low_limit += current->mm->delta_mmap;
31259 +#endif
31260 +
31261 info.high_limit = TASK_SIZE;
31262 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
31263 info.align_offset = 0;
31264 + info.threadstack_offset = offset;
31265 return vm_unmapped_area(&info);
31266 }
31267
31268 static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
31269 unsigned long addr0, unsigned long len,
31270 - unsigned long pgoff, unsigned long flags)
31271 + unsigned long pgoff, unsigned long flags, unsigned long offset)
31272 {
31273 struct hstate *h = hstate_file(file);
31274 struct vm_unmapped_area_info info;
31275 @@ -120,6 +127,7 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
31276 info.high_limit = current->mm->mmap_base;
31277 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
31278 info.align_offset = 0;
31279 + info.threadstack_offset = offset;
31280 addr = vm_unmapped_area(&info);
31281
31282 /*
31283 @@ -132,6 +140,12 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
31284 VM_BUG_ON(addr != -ENOMEM);
31285 info.flags = 0;
31286 info.low_limit = TASK_UNMAPPED_BASE;
31287 +
31288 +#ifdef CONFIG_PAX_RANDMMAP
31289 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
31290 + info.low_limit += current->mm->delta_mmap;
31291 +#endif
31292 +
31293 info.high_limit = TASK_SIZE;
31294 addr = vm_unmapped_area(&info);
31295 }
31296 @@ -146,10 +160,20 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
31297 struct hstate *h = hstate_file(file);
31298 struct mm_struct *mm = current->mm;
31299 struct vm_area_struct *vma;
31300 + unsigned long pax_task_size = TASK_SIZE;
31301 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
31302
31303 if (len & ~huge_page_mask(h))
31304 return -EINVAL;
31305 - if (len > TASK_SIZE)
31306 +
31307 +#ifdef CONFIG_PAX_SEGMEXEC
31308 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
31309 + pax_task_size = SEGMEXEC_TASK_SIZE;
31310 +#endif
31311 +
31312 + pax_task_size -= PAGE_SIZE;
31313 +
31314 + if (len > pax_task_size)
31315 return -ENOMEM;
31316
31317 if (flags & MAP_FIXED) {
31318 @@ -158,19 +182,22 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
31319 return addr;
31320 }
31321
31322 +#ifdef CONFIG_PAX_RANDMMAP
31323 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
31324 +#endif
31325 +
31326 if (addr) {
31327 addr = ALIGN(addr, huge_page_size(h));
31328 vma = find_vma(mm, addr);
31329 - if (TASK_SIZE - len >= addr &&
31330 - (!vma || addr + len <= vma->vm_start))
31331 + if (pax_task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
31332 return addr;
31333 }
31334 if (mm->get_unmapped_area == arch_get_unmapped_area)
31335 return hugetlb_get_unmapped_area_bottomup(file, addr, len,
31336 - pgoff, flags);
31337 + pgoff, flags, offset);
31338 else
31339 return hugetlb_get_unmapped_area_topdown(file, addr, len,
31340 - pgoff, flags);
31341 + pgoff, flags, offset);
31342 }
31343
31344 #endif /*HAVE_ARCH_HUGETLB_UNMAPPED_AREA*/
31345 diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
31346 index 04664cd..dae6e5d 100644
31347 --- a/arch/x86/mm/init.c
31348 +++ b/arch/x86/mm/init.c
31349 @@ -4,6 +4,7 @@
31350 #include <linux/swap.h>
31351 #include <linux/memblock.h>
31352 #include <linux/bootmem.h> /* for max_low_pfn */
31353 +#include <linux/tboot.h>
31354
31355 #include <asm/cacheflush.h>
31356 #include <asm/e820.h>
31357 @@ -17,6 +18,8 @@
31358 #include <asm/proto.h>
31359 #include <asm/dma.h> /* for MAX_DMA_PFN */
31360 #include <asm/microcode.h>
31361 +#include <asm/desc.h>
31362 +#include <asm/bios_ebda.h>
31363
31364 #include "mm_internal.h"
31365
31366 @@ -465,7 +468,18 @@ void __init init_mem_mapping(void)
31367 early_ioremap_page_table_range_init();
31368 #endif
31369
31370 +#ifdef CONFIG_PAX_PER_CPU_PGD
31371 + clone_pgd_range(get_cpu_pgd(0, kernel) + KERNEL_PGD_BOUNDARY,
31372 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
31373 + KERNEL_PGD_PTRS);
31374 + clone_pgd_range(get_cpu_pgd(0, user) + KERNEL_PGD_BOUNDARY,
31375 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
31376 + KERNEL_PGD_PTRS);
31377 + load_cr3(get_cpu_pgd(0, kernel));
31378 +#else
31379 load_cr3(swapper_pg_dir);
31380 +#endif
31381 +
31382 __flush_tlb_all();
31383
31384 early_memtest(0, max_pfn_mapped << PAGE_SHIFT);
31385 @@ -481,10 +495,40 @@ void __init init_mem_mapping(void)
31386 * Access has to be given to non-kernel-ram areas as well, these contain the PCI
31387 * mmio resources as well as potential bios/acpi data regions.
31388 */
31389 +
31390 +#ifdef CONFIG_GRKERNSEC_KMEM
31391 +static unsigned int ebda_start __read_only;
31392 +static unsigned int ebda_end __read_only;
31393 +#endif
31394 +
31395 int devmem_is_allowed(unsigned long pagenr)
31396 {
31397 - if (pagenr < 256)
31398 +#ifdef CONFIG_GRKERNSEC_KMEM
31399 + /* allow BDA */
31400 + if (!pagenr)
31401 return 1;
31402 + /* allow EBDA */
31403 + if (pagenr >= ebda_start && pagenr < ebda_end)
31404 + return 1;
31405 + /* if tboot is in use, allow access to its hardcoded serial log range */
31406 + if (tboot_enabled() && ((0x60000 >> PAGE_SHIFT) <= pagenr) && (pagenr < (0x68000 >> PAGE_SHIFT)))
31407 + return 1;
31408 +#else
31409 + if (!pagenr)
31410 + return 1;
31411 +#ifdef CONFIG_VM86
31412 + if (pagenr < (ISA_START_ADDRESS >> PAGE_SHIFT))
31413 + return 1;
31414 +#endif
31415 +#endif
31416 +
31417 + if ((ISA_START_ADDRESS >> PAGE_SHIFT) <= pagenr && pagenr < (ISA_END_ADDRESS >> PAGE_SHIFT))
31418 + return 1;
31419 +#ifdef CONFIG_GRKERNSEC_KMEM
31420 + /* throw out everything else below 1MB */
31421 + if (pagenr <= 256)
31422 + return 0;
31423 +#endif
31424 if (iomem_is_exclusive(pagenr << PAGE_SHIFT))
31425 return 0;
31426 if (!page_is_ram(pagenr))
31427 @@ -530,8 +574,117 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)
31428 #endif
31429 }
31430
31431 +#ifdef CONFIG_GRKERNSEC_KMEM
31432 +static inline void gr_init_ebda(void)
31433 +{
31434 + unsigned int ebda_addr;
31435 + unsigned int ebda_size = 0;
31436 +
31437 + ebda_addr = get_bios_ebda();
31438 + if (ebda_addr) {
31439 + ebda_size = *(unsigned char *)phys_to_virt(ebda_addr);
31440 + ebda_size <<= 10;
31441 + }
31442 + if (ebda_addr && ebda_size) {
31443 + ebda_start = ebda_addr >> PAGE_SHIFT;
31444 + ebda_end = min((unsigned int)PAGE_ALIGN(ebda_addr + ebda_size), (unsigned int)0xa0000) >> PAGE_SHIFT;
31445 + } else {
31446 + ebda_start = 0x9f000 >> PAGE_SHIFT;
31447 + ebda_end = 0xa0000 >> PAGE_SHIFT;
31448 + }
31449 +}
31450 +#else
31451 +static inline void gr_init_ebda(void) { }
31452 +#endif
31453 +
31454 void free_initmem(void)
31455 {
31456 +#ifdef CONFIG_PAX_KERNEXEC
31457 +#ifdef CONFIG_X86_32
31458 + /* PaX: limit KERNEL_CS to actual size */
31459 + unsigned long addr, limit;
31460 + struct desc_struct d;
31461 + int cpu;
31462 +#else
31463 + pgd_t *pgd;
31464 + pud_t *pud;
31465 + pmd_t *pmd;
31466 + unsigned long addr, end;
31467 +#endif
31468 +#endif
31469 +
31470 + gr_init_ebda();
31471 +
31472 +#ifdef CONFIG_PAX_KERNEXEC
31473 +#ifdef CONFIG_X86_32
31474 + limit = paravirt_enabled() ? ktva_ktla(0xffffffff) : (unsigned long)&_etext;
31475 + limit = (limit - 1UL) >> PAGE_SHIFT;
31476 +
31477 + memset(__LOAD_PHYSICAL_ADDR + PAGE_OFFSET, POISON_FREE_INITMEM, PAGE_SIZE);
31478 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
31479 + pack_descriptor(&d, get_desc_base(&get_cpu_gdt_table(cpu)[GDT_ENTRY_KERNEL_CS]), limit, 0x9B, 0xC);
31480 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEL_CS, &d, DESCTYPE_S);
31481 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEXEC_KERNEL_CS, &d, DESCTYPE_S);
31482 + }
31483 +
31484 + /* PaX: make KERNEL_CS read-only */
31485 + addr = PFN_ALIGN(ktla_ktva((unsigned long)&_text));
31486 + if (!paravirt_enabled())
31487 + set_memory_ro(addr, (PFN_ALIGN(_sdata) - addr) >> PAGE_SHIFT);
31488 +/*
31489 + for (addr = ktla_ktva((unsigned long)&_text); addr < (unsigned long)&_sdata; addr += PMD_SIZE) {
31490 + pgd = pgd_offset_k(addr);
31491 + pud = pud_offset(pgd, addr);
31492 + pmd = pmd_offset(pud, addr);
31493 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
31494 + }
31495 +*/
31496 +#ifdef CONFIG_X86_PAE
31497 + set_memory_nx(PFN_ALIGN(__init_begin), (PFN_ALIGN(__init_end) - PFN_ALIGN(__init_begin)) >> PAGE_SHIFT);
31498 +/*
31499 + for (addr = (unsigned long)&__init_begin; addr < (unsigned long)&__init_end; addr += PMD_SIZE) {
31500 + pgd = pgd_offset_k(addr);
31501 + pud = pud_offset(pgd, addr);
31502 + pmd = pmd_offset(pud, addr);
31503 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
31504 + }
31505 +*/
31506 +#endif
31507 +
31508 +#ifdef CONFIG_MODULES
31509 + set_memory_4k((unsigned long)MODULES_EXEC_VADDR, (MODULES_EXEC_END - MODULES_EXEC_VADDR) >> PAGE_SHIFT);
31510 +#endif
31511 +
31512 +#else
31513 + /* PaX: make kernel code/rodata read-only, rest non-executable */
31514 + for (addr = __START_KERNEL_map; addr < __START_KERNEL_map + KERNEL_IMAGE_SIZE; addr += PMD_SIZE) {
31515 + pgd = pgd_offset_k(addr);
31516 + pud = pud_offset(pgd, addr);
31517 + pmd = pmd_offset(pud, addr);
31518 + if (!pmd_present(*pmd))
31519 + continue;
31520 + if ((unsigned long)_text <= addr && addr < (unsigned long)_sdata)
31521 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
31522 + else
31523 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
31524 + }
31525 +
31526 + addr = (unsigned long)__va(__pa(__START_KERNEL_map));
31527 + end = addr + KERNEL_IMAGE_SIZE;
31528 + for (; addr < end; addr += PMD_SIZE) {
31529 + pgd = pgd_offset_k(addr);
31530 + pud = pud_offset(pgd, addr);
31531 + pmd = pmd_offset(pud, addr);
31532 + if (!pmd_present(*pmd))
31533 + continue;
31534 + if ((unsigned long)__va(__pa(_text)) <= addr && addr < (unsigned long)__va(__pa(_sdata)))
31535 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
31536 + }
31537 +#endif
31538 +
31539 + flush_tlb_all();
31540 +#endif
31541 +
31542 free_init_pages("unused kernel",
31543 (unsigned long)(&__init_begin),
31544 (unsigned long)(&__init_end));
31545 diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
31546 index 4287f1f..3b99c71 100644
31547 --- a/arch/x86/mm/init_32.c
31548 +++ b/arch/x86/mm/init_32.c
31549 @@ -62,33 +62,6 @@ static noinline int do_test_wp_bit(void);
31550 bool __read_mostly __vmalloc_start_set = false;
31551
31552 /*
31553 - * Creates a middle page table and puts a pointer to it in the
31554 - * given global directory entry. This only returns the gd entry
31555 - * in non-PAE compilation mode, since the middle layer is folded.
31556 - */
31557 -static pmd_t * __init one_md_table_init(pgd_t *pgd)
31558 -{
31559 - pud_t *pud;
31560 - pmd_t *pmd_table;
31561 -
31562 -#ifdef CONFIG_X86_PAE
31563 - if (!(pgd_val(*pgd) & _PAGE_PRESENT)) {
31564 - pmd_table = (pmd_t *)alloc_low_page();
31565 - paravirt_alloc_pmd(&init_mm, __pa(pmd_table) >> PAGE_SHIFT);
31566 - set_pgd(pgd, __pgd(__pa(pmd_table) | _PAGE_PRESENT));
31567 - pud = pud_offset(pgd, 0);
31568 - BUG_ON(pmd_table != pmd_offset(pud, 0));
31569 -
31570 - return pmd_table;
31571 - }
31572 -#endif
31573 - pud = pud_offset(pgd, 0);
31574 - pmd_table = pmd_offset(pud, 0);
31575 -
31576 - return pmd_table;
31577 -}
31578 -
31579 -/*
31580 * Create a page table and place a pointer to it in a middle page
31581 * directory entry:
31582 */
31583 @@ -98,13 +71,28 @@ static pte_t * __init one_page_table_init(pmd_t *pmd)
31584 pte_t *page_table = (pte_t *)alloc_low_page();
31585
31586 paravirt_alloc_pte(&init_mm, __pa(page_table) >> PAGE_SHIFT);
31587 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
31588 + set_pmd(pmd, __pmd(__pa(page_table) | _KERNPG_TABLE));
31589 +#else
31590 set_pmd(pmd, __pmd(__pa(page_table) | _PAGE_TABLE));
31591 +#endif
31592 BUG_ON(page_table != pte_offset_kernel(pmd, 0));
31593 }
31594
31595 return pte_offset_kernel(pmd, 0);
31596 }
31597
31598 +static pmd_t * __init one_md_table_init(pgd_t *pgd)
31599 +{
31600 + pud_t *pud;
31601 + pmd_t *pmd_table;
31602 +
31603 + pud = pud_offset(pgd, 0);
31604 + pmd_table = pmd_offset(pud, 0);
31605 +
31606 + return pmd_table;
31607 +}
31608 +
31609 pmd_t * __init populate_extra_pmd(unsigned long vaddr)
31610 {
31611 int pgd_idx = pgd_index(vaddr);
31612 @@ -208,6 +196,7 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
31613 int pgd_idx, pmd_idx;
31614 unsigned long vaddr;
31615 pgd_t *pgd;
31616 + pud_t *pud;
31617 pmd_t *pmd;
31618 pte_t *pte = NULL;
31619 unsigned long count = page_table_range_init_count(start, end);
31620 @@ -222,8 +211,13 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
31621 pgd = pgd_base + pgd_idx;
31622
31623 for ( ; (pgd_idx < PTRS_PER_PGD) && (vaddr != end); pgd++, pgd_idx++) {
31624 - pmd = one_md_table_init(pgd);
31625 - pmd = pmd + pmd_index(vaddr);
31626 + pud = pud_offset(pgd, vaddr);
31627 + pmd = pmd_offset(pud, vaddr);
31628 +
31629 +#ifdef CONFIG_X86_PAE
31630 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
31631 +#endif
31632 +
31633 for (; (pmd_idx < PTRS_PER_PMD) && (vaddr != end);
31634 pmd++, pmd_idx++) {
31635 pte = page_table_kmap_check(one_page_table_init(pmd),
31636 @@ -235,11 +229,20 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
31637 }
31638 }
31639
31640 -static inline int is_kernel_text(unsigned long addr)
31641 +static inline int is_kernel_text(unsigned long start, unsigned long end)
31642 {
31643 - if (addr >= (unsigned long)_text && addr <= (unsigned long)__init_end)
31644 - return 1;
31645 - return 0;
31646 + if ((start > ktla_ktva((unsigned long)_etext) ||
31647 + end <= ktla_ktva((unsigned long)_stext)) &&
31648 + (start > ktla_ktva((unsigned long)_einittext) ||
31649 + end <= ktla_ktva((unsigned long)_sinittext)) &&
31650 +
31651 +#ifdef CONFIG_ACPI_SLEEP
31652 + (start > (unsigned long)__va(acpi_wakeup_address) + 0x4000 || end <= (unsigned long)__va(acpi_wakeup_address)) &&
31653 +#endif
31654 +
31655 + (start > (unsigned long)__va(0xfffff) || end <= (unsigned long)__va(0xc0000)))
31656 + return 0;
31657 + return 1;
31658 }
31659
31660 /*
31661 @@ -256,9 +259,10 @@ kernel_physical_mapping_init(unsigned long start,
31662 unsigned long last_map_addr = end;
31663 unsigned long start_pfn, end_pfn;
31664 pgd_t *pgd_base = swapper_pg_dir;
31665 - int pgd_idx, pmd_idx, pte_ofs;
31666 + unsigned int pgd_idx, pmd_idx, pte_ofs;
31667 unsigned long pfn;
31668 pgd_t *pgd;
31669 + pud_t *pud;
31670 pmd_t *pmd;
31671 pte_t *pte;
31672 unsigned pages_2m, pages_4k;
31673 @@ -291,8 +295,13 @@ repeat:
31674 pfn = start_pfn;
31675 pgd_idx = pgd_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
31676 pgd = pgd_base + pgd_idx;
31677 - for (; pgd_idx < PTRS_PER_PGD; pgd++, pgd_idx++) {
31678 - pmd = one_md_table_init(pgd);
31679 + for (; pgd_idx < PTRS_PER_PGD && pfn < max_low_pfn; pgd++, pgd_idx++) {
31680 + pud = pud_offset(pgd, 0);
31681 + pmd = pmd_offset(pud, 0);
31682 +
31683 +#ifdef CONFIG_X86_PAE
31684 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
31685 +#endif
31686
31687 if (pfn >= end_pfn)
31688 continue;
31689 @@ -304,14 +313,13 @@ repeat:
31690 #endif
31691 for (; pmd_idx < PTRS_PER_PMD && pfn < end_pfn;
31692 pmd++, pmd_idx++) {
31693 - unsigned int addr = pfn * PAGE_SIZE + PAGE_OFFSET;
31694 + unsigned long address = pfn * PAGE_SIZE + PAGE_OFFSET;
31695
31696 /*
31697 * Map with big pages if possible, otherwise
31698 * create normal page tables:
31699 */
31700 if (use_pse) {
31701 - unsigned int addr2;
31702 pgprot_t prot = PAGE_KERNEL_LARGE;
31703 /*
31704 * first pass will use the same initial
31705 @@ -322,11 +330,7 @@ repeat:
31706 _PAGE_PSE);
31707
31708 pfn &= PMD_MASK >> PAGE_SHIFT;
31709 - addr2 = (pfn + PTRS_PER_PTE-1) * PAGE_SIZE +
31710 - PAGE_OFFSET + PAGE_SIZE-1;
31711 -
31712 - if (is_kernel_text(addr) ||
31713 - is_kernel_text(addr2))
31714 + if (is_kernel_text(address, address + PMD_SIZE))
31715 prot = PAGE_KERNEL_LARGE_EXEC;
31716
31717 pages_2m++;
31718 @@ -343,7 +347,7 @@ repeat:
31719 pte_ofs = pte_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
31720 pte += pte_ofs;
31721 for (; pte_ofs < PTRS_PER_PTE && pfn < end_pfn;
31722 - pte++, pfn++, pte_ofs++, addr += PAGE_SIZE) {
31723 + pte++, pfn++, pte_ofs++, address += PAGE_SIZE) {
31724 pgprot_t prot = PAGE_KERNEL;
31725 /*
31726 * first pass will use the same initial
31727 @@ -351,7 +355,7 @@ repeat:
31728 */
31729 pgprot_t init_prot = __pgprot(PTE_IDENT_ATTR);
31730
31731 - if (is_kernel_text(addr))
31732 + if (is_kernel_text(address, address + PAGE_SIZE))
31733 prot = PAGE_KERNEL_EXEC;
31734
31735 pages_4k++;
31736 @@ -474,7 +478,7 @@ void __init native_pagetable_init(void)
31737
31738 pud = pud_offset(pgd, va);
31739 pmd = pmd_offset(pud, va);
31740 - if (!pmd_present(*pmd))
31741 + if (!pmd_present(*pmd)) // PAX TODO || pmd_large(*pmd))
31742 break;
31743
31744 /* should not be large page here */
31745 @@ -532,12 +536,10 @@ void __init early_ioremap_page_table_range_init(void)
31746
31747 static void __init pagetable_init(void)
31748 {
31749 - pgd_t *pgd_base = swapper_pg_dir;
31750 -
31751 - permanent_kmaps_init(pgd_base);
31752 + permanent_kmaps_init(swapper_pg_dir);
31753 }
31754
31755 -pteval_t __supported_pte_mask __read_mostly = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
31756 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
31757 EXPORT_SYMBOL_GPL(__supported_pte_mask);
31758
31759 /* user-defined highmem size */
31760 @@ -787,10 +789,10 @@ void __init mem_init(void)
31761 ((unsigned long)&__init_end -
31762 (unsigned long)&__init_begin) >> 10,
31763
31764 - (unsigned long)&_etext, (unsigned long)&_edata,
31765 - ((unsigned long)&_edata - (unsigned long)&_etext) >> 10,
31766 + (unsigned long)&_sdata, (unsigned long)&_edata,
31767 + ((unsigned long)&_edata - (unsigned long)&_sdata) >> 10,
31768
31769 - (unsigned long)&_text, (unsigned long)&_etext,
31770 + ktla_ktva((unsigned long)&_text), ktla_ktva((unsigned long)&_etext),
31771 ((unsigned long)&_etext - (unsigned long)&_text) >> 10);
31772
31773 /*
31774 @@ -880,6 +882,7 @@ void set_kernel_text_rw(void)
31775 if (!kernel_set_to_readonly)
31776 return;
31777
31778 + start = ktla_ktva(start);
31779 pr_debug("Set kernel text: %lx - %lx for read write\n",
31780 start, start+size);
31781
31782 @@ -894,6 +897,7 @@ void set_kernel_text_ro(void)
31783 if (!kernel_set_to_readonly)
31784 return;
31785
31786 + start = ktla_ktva(start);
31787 pr_debug("Set kernel text: %lx - %lx for read only\n",
31788 start, start+size);
31789
31790 @@ -922,6 +926,7 @@ void mark_rodata_ro(void)
31791 unsigned long start = PFN_ALIGN(_text);
31792 unsigned long size = PFN_ALIGN(_etext) - start;
31793
31794 + start = ktla_ktva(start);
31795 set_pages_ro(virt_to_page(start), size >> PAGE_SHIFT);
31796 printk(KERN_INFO "Write protecting the kernel text: %luk\n",
31797 size >> 10);
31798 diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
31799 index 104d56a..62ba13f1 100644
31800 --- a/arch/x86/mm/init_64.c
31801 +++ b/arch/x86/mm/init_64.c
31802 @@ -151,7 +151,7 @@ early_param("gbpages", parse_direct_gbpages_on);
31803 * around without checking the pgd every time.
31804 */
31805
31806 -pteval_t __supported_pte_mask __read_mostly = ~_PAGE_IOMAP;
31807 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_IOMAP);
31808 EXPORT_SYMBOL_GPL(__supported_pte_mask);
31809
31810 int force_personality32;
31811 @@ -184,12 +184,29 @@ void sync_global_pgds(unsigned long start, unsigned long end)
31812
31813 for (address = start; address <= end; address += PGDIR_SIZE) {
31814 const pgd_t *pgd_ref = pgd_offset_k(address);
31815 +
31816 +#ifdef CONFIG_PAX_PER_CPU_PGD
31817 + unsigned long cpu;
31818 +#else
31819 struct page *page;
31820 +#endif
31821
31822 if (pgd_none(*pgd_ref))
31823 continue;
31824
31825 spin_lock(&pgd_lock);
31826 +
31827 +#ifdef CONFIG_PAX_PER_CPU_PGD
31828 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
31829 + pgd_t *pgd = pgd_offset_cpu(cpu, user, address);
31830 +
31831 + if (pgd_none(*pgd))
31832 + set_pgd(pgd, *pgd_ref);
31833 + else
31834 + BUG_ON(pgd_page_vaddr(*pgd)
31835 + != pgd_page_vaddr(*pgd_ref));
31836 + pgd = pgd_offset_cpu(cpu, kernel, address);
31837 +#else
31838 list_for_each_entry(page, &pgd_list, lru) {
31839 pgd_t *pgd;
31840 spinlock_t *pgt_lock;
31841 @@ -198,6 +215,7 @@ void sync_global_pgds(unsigned long start, unsigned long end)
31842 /* the pgt_lock only for Xen */
31843 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
31844 spin_lock(pgt_lock);
31845 +#endif
31846
31847 if (pgd_none(*pgd))
31848 set_pgd(pgd, *pgd_ref);
31849 @@ -205,7 +223,10 @@ void sync_global_pgds(unsigned long start, unsigned long end)
31850 BUG_ON(pgd_page_vaddr(*pgd)
31851 != pgd_page_vaddr(*pgd_ref));
31852
31853 +#ifndef CONFIG_PAX_PER_CPU_PGD
31854 spin_unlock(pgt_lock);
31855 +#endif
31856 +
31857 }
31858 spin_unlock(&pgd_lock);
31859 }
31860 @@ -238,7 +259,7 @@ static pud_t *fill_pud(pgd_t *pgd, unsigned long vaddr)
31861 {
31862 if (pgd_none(*pgd)) {
31863 pud_t *pud = (pud_t *)spp_getpage();
31864 - pgd_populate(&init_mm, pgd, pud);
31865 + pgd_populate_kernel(&init_mm, pgd, pud);
31866 if (pud != pud_offset(pgd, 0))
31867 printk(KERN_ERR "PAGETABLE BUG #00! %p <-> %p\n",
31868 pud, pud_offset(pgd, 0));
31869 @@ -250,7 +271,7 @@ static pmd_t *fill_pmd(pud_t *pud, unsigned long vaddr)
31870 {
31871 if (pud_none(*pud)) {
31872 pmd_t *pmd = (pmd_t *) spp_getpage();
31873 - pud_populate(&init_mm, pud, pmd);
31874 + pud_populate_kernel(&init_mm, pud, pmd);
31875 if (pmd != pmd_offset(pud, 0))
31876 printk(KERN_ERR "PAGETABLE BUG #01! %p <-> %p\n",
31877 pmd, pmd_offset(pud, 0));
31878 @@ -279,7 +300,9 @@ void set_pte_vaddr_pud(pud_t *pud_page, unsigned long vaddr, pte_t new_pte)
31879 pmd = fill_pmd(pud, vaddr);
31880 pte = fill_pte(pmd, vaddr);
31881
31882 + pax_open_kernel();
31883 set_pte(pte, new_pte);
31884 + pax_close_kernel();
31885
31886 /*
31887 * It's enough to flush this one mapping.
31888 @@ -338,14 +361,12 @@ static void __init __init_extra_mapping(unsigned long phys, unsigned long size,
31889 pgd = pgd_offset_k((unsigned long)__va(phys));
31890 if (pgd_none(*pgd)) {
31891 pud = (pud_t *) spp_getpage();
31892 - set_pgd(pgd, __pgd(__pa(pud) | _KERNPG_TABLE |
31893 - _PAGE_USER));
31894 + set_pgd(pgd, __pgd(__pa(pud) | _PAGE_TABLE));
31895 }
31896 pud = pud_offset(pgd, (unsigned long)__va(phys));
31897 if (pud_none(*pud)) {
31898 pmd = (pmd_t *) spp_getpage();
31899 - set_pud(pud, __pud(__pa(pmd) | _KERNPG_TABLE |
31900 - _PAGE_USER));
31901 + set_pud(pud, __pud(__pa(pmd) | _PAGE_TABLE));
31902 }
31903 pmd = pmd_offset(pud, phys);
31904 BUG_ON(!pmd_none(*pmd));
31905 @@ -586,7 +607,7 @@ phys_pud_init(pud_t *pud_page, unsigned long addr, unsigned long end,
31906 prot);
31907
31908 spin_lock(&init_mm.page_table_lock);
31909 - pud_populate(&init_mm, pud, pmd);
31910 + pud_populate_kernel(&init_mm, pud, pmd);
31911 spin_unlock(&init_mm.page_table_lock);
31912 }
31913 __flush_tlb_all();
31914 @@ -627,7 +648,7 @@ kernel_physical_mapping_init(unsigned long start,
31915 page_size_mask);
31916
31917 spin_lock(&init_mm.page_table_lock);
31918 - pgd_populate(&init_mm, pgd, pud);
31919 + pgd_populate_kernel(&init_mm, pgd, pud);
31920 spin_unlock(&init_mm.page_table_lock);
31921 pgd_changed = true;
31922 }
31923 @@ -1188,8 +1209,8 @@ int kern_addr_valid(unsigned long addr)
31924 static struct vm_area_struct gate_vma = {
31925 .vm_start = VSYSCALL_START,
31926 .vm_end = VSYSCALL_START + (VSYSCALL_MAPPED_PAGES * PAGE_SIZE),
31927 - .vm_page_prot = PAGE_READONLY_EXEC,
31928 - .vm_flags = VM_READ | VM_EXEC
31929 + .vm_page_prot = PAGE_READONLY,
31930 + .vm_flags = VM_READ
31931 };
31932
31933 struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
31934 @@ -1223,7 +1244,7 @@ int in_gate_area_no_mm(unsigned long addr)
31935
31936 const char *arch_vma_name(struct vm_area_struct *vma)
31937 {
31938 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
31939 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
31940 return "[vdso]";
31941 if (vma == &gate_vma)
31942 return "[vsyscall]";
31943 diff --git a/arch/x86/mm/iomap_32.c b/arch/x86/mm/iomap_32.c
31944 index 7b179b4..6bd17777 100644
31945 --- a/arch/x86/mm/iomap_32.c
31946 +++ b/arch/x86/mm/iomap_32.c
31947 @@ -64,7 +64,11 @@ void *kmap_atomic_prot_pfn(unsigned long pfn, pgprot_t prot)
31948 type = kmap_atomic_idx_push();
31949 idx = type + KM_TYPE_NR * smp_processor_id();
31950 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
31951 +
31952 + pax_open_kernel();
31953 set_pte(kmap_pte - idx, pfn_pte(pfn, prot));
31954 + pax_close_kernel();
31955 +
31956 arch_flush_lazy_mmu_mode();
31957
31958 return (void *)vaddr;
31959 diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
31960 index 799580c..72f9fe0 100644
31961 --- a/arch/x86/mm/ioremap.c
31962 +++ b/arch/x86/mm/ioremap.c
31963 @@ -97,7 +97,7 @@ static void __iomem *__ioremap_caller(resource_size_t phys_addr,
31964 for (pfn = phys_addr >> PAGE_SHIFT; pfn <= last_pfn; pfn++) {
31965 int is_ram = page_is_ram(pfn);
31966
31967 - if (is_ram && pfn_valid(pfn) && !PageReserved(pfn_to_page(pfn)))
31968 + if (is_ram && pfn_valid(pfn) && (pfn >= 0x100 || !PageReserved(pfn_to_page(pfn))))
31969 return NULL;
31970 WARN_ON_ONCE(is_ram);
31971 }
31972 @@ -256,7 +256,7 @@ EXPORT_SYMBOL(ioremap_prot);
31973 *
31974 * Caller must ensure there is only one unmapping for the same pointer.
31975 */
31976 -void iounmap(volatile void __iomem *addr)
31977 +void iounmap(const volatile void __iomem *addr)
31978 {
31979 struct vm_struct *p, *o;
31980
31981 @@ -310,6 +310,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
31982
31983 /* If page is RAM, we can use __va. Otherwise ioremap and unmap. */
31984 if (page_is_ram(start >> PAGE_SHIFT))
31985 +#ifdef CONFIG_HIGHMEM
31986 + if ((start >> PAGE_SHIFT) < max_low_pfn)
31987 +#endif
31988 return __va(phys);
31989
31990 addr = (void __force *)ioremap_cache(start, PAGE_SIZE);
31991 @@ -322,6 +325,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
31992 void unxlate_dev_mem_ptr(unsigned long phys, void *addr)
31993 {
31994 if (page_is_ram(phys >> PAGE_SHIFT))
31995 +#ifdef CONFIG_HIGHMEM
31996 + if ((phys >> PAGE_SHIFT) < max_low_pfn)
31997 +#endif
31998 return;
31999
32000 iounmap((void __iomem *)((unsigned long)addr & PAGE_MASK));
32001 @@ -339,7 +345,7 @@ static int __init early_ioremap_debug_setup(char *str)
32002 early_param("early_ioremap_debug", early_ioremap_debug_setup);
32003
32004 static __initdata int after_paging_init;
32005 -static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __page_aligned_bss;
32006 +static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __read_only __aligned(PAGE_SIZE);
32007
32008 static inline pmd_t * __init early_ioremap_pmd(unsigned long addr)
32009 {
32010 @@ -376,8 +382,7 @@ void __init early_ioremap_init(void)
32011 slot_virt[i] = __fix_to_virt(FIX_BTMAP_BEGIN - NR_FIX_BTMAPS*i);
32012
32013 pmd = early_ioremap_pmd(fix_to_virt(FIX_BTMAP_BEGIN));
32014 - memset(bm_pte, 0, sizeof(bm_pte));
32015 - pmd_populate_kernel(&init_mm, pmd, bm_pte);
32016 + pmd_populate_user(&init_mm, pmd, bm_pte);
32017
32018 /*
32019 * The boot-ioremap range spans multiple pmds, for which
32020 diff --git a/arch/x86/mm/kmemcheck/kmemcheck.c b/arch/x86/mm/kmemcheck/kmemcheck.c
32021 index d87dd6d..bf3fa66 100644
32022 --- a/arch/x86/mm/kmemcheck/kmemcheck.c
32023 +++ b/arch/x86/mm/kmemcheck/kmemcheck.c
32024 @@ -622,9 +622,9 @@ bool kmemcheck_fault(struct pt_regs *regs, unsigned long address,
32025 * memory (e.g. tracked pages)? For now, we need this to avoid
32026 * invoking kmemcheck for PnP BIOS calls.
32027 */
32028 - if (regs->flags & X86_VM_MASK)
32029 + if (v8086_mode(regs))
32030 return false;
32031 - if (regs->cs != __KERNEL_CS)
32032 + if (regs->cs != __KERNEL_CS && regs->cs != __KERNEXEC_KERNEL_CS)
32033 return false;
32034
32035 pte = kmemcheck_pte_lookup(address);
32036 diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c
32037 index 25e7e13..1964579 100644
32038 --- a/arch/x86/mm/mmap.c
32039 +++ b/arch/x86/mm/mmap.c
32040 @@ -52,7 +52,7 @@ static unsigned int stack_maxrandom_size(void)
32041 * Leave an at least ~128 MB hole with possible stack randomization.
32042 */
32043 #define MIN_GAP (128*1024*1024UL + stack_maxrandom_size())
32044 -#define MAX_GAP (TASK_SIZE/6*5)
32045 +#define MAX_GAP (pax_task_size/6*5)
32046
32047 static int mmap_is_legacy(void)
32048 {
32049 @@ -82,27 +82,40 @@ static unsigned long mmap_rnd(void)
32050 return rnd << PAGE_SHIFT;
32051 }
32052
32053 -static unsigned long mmap_base(void)
32054 +static unsigned long mmap_base(struct mm_struct *mm)
32055 {
32056 unsigned long gap = rlimit(RLIMIT_STACK);
32057 + unsigned long pax_task_size = TASK_SIZE;
32058 +
32059 +#ifdef CONFIG_PAX_SEGMEXEC
32060 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
32061 + pax_task_size = SEGMEXEC_TASK_SIZE;
32062 +#endif
32063
32064 if (gap < MIN_GAP)
32065 gap = MIN_GAP;
32066 else if (gap > MAX_GAP)
32067 gap = MAX_GAP;
32068
32069 - return PAGE_ALIGN(TASK_SIZE - gap - mmap_rnd());
32070 + return PAGE_ALIGN(pax_task_size - gap - mmap_rnd());
32071 }
32072
32073 /*
32074 * Bottom-up (legacy) layout on X86_32 did not support randomization, X86_64
32075 * does, but not when emulating X86_32
32076 */
32077 -static unsigned long mmap_legacy_base(void)
32078 +static unsigned long mmap_legacy_base(struct mm_struct *mm)
32079 {
32080 - if (mmap_is_ia32())
32081 + if (mmap_is_ia32()) {
32082 +
32083 +#ifdef CONFIG_PAX_SEGMEXEC
32084 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
32085 + return SEGMEXEC_TASK_UNMAPPED_BASE;
32086 + else
32087 +#endif
32088 +
32089 return TASK_UNMAPPED_BASE;
32090 - else
32091 + } else
32092 return TASK_UNMAPPED_BASE + mmap_rnd();
32093 }
32094
32095 @@ -112,8 +125,15 @@ static unsigned long mmap_legacy_base(void)
32096 */
32097 void arch_pick_mmap_layout(struct mm_struct *mm)
32098 {
32099 - mm->mmap_legacy_base = mmap_legacy_base();
32100 - mm->mmap_base = mmap_base();
32101 + mm->mmap_legacy_base = mmap_legacy_base(mm);
32102 + mm->mmap_base = mmap_base(mm);
32103 +
32104 +#ifdef CONFIG_PAX_RANDMMAP
32105 + if (mm->pax_flags & MF_PAX_RANDMMAP) {
32106 + mm->mmap_legacy_base += mm->delta_mmap;
32107 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
32108 + }
32109 +#endif
32110
32111 if (mmap_is_legacy()) {
32112 mm->mmap_base = mm->mmap_legacy_base;
32113 diff --git a/arch/x86/mm/mmio-mod.c b/arch/x86/mm/mmio-mod.c
32114 index 0057a7a..95c7edd 100644
32115 --- a/arch/x86/mm/mmio-mod.c
32116 +++ b/arch/x86/mm/mmio-mod.c
32117 @@ -194,7 +194,7 @@ static void pre(struct kmmio_probe *p, struct pt_regs *regs,
32118 break;
32119 default:
32120 {
32121 - unsigned char *ip = (unsigned char *)instptr;
32122 + unsigned char *ip = (unsigned char *)ktla_ktva(instptr);
32123 my_trace->opcode = MMIO_UNKNOWN_OP;
32124 my_trace->width = 0;
32125 my_trace->value = (*ip) << 16 | *(ip + 1) << 8 |
32126 @@ -234,7 +234,7 @@ static void post(struct kmmio_probe *p, unsigned long condition,
32127 static void ioremap_trace_core(resource_size_t offset, unsigned long size,
32128 void __iomem *addr)
32129 {
32130 - static atomic_t next_id;
32131 + static atomic_unchecked_t next_id;
32132 struct remap_trace *trace = kmalloc(sizeof(*trace), GFP_KERNEL);
32133 /* These are page-unaligned. */
32134 struct mmiotrace_map map = {
32135 @@ -258,7 +258,7 @@ static void ioremap_trace_core(resource_size_t offset, unsigned long size,
32136 .private = trace
32137 },
32138 .phys = offset,
32139 - .id = atomic_inc_return(&next_id)
32140 + .id = atomic_inc_return_unchecked(&next_id)
32141 };
32142 map.map_id = trace->id;
32143
32144 @@ -290,7 +290,7 @@ void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
32145 ioremap_trace_core(offset, size, addr);
32146 }
32147
32148 -static void iounmap_trace_core(volatile void __iomem *addr)
32149 +static void iounmap_trace_core(const volatile void __iomem *addr)
32150 {
32151 struct mmiotrace_map map = {
32152 .phys = 0,
32153 @@ -328,7 +328,7 @@ not_enabled:
32154 }
32155 }
32156
32157 -void mmiotrace_iounmap(volatile void __iomem *addr)
32158 +void mmiotrace_iounmap(const volatile void __iomem *addr)
32159 {
32160 might_sleep();
32161 if (is_enabled()) /* recheck and proper locking in *_core() */
32162 diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
32163 index 8bf93ba..dbcd670 100644
32164 --- a/arch/x86/mm/numa.c
32165 +++ b/arch/x86/mm/numa.c
32166 @@ -474,7 +474,7 @@ static bool __init numa_meminfo_cover_memory(const struct numa_meminfo *mi)
32167 return true;
32168 }
32169
32170 -static int __init numa_register_memblks(struct numa_meminfo *mi)
32171 +static int __init __intentional_overflow(-1) numa_register_memblks(struct numa_meminfo *mi)
32172 {
32173 unsigned long uninitialized_var(pfn_align);
32174 int i, nid;
32175 diff --git a/arch/x86/mm/pageattr-test.c b/arch/x86/mm/pageattr-test.c
32176 index d0b1773..4c3327c 100644
32177 --- a/arch/x86/mm/pageattr-test.c
32178 +++ b/arch/x86/mm/pageattr-test.c
32179 @@ -36,7 +36,7 @@ enum {
32180
32181 static int pte_testbit(pte_t pte)
32182 {
32183 - return pte_flags(pte) & _PAGE_UNUSED1;
32184 + return pte_flags(pte) & _PAGE_CPA_TEST;
32185 }
32186
32187 struct split_state {
32188 diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
32189 index bb32480..75f2f5e 100644
32190 --- a/arch/x86/mm/pageattr.c
32191 +++ b/arch/x86/mm/pageattr.c
32192 @@ -261,7 +261,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
32193 */
32194 #ifdef CONFIG_PCI_BIOS
32195 if (pcibios_enabled && within(pfn, BIOS_BEGIN >> PAGE_SHIFT, BIOS_END >> PAGE_SHIFT))
32196 - pgprot_val(forbidden) |= _PAGE_NX;
32197 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
32198 #endif
32199
32200 /*
32201 @@ -269,9 +269,10 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
32202 * Does not cover __inittext since that is gone later on. On
32203 * 64bit we do not enforce !NX on the low mapping
32204 */
32205 - if (within(address, (unsigned long)_text, (unsigned long)_etext))
32206 - pgprot_val(forbidden) |= _PAGE_NX;
32207 + if (within(address, ktla_ktva((unsigned long)_text), ktla_ktva((unsigned long)_etext)))
32208 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
32209
32210 +#ifdef CONFIG_DEBUG_RODATA
32211 /*
32212 * The .rodata section needs to be read-only. Using the pfn
32213 * catches all aliases.
32214 @@ -279,6 +280,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
32215 if (within(pfn, __pa_symbol(__start_rodata) >> PAGE_SHIFT,
32216 __pa_symbol(__end_rodata) >> PAGE_SHIFT))
32217 pgprot_val(forbidden) |= _PAGE_RW;
32218 +#endif
32219
32220 #if defined(CONFIG_X86_64) && defined(CONFIG_DEBUG_RODATA)
32221 /*
32222 @@ -317,6 +319,13 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
32223 }
32224 #endif
32225
32226 +#ifdef CONFIG_PAX_KERNEXEC
32227 + if (within(pfn, __pa(ktla_ktva((unsigned long)&_text)), __pa((unsigned long)&_sdata))) {
32228 + pgprot_val(forbidden) |= _PAGE_RW;
32229 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
32230 + }
32231 +#endif
32232 +
32233 prot = __pgprot(pgprot_val(prot) & ~pgprot_val(forbidden));
32234
32235 return prot;
32236 @@ -400,23 +409,37 @@ EXPORT_SYMBOL_GPL(slow_virt_to_phys);
32237 static void __set_pmd_pte(pte_t *kpte, unsigned long address, pte_t pte)
32238 {
32239 /* change init_mm */
32240 + pax_open_kernel();
32241 set_pte_atomic(kpte, pte);
32242 +
32243 #ifdef CONFIG_X86_32
32244 if (!SHARED_KERNEL_PMD) {
32245 +
32246 +#ifdef CONFIG_PAX_PER_CPU_PGD
32247 + unsigned long cpu;
32248 +#else
32249 struct page *page;
32250 +#endif
32251
32252 +#ifdef CONFIG_PAX_PER_CPU_PGD
32253 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
32254 + pgd_t *pgd = get_cpu_pgd(cpu, kernel);
32255 +#else
32256 list_for_each_entry(page, &pgd_list, lru) {
32257 - pgd_t *pgd;
32258 + pgd_t *pgd = (pgd_t *)page_address(page);
32259 +#endif
32260 +
32261 pud_t *pud;
32262 pmd_t *pmd;
32263
32264 - pgd = (pgd_t *)page_address(page) + pgd_index(address);
32265 + pgd += pgd_index(address);
32266 pud = pud_offset(pgd, address);
32267 pmd = pmd_offset(pud, address);
32268 set_pte_atomic((pte_t *)pmd, pte);
32269 }
32270 }
32271 #endif
32272 + pax_close_kernel();
32273 }
32274
32275 static int
32276 diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c
32277 index 6574388..87e9bef 100644
32278 --- a/arch/x86/mm/pat.c
32279 +++ b/arch/x86/mm/pat.c
32280 @@ -376,7 +376,7 @@ int free_memtype(u64 start, u64 end)
32281
32282 if (!entry) {
32283 printk(KERN_INFO "%s:%d freeing invalid memtype [mem %#010Lx-%#010Lx]\n",
32284 - current->comm, current->pid, start, end - 1);
32285 + current->comm, task_pid_nr(current), start, end - 1);
32286 return -EINVAL;
32287 }
32288
32289 @@ -506,8 +506,8 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
32290
32291 while (cursor < to) {
32292 if (!devmem_is_allowed(pfn)) {
32293 - printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx]\n",
32294 - current->comm, from, to - 1);
32295 + printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx] (%#010Lx)\n",
32296 + current->comm, from, to - 1, cursor);
32297 return 0;
32298 }
32299 cursor += PAGE_SIZE;
32300 @@ -577,7 +577,7 @@ int kernel_map_sync_memtype(u64 base, unsigned long size, unsigned long flags)
32301 if (ioremap_change_attr((unsigned long)__va(base), id_sz, flags) < 0) {
32302 printk(KERN_INFO "%s:%d ioremap_change_attr failed %s "
32303 "for [mem %#010Lx-%#010Lx]\n",
32304 - current->comm, current->pid,
32305 + current->comm, task_pid_nr(current),
32306 cattr_name(flags),
32307 base, (unsigned long long)(base + size-1));
32308 return -EINVAL;
32309 @@ -612,7 +612,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
32310 flags = lookup_memtype(paddr);
32311 if (want_flags != flags) {
32312 printk(KERN_WARNING "%s:%d map pfn RAM range req %s for [mem %#010Lx-%#010Lx], got %s\n",
32313 - current->comm, current->pid,
32314 + current->comm, task_pid_nr(current),
32315 cattr_name(want_flags),
32316 (unsigned long long)paddr,
32317 (unsigned long long)(paddr + size - 1),
32318 @@ -634,7 +634,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
32319 free_memtype(paddr, paddr + size);
32320 printk(KERN_ERR "%s:%d map pfn expected mapping type %s"
32321 " for [mem %#010Lx-%#010Lx], got %s\n",
32322 - current->comm, current->pid,
32323 + current->comm, task_pid_nr(current),
32324 cattr_name(want_flags),
32325 (unsigned long long)paddr,
32326 (unsigned long long)(paddr + size - 1),
32327 diff --git a/arch/x86/mm/pat_rbtree.c b/arch/x86/mm/pat_rbtree.c
32328 index 415f6c4..d319983 100644
32329 --- a/arch/x86/mm/pat_rbtree.c
32330 +++ b/arch/x86/mm/pat_rbtree.c
32331 @@ -160,7 +160,7 @@ success:
32332
32333 failure:
32334 printk(KERN_INFO "%s:%d conflicting memory types "
32335 - "%Lx-%Lx %s<->%s\n", current->comm, current->pid, start,
32336 + "%Lx-%Lx %s<->%s\n", current->comm, task_pid_nr(current), start,
32337 end, cattr_name(found_type), cattr_name(match->type));
32338 return -EBUSY;
32339 }
32340 diff --git a/arch/x86/mm/pf_in.c b/arch/x86/mm/pf_in.c
32341 index 9f0614d..92ae64a 100644
32342 --- a/arch/x86/mm/pf_in.c
32343 +++ b/arch/x86/mm/pf_in.c
32344 @@ -148,7 +148,7 @@ enum reason_type get_ins_type(unsigned long ins_addr)
32345 int i;
32346 enum reason_type rv = OTHERS;
32347
32348 - p = (unsigned char *)ins_addr;
32349 + p = (unsigned char *)ktla_ktva(ins_addr);
32350 p += skip_prefix(p, &prf);
32351 p += get_opcode(p, &opcode);
32352
32353 @@ -168,7 +168,7 @@ static unsigned int get_ins_reg_width(unsigned long ins_addr)
32354 struct prefix_bits prf;
32355 int i;
32356
32357 - p = (unsigned char *)ins_addr;
32358 + p = (unsigned char *)ktla_ktva(ins_addr);
32359 p += skip_prefix(p, &prf);
32360 p += get_opcode(p, &opcode);
32361
32362 @@ -191,7 +191,7 @@ unsigned int get_ins_mem_width(unsigned long ins_addr)
32363 struct prefix_bits prf;
32364 int i;
32365
32366 - p = (unsigned char *)ins_addr;
32367 + p = (unsigned char *)ktla_ktva(ins_addr);
32368 p += skip_prefix(p, &prf);
32369 p += get_opcode(p, &opcode);
32370
32371 @@ -415,7 +415,7 @@ unsigned long get_ins_reg_val(unsigned long ins_addr, struct pt_regs *regs)
32372 struct prefix_bits prf;
32373 int i;
32374
32375 - p = (unsigned char *)ins_addr;
32376 + p = (unsigned char *)ktla_ktva(ins_addr);
32377 p += skip_prefix(p, &prf);
32378 p += get_opcode(p, &opcode);
32379 for (i = 0; i < ARRAY_SIZE(reg_rop); i++)
32380 @@ -470,7 +470,7 @@ unsigned long get_ins_imm_val(unsigned long ins_addr)
32381 struct prefix_bits prf;
32382 int i;
32383
32384 - p = (unsigned char *)ins_addr;
32385 + p = (unsigned char *)ktla_ktva(ins_addr);
32386 p += skip_prefix(p, &prf);
32387 p += get_opcode(p, &opcode);
32388 for (i = 0; i < ARRAY_SIZE(imm_wop); i++)
32389 diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
32390 index dfa537a..fd45c64 100644
32391 --- a/arch/x86/mm/pgtable.c
32392 +++ b/arch/x86/mm/pgtable.c
32393 @@ -91,10 +91,67 @@ static inline void pgd_list_del(pgd_t *pgd)
32394 list_del(&page->lru);
32395 }
32396
32397 -#define UNSHARED_PTRS_PER_PGD \
32398 - (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
32399 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
32400 +pgdval_t clone_pgd_mask __read_only = ~_PAGE_PRESENT;
32401
32402 +void __shadow_user_pgds(pgd_t *dst, const pgd_t *src)
32403 +{
32404 + unsigned int count = USER_PGD_PTRS;
32405
32406 + if (!pax_user_shadow_base)
32407 + return;
32408 +
32409 + while (count--)
32410 + *dst++ = __pgd((pgd_val(*src++) | (_PAGE_NX & __supported_pte_mask)) & ~_PAGE_USER);
32411 +}
32412 +#endif
32413 +
32414 +#ifdef CONFIG_PAX_PER_CPU_PGD
32415 +void __clone_user_pgds(pgd_t *dst, const pgd_t *src)
32416 +{
32417 + unsigned int count = USER_PGD_PTRS;
32418 +
32419 + while (count--) {
32420 + pgd_t pgd;
32421 +
32422 +#ifdef CONFIG_X86_64
32423 + pgd = __pgd(pgd_val(*src++) | _PAGE_USER);
32424 +#else
32425 + pgd = *src++;
32426 +#endif
32427 +
32428 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
32429 + pgd = __pgd(pgd_val(pgd) & clone_pgd_mask);
32430 +#endif
32431 +
32432 + *dst++ = pgd;
32433 + }
32434 +
32435 +}
32436 +#endif
32437 +
32438 +#ifdef CONFIG_X86_64
32439 +#define pxd_t pud_t
32440 +#define pyd_t pgd_t
32441 +#define paravirt_release_pxd(pfn) paravirt_release_pud(pfn)
32442 +#define pxd_free(mm, pud) pud_free((mm), (pud))
32443 +#define pyd_populate(mm, pgd, pud) pgd_populate((mm), (pgd), (pud))
32444 +#define pyd_offset(mm, address) pgd_offset((mm), (address))
32445 +#define PYD_SIZE PGDIR_SIZE
32446 +#else
32447 +#define pxd_t pmd_t
32448 +#define pyd_t pud_t
32449 +#define paravirt_release_pxd(pfn) paravirt_release_pmd(pfn)
32450 +#define pxd_free(mm, pud) pmd_free((mm), (pud))
32451 +#define pyd_populate(mm, pgd, pud) pud_populate((mm), (pgd), (pud))
32452 +#define pyd_offset(mm, address) pud_offset((mm), (address))
32453 +#define PYD_SIZE PUD_SIZE
32454 +#endif
32455 +
32456 +#ifdef CONFIG_PAX_PER_CPU_PGD
32457 +static inline void pgd_ctor(struct mm_struct *mm, pgd_t *pgd) {}
32458 +static inline void pgd_dtor(pgd_t *pgd) {}
32459 +#else
32460 static void pgd_set_mm(pgd_t *pgd, struct mm_struct *mm)
32461 {
32462 BUILD_BUG_ON(sizeof(virt_to_page(pgd)->index) < sizeof(mm));
32463 @@ -135,6 +192,7 @@ static void pgd_dtor(pgd_t *pgd)
32464 pgd_list_del(pgd);
32465 spin_unlock(&pgd_lock);
32466 }
32467 +#endif
32468
32469 /*
32470 * List of all pgd's needed for non-PAE so it can invalidate entries
32471 @@ -147,7 +205,7 @@ static void pgd_dtor(pgd_t *pgd)
32472 * -- nyc
32473 */
32474
32475 -#ifdef CONFIG_X86_PAE
32476 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
32477 /*
32478 * In PAE mode, we need to do a cr3 reload (=tlb flush) when
32479 * updating the top-level pagetable entries to guarantee the
32480 @@ -159,7 +217,7 @@ static void pgd_dtor(pgd_t *pgd)
32481 * not shared between pagetables (!SHARED_KERNEL_PMDS), we allocate
32482 * and initialize the kernel pmds here.
32483 */
32484 -#define PREALLOCATED_PMDS UNSHARED_PTRS_PER_PGD
32485 +#define PREALLOCATED_PXDS (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
32486
32487 void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
32488 {
32489 @@ -177,36 +235,38 @@ void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
32490 */
32491 flush_tlb_mm(mm);
32492 }
32493 +#elif defined(CONFIG_X86_64) && defined(CONFIG_PAX_PER_CPU_PGD)
32494 +#define PREALLOCATED_PXDS USER_PGD_PTRS
32495 #else /* !CONFIG_X86_PAE */
32496
32497 /* No need to prepopulate any pagetable entries in non-PAE modes. */
32498 -#define PREALLOCATED_PMDS 0
32499 +#define PREALLOCATED_PXDS 0
32500
32501 #endif /* CONFIG_X86_PAE */
32502
32503 -static void free_pmds(pmd_t *pmds[])
32504 +static void free_pxds(pxd_t *pxds[])
32505 {
32506 int i;
32507
32508 - for(i = 0; i < PREALLOCATED_PMDS; i++)
32509 - if (pmds[i])
32510 - free_page((unsigned long)pmds[i]);
32511 + for(i = 0; i < PREALLOCATED_PXDS; i++)
32512 + if (pxds[i])
32513 + free_page((unsigned long)pxds[i]);
32514 }
32515
32516 -static int preallocate_pmds(pmd_t *pmds[])
32517 +static int preallocate_pxds(pxd_t *pxds[])
32518 {
32519 int i;
32520 bool failed = false;
32521
32522 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
32523 - pmd_t *pmd = (pmd_t *)__get_free_page(PGALLOC_GFP);
32524 - if (pmd == NULL)
32525 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
32526 + pxd_t *pxd = (pxd_t *)__get_free_page(PGALLOC_GFP);
32527 + if (pxd == NULL)
32528 failed = true;
32529 - pmds[i] = pmd;
32530 + pxds[i] = pxd;
32531 }
32532
32533 if (failed) {
32534 - free_pmds(pmds);
32535 + free_pxds(pxds);
32536 return -ENOMEM;
32537 }
32538
32539 @@ -219,49 +279,52 @@ static int preallocate_pmds(pmd_t *pmds[])
32540 * preallocate which never got a corresponding vma will need to be
32541 * freed manually.
32542 */
32543 -static void pgd_mop_up_pmds(struct mm_struct *mm, pgd_t *pgdp)
32544 +static void pgd_mop_up_pxds(struct mm_struct *mm, pgd_t *pgdp)
32545 {
32546 int i;
32547
32548 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
32549 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
32550 pgd_t pgd = pgdp[i];
32551
32552 if (pgd_val(pgd) != 0) {
32553 - pmd_t *pmd = (pmd_t *)pgd_page_vaddr(pgd);
32554 + pxd_t *pxd = (pxd_t *)pgd_page_vaddr(pgd);
32555
32556 - pgdp[i] = native_make_pgd(0);
32557 + set_pgd(pgdp + i, native_make_pgd(0));
32558
32559 - paravirt_release_pmd(pgd_val(pgd) >> PAGE_SHIFT);
32560 - pmd_free(mm, pmd);
32561 + paravirt_release_pxd(pgd_val(pgd) >> PAGE_SHIFT);
32562 + pxd_free(mm, pxd);
32563 }
32564 }
32565 }
32566
32567 -static void pgd_prepopulate_pmd(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmds[])
32568 +static void pgd_prepopulate_pxd(struct mm_struct *mm, pgd_t *pgd, pxd_t *pxds[])
32569 {
32570 - pud_t *pud;
32571 + pyd_t *pyd;
32572 int i;
32573
32574 - if (PREALLOCATED_PMDS == 0) /* Work around gcc-3.4.x bug */
32575 + if (PREALLOCATED_PXDS == 0) /* Work around gcc-3.4.x bug */
32576 return;
32577
32578 - pud = pud_offset(pgd, 0);
32579 -
32580 - for (i = 0; i < PREALLOCATED_PMDS; i++, pud++) {
32581 - pmd_t *pmd = pmds[i];
32582 +#ifdef CONFIG_X86_64
32583 + pyd = pyd_offset(mm, 0L);
32584 +#else
32585 + pyd = pyd_offset(pgd, 0L);
32586 +#endif
32587
32588 + for (i = 0; i < PREALLOCATED_PXDS; i++, pyd++) {
32589 + pxd_t *pxd = pxds[i];
32590 if (i >= KERNEL_PGD_BOUNDARY)
32591 - memcpy(pmd, (pmd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
32592 - sizeof(pmd_t) * PTRS_PER_PMD);
32593 + memcpy(pxd, (pxd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
32594 + sizeof(pxd_t) * PTRS_PER_PMD);
32595
32596 - pud_populate(mm, pud, pmd);
32597 + pyd_populate(mm, pyd, pxd);
32598 }
32599 }
32600
32601 pgd_t *pgd_alloc(struct mm_struct *mm)
32602 {
32603 pgd_t *pgd;
32604 - pmd_t *pmds[PREALLOCATED_PMDS];
32605 + pxd_t *pxds[PREALLOCATED_PXDS];
32606
32607 pgd = (pgd_t *)__get_free_page(PGALLOC_GFP);
32608
32609 @@ -270,11 +333,11 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
32610
32611 mm->pgd = pgd;
32612
32613 - if (preallocate_pmds(pmds) != 0)
32614 + if (preallocate_pxds(pxds) != 0)
32615 goto out_free_pgd;
32616
32617 if (paravirt_pgd_alloc(mm) != 0)
32618 - goto out_free_pmds;
32619 + goto out_free_pxds;
32620
32621 /*
32622 * Make sure that pre-populating the pmds is atomic with
32623 @@ -284,14 +347,14 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
32624 spin_lock(&pgd_lock);
32625
32626 pgd_ctor(mm, pgd);
32627 - pgd_prepopulate_pmd(mm, pgd, pmds);
32628 + pgd_prepopulate_pxd(mm, pgd, pxds);
32629
32630 spin_unlock(&pgd_lock);
32631
32632 return pgd;
32633
32634 -out_free_pmds:
32635 - free_pmds(pmds);
32636 +out_free_pxds:
32637 + free_pxds(pxds);
32638 out_free_pgd:
32639 free_page((unsigned long)pgd);
32640 out:
32641 @@ -300,7 +363,7 @@ out:
32642
32643 void pgd_free(struct mm_struct *mm, pgd_t *pgd)
32644 {
32645 - pgd_mop_up_pmds(mm, pgd);
32646 + pgd_mop_up_pxds(mm, pgd);
32647 pgd_dtor(pgd);
32648 paravirt_pgd_free(mm, pgd);
32649 free_page((unsigned long)pgd);
32650 diff --git a/arch/x86/mm/pgtable_32.c b/arch/x86/mm/pgtable_32.c
32651 index a69bcb8..19068ab 100644
32652 --- a/arch/x86/mm/pgtable_32.c
32653 +++ b/arch/x86/mm/pgtable_32.c
32654 @@ -47,10 +47,13 @@ void set_pte_vaddr(unsigned long vaddr, pte_t pteval)
32655 return;
32656 }
32657 pte = pte_offset_kernel(pmd, vaddr);
32658 +
32659 + pax_open_kernel();
32660 if (pte_val(pteval))
32661 set_pte_at(&init_mm, vaddr, pte, pteval);
32662 else
32663 pte_clear(&init_mm, vaddr, pte);
32664 + pax_close_kernel();
32665
32666 /*
32667 * It's enough to flush this one mapping.
32668 diff --git a/arch/x86/mm/physaddr.c b/arch/x86/mm/physaddr.c
32669 index e666cbb..61788c45 100644
32670 --- a/arch/x86/mm/physaddr.c
32671 +++ b/arch/x86/mm/physaddr.c
32672 @@ -10,7 +10,7 @@
32673 #ifdef CONFIG_X86_64
32674
32675 #ifdef CONFIG_DEBUG_VIRTUAL
32676 -unsigned long __phys_addr(unsigned long x)
32677 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
32678 {
32679 unsigned long y = x - __START_KERNEL_map;
32680
32681 @@ -67,7 +67,7 @@ EXPORT_SYMBOL(__virt_addr_valid);
32682 #else
32683
32684 #ifdef CONFIG_DEBUG_VIRTUAL
32685 -unsigned long __phys_addr(unsigned long x)
32686 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
32687 {
32688 unsigned long phys_addr = x - PAGE_OFFSET;
32689 /* VMALLOC_* aren't constants */
32690 diff --git a/arch/x86/mm/setup_nx.c b/arch/x86/mm/setup_nx.c
32691 index 90555bf..f5f1828 100644
32692 --- a/arch/x86/mm/setup_nx.c
32693 +++ b/arch/x86/mm/setup_nx.c
32694 @@ -5,8 +5,10 @@
32695 #include <asm/pgtable.h>
32696 #include <asm/proto.h>
32697
32698 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
32699 static int disable_nx;
32700
32701 +#ifndef CONFIG_PAX_PAGEEXEC
32702 /*
32703 * noexec = on|off
32704 *
32705 @@ -28,12 +30,17 @@ static int __init noexec_setup(char *str)
32706 return 0;
32707 }
32708 early_param("noexec", noexec_setup);
32709 +#endif
32710 +
32711 +#endif
32712
32713 void x86_configure_nx(void)
32714 {
32715 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
32716 if (cpu_has_nx && !disable_nx)
32717 __supported_pte_mask |= _PAGE_NX;
32718 else
32719 +#endif
32720 __supported_pte_mask &= ~_PAGE_NX;
32721 }
32722
32723 diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c
32724 index ae699b3..f1b2ad2 100644
32725 --- a/arch/x86/mm/tlb.c
32726 +++ b/arch/x86/mm/tlb.c
32727 @@ -48,7 +48,11 @@ void leave_mm(int cpu)
32728 BUG();
32729 if (cpumask_test_cpu(cpu, mm_cpumask(active_mm))) {
32730 cpumask_clear_cpu(cpu, mm_cpumask(active_mm));
32731 +
32732 +#ifndef CONFIG_PAX_PER_CPU_PGD
32733 load_cr3(swapper_pg_dir);
32734 +#endif
32735 +
32736 }
32737 }
32738 EXPORT_SYMBOL_GPL(leave_mm);
32739 diff --git a/arch/x86/mm/uderef_64.c b/arch/x86/mm/uderef_64.c
32740 new file mode 100644
32741 index 0000000..dace51c
32742 --- /dev/null
32743 +++ b/arch/x86/mm/uderef_64.c
32744 @@ -0,0 +1,37 @@
32745 +#include <linux/mm.h>
32746 +#include <asm/pgtable.h>
32747 +#include <asm/uaccess.h>
32748 +
32749 +#ifdef CONFIG_PAX_MEMORY_UDEREF
32750 +/* PaX: due to the special call convention these functions must
32751 + * - remain leaf functions under all configurations,
32752 + * - never be called directly, only dereferenced from the wrappers.
32753 + */
32754 +void __pax_open_userland(void)
32755 +{
32756 + unsigned int cpu;
32757 +
32758 + if (unlikely(!segment_eq(get_fs(), USER_DS)))
32759 + return;
32760 +
32761 + cpu = raw_get_cpu();
32762 + BUG_ON((read_cr3() & ~PAGE_MASK) != PCID_KERNEL);
32763 + write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER | PCID_NOFLUSH);
32764 + raw_put_cpu_no_resched();
32765 +}
32766 +EXPORT_SYMBOL(__pax_open_userland);
32767 +
32768 +void __pax_close_userland(void)
32769 +{
32770 + unsigned int cpu;
32771 +
32772 + if (unlikely(!segment_eq(get_fs(), USER_DS)))
32773 + return;
32774 +
32775 + cpu = raw_get_cpu();
32776 + BUG_ON((read_cr3() & ~PAGE_MASK) != PCID_USER);
32777 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
32778 + raw_put_cpu_no_resched();
32779 +}
32780 +EXPORT_SYMBOL(__pax_close_userland);
32781 +#endif
32782 diff --git a/arch/x86/net/bpf_jit.S b/arch/x86/net/bpf_jit.S
32783 index 877b9a1..a8ecf42 100644
32784 --- a/arch/x86/net/bpf_jit.S
32785 +++ b/arch/x86/net/bpf_jit.S
32786 @@ -9,6 +9,7 @@
32787 */
32788 #include <linux/linkage.h>
32789 #include <asm/dwarf2.h>
32790 +#include <asm/alternative-asm.h>
32791
32792 /*
32793 * Calling convention :
32794 @@ -35,6 +36,7 @@ sk_load_word_positive_offset:
32795 jle bpf_slow_path_word
32796 mov (SKBDATA,%rsi),%eax
32797 bswap %eax /* ntohl() */
32798 + pax_force_retaddr
32799 ret
32800
32801 sk_load_half:
32802 @@ -52,6 +54,7 @@ sk_load_half_positive_offset:
32803 jle bpf_slow_path_half
32804 movzwl (SKBDATA,%rsi),%eax
32805 rol $8,%ax # ntohs()
32806 + pax_force_retaddr
32807 ret
32808
32809 sk_load_byte:
32810 @@ -66,6 +69,7 @@ sk_load_byte_positive_offset:
32811 cmp %esi,%r9d /* if (offset >= hlen) goto bpf_slow_path_byte */
32812 jle bpf_slow_path_byte
32813 movzbl (SKBDATA,%rsi),%eax
32814 + pax_force_retaddr
32815 ret
32816
32817 /**
32818 @@ -87,6 +91,7 @@ sk_load_byte_msh_positive_offset:
32819 movzbl (SKBDATA,%rsi),%ebx
32820 and $15,%bl
32821 shl $2,%bl
32822 + pax_force_retaddr
32823 ret
32824
32825 /* rsi contains offset and can be scratched */
32826 @@ -109,6 +114,7 @@ bpf_slow_path_word:
32827 js bpf_error
32828 mov -12(%rbp),%eax
32829 bswap %eax
32830 + pax_force_retaddr
32831 ret
32832
32833 bpf_slow_path_half:
32834 @@ -117,12 +123,14 @@ bpf_slow_path_half:
32835 mov -12(%rbp),%ax
32836 rol $8,%ax
32837 movzwl %ax,%eax
32838 + pax_force_retaddr
32839 ret
32840
32841 bpf_slow_path_byte:
32842 bpf_slow_path_common(1)
32843 js bpf_error
32844 movzbl -12(%rbp),%eax
32845 + pax_force_retaddr
32846 ret
32847
32848 bpf_slow_path_byte_msh:
32849 @@ -133,6 +141,7 @@ bpf_slow_path_byte_msh:
32850 and $15,%al
32851 shl $2,%al
32852 xchg %eax,%ebx
32853 + pax_force_retaddr
32854 ret
32855
32856 #define sk_negative_common(SIZE) \
32857 @@ -157,6 +166,7 @@ sk_load_word_negative_offset:
32858 sk_negative_common(4)
32859 mov (%rax), %eax
32860 bswap %eax
32861 + pax_force_retaddr
32862 ret
32863
32864 bpf_slow_path_half_neg:
32865 @@ -168,6 +178,7 @@ sk_load_half_negative_offset:
32866 mov (%rax),%ax
32867 rol $8,%ax
32868 movzwl %ax,%eax
32869 + pax_force_retaddr
32870 ret
32871
32872 bpf_slow_path_byte_neg:
32873 @@ -177,6 +188,7 @@ sk_load_byte_negative_offset:
32874 .globl sk_load_byte_negative_offset
32875 sk_negative_common(1)
32876 movzbl (%rax), %eax
32877 + pax_force_retaddr
32878 ret
32879
32880 bpf_slow_path_byte_msh_neg:
32881 @@ -190,6 +202,7 @@ sk_load_byte_msh_negative_offset:
32882 and $15,%al
32883 shl $2,%al
32884 xchg %eax,%ebx
32885 + pax_force_retaddr
32886 ret
32887
32888 bpf_error:
32889 @@ -197,4 +210,5 @@ bpf_error:
32890 xor %eax,%eax
32891 mov -8(%rbp),%rbx
32892 leaveq
32893 + pax_force_retaddr
32894 ret
32895 diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
32896 index 26328e8..5f96c25 100644
32897 --- a/arch/x86/net/bpf_jit_comp.c
32898 +++ b/arch/x86/net/bpf_jit_comp.c
32899 @@ -50,13 +50,90 @@ static inline u8 *emit_code(u8 *ptr, u32 bytes, unsigned int len)
32900 return ptr + len;
32901 }
32902
32903 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32904 +#define MAX_INSTR_CODE_SIZE 96
32905 +#else
32906 +#define MAX_INSTR_CODE_SIZE 64
32907 +#endif
32908 +
32909 #define EMIT(bytes, len) do { prog = emit_code(prog, bytes, len); } while (0)
32910
32911 #define EMIT1(b1) EMIT(b1, 1)
32912 #define EMIT2(b1, b2) EMIT((b1) + ((b2) << 8), 2)
32913 #define EMIT3(b1, b2, b3) EMIT((b1) + ((b2) << 8) + ((b3) << 16), 3)
32914 #define EMIT4(b1, b2, b3, b4) EMIT((b1) + ((b2) << 8) + ((b3) << 16) + ((b4) << 24), 4)
32915 +
32916 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32917 +/* original constant will appear in ecx */
32918 +#define DILUTE_CONST_SEQUENCE(_off, _key) \
32919 +do { \
32920 + /* mov ecx, randkey */ \
32921 + EMIT1(0xb9); \
32922 + EMIT(_key, 4); \
32923 + /* xor ecx, randkey ^ off */ \
32924 + EMIT2(0x81, 0xf1); \
32925 + EMIT((_key) ^ (_off), 4); \
32926 +} while (0)
32927 +
32928 +#define EMIT1_off32(b1, _off) \
32929 +do { \
32930 + switch (b1) { \
32931 + case 0x05: /* add eax, imm32 */ \
32932 + case 0x2d: /* sub eax, imm32 */ \
32933 + case 0x25: /* and eax, imm32 */ \
32934 + case 0x0d: /* or eax, imm32 */ \
32935 + case 0xb8: /* mov eax, imm32 */ \
32936 + case 0x35: /* xor eax, imm32 */ \
32937 + case 0x3d: /* cmp eax, imm32 */ \
32938 + case 0xa9: /* test eax, imm32 */ \
32939 + DILUTE_CONST_SEQUENCE(_off, randkey); \
32940 + EMIT2((b1) - 4, 0xc8); /* convert imm instruction to eax, ecx */\
32941 + break; \
32942 + case 0xbb: /* mov ebx, imm32 */ \
32943 + DILUTE_CONST_SEQUENCE(_off, randkey); \
32944 + /* mov ebx, ecx */ \
32945 + EMIT2(0x89, 0xcb); \
32946 + break; \
32947 + case 0xbe: /* mov esi, imm32 */ \
32948 + DILUTE_CONST_SEQUENCE(_off, randkey); \
32949 + /* mov esi, ecx */ \
32950 + EMIT2(0x89, 0xce); \
32951 + break; \
32952 + case 0xe8: /* call rel imm32, always to known funcs */ \
32953 + EMIT1(b1); \
32954 + EMIT(_off, 4); \
32955 + break; \
32956 + case 0xe9: /* jmp rel imm32 */ \
32957 + EMIT1(b1); \
32958 + EMIT(_off, 4); \
32959 + /* prevent fall-through, we're not called if off = 0 */ \
32960 + EMIT(0xcccccccc, 4); \
32961 + EMIT(0xcccccccc, 4); \
32962 + break; \
32963 + default: \
32964 + BUILD_BUG(); \
32965 + } \
32966 +} while (0)
32967 +
32968 +#define EMIT2_off32(b1, b2, _off) \
32969 +do { \
32970 + if ((b1) == 0x8d && (b2) == 0xb3) { /* lea esi, [rbx+imm32] */ \
32971 + EMIT2(0x8d, 0xb3); /* lea esi, [rbx+randkey] */ \
32972 + EMIT(randkey, 4); \
32973 + EMIT2(0x8d, 0xb6); /* lea esi, [esi+off-randkey] */ \
32974 + EMIT((_off) - randkey, 4); \
32975 + } else if ((b1) == 0x69 && (b2) == 0xc0) { /* imul eax, imm32 */\
32976 + DILUTE_CONST_SEQUENCE(_off, randkey); \
32977 + /* imul eax, ecx */ \
32978 + EMIT3(0x0f, 0xaf, 0xc1); \
32979 + } else { \
32980 + BUILD_BUG(); \
32981 + } \
32982 +} while (0)
32983 +#else
32984 #define EMIT1_off32(b1, off) do { EMIT1(b1); EMIT(off, 4);} while (0)
32985 +#define EMIT2_off32(b1, b2, off) do { EMIT2(b1, b2); EMIT(off, 4);} while (0)
32986 +#endif
32987
32988 #define CLEAR_A() EMIT2(0x31, 0xc0) /* xor %eax,%eax */
32989 #define CLEAR_X() EMIT2(0x31, 0xdb) /* xor %ebx,%ebx */
32990 @@ -91,6 +168,24 @@ do { \
32991 #define X86_JBE 0x76
32992 #define X86_JA 0x77
32993
32994 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32995 +#define APPEND_FLOW_VERIFY() \
32996 +do { \
32997 + /* mov ecx, randkey */ \
32998 + EMIT1(0xb9); \
32999 + EMIT(randkey, 4); \
33000 + /* cmp ecx, randkey */ \
33001 + EMIT2(0x81, 0xf9); \
33002 + EMIT(randkey, 4); \
33003 + /* jz after 8 int 3s */ \
33004 + EMIT2(0x74, 0x08); \
33005 + EMIT(0xcccccccc, 4); \
33006 + EMIT(0xcccccccc, 4); \
33007 +} while (0)
33008 +#else
33009 +#define APPEND_FLOW_VERIFY() do { } while (0)
33010 +#endif
33011 +
33012 #define EMIT_COND_JMP(op, offset) \
33013 do { \
33014 if (is_near(offset)) \
33015 @@ -98,6 +193,7 @@ do { \
33016 else { \
33017 EMIT2(0x0f, op + 0x10); \
33018 EMIT(offset, 4); /* jxx .+off32 */ \
33019 + APPEND_FLOW_VERIFY(); \
33020 } \
33021 } while (0)
33022
33023 @@ -145,55 +241,54 @@ static int pkt_type_offset(void)
33024 return -1;
33025 }
33026
33027 -struct bpf_binary_header {
33028 - unsigned int pages;
33029 - /* Note : for security reasons, bpf code will follow a randomly
33030 - * sized amount of int3 instructions
33031 - */
33032 - u8 image[];
33033 -};
33034 -
33035 -static struct bpf_binary_header *bpf_alloc_binary(unsigned int proglen,
33036 +/* Note : for security reasons, bpf code will follow a randomly
33037 + * sized amount of int3 instructions
33038 + */
33039 +static u8 *bpf_alloc_binary(unsigned int proglen,
33040 u8 **image_ptr)
33041 {
33042 unsigned int sz, hole;
33043 - struct bpf_binary_header *header;
33044 + u8 *header;
33045
33046 /* Most of BPF filters are really small,
33047 * but if some of them fill a page, allow at least
33048 * 128 extra bytes to insert a random section of int3
33049 */
33050 - sz = round_up(proglen + sizeof(*header) + 128, PAGE_SIZE);
33051 - header = module_alloc(sz);
33052 + sz = round_up(proglen + 128, PAGE_SIZE);
33053 + header = module_alloc_exec(sz);
33054 if (!header)
33055 return NULL;
33056
33057 + pax_open_kernel();
33058 memset(header, 0xcc, sz); /* fill whole space with int3 instructions */
33059 + pax_close_kernel();
33060
33061 - header->pages = sz / PAGE_SIZE;
33062 - hole = sz - (proglen + sizeof(*header));
33063 + hole = PAGE_SIZE - (proglen & ~PAGE_MASK);
33064
33065 /* insert a random number of int3 instructions before BPF code */
33066 - *image_ptr = &header->image[prandom_u32() % hole];
33067 + *image_ptr = &header[prandom_u32() % hole];
33068 return header;
33069 }
33070
33071 void bpf_jit_compile(struct sk_filter *fp)
33072 {
33073 - u8 temp[64];
33074 + u8 temp[MAX_INSTR_CODE_SIZE];
33075 u8 *prog;
33076 unsigned int proglen, oldproglen = 0;
33077 int ilen, i;
33078 int t_offset, f_offset;
33079 u8 t_op, f_op, seen = 0, pass;
33080 u8 *image = NULL;
33081 - struct bpf_binary_header *header = NULL;
33082 + u8 *header = NULL;
33083 u8 *func;
33084 int pc_ret0 = -1; /* bpf index of first RET #0 instruction (if any) */
33085 unsigned int cleanup_addr; /* epilogue code offset */
33086 unsigned int *addrs;
33087 const struct sock_filter *filter = fp->insns;
33088 int flen = fp->len;
33089 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
33090 + unsigned int randkey;
33091 +#endif
33092
33093 if (!bpf_jit_enable)
33094 return;
33095 @@ -202,11 +297,15 @@ void bpf_jit_compile(struct sk_filter *fp)
33096 if (addrs == NULL)
33097 return;
33098
33099 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
33100 + randkey = get_random_int();
33101 +#endif
33102 +
33103 /* Before first pass, make a rough estimation of addrs[]
33104 - * each bpf instruction is translated to less than 64 bytes
33105 + * each bpf instruction is translated to less than MAX_INSTR_CODE_SIZE bytes
33106 */
33107 for (proglen = 0, i = 0; i < flen; i++) {
33108 - proglen += 64;
33109 + proglen += MAX_INSTR_CODE_SIZE;
33110 addrs[i] = proglen;
33111 }
33112 cleanup_addr = proglen; /* epilogue address */
33113 @@ -317,10 +416,8 @@ void bpf_jit_compile(struct sk_filter *fp)
33114 case BPF_S_ALU_MUL_K: /* A *= K */
33115 if (is_imm8(K))
33116 EMIT3(0x6b, 0xc0, K); /* imul imm8,%eax,%eax */
33117 - else {
33118 - EMIT2(0x69, 0xc0); /* imul imm32,%eax */
33119 - EMIT(K, 4);
33120 - }
33121 + else
33122 + EMIT2_off32(0x69, 0xc0, K); /* imul imm32,%eax */
33123 break;
33124 case BPF_S_ALU_DIV_X: /* A /= X; */
33125 seen |= SEEN_XREG;
33126 @@ -360,13 +457,23 @@ void bpf_jit_compile(struct sk_filter *fp)
33127 break;
33128 case BPF_S_ALU_MOD_K: /* A %= K; */
33129 EMIT2(0x31, 0xd2); /* xor %edx,%edx */
33130 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
33131 + DILUTE_CONST_SEQUENCE(K, randkey);
33132 +#else
33133 EMIT1(0xb9);EMIT(K, 4); /* mov imm32,%ecx */
33134 +#endif
33135 EMIT2(0xf7, 0xf1); /* div %ecx */
33136 EMIT2(0x89, 0xd0); /* mov %edx,%eax */
33137 break;
33138 case BPF_S_ALU_DIV_K: /* A = reciprocal_divide(A, K); */
33139 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
33140 + DILUTE_CONST_SEQUENCE(K, randkey);
33141 + // imul rax, rcx
33142 + EMIT4(0x48, 0x0f, 0xaf, 0xc1);
33143 +#else
33144 EMIT3(0x48, 0x69, 0xc0); /* imul imm32,%rax,%rax */
33145 EMIT(K, 4);
33146 +#endif
33147 EMIT4(0x48, 0xc1, 0xe8, 0x20); /* shr $0x20,%rax */
33148 break;
33149 case BPF_S_ALU_AND_X:
33150 @@ -637,8 +744,7 @@ common_load_ind: seen |= SEEN_DATAREF | SEEN_XREG;
33151 if (is_imm8(K)) {
33152 EMIT3(0x8d, 0x73, K); /* lea imm8(%rbx), %esi */
33153 } else {
33154 - EMIT2(0x8d, 0xb3); /* lea imm32(%rbx),%esi */
33155 - EMIT(K, 4);
33156 + EMIT2_off32(0x8d, 0xb3, K); /* lea imm32(%rbx),%esi */
33157 }
33158 } else {
33159 EMIT2(0x89,0xde); /* mov %ebx,%esi */
33160 @@ -728,10 +834,12 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
33161 if (unlikely(proglen + ilen > oldproglen)) {
33162 pr_err("bpb_jit_compile fatal error\n");
33163 kfree(addrs);
33164 - module_free(NULL, header);
33165 + module_free_exec(NULL, image);
33166 return;
33167 }
33168 + pax_open_kernel();
33169 memcpy(image + proglen, temp, ilen);
33170 + pax_close_kernel();
33171 }
33172 proglen += ilen;
33173 addrs[i] = proglen;
33174 @@ -764,7 +872,6 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
33175
33176 if (image) {
33177 bpf_flush_icache(header, image + proglen);
33178 - set_memory_ro((unsigned long)header, header->pages);
33179 fp->bpf_func = (void *)image;
33180 }
33181 out:
33182 @@ -776,10 +883,9 @@ static void bpf_jit_free_deferred(struct work_struct *work)
33183 {
33184 struct sk_filter *fp = container_of(work, struct sk_filter, work);
33185 unsigned long addr = (unsigned long)fp->bpf_func & PAGE_MASK;
33186 - struct bpf_binary_header *header = (void *)addr;
33187
33188 - set_memory_rw(addr, header->pages);
33189 - module_free(NULL, header);
33190 + set_memory_rw(addr, 1);
33191 + module_free_exec(NULL, (void *)addr);
33192 kfree(fp);
33193 }
33194
33195 diff --git a/arch/x86/oprofile/backtrace.c b/arch/x86/oprofile/backtrace.c
33196 index d6aa6e8..266395a 100644
33197 --- a/arch/x86/oprofile/backtrace.c
33198 +++ b/arch/x86/oprofile/backtrace.c
33199 @@ -46,11 +46,11 @@ dump_user_backtrace_32(struct stack_frame_ia32 *head)
33200 struct stack_frame_ia32 *fp;
33201 unsigned long bytes;
33202
33203 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
33204 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
33205 if (bytes != sizeof(bufhead))
33206 return NULL;
33207
33208 - fp = (struct stack_frame_ia32 *) compat_ptr(bufhead[0].next_frame);
33209 + fp = (struct stack_frame_ia32 __force_kernel *) compat_ptr(bufhead[0].next_frame);
33210
33211 oprofile_add_trace(bufhead[0].return_address);
33212
33213 @@ -92,7 +92,7 @@ static struct stack_frame *dump_user_backtrace(struct stack_frame *head)
33214 struct stack_frame bufhead[2];
33215 unsigned long bytes;
33216
33217 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
33218 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
33219 if (bytes != sizeof(bufhead))
33220 return NULL;
33221
33222 @@ -111,7 +111,7 @@ x86_backtrace(struct pt_regs * const regs, unsigned int depth)
33223 {
33224 struct stack_frame *head = (struct stack_frame *)frame_pointer(regs);
33225
33226 - if (!user_mode_vm(regs)) {
33227 + if (!user_mode(regs)) {
33228 unsigned long stack = kernel_stack_pointer(regs);
33229 if (depth)
33230 dump_trace(NULL, regs, (unsigned long *)stack, 0,
33231 diff --git a/arch/x86/oprofile/nmi_int.c b/arch/x86/oprofile/nmi_int.c
33232 index 6890d84..1dad1f1 100644
33233 --- a/arch/x86/oprofile/nmi_int.c
33234 +++ b/arch/x86/oprofile/nmi_int.c
33235 @@ -23,6 +23,7 @@
33236 #include <asm/nmi.h>
33237 #include <asm/msr.h>
33238 #include <asm/apic.h>
33239 +#include <asm/pgtable.h>
33240
33241 #include "op_counter.h"
33242 #include "op_x86_model.h"
33243 @@ -774,8 +775,11 @@ int __init op_nmi_init(struct oprofile_operations *ops)
33244 if (ret)
33245 return ret;
33246
33247 - if (!model->num_virt_counters)
33248 - model->num_virt_counters = model->num_counters;
33249 + if (!model->num_virt_counters) {
33250 + pax_open_kernel();
33251 + *(unsigned int *)&model->num_virt_counters = model->num_counters;
33252 + pax_close_kernel();
33253 + }
33254
33255 mux_init(ops);
33256
33257 diff --git a/arch/x86/oprofile/op_model_amd.c b/arch/x86/oprofile/op_model_amd.c
33258 index 50d86c0..7985318 100644
33259 --- a/arch/x86/oprofile/op_model_amd.c
33260 +++ b/arch/x86/oprofile/op_model_amd.c
33261 @@ -519,9 +519,11 @@ static int op_amd_init(struct oprofile_operations *ops)
33262 num_counters = AMD64_NUM_COUNTERS;
33263 }
33264
33265 - op_amd_spec.num_counters = num_counters;
33266 - op_amd_spec.num_controls = num_counters;
33267 - op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
33268 + pax_open_kernel();
33269 + *(unsigned int *)&op_amd_spec.num_counters = num_counters;
33270 + *(unsigned int *)&op_amd_spec.num_controls = num_counters;
33271 + *(unsigned int *)&op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
33272 + pax_close_kernel();
33273
33274 return 0;
33275 }
33276 diff --git a/arch/x86/oprofile/op_model_ppro.c b/arch/x86/oprofile/op_model_ppro.c
33277 index d90528e..0127e2b 100644
33278 --- a/arch/x86/oprofile/op_model_ppro.c
33279 +++ b/arch/x86/oprofile/op_model_ppro.c
33280 @@ -19,6 +19,7 @@
33281 #include <asm/msr.h>
33282 #include <asm/apic.h>
33283 #include <asm/nmi.h>
33284 +#include <asm/pgtable.h>
33285
33286 #include "op_x86_model.h"
33287 #include "op_counter.h"
33288 @@ -221,8 +222,10 @@ static void arch_perfmon_setup_counters(void)
33289
33290 num_counters = min((int)eax.split.num_counters, OP_MAX_COUNTER);
33291
33292 - op_arch_perfmon_spec.num_counters = num_counters;
33293 - op_arch_perfmon_spec.num_controls = num_counters;
33294 + pax_open_kernel();
33295 + *(unsigned int *)&op_arch_perfmon_spec.num_counters = num_counters;
33296 + *(unsigned int *)&op_arch_perfmon_spec.num_controls = num_counters;
33297 + pax_close_kernel();
33298 }
33299
33300 static int arch_perfmon_init(struct oprofile_operations *ignore)
33301 diff --git a/arch/x86/oprofile/op_x86_model.h b/arch/x86/oprofile/op_x86_model.h
33302 index 71e8a67..6a313bb 100644
33303 --- a/arch/x86/oprofile/op_x86_model.h
33304 +++ b/arch/x86/oprofile/op_x86_model.h
33305 @@ -52,7 +52,7 @@ struct op_x86_model_spec {
33306 void (*switch_ctrl)(struct op_x86_model_spec const *model,
33307 struct op_msrs const * const msrs);
33308 #endif
33309 -};
33310 +} __do_const;
33311
33312 struct op_counter_config;
33313
33314 diff --git a/arch/x86/pci/irq.c b/arch/x86/pci/irq.c
33315 index 372e9b8..e775a6c 100644
33316 --- a/arch/x86/pci/irq.c
33317 +++ b/arch/x86/pci/irq.c
33318 @@ -50,7 +50,7 @@ struct irq_router {
33319 struct irq_router_handler {
33320 u16 vendor;
33321 int (*probe)(struct irq_router *r, struct pci_dev *router, u16 device);
33322 -};
33323 +} __do_const;
33324
33325 int (*pcibios_enable_irq)(struct pci_dev *dev) = pirq_enable_irq;
33326 void (*pcibios_disable_irq)(struct pci_dev *dev) = NULL;
33327 @@ -794,7 +794,7 @@ static __init int pico_router_probe(struct irq_router *r, struct pci_dev *router
33328 return 0;
33329 }
33330
33331 -static __initdata struct irq_router_handler pirq_routers[] = {
33332 +static __initconst const struct irq_router_handler pirq_routers[] = {
33333 { PCI_VENDOR_ID_INTEL, intel_router_probe },
33334 { PCI_VENDOR_ID_AL, ali_router_probe },
33335 { PCI_VENDOR_ID_ITE, ite_router_probe },
33336 @@ -821,7 +821,7 @@ static struct pci_dev *pirq_router_dev;
33337 static void __init pirq_find_router(struct irq_router *r)
33338 {
33339 struct irq_routing_table *rt = pirq_table;
33340 - struct irq_router_handler *h;
33341 + const struct irq_router_handler *h;
33342
33343 #ifdef CONFIG_PCI_BIOS
33344 if (!rt->signature) {
33345 @@ -1094,7 +1094,7 @@ static int __init fix_acer_tm360_irqrouting(const struct dmi_system_id *d)
33346 return 0;
33347 }
33348
33349 -static struct dmi_system_id __initdata pciirq_dmi_table[] = {
33350 +static const struct dmi_system_id __initconst pciirq_dmi_table[] = {
33351 {
33352 .callback = fix_broken_hp_bios_irq9,
33353 .ident = "HP Pavilion N5400 Series Laptop",
33354 diff --git a/arch/x86/pci/mrst.c b/arch/x86/pci/mrst.c
33355 index 903fded..94b0d88 100644
33356 --- a/arch/x86/pci/mrst.c
33357 +++ b/arch/x86/pci/mrst.c
33358 @@ -241,7 +241,9 @@ int __init pci_mrst_init(void)
33359 pr_info("Intel MID platform detected, using MID PCI ops\n");
33360 pci_mmcfg_late_init();
33361 pcibios_enable_irq = mrst_pci_irq_enable;
33362 - pci_root_ops = pci_mrst_ops;
33363 + pax_open_kernel();
33364 + memcpy((void *)&pci_root_ops, &pci_mrst_ops, sizeof(pci_mrst_ops));
33365 + pax_close_kernel();
33366 pci_soc_mode = 1;
33367 /* Continue with standard init */
33368 return 1;
33369 diff --git a/arch/x86/pci/pcbios.c b/arch/x86/pci/pcbios.c
33370 index c77b24a..c979855 100644
33371 --- a/arch/x86/pci/pcbios.c
33372 +++ b/arch/x86/pci/pcbios.c
33373 @@ -79,7 +79,7 @@ union bios32 {
33374 static struct {
33375 unsigned long address;
33376 unsigned short segment;
33377 -} bios32_indirect = { 0, __KERNEL_CS };
33378 +} bios32_indirect __read_only = { 0, __PCIBIOS_CS };
33379
33380 /*
33381 * Returns the entry point for the given service, NULL on error
33382 @@ -92,37 +92,80 @@ static unsigned long bios32_service(unsigned long service)
33383 unsigned long length; /* %ecx */
33384 unsigned long entry; /* %edx */
33385 unsigned long flags;
33386 + struct desc_struct d, *gdt;
33387
33388 local_irq_save(flags);
33389 - __asm__("lcall *(%%edi); cld"
33390 +
33391 + gdt = get_cpu_gdt_table(smp_processor_id());
33392 +
33393 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x9B, 0xC);
33394 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
33395 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x93, 0xC);
33396 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
33397 +
33398 + __asm__("movw %w7, %%ds; lcall *(%%edi); push %%ss; pop %%ds; cld"
33399 : "=a" (return_code),
33400 "=b" (address),
33401 "=c" (length),
33402 "=d" (entry)
33403 : "0" (service),
33404 "1" (0),
33405 - "D" (&bios32_indirect));
33406 + "D" (&bios32_indirect),
33407 + "r"(__PCIBIOS_DS)
33408 + : "memory");
33409 +
33410 + pax_open_kernel();
33411 + gdt[GDT_ENTRY_PCIBIOS_CS].a = 0;
33412 + gdt[GDT_ENTRY_PCIBIOS_CS].b = 0;
33413 + gdt[GDT_ENTRY_PCIBIOS_DS].a = 0;
33414 + gdt[GDT_ENTRY_PCIBIOS_DS].b = 0;
33415 + pax_close_kernel();
33416 +
33417 local_irq_restore(flags);
33418
33419 switch (return_code) {
33420 - case 0:
33421 - return address + entry;
33422 - case 0x80: /* Not present */
33423 - printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
33424 - return 0;
33425 - default: /* Shouldn't happen */
33426 - printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
33427 - service, return_code);
33428 + case 0: {
33429 + int cpu;
33430 + unsigned char flags;
33431 +
33432 + printk(KERN_INFO "bios32_service: base:%08lx length:%08lx entry:%08lx\n", address, length, entry);
33433 + if (address >= 0xFFFF0 || length > 0x100000 - address || length <= entry) {
33434 + printk(KERN_WARNING "bios32_service: not valid\n");
33435 return 0;
33436 + }
33437 + address = address + PAGE_OFFSET;
33438 + length += 16UL; /* some BIOSs underreport this... */
33439 + flags = 4;
33440 + if (length >= 64*1024*1024) {
33441 + length >>= PAGE_SHIFT;
33442 + flags |= 8;
33443 + }
33444 +
33445 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
33446 + gdt = get_cpu_gdt_table(cpu);
33447 + pack_descriptor(&d, address, length, 0x9b, flags);
33448 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
33449 + pack_descriptor(&d, address, length, 0x93, flags);
33450 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
33451 + }
33452 + return entry;
33453 + }
33454 + case 0x80: /* Not present */
33455 + printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
33456 + return 0;
33457 + default: /* Shouldn't happen */
33458 + printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
33459 + service, return_code);
33460 + return 0;
33461 }
33462 }
33463
33464 static struct {
33465 unsigned long address;
33466 unsigned short segment;
33467 -} pci_indirect = { 0, __KERNEL_CS };
33468 +} pci_indirect __read_only = { 0, __PCIBIOS_CS };
33469
33470 -static int pci_bios_present;
33471 +static int pci_bios_present __read_only;
33472
33473 static int check_pcibios(void)
33474 {
33475 @@ -131,11 +174,13 @@ static int check_pcibios(void)
33476 unsigned long flags, pcibios_entry;
33477
33478 if ((pcibios_entry = bios32_service(PCI_SERVICE))) {
33479 - pci_indirect.address = pcibios_entry + PAGE_OFFSET;
33480 + pci_indirect.address = pcibios_entry;
33481
33482 local_irq_save(flags);
33483 - __asm__(
33484 - "lcall *(%%edi); cld\n\t"
33485 + __asm__("movw %w6, %%ds\n\t"
33486 + "lcall *%%ss:(%%edi); cld\n\t"
33487 + "push %%ss\n\t"
33488 + "pop %%ds\n\t"
33489 "jc 1f\n\t"
33490 "xor %%ah, %%ah\n"
33491 "1:"
33492 @@ -144,7 +189,8 @@ static int check_pcibios(void)
33493 "=b" (ebx),
33494 "=c" (ecx)
33495 : "1" (PCIBIOS_PCI_BIOS_PRESENT),
33496 - "D" (&pci_indirect)
33497 + "D" (&pci_indirect),
33498 + "r" (__PCIBIOS_DS)
33499 : "memory");
33500 local_irq_restore(flags);
33501
33502 @@ -189,7 +235,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
33503
33504 switch (len) {
33505 case 1:
33506 - __asm__("lcall *(%%esi); cld\n\t"
33507 + __asm__("movw %w6, %%ds\n\t"
33508 + "lcall *%%ss:(%%esi); cld\n\t"
33509 + "push %%ss\n\t"
33510 + "pop %%ds\n\t"
33511 "jc 1f\n\t"
33512 "xor %%ah, %%ah\n"
33513 "1:"
33514 @@ -198,7 +247,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
33515 : "1" (PCIBIOS_READ_CONFIG_BYTE),
33516 "b" (bx),
33517 "D" ((long)reg),
33518 - "S" (&pci_indirect));
33519 + "S" (&pci_indirect),
33520 + "r" (__PCIBIOS_DS));
33521 /*
33522 * Zero-extend the result beyond 8 bits, do not trust the
33523 * BIOS having done it:
33524 @@ -206,7 +256,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
33525 *value &= 0xff;
33526 break;
33527 case 2:
33528 - __asm__("lcall *(%%esi); cld\n\t"
33529 + __asm__("movw %w6, %%ds\n\t"
33530 + "lcall *%%ss:(%%esi); cld\n\t"
33531 + "push %%ss\n\t"
33532 + "pop %%ds\n\t"
33533 "jc 1f\n\t"
33534 "xor %%ah, %%ah\n"
33535 "1:"
33536 @@ -215,7 +268,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
33537 : "1" (PCIBIOS_READ_CONFIG_WORD),
33538 "b" (bx),
33539 "D" ((long)reg),
33540 - "S" (&pci_indirect));
33541 + "S" (&pci_indirect),
33542 + "r" (__PCIBIOS_DS));
33543 /*
33544 * Zero-extend the result beyond 16 bits, do not trust the
33545 * BIOS having done it:
33546 @@ -223,7 +277,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
33547 *value &= 0xffff;
33548 break;
33549 case 4:
33550 - __asm__("lcall *(%%esi); cld\n\t"
33551 + __asm__("movw %w6, %%ds\n\t"
33552 + "lcall *%%ss:(%%esi); cld\n\t"
33553 + "push %%ss\n\t"
33554 + "pop %%ds\n\t"
33555 "jc 1f\n\t"
33556 "xor %%ah, %%ah\n"
33557 "1:"
33558 @@ -232,7 +289,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
33559 : "1" (PCIBIOS_READ_CONFIG_DWORD),
33560 "b" (bx),
33561 "D" ((long)reg),
33562 - "S" (&pci_indirect));
33563 + "S" (&pci_indirect),
33564 + "r" (__PCIBIOS_DS));
33565 break;
33566 }
33567
33568 @@ -256,7 +314,10 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
33569
33570 switch (len) {
33571 case 1:
33572 - __asm__("lcall *(%%esi); cld\n\t"
33573 + __asm__("movw %w6, %%ds\n\t"
33574 + "lcall *%%ss:(%%esi); cld\n\t"
33575 + "push %%ss\n\t"
33576 + "pop %%ds\n\t"
33577 "jc 1f\n\t"
33578 "xor %%ah, %%ah\n"
33579 "1:"
33580 @@ -265,10 +326,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
33581 "c" (value),
33582 "b" (bx),
33583 "D" ((long)reg),
33584 - "S" (&pci_indirect));
33585 + "S" (&pci_indirect),
33586 + "r" (__PCIBIOS_DS));
33587 break;
33588 case 2:
33589 - __asm__("lcall *(%%esi); cld\n\t"
33590 + __asm__("movw %w6, %%ds\n\t"
33591 + "lcall *%%ss:(%%esi); cld\n\t"
33592 + "push %%ss\n\t"
33593 + "pop %%ds\n\t"
33594 "jc 1f\n\t"
33595 "xor %%ah, %%ah\n"
33596 "1:"
33597 @@ -277,10 +342,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
33598 "c" (value),
33599 "b" (bx),
33600 "D" ((long)reg),
33601 - "S" (&pci_indirect));
33602 + "S" (&pci_indirect),
33603 + "r" (__PCIBIOS_DS));
33604 break;
33605 case 4:
33606 - __asm__("lcall *(%%esi); cld\n\t"
33607 + __asm__("movw %w6, %%ds\n\t"
33608 + "lcall *%%ss:(%%esi); cld\n\t"
33609 + "push %%ss\n\t"
33610 + "pop %%ds\n\t"
33611 "jc 1f\n\t"
33612 "xor %%ah, %%ah\n"
33613 "1:"
33614 @@ -289,7 +358,8 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
33615 "c" (value),
33616 "b" (bx),
33617 "D" ((long)reg),
33618 - "S" (&pci_indirect));
33619 + "S" (&pci_indirect),
33620 + "r" (__PCIBIOS_DS));
33621 break;
33622 }
33623
33624 @@ -394,10 +464,13 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
33625
33626 DBG("PCI: Fetching IRQ routing table... ");
33627 __asm__("push %%es\n\t"
33628 + "movw %w8, %%ds\n\t"
33629 "push %%ds\n\t"
33630 "pop %%es\n\t"
33631 - "lcall *(%%esi); cld\n\t"
33632 + "lcall *%%ss:(%%esi); cld\n\t"
33633 "pop %%es\n\t"
33634 + "push %%ss\n\t"
33635 + "pop %%ds\n"
33636 "jc 1f\n\t"
33637 "xor %%ah, %%ah\n"
33638 "1:"
33639 @@ -408,7 +481,8 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
33640 "1" (0),
33641 "D" ((long) &opt),
33642 "S" (&pci_indirect),
33643 - "m" (opt)
33644 + "m" (opt),
33645 + "r" (__PCIBIOS_DS)
33646 : "memory");
33647 DBG("OK ret=%d, size=%d, map=%x\n", ret, opt.size, map);
33648 if (ret & 0xff00)
33649 @@ -432,7 +506,10 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
33650 {
33651 int ret;
33652
33653 - __asm__("lcall *(%%esi); cld\n\t"
33654 + __asm__("movw %w5, %%ds\n\t"
33655 + "lcall *%%ss:(%%esi); cld\n\t"
33656 + "push %%ss\n\t"
33657 + "pop %%ds\n"
33658 "jc 1f\n\t"
33659 "xor %%ah, %%ah\n"
33660 "1:"
33661 @@ -440,7 +517,8 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
33662 : "0" (PCIBIOS_SET_PCI_HW_INT),
33663 "b" ((dev->bus->number << 8) | dev->devfn),
33664 "c" ((irq << 8) | (pin + 10)),
33665 - "S" (&pci_indirect));
33666 + "S" (&pci_indirect),
33667 + "r" (__PCIBIOS_DS));
33668 return !(ret & 0xff00);
33669 }
33670 EXPORT_SYMBOL(pcibios_set_irq_routing);
33671 diff --git a/arch/x86/platform/efi/efi_32.c b/arch/x86/platform/efi/efi_32.c
33672 index 40e4469..d915bf9 100644
33673 --- a/arch/x86/platform/efi/efi_32.c
33674 +++ b/arch/x86/platform/efi/efi_32.c
33675 @@ -44,11 +44,22 @@ void efi_call_phys_prelog(void)
33676 {
33677 struct desc_ptr gdt_descr;
33678
33679 +#ifdef CONFIG_PAX_KERNEXEC
33680 + struct desc_struct d;
33681 +#endif
33682 +
33683 local_irq_save(efi_rt_eflags);
33684
33685 load_cr3(initial_page_table);
33686 __flush_tlb_all();
33687
33688 +#ifdef CONFIG_PAX_KERNEXEC
33689 + pack_descriptor(&d, 0, 0xFFFFF, 0x9B, 0xC);
33690 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
33691 + pack_descriptor(&d, 0, 0xFFFFF, 0x93, 0xC);
33692 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
33693 +#endif
33694 +
33695 gdt_descr.address = __pa(get_cpu_gdt_table(0));
33696 gdt_descr.size = GDT_SIZE - 1;
33697 load_gdt(&gdt_descr);
33698 @@ -58,11 +69,24 @@ void efi_call_phys_epilog(void)
33699 {
33700 struct desc_ptr gdt_descr;
33701
33702 +#ifdef CONFIG_PAX_KERNEXEC
33703 + struct desc_struct d;
33704 +
33705 + memset(&d, 0, sizeof d);
33706 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
33707 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
33708 +#endif
33709 +
33710 gdt_descr.address = (unsigned long)get_cpu_gdt_table(0);
33711 gdt_descr.size = GDT_SIZE - 1;
33712 load_gdt(&gdt_descr);
33713
33714 +#ifdef CONFIG_PAX_PER_CPU_PGD
33715 + load_cr3(get_cpu_pgd(smp_processor_id(), kernel));
33716 +#else
33717 load_cr3(swapper_pg_dir);
33718 +#endif
33719 +
33720 __flush_tlb_all();
33721
33722 local_irq_restore(efi_rt_eflags);
33723 diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c
33724 index 39a0e7f1..872396e 100644
33725 --- a/arch/x86/platform/efi/efi_64.c
33726 +++ b/arch/x86/platform/efi/efi_64.c
33727 @@ -76,6 +76,11 @@ void __init efi_call_phys_prelog(void)
33728 vaddress = (unsigned long)__va(pgd * PGDIR_SIZE);
33729 set_pgd(pgd_offset_k(pgd * PGDIR_SIZE), *pgd_offset_k(vaddress));
33730 }
33731 +
33732 +#ifdef CONFIG_PAX_PER_CPU_PGD
33733 + load_cr3(swapper_pg_dir);
33734 +#endif
33735 +
33736 __flush_tlb_all();
33737 }
33738
33739 @@ -89,6 +94,11 @@ void __init efi_call_phys_epilog(void)
33740 for (pgd = 0; pgd < n_pgds; pgd++)
33741 set_pgd(pgd_offset_k(pgd * PGDIR_SIZE), save_pgd[pgd]);
33742 kfree(save_pgd);
33743 +
33744 +#ifdef CONFIG_PAX_PER_CPU_PGD
33745 + load_cr3(get_cpu_pgd(smp_processor_id(), kernel));
33746 +#endif
33747 +
33748 __flush_tlb_all();
33749 local_irq_restore(efi_flags);
33750 early_code_mapping_set_exec(0);
33751 diff --git a/arch/x86/platform/efi/efi_stub_32.S b/arch/x86/platform/efi/efi_stub_32.S
33752 index fbe66e6..eae5e38 100644
33753 --- a/arch/x86/platform/efi/efi_stub_32.S
33754 +++ b/arch/x86/platform/efi/efi_stub_32.S
33755 @@ -6,7 +6,9 @@
33756 */
33757
33758 #include <linux/linkage.h>
33759 +#include <linux/init.h>
33760 #include <asm/page_types.h>
33761 +#include <asm/segment.h>
33762
33763 /*
33764 * efi_call_phys(void *, ...) is a function with variable parameters.
33765 @@ -20,7 +22,7 @@
33766 * service functions will comply with gcc calling convention, too.
33767 */
33768
33769 -.text
33770 +__INIT
33771 ENTRY(efi_call_phys)
33772 /*
33773 * 0. The function can only be called in Linux kernel. So CS has been
33774 @@ -36,10 +38,24 @@ ENTRY(efi_call_phys)
33775 * The mapping of lower virtual memory has been created in prelog and
33776 * epilog.
33777 */
33778 - movl $1f, %edx
33779 - subl $__PAGE_OFFSET, %edx
33780 - jmp *%edx
33781 +#ifdef CONFIG_PAX_KERNEXEC
33782 + movl $(__KERNEXEC_EFI_DS), %edx
33783 + mov %edx, %ds
33784 + mov %edx, %es
33785 + mov %edx, %ss
33786 + addl $2f,(1f)
33787 + ljmp *(1f)
33788 +
33789 +__INITDATA
33790 +1: .long __LOAD_PHYSICAL_ADDR, __KERNEXEC_EFI_CS
33791 +.previous
33792 +
33793 +2:
33794 + subl $2b,(1b)
33795 +#else
33796 + jmp 1f-__PAGE_OFFSET
33797 1:
33798 +#endif
33799
33800 /*
33801 * 2. Now on the top of stack is the return
33802 @@ -47,14 +63,8 @@ ENTRY(efi_call_phys)
33803 * parameter 2, ..., param n. To make things easy, we save the return
33804 * address of efi_call_phys in a global variable.
33805 */
33806 - popl %edx
33807 - movl %edx, saved_return_addr
33808 - /* get the function pointer into ECX*/
33809 - popl %ecx
33810 - movl %ecx, efi_rt_function_ptr
33811 - movl $2f, %edx
33812 - subl $__PAGE_OFFSET, %edx
33813 - pushl %edx
33814 + popl (saved_return_addr)
33815 + popl (efi_rt_function_ptr)
33816
33817 /*
33818 * 3. Clear PG bit in %CR0.
33819 @@ -73,9 +83,8 @@ ENTRY(efi_call_phys)
33820 /*
33821 * 5. Call the physical function.
33822 */
33823 - jmp *%ecx
33824 + call *(efi_rt_function_ptr-__PAGE_OFFSET)
33825
33826 -2:
33827 /*
33828 * 6. After EFI runtime service returns, control will return to
33829 * following instruction. We'd better readjust stack pointer first.
33830 @@ -88,35 +97,36 @@ ENTRY(efi_call_phys)
33831 movl %cr0, %edx
33832 orl $0x80000000, %edx
33833 movl %edx, %cr0
33834 - jmp 1f
33835 -1:
33836 +
33837 /*
33838 * 8. Now restore the virtual mode from flat mode by
33839 * adding EIP with PAGE_OFFSET.
33840 */
33841 - movl $1f, %edx
33842 - jmp *%edx
33843 +#ifdef CONFIG_PAX_KERNEXEC
33844 + movl $(__KERNEL_DS), %edx
33845 + mov %edx, %ds
33846 + mov %edx, %es
33847 + mov %edx, %ss
33848 + ljmp $(__KERNEL_CS),$1f
33849 +#else
33850 + jmp 1f+__PAGE_OFFSET
33851 +#endif
33852 1:
33853
33854 /*
33855 * 9. Balance the stack. And because EAX contain the return value,
33856 * we'd better not clobber it.
33857 */
33858 - leal efi_rt_function_ptr, %edx
33859 - movl (%edx), %ecx
33860 - pushl %ecx
33861 + pushl (efi_rt_function_ptr)
33862
33863 /*
33864 - * 10. Push the saved return address onto the stack and return.
33865 + * 10. Return to the saved return address.
33866 */
33867 - leal saved_return_addr, %edx
33868 - movl (%edx), %ecx
33869 - pushl %ecx
33870 - ret
33871 + jmpl *(saved_return_addr)
33872 ENDPROC(efi_call_phys)
33873 .previous
33874
33875 -.data
33876 +__INITDATA
33877 saved_return_addr:
33878 .long 0
33879 efi_rt_function_ptr:
33880 diff --git a/arch/x86/platform/efi/efi_stub_64.S b/arch/x86/platform/efi/efi_stub_64.S
33881 index 4c07cca..2c8427d 100644
33882 --- a/arch/x86/platform/efi/efi_stub_64.S
33883 +++ b/arch/x86/platform/efi/efi_stub_64.S
33884 @@ -7,6 +7,7 @@
33885 */
33886
33887 #include <linux/linkage.h>
33888 +#include <asm/alternative-asm.h>
33889
33890 #define SAVE_XMM \
33891 mov %rsp, %rax; \
33892 @@ -40,6 +41,7 @@ ENTRY(efi_call0)
33893 call *%rdi
33894 addq $32, %rsp
33895 RESTORE_XMM
33896 + pax_force_retaddr 0, 1
33897 ret
33898 ENDPROC(efi_call0)
33899
33900 @@ -50,6 +52,7 @@ ENTRY(efi_call1)
33901 call *%rdi
33902 addq $32, %rsp
33903 RESTORE_XMM
33904 + pax_force_retaddr 0, 1
33905 ret
33906 ENDPROC(efi_call1)
33907
33908 @@ -60,6 +63,7 @@ ENTRY(efi_call2)
33909 call *%rdi
33910 addq $32, %rsp
33911 RESTORE_XMM
33912 + pax_force_retaddr 0, 1
33913 ret
33914 ENDPROC(efi_call2)
33915
33916 @@ -71,6 +75,7 @@ ENTRY(efi_call3)
33917 call *%rdi
33918 addq $32, %rsp
33919 RESTORE_XMM
33920 + pax_force_retaddr 0, 1
33921 ret
33922 ENDPROC(efi_call3)
33923
33924 @@ -83,6 +88,7 @@ ENTRY(efi_call4)
33925 call *%rdi
33926 addq $32, %rsp
33927 RESTORE_XMM
33928 + pax_force_retaddr 0, 1
33929 ret
33930 ENDPROC(efi_call4)
33931
33932 @@ -96,6 +102,7 @@ ENTRY(efi_call5)
33933 call *%rdi
33934 addq $48, %rsp
33935 RESTORE_XMM
33936 + pax_force_retaddr 0, 1
33937 ret
33938 ENDPROC(efi_call5)
33939
33940 @@ -112,5 +119,6 @@ ENTRY(efi_call6)
33941 call *%rdi
33942 addq $48, %rsp
33943 RESTORE_XMM
33944 + pax_force_retaddr 0, 1
33945 ret
33946 ENDPROC(efi_call6)
33947 diff --git a/arch/x86/platform/mrst/mrst.c b/arch/x86/platform/mrst/mrst.c
33948 index 3ca5957..7909c18 100644
33949 --- a/arch/x86/platform/mrst/mrst.c
33950 +++ b/arch/x86/platform/mrst/mrst.c
33951 @@ -78,13 +78,15 @@ struct sfi_rtc_table_entry sfi_mrtc_array[SFI_MRTC_MAX];
33952 EXPORT_SYMBOL_GPL(sfi_mrtc_array);
33953 int sfi_mrtc_num;
33954
33955 -static void mrst_power_off(void)
33956 +static __noreturn void mrst_power_off(void)
33957 {
33958 + BUG();
33959 }
33960
33961 -static void mrst_reboot(void)
33962 +static __noreturn void mrst_reboot(void)
33963 {
33964 intel_scu_ipc_simple_command(IPCMSG_COLD_BOOT, 0);
33965 + BUG();
33966 }
33967
33968 /* parse all the mtimer info to a static mtimer array */
33969 diff --git a/arch/x86/platform/olpc/olpc_dt.c b/arch/x86/platform/olpc/olpc_dt.c
33970 index d6ee929..3637cb5 100644
33971 --- a/arch/x86/platform/olpc/olpc_dt.c
33972 +++ b/arch/x86/platform/olpc/olpc_dt.c
33973 @@ -156,7 +156,7 @@ void * __init prom_early_alloc(unsigned long size)
33974 return res;
33975 }
33976
33977 -static struct of_pdt_ops prom_olpc_ops __initdata = {
33978 +static struct of_pdt_ops prom_olpc_ops __initconst = {
33979 .nextprop = olpc_dt_nextprop,
33980 .getproplen = olpc_dt_getproplen,
33981 .getproperty = olpc_dt_getproperty,
33982 diff --git a/arch/x86/power/cpu.c b/arch/x86/power/cpu.c
33983 index 424f4c9..f2a2988 100644
33984 --- a/arch/x86/power/cpu.c
33985 +++ b/arch/x86/power/cpu.c
33986 @@ -137,11 +137,8 @@ static void do_fpu_end(void)
33987 static void fix_processor_context(void)
33988 {
33989 int cpu = smp_processor_id();
33990 - struct tss_struct *t = &per_cpu(init_tss, cpu);
33991 -#ifdef CONFIG_X86_64
33992 - struct desc_struct *desc = get_cpu_gdt_table(cpu);
33993 - tss_desc tss;
33994 -#endif
33995 + struct tss_struct *t = init_tss + cpu;
33996 +
33997 set_tss_desc(cpu, t); /*
33998 * This just modifies memory; should not be
33999 * necessary. But... This is necessary, because
34000 @@ -150,10 +147,6 @@ static void fix_processor_context(void)
34001 */
34002
34003 #ifdef CONFIG_X86_64
34004 - memcpy(&tss, &desc[GDT_ENTRY_TSS], sizeof(tss_desc));
34005 - tss.type = 0x9; /* The available 64-bit TSS (see AMD vol 2, pg 91 */
34006 - write_gdt_entry(desc, GDT_ENTRY_TSS, &tss, DESC_TSS);
34007 -
34008 syscall_init(); /* This sets MSR_*STAR and related */
34009 #endif
34010 load_TR_desc(); /* This does ltr */
34011 diff --git a/arch/x86/realmode/init.c b/arch/x86/realmode/init.c
34012 index a44f457..9140171 100644
34013 --- a/arch/x86/realmode/init.c
34014 +++ b/arch/x86/realmode/init.c
34015 @@ -70,7 +70,13 @@ void __init setup_real_mode(void)
34016 __va(real_mode_header->trampoline_header);
34017
34018 #ifdef CONFIG_X86_32
34019 - trampoline_header->start = __pa_symbol(startup_32_smp);
34020 + trampoline_header->start = __pa_symbol(ktla_ktva(startup_32_smp));
34021 +
34022 +#ifdef CONFIG_PAX_KERNEXEC
34023 + trampoline_header->start -= LOAD_PHYSICAL_ADDR;
34024 +#endif
34025 +
34026 + trampoline_header->boot_cs = __BOOT_CS;
34027 trampoline_header->gdt_limit = __BOOT_DS + 7;
34028 trampoline_header->gdt_base = __pa_symbol(boot_gdt);
34029 #else
34030 @@ -86,7 +92,7 @@ void __init setup_real_mode(void)
34031 *trampoline_cr4_features = read_cr4();
34032
34033 trampoline_pgd = (u64 *) __va(real_mode_header->trampoline_pgd);
34034 - trampoline_pgd[0] = init_level4_pgt[pgd_index(__PAGE_OFFSET)].pgd;
34035 + trampoline_pgd[0] = init_level4_pgt[pgd_index(__PAGE_OFFSET)].pgd & ~_PAGE_NX;
34036 trampoline_pgd[511] = init_level4_pgt[511].pgd;
34037 #endif
34038 }
34039 diff --git a/arch/x86/realmode/rm/Makefile b/arch/x86/realmode/rm/Makefile
34040 index 9cac825..4890b25 100644
34041 --- a/arch/x86/realmode/rm/Makefile
34042 +++ b/arch/x86/realmode/rm/Makefile
34043 @@ -79,5 +79,8 @@ KBUILD_CFLAGS := $(LINUXINCLUDE) -m32 -g -Os -D_SETUP -D__KERNEL__ -D_WAKEUP \
34044 $(call cc-option, -fno-unit-at-a-time)) \
34045 $(call cc-option, -fno-stack-protector) \
34046 $(call cc-option, -mpreferred-stack-boundary=2)
34047 +ifdef CONSTIFY_PLUGIN
34048 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
34049 +endif
34050 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
34051 GCOV_PROFILE := n
34052 diff --git a/arch/x86/realmode/rm/header.S b/arch/x86/realmode/rm/header.S
34053 index a28221d..93c40f1 100644
34054 --- a/arch/x86/realmode/rm/header.S
34055 +++ b/arch/x86/realmode/rm/header.S
34056 @@ -30,7 +30,9 @@ GLOBAL(real_mode_header)
34057 #endif
34058 /* APM/BIOS reboot */
34059 .long pa_machine_real_restart_asm
34060 -#ifdef CONFIG_X86_64
34061 +#ifdef CONFIG_X86_32
34062 + .long __KERNEL_CS
34063 +#else
34064 .long __KERNEL32_CS
34065 #endif
34066 END(real_mode_header)
34067 diff --git a/arch/x86/realmode/rm/trampoline_32.S b/arch/x86/realmode/rm/trampoline_32.S
34068 index c1b2791..f9e31c7 100644
34069 --- a/arch/x86/realmode/rm/trampoline_32.S
34070 +++ b/arch/x86/realmode/rm/trampoline_32.S
34071 @@ -25,6 +25,12 @@
34072 #include <asm/page_types.h>
34073 #include "realmode.h"
34074
34075 +#ifdef CONFIG_PAX_KERNEXEC
34076 +#define ta(X) (X)
34077 +#else
34078 +#define ta(X) (pa_ ## X)
34079 +#endif
34080 +
34081 .text
34082 .code16
34083
34084 @@ -39,8 +45,6 @@ ENTRY(trampoline_start)
34085
34086 cli # We should be safe anyway
34087
34088 - movl tr_start, %eax # where we need to go
34089 -
34090 movl $0xA5A5A5A5, trampoline_status
34091 # write marker for master knows we're running
34092
34093 @@ -56,7 +60,7 @@ ENTRY(trampoline_start)
34094 movw $1, %dx # protected mode (PE) bit
34095 lmsw %dx # into protected mode
34096
34097 - ljmpl $__BOOT_CS, $pa_startup_32
34098 + ljmpl *(trampoline_header)
34099
34100 .section ".text32","ax"
34101 .code32
34102 @@ -67,7 +71,7 @@ ENTRY(startup_32) # note: also used from wakeup_asm.S
34103 .balign 8
34104 GLOBAL(trampoline_header)
34105 tr_start: .space 4
34106 - tr_gdt_pad: .space 2
34107 + tr_boot_cs: .space 2
34108 tr_gdt: .space 6
34109 END(trampoline_header)
34110
34111 diff --git a/arch/x86/realmode/rm/trampoline_64.S b/arch/x86/realmode/rm/trampoline_64.S
34112 index bb360dc..d0fd8f8 100644
34113 --- a/arch/x86/realmode/rm/trampoline_64.S
34114 +++ b/arch/x86/realmode/rm/trampoline_64.S
34115 @@ -94,6 +94,7 @@ ENTRY(startup_32)
34116 movl %edx, %gs
34117
34118 movl pa_tr_cr4, %eax
34119 + andl $~X86_CR4_PCIDE, %eax
34120 movl %eax, %cr4 # Enable PAE mode
34121
34122 # Setup trampoline 4 level pagetables
34123 @@ -107,7 +108,7 @@ ENTRY(startup_32)
34124 wrmsr
34125
34126 # Enable paging and in turn activate Long Mode
34127 - movl $(X86_CR0_PG | X86_CR0_WP | X86_CR0_PE), %eax
34128 + movl $(X86_CR0_PG | X86_CR0_PE), %eax
34129 movl %eax, %cr0
34130
34131 /*
34132 diff --git a/arch/x86/tools/Makefile b/arch/x86/tools/Makefile
34133 index e812034..c747134 100644
34134 --- a/arch/x86/tools/Makefile
34135 +++ b/arch/x86/tools/Makefile
34136 @@ -37,7 +37,7 @@ $(obj)/test_get_len.o: $(srctree)/arch/x86/lib/insn.c $(srctree)/arch/x86/lib/in
34137
34138 $(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
34139
34140 -HOST_EXTRACFLAGS += -I$(srctree)/tools/include
34141 +HOST_EXTRACFLAGS += -I$(srctree)/tools/include -ggdb
34142 hostprogs-y += relocs
34143 relocs-objs := relocs_32.o relocs_64.o relocs_common.o
34144 relocs: $(obj)/relocs
34145 diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c
34146 index f7bab68..b6d9886 100644
34147 --- a/arch/x86/tools/relocs.c
34148 +++ b/arch/x86/tools/relocs.c
34149 @@ -1,5 +1,7 @@
34150 /* This is included from relocs_32/64.c */
34151
34152 +#include "../../../include/generated/autoconf.h"
34153 +
34154 #define ElfW(type) _ElfW(ELF_BITS, type)
34155 #define _ElfW(bits, type) __ElfW(bits, type)
34156 #define __ElfW(bits, type) Elf##bits##_##type
34157 @@ -11,6 +13,7 @@
34158 #define Elf_Sym ElfW(Sym)
34159
34160 static Elf_Ehdr ehdr;
34161 +static Elf_Phdr *phdr;
34162
34163 struct relocs {
34164 uint32_t *offset;
34165 @@ -383,9 +386,39 @@ static void read_ehdr(FILE *fp)
34166 }
34167 }
34168
34169 +static void read_phdrs(FILE *fp)
34170 +{
34171 + unsigned int i;
34172 +
34173 + phdr = calloc(ehdr.e_phnum, sizeof(Elf_Phdr));
34174 + if (!phdr) {
34175 + die("Unable to allocate %d program headers\n",
34176 + ehdr.e_phnum);
34177 + }
34178 + if (fseek(fp, ehdr.e_phoff, SEEK_SET) < 0) {
34179 + die("Seek to %d failed: %s\n",
34180 + ehdr.e_phoff, strerror(errno));
34181 + }
34182 + if (fread(phdr, sizeof(*phdr), ehdr.e_phnum, fp) != ehdr.e_phnum) {
34183 + die("Cannot read ELF program headers: %s\n",
34184 + strerror(errno));
34185 + }
34186 + for(i = 0; i < ehdr.e_phnum; i++) {
34187 + phdr[i].p_type = elf_word_to_cpu(phdr[i].p_type);
34188 + phdr[i].p_offset = elf_off_to_cpu(phdr[i].p_offset);
34189 + phdr[i].p_vaddr = elf_addr_to_cpu(phdr[i].p_vaddr);
34190 + phdr[i].p_paddr = elf_addr_to_cpu(phdr[i].p_paddr);
34191 + phdr[i].p_filesz = elf_word_to_cpu(phdr[i].p_filesz);
34192 + phdr[i].p_memsz = elf_word_to_cpu(phdr[i].p_memsz);
34193 + phdr[i].p_flags = elf_word_to_cpu(phdr[i].p_flags);
34194 + phdr[i].p_align = elf_word_to_cpu(phdr[i].p_align);
34195 + }
34196 +
34197 +}
34198 +
34199 static void read_shdrs(FILE *fp)
34200 {
34201 - int i;
34202 + unsigned int i;
34203 Elf_Shdr shdr;
34204
34205 secs = calloc(ehdr.e_shnum, sizeof(struct section));
34206 @@ -420,7 +453,7 @@ static void read_shdrs(FILE *fp)
34207
34208 static void read_strtabs(FILE *fp)
34209 {
34210 - int i;
34211 + unsigned int i;
34212 for (i = 0; i < ehdr.e_shnum; i++) {
34213 struct section *sec = &secs[i];
34214 if (sec->shdr.sh_type != SHT_STRTAB) {
34215 @@ -445,7 +478,7 @@ static void read_strtabs(FILE *fp)
34216
34217 static void read_symtabs(FILE *fp)
34218 {
34219 - int i,j;
34220 + unsigned int i,j;
34221 for (i = 0; i < ehdr.e_shnum; i++) {
34222 struct section *sec = &secs[i];
34223 if (sec->shdr.sh_type != SHT_SYMTAB) {
34224 @@ -476,9 +509,11 @@ static void read_symtabs(FILE *fp)
34225 }
34226
34227
34228 -static void read_relocs(FILE *fp)
34229 +static void read_relocs(FILE *fp, int use_real_mode)
34230 {
34231 - int i,j;
34232 + unsigned int i,j;
34233 + uint32_t base;
34234 +
34235 for (i = 0; i < ehdr.e_shnum; i++) {
34236 struct section *sec = &secs[i];
34237 if (sec->shdr.sh_type != SHT_REL_TYPE) {
34238 @@ -498,9 +533,22 @@ static void read_relocs(FILE *fp)
34239 die("Cannot read symbol table: %s\n",
34240 strerror(errno));
34241 }
34242 + base = 0;
34243 +
34244 +#ifdef CONFIG_X86_32
34245 + for (j = 0; !use_real_mode && j < ehdr.e_phnum; j++) {
34246 + if (phdr[j].p_type != PT_LOAD )
34247 + continue;
34248 + 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)
34249 + continue;
34250 + base = CONFIG_PAGE_OFFSET + phdr[j].p_paddr - phdr[j].p_vaddr;
34251 + break;
34252 + }
34253 +#endif
34254 +
34255 for (j = 0; j < sec->shdr.sh_size/sizeof(Elf_Rel); j++) {
34256 Elf_Rel *rel = &sec->reltab[j];
34257 - rel->r_offset = elf_addr_to_cpu(rel->r_offset);
34258 + rel->r_offset = elf_addr_to_cpu(rel->r_offset) + base;
34259 rel->r_info = elf_xword_to_cpu(rel->r_info);
34260 #if (SHT_REL_TYPE == SHT_RELA)
34261 rel->r_addend = elf_xword_to_cpu(rel->r_addend);
34262 @@ -512,7 +560,7 @@ static void read_relocs(FILE *fp)
34263
34264 static void print_absolute_symbols(void)
34265 {
34266 - int i;
34267 + unsigned int i;
34268 const char *format;
34269
34270 if (ELF_BITS == 64)
34271 @@ -525,7 +573,7 @@ static void print_absolute_symbols(void)
34272 for (i = 0; i < ehdr.e_shnum; i++) {
34273 struct section *sec = &secs[i];
34274 char *sym_strtab;
34275 - int j;
34276 + unsigned int j;
34277
34278 if (sec->shdr.sh_type != SHT_SYMTAB) {
34279 continue;
34280 @@ -552,7 +600,7 @@ static void print_absolute_symbols(void)
34281
34282 static void print_absolute_relocs(void)
34283 {
34284 - int i, printed = 0;
34285 + unsigned int i, printed = 0;
34286 const char *format;
34287
34288 if (ELF_BITS == 64)
34289 @@ -565,7 +613,7 @@ static void print_absolute_relocs(void)
34290 struct section *sec_applies, *sec_symtab;
34291 char *sym_strtab;
34292 Elf_Sym *sh_symtab;
34293 - int j;
34294 + unsigned int j;
34295 if (sec->shdr.sh_type != SHT_REL_TYPE) {
34296 continue;
34297 }
34298 @@ -642,13 +690,13 @@ static void add_reloc(struct relocs *r, uint32_t offset)
34299 static void walk_relocs(int (*process)(struct section *sec, Elf_Rel *rel,
34300 Elf_Sym *sym, const char *symname))
34301 {
34302 - int i;
34303 + unsigned int i;
34304 /* Walk through the relocations */
34305 for (i = 0; i < ehdr.e_shnum; i++) {
34306 char *sym_strtab;
34307 Elf_Sym *sh_symtab;
34308 struct section *sec_applies, *sec_symtab;
34309 - int j;
34310 + unsigned int j;
34311 struct section *sec = &secs[i];
34312
34313 if (sec->shdr.sh_type != SHT_REL_TYPE) {
34314 @@ -812,6 +860,23 @@ static int do_reloc32(struct section *sec, Elf_Rel *rel, Elf_Sym *sym,
34315 {
34316 unsigned r_type = ELF32_R_TYPE(rel->r_info);
34317 int shn_abs = (sym->st_shndx == SHN_ABS) && !is_reloc(S_REL, symname);
34318 + char *sym_strtab = sec->link->link->strtab;
34319 +
34320 + /* Don't relocate actual per-cpu variables, they are absolute indices, not addresses */
34321 + if (!strcmp(sec_name(sym->st_shndx), ".data..percpu") && strcmp(sym_name(sym_strtab, sym), "__per_cpu_load"))
34322 + return 0;
34323 +
34324 +#ifdef CONFIG_PAX_KERNEXEC
34325 + /* Don't relocate actual code, they are relocated implicitly by the base address of KERNEL_CS */
34326 + if (!strcmp(sec_name(sym->st_shndx), ".text.end") && !strcmp(sym_name(sym_strtab, sym), "_etext"))
34327 + return 0;
34328 + if (!strcmp(sec_name(sym->st_shndx), ".init.text"))
34329 + return 0;
34330 + if (!strcmp(sec_name(sym->st_shndx), ".exit.text"))
34331 + return 0;
34332 + if (!strcmp(sec_name(sym->st_shndx), ".text") && strcmp(sym_name(sym_strtab, sym), "__LOAD_PHYSICAL_ADDR"))
34333 + return 0;
34334 +#endif
34335
34336 switch (r_type) {
34337 case R_386_NONE:
34338 @@ -950,7 +1015,7 @@ static int write32_as_text(uint32_t v, FILE *f)
34339
34340 static void emit_relocs(int as_text, int use_real_mode)
34341 {
34342 - int i;
34343 + unsigned int i;
34344 int (*write_reloc)(uint32_t, FILE *) = write32;
34345 int (*do_reloc)(struct section *sec, Elf_Rel *rel, Elf_Sym *sym,
34346 const char *symname);
34347 @@ -1026,10 +1091,11 @@ void process(FILE *fp, int use_real_mode, int as_text,
34348 {
34349 regex_init(use_real_mode);
34350 read_ehdr(fp);
34351 + read_phdrs(fp);
34352 read_shdrs(fp);
34353 read_strtabs(fp);
34354 read_symtabs(fp);
34355 - read_relocs(fp);
34356 + read_relocs(fp, use_real_mode);
34357 if (ELF_BITS == 64)
34358 percpu_init();
34359 if (show_absolute_syms) {
34360 diff --git a/arch/x86/um/tls_32.c b/arch/x86/um/tls_32.c
34361 index 80ffa5b..a33bd15 100644
34362 --- a/arch/x86/um/tls_32.c
34363 +++ b/arch/x86/um/tls_32.c
34364 @@ -260,7 +260,7 @@ out:
34365 if (unlikely(task == current &&
34366 !t->arch.tls_array[idx - GDT_ENTRY_TLS_MIN].flushed)) {
34367 printk(KERN_ERR "get_tls_entry: task with pid %d got here "
34368 - "without flushed TLS.", current->pid);
34369 + "without flushed TLS.", task_pid_nr(current));
34370 }
34371
34372 return 0;
34373 diff --git a/arch/x86/vdso/Makefile b/arch/x86/vdso/Makefile
34374 index fd14be1..e3c79c0 100644
34375 --- a/arch/x86/vdso/Makefile
34376 +++ b/arch/x86/vdso/Makefile
34377 @@ -181,7 +181,7 @@ quiet_cmd_vdso = VDSO $@
34378 -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) && \
34379 sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@'
34380
34381 -VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
34382 +VDSO_LDFLAGS = -fPIC -shared -Wl,--no-undefined $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
34383 GCOV_PROFILE := n
34384
34385 #
34386 diff --git a/arch/x86/vdso/vdso32-setup.c b/arch/x86/vdso/vdso32-setup.c
34387 index d6bfb87..876ee18 100644
34388 --- a/arch/x86/vdso/vdso32-setup.c
34389 +++ b/arch/x86/vdso/vdso32-setup.c
34390 @@ -25,6 +25,7 @@
34391 #include <asm/tlbflush.h>
34392 #include <asm/vdso.h>
34393 #include <asm/proto.h>
34394 +#include <asm/mman.h>
34395
34396 enum {
34397 VDSO_DISABLED = 0,
34398 @@ -226,7 +227,7 @@ static inline void map_compat_vdso(int map)
34399 void enable_sep_cpu(void)
34400 {
34401 int cpu = get_cpu();
34402 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
34403 + struct tss_struct *tss = init_tss + cpu;
34404
34405 if (!boot_cpu_has(X86_FEATURE_SEP)) {
34406 put_cpu();
34407 @@ -249,7 +250,7 @@ static int __init gate_vma_init(void)
34408 gate_vma.vm_start = FIXADDR_USER_START;
34409 gate_vma.vm_end = FIXADDR_USER_END;
34410 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
34411 - gate_vma.vm_page_prot = __P101;
34412 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
34413
34414 return 0;
34415 }
34416 @@ -330,14 +331,14 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
34417 if (compat)
34418 addr = VDSO_HIGH_BASE;
34419 else {
34420 - addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, 0);
34421 + addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, MAP_EXECUTABLE);
34422 if (IS_ERR_VALUE(addr)) {
34423 ret = addr;
34424 goto up_fail;
34425 }
34426 }
34427
34428 - current->mm->context.vdso = (void *)addr;
34429 + current->mm->context.vdso = addr;
34430
34431 if (compat_uses_vma || !compat) {
34432 /*
34433 @@ -353,11 +354,11 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
34434 }
34435
34436 current_thread_info()->sysenter_return =
34437 - VDSO32_SYMBOL(addr, SYSENTER_RETURN);
34438 + (__force void __user *)VDSO32_SYMBOL(addr, SYSENTER_RETURN);
34439
34440 up_fail:
34441 if (ret)
34442 - current->mm->context.vdso = NULL;
34443 + current->mm->context.vdso = 0;
34444
34445 up_write(&mm->mmap_sem);
34446
34447 @@ -404,8 +405,14 @@ __initcall(ia32_binfmt_init);
34448
34449 const char *arch_vma_name(struct vm_area_struct *vma)
34450 {
34451 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
34452 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
34453 return "[vdso]";
34454 +
34455 +#ifdef CONFIG_PAX_SEGMEXEC
34456 + if (vma->vm_mm && vma->vm_mirror && vma->vm_mirror->vm_start == vma->vm_mm->context.vdso)
34457 + return "[vdso]";
34458 +#endif
34459 +
34460 return NULL;
34461 }
34462
34463 @@ -415,7 +422,7 @@ struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
34464 * Check to see if the corresponding task was created in compat vdso
34465 * mode.
34466 */
34467 - if (mm && mm->context.vdso == (void *)VDSO_HIGH_BASE)
34468 + if (mm && mm->context.vdso == VDSO_HIGH_BASE)
34469 return &gate_vma;
34470 return NULL;
34471 }
34472 diff --git a/arch/x86/vdso/vma.c b/arch/x86/vdso/vma.c
34473 index 431e875..cbb23f3 100644
34474 --- a/arch/x86/vdso/vma.c
34475 +++ b/arch/x86/vdso/vma.c
34476 @@ -16,8 +16,6 @@
34477 #include <asm/vdso.h>
34478 #include <asm/page.h>
34479
34480 -unsigned int __read_mostly vdso_enabled = 1;
34481 -
34482 extern char vdso_start[], vdso_end[];
34483 extern unsigned short vdso_sync_cpuid;
34484
34485 @@ -141,7 +139,6 @@ static unsigned long vdso_addr(unsigned long start, unsigned len)
34486 * unaligned here as a result of stack start randomization.
34487 */
34488 addr = PAGE_ALIGN(addr);
34489 - addr = align_vdso_addr(addr);
34490
34491 return addr;
34492 }
34493 @@ -154,30 +151,31 @@ static int setup_additional_pages(struct linux_binprm *bprm,
34494 unsigned size)
34495 {
34496 struct mm_struct *mm = current->mm;
34497 - unsigned long addr;
34498 + unsigned long addr = 0;
34499 int ret;
34500
34501 - if (!vdso_enabled)
34502 - return 0;
34503 -
34504 down_write(&mm->mmap_sem);
34505 +
34506 +#ifdef CONFIG_PAX_RANDMMAP
34507 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
34508 +#endif
34509 +
34510 addr = vdso_addr(mm->start_stack, size);
34511 + addr = align_vdso_addr(addr);
34512 addr = get_unmapped_area(NULL, addr, size, 0, 0);
34513 if (IS_ERR_VALUE(addr)) {
34514 ret = addr;
34515 goto up_fail;
34516 }
34517
34518 - current->mm->context.vdso = (void *)addr;
34519 + mm->context.vdso = addr;
34520
34521 ret = install_special_mapping(mm, addr, size,
34522 VM_READ|VM_EXEC|
34523 VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC,
34524 pages);
34525 - if (ret) {
34526 - current->mm->context.vdso = NULL;
34527 - goto up_fail;
34528 - }
34529 + if (ret)
34530 + mm->context.vdso = 0;
34531
34532 up_fail:
34533 up_write(&mm->mmap_sem);
34534 @@ -197,10 +195,3 @@ int x32_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
34535 vdsox32_size);
34536 }
34537 #endif
34538 -
34539 -static __init int vdso_setup(char *s)
34540 -{
34541 - vdso_enabled = simple_strtoul(s, NULL, 0);
34542 - return 0;
34543 -}
34544 -__setup("vdso=", vdso_setup);
34545 diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
34546 index fa6ade7..73da73a5 100644
34547 --- a/arch/x86/xen/enlighten.c
34548 +++ b/arch/x86/xen/enlighten.c
34549 @@ -123,8 +123,6 @@ EXPORT_SYMBOL_GPL(xen_start_info);
34550
34551 struct shared_info xen_dummy_shared_info;
34552
34553 -void *xen_initial_gdt;
34554 -
34555 RESERVE_BRK(shared_info_page_brk, PAGE_SIZE);
34556 __read_mostly int xen_have_vector_callback;
34557 EXPORT_SYMBOL_GPL(xen_have_vector_callback);
34558 @@ -541,8 +539,7 @@ static void xen_load_gdt(const struct desc_ptr *dtr)
34559 {
34560 unsigned long va = dtr->address;
34561 unsigned int size = dtr->size + 1;
34562 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
34563 - unsigned long frames[pages];
34564 + unsigned long frames[65536 / PAGE_SIZE];
34565 int f;
34566
34567 /*
34568 @@ -590,8 +587,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
34569 {
34570 unsigned long va = dtr->address;
34571 unsigned int size = dtr->size + 1;
34572 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
34573 - unsigned long frames[pages];
34574 + unsigned long frames[(GDT_SIZE + PAGE_SIZE - 1) / PAGE_SIZE];
34575 int f;
34576
34577 /*
34578 @@ -599,7 +595,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
34579 * 8-byte entries, or 16 4k pages..
34580 */
34581
34582 - BUG_ON(size > 65536);
34583 + BUG_ON(size > GDT_SIZE);
34584 BUG_ON(va & ~PAGE_MASK);
34585
34586 for (f = 0; va < dtr->address + size; va += PAGE_SIZE, f++) {
34587 @@ -988,7 +984,7 @@ static u32 xen_safe_apic_wait_icr_idle(void)
34588 return 0;
34589 }
34590
34591 -static void set_xen_basic_apic_ops(void)
34592 +static void __init set_xen_basic_apic_ops(void)
34593 {
34594 apic->read = xen_apic_read;
34595 apic->write = xen_apic_write;
34596 @@ -1293,30 +1289,30 @@ static const struct pv_apic_ops xen_apic_ops __initconst = {
34597 #endif
34598 };
34599
34600 -static void xen_reboot(int reason)
34601 +static __noreturn void xen_reboot(int reason)
34602 {
34603 struct sched_shutdown r = { .reason = reason };
34604
34605 - if (HYPERVISOR_sched_op(SCHEDOP_shutdown, &r))
34606 - BUG();
34607 + HYPERVISOR_sched_op(SCHEDOP_shutdown, &r);
34608 + BUG();
34609 }
34610
34611 -static void xen_restart(char *msg)
34612 +static __noreturn void xen_restart(char *msg)
34613 {
34614 xen_reboot(SHUTDOWN_reboot);
34615 }
34616
34617 -static void xen_emergency_restart(void)
34618 +static __noreturn void xen_emergency_restart(void)
34619 {
34620 xen_reboot(SHUTDOWN_reboot);
34621 }
34622
34623 -static void xen_machine_halt(void)
34624 +static __noreturn void xen_machine_halt(void)
34625 {
34626 xen_reboot(SHUTDOWN_poweroff);
34627 }
34628
34629 -static void xen_machine_power_off(void)
34630 +static __noreturn void xen_machine_power_off(void)
34631 {
34632 if (pm_power_off)
34633 pm_power_off();
34634 @@ -1467,7 +1463,17 @@ asmlinkage void __init xen_start_kernel(void)
34635 __userpte_alloc_gfp &= ~__GFP_HIGHMEM;
34636
34637 /* Work out if we support NX */
34638 - x86_configure_nx();
34639 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
34640 + if ((cpuid_eax(0x80000000) & 0xffff0000) == 0x80000000 &&
34641 + (cpuid_edx(0x80000001) & (1U << (X86_FEATURE_NX & 31)))) {
34642 + unsigned l, h;
34643 +
34644 + __supported_pte_mask |= _PAGE_NX;
34645 + rdmsr(MSR_EFER, l, h);
34646 + l |= EFER_NX;
34647 + wrmsr(MSR_EFER, l, h);
34648 + }
34649 +#endif
34650
34651 xen_setup_features();
34652
34653 @@ -1498,13 +1504,6 @@ asmlinkage void __init xen_start_kernel(void)
34654
34655 machine_ops = xen_machine_ops;
34656
34657 - /*
34658 - * The only reliable way to retain the initial address of the
34659 - * percpu gdt_page is to remember it here, so we can go and
34660 - * mark it RW later, when the initial percpu area is freed.
34661 - */
34662 - xen_initial_gdt = &per_cpu(gdt_page, 0);
34663 -
34664 xen_smp_init();
34665
34666 #ifdef CONFIG_ACPI_NUMA
34667 diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
34668 index fdc3ba2..23cae00 100644
34669 --- a/arch/x86/xen/mmu.c
34670 +++ b/arch/x86/xen/mmu.c
34671 @@ -379,7 +379,7 @@ static pteval_t pte_mfn_to_pfn(pteval_t val)
34672 return val;
34673 }
34674
34675 -static pteval_t pte_pfn_to_mfn(pteval_t val)
34676 +static pteval_t __intentional_overflow(-1) pte_pfn_to_mfn(pteval_t val)
34677 {
34678 if (val & _PAGE_PRESENT) {
34679 unsigned long pfn = (val & PTE_PFN_MASK) >> PAGE_SHIFT;
34680 @@ -1894,6 +1894,9 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
34681 /* L3_k[510] -> level2_kernel_pgt
34682 * L3_i[511] -> level2_fixmap_pgt */
34683 convert_pfn_mfn(level3_kernel_pgt);
34684 + convert_pfn_mfn(level3_vmalloc_start_pgt);
34685 + convert_pfn_mfn(level3_vmalloc_end_pgt);
34686 + convert_pfn_mfn(level3_vmemmap_pgt);
34687
34688 /* We get [511][511] and have Xen's version of level2_kernel_pgt */
34689 l3 = m2v(pgd[pgd_index(__START_KERNEL_map)].pgd);
34690 @@ -1923,8 +1926,12 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
34691 set_page_prot(init_level4_pgt, PAGE_KERNEL_RO);
34692 set_page_prot(level3_ident_pgt, PAGE_KERNEL_RO);
34693 set_page_prot(level3_kernel_pgt, PAGE_KERNEL_RO);
34694 + set_page_prot(level3_vmalloc_start_pgt, PAGE_KERNEL_RO);
34695 + set_page_prot(level3_vmalloc_end_pgt, PAGE_KERNEL_RO);
34696 + set_page_prot(level3_vmemmap_pgt, PAGE_KERNEL_RO);
34697 set_page_prot(level3_user_vsyscall, PAGE_KERNEL_RO);
34698 set_page_prot(level2_ident_pgt, PAGE_KERNEL_RO);
34699 + set_page_prot(level2_vmemmap_pgt, PAGE_KERNEL_RO);
34700 set_page_prot(level2_kernel_pgt, PAGE_KERNEL_RO);
34701 set_page_prot(level2_fixmap_pgt, PAGE_KERNEL_RO);
34702
34703 @@ -2108,6 +2115,7 @@ static void __init xen_post_allocator_init(void)
34704 pv_mmu_ops.set_pud = xen_set_pud;
34705 #if PAGETABLE_LEVELS == 4
34706 pv_mmu_ops.set_pgd = xen_set_pgd;
34707 + pv_mmu_ops.set_pgd_batched = xen_set_pgd;
34708 #endif
34709
34710 /* This will work as long as patching hasn't happened yet
34711 @@ -2186,6 +2194,7 @@ static const struct pv_mmu_ops xen_mmu_ops __initconst = {
34712 .pud_val = PV_CALLEE_SAVE(xen_pud_val),
34713 .make_pud = PV_CALLEE_SAVE(xen_make_pud),
34714 .set_pgd = xen_set_pgd_hyper,
34715 + .set_pgd_batched = xen_set_pgd_hyper,
34716
34717 .alloc_pud = xen_alloc_pmd_init,
34718 .release_pud = xen_release_pmd_init,
34719 diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c
34720 index 31d0475..51af671 100644
34721 --- a/arch/x86/xen/smp.c
34722 +++ b/arch/x86/xen/smp.c
34723 @@ -274,17 +274,13 @@ static void __init xen_smp_prepare_boot_cpu(void)
34724 native_smp_prepare_boot_cpu();
34725
34726 if (xen_pv_domain()) {
34727 - /* We've switched to the "real" per-cpu gdt, so make sure the
34728 - old memory can be recycled */
34729 - make_lowmem_page_readwrite(xen_initial_gdt);
34730 -
34731 #ifdef CONFIG_X86_32
34732 /*
34733 * Xen starts us with XEN_FLAT_RING1_DS, but linux code
34734 * expects __USER_DS
34735 */
34736 - loadsegment(ds, __USER_DS);
34737 - loadsegment(es, __USER_DS);
34738 + loadsegment(ds, __KERNEL_DS);
34739 + loadsegment(es, __KERNEL_DS);
34740 #endif
34741
34742 xen_filter_cpu_maps();
34743 @@ -364,7 +360,7 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
34744 ctxt->user_regs.ss = __KERNEL_DS;
34745 #ifdef CONFIG_X86_32
34746 ctxt->user_regs.fs = __KERNEL_PERCPU;
34747 - ctxt->user_regs.gs = __KERNEL_STACK_CANARY;
34748 + savesegment(gs, ctxt->user_regs.gs);
34749 #else
34750 ctxt->gs_base_kernel = per_cpu_offset(cpu);
34751 #endif
34752 @@ -374,8 +370,8 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
34753
34754 {
34755 ctxt->user_regs.eflags = 0x1000; /* IOPL_RING1 */
34756 - ctxt->user_regs.ds = __USER_DS;
34757 - ctxt->user_regs.es = __USER_DS;
34758 + ctxt->user_regs.ds = __KERNEL_DS;
34759 + ctxt->user_regs.es = __KERNEL_DS;
34760
34761 xen_copy_trap_info(ctxt->trap_ctxt);
34762
34763 @@ -420,13 +416,12 @@ static int xen_cpu_up(unsigned int cpu, struct task_struct *idle)
34764 int rc;
34765
34766 per_cpu(current_task, cpu) = idle;
34767 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
34768 #ifdef CONFIG_X86_32
34769 irq_ctx_init(cpu);
34770 #else
34771 clear_tsk_thread_flag(idle, TIF_FORK);
34772 - per_cpu(kernel_stack, cpu) =
34773 - (unsigned long)task_stack_page(idle) -
34774 - KERNEL_STACK_OFFSET + THREAD_SIZE;
34775 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
34776 #endif
34777 xen_setup_runstate_info(cpu);
34778 xen_setup_timer(cpu);
34779 @@ -702,7 +697,7 @@ static const struct smp_ops xen_smp_ops __initconst = {
34780
34781 void __init xen_smp_init(void)
34782 {
34783 - smp_ops = xen_smp_ops;
34784 + memcpy((void *)&smp_ops, &xen_smp_ops, sizeof smp_ops);
34785 xen_fill_possible_map();
34786 }
34787
34788 diff --git a/arch/x86/xen/xen-asm_32.S b/arch/x86/xen/xen-asm_32.S
34789 index 33ca6e4..0ded929 100644
34790 --- a/arch/x86/xen/xen-asm_32.S
34791 +++ b/arch/x86/xen/xen-asm_32.S
34792 @@ -84,14 +84,14 @@ ENTRY(xen_iret)
34793 ESP_OFFSET=4 # bytes pushed onto stack
34794
34795 /*
34796 - * Store vcpu_info pointer for easy access. Do it this way to
34797 - * avoid having to reload %fs
34798 + * Store vcpu_info pointer for easy access.
34799 */
34800 #ifdef CONFIG_SMP
34801 - GET_THREAD_INFO(%eax)
34802 - movl %ss:TI_cpu(%eax), %eax
34803 - movl %ss:__per_cpu_offset(,%eax,4), %eax
34804 - mov %ss:xen_vcpu(%eax), %eax
34805 + push %fs
34806 + mov $(__KERNEL_PERCPU), %eax
34807 + mov %eax, %fs
34808 + mov PER_CPU_VAR(xen_vcpu), %eax
34809 + pop %fs
34810 #else
34811 movl %ss:xen_vcpu, %eax
34812 #endif
34813 diff --git a/arch/x86/xen/xen-head.S b/arch/x86/xen/xen-head.S
34814 index 7faed58..ba4427c 100644
34815 --- a/arch/x86/xen/xen-head.S
34816 +++ b/arch/x86/xen/xen-head.S
34817 @@ -19,6 +19,17 @@ ENTRY(startup_xen)
34818 #ifdef CONFIG_X86_32
34819 mov %esi,xen_start_info
34820 mov $init_thread_union+THREAD_SIZE,%esp
34821 +#ifdef CONFIG_SMP
34822 + movl $cpu_gdt_table,%edi
34823 + movl $__per_cpu_load,%eax
34824 + movw %ax,__KERNEL_PERCPU + 2(%edi)
34825 + rorl $16,%eax
34826 + movb %al,__KERNEL_PERCPU + 4(%edi)
34827 + movb %ah,__KERNEL_PERCPU + 7(%edi)
34828 + movl $__per_cpu_end - 1,%eax
34829 + subl $__per_cpu_start,%eax
34830 + movw %ax,__KERNEL_PERCPU + 0(%edi)
34831 +#endif
34832 #else
34833 mov %rsi,xen_start_info
34834 mov $init_thread_union+THREAD_SIZE,%rsp
34835 diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h
34836 index 95f8c61..611d6e8 100644
34837 --- a/arch/x86/xen/xen-ops.h
34838 +++ b/arch/x86/xen/xen-ops.h
34839 @@ -10,8 +10,6 @@
34840 extern const char xen_hypervisor_callback[];
34841 extern const char xen_failsafe_callback[];
34842
34843 -extern void *xen_initial_gdt;
34844 -
34845 struct trap_info;
34846 void xen_copy_trap_info(struct trap_info *traps);
34847
34848 diff --git a/arch/xtensa/variants/dc232b/include/variant/core.h b/arch/xtensa/variants/dc232b/include/variant/core.h
34849 index 525bd3d..ef888b1 100644
34850 --- a/arch/xtensa/variants/dc232b/include/variant/core.h
34851 +++ b/arch/xtensa/variants/dc232b/include/variant/core.h
34852 @@ -119,9 +119,9 @@
34853 ----------------------------------------------------------------------*/
34854
34855 #define XCHAL_ICACHE_LINESIZE 32 /* I-cache line size in bytes */
34856 -#define XCHAL_DCACHE_LINESIZE 32 /* D-cache line size in bytes */
34857 #define XCHAL_ICACHE_LINEWIDTH 5 /* log2(I line size in bytes) */
34858 #define XCHAL_DCACHE_LINEWIDTH 5 /* log2(D line size in bytes) */
34859 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
34860
34861 #define XCHAL_ICACHE_SIZE 16384 /* I-cache size in bytes or 0 */
34862 #define XCHAL_DCACHE_SIZE 16384 /* D-cache size in bytes or 0 */
34863 diff --git a/arch/xtensa/variants/fsf/include/variant/core.h b/arch/xtensa/variants/fsf/include/variant/core.h
34864 index 2f33760..835e50a 100644
34865 --- a/arch/xtensa/variants/fsf/include/variant/core.h
34866 +++ b/arch/xtensa/variants/fsf/include/variant/core.h
34867 @@ -11,6 +11,7 @@
34868 #ifndef _XTENSA_CORE_H
34869 #define _XTENSA_CORE_H
34870
34871 +#include <linux/const.h>
34872
34873 /****************************************************************************
34874 Parameters Useful for Any Code, USER or PRIVILEGED
34875 @@ -112,9 +113,9 @@
34876 ----------------------------------------------------------------------*/
34877
34878 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
34879 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
34880 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
34881 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
34882 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
34883
34884 #define XCHAL_ICACHE_SIZE 8192 /* I-cache size in bytes or 0 */
34885 #define XCHAL_DCACHE_SIZE 8192 /* D-cache size in bytes or 0 */
34886 diff --git a/arch/xtensa/variants/s6000/include/variant/core.h b/arch/xtensa/variants/s6000/include/variant/core.h
34887 index af00795..2bb8105 100644
34888 --- a/arch/xtensa/variants/s6000/include/variant/core.h
34889 +++ b/arch/xtensa/variants/s6000/include/variant/core.h
34890 @@ -11,6 +11,7 @@
34891 #ifndef _XTENSA_CORE_CONFIGURATION_H
34892 #define _XTENSA_CORE_CONFIGURATION_H
34893
34894 +#include <linux/const.h>
34895
34896 /****************************************************************************
34897 Parameters Useful for Any Code, USER or PRIVILEGED
34898 @@ -118,9 +119,9 @@
34899 ----------------------------------------------------------------------*/
34900
34901 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
34902 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
34903 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
34904 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
34905 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
34906
34907 #define XCHAL_ICACHE_SIZE 32768 /* I-cache size in bytes or 0 */
34908 #define XCHAL_DCACHE_SIZE 32768 /* D-cache size in bytes or 0 */
34909 diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
34910 index 4e491d9..c8e18e4 100644
34911 --- a/block/blk-cgroup.c
34912 +++ b/block/blk-cgroup.c
34913 @@ -812,7 +812,7 @@ static void blkcg_css_free(struct cgroup_subsys_state *css)
34914 static struct cgroup_subsys_state *
34915 blkcg_css_alloc(struct cgroup_subsys_state *parent_css)
34916 {
34917 - static atomic64_t id_seq = ATOMIC64_INIT(0);
34918 + static atomic64_unchecked_t id_seq = ATOMIC64_INIT(0);
34919 struct blkcg *blkcg;
34920
34921 if (!parent_css) {
34922 @@ -826,7 +826,7 @@ blkcg_css_alloc(struct cgroup_subsys_state *parent_css)
34923
34924 blkcg->cfq_weight = CFQ_WEIGHT_DEFAULT;
34925 blkcg->cfq_leaf_weight = CFQ_WEIGHT_DEFAULT;
34926 - blkcg->id = atomic64_inc_return(&id_seq); /* root is 0, start from 1 */
34927 + blkcg->id = atomic64_inc_return_unchecked(&id_seq); /* root is 0, start from 1 */
34928 done:
34929 spin_lock_init(&blkcg->lock);
34930 INIT_RADIX_TREE(&blkcg->blkg_tree, GFP_ATOMIC);
34931 diff --git a/block/blk-iopoll.c b/block/blk-iopoll.c
34932 index 4b8d9b54..a7178c0 100644
34933 --- a/block/blk-iopoll.c
34934 +++ b/block/blk-iopoll.c
34935 @@ -77,7 +77,7 @@ void blk_iopoll_complete(struct blk_iopoll *iopoll)
34936 }
34937 EXPORT_SYMBOL(blk_iopoll_complete);
34938
34939 -static void blk_iopoll_softirq(struct softirq_action *h)
34940 +static __latent_entropy void blk_iopoll_softirq(void)
34941 {
34942 struct list_head *list = &__get_cpu_var(blk_cpu_iopoll);
34943 int rearm = 0, budget = blk_iopoll_budget;
34944 diff --git a/block/blk-map.c b/block/blk-map.c
34945 index 623e1cd..ca1e109 100644
34946 --- a/block/blk-map.c
34947 +++ b/block/blk-map.c
34948 @@ -302,7 +302,7 @@ int blk_rq_map_kern(struct request_queue *q, struct request *rq, void *kbuf,
34949 if (!len || !kbuf)
34950 return -EINVAL;
34951
34952 - do_copy = !blk_rq_aligned(q, addr, len) || object_is_on_stack(kbuf);
34953 + do_copy = !blk_rq_aligned(q, addr, len) || object_starts_on_stack(kbuf);
34954 if (do_copy)
34955 bio = bio_copy_kern(q, kbuf, len, gfp_mask, reading);
34956 else
34957 diff --git a/block/blk-softirq.c b/block/blk-softirq.c
34958 index ec9e606..3f38839 100644
34959 --- a/block/blk-softirq.c
34960 +++ b/block/blk-softirq.c
34961 @@ -18,7 +18,7 @@ static DEFINE_PER_CPU(struct list_head, blk_cpu_done);
34962 * Softirq action handler - move entries to local list and loop over them
34963 * while passing them to the queue registered handler.
34964 */
34965 -static void blk_done_softirq(struct softirq_action *h)
34966 +static __latent_entropy void blk_done_softirq(void)
34967 {
34968 struct list_head *cpu_list, local_list;
34969
34970 diff --git a/block/bsg.c b/block/bsg.c
34971 index 420a5a9..23834aa 100644
34972 --- a/block/bsg.c
34973 +++ b/block/bsg.c
34974 @@ -176,16 +176,24 @@ static int blk_fill_sgv4_hdr_rq(struct request_queue *q, struct request *rq,
34975 struct sg_io_v4 *hdr, struct bsg_device *bd,
34976 fmode_t has_write_perm)
34977 {
34978 + unsigned char tmpcmd[sizeof(rq->__cmd)];
34979 + unsigned char *cmdptr;
34980 +
34981 if (hdr->request_len > BLK_MAX_CDB) {
34982 rq->cmd = kzalloc(hdr->request_len, GFP_KERNEL);
34983 if (!rq->cmd)
34984 return -ENOMEM;
34985 - }
34986 + cmdptr = rq->cmd;
34987 + } else
34988 + cmdptr = tmpcmd;
34989
34990 - if (copy_from_user(rq->cmd, (void __user *)(unsigned long)hdr->request,
34991 + if (copy_from_user(cmdptr, (void __user *)(unsigned long)hdr->request,
34992 hdr->request_len))
34993 return -EFAULT;
34994
34995 + if (cmdptr != rq->cmd)
34996 + memcpy(rq->cmd, cmdptr, hdr->request_len);
34997 +
34998 if (hdr->subprotocol == BSG_SUB_PROTOCOL_SCSI_CMD) {
34999 if (blk_verify_command(rq->cmd, has_write_perm))
35000 return -EPERM;
35001 diff --git a/block/compat_ioctl.c b/block/compat_ioctl.c
35002 index fbd5a67..5d631b5 100644
35003 --- a/block/compat_ioctl.c
35004 +++ b/block/compat_ioctl.c
35005 @@ -341,7 +341,7 @@ static int compat_fd_ioctl(struct block_device *bdev, fmode_t mode,
35006 err |= __get_user(f->spec1, &uf->spec1);
35007 err |= __get_user(f->fmt_gap, &uf->fmt_gap);
35008 err |= __get_user(name, &uf->name);
35009 - f->name = compat_ptr(name);
35010 + f->name = (void __force_kernel *)compat_ptr(name);
35011 if (err) {
35012 err = -EFAULT;
35013 goto out;
35014 diff --git a/block/genhd.c b/block/genhd.c
35015 index 791f419..89f21c4 100644
35016 --- a/block/genhd.c
35017 +++ b/block/genhd.c
35018 @@ -467,21 +467,24 @@ static char *bdevt_str(dev_t devt, char *buf)
35019
35020 /*
35021 * Register device numbers dev..(dev+range-1)
35022 - * range must be nonzero
35023 + * Noop if @range is zero.
35024 * The hash chain is sorted on range, so that subranges can override.
35025 */
35026 void blk_register_region(dev_t devt, unsigned long range, struct module *module,
35027 struct kobject *(*probe)(dev_t, int *, void *),
35028 int (*lock)(dev_t, void *), void *data)
35029 {
35030 - kobj_map(bdev_map, devt, range, module, probe, lock, data);
35031 + if (range)
35032 + kobj_map(bdev_map, devt, range, module, probe, lock, data);
35033 }
35034
35035 EXPORT_SYMBOL(blk_register_region);
35036
35037 +/* undo blk_register_region(), noop if @range is zero */
35038 void blk_unregister_region(dev_t devt, unsigned long range)
35039 {
35040 - kobj_unmap(bdev_map, devt, range);
35041 + if (range)
35042 + kobj_unmap(bdev_map, devt, range);
35043 }
35044
35045 EXPORT_SYMBOL(blk_unregister_region);
35046 diff --git a/block/partitions/efi.c b/block/partitions/efi.c
35047 index a8287b4..241a48e 100644
35048 --- a/block/partitions/efi.c
35049 +++ b/block/partitions/efi.c
35050 @@ -292,14 +292,14 @@ static gpt_entry *alloc_read_gpt_entries(struct parsed_partitions *state,
35051 if (!gpt)
35052 return NULL;
35053
35054 + if (!le32_to_cpu(gpt->num_partition_entries))
35055 + return NULL;
35056 + pte = kcalloc(le32_to_cpu(gpt->num_partition_entries), le32_to_cpu(gpt->sizeof_partition_entry), GFP_KERNEL);
35057 + if (!pte)
35058 + return NULL;
35059 +
35060 count = le32_to_cpu(gpt->num_partition_entries) *
35061 le32_to_cpu(gpt->sizeof_partition_entry);
35062 - if (!count)
35063 - return NULL;
35064 - pte = kmalloc(count, GFP_KERNEL);
35065 - if (!pte)
35066 - return NULL;
35067 -
35068 if (read_lba(state, le64_to_cpu(gpt->partition_entry_lba),
35069 (u8 *) pte, count) < count) {
35070 kfree(pte);
35071 diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
35072 index a5ffcc9..e057498 100644
35073 --- a/block/scsi_ioctl.c
35074 +++ b/block/scsi_ioctl.c
35075 @@ -67,7 +67,7 @@ static int scsi_get_bus(struct request_queue *q, int __user *p)
35076 return put_user(0, p);
35077 }
35078
35079 -static int sg_get_timeout(struct request_queue *q)
35080 +static int __intentional_overflow(-1) sg_get_timeout(struct request_queue *q)
35081 {
35082 return jiffies_to_clock_t(q->sg_timeout);
35083 }
35084 @@ -224,8 +224,20 @@ EXPORT_SYMBOL(blk_verify_command);
35085 static int blk_fill_sghdr_rq(struct request_queue *q, struct request *rq,
35086 struct sg_io_hdr *hdr, fmode_t mode)
35087 {
35088 - if (copy_from_user(rq->cmd, hdr->cmdp, hdr->cmd_len))
35089 + unsigned char tmpcmd[sizeof(rq->__cmd)];
35090 + unsigned char *cmdptr;
35091 +
35092 + if (rq->cmd != rq->__cmd)
35093 + cmdptr = rq->cmd;
35094 + else
35095 + cmdptr = tmpcmd;
35096 +
35097 + if (copy_from_user(cmdptr, hdr->cmdp, hdr->cmd_len))
35098 return -EFAULT;
35099 +
35100 + if (cmdptr != rq->cmd)
35101 + memcpy(rq->cmd, cmdptr, hdr->cmd_len);
35102 +
35103 if (blk_verify_command(rq->cmd, mode & FMODE_WRITE))
35104 return -EPERM;
35105
35106 @@ -434,6 +446,8 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
35107 int err;
35108 unsigned int in_len, out_len, bytes, opcode, cmdlen;
35109 char *buffer = NULL, sense[SCSI_SENSE_BUFFERSIZE];
35110 + unsigned char tmpcmd[sizeof(rq->__cmd)];
35111 + unsigned char *cmdptr;
35112
35113 if (!sic)
35114 return -EINVAL;
35115 @@ -467,9 +481,18 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
35116 */
35117 err = -EFAULT;
35118 rq->cmd_len = cmdlen;
35119 - if (copy_from_user(rq->cmd, sic->data, cmdlen))
35120 +
35121 + if (rq->cmd != rq->__cmd)
35122 + cmdptr = rq->cmd;
35123 + else
35124 + cmdptr = tmpcmd;
35125 +
35126 + if (copy_from_user(cmdptr, sic->data, cmdlen))
35127 goto error;
35128
35129 + if (rq->cmd != cmdptr)
35130 + memcpy(rq->cmd, cmdptr, cmdlen);
35131 +
35132 if (in_len && copy_from_user(buffer, sic->data + cmdlen, in_len))
35133 goto error;
35134
35135 diff --git a/crypto/cryptd.c b/crypto/cryptd.c
35136 index 7bdd61b..afec999 100644
35137 --- a/crypto/cryptd.c
35138 +++ b/crypto/cryptd.c
35139 @@ -63,7 +63,7 @@ struct cryptd_blkcipher_ctx {
35140
35141 struct cryptd_blkcipher_request_ctx {
35142 crypto_completion_t complete;
35143 -};
35144 +} __no_const;
35145
35146 struct cryptd_hash_ctx {
35147 struct crypto_shash *child;
35148 @@ -80,7 +80,7 @@ struct cryptd_aead_ctx {
35149
35150 struct cryptd_aead_request_ctx {
35151 crypto_completion_t complete;
35152 -};
35153 +} __no_const;
35154
35155 static void cryptd_queue_worker(struct work_struct *work);
35156
35157 diff --git a/crypto/pcrypt.c b/crypto/pcrypt.c
35158 index f8c920c..ab2cb5a 100644
35159 --- a/crypto/pcrypt.c
35160 +++ b/crypto/pcrypt.c
35161 @@ -440,7 +440,7 @@ static int pcrypt_sysfs_add(struct padata_instance *pinst, const char *name)
35162 int ret;
35163
35164 pinst->kobj.kset = pcrypt_kset;
35165 - ret = kobject_add(&pinst->kobj, NULL, name);
35166 + ret = kobject_add(&pinst->kobj, NULL, "%s", name);
35167 if (!ret)
35168 kobject_uevent(&pinst->kobj, KOBJ_ADD);
35169
35170 diff --git a/drivers/acpi/apei/apei-internal.h b/drivers/acpi/apei/apei-internal.h
35171 index f220d64..d359ad6 100644
35172 --- a/drivers/acpi/apei/apei-internal.h
35173 +++ b/drivers/acpi/apei/apei-internal.h
35174 @@ -20,7 +20,7 @@ typedef int (*apei_exec_ins_func_t)(struct apei_exec_context *ctx,
35175 struct apei_exec_ins_type {
35176 u32 flags;
35177 apei_exec_ins_func_t run;
35178 -};
35179 +} __do_const;
35180
35181 struct apei_exec_context {
35182 u32 ip;
35183 diff --git a/drivers/acpi/apei/cper.c b/drivers/acpi/apei/cper.c
35184 index 33dc6a0..4b24b47 100644
35185 --- a/drivers/acpi/apei/cper.c
35186 +++ b/drivers/acpi/apei/cper.c
35187 @@ -39,12 +39,12 @@
35188 */
35189 u64 cper_next_record_id(void)
35190 {
35191 - static atomic64_t seq;
35192 + static atomic64_unchecked_t seq;
35193
35194 - if (!atomic64_read(&seq))
35195 - atomic64_set(&seq, ((u64)get_seconds()) << 32);
35196 + if (!atomic64_read_unchecked(&seq))
35197 + atomic64_set_unchecked(&seq, ((u64)get_seconds()) << 32);
35198
35199 - return atomic64_inc_return(&seq);
35200 + return atomic64_inc_return_unchecked(&seq);
35201 }
35202 EXPORT_SYMBOL_GPL(cper_next_record_id);
35203
35204 diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c
35205 index 8ec37bb..b0716e5 100644
35206 --- a/drivers/acpi/apei/ghes.c
35207 +++ b/drivers/acpi/apei/ghes.c
35208 @@ -498,7 +498,7 @@ static void __ghes_print_estatus(const char *pfx,
35209 const struct acpi_hest_generic *generic,
35210 const struct acpi_hest_generic_status *estatus)
35211 {
35212 - static atomic_t seqno;
35213 + static atomic_unchecked_t seqno;
35214 unsigned int curr_seqno;
35215 char pfx_seq[64];
35216
35217 @@ -509,7 +509,7 @@ static void __ghes_print_estatus(const char *pfx,
35218 else
35219 pfx = KERN_ERR;
35220 }
35221 - curr_seqno = atomic_inc_return(&seqno);
35222 + curr_seqno = atomic_inc_return_unchecked(&seqno);
35223 snprintf(pfx_seq, sizeof(pfx_seq), "%s{%u}" HW_ERR, pfx, curr_seqno);
35224 printk("%s""Hardware error from APEI Generic Hardware Error Source: %d\n",
35225 pfx_seq, generic->header.source_id);
35226 diff --git a/drivers/acpi/bgrt.c b/drivers/acpi/bgrt.c
35227 index a83e3c6..c3d617f 100644
35228 --- a/drivers/acpi/bgrt.c
35229 +++ b/drivers/acpi/bgrt.c
35230 @@ -86,8 +86,10 @@ static int __init bgrt_init(void)
35231 if (!bgrt_image)
35232 return -ENODEV;
35233
35234 - bin_attr_image.private = bgrt_image;
35235 - bin_attr_image.size = bgrt_image_size;
35236 + pax_open_kernel();
35237 + *(void **)&bin_attr_image.private = bgrt_image;
35238 + *(size_t *)&bin_attr_image.size = bgrt_image_size;
35239 + pax_close_kernel();
35240
35241 bgrt_kobj = kobject_create_and_add("bgrt", acpi_kobj);
35242 if (!bgrt_kobj)
35243 diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c
35244 index 9515f18..4b149c9 100644
35245 --- a/drivers/acpi/blacklist.c
35246 +++ b/drivers/acpi/blacklist.c
35247 @@ -52,7 +52,7 @@ struct acpi_blacklist_item {
35248 u32 is_critical_error;
35249 };
35250
35251 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata;
35252 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst;
35253
35254 /*
35255 * POLICY: If *anything* doesn't work, put it on the blacklist.
35256 @@ -199,7 +199,7 @@ static int __init dmi_disable_osi_win8(const struct dmi_system_id *d)
35257 return 0;
35258 }
35259
35260 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
35261 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst = {
35262 {
35263 .callback = dmi_disable_osi_vista,
35264 .ident = "Fujitsu Siemens",
35265 diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
35266 index c7414a5..d5afd71 100644
35267 --- a/drivers/acpi/processor_idle.c
35268 +++ b/drivers/acpi/processor_idle.c
35269 @@ -966,7 +966,7 @@ static int acpi_processor_setup_cpuidle_states(struct acpi_processor *pr)
35270 {
35271 int i, count = CPUIDLE_DRIVER_STATE_START;
35272 struct acpi_processor_cx *cx;
35273 - struct cpuidle_state *state;
35274 + cpuidle_state_no_const *state;
35275 struct cpuidle_driver *drv = &acpi_idle_driver;
35276
35277 if (!pr->flags.power_setup_done)
35278 diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c
35279 index 05306a5..733d1f0 100644
35280 --- a/drivers/acpi/sysfs.c
35281 +++ b/drivers/acpi/sysfs.c
35282 @@ -423,11 +423,11 @@ static u32 num_counters;
35283 static struct attribute **all_attrs;
35284 static u32 acpi_gpe_count;
35285
35286 -static struct attribute_group interrupt_stats_attr_group = {
35287 +static attribute_group_no_const interrupt_stats_attr_group = {
35288 .name = "interrupts",
35289 };
35290
35291 -static struct kobj_attribute *counter_attrs;
35292 +static kobj_attribute_no_const *counter_attrs;
35293
35294 static void delete_gpe_attr_array(void)
35295 {
35296 diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
35297 index cfb7447..98f2149 100644
35298 --- a/drivers/ata/libahci.c
35299 +++ b/drivers/ata/libahci.c
35300 @@ -1239,7 +1239,7 @@ int ahci_kick_engine(struct ata_port *ap)
35301 }
35302 EXPORT_SYMBOL_GPL(ahci_kick_engine);
35303
35304 -static int ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
35305 +static int __intentional_overflow(-1) ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
35306 struct ata_taskfile *tf, int is_cmd, u16 flags,
35307 unsigned long timeout_msec)
35308 {
35309 diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
35310 index 81a94a3..b711c74 100644
35311 --- a/drivers/ata/libata-core.c
35312 +++ b/drivers/ata/libata-core.c
35313 @@ -98,7 +98,7 @@ static unsigned int ata_dev_set_xfermode(struct ata_device *dev);
35314 static void ata_dev_xfermask(struct ata_device *dev);
35315 static unsigned long ata_dev_blacklisted(const struct ata_device *dev);
35316
35317 -atomic_t ata_print_id = ATOMIC_INIT(0);
35318 +atomic_unchecked_t ata_print_id = ATOMIC_INIT(0);
35319
35320 struct ata_force_param {
35321 const char *name;
35322 @@ -4809,7 +4809,7 @@ void ata_qc_free(struct ata_queued_cmd *qc)
35323 struct ata_port *ap;
35324 unsigned int tag;
35325
35326 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
35327 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
35328 ap = qc->ap;
35329
35330 qc->flags = 0;
35331 @@ -4825,7 +4825,7 @@ void __ata_qc_complete(struct ata_queued_cmd *qc)
35332 struct ata_port *ap;
35333 struct ata_link *link;
35334
35335 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
35336 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
35337 WARN_ON_ONCE(!(qc->flags & ATA_QCFLAG_ACTIVE));
35338 ap = qc->ap;
35339 link = qc->dev->link;
35340 @@ -5944,6 +5944,7 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
35341 return;
35342
35343 spin_lock(&lock);
35344 + pax_open_kernel();
35345
35346 for (cur = ops->inherits; cur; cur = cur->inherits) {
35347 void **inherit = (void **)cur;
35348 @@ -5957,8 +5958,9 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
35349 if (IS_ERR(*pp))
35350 *pp = NULL;
35351
35352 - ops->inherits = NULL;
35353 + *(struct ata_port_operations **)&ops->inherits = NULL;
35354
35355 + pax_close_kernel();
35356 spin_unlock(&lock);
35357 }
35358
35359 @@ -6151,7 +6153,7 @@ int ata_host_register(struct ata_host *host, struct scsi_host_template *sht)
35360
35361 /* give ports names and add SCSI hosts */
35362 for (i = 0; i < host->n_ports; i++) {
35363 - host->ports[i]->print_id = atomic_inc_return(&ata_print_id);
35364 + host->ports[i]->print_id = atomic_inc_return_unchecked(&ata_print_id);
35365 host->ports[i]->local_port_no = i + 1;
35366 }
35367
35368 diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
35369 index ab58556..ed19dd2 100644
35370 --- a/drivers/ata/libata-scsi.c
35371 +++ b/drivers/ata/libata-scsi.c
35372 @@ -4114,7 +4114,7 @@ int ata_sas_port_init(struct ata_port *ap)
35373
35374 if (rc)
35375 return rc;
35376 - ap->print_id = atomic_inc_return(&ata_print_id);
35377 + ap->print_id = atomic_inc_return_unchecked(&ata_print_id);
35378 return 0;
35379 }
35380 EXPORT_SYMBOL_GPL(ata_sas_port_init);
35381 diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h
35382 index 45b5ab3..98446b8 100644
35383 --- a/drivers/ata/libata.h
35384 +++ b/drivers/ata/libata.h
35385 @@ -53,7 +53,7 @@ enum {
35386 ATA_DNXFER_QUIET = (1 << 31),
35387 };
35388
35389 -extern atomic_t ata_print_id;
35390 +extern atomic_unchecked_t ata_print_id;
35391 extern int atapi_passthru16;
35392 extern int libata_fua;
35393 extern int libata_noacpi;
35394 diff --git a/drivers/ata/pata_arasan_cf.c b/drivers/ata/pata_arasan_cf.c
35395 index 853f610..97d24da 100644
35396 --- a/drivers/ata/pata_arasan_cf.c
35397 +++ b/drivers/ata/pata_arasan_cf.c
35398 @@ -865,7 +865,9 @@ static int arasan_cf_probe(struct platform_device *pdev)
35399 /* Handle platform specific quirks */
35400 if (quirk) {
35401 if (quirk & CF_BROKEN_PIO) {
35402 - ap->ops->set_piomode = NULL;
35403 + pax_open_kernel();
35404 + *(void **)&ap->ops->set_piomode = NULL;
35405 + pax_close_kernel();
35406 ap->pio_mask = 0;
35407 }
35408 if (quirk & CF_BROKEN_MWDMA)
35409 diff --git a/drivers/atm/adummy.c b/drivers/atm/adummy.c
35410 index f9b983a..887b9d8 100644
35411 --- a/drivers/atm/adummy.c
35412 +++ b/drivers/atm/adummy.c
35413 @@ -114,7 +114,7 @@ adummy_send(struct atm_vcc *vcc, struct sk_buff *skb)
35414 vcc->pop(vcc, skb);
35415 else
35416 dev_kfree_skb_any(skb);
35417 - atomic_inc(&vcc->stats->tx);
35418 + atomic_inc_unchecked(&vcc->stats->tx);
35419
35420 return 0;
35421 }
35422 diff --git a/drivers/atm/ambassador.c b/drivers/atm/ambassador.c
35423 index 62a7607..cc4be104 100644
35424 --- a/drivers/atm/ambassador.c
35425 +++ b/drivers/atm/ambassador.c
35426 @@ -454,7 +454,7 @@ static void tx_complete (amb_dev * dev, tx_out * tx) {
35427 PRINTD (DBG_FLOW|DBG_TX, "tx_complete %p %p", dev, tx);
35428
35429 // VC layer stats
35430 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
35431 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
35432
35433 // free the descriptor
35434 kfree (tx_descr);
35435 @@ -495,7 +495,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
35436 dump_skb ("<<<", vc, skb);
35437
35438 // VC layer stats
35439 - atomic_inc(&atm_vcc->stats->rx);
35440 + atomic_inc_unchecked(&atm_vcc->stats->rx);
35441 __net_timestamp(skb);
35442 // end of our responsibility
35443 atm_vcc->push (atm_vcc, skb);
35444 @@ -510,7 +510,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
35445 } else {
35446 PRINTK (KERN_INFO, "dropped over-size frame");
35447 // should we count this?
35448 - atomic_inc(&atm_vcc->stats->rx_drop);
35449 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
35450 }
35451
35452 } else {
35453 @@ -1338,7 +1338,7 @@ static int amb_send (struct atm_vcc * atm_vcc, struct sk_buff * skb) {
35454 }
35455
35456 if (check_area (skb->data, skb->len)) {
35457 - atomic_inc(&atm_vcc->stats->tx_err);
35458 + atomic_inc_unchecked(&atm_vcc->stats->tx_err);
35459 return -ENOMEM; // ?
35460 }
35461
35462 diff --git a/drivers/atm/atmtcp.c b/drivers/atm/atmtcp.c
35463 index 0e3f8f9..765a7a5 100644
35464 --- a/drivers/atm/atmtcp.c
35465 +++ b/drivers/atm/atmtcp.c
35466 @@ -206,7 +206,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
35467 if (vcc->pop) vcc->pop(vcc,skb);
35468 else dev_kfree_skb(skb);
35469 if (dev_data) return 0;
35470 - atomic_inc(&vcc->stats->tx_err);
35471 + atomic_inc_unchecked(&vcc->stats->tx_err);
35472 return -ENOLINK;
35473 }
35474 size = skb->len+sizeof(struct atmtcp_hdr);
35475 @@ -214,7 +214,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
35476 if (!new_skb) {
35477 if (vcc->pop) vcc->pop(vcc,skb);
35478 else dev_kfree_skb(skb);
35479 - atomic_inc(&vcc->stats->tx_err);
35480 + atomic_inc_unchecked(&vcc->stats->tx_err);
35481 return -ENOBUFS;
35482 }
35483 hdr = (void *) skb_put(new_skb,sizeof(struct atmtcp_hdr));
35484 @@ -225,8 +225,8 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
35485 if (vcc->pop) vcc->pop(vcc,skb);
35486 else dev_kfree_skb(skb);
35487 out_vcc->push(out_vcc,new_skb);
35488 - atomic_inc(&vcc->stats->tx);
35489 - atomic_inc(&out_vcc->stats->rx);
35490 + atomic_inc_unchecked(&vcc->stats->tx);
35491 + atomic_inc_unchecked(&out_vcc->stats->rx);
35492 return 0;
35493 }
35494
35495 @@ -299,7 +299,7 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
35496 out_vcc = find_vcc(dev, ntohs(hdr->vpi), ntohs(hdr->vci));
35497 read_unlock(&vcc_sklist_lock);
35498 if (!out_vcc) {
35499 - atomic_inc(&vcc->stats->tx_err);
35500 + atomic_inc_unchecked(&vcc->stats->tx_err);
35501 goto done;
35502 }
35503 skb_pull(skb,sizeof(struct atmtcp_hdr));
35504 @@ -311,8 +311,8 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
35505 __net_timestamp(new_skb);
35506 skb_copy_from_linear_data(skb, skb_put(new_skb, skb->len), skb->len);
35507 out_vcc->push(out_vcc,new_skb);
35508 - atomic_inc(&vcc->stats->tx);
35509 - atomic_inc(&out_vcc->stats->rx);
35510 + atomic_inc_unchecked(&vcc->stats->tx);
35511 + atomic_inc_unchecked(&out_vcc->stats->rx);
35512 done:
35513 if (vcc->pop) vcc->pop(vcc,skb);
35514 else dev_kfree_skb(skb);
35515 diff --git a/drivers/atm/eni.c b/drivers/atm/eni.c
35516 index b1955ba..b179940 100644
35517 --- a/drivers/atm/eni.c
35518 +++ b/drivers/atm/eni.c
35519 @@ -522,7 +522,7 @@ static int rx_aal0(struct atm_vcc *vcc)
35520 DPRINTK(DEV_LABEL "(itf %d): trashing empty cell\n",
35521 vcc->dev->number);
35522 length = 0;
35523 - atomic_inc(&vcc->stats->rx_err);
35524 + atomic_inc_unchecked(&vcc->stats->rx_err);
35525 }
35526 else {
35527 length = ATM_CELL_SIZE-1; /* no HEC */
35528 @@ -577,7 +577,7 @@ static int rx_aal5(struct atm_vcc *vcc)
35529 size);
35530 }
35531 eff = length = 0;
35532 - atomic_inc(&vcc->stats->rx_err);
35533 + atomic_inc_unchecked(&vcc->stats->rx_err);
35534 }
35535 else {
35536 size = (descr & MID_RED_COUNT)*(ATM_CELL_PAYLOAD >> 2);
35537 @@ -594,7 +594,7 @@ static int rx_aal5(struct atm_vcc *vcc)
35538 "(VCI=%d,length=%ld,size=%ld (descr 0x%lx))\n",
35539 vcc->dev->number,vcc->vci,length,size << 2,descr);
35540 length = eff = 0;
35541 - atomic_inc(&vcc->stats->rx_err);
35542 + atomic_inc_unchecked(&vcc->stats->rx_err);
35543 }
35544 }
35545 skb = eff ? atm_alloc_charge(vcc,eff << 2,GFP_ATOMIC) : NULL;
35546 @@ -767,7 +767,7 @@ rx_dequeued++;
35547 vcc->push(vcc,skb);
35548 pushed++;
35549 }
35550 - atomic_inc(&vcc->stats->rx);
35551 + atomic_inc_unchecked(&vcc->stats->rx);
35552 }
35553 wake_up(&eni_dev->rx_wait);
35554 }
35555 @@ -1227,7 +1227,7 @@ static void dequeue_tx(struct atm_dev *dev)
35556 PCI_DMA_TODEVICE);
35557 if (vcc->pop) vcc->pop(vcc,skb);
35558 else dev_kfree_skb_irq(skb);
35559 - atomic_inc(&vcc->stats->tx);
35560 + atomic_inc_unchecked(&vcc->stats->tx);
35561 wake_up(&eni_dev->tx_wait);
35562 dma_complete++;
35563 }
35564 diff --git a/drivers/atm/firestream.c b/drivers/atm/firestream.c
35565 index b41c948..a002b17 100644
35566 --- a/drivers/atm/firestream.c
35567 +++ b/drivers/atm/firestream.c
35568 @@ -749,7 +749,7 @@ static void process_txdone_queue (struct fs_dev *dev, struct queue *q)
35569 }
35570 }
35571
35572 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
35573 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
35574
35575 fs_dprintk (FS_DEBUG_TXMEM, "i");
35576 fs_dprintk (FS_DEBUG_ALLOC, "Free t-skb: %p\n", skb);
35577 @@ -816,7 +816,7 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
35578 #endif
35579 skb_put (skb, qe->p1 & 0xffff);
35580 ATM_SKB(skb)->vcc = atm_vcc;
35581 - atomic_inc(&atm_vcc->stats->rx);
35582 + atomic_inc_unchecked(&atm_vcc->stats->rx);
35583 __net_timestamp(skb);
35584 fs_dprintk (FS_DEBUG_ALLOC, "Free rec-skb: %p (pushed)\n", skb);
35585 atm_vcc->push (atm_vcc, skb);
35586 @@ -837,12 +837,12 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
35587 kfree (pe);
35588 }
35589 if (atm_vcc)
35590 - atomic_inc(&atm_vcc->stats->rx_drop);
35591 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
35592 break;
35593 case 0x1f: /* Reassembly abort: no buffers. */
35594 /* Silently increment error counter. */
35595 if (atm_vcc)
35596 - atomic_inc(&atm_vcc->stats->rx_drop);
35597 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
35598 break;
35599 default: /* Hmm. Haven't written the code to handle the others yet... -- REW */
35600 printk (KERN_WARNING "Don't know what to do with RX status %x: %s.\n",
35601 diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c
35602 index 204814e..cede831 100644
35603 --- a/drivers/atm/fore200e.c
35604 +++ b/drivers/atm/fore200e.c
35605 @@ -931,9 +931,9 @@ fore200e_tx_irq(struct fore200e* fore200e)
35606 #endif
35607 /* check error condition */
35608 if (*entry->status & STATUS_ERROR)
35609 - atomic_inc(&vcc->stats->tx_err);
35610 + atomic_inc_unchecked(&vcc->stats->tx_err);
35611 else
35612 - atomic_inc(&vcc->stats->tx);
35613 + atomic_inc_unchecked(&vcc->stats->tx);
35614 }
35615 }
35616
35617 @@ -1082,7 +1082,7 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
35618 if (skb == NULL) {
35619 DPRINTK(2, "unable to alloc new skb, rx PDU length = %d\n", pdu_len);
35620
35621 - atomic_inc(&vcc->stats->rx_drop);
35622 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35623 return -ENOMEM;
35624 }
35625
35626 @@ -1125,14 +1125,14 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
35627
35628 dev_kfree_skb_any(skb);
35629
35630 - atomic_inc(&vcc->stats->rx_drop);
35631 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35632 return -ENOMEM;
35633 }
35634
35635 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
35636
35637 vcc->push(vcc, skb);
35638 - atomic_inc(&vcc->stats->rx);
35639 + atomic_inc_unchecked(&vcc->stats->rx);
35640
35641 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
35642
35643 @@ -1210,7 +1210,7 @@ fore200e_rx_irq(struct fore200e* fore200e)
35644 DPRINTK(2, "damaged PDU on %d.%d.%d\n",
35645 fore200e->atm_dev->number,
35646 entry->rpd->atm_header.vpi, entry->rpd->atm_header.vci);
35647 - atomic_inc(&vcc->stats->rx_err);
35648 + atomic_inc_unchecked(&vcc->stats->rx_err);
35649 }
35650 }
35651
35652 @@ -1655,7 +1655,7 @@ fore200e_send(struct atm_vcc *vcc, struct sk_buff *skb)
35653 goto retry_here;
35654 }
35655
35656 - atomic_inc(&vcc->stats->tx_err);
35657 + atomic_inc_unchecked(&vcc->stats->tx_err);
35658
35659 fore200e->tx_sat++;
35660 DPRINTK(2, "tx queue of device %s is saturated, PDU dropped - heartbeat is %08x\n",
35661 diff --git a/drivers/atm/he.c b/drivers/atm/he.c
35662 index 8557adc..3fb5d55 100644
35663 --- a/drivers/atm/he.c
35664 +++ b/drivers/atm/he.c
35665 @@ -1691,7 +1691,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
35666
35667 if (RBRQ_HBUF_ERR(he_dev->rbrq_head)) {
35668 hprintk("HBUF_ERR! (cid 0x%x)\n", cid);
35669 - atomic_inc(&vcc->stats->rx_drop);
35670 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35671 goto return_host_buffers;
35672 }
35673
35674 @@ -1718,7 +1718,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
35675 RBRQ_LEN_ERR(he_dev->rbrq_head)
35676 ? "LEN_ERR" : "",
35677 vcc->vpi, vcc->vci);
35678 - atomic_inc(&vcc->stats->rx_err);
35679 + atomic_inc_unchecked(&vcc->stats->rx_err);
35680 goto return_host_buffers;
35681 }
35682
35683 @@ -1770,7 +1770,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
35684 vcc->push(vcc, skb);
35685 spin_lock(&he_dev->global_lock);
35686
35687 - atomic_inc(&vcc->stats->rx);
35688 + atomic_inc_unchecked(&vcc->stats->rx);
35689
35690 return_host_buffers:
35691 ++pdus_assembled;
35692 @@ -2096,7 +2096,7 @@ __enqueue_tpd(struct he_dev *he_dev, struct he_tpd *tpd, unsigned cid)
35693 tpd->vcc->pop(tpd->vcc, tpd->skb);
35694 else
35695 dev_kfree_skb_any(tpd->skb);
35696 - atomic_inc(&tpd->vcc->stats->tx_err);
35697 + atomic_inc_unchecked(&tpd->vcc->stats->tx_err);
35698 }
35699 pci_pool_free(he_dev->tpd_pool, tpd, TPD_ADDR(tpd->status));
35700 return;
35701 @@ -2508,7 +2508,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35702 vcc->pop(vcc, skb);
35703 else
35704 dev_kfree_skb_any(skb);
35705 - atomic_inc(&vcc->stats->tx_err);
35706 + atomic_inc_unchecked(&vcc->stats->tx_err);
35707 return -EINVAL;
35708 }
35709
35710 @@ -2519,7 +2519,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35711 vcc->pop(vcc, skb);
35712 else
35713 dev_kfree_skb_any(skb);
35714 - atomic_inc(&vcc->stats->tx_err);
35715 + atomic_inc_unchecked(&vcc->stats->tx_err);
35716 return -EINVAL;
35717 }
35718 #endif
35719 @@ -2531,7 +2531,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35720 vcc->pop(vcc, skb);
35721 else
35722 dev_kfree_skb_any(skb);
35723 - atomic_inc(&vcc->stats->tx_err);
35724 + atomic_inc_unchecked(&vcc->stats->tx_err);
35725 spin_unlock_irqrestore(&he_dev->global_lock, flags);
35726 return -ENOMEM;
35727 }
35728 @@ -2573,7 +2573,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35729 vcc->pop(vcc, skb);
35730 else
35731 dev_kfree_skb_any(skb);
35732 - atomic_inc(&vcc->stats->tx_err);
35733 + atomic_inc_unchecked(&vcc->stats->tx_err);
35734 spin_unlock_irqrestore(&he_dev->global_lock, flags);
35735 return -ENOMEM;
35736 }
35737 @@ -2604,7 +2604,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35738 __enqueue_tpd(he_dev, tpd, cid);
35739 spin_unlock_irqrestore(&he_dev->global_lock, flags);
35740
35741 - atomic_inc(&vcc->stats->tx);
35742 + atomic_inc_unchecked(&vcc->stats->tx);
35743
35744 return 0;
35745 }
35746 diff --git a/drivers/atm/horizon.c b/drivers/atm/horizon.c
35747 index 1dc0519..1aadaf7 100644
35748 --- a/drivers/atm/horizon.c
35749 +++ b/drivers/atm/horizon.c
35750 @@ -1034,7 +1034,7 @@ static void rx_schedule (hrz_dev * dev, int irq) {
35751 {
35752 struct atm_vcc * vcc = ATM_SKB(skb)->vcc;
35753 // VC layer stats
35754 - atomic_inc(&vcc->stats->rx);
35755 + atomic_inc_unchecked(&vcc->stats->rx);
35756 __net_timestamp(skb);
35757 // end of our responsibility
35758 vcc->push (vcc, skb);
35759 @@ -1186,7 +1186,7 @@ static void tx_schedule (hrz_dev * const dev, int irq) {
35760 dev->tx_iovec = NULL;
35761
35762 // VC layer stats
35763 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
35764 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
35765
35766 // free the skb
35767 hrz_kfree_skb (skb);
35768 diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
35769 index 1bdf104..9dc44b1 100644
35770 --- a/drivers/atm/idt77252.c
35771 +++ b/drivers/atm/idt77252.c
35772 @@ -812,7 +812,7 @@ drain_scq(struct idt77252_dev *card, struct vc_map *vc)
35773 else
35774 dev_kfree_skb(skb);
35775
35776 - atomic_inc(&vcc->stats->tx);
35777 + atomic_inc_unchecked(&vcc->stats->tx);
35778 }
35779
35780 atomic_dec(&scq->used);
35781 @@ -1075,13 +1075,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35782 if ((sb = dev_alloc_skb(64)) == NULL) {
35783 printk("%s: Can't allocate buffers for aal0.\n",
35784 card->name);
35785 - atomic_add(i, &vcc->stats->rx_drop);
35786 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
35787 break;
35788 }
35789 if (!atm_charge(vcc, sb->truesize)) {
35790 RXPRINTK("%s: atm_charge() dropped aal0 packets.\n",
35791 card->name);
35792 - atomic_add(i - 1, &vcc->stats->rx_drop);
35793 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop);
35794 dev_kfree_skb(sb);
35795 break;
35796 }
35797 @@ -1098,7 +1098,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35798 ATM_SKB(sb)->vcc = vcc;
35799 __net_timestamp(sb);
35800 vcc->push(vcc, sb);
35801 - atomic_inc(&vcc->stats->rx);
35802 + atomic_inc_unchecked(&vcc->stats->rx);
35803
35804 cell += ATM_CELL_PAYLOAD;
35805 }
35806 @@ -1135,13 +1135,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35807 "(CDC: %08x)\n",
35808 card->name, len, rpp->len, readl(SAR_REG_CDC));
35809 recycle_rx_pool_skb(card, rpp);
35810 - atomic_inc(&vcc->stats->rx_err);
35811 + atomic_inc_unchecked(&vcc->stats->rx_err);
35812 return;
35813 }
35814 if (stat & SAR_RSQE_CRC) {
35815 RXPRINTK("%s: AAL5 CRC error.\n", card->name);
35816 recycle_rx_pool_skb(card, rpp);
35817 - atomic_inc(&vcc->stats->rx_err);
35818 + atomic_inc_unchecked(&vcc->stats->rx_err);
35819 return;
35820 }
35821 if (skb_queue_len(&rpp->queue) > 1) {
35822 @@ -1152,7 +1152,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35823 RXPRINTK("%s: Can't alloc RX skb.\n",
35824 card->name);
35825 recycle_rx_pool_skb(card, rpp);
35826 - atomic_inc(&vcc->stats->rx_err);
35827 + atomic_inc_unchecked(&vcc->stats->rx_err);
35828 return;
35829 }
35830 if (!atm_charge(vcc, skb->truesize)) {
35831 @@ -1171,7 +1171,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35832 __net_timestamp(skb);
35833
35834 vcc->push(vcc, skb);
35835 - atomic_inc(&vcc->stats->rx);
35836 + atomic_inc_unchecked(&vcc->stats->rx);
35837
35838 return;
35839 }
35840 @@ -1193,7 +1193,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35841 __net_timestamp(skb);
35842
35843 vcc->push(vcc, skb);
35844 - atomic_inc(&vcc->stats->rx);
35845 + atomic_inc_unchecked(&vcc->stats->rx);
35846
35847 if (skb->truesize > SAR_FB_SIZE_3)
35848 add_rx_skb(card, 3, SAR_FB_SIZE_3, 1);
35849 @@ -1304,14 +1304,14 @@ idt77252_rx_raw(struct idt77252_dev *card)
35850 if (vcc->qos.aal != ATM_AAL0) {
35851 RPRINTK("%s: raw cell for non AAL0 vc %u.%u\n",
35852 card->name, vpi, vci);
35853 - atomic_inc(&vcc->stats->rx_drop);
35854 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35855 goto drop;
35856 }
35857
35858 if ((sb = dev_alloc_skb(64)) == NULL) {
35859 printk("%s: Can't allocate buffers for AAL0.\n",
35860 card->name);
35861 - atomic_inc(&vcc->stats->rx_err);
35862 + atomic_inc_unchecked(&vcc->stats->rx_err);
35863 goto drop;
35864 }
35865
35866 @@ -1330,7 +1330,7 @@ idt77252_rx_raw(struct idt77252_dev *card)
35867 ATM_SKB(sb)->vcc = vcc;
35868 __net_timestamp(sb);
35869 vcc->push(vcc, sb);
35870 - atomic_inc(&vcc->stats->rx);
35871 + atomic_inc_unchecked(&vcc->stats->rx);
35872
35873 drop:
35874 skb_pull(queue, 64);
35875 @@ -1955,13 +1955,13 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
35876
35877 if (vc == NULL) {
35878 printk("%s: NULL connection in send().\n", card->name);
35879 - atomic_inc(&vcc->stats->tx_err);
35880 + atomic_inc_unchecked(&vcc->stats->tx_err);
35881 dev_kfree_skb(skb);
35882 return -EINVAL;
35883 }
35884 if (!test_bit(VCF_TX, &vc->flags)) {
35885 printk("%s: Trying to transmit on a non-tx VC.\n", card->name);
35886 - atomic_inc(&vcc->stats->tx_err);
35887 + atomic_inc_unchecked(&vcc->stats->tx_err);
35888 dev_kfree_skb(skb);
35889 return -EINVAL;
35890 }
35891 @@ -1973,14 +1973,14 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
35892 break;
35893 default:
35894 printk("%s: Unsupported AAL: %d\n", card->name, vcc->qos.aal);
35895 - atomic_inc(&vcc->stats->tx_err);
35896 + atomic_inc_unchecked(&vcc->stats->tx_err);
35897 dev_kfree_skb(skb);
35898 return -EINVAL;
35899 }
35900
35901 if (skb_shinfo(skb)->nr_frags != 0) {
35902 printk("%s: No scatter-gather yet.\n", card->name);
35903 - atomic_inc(&vcc->stats->tx_err);
35904 + atomic_inc_unchecked(&vcc->stats->tx_err);
35905 dev_kfree_skb(skb);
35906 return -EINVAL;
35907 }
35908 @@ -1988,7 +1988,7 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
35909
35910 err = queue_skb(card, vc, skb, oam);
35911 if (err) {
35912 - atomic_inc(&vcc->stats->tx_err);
35913 + atomic_inc_unchecked(&vcc->stats->tx_err);
35914 dev_kfree_skb(skb);
35915 return err;
35916 }
35917 @@ -2011,7 +2011,7 @@ idt77252_send_oam(struct atm_vcc *vcc, void *cell, int flags)
35918 skb = dev_alloc_skb(64);
35919 if (!skb) {
35920 printk("%s: Out of memory in send_oam().\n", card->name);
35921 - atomic_inc(&vcc->stats->tx_err);
35922 + atomic_inc_unchecked(&vcc->stats->tx_err);
35923 return -ENOMEM;
35924 }
35925 atomic_add(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc);
35926 diff --git a/drivers/atm/iphase.c b/drivers/atm/iphase.c
35927 index 4217f29..88f547a 100644
35928 --- a/drivers/atm/iphase.c
35929 +++ b/drivers/atm/iphase.c
35930 @@ -1145,7 +1145,7 @@ static int rx_pkt(struct atm_dev *dev)
35931 status = (u_short) (buf_desc_ptr->desc_mode);
35932 if (status & (RX_CER | RX_PTE | RX_OFL))
35933 {
35934 - atomic_inc(&vcc->stats->rx_err);
35935 + atomic_inc_unchecked(&vcc->stats->rx_err);
35936 IF_ERR(printk("IA: bad packet, dropping it");)
35937 if (status & RX_CER) {
35938 IF_ERR(printk(" cause: packet CRC error\n");)
35939 @@ -1168,7 +1168,7 @@ static int rx_pkt(struct atm_dev *dev)
35940 len = dma_addr - buf_addr;
35941 if (len > iadev->rx_buf_sz) {
35942 printk("Over %d bytes sdu received, dropped!!!\n", iadev->rx_buf_sz);
35943 - atomic_inc(&vcc->stats->rx_err);
35944 + atomic_inc_unchecked(&vcc->stats->rx_err);
35945 goto out_free_desc;
35946 }
35947
35948 @@ -1318,7 +1318,7 @@ static void rx_dle_intr(struct atm_dev *dev)
35949 ia_vcc = INPH_IA_VCC(vcc);
35950 if (ia_vcc == NULL)
35951 {
35952 - atomic_inc(&vcc->stats->rx_err);
35953 + atomic_inc_unchecked(&vcc->stats->rx_err);
35954 atm_return(vcc, skb->truesize);
35955 dev_kfree_skb_any(skb);
35956 goto INCR_DLE;
35957 @@ -1330,7 +1330,7 @@ static void rx_dle_intr(struct atm_dev *dev)
35958 if ((length > iadev->rx_buf_sz) || (length >
35959 (skb->len - sizeof(struct cpcs_trailer))))
35960 {
35961 - atomic_inc(&vcc->stats->rx_err);
35962 + atomic_inc_unchecked(&vcc->stats->rx_err);
35963 IF_ERR(printk("rx_dle_intr: Bad AAL5 trailer %d (skb len %d)",
35964 length, skb->len);)
35965 atm_return(vcc, skb->truesize);
35966 @@ -1346,7 +1346,7 @@ static void rx_dle_intr(struct atm_dev *dev)
35967
35968 IF_RX(printk("rx_dle_intr: skb push");)
35969 vcc->push(vcc,skb);
35970 - atomic_inc(&vcc->stats->rx);
35971 + atomic_inc_unchecked(&vcc->stats->rx);
35972 iadev->rx_pkt_cnt++;
35973 }
35974 INCR_DLE:
35975 @@ -2826,15 +2826,15 @@ static int ia_ioctl(struct atm_dev *dev, unsigned int cmd, void __user *arg)
35976 {
35977 struct k_sonet_stats *stats;
35978 stats = &PRIV(_ia_dev[board])->sonet_stats;
35979 - printk("section_bip: %d\n", atomic_read(&stats->section_bip));
35980 - printk("line_bip : %d\n", atomic_read(&stats->line_bip));
35981 - printk("path_bip : %d\n", atomic_read(&stats->path_bip));
35982 - printk("line_febe : %d\n", atomic_read(&stats->line_febe));
35983 - printk("path_febe : %d\n", atomic_read(&stats->path_febe));
35984 - printk("corr_hcs : %d\n", atomic_read(&stats->corr_hcs));
35985 - printk("uncorr_hcs : %d\n", atomic_read(&stats->uncorr_hcs));
35986 - printk("tx_cells : %d\n", atomic_read(&stats->tx_cells));
35987 - printk("rx_cells : %d\n", atomic_read(&stats->rx_cells));
35988 + printk("section_bip: %d\n", atomic_read_unchecked(&stats->section_bip));
35989 + printk("line_bip : %d\n", atomic_read_unchecked(&stats->line_bip));
35990 + printk("path_bip : %d\n", atomic_read_unchecked(&stats->path_bip));
35991 + printk("line_febe : %d\n", atomic_read_unchecked(&stats->line_febe));
35992 + printk("path_febe : %d\n", atomic_read_unchecked(&stats->path_febe));
35993 + printk("corr_hcs : %d\n", atomic_read_unchecked(&stats->corr_hcs));
35994 + printk("uncorr_hcs : %d\n", atomic_read_unchecked(&stats->uncorr_hcs));
35995 + printk("tx_cells : %d\n", atomic_read_unchecked(&stats->tx_cells));
35996 + printk("rx_cells : %d\n", atomic_read_unchecked(&stats->rx_cells));
35997 }
35998 ia_cmds.status = 0;
35999 break;
36000 @@ -2939,7 +2939,7 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
36001 if ((desc == 0) || (desc > iadev->num_tx_desc))
36002 {
36003 IF_ERR(printk(DEV_LABEL "invalid desc for send: %d\n", desc);)
36004 - atomic_inc(&vcc->stats->tx);
36005 + atomic_inc_unchecked(&vcc->stats->tx);
36006 if (vcc->pop)
36007 vcc->pop(vcc, skb);
36008 else
36009 @@ -3044,14 +3044,14 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
36010 ATM_DESC(skb) = vcc->vci;
36011 skb_queue_tail(&iadev->tx_dma_q, skb);
36012
36013 - atomic_inc(&vcc->stats->tx);
36014 + atomic_inc_unchecked(&vcc->stats->tx);
36015 iadev->tx_pkt_cnt++;
36016 /* Increment transaction counter */
36017 writel(2, iadev->dma+IPHASE5575_TX_COUNTER);
36018
36019 #if 0
36020 /* add flow control logic */
36021 - if (atomic_read(&vcc->stats->tx) % 20 == 0) {
36022 + if (atomic_read_unchecked(&vcc->stats->tx) % 20 == 0) {
36023 if (iavcc->vc_desc_cnt > 10) {
36024 vcc->tx_quota = vcc->tx_quota * 3 / 4;
36025 printk("Tx1: vcc->tx_quota = %d \n", (u32)vcc->tx_quota );
36026 diff --git a/drivers/atm/lanai.c b/drivers/atm/lanai.c
36027 index fa7d701..1e404c7 100644
36028 --- a/drivers/atm/lanai.c
36029 +++ b/drivers/atm/lanai.c
36030 @@ -1303,7 +1303,7 @@ static void lanai_send_one_aal5(struct lanai_dev *lanai,
36031 vcc_tx_add_aal5_trailer(lvcc, skb->len, 0, 0);
36032 lanai_endtx(lanai, lvcc);
36033 lanai_free_skb(lvcc->tx.atmvcc, skb);
36034 - atomic_inc(&lvcc->tx.atmvcc->stats->tx);
36035 + atomic_inc_unchecked(&lvcc->tx.atmvcc->stats->tx);
36036 }
36037
36038 /* Try to fill the buffer - don't call unless there is backlog */
36039 @@ -1426,7 +1426,7 @@ static void vcc_rx_aal5(struct lanai_vcc *lvcc, int endptr)
36040 ATM_SKB(skb)->vcc = lvcc->rx.atmvcc;
36041 __net_timestamp(skb);
36042 lvcc->rx.atmvcc->push(lvcc->rx.atmvcc, skb);
36043 - atomic_inc(&lvcc->rx.atmvcc->stats->rx);
36044 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx);
36045 out:
36046 lvcc->rx.buf.ptr = end;
36047 cardvcc_write(lvcc, endptr, vcc_rxreadptr);
36048 @@ -1667,7 +1667,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
36049 DPRINTK("(itf %d) got RX service entry 0x%X for non-AAL5 "
36050 "vcc %d\n", lanai->number, (unsigned int) s, vci);
36051 lanai->stats.service_rxnotaal5++;
36052 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
36053 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
36054 return 0;
36055 }
36056 if (likely(!(s & (SERVICE_TRASH | SERVICE_STREAM | SERVICE_CRCERR)))) {
36057 @@ -1679,7 +1679,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
36058 int bytes;
36059 read_unlock(&vcc_sklist_lock);
36060 DPRINTK("got trashed rx pdu on vci %d\n", vci);
36061 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
36062 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
36063 lvcc->stats.x.aal5.service_trash++;
36064 bytes = (SERVICE_GET_END(s) * 16) -
36065 (((unsigned long) lvcc->rx.buf.ptr) -
36066 @@ -1691,7 +1691,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
36067 }
36068 if (s & SERVICE_STREAM) {
36069 read_unlock(&vcc_sklist_lock);
36070 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
36071 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
36072 lvcc->stats.x.aal5.service_stream++;
36073 printk(KERN_ERR DEV_LABEL "(itf %d): Got AAL5 stream "
36074 "PDU on VCI %d!\n", lanai->number, vci);
36075 @@ -1699,7 +1699,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
36076 return 0;
36077 }
36078 DPRINTK("got rx crc error on vci %d\n", vci);
36079 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
36080 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
36081 lvcc->stats.x.aal5.service_rxcrc++;
36082 lvcc->rx.buf.ptr = &lvcc->rx.buf.start[SERVICE_GET_END(s) * 4];
36083 cardvcc_write(lvcc, SERVICE_GET_END(s), vcc_rxreadptr);
36084 diff --git a/drivers/atm/nicstar.c b/drivers/atm/nicstar.c
36085 index 5aca5f4..ce3a6b0 100644
36086 --- a/drivers/atm/nicstar.c
36087 +++ b/drivers/atm/nicstar.c
36088 @@ -1640,7 +1640,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
36089 if ((vc = (vc_map *) vcc->dev_data) == NULL) {
36090 printk("nicstar%d: vcc->dev_data == NULL on ns_send().\n",
36091 card->index);
36092 - atomic_inc(&vcc->stats->tx_err);
36093 + atomic_inc_unchecked(&vcc->stats->tx_err);
36094 dev_kfree_skb_any(skb);
36095 return -EINVAL;
36096 }
36097 @@ -1648,7 +1648,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
36098 if (!vc->tx) {
36099 printk("nicstar%d: Trying to transmit on a non-tx VC.\n",
36100 card->index);
36101 - atomic_inc(&vcc->stats->tx_err);
36102 + atomic_inc_unchecked(&vcc->stats->tx_err);
36103 dev_kfree_skb_any(skb);
36104 return -EINVAL;
36105 }
36106 @@ -1656,14 +1656,14 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
36107 if (vcc->qos.aal != ATM_AAL5 && vcc->qos.aal != ATM_AAL0) {
36108 printk("nicstar%d: Only AAL0 and AAL5 are supported.\n",
36109 card->index);
36110 - atomic_inc(&vcc->stats->tx_err);
36111 + atomic_inc_unchecked(&vcc->stats->tx_err);
36112 dev_kfree_skb_any(skb);
36113 return -EINVAL;
36114 }
36115
36116 if (skb_shinfo(skb)->nr_frags != 0) {
36117 printk("nicstar%d: No scatter-gather yet.\n", card->index);
36118 - atomic_inc(&vcc->stats->tx_err);
36119 + atomic_inc_unchecked(&vcc->stats->tx_err);
36120 dev_kfree_skb_any(skb);
36121 return -EINVAL;
36122 }
36123 @@ -1711,11 +1711,11 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
36124 }
36125
36126 if (push_scqe(card, vc, scq, &scqe, skb) != 0) {
36127 - atomic_inc(&vcc->stats->tx_err);
36128 + atomic_inc_unchecked(&vcc->stats->tx_err);
36129 dev_kfree_skb_any(skb);
36130 return -EIO;
36131 }
36132 - atomic_inc(&vcc->stats->tx);
36133 + atomic_inc_unchecked(&vcc->stats->tx);
36134
36135 return 0;
36136 }
36137 @@ -2032,14 +2032,14 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
36138 printk
36139 ("nicstar%d: Can't allocate buffers for aal0.\n",
36140 card->index);
36141 - atomic_add(i, &vcc->stats->rx_drop);
36142 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
36143 break;
36144 }
36145 if (!atm_charge(vcc, sb->truesize)) {
36146 RXPRINTK
36147 ("nicstar%d: atm_charge() dropped aal0 packets.\n",
36148 card->index);
36149 - atomic_add(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
36150 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
36151 dev_kfree_skb_any(sb);
36152 break;
36153 }
36154 @@ -2054,7 +2054,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
36155 ATM_SKB(sb)->vcc = vcc;
36156 __net_timestamp(sb);
36157 vcc->push(vcc, sb);
36158 - atomic_inc(&vcc->stats->rx);
36159 + atomic_inc_unchecked(&vcc->stats->rx);
36160 cell += ATM_CELL_PAYLOAD;
36161 }
36162
36163 @@ -2071,7 +2071,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
36164 if (iovb == NULL) {
36165 printk("nicstar%d: Out of iovec buffers.\n",
36166 card->index);
36167 - atomic_inc(&vcc->stats->rx_drop);
36168 + atomic_inc_unchecked(&vcc->stats->rx_drop);
36169 recycle_rx_buf(card, skb);
36170 return;
36171 }
36172 @@ -2095,7 +2095,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
36173 small or large buffer itself. */
36174 } else if (NS_PRV_IOVCNT(iovb) >= NS_MAX_IOVECS) {
36175 printk("nicstar%d: received too big AAL5 SDU.\n", card->index);
36176 - atomic_inc(&vcc->stats->rx_err);
36177 + atomic_inc_unchecked(&vcc->stats->rx_err);
36178 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
36179 NS_MAX_IOVECS);
36180 NS_PRV_IOVCNT(iovb) = 0;
36181 @@ -2115,7 +2115,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
36182 ("nicstar%d: Expected a small buffer, and this is not one.\n",
36183 card->index);
36184 which_list(card, skb);
36185 - atomic_inc(&vcc->stats->rx_err);
36186 + atomic_inc_unchecked(&vcc->stats->rx_err);
36187 recycle_rx_buf(card, skb);
36188 vc->rx_iov = NULL;
36189 recycle_iov_buf(card, iovb);
36190 @@ -2128,7 +2128,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
36191 ("nicstar%d: Expected a large buffer, and this is not one.\n",
36192 card->index);
36193 which_list(card, skb);
36194 - atomic_inc(&vcc->stats->rx_err);
36195 + atomic_inc_unchecked(&vcc->stats->rx_err);
36196 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
36197 NS_PRV_IOVCNT(iovb));
36198 vc->rx_iov = NULL;
36199 @@ -2151,7 +2151,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
36200 printk(" - PDU size mismatch.\n");
36201 else
36202 printk(".\n");
36203 - atomic_inc(&vcc->stats->rx_err);
36204 + atomic_inc_unchecked(&vcc->stats->rx_err);
36205 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
36206 NS_PRV_IOVCNT(iovb));
36207 vc->rx_iov = NULL;
36208 @@ -2165,7 +2165,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
36209 /* skb points to a small buffer */
36210 if (!atm_charge(vcc, skb->truesize)) {
36211 push_rxbufs(card, skb);
36212 - atomic_inc(&vcc->stats->rx_drop);
36213 + atomic_inc_unchecked(&vcc->stats->rx_drop);
36214 } else {
36215 skb_put(skb, len);
36216 dequeue_sm_buf(card, skb);
36217 @@ -2175,7 +2175,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
36218 ATM_SKB(skb)->vcc = vcc;
36219 __net_timestamp(skb);
36220 vcc->push(vcc, skb);
36221 - atomic_inc(&vcc->stats->rx);
36222 + atomic_inc_unchecked(&vcc->stats->rx);
36223 }
36224 } else if (NS_PRV_IOVCNT(iovb) == 2) { /* One small plus one large buffer */
36225 struct sk_buff *sb;
36226 @@ -2186,7 +2186,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
36227 if (len <= NS_SMBUFSIZE) {
36228 if (!atm_charge(vcc, sb->truesize)) {
36229 push_rxbufs(card, sb);
36230 - atomic_inc(&vcc->stats->rx_drop);
36231 + atomic_inc_unchecked(&vcc->stats->rx_drop);
36232 } else {
36233 skb_put(sb, len);
36234 dequeue_sm_buf(card, sb);
36235 @@ -2196,7 +2196,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
36236 ATM_SKB(sb)->vcc = vcc;
36237 __net_timestamp(sb);
36238 vcc->push(vcc, sb);
36239 - atomic_inc(&vcc->stats->rx);
36240 + atomic_inc_unchecked(&vcc->stats->rx);
36241 }
36242
36243 push_rxbufs(card, skb);
36244 @@ -2205,7 +2205,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
36245
36246 if (!atm_charge(vcc, skb->truesize)) {
36247 push_rxbufs(card, skb);
36248 - atomic_inc(&vcc->stats->rx_drop);
36249 + atomic_inc_unchecked(&vcc->stats->rx_drop);
36250 } else {
36251 dequeue_lg_buf(card, skb);
36252 #ifdef NS_USE_DESTRUCTORS
36253 @@ -2218,7 +2218,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
36254 ATM_SKB(skb)->vcc = vcc;
36255 __net_timestamp(skb);
36256 vcc->push(vcc, skb);
36257 - atomic_inc(&vcc->stats->rx);
36258 + atomic_inc_unchecked(&vcc->stats->rx);
36259 }
36260
36261 push_rxbufs(card, sb);
36262 @@ -2239,7 +2239,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
36263 printk
36264 ("nicstar%d: Out of huge buffers.\n",
36265 card->index);
36266 - atomic_inc(&vcc->stats->rx_drop);
36267 + atomic_inc_unchecked(&vcc->stats->rx_drop);
36268 recycle_iovec_rx_bufs(card,
36269 (struct iovec *)
36270 iovb->data,
36271 @@ -2290,7 +2290,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
36272 card->hbpool.count++;
36273 } else
36274 dev_kfree_skb_any(hb);
36275 - atomic_inc(&vcc->stats->rx_drop);
36276 + atomic_inc_unchecked(&vcc->stats->rx_drop);
36277 } else {
36278 /* Copy the small buffer to the huge buffer */
36279 sb = (struct sk_buff *)iov->iov_base;
36280 @@ -2327,7 +2327,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
36281 #endif /* NS_USE_DESTRUCTORS */
36282 __net_timestamp(hb);
36283 vcc->push(vcc, hb);
36284 - atomic_inc(&vcc->stats->rx);
36285 + atomic_inc_unchecked(&vcc->stats->rx);
36286 }
36287 }
36288
36289 diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c
36290 index 32784d1..4a8434a 100644
36291 --- a/drivers/atm/solos-pci.c
36292 +++ b/drivers/atm/solos-pci.c
36293 @@ -838,7 +838,7 @@ void solos_bh(unsigned long card_arg)
36294 }
36295 atm_charge(vcc, skb->truesize);
36296 vcc->push(vcc, skb);
36297 - atomic_inc(&vcc->stats->rx);
36298 + atomic_inc_unchecked(&vcc->stats->rx);
36299 break;
36300
36301 case PKT_STATUS:
36302 @@ -1116,7 +1116,7 @@ static uint32_t fpga_tx(struct solos_card *card)
36303 vcc = SKB_CB(oldskb)->vcc;
36304
36305 if (vcc) {
36306 - atomic_inc(&vcc->stats->tx);
36307 + atomic_inc_unchecked(&vcc->stats->tx);
36308 solos_pop(vcc, oldskb);
36309 } else {
36310 dev_kfree_skb_irq(oldskb);
36311 diff --git a/drivers/atm/suni.c b/drivers/atm/suni.c
36312 index 0215934..ce9f5b1 100644
36313 --- a/drivers/atm/suni.c
36314 +++ b/drivers/atm/suni.c
36315 @@ -49,8 +49,8 @@ static DEFINE_SPINLOCK(sunis_lock);
36316
36317
36318 #define ADD_LIMITED(s,v) \
36319 - atomic_add((v),&stats->s); \
36320 - if (atomic_read(&stats->s) < 0) atomic_set(&stats->s,INT_MAX);
36321 + atomic_add_unchecked((v),&stats->s); \
36322 + if (atomic_read_unchecked(&stats->s) < 0) atomic_set_unchecked(&stats->s,INT_MAX);
36323
36324
36325 static void suni_hz(unsigned long from_timer)
36326 diff --git a/drivers/atm/uPD98402.c b/drivers/atm/uPD98402.c
36327 index 5120a96..e2572bd 100644
36328 --- a/drivers/atm/uPD98402.c
36329 +++ b/drivers/atm/uPD98402.c
36330 @@ -42,7 +42,7 @@ static int fetch_stats(struct atm_dev *dev,struct sonet_stats __user *arg,int ze
36331 struct sonet_stats tmp;
36332 int error = 0;
36333
36334 - atomic_add(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
36335 + atomic_add_unchecked(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
36336 sonet_copy_stats(&PRIV(dev)->sonet_stats,&tmp);
36337 if (arg) error = copy_to_user(arg,&tmp,sizeof(tmp));
36338 if (zero && !error) {
36339 @@ -161,9 +161,9 @@ static int uPD98402_ioctl(struct atm_dev *dev,unsigned int cmd,void __user *arg)
36340
36341
36342 #define ADD_LIMITED(s,v) \
36343 - { atomic_add(GET(v),&PRIV(dev)->sonet_stats.s); \
36344 - if (atomic_read(&PRIV(dev)->sonet_stats.s) < 0) \
36345 - atomic_set(&PRIV(dev)->sonet_stats.s,INT_MAX); }
36346 + { atomic_add_unchecked(GET(v),&PRIV(dev)->sonet_stats.s); \
36347 + if (atomic_read_unchecked(&PRIV(dev)->sonet_stats.s) < 0) \
36348 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.s,INT_MAX); }
36349
36350
36351 static void stat_event(struct atm_dev *dev)
36352 @@ -194,7 +194,7 @@ static void uPD98402_int(struct atm_dev *dev)
36353 if (reason & uPD98402_INT_PFM) stat_event(dev);
36354 if (reason & uPD98402_INT_PCO) {
36355 (void) GET(PCOCR); /* clear interrupt cause */
36356 - atomic_add(GET(HECCT),
36357 + atomic_add_unchecked(GET(HECCT),
36358 &PRIV(dev)->sonet_stats.uncorr_hcs);
36359 }
36360 if ((reason & uPD98402_INT_RFO) &&
36361 @@ -222,9 +222,9 @@ static int uPD98402_start(struct atm_dev *dev)
36362 PUT(~(uPD98402_INT_PFM | uPD98402_INT_ALM | uPD98402_INT_RFO |
36363 uPD98402_INT_LOS),PIMR); /* enable them */
36364 (void) fetch_stats(dev,NULL,1); /* clear kernel counters */
36365 - atomic_set(&PRIV(dev)->sonet_stats.corr_hcs,-1);
36366 - atomic_set(&PRIV(dev)->sonet_stats.tx_cells,-1);
36367 - atomic_set(&PRIV(dev)->sonet_stats.rx_cells,-1);
36368 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.corr_hcs,-1);
36369 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.tx_cells,-1);
36370 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.rx_cells,-1);
36371 return 0;
36372 }
36373
36374 diff --git a/drivers/atm/zatm.c b/drivers/atm/zatm.c
36375 index 969c3c2..9b72956 100644
36376 --- a/drivers/atm/zatm.c
36377 +++ b/drivers/atm/zatm.c
36378 @@ -459,7 +459,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
36379 }
36380 if (!size) {
36381 dev_kfree_skb_irq(skb);
36382 - if (vcc) atomic_inc(&vcc->stats->rx_err);
36383 + if (vcc) atomic_inc_unchecked(&vcc->stats->rx_err);
36384 continue;
36385 }
36386 if (!atm_charge(vcc,skb->truesize)) {
36387 @@ -469,7 +469,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
36388 skb->len = size;
36389 ATM_SKB(skb)->vcc = vcc;
36390 vcc->push(vcc,skb);
36391 - atomic_inc(&vcc->stats->rx);
36392 + atomic_inc_unchecked(&vcc->stats->rx);
36393 }
36394 zout(pos & 0xffff,MTA(mbx));
36395 #if 0 /* probably a stupid idea */
36396 @@ -733,7 +733,7 @@ if (*ZATM_PRV_DSC(skb) != (uPD98401_TXPD_V | uPD98401_TXPD_DP |
36397 skb_queue_head(&zatm_vcc->backlog,skb);
36398 break;
36399 }
36400 - atomic_inc(&vcc->stats->tx);
36401 + atomic_inc_unchecked(&vcc->stats->tx);
36402 wake_up(&zatm_vcc->tx_wait);
36403 }
36404
36405 diff --git a/drivers/base/bus.c b/drivers/base/bus.c
36406 index 4c289ab..de1c333 100644
36407 --- a/drivers/base/bus.c
36408 +++ b/drivers/base/bus.c
36409 @@ -1193,7 +1193,7 @@ int subsys_interface_register(struct subsys_interface *sif)
36410 return -EINVAL;
36411
36412 mutex_lock(&subsys->p->mutex);
36413 - list_add_tail(&sif->node, &subsys->p->interfaces);
36414 + pax_list_add_tail((struct list_head *)&sif->node, &subsys->p->interfaces);
36415 if (sif->add_dev) {
36416 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
36417 while ((dev = subsys_dev_iter_next(&iter)))
36418 @@ -1218,7 +1218,7 @@ void subsys_interface_unregister(struct subsys_interface *sif)
36419 subsys = sif->subsys;
36420
36421 mutex_lock(&subsys->p->mutex);
36422 - list_del_init(&sif->node);
36423 + pax_list_del_init((struct list_head *)&sif->node);
36424 if (sif->remove_dev) {
36425 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
36426 while ((dev = subsys_dev_iter_next(&iter)))
36427 diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c
36428 index 7413d06..79155fa 100644
36429 --- a/drivers/base/devtmpfs.c
36430 +++ b/drivers/base/devtmpfs.c
36431 @@ -354,7 +354,7 @@ int devtmpfs_mount(const char *mntdir)
36432 if (!thread)
36433 return 0;
36434
36435 - err = sys_mount("devtmpfs", (char *)mntdir, "devtmpfs", MS_SILENT, NULL);
36436 + err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)mntdir, (char __force_user *)"devtmpfs", MS_SILENT, NULL);
36437 if (err)
36438 printk(KERN_INFO "devtmpfs: error mounting %i\n", err);
36439 else
36440 @@ -380,11 +380,11 @@ static int devtmpfsd(void *p)
36441 *err = sys_unshare(CLONE_NEWNS);
36442 if (*err)
36443 goto out;
36444 - *err = sys_mount("devtmpfs", "/", "devtmpfs", MS_SILENT, options);
36445 + *err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)"/", (char __force_user *)"devtmpfs", MS_SILENT, (char __force_user *)options);
36446 if (*err)
36447 goto out;
36448 - sys_chdir("/.."); /* will traverse into overmounted root */
36449 - sys_chroot(".");
36450 + sys_chdir((char __force_user *)"/.."); /* will traverse into overmounted root */
36451 + sys_chroot((char __force_user *)".");
36452 complete(&setup_done);
36453 while (1) {
36454 spin_lock(&req_lock);
36455 diff --git a/drivers/base/node.c b/drivers/base/node.c
36456 index bc9f43b..29703b8 100644
36457 --- a/drivers/base/node.c
36458 +++ b/drivers/base/node.c
36459 @@ -620,7 +620,7 @@ static ssize_t print_nodes_state(enum node_states state, char *buf)
36460 struct node_attr {
36461 struct device_attribute attr;
36462 enum node_states state;
36463 -};
36464 +} __do_const;
36465
36466 static ssize_t show_node_state(struct device *dev,
36467 struct device_attribute *attr, char *buf)
36468 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
36469 index bfb8955..42c9b9a 100644
36470 --- a/drivers/base/power/domain.c
36471 +++ b/drivers/base/power/domain.c
36472 @@ -1850,7 +1850,7 @@ int pm_genpd_attach_cpuidle(struct generic_pm_domain *genpd, int state)
36473 {
36474 struct cpuidle_driver *cpuidle_drv;
36475 struct gpd_cpu_data *cpu_data;
36476 - struct cpuidle_state *idle_state;
36477 + cpuidle_state_no_const *idle_state;
36478 int ret = 0;
36479
36480 if (IS_ERR_OR_NULL(genpd) || state < 0)
36481 @@ -1918,7 +1918,7 @@ int pm_genpd_name_attach_cpuidle(const char *name, int state)
36482 int pm_genpd_detach_cpuidle(struct generic_pm_domain *genpd)
36483 {
36484 struct gpd_cpu_data *cpu_data;
36485 - struct cpuidle_state *idle_state;
36486 + cpuidle_state_no_const *idle_state;
36487 int ret = 0;
36488
36489 if (IS_ERR_OR_NULL(genpd))
36490 diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c
36491 index 03e089a..0e9560c 100644
36492 --- a/drivers/base/power/sysfs.c
36493 +++ b/drivers/base/power/sysfs.c
36494 @@ -185,7 +185,7 @@ static ssize_t rtpm_status_show(struct device *dev,
36495 return -EIO;
36496 }
36497 }
36498 - return sprintf(buf, p);
36499 + return sprintf(buf, "%s", p);
36500 }
36501
36502 static DEVICE_ATTR(runtime_status, 0444, rtpm_status_show, NULL);
36503 diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
36504 index 2d56f41..8830f19 100644
36505 --- a/drivers/base/power/wakeup.c
36506 +++ b/drivers/base/power/wakeup.c
36507 @@ -29,14 +29,14 @@ bool events_check_enabled __read_mostly;
36508 * They need to be modified together atomically, so it's better to use one
36509 * atomic variable to hold them both.
36510 */
36511 -static atomic_t combined_event_count = ATOMIC_INIT(0);
36512 +static atomic_unchecked_t combined_event_count = ATOMIC_INIT(0);
36513
36514 #define IN_PROGRESS_BITS (sizeof(int) * 4)
36515 #define MAX_IN_PROGRESS ((1 << IN_PROGRESS_BITS) - 1)
36516
36517 static void split_counters(unsigned int *cnt, unsigned int *inpr)
36518 {
36519 - unsigned int comb = atomic_read(&combined_event_count);
36520 + unsigned int comb = atomic_read_unchecked(&combined_event_count);
36521
36522 *cnt = (comb >> IN_PROGRESS_BITS);
36523 *inpr = comb & MAX_IN_PROGRESS;
36524 @@ -395,7 +395,7 @@ static void wakeup_source_activate(struct wakeup_source *ws)
36525 ws->start_prevent_time = ws->last_time;
36526
36527 /* Increment the counter of events in progress. */
36528 - cec = atomic_inc_return(&combined_event_count);
36529 + cec = atomic_inc_return_unchecked(&combined_event_count);
36530
36531 trace_wakeup_source_activate(ws->name, cec);
36532 }
36533 @@ -521,7 +521,7 @@ static void wakeup_source_deactivate(struct wakeup_source *ws)
36534 * Increment the counter of registered wakeup events and decrement the
36535 * couter of wakeup events in progress simultaneously.
36536 */
36537 - cec = atomic_add_return(MAX_IN_PROGRESS, &combined_event_count);
36538 + cec = atomic_add_return_unchecked(MAX_IN_PROGRESS, &combined_event_count);
36539 trace_wakeup_source_deactivate(ws->name, cec);
36540
36541 split_counters(&cnt, &inpr);
36542 diff --git a/drivers/base/syscore.c b/drivers/base/syscore.c
36543 index e8d11b6..7b1b36f 100644
36544 --- a/drivers/base/syscore.c
36545 +++ b/drivers/base/syscore.c
36546 @@ -21,7 +21,7 @@ static DEFINE_MUTEX(syscore_ops_lock);
36547 void register_syscore_ops(struct syscore_ops *ops)
36548 {
36549 mutex_lock(&syscore_ops_lock);
36550 - list_add_tail(&ops->node, &syscore_ops_list);
36551 + pax_list_add_tail((struct list_head *)&ops->node, &syscore_ops_list);
36552 mutex_unlock(&syscore_ops_lock);
36553 }
36554 EXPORT_SYMBOL_GPL(register_syscore_ops);
36555 @@ -33,7 +33,7 @@ EXPORT_SYMBOL_GPL(register_syscore_ops);
36556 void unregister_syscore_ops(struct syscore_ops *ops)
36557 {
36558 mutex_lock(&syscore_ops_lock);
36559 - list_del(&ops->node);
36560 + pax_list_del((struct list_head *)&ops->node);
36561 mutex_unlock(&syscore_ops_lock);
36562 }
36563 EXPORT_SYMBOL_GPL(unregister_syscore_ops);
36564 diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
36565 index edfa251..1734d4d 100644
36566 --- a/drivers/block/cciss.c
36567 +++ b/drivers/block/cciss.c
36568 @@ -3011,7 +3011,7 @@ static void start_io(ctlr_info_t *h)
36569 while (!list_empty(&h->reqQ)) {
36570 c = list_entry(h->reqQ.next, CommandList_struct, list);
36571 /* can't do anything if fifo is full */
36572 - if ((h->access.fifo_full(h))) {
36573 + if ((h->access->fifo_full(h))) {
36574 dev_warn(&h->pdev->dev, "fifo full\n");
36575 break;
36576 }
36577 @@ -3021,7 +3021,7 @@ static void start_io(ctlr_info_t *h)
36578 h->Qdepth--;
36579
36580 /* Tell the controller execute command */
36581 - h->access.submit_command(h, c);
36582 + h->access->submit_command(h, c);
36583
36584 /* Put job onto the completed Q */
36585 addQ(&h->cmpQ, c);
36586 @@ -3447,17 +3447,17 @@ startio:
36587
36588 static inline unsigned long get_next_completion(ctlr_info_t *h)
36589 {
36590 - return h->access.command_completed(h);
36591 + return h->access->command_completed(h);
36592 }
36593
36594 static inline int interrupt_pending(ctlr_info_t *h)
36595 {
36596 - return h->access.intr_pending(h);
36597 + return h->access->intr_pending(h);
36598 }
36599
36600 static inline long interrupt_not_for_us(ctlr_info_t *h)
36601 {
36602 - return ((h->access.intr_pending(h) == 0) ||
36603 + return ((h->access->intr_pending(h) == 0) ||
36604 (h->interrupts_enabled == 0));
36605 }
36606
36607 @@ -3490,7 +3490,7 @@ static inline u32 next_command(ctlr_info_t *h)
36608 u32 a;
36609
36610 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
36611 - return h->access.command_completed(h);
36612 + return h->access->command_completed(h);
36613
36614 if ((*(h->reply_pool_head) & 1) == (h->reply_pool_wraparound)) {
36615 a = *(h->reply_pool_head); /* Next cmd in ring buffer */
36616 @@ -4047,7 +4047,7 @@ static void cciss_put_controller_into_performant_mode(ctlr_info_t *h)
36617 trans_support & CFGTBL_Trans_use_short_tags);
36618
36619 /* Change the access methods to the performant access methods */
36620 - h->access = SA5_performant_access;
36621 + h->access = &SA5_performant_access;
36622 h->transMethod = CFGTBL_Trans_Performant;
36623
36624 return;
36625 @@ -4327,7 +4327,7 @@ static int cciss_pci_init(ctlr_info_t *h)
36626 if (prod_index < 0)
36627 return -ENODEV;
36628 h->product_name = products[prod_index].product_name;
36629 - h->access = *(products[prod_index].access);
36630 + h->access = products[prod_index].access;
36631
36632 if (cciss_board_disabled(h)) {
36633 dev_warn(&h->pdev->dev, "controller appears to be disabled\n");
36634 @@ -5059,7 +5059,7 @@ reinit_after_soft_reset:
36635 }
36636
36637 /* make sure the board interrupts are off */
36638 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
36639 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
36640 rc = cciss_request_irq(h, do_cciss_msix_intr, do_cciss_intx);
36641 if (rc)
36642 goto clean2;
36643 @@ -5109,7 +5109,7 @@ reinit_after_soft_reset:
36644 * fake ones to scoop up any residual completions.
36645 */
36646 spin_lock_irqsave(&h->lock, flags);
36647 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
36648 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
36649 spin_unlock_irqrestore(&h->lock, flags);
36650 free_irq(h->intr[h->intr_mode], h);
36651 rc = cciss_request_irq(h, cciss_msix_discard_completions,
36652 @@ -5129,9 +5129,9 @@ reinit_after_soft_reset:
36653 dev_info(&h->pdev->dev, "Board READY.\n");
36654 dev_info(&h->pdev->dev,
36655 "Waiting for stale completions to drain.\n");
36656 - h->access.set_intr_mask(h, CCISS_INTR_ON);
36657 + h->access->set_intr_mask(h, CCISS_INTR_ON);
36658 msleep(10000);
36659 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
36660 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
36661
36662 rc = controller_reset_failed(h->cfgtable);
36663 if (rc)
36664 @@ -5154,7 +5154,7 @@ reinit_after_soft_reset:
36665 cciss_scsi_setup(h);
36666
36667 /* Turn the interrupts on so we can service requests */
36668 - h->access.set_intr_mask(h, CCISS_INTR_ON);
36669 + h->access->set_intr_mask(h, CCISS_INTR_ON);
36670
36671 /* Get the firmware version */
36672 inq_buff = kzalloc(sizeof(InquiryData_struct), GFP_KERNEL);
36673 @@ -5226,7 +5226,7 @@ static void cciss_shutdown(struct pci_dev *pdev)
36674 kfree(flush_buf);
36675 if (return_code != IO_OK)
36676 dev_warn(&h->pdev->dev, "Error flushing cache\n");
36677 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
36678 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
36679 free_irq(h->intr[h->intr_mode], h);
36680 }
36681
36682 diff --git a/drivers/block/cciss.h b/drivers/block/cciss.h
36683 index 7fda30e..eb5dfe0 100644
36684 --- a/drivers/block/cciss.h
36685 +++ b/drivers/block/cciss.h
36686 @@ -101,7 +101,7 @@ struct ctlr_info
36687 /* information about each logical volume */
36688 drive_info_struct *drv[CISS_MAX_LUN];
36689
36690 - struct access_method access;
36691 + struct access_method *access;
36692
36693 /* queue and queue Info */
36694 struct list_head reqQ;
36695 diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
36696 index 2b94403..fd6ad1f 100644
36697 --- a/drivers/block/cpqarray.c
36698 +++ b/drivers/block/cpqarray.c
36699 @@ -404,7 +404,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
36700 if (register_blkdev(COMPAQ_SMART2_MAJOR+i, hba[i]->devname)) {
36701 goto Enomem4;
36702 }
36703 - hba[i]->access.set_intr_mask(hba[i], 0);
36704 + hba[i]->access->set_intr_mask(hba[i], 0);
36705 if (request_irq(hba[i]->intr, do_ida_intr,
36706 IRQF_DISABLED|IRQF_SHARED, hba[i]->devname, hba[i]))
36707 {
36708 @@ -459,7 +459,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
36709 add_timer(&hba[i]->timer);
36710
36711 /* Enable IRQ now that spinlock and rate limit timer are set up */
36712 - hba[i]->access.set_intr_mask(hba[i], FIFO_NOT_EMPTY);
36713 + hba[i]->access->set_intr_mask(hba[i], FIFO_NOT_EMPTY);
36714
36715 for(j=0; j<NWD; j++) {
36716 struct gendisk *disk = ida_gendisk[i][j];
36717 @@ -694,7 +694,7 @@ DBGINFO(
36718 for(i=0; i<NR_PRODUCTS; i++) {
36719 if (board_id == products[i].board_id) {
36720 c->product_name = products[i].product_name;
36721 - c->access = *(products[i].access);
36722 + c->access = products[i].access;
36723 break;
36724 }
36725 }
36726 @@ -792,7 +792,7 @@ static int cpqarray_eisa_detect(void)
36727 hba[ctlr]->intr = intr;
36728 sprintf(hba[ctlr]->devname, "ida%d", nr_ctlr);
36729 hba[ctlr]->product_name = products[j].product_name;
36730 - hba[ctlr]->access = *(products[j].access);
36731 + hba[ctlr]->access = products[j].access;
36732 hba[ctlr]->ctlr = ctlr;
36733 hba[ctlr]->board_id = board_id;
36734 hba[ctlr]->pci_dev = NULL; /* not PCI */
36735 @@ -978,7 +978,7 @@ static void start_io(ctlr_info_t *h)
36736
36737 while((c = h->reqQ) != NULL) {
36738 /* Can't do anything if we're busy */
36739 - if (h->access.fifo_full(h) == 0)
36740 + if (h->access->fifo_full(h) == 0)
36741 return;
36742
36743 /* Get the first entry from the request Q */
36744 @@ -986,7 +986,7 @@ static void start_io(ctlr_info_t *h)
36745 h->Qdepth--;
36746
36747 /* Tell the controller to do our bidding */
36748 - h->access.submit_command(h, c);
36749 + h->access->submit_command(h, c);
36750
36751 /* Get onto the completion Q */
36752 addQ(&h->cmpQ, c);
36753 @@ -1048,7 +1048,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
36754 unsigned long flags;
36755 __u32 a,a1;
36756
36757 - istat = h->access.intr_pending(h);
36758 + istat = h->access->intr_pending(h);
36759 /* Is this interrupt for us? */
36760 if (istat == 0)
36761 return IRQ_NONE;
36762 @@ -1059,7 +1059,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
36763 */
36764 spin_lock_irqsave(IDA_LOCK(h->ctlr), flags);
36765 if (istat & FIFO_NOT_EMPTY) {
36766 - while((a = h->access.command_completed(h))) {
36767 + while((a = h->access->command_completed(h))) {
36768 a1 = a; a &= ~3;
36769 if ((c = h->cmpQ) == NULL)
36770 {
36771 @@ -1448,11 +1448,11 @@ static int sendcmd(
36772 /*
36773 * Disable interrupt
36774 */
36775 - info_p->access.set_intr_mask(info_p, 0);
36776 + info_p->access->set_intr_mask(info_p, 0);
36777 /* Make sure there is room in the command FIFO */
36778 /* Actually it should be completely empty at this time. */
36779 for (i = 200000; i > 0; i--) {
36780 - temp = info_p->access.fifo_full(info_p);
36781 + temp = info_p->access->fifo_full(info_p);
36782 if (temp != 0) {
36783 break;
36784 }
36785 @@ -1465,7 +1465,7 @@ DBG(
36786 /*
36787 * Send the cmd
36788 */
36789 - info_p->access.submit_command(info_p, c);
36790 + info_p->access->submit_command(info_p, c);
36791 complete = pollcomplete(ctlr);
36792
36793 pci_unmap_single(info_p->pci_dev, (dma_addr_t) c->req.sg[0].addr,
36794 @@ -1548,9 +1548,9 @@ static int revalidate_allvol(ctlr_info_t *host)
36795 * we check the new geometry. Then turn interrupts back on when
36796 * we're done.
36797 */
36798 - host->access.set_intr_mask(host, 0);
36799 + host->access->set_intr_mask(host, 0);
36800 getgeometry(ctlr);
36801 - host->access.set_intr_mask(host, FIFO_NOT_EMPTY);
36802 + host->access->set_intr_mask(host, FIFO_NOT_EMPTY);
36803
36804 for(i=0; i<NWD; i++) {
36805 struct gendisk *disk = ida_gendisk[ctlr][i];
36806 @@ -1590,7 +1590,7 @@ static int pollcomplete(int ctlr)
36807 /* Wait (up to 2 seconds) for a command to complete */
36808
36809 for (i = 200000; i > 0; i--) {
36810 - done = hba[ctlr]->access.command_completed(hba[ctlr]);
36811 + done = hba[ctlr]->access->command_completed(hba[ctlr]);
36812 if (done == 0) {
36813 udelay(10); /* a short fixed delay */
36814 } else
36815 diff --git a/drivers/block/cpqarray.h b/drivers/block/cpqarray.h
36816 index be73e9d..7fbf140 100644
36817 --- a/drivers/block/cpqarray.h
36818 +++ b/drivers/block/cpqarray.h
36819 @@ -99,7 +99,7 @@ struct ctlr_info {
36820 drv_info_t drv[NWD];
36821 struct proc_dir_entry *proc;
36822
36823 - struct access_method access;
36824 + struct access_method *access;
36825
36826 cmdlist_t *reqQ;
36827 cmdlist_t *cmpQ;
36828 diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h
36829 index 2d7f608..11245fe 100644
36830 --- a/drivers/block/drbd/drbd_int.h
36831 +++ b/drivers/block/drbd/drbd_int.h
36832 @@ -582,7 +582,7 @@ struct drbd_epoch {
36833 struct drbd_tconn *tconn;
36834 struct list_head list;
36835 unsigned int barrier_nr;
36836 - atomic_t epoch_size; /* increased on every request added. */
36837 + atomic_unchecked_t epoch_size; /* increased on every request added. */
36838 atomic_t active; /* increased on every req. added, and dec on every finished. */
36839 unsigned long flags;
36840 };
36841 @@ -1022,7 +1022,7 @@ struct drbd_conf {
36842 unsigned int al_tr_number;
36843 int al_tr_cycle;
36844 wait_queue_head_t seq_wait;
36845 - atomic_t packet_seq;
36846 + atomic_unchecked_t packet_seq;
36847 unsigned int peer_seq;
36848 spinlock_t peer_seq_lock;
36849 unsigned int minor;
36850 @@ -1572,7 +1572,7 @@ static inline int drbd_setsockopt(struct socket *sock, int level, int optname,
36851 char __user *uoptval;
36852 int err;
36853
36854 - uoptval = (char __user __force *)optval;
36855 + uoptval = (char __force_user *)optval;
36856
36857 set_fs(KERNEL_DS);
36858 if (level == SOL_SOCKET)
36859 diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
36860 index 55635ed..40e837c 100644
36861 --- a/drivers/block/drbd/drbd_main.c
36862 +++ b/drivers/block/drbd/drbd_main.c
36863 @@ -1317,7 +1317,7 @@ static int _drbd_send_ack(struct drbd_conf *mdev, enum drbd_packet cmd,
36864 p->sector = sector;
36865 p->block_id = block_id;
36866 p->blksize = blksize;
36867 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
36868 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
36869 return drbd_send_command(mdev, sock, cmd, sizeof(*p), NULL, 0);
36870 }
36871
36872 @@ -1619,7 +1619,7 @@ int drbd_send_dblock(struct drbd_conf *mdev, struct drbd_request *req)
36873 return -EIO;
36874 p->sector = cpu_to_be64(req->i.sector);
36875 p->block_id = (unsigned long)req;
36876 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
36877 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
36878 dp_flags = bio_flags_to_wire(mdev, req->master_bio->bi_rw);
36879 if (mdev->state.conn >= C_SYNC_SOURCE &&
36880 mdev->state.conn <= C_PAUSED_SYNC_T)
36881 @@ -2574,8 +2574,8 @@ void conn_destroy(struct kref *kref)
36882 {
36883 struct drbd_tconn *tconn = container_of(kref, struct drbd_tconn, kref);
36884
36885 - if (atomic_read(&tconn->current_epoch->epoch_size) != 0)
36886 - conn_err(tconn, "epoch_size:%d\n", atomic_read(&tconn->current_epoch->epoch_size));
36887 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size) != 0)
36888 + conn_err(tconn, "epoch_size:%d\n", atomic_read_unchecked(&tconn->current_epoch->epoch_size));
36889 kfree(tconn->current_epoch);
36890
36891 idr_destroy(&tconn->volumes);
36892 diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c
36893 index 8cc1e64..ba7ffa9 100644
36894 --- a/drivers/block/drbd/drbd_nl.c
36895 +++ b/drivers/block/drbd/drbd_nl.c
36896 @@ -3440,7 +3440,7 @@ out:
36897
36898 void drbd_bcast_event(struct drbd_conf *mdev, const struct sib_info *sib)
36899 {
36900 - static atomic_t drbd_genl_seq = ATOMIC_INIT(2); /* two. */
36901 + static atomic_unchecked_t drbd_genl_seq = ATOMIC_INIT(2); /* two. */
36902 struct sk_buff *msg;
36903 struct drbd_genlmsghdr *d_out;
36904 unsigned seq;
36905 @@ -3453,7 +3453,7 @@ void drbd_bcast_event(struct drbd_conf *mdev, const struct sib_info *sib)
36906 return;
36907 }
36908
36909 - seq = atomic_inc_return(&drbd_genl_seq);
36910 + seq = atomic_inc_return_unchecked(&drbd_genl_seq);
36911 msg = genlmsg_new(NLMSG_GOODSIZE, GFP_NOIO);
36912 if (!msg)
36913 goto failed;
36914 diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
36915 index cc29cd3..d4b058b 100644
36916 --- a/drivers/block/drbd/drbd_receiver.c
36917 +++ b/drivers/block/drbd/drbd_receiver.c
36918 @@ -834,7 +834,7 @@ int drbd_connected(struct drbd_conf *mdev)
36919 {
36920 int err;
36921
36922 - atomic_set(&mdev->packet_seq, 0);
36923 + atomic_set_unchecked(&mdev->packet_seq, 0);
36924 mdev->peer_seq = 0;
36925
36926 mdev->state_mutex = mdev->tconn->agreed_pro_version < 100 ?
36927 @@ -1193,7 +1193,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
36928 do {
36929 next_epoch = NULL;
36930
36931 - epoch_size = atomic_read(&epoch->epoch_size);
36932 + epoch_size = atomic_read_unchecked(&epoch->epoch_size);
36933
36934 switch (ev & ~EV_CLEANUP) {
36935 case EV_PUT:
36936 @@ -1233,7 +1233,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
36937 rv = FE_DESTROYED;
36938 } else {
36939 epoch->flags = 0;
36940 - atomic_set(&epoch->epoch_size, 0);
36941 + atomic_set_unchecked(&epoch->epoch_size, 0);
36942 /* atomic_set(&epoch->active, 0); is already zero */
36943 if (rv == FE_STILL_LIVE)
36944 rv = FE_RECYCLED;
36945 @@ -1451,7 +1451,7 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
36946 conn_wait_active_ee_empty(tconn);
36947 drbd_flush(tconn);
36948
36949 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
36950 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
36951 epoch = kmalloc(sizeof(struct drbd_epoch), GFP_NOIO);
36952 if (epoch)
36953 break;
36954 @@ -1464,11 +1464,11 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
36955 }
36956
36957 epoch->flags = 0;
36958 - atomic_set(&epoch->epoch_size, 0);
36959 + atomic_set_unchecked(&epoch->epoch_size, 0);
36960 atomic_set(&epoch->active, 0);
36961
36962 spin_lock(&tconn->epoch_lock);
36963 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
36964 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
36965 list_add(&epoch->list, &tconn->current_epoch->list);
36966 tconn->current_epoch = epoch;
36967 tconn->epochs++;
36968 @@ -2172,7 +2172,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
36969
36970 err = wait_for_and_update_peer_seq(mdev, peer_seq);
36971 drbd_send_ack_dp(mdev, P_NEG_ACK, p, pi->size);
36972 - atomic_inc(&tconn->current_epoch->epoch_size);
36973 + atomic_inc_unchecked(&tconn->current_epoch->epoch_size);
36974 err2 = drbd_drain_block(mdev, pi->size);
36975 if (!err)
36976 err = err2;
36977 @@ -2206,7 +2206,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
36978
36979 spin_lock(&tconn->epoch_lock);
36980 peer_req->epoch = tconn->current_epoch;
36981 - atomic_inc(&peer_req->epoch->epoch_size);
36982 + atomic_inc_unchecked(&peer_req->epoch->epoch_size);
36983 atomic_inc(&peer_req->epoch->active);
36984 spin_unlock(&tconn->epoch_lock);
36985
36986 @@ -4347,7 +4347,7 @@ struct data_cmd {
36987 int expect_payload;
36988 size_t pkt_size;
36989 int (*fn)(struct drbd_tconn *, struct packet_info *);
36990 -};
36991 +} __do_const;
36992
36993 static struct data_cmd drbd_cmd_handler[] = {
36994 [P_DATA] = { 1, sizeof(struct p_data), receive_Data },
36995 @@ -4467,7 +4467,7 @@ static void conn_disconnect(struct drbd_tconn *tconn)
36996 if (!list_empty(&tconn->current_epoch->list))
36997 conn_err(tconn, "ASSERTION FAILED: tconn->current_epoch->list not empty\n");
36998 /* ok, no more ee's on the fly, it is safe to reset the epoch_size */
36999 - atomic_set(&tconn->current_epoch->epoch_size, 0);
37000 + atomic_set_unchecked(&tconn->current_epoch->epoch_size, 0);
37001 tconn->send.seen_any_write_yet = false;
37002
37003 conn_info(tconn, "Connection closed\n");
37004 @@ -5223,7 +5223,7 @@ static int tconn_finish_peer_reqs(struct drbd_tconn *tconn)
37005 struct asender_cmd {
37006 size_t pkt_size;
37007 int (*fn)(struct drbd_tconn *tconn, struct packet_info *);
37008 -};
37009 +} __do_const;
37010
37011 static struct asender_cmd asender_tbl[] = {
37012 [P_PING] = { 0, got_Ping },
37013 diff --git a/drivers/block/loop.c b/drivers/block/loop.c
37014 index c8dac73..1800093 100644
37015 --- a/drivers/block/loop.c
37016 +++ b/drivers/block/loop.c
37017 @@ -232,7 +232,7 @@ static int __do_lo_send_write(struct file *file,
37018
37019 file_start_write(file);
37020 set_fs(get_ds());
37021 - bw = file->f_op->write(file, buf, len, &pos);
37022 + bw = file->f_op->write(file, (const char __force_user *)buf, len, &pos);
37023 set_fs(old_fs);
37024 file_end_write(file);
37025 if (likely(bw == len))
37026 diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
37027 index 5618847..5a46f3b 100644
37028 --- a/drivers/block/pktcdvd.c
37029 +++ b/drivers/block/pktcdvd.c
37030 @@ -108,7 +108,7 @@ static int pkt_seq_show(struct seq_file *m, void *p);
37031
37032 static sector_t get_zone(sector_t sector, struct pktcdvd_device *pd)
37033 {
37034 - return (sector + pd->offset) & ~(sector_t)(pd->settings.size - 1);
37035 + return (sector + pd->offset) & ~(sector_t)(pd->settings.size - 1UL);
37036 }
37037
37038 /*
37039 @@ -1897,7 +1897,7 @@ static noinline_for_stack int pkt_probe_settings(struct pktcdvd_device *pd)
37040 return -EROFS;
37041 }
37042 pd->settings.fp = ti.fp;
37043 - pd->offset = (be32_to_cpu(ti.track_start) << 2) & (pd->settings.size - 1);
37044 + pd->offset = (be32_to_cpu(ti.track_start) << 2) & (pd->settings.size - 1UL);
37045
37046 if (ti.nwa_v) {
37047 pd->nwa = be32_to_cpu(ti.next_writable);
37048 diff --git a/drivers/bluetooth/btwilink.c b/drivers/bluetooth/btwilink.c
37049 index 60abf59..80789e1 100644
37050 --- a/drivers/bluetooth/btwilink.c
37051 +++ b/drivers/bluetooth/btwilink.c
37052 @@ -293,7 +293,7 @@ static int ti_st_send_frame(struct sk_buff *skb)
37053
37054 static int bt_ti_probe(struct platform_device *pdev)
37055 {
37056 - static struct ti_st *hst;
37057 + struct ti_st *hst;
37058 struct hci_dev *hdev;
37059 int err;
37060
37061 diff --git a/drivers/bus/arm-cci.c b/drivers/bus/arm-cci.c
37062 index 2009266..7be9ca2 100644
37063 --- a/drivers/bus/arm-cci.c
37064 +++ b/drivers/bus/arm-cci.c
37065 @@ -405,7 +405,7 @@ static int __init cci_probe(void)
37066
37067 nb_cci_ports = cci_config->nb_ace + cci_config->nb_ace_lite;
37068
37069 - ports = kcalloc(sizeof(*ports), nb_cci_ports, GFP_KERNEL);
37070 + ports = kcalloc(nb_cci_ports, sizeof(*ports), GFP_KERNEL);
37071 if (!ports)
37072 return -ENOMEM;
37073
37074 diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
37075 index 8a3aff7..d7538c2 100644
37076 --- a/drivers/cdrom/cdrom.c
37077 +++ b/drivers/cdrom/cdrom.c
37078 @@ -416,7 +416,6 @@ int register_cdrom(struct cdrom_device_info *cdi)
37079 ENSURE(reset, CDC_RESET);
37080 ENSURE(generic_packet, CDC_GENERIC_PACKET);
37081 cdi->mc_flags = 0;
37082 - cdo->n_minors = 0;
37083 cdi->options = CDO_USE_FFLAGS;
37084
37085 if (autoclose==1 && CDROM_CAN(CDC_CLOSE_TRAY))
37086 @@ -436,8 +435,11 @@ int register_cdrom(struct cdrom_device_info *cdi)
37087 else
37088 cdi->cdda_method = CDDA_OLD;
37089
37090 - if (!cdo->generic_packet)
37091 - cdo->generic_packet = cdrom_dummy_generic_packet;
37092 + if (!cdo->generic_packet) {
37093 + pax_open_kernel();
37094 + *(void **)&cdo->generic_packet = cdrom_dummy_generic_packet;
37095 + pax_close_kernel();
37096 + }
37097
37098 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" registered\n", cdi->name);
37099 mutex_lock(&cdrom_mutex);
37100 @@ -458,7 +460,6 @@ void unregister_cdrom(struct cdrom_device_info *cdi)
37101 if (cdi->exit)
37102 cdi->exit(cdi);
37103
37104 - cdi->ops->n_minors--;
37105 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" unregistered\n", cdi->name);
37106 }
37107
37108 @@ -2107,7 +2108,7 @@ static int cdrom_read_cdda_old(struct cdrom_device_info *cdi, __u8 __user *ubuf,
37109 */
37110 nr = nframes;
37111 do {
37112 - cgc.buffer = kmalloc(CD_FRAMESIZE_RAW * nr, GFP_KERNEL);
37113 + cgc.buffer = kzalloc(CD_FRAMESIZE_RAW * nr, GFP_KERNEL);
37114 if (cgc.buffer)
37115 break;
37116
37117 @@ -3429,7 +3430,7 @@ static int cdrom_print_info(const char *header, int val, char *info,
37118 struct cdrom_device_info *cdi;
37119 int ret;
37120
37121 - ret = scnprintf(info + *pos, max_size - *pos, header);
37122 + ret = scnprintf(info + *pos, max_size - *pos, "%s", header);
37123 if (!ret)
37124 return 1;
37125
37126 diff --git a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c
37127 index 5980cb9..6d7bd7e 100644
37128 --- a/drivers/cdrom/gdrom.c
37129 +++ b/drivers/cdrom/gdrom.c
37130 @@ -491,7 +491,6 @@ static struct cdrom_device_ops gdrom_ops = {
37131 .audio_ioctl = gdrom_audio_ioctl,
37132 .capability = CDC_MULTI_SESSION | CDC_MEDIA_CHANGED |
37133 CDC_RESET | CDC_DRIVE_STATUS | CDC_CD_R,
37134 - .n_minors = 1,
37135 };
37136
37137 static int gdrom_bdops_open(struct block_device *bdev, fmode_t mode)
37138 diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
37139 index 1421997..33f5d6d 100644
37140 --- a/drivers/char/Kconfig
37141 +++ b/drivers/char/Kconfig
37142 @@ -8,7 +8,8 @@ source "drivers/tty/Kconfig"
37143
37144 config DEVKMEM
37145 bool "/dev/kmem virtual device support"
37146 - default y
37147 + default n
37148 + depends on !GRKERNSEC_KMEM
37149 help
37150 Say Y here if you want to support the /dev/kmem device. The
37151 /dev/kmem device is rarely used, but can be used for certain
37152 @@ -570,6 +571,7 @@ config DEVPORT
37153 bool
37154 depends on !M68K
37155 depends on ISA || PCI
37156 + depends on !GRKERNSEC_KMEM
37157 default y
37158
37159 source "drivers/s390/char/Kconfig"
37160 diff --git a/drivers/char/agp/compat_ioctl.c b/drivers/char/agp/compat_ioctl.c
37161 index a48e05b..6bac831 100644
37162 --- a/drivers/char/agp/compat_ioctl.c
37163 +++ b/drivers/char/agp/compat_ioctl.c
37164 @@ -108,7 +108,7 @@ static int compat_agpioc_reserve_wrap(struct agp_file_private *priv, void __user
37165 return -ENOMEM;
37166 }
37167
37168 - if (copy_from_user(usegment, (void __user *) ureserve.seg_list,
37169 + if (copy_from_user(usegment, (void __force_user *) ureserve.seg_list,
37170 sizeof(*usegment) * ureserve.seg_count)) {
37171 kfree(usegment);
37172 kfree(ksegment);
37173 diff --git a/drivers/char/agp/frontend.c b/drivers/char/agp/frontend.c
37174 index 1b19239..b87b143 100644
37175 --- a/drivers/char/agp/frontend.c
37176 +++ b/drivers/char/agp/frontend.c
37177 @@ -819,7 +819,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
37178 if (copy_from_user(&reserve, arg, sizeof(struct agp_region)))
37179 return -EFAULT;
37180
37181 - if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment))
37182 + if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment_priv))
37183 return -EFAULT;
37184
37185 client = agp_find_client_by_pid(reserve.pid);
37186 @@ -849,7 +849,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
37187 if (segment == NULL)
37188 return -ENOMEM;
37189
37190 - if (copy_from_user(segment, (void __user *) reserve.seg_list,
37191 + if (copy_from_user(segment, (void __force_user *) reserve.seg_list,
37192 sizeof(struct agp_segment) * reserve.seg_count)) {
37193 kfree(segment);
37194 return -EFAULT;
37195 diff --git a/drivers/char/genrtc.c b/drivers/char/genrtc.c
37196 index 4f94375..413694e 100644
37197 --- a/drivers/char/genrtc.c
37198 +++ b/drivers/char/genrtc.c
37199 @@ -273,6 +273,7 @@ static int gen_rtc_ioctl(struct file *file,
37200 switch (cmd) {
37201
37202 case RTC_PLL_GET:
37203 + memset(&pll, 0, sizeof(pll));
37204 if (get_rtc_pll(&pll))
37205 return -EINVAL;
37206 else
37207 diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
37208 index 448ce5e..3a76625 100644
37209 --- a/drivers/char/hpet.c
37210 +++ b/drivers/char/hpet.c
37211 @@ -559,7 +559,7 @@ static inline unsigned long hpet_time_div(struct hpets *hpets,
37212 }
37213
37214 static int
37215 -hpet_ioctl_common(struct hpet_dev *devp, int cmd, unsigned long arg,
37216 +hpet_ioctl_common(struct hpet_dev *devp, unsigned int cmd, unsigned long arg,
37217 struct hpet_info *info)
37218 {
37219 struct hpet_timer __iomem *timer;
37220 diff --git a/drivers/char/hw_random/intel-rng.c b/drivers/char/hw_random/intel-rng.c
37221 index 86fe45c..c0ea948 100644
37222 --- a/drivers/char/hw_random/intel-rng.c
37223 +++ b/drivers/char/hw_random/intel-rng.c
37224 @@ -314,7 +314,7 @@ PFX "RNG, try using the 'no_fwh_detect' option.\n";
37225
37226 if (no_fwh_detect)
37227 return -ENODEV;
37228 - printk(warning);
37229 + printk("%s", warning);
37230 return -EBUSY;
37231 }
37232
37233 diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
37234 index ec4e10f..f2a763b 100644
37235 --- a/drivers/char/ipmi/ipmi_msghandler.c
37236 +++ b/drivers/char/ipmi/ipmi_msghandler.c
37237 @@ -420,7 +420,7 @@ struct ipmi_smi {
37238 struct proc_dir_entry *proc_dir;
37239 char proc_dir_name[10];
37240
37241 - atomic_t stats[IPMI_NUM_STATS];
37242 + atomic_unchecked_t stats[IPMI_NUM_STATS];
37243
37244 /*
37245 * run_to_completion duplicate of smb_info, smi_info
37246 @@ -453,9 +453,9 @@ static DEFINE_MUTEX(smi_watchers_mutex);
37247
37248
37249 #define ipmi_inc_stat(intf, stat) \
37250 - atomic_inc(&(intf)->stats[IPMI_STAT_ ## stat])
37251 + atomic_inc_unchecked(&(intf)->stats[IPMI_STAT_ ## stat])
37252 #define ipmi_get_stat(intf, stat) \
37253 - ((unsigned int) atomic_read(&(intf)->stats[IPMI_STAT_ ## stat]))
37254 + ((unsigned int) atomic_read_unchecked(&(intf)->stats[IPMI_STAT_ ## stat]))
37255
37256 static int is_lan_addr(struct ipmi_addr *addr)
37257 {
37258 @@ -2883,7 +2883,7 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
37259 INIT_LIST_HEAD(&intf->cmd_rcvrs);
37260 init_waitqueue_head(&intf->waitq);
37261 for (i = 0; i < IPMI_NUM_STATS; i++)
37262 - atomic_set(&intf->stats[i], 0);
37263 + atomic_set_unchecked(&intf->stats[i], 0);
37264
37265 intf->proc_dir = NULL;
37266
37267 diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
37268 index 15e4a60..b046093 100644
37269 --- a/drivers/char/ipmi/ipmi_si_intf.c
37270 +++ b/drivers/char/ipmi/ipmi_si_intf.c
37271 @@ -280,7 +280,7 @@ struct smi_info {
37272 unsigned char slave_addr;
37273
37274 /* Counters and things for the proc filesystem. */
37275 - atomic_t stats[SI_NUM_STATS];
37276 + atomic_unchecked_t stats[SI_NUM_STATS];
37277
37278 struct task_struct *thread;
37279
37280 @@ -289,9 +289,9 @@ struct smi_info {
37281 };
37282
37283 #define smi_inc_stat(smi, stat) \
37284 - atomic_inc(&(smi)->stats[SI_STAT_ ## stat])
37285 + atomic_inc_unchecked(&(smi)->stats[SI_STAT_ ## stat])
37286 #define smi_get_stat(smi, stat) \
37287 - ((unsigned int) atomic_read(&(smi)->stats[SI_STAT_ ## stat]))
37288 + ((unsigned int) atomic_read_unchecked(&(smi)->stats[SI_STAT_ ## stat]))
37289
37290 #define SI_MAX_PARMS 4
37291
37292 @@ -3324,7 +3324,7 @@ static int try_smi_init(struct smi_info *new_smi)
37293 atomic_set(&new_smi->req_events, 0);
37294 new_smi->run_to_completion = 0;
37295 for (i = 0; i < SI_NUM_STATS; i++)
37296 - atomic_set(&new_smi->stats[i], 0);
37297 + atomic_set_unchecked(&new_smi->stats[i], 0);
37298
37299 new_smi->interrupt_disabled = 1;
37300 atomic_set(&new_smi->stop_operation, 0);
37301 diff --git a/drivers/char/mem.c b/drivers/char/mem.c
37302 index f895a8c..2bc9147 100644
37303 --- a/drivers/char/mem.c
37304 +++ b/drivers/char/mem.c
37305 @@ -18,6 +18,7 @@
37306 #include <linux/raw.h>
37307 #include <linux/tty.h>
37308 #include <linux/capability.h>
37309 +#include <linux/security.h>
37310 #include <linux/ptrace.h>
37311 #include <linux/device.h>
37312 #include <linux/highmem.h>
37313 @@ -37,6 +38,10 @@
37314
37315 #define DEVPORT_MINOR 4
37316
37317 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
37318 +extern const struct file_operations grsec_fops;
37319 +#endif
37320 +
37321 static inline unsigned long size_inside_page(unsigned long start,
37322 unsigned long size)
37323 {
37324 @@ -68,9 +73,13 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
37325
37326 while (cursor < to) {
37327 if (!devmem_is_allowed(pfn)) {
37328 +#ifdef CONFIG_GRKERNSEC_KMEM
37329 + gr_handle_mem_readwrite(from, to);
37330 +#else
37331 printk(KERN_INFO
37332 "Program %s tried to access /dev/mem between %Lx->%Lx.\n",
37333 current->comm, from, to);
37334 +#endif
37335 return 0;
37336 }
37337 cursor += PAGE_SIZE;
37338 @@ -78,6 +87,11 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
37339 }
37340 return 1;
37341 }
37342 +#elif defined(CONFIG_GRKERNSEC_KMEM)
37343 +static inline int range_is_allowed(unsigned long pfn, unsigned long size)
37344 +{
37345 + return 0;
37346 +}
37347 #else
37348 static inline int range_is_allowed(unsigned long pfn, unsigned long size)
37349 {
37350 @@ -120,6 +134,7 @@ static ssize_t read_mem(struct file *file, char __user *buf,
37351
37352 while (count > 0) {
37353 unsigned long remaining;
37354 + char *temp;
37355
37356 sz = size_inside_page(p, count);
37357
37358 @@ -135,7 +150,23 @@ static ssize_t read_mem(struct file *file, char __user *buf,
37359 if (!ptr)
37360 return -EFAULT;
37361
37362 - remaining = copy_to_user(buf, ptr, sz);
37363 +#ifdef CONFIG_PAX_USERCOPY
37364 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
37365 + if (!temp) {
37366 + unxlate_dev_mem_ptr(p, ptr);
37367 + return -ENOMEM;
37368 + }
37369 + memcpy(temp, ptr, sz);
37370 +#else
37371 + temp = ptr;
37372 +#endif
37373 +
37374 + remaining = copy_to_user(buf, temp, sz);
37375 +
37376 +#ifdef CONFIG_PAX_USERCOPY
37377 + kfree(temp);
37378 +#endif
37379 +
37380 unxlate_dev_mem_ptr(p, ptr);
37381 if (remaining)
37382 return -EFAULT;
37383 @@ -364,9 +395,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
37384 size_t count, loff_t *ppos)
37385 {
37386 unsigned long p = *ppos;
37387 - ssize_t low_count, read, sz;
37388 + ssize_t low_count, read, sz, err = 0;
37389 char *kbuf; /* k-addr because vread() takes vmlist_lock rwlock */
37390 - int err = 0;
37391
37392 read = 0;
37393 if (p < (unsigned long) high_memory) {
37394 @@ -388,6 +418,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
37395 }
37396 #endif
37397 while (low_count > 0) {
37398 + char *temp;
37399 +
37400 sz = size_inside_page(p, low_count);
37401
37402 /*
37403 @@ -397,7 +429,22 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
37404 */
37405 kbuf = xlate_dev_kmem_ptr((char *)p);
37406
37407 - if (copy_to_user(buf, kbuf, sz))
37408 +#ifdef CONFIG_PAX_USERCOPY
37409 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
37410 + if (!temp)
37411 + return -ENOMEM;
37412 + memcpy(temp, kbuf, sz);
37413 +#else
37414 + temp = kbuf;
37415 +#endif
37416 +
37417 + err = copy_to_user(buf, temp, sz);
37418 +
37419 +#ifdef CONFIG_PAX_USERCOPY
37420 + kfree(temp);
37421 +#endif
37422 +
37423 + if (err)
37424 return -EFAULT;
37425 buf += sz;
37426 p += sz;
37427 @@ -822,6 +869,9 @@ static const struct memdev {
37428 #ifdef CONFIG_PRINTK
37429 [11] = { "kmsg", 0644, &kmsg_fops, NULL },
37430 #endif
37431 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
37432 + [13] = { "grsec",S_IRUSR | S_IWUGO, &grsec_fops, NULL },
37433 +#endif
37434 };
37435
37436 static int memory_open(struct inode *inode, struct file *filp)
37437 @@ -893,7 +943,7 @@ static int __init chr_dev_init(void)
37438 continue;
37439
37440 device_create(mem_class, NULL, MKDEV(MEM_MAJOR, minor),
37441 - NULL, devlist[minor].name);
37442 + NULL, "%s", devlist[minor].name);
37443 }
37444
37445 return tty_init();
37446 diff --git a/drivers/char/nvram.c b/drivers/char/nvram.c
37447 index 9df78e2..01ba9ae 100644
37448 --- a/drivers/char/nvram.c
37449 +++ b/drivers/char/nvram.c
37450 @@ -247,7 +247,7 @@ static ssize_t nvram_read(struct file *file, char __user *buf,
37451
37452 spin_unlock_irq(&rtc_lock);
37453
37454 - if (copy_to_user(buf, contents, tmp - contents))
37455 + if (tmp - contents > sizeof(contents) || copy_to_user(buf, contents, tmp - contents))
37456 return -EFAULT;
37457
37458 *ppos = i;
37459 diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
37460 index d39cca6..8c1e269 100644
37461 --- a/drivers/char/pcmcia/synclink_cs.c
37462 +++ b/drivers/char/pcmcia/synclink_cs.c
37463 @@ -2345,9 +2345,9 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
37464
37465 if (debug_level >= DEBUG_LEVEL_INFO)
37466 printk("%s(%d):mgslpc_close(%s) entry, count=%d\n",
37467 - __FILE__, __LINE__, info->device_name, port->count);
37468 + __FILE__, __LINE__, info->device_name, atomic_read(&port->count));
37469
37470 - WARN_ON(!port->count);
37471 + WARN_ON(!atomic_read(&port->count));
37472
37473 if (tty_port_close_start(port, tty, filp) == 0)
37474 goto cleanup;
37475 @@ -2365,7 +2365,7 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
37476 cleanup:
37477 if (debug_level >= DEBUG_LEVEL_INFO)
37478 printk("%s(%d):mgslpc_close(%s) exit, count=%d\n", __FILE__, __LINE__,
37479 - tty->driver->name, port->count);
37480 + tty->driver->name, atomic_read(&port->count));
37481 }
37482
37483 /* Wait until the transmitter is empty.
37484 @@ -2507,7 +2507,7 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
37485
37486 if (debug_level >= DEBUG_LEVEL_INFO)
37487 printk("%s(%d):mgslpc_open(%s), old ref count = %d\n",
37488 - __FILE__, __LINE__, tty->driver->name, port->count);
37489 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
37490
37491 /* If port is closing, signal caller to try again */
37492 if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING){
37493 @@ -2527,11 +2527,11 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
37494 goto cleanup;
37495 }
37496 spin_lock(&port->lock);
37497 - port->count++;
37498 + atomic_inc(&port->count);
37499 spin_unlock(&port->lock);
37500 spin_unlock_irqrestore(&info->netlock, flags);
37501
37502 - if (port->count == 1) {
37503 + if (atomic_read(&port->count) == 1) {
37504 /* 1st open on this device, init hardware */
37505 retval = startup(info, tty);
37506 if (retval < 0)
37507 @@ -3920,7 +3920,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
37508 unsigned short new_crctype;
37509
37510 /* return error if TTY interface open */
37511 - if (info->port.count)
37512 + if (atomic_read(&info->port.count))
37513 return -EBUSY;
37514
37515 switch (encoding)
37516 @@ -4024,7 +4024,7 @@ static int hdlcdev_open(struct net_device *dev)
37517
37518 /* arbitrate between network and tty opens */
37519 spin_lock_irqsave(&info->netlock, flags);
37520 - if (info->port.count != 0 || info->netcount != 0) {
37521 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
37522 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
37523 spin_unlock_irqrestore(&info->netlock, flags);
37524 return -EBUSY;
37525 @@ -4114,7 +4114,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
37526 printk("%s:hdlcdev_ioctl(%s)\n", __FILE__, dev->name);
37527
37528 /* return error if TTY interface open */
37529 - if (info->port.count)
37530 + if (atomic_read(&info->port.count))
37531 return -EBUSY;
37532
37533 if (cmd != SIOCWANDEV)
37534 diff --git a/drivers/char/random.c b/drivers/char/random.c
37535 index 7a744d3..35a177ee 100644
37536 --- a/drivers/char/random.c
37537 +++ b/drivers/char/random.c
37538 @@ -269,8 +269,13 @@
37539 /*
37540 * Configuration information
37541 */
37542 +#ifdef CONFIG_GRKERNSEC_RANDNET
37543 +#define INPUT_POOL_WORDS 512
37544 +#define OUTPUT_POOL_WORDS 128
37545 +#else
37546 #define INPUT_POOL_WORDS 128
37547 #define OUTPUT_POOL_WORDS 32
37548 +#endif
37549 #define SEC_XFER_SIZE 512
37550 #define EXTRACT_SIZE 10
37551
37552 @@ -310,10 +315,17 @@ static struct poolinfo {
37553 int poolwords;
37554 int tap1, tap2, tap3, tap4, tap5;
37555 } poolinfo_table[] = {
37556 +#ifdef CONFIG_GRKERNSEC_RANDNET
37557 + /* x^512 + x^411 + x^308 + x^208 +x^104 + x + 1 -- 225 */
37558 + { 512, 411, 308, 208, 104, 1 },
37559 + /* x^128 + x^103 + x^76 + x^51 + x^25 + x + 1 -- 105 */
37560 + { 128, 103, 76, 51, 25, 1 },
37561 +#else
37562 /* x^128 + x^103 + x^76 + x^51 +x^25 + x + 1 -- 105 */
37563 { 128, 103, 76, 51, 25, 1 },
37564 /* x^32 + x^26 + x^20 + x^14 + x^7 + x + 1 -- 15 */
37565 { 32, 26, 20, 14, 7, 1 },
37566 +#endif
37567 #if 0
37568 /* x^2048 + x^1638 + x^1231 + x^819 + x^411 + x + 1 -- 115 */
37569 { 2048, 1638, 1231, 819, 411, 1 },
37570 @@ -521,8 +533,8 @@ static void _mix_pool_bytes(struct entropy_store *r, const void *in,
37571 input_rotate += i ? 7 : 14;
37572 }
37573
37574 - ACCESS_ONCE(r->input_rotate) = input_rotate;
37575 - ACCESS_ONCE(r->add_ptr) = i;
37576 + ACCESS_ONCE_RW(r->input_rotate) = input_rotate;
37577 + ACCESS_ONCE_RW(r->add_ptr) = i;
37578 smp_wmb();
37579
37580 if (out)
37581 @@ -1029,7 +1041,7 @@ static ssize_t extract_entropy_user(struct entropy_store *r, void __user *buf,
37582
37583 extract_buf(r, tmp);
37584 i = min_t(int, nbytes, EXTRACT_SIZE);
37585 - if (copy_to_user(buf, tmp, i)) {
37586 + if (i > sizeof(tmp) || copy_to_user(buf, tmp, i)) {
37587 ret = -EFAULT;
37588 break;
37589 }
37590 @@ -1365,7 +1377,7 @@ EXPORT_SYMBOL(generate_random_uuid);
37591 #include <linux/sysctl.h>
37592
37593 static int min_read_thresh = 8, min_write_thresh;
37594 -static int max_read_thresh = INPUT_POOL_WORDS * 32;
37595 +static int max_read_thresh = OUTPUT_POOL_WORDS * 32;
37596 static int max_write_thresh = INPUT_POOL_WORDS * 32;
37597 static char sysctl_bootid[16];
37598
37599 @@ -1381,7 +1393,7 @@ static char sysctl_bootid[16];
37600 static int proc_do_uuid(struct ctl_table *table, int write,
37601 void __user *buffer, size_t *lenp, loff_t *ppos)
37602 {
37603 - struct ctl_table fake_table;
37604 + ctl_table_no_const fake_table;
37605 unsigned char buf[64], tmp_uuid[16], *uuid;
37606
37607 uuid = table->data;
37608 diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c
37609 index 7cc1fe22..b602d6b 100644
37610 --- a/drivers/char/sonypi.c
37611 +++ b/drivers/char/sonypi.c
37612 @@ -54,6 +54,7 @@
37613
37614 #include <asm/uaccess.h>
37615 #include <asm/io.h>
37616 +#include <asm/local.h>
37617
37618 #include <linux/sonypi.h>
37619
37620 @@ -490,7 +491,7 @@ static struct sonypi_device {
37621 spinlock_t fifo_lock;
37622 wait_queue_head_t fifo_proc_list;
37623 struct fasync_struct *fifo_async;
37624 - int open_count;
37625 + local_t open_count;
37626 int model;
37627 struct input_dev *input_jog_dev;
37628 struct input_dev *input_key_dev;
37629 @@ -892,7 +893,7 @@ static int sonypi_misc_fasync(int fd, struct file *filp, int on)
37630 static int sonypi_misc_release(struct inode *inode, struct file *file)
37631 {
37632 mutex_lock(&sonypi_device.lock);
37633 - sonypi_device.open_count--;
37634 + local_dec(&sonypi_device.open_count);
37635 mutex_unlock(&sonypi_device.lock);
37636 return 0;
37637 }
37638 @@ -901,9 +902,9 @@ static int sonypi_misc_open(struct inode *inode, struct file *file)
37639 {
37640 mutex_lock(&sonypi_device.lock);
37641 /* Flush input queue on first open */
37642 - if (!sonypi_device.open_count)
37643 + if (!local_read(&sonypi_device.open_count))
37644 kfifo_reset(&sonypi_device.fifo);
37645 - sonypi_device.open_count++;
37646 + local_inc(&sonypi_device.open_count);
37647 mutex_unlock(&sonypi_device.lock);
37648
37649 return 0;
37650 diff --git a/drivers/char/tpm/tpm_acpi.c b/drivers/char/tpm/tpm_acpi.c
37651 index 64420b3..5c40b56 100644
37652 --- a/drivers/char/tpm/tpm_acpi.c
37653 +++ b/drivers/char/tpm/tpm_acpi.c
37654 @@ -98,11 +98,12 @@ int read_log(struct tpm_bios_log *log)
37655 virt = acpi_os_map_memory(start, len);
37656 if (!virt) {
37657 kfree(log->bios_event_log);
37658 + log->bios_event_log = NULL;
37659 printk("%s: ERROR - Unable to map memory\n", __func__);
37660 return -EIO;
37661 }
37662
37663 - memcpy_fromio(log->bios_event_log, virt, len);
37664 + memcpy_fromio(log->bios_event_log, (const char __force_kernel *)virt, len);
37665
37666 acpi_os_unmap_memory(virt, len);
37667 return 0;
37668 diff --git a/drivers/char/tpm/tpm_eventlog.c b/drivers/char/tpm/tpm_eventlog.c
37669 index 84ddc55..1d32f1e 100644
37670 --- a/drivers/char/tpm/tpm_eventlog.c
37671 +++ b/drivers/char/tpm/tpm_eventlog.c
37672 @@ -95,7 +95,7 @@ static void *tpm_bios_measurements_start(struct seq_file *m, loff_t *pos)
37673 event = addr;
37674
37675 if ((event->event_type == 0 && event->event_size == 0) ||
37676 - ((addr + sizeof(struct tcpa_event) + event->event_size) >= limit))
37677 + (event->event_size >= limit - addr - sizeof(struct tcpa_event)))
37678 return NULL;
37679
37680 return addr;
37681 @@ -120,7 +120,7 @@ static void *tpm_bios_measurements_next(struct seq_file *m, void *v,
37682 return NULL;
37683
37684 if ((event->event_type == 0 && event->event_size == 0) ||
37685 - ((v + sizeof(struct tcpa_event) + event->event_size) >= limit))
37686 + (event->event_size >= limit - v - sizeof(struct tcpa_event)))
37687 return NULL;
37688
37689 (*pos)++;
37690 @@ -213,7 +213,8 @@ static int tpm_binary_bios_measurements_show(struct seq_file *m, void *v)
37691 int i;
37692
37693 for (i = 0; i < sizeof(struct tcpa_event) + event->event_size; i++)
37694 - seq_putc(m, data[i]);
37695 + if (!seq_putc(m, data[i]))
37696 + return -EFAULT;
37697
37698 return 0;
37699 }
37700 diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
37701 index b79cf3e..de172d64f 100644
37702 --- a/drivers/char/virtio_console.c
37703 +++ b/drivers/char/virtio_console.c
37704 @@ -682,7 +682,7 @@ static ssize_t fill_readbuf(struct port *port, char *out_buf, size_t out_count,
37705 if (to_user) {
37706 ssize_t ret;
37707
37708 - ret = copy_to_user(out_buf, buf->buf + buf->offset, out_count);
37709 + ret = copy_to_user((char __force_user *)out_buf, buf->buf + buf->offset, out_count);
37710 if (ret)
37711 return -EFAULT;
37712 } else {
37713 @@ -785,7 +785,7 @@ static ssize_t port_fops_read(struct file *filp, char __user *ubuf,
37714 if (!port_has_data(port) && !port->host_connected)
37715 return 0;
37716
37717 - return fill_readbuf(port, ubuf, count, true);
37718 + return fill_readbuf(port, (char __force_kernel *)ubuf, count, true);
37719 }
37720
37721 static int wait_port_writable(struct port *port, bool nonblock)
37722 diff --git a/drivers/clk/clk-composite.c b/drivers/clk/clk-composite.c
37723 index a33f46f..a720eed 100644
37724 --- a/drivers/clk/clk-composite.c
37725 +++ b/drivers/clk/clk-composite.c
37726 @@ -122,7 +122,7 @@ struct clk *clk_register_composite(struct device *dev, const char *name,
37727 struct clk *clk;
37728 struct clk_init_data init;
37729 struct clk_composite *composite;
37730 - struct clk_ops *clk_composite_ops;
37731 + clk_ops_no_const *clk_composite_ops;
37732
37733 composite = kzalloc(sizeof(*composite), GFP_KERNEL);
37734 if (!composite) {
37735 diff --git a/drivers/clk/socfpga/clk.c b/drivers/clk/socfpga/clk.c
37736 index 81dd31a..ef5c542 100644
37737 --- a/drivers/clk/socfpga/clk.c
37738 +++ b/drivers/clk/socfpga/clk.c
37739 @@ -22,6 +22,7 @@
37740 #include <linux/clk-provider.h>
37741 #include <linux/io.h>
37742 #include <linux/of.h>
37743 +#include <asm/pgtable.h>
37744
37745 /* Clock Manager offsets */
37746 #define CLKMGR_CTRL 0x0
37747 @@ -152,8 +153,10 @@ static __init struct clk *socfpga_clk_init(struct device_node *node,
37748 streq(clk_name, "periph_pll") ||
37749 streq(clk_name, "sdram_pll")) {
37750 socfpga_clk->hw.bit_idx = SOCFPGA_PLL_EXT_ENA;
37751 - clk_pll_ops.enable = clk_gate_ops.enable;
37752 - clk_pll_ops.disable = clk_gate_ops.disable;
37753 + pax_open_kernel();
37754 + *(void **)&clk_pll_ops.enable = clk_gate_ops.enable;
37755 + *(void **)&clk_pll_ops.disable = clk_gate_ops.disable;
37756 + pax_close_kernel();
37757 }
37758
37759 clk = clk_register(NULL, &socfpga_clk->hw.hw);
37760 @@ -244,7 +247,7 @@ static unsigned long socfpga_clk_recalc_rate(struct clk_hw *hwclk,
37761 return parent_rate / div;
37762 }
37763
37764 -static struct clk_ops gateclk_ops = {
37765 +static clk_ops_no_const gateclk_ops __read_only = {
37766 .recalc_rate = socfpga_clk_recalc_rate,
37767 .get_parent = socfpga_clk_get_parent,
37768 .set_parent = socfpga_clk_set_parent,
37769 diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
37770 index 506fd23..01a593f 100644
37771 --- a/drivers/cpufreq/acpi-cpufreq.c
37772 +++ b/drivers/cpufreq/acpi-cpufreq.c
37773 @@ -172,7 +172,7 @@ static ssize_t show_global_boost(struct kobject *kobj,
37774 return sprintf(buf, "%u\n", boost_enabled);
37775 }
37776
37777 -static struct global_attr global_boost = __ATTR(boost, 0644,
37778 +static global_attr_no_const global_boost = __ATTR(boost, 0644,
37779 show_global_boost,
37780 store_global_boost);
37781
37782 @@ -721,8 +721,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
37783 data->acpi_data = per_cpu_ptr(acpi_perf_data, cpu);
37784 per_cpu(acfreq_data, cpu) = data;
37785
37786 - if (cpu_has(c, X86_FEATURE_CONSTANT_TSC))
37787 - acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
37788 + if (cpu_has(c, X86_FEATURE_CONSTANT_TSC)) {
37789 + pax_open_kernel();
37790 + *(u8 *)&acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
37791 + pax_close_kernel();
37792 + }
37793
37794 result = acpi_processor_register_performance(data->acpi_data, cpu);
37795 if (result)
37796 @@ -850,7 +853,9 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
37797 policy->cur = acpi_cpufreq_guess_freq(data, policy->cpu);
37798 break;
37799 case ACPI_ADR_SPACE_FIXED_HARDWARE:
37800 - acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
37801 + pax_open_kernel();
37802 + *(void **)&acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
37803 + pax_close_kernel();
37804 policy->cur = get_cur_freq_on_cpu(cpu);
37805 break;
37806 default:
37807 diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
37808 index 04548f7..457a342 100644
37809 --- a/drivers/cpufreq/cpufreq.c
37810 +++ b/drivers/cpufreq/cpufreq.c
37811 @@ -2069,7 +2069,7 @@ static int cpufreq_cpu_callback(struct notifier_block *nfb,
37812 return NOTIFY_OK;
37813 }
37814
37815 -static struct notifier_block __refdata cpufreq_cpu_notifier = {
37816 +static struct notifier_block cpufreq_cpu_notifier = {
37817 .notifier_call = cpufreq_cpu_callback,
37818 };
37819
37820 @@ -2101,8 +2101,11 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
37821
37822 pr_debug("trying to register driver %s\n", driver_data->name);
37823
37824 - if (driver_data->setpolicy)
37825 - driver_data->flags |= CPUFREQ_CONST_LOOPS;
37826 + if (driver_data->setpolicy) {
37827 + pax_open_kernel();
37828 + *(u8 *)&driver_data->flags |= CPUFREQ_CONST_LOOPS;
37829 + pax_close_kernel();
37830 + }
37831
37832 write_lock_irqsave(&cpufreq_driver_lock, flags);
37833 if (cpufreq_driver) {
37834 diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c
37835 index 0806c31..6a73276 100644
37836 --- a/drivers/cpufreq/cpufreq_governor.c
37837 +++ b/drivers/cpufreq/cpufreq_governor.c
37838 @@ -187,7 +187,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
37839 struct dbs_data *dbs_data;
37840 struct od_cpu_dbs_info_s *od_dbs_info = NULL;
37841 struct cs_cpu_dbs_info_s *cs_dbs_info = NULL;
37842 - struct od_ops *od_ops = NULL;
37843 + const struct od_ops *od_ops = NULL;
37844 struct od_dbs_tuners *od_tuners = NULL;
37845 struct cs_dbs_tuners *cs_tuners = NULL;
37846 struct cpu_dbs_common_info *cpu_cdbs;
37847 @@ -253,7 +253,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
37848
37849 if ((cdata->governor == GOV_CONSERVATIVE) &&
37850 (!policy->governor->initialized)) {
37851 - struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
37852 + const struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
37853
37854 cpufreq_register_notifier(cs_ops->notifier_block,
37855 CPUFREQ_TRANSITION_NOTIFIER);
37856 @@ -273,7 +273,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
37857
37858 if ((dbs_data->cdata->governor == GOV_CONSERVATIVE) &&
37859 (policy->governor->initialized == 1)) {
37860 - struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
37861 + const struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
37862
37863 cpufreq_unregister_notifier(cs_ops->notifier_block,
37864 CPUFREQ_TRANSITION_NOTIFIER);
37865 diff --git a/drivers/cpufreq/cpufreq_governor.h b/drivers/cpufreq/cpufreq_governor.h
37866 index 88cd39f..87f0393 100644
37867 --- a/drivers/cpufreq/cpufreq_governor.h
37868 +++ b/drivers/cpufreq/cpufreq_governor.h
37869 @@ -202,7 +202,7 @@ struct common_dbs_data {
37870 void (*exit)(struct dbs_data *dbs_data);
37871
37872 /* Governor specific ops, see below */
37873 - void *gov_ops;
37874 + const void *gov_ops;
37875 };
37876
37877 /* Governor Per policy data */
37878 @@ -222,7 +222,7 @@ struct od_ops {
37879 unsigned int (*powersave_bias_target)(struct cpufreq_policy *policy,
37880 unsigned int freq_next, unsigned int relation);
37881 void (*freq_increase)(struct cpufreq_policy *policy, unsigned int freq);
37882 -};
37883 +} __no_const;
37884
37885 struct cs_ops {
37886 struct notifier_block *notifier_block;
37887 diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c
37888 index 32f26f6..feb657b 100644
37889 --- a/drivers/cpufreq/cpufreq_ondemand.c
37890 +++ b/drivers/cpufreq/cpufreq_ondemand.c
37891 @@ -522,7 +522,7 @@ static void od_exit(struct dbs_data *dbs_data)
37892
37893 define_get_cpu_dbs_routines(od_cpu_dbs_info);
37894
37895 -static struct od_ops od_ops = {
37896 +static struct od_ops od_ops __read_only = {
37897 .powersave_bias_init_cpu = ondemand_powersave_bias_init_cpu,
37898 .powersave_bias_target = generic_powersave_bias_target,
37899 .freq_increase = dbs_freq_increase,
37900 @@ -577,14 +577,18 @@ void od_register_powersave_bias_handler(unsigned int (*f)
37901 (struct cpufreq_policy *, unsigned int, unsigned int),
37902 unsigned int powersave_bias)
37903 {
37904 - od_ops.powersave_bias_target = f;
37905 + pax_open_kernel();
37906 + *(void **)&od_ops.powersave_bias_target = f;
37907 + pax_close_kernel();
37908 od_set_powersave_bias(powersave_bias);
37909 }
37910 EXPORT_SYMBOL_GPL(od_register_powersave_bias_handler);
37911
37912 void od_unregister_powersave_bias_handler(void)
37913 {
37914 - od_ops.powersave_bias_target = generic_powersave_bias_target;
37915 + pax_open_kernel();
37916 + *(void **)&od_ops.powersave_bias_target = generic_powersave_bias_target;
37917 + pax_close_kernel();
37918 od_set_powersave_bias(0);
37919 }
37920 EXPORT_SYMBOL_GPL(od_unregister_powersave_bias_handler);
37921 diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
37922 index 4cf0d28..5830372 100644
37923 --- a/drivers/cpufreq/cpufreq_stats.c
37924 +++ b/drivers/cpufreq/cpufreq_stats.c
37925 @@ -352,7 +352,7 @@ static int cpufreq_stat_cpu_callback(struct notifier_block *nfb,
37926 }
37927
37928 /* priority=1 so this will get called before cpufreq_remove_dev */
37929 -static struct notifier_block cpufreq_stat_cpu_notifier __refdata = {
37930 +static struct notifier_block cpufreq_stat_cpu_notifier = {
37931 .notifier_call = cpufreq_stat_cpu_callback,
37932 .priority = 1,
37933 };
37934 diff --git a/drivers/cpufreq/p4-clockmod.c b/drivers/cpufreq/p4-clockmod.c
37935 index 2f0a2a6..93d728e 100644
37936 --- a/drivers/cpufreq/p4-clockmod.c
37937 +++ b/drivers/cpufreq/p4-clockmod.c
37938 @@ -160,10 +160,14 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
37939 case 0x0F: /* Core Duo */
37940 case 0x16: /* Celeron Core */
37941 case 0x1C: /* Atom */
37942 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37943 + pax_open_kernel();
37944 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37945 + pax_close_kernel();
37946 return speedstep_get_frequency(SPEEDSTEP_CPU_PCORE);
37947 case 0x0D: /* Pentium M (Dothan) */
37948 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37949 + pax_open_kernel();
37950 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37951 + pax_close_kernel();
37952 /* fall through */
37953 case 0x09: /* Pentium M (Banias) */
37954 return speedstep_get_frequency(SPEEDSTEP_CPU_PM);
37955 @@ -175,7 +179,9 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
37956
37957 /* on P-4s, the TSC runs with constant frequency independent whether
37958 * throttling is active or not. */
37959 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37960 + pax_open_kernel();
37961 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37962 + pax_close_kernel();
37963
37964 if (speedstep_detect_processor() == SPEEDSTEP_CPU_P4M) {
37965 printk(KERN_WARNING PFX "Warning: Pentium 4-M detected. "
37966 diff --git a/drivers/cpufreq/sparc-us3-cpufreq.c b/drivers/cpufreq/sparc-us3-cpufreq.c
37967 index ac76b48..2445bc6 100644
37968 --- a/drivers/cpufreq/sparc-us3-cpufreq.c
37969 +++ b/drivers/cpufreq/sparc-us3-cpufreq.c
37970 @@ -18,14 +18,12 @@
37971 #include <asm/head.h>
37972 #include <asm/timer.h>
37973
37974 -static struct cpufreq_driver *cpufreq_us3_driver;
37975 -
37976 struct us3_freq_percpu_info {
37977 struct cpufreq_frequency_table table[4];
37978 };
37979
37980 /* Indexed by cpu number. */
37981 -static struct us3_freq_percpu_info *us3_freq_table;
37982 +static struct us3_freq_percpu_info us3_freq_table[NR_CPUS];
37983
37984 /* UltraSPARC-III has three dividers: 1, 2, and 32. These are controlled
37985 * in the Safari config register.
37986 @@ -186,12 +184,25 @@ static int __init us3_freq_cpu_init(struct cpufreq_policy *policy)
37987
37988 static int us3_freq_cpu_exit(struct cpufreq_policy *policy)
37989 {
37990 - if (cpufreq_us3_driver)
37991 - us3_set_cpu_divider_index(policy, 0);
37992 + us3_set_cpu_divider_index(policy->cpu, 0);
37993
37994 return 0;
37995 }
37996
37997 +static int __init us3_freq_init(void);
37998 +static void __exit us3_freq_exit(void);
37999 +
38000 +static struct cpufreq_driver cpufreq_us3_driver = {
38001 + .init = us3_freq_cpu_init,
38002 + .verify = us3_freq_verify,
38003 + .target = us3_freq_target,
38004 + .get = us3_freq_get,
38005 + .exit = us3_freq_cpu_exit,
38006 + .owner = THIS_MODULE,
38007 + .name = "UltraSPARC-III",
38008 +
38009 +};
38010 +
38011 static int __init us3_freq_init(void)
38012 {
38013 unsigned long manuf, impl, ver;
38014 @@ -208,55 +219,15 @@ static int __init us3_freq_init(void)
38015 (impl == CHEETAH_IMPL ||
38016 impl == CHEETAH_PLUS_IMPL ||
38017 impl == JAGUAR_IMPL ||
38018 - impl == PANTHER_IMPL)) {
38019 - struct cpufreq_driver *driver;
38020 -
38021 - ret = -ENOMEM;
38022 - driver = kzalloc(sizeof(*driver), GFP_KERNEL);
38023 - if (!driver)
38024 - goto err_out;
38025 -
38026 - us3_freq_table = kzalloc((NR_CPUS * sizeof(*us3_freq_table)),
38027 - GFP_KERNEL);
38028 - if (!us3_freq_table)
38029 - goto err_out;
38030 -
38031 - driver->init = us3_freq_cpu_init;
38032 - driver->verify = us3_freq_verify;
38033 - driver->target = us3_freq_target;
38034 - driver->get = us3_freq_get;
38035 - driver->exit = us3_freq_cpu_exit;
38036 - strcpy(driver->name, "UltraSPARC-III");
38037 -
38038 - cpufreq_us3_driver = driver;
38039 - ret = cpufreq_register_driver(driver);
38040 - if (ret)
38041 - goto err_out;
38042 -
38043 - return 0;
38044 -
38045 -err_out:
38046 - if (driver) {
38047 - kfree(driver);
38048 - cpufreq_us3_driver = NULL;
38049 - }
38050 - kfree(us3_freq_table);
38051 - us3_freq_table = NULL;
38052 - return ret;
38053 - }
38054 + impl == PANTHER_IMPL))
38055 + return cpufreq_register_driver(&cpufreq_us3_driver);
38056
38057 return -ENODEV;
38058 }
38059
38060 static void __exit us3_freq_exit(void)
38061 {
38062 - if (cpufreq_us3_driver) {
38063 - cpufreq_unregister_driver(cpufreq_us3_driver);
38064 - kfree(cpufreq_us3_driver);
38065 - cpufreq_us3_driver = NULL;
38066 - kfree(us3_freq_table);
38067 - us3_freq_table = NULL;
38068 - }
38069 + cpufreq_unregister_driver(&cpufreq_us3_driver);
38070 }
38071
38072 MODULE_AUTHOR("David S. Miller <davem@redhat.com>");
38073 diff --git a/drivers/cpufreq/speedstep-centrino.c b/drivers/cpufreq/speedstep-centrino.c
38074 index f897d51..15da295 100644
38075 --- a/drivers/cpufreq/speedstep-centrino.c
38076 +++ b/drivers/cpufreq/speedstep-centrino.c
38077 @@ -353,8 +353,11 @@ static int centrino_cpu_init(struct cpufreq_policy *policy)
38078 !cpu_has(cpu, X86_FEATURE_EST))
38079 return -ENODEV;
38080
38081 - if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC))
38082 - centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
38083 + if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC)) {
38084 + pax_open_kernel();
38085 + *(u8 *)&centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
38086 + pax_close_kernel();
38087 + }
38088
38089 if (policy->cpu != 0)
38090 return -ENODEV;
38091 diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
38092 index 22c07fb..9dff5ac 100644
38093 --- a/drivers/cpuidle/cpuidle.c
38094 +++ b/drivers/cpuidle/cpuidle.c
38095 @@ -252,7 +252,7 @@ static int poll_idle(struct cpuidle_device *dev,
38096
38097 static void poll_idle_init(struct cpuidle_driver *drv)
38098 {
38099 - struct cpuidle_state *state = &drv->states[0];
38100 + cpuidle_state_no_const *state = &drv->states[0];
38101
38102 snprintf(state->name, CPUIDLE_NAME_LEN, "POLL");
38103 snprintf(state->desc, CPUIDLE_DESC_LEN, "CPUIDLE CORE POLL IDLE");
38104 diff --git a/drivers/cpuidle/governor.c b/drivers/cpuidle/governor.c
38105 index ea2f8e7..70ac501 100644
38106 --- a/drivers/cpuidle/governor.c
38107 +++ b/drivers/cpuidle/governor.c
38108 @@ -87,7 +87,7 @@ int cpuidle_register_governor(struct cpuidle_governor *gov)
38109 mutex_lock(&cpuidle_lock);
38110 if (__cpuidle_find_governor(gov->name) == NULL) {
38111 ret = 0;
38112 - list_add_tail(&gov->governor_list, &cpuidle_governors);
38113 + pax_list_add_tail((struct list_head *)&gov->governor_list, &cpuidle_governors);
38114 if (!cpuidle_curr_governor ||
38115 cpuidle_curr_governor->rating < gov->rating)
38116 cpuidle_switch_governor(gov);
38117 @@ -135,7 +135,7 @@ void cpuidle_unregister_governor(struct cpuidle_governor *gov)
38118 new_gov = cpuidle_replace_governor(gov->rating);
38119 cpuidle_switch_governor(new_gov);
38120 }
38121 - list_del(&gov->governor_list);
38122 + pax_list_del((struct list_head *)&gov->governor_list);
38123 mutex_unlock(&cpuidle_lock);
38124 }
38125
38126 diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
38127 index 8739cc0..dc859d0 100644
38128 --- a/drivers/cpuidle/sysfs.c
38129 +++ b/drivers/cpuidle/sysfs.c
38130 @@ -134,7 +134,7 @@ static struct attribute *cpuidle_switch_attrs[] = {
38131 NULL
38132 };
38133
38134 -static struct attribute_group cpuidle_attr_group = {
38135 +static attribute_group_no_const cpuidle_attr_group = {
38136 .attrs = cpuidle_default_attrs,
38137 .name = "cpuidle",
38138 };
38139 diff --git a/drivers/crypto/hifn_795x.c b/drivers/crypto/hifn_795x.c
38140 index 12fea3e..1e28f47 100644
38141 --- a/drivers/crypto/hifn_795x.c
38142 +++ b/drivers/crypto/hifn_795x.c
38143 @@ -51,7 +51,7 @@ module_param_string(hifn_pll_ref, hifn_pll_ref, sizeof(hifn_pll_ref), 0444);
38144 MODULE_PARM_DESC(hifn_pll_ref,
38145 "PLL reference clock (pci[freq] or ext[freq], default ext)");
38146
38147 -static atomic_t hifn_dev_number;
38148 +static atomic_unchecked_t hifn_dev_number;
38149
38150 #define ACRYPTO_OP_DECRYPT 0
38151 #define ACRYPTO_OP_ENCRYPT 1
38152 @@ -2577,7 +2577,7 @@ static int hifn_probe(struct pci_dev *pdev, const struct pci_device_id *id)
38153 goto err_out_disable_pci_device;
38154
38155 snprintf(name, sizeof(name), "hifn%d",
38156 - atomic_inc_return(&hifn_dev_number)-1);
38157 + atomic_inc_return_unchecked(&hifn_dev_number)-1);
38158
38159 err = pci_request_regions(pdev, name);
38160 if (err)
38161 diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
38162 index c99c00d..990a4b2 100644
38163 --- a/drivers/devfreq/devfreq.c
38164 +++ b/drivers/devfreq/devfreq.c
38165 @@ -607,7 +607,7 @@ int devfreq_add_governor(struct devfreq_governor *governor)
38166 goto err_out;
38167 }
38168
38169 - list_add(&governor->node, &devfreq_governor_list);
38170 + pax_list_add((struct list_head *)&governor->node, &devfreq_governor_list);
38171
38172 list_for_each_entry(devfreq, &devfreq_list, node) {
38173 int ret = 0;
38174 @@ -695,7 +695,7 @@ int devfreq_remove_governor(struct devfreq_governor *governor)
38175 }
38176 }
38177
38178 - list_del(&governor->node);
38179 + pax_list_del((struct list_head *)&governor->node);
38180 err_out:
38181 mutex_unlock(&devfreq_list_lock);
38182
38183 diff --git a/drivers/dma/sh/shdmac.c b/drivers/dma/sh/shdmac.c
38184 index 1069e88..dfcd642 100644
38185 --- a/drivers/dma/sh/shdmac.c
38186 +++ b/drivers/dma/sh/shdmac.c
38187 @@ -511,7 +511,7 @@ static int sh_dmae_nmi_handler(struct notifier_block *self,
38188 return ret;
38189 }
38190
38191 -static struct notifier_block sh_dmae_nmi_notifier __read_mostly = {
38192 +static struct notifier_block sh_dmae_nmi_notifier = {
38193 .notifier_call = sh_dmae_nmi_handler,
38194
38195 /* Run before NMI debug handler and KGDB */
38196 diff --git a/drivers/edac/edac_device.c b/drivers/edac/edac_device.c
38197 index 211021d..201d47f 100644
38198 --- a/drivers/edac/edac_device.c
38199 +++ b/drivers/edac/edac_device.c
38200 @@ -474,9 +474,9 @@ void edac_device_reset_delay_period(struct edac_device_ctl_info *edac_dev,
38201 */
38202 int edac_device_alloc_index(void)
38203 {
38204 - static atomic_t device_indexes = ATOMIC_INIT(0);
38205 + static atomic_unchecked_t device_indexes = ATOMIC_INIT(0);
38206
38207 - return atomic_inc_return(&device_indexes) - 1;
38208 + return atomic_inc_return_unchecked(&device_indexes) - 1;
38209 }
38210 EXPORT_SYMBOL_GPL(edac_device_alloc_index);
38211
38212 diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
38213 index 9f7e0e60..348c875 100644
38214 --- a/drivers/edac/edac_mc_sysfs.c
38215 +++ b/drivers/edac/edac_mc_sysfs.c
38216 @@ -150,7 +150,7 @@ static const char * const edac_caps[] = {
38217 struct dev_ch_attribute {
38218 struct device_attribute attr;
38219 int channel;
38220 -};
38221 +} __do_const;
38222
38223 #define DEVICE_CHANNEL(_name, _mode, _show, _store, _var) \
38224 struct dev_ch_attribute dev_attr_legacy_##_name = \
38225 @@ -1007,14 +1007,16 @@ int edac_create_sysfs_mci_device(struct mem_ctl_info *mci)
38226 }
38227
38228 if (mci->set_sdram_scrub_rate || mci->get_sdram_scrub_rate) {
38229 + pax_open_kernel();
38230 if (mci->get_sdram_scrub_rate) {
38231 - dev_attr_sdram_scrub_rate.attr.mode |= S_IRUGO;
38232 - dev_attr_sdram_scrub_rate.show = &mci_sdram_scrub_rate_show;
38233 + *(umode_t *)&dev_attr_sdram_scrub_rate.attr.mode |= S_IRUGO;
38234 + *(void **)&dev_attr_sdram_scrub_rate.show = &mci_sdram_scrub_rate_show;
38235 }
38236 if (mci->set_sdram_scrub_rate) {
38237 - dev_attr_sdram_scrub_rate.attr.mode |= S_IWUSR;
38238 - dev_attr_sdram_scrub_rate.store = &mci_sdram_scrub_rate_store;
38239 + *(umode_t *)&dev_attr_sdram_scrub_rate.attr.mode |= S_IWUSR;
38240 + *(void **)&dev_attr_sdram_scrub_rate.store = &mci_sdram_scrub_rate_store;
38241 }
38242 + pax_close_kernel();
38243 err = device_create_file(&mci->dev,
38244 &dev_attr_sdram_scrub_rate);
38245 if (err) {
38246 diff --git a/drivers/edac/edac_pci.c b/drivers/edac/edac_pci.c
38247 index dd370f9..0281629 100644
38248 --- a/drivers/edac/edac_pci.c
38249 +++ b/drivers/edac/edac_pci.c
38250 @@ -29,7 +29,7 @@
38251
38252 static DEFINE_MUTEX(edac_pci_ctls_mutex);
38253 static LIST_HEAD(edac_pci_list);
38254 -static atomic_t pci_indexes = ATOMIC_INIT(0);
38255 +static atomic_unchecked_t pci_indexes = ATOMIC_INIT(0);
38256
38257 /*
38258 * edac_pci_alloc_ctl_info
38259 @@ -315,7 +315,7 @@ EXPORT_SYMBOL_GPL(edac_pci_reset_delay_period);
38260 */
38261 int edac_pci_alloc_index(void)
38262 {
38263 - return atomic_inc_return(&pci_indexes) - 1;
38264 + return atomic_inc_return_unchecked(&pci_indexes) - 1;
38265 }
38266 EXPORT_SYMBOL_GPL(edac_pci_alloc_index);
38267
38268 diff --git a/drivers/edac/edac_pci_sysfs.c b/drivers/edac/edac_pci_sysfs.c
38269 index e8658e4..22746d6 100644
38270 --- a/drivers/edac/edac_pci_sysfs.c
38271 +++ b/drivers/edac/edac_pci_sysfs.c
38272 @@ -26,8 +26,8 @@ static int edac_pci_log_pe = 1; /* log PCI parity errors */
38273 static int edac_pci_log_npe = 1; /* log PCI non-parity error errors */
38274 static int edac_pci_poll_msec = 1000; /* one second workq period */
38275
38276 -static atomic_t pci_parity_count = ATOMIC_INIT(0);
38277 -static atomic_t pci_nonparity_count = ATOMIC_INIT(0);
38278 +static atomic_unchecked_t pci_parity_count = ATOMIC_INIT(0);
38279 +static atomic_unchecked_t pci_nonparity_count = ATOMIC_INIT(0);
38280
38281 static struct kobject *edac_pci_top_main_kobj;
38282 static atomic_t edac_pci_sysfs_refcount = ATOMIC_INIT(0);
38283 @@ -235,7 +235,7 @@ struct edac_pci_dev_attribute {
38284 void *value;
38285 ssize_t(*show) (void *, char *);
38286 ssize_t(*store) (void *, const char *, size_t);
38287 -};
38288 +} __do_const;
38289
38290 /* Set of show/store abstract level functions for PCI Parity object */
38291 static ssize_t edac_pci_dev_show(struct kobject *kobj, struct attribute *attr,
38292 @@ -579,7 +579,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
38293 edac_printk(KERN_CRIT, EDAC_PCI,
38294 "Signaled System Error on %s\n",
38295 pci_name(dev));
38296 - atomic_inc(&pci_nonparity_count);
38297 + atomic_inc_unchecked(&pci_nonparity_count);
38298 }
38299
38300 if (status & (PCI_STATUS_PARITY)) {
38301 @@ -587,7 +587,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
38302 "Master Data Parity Error on %s\n",
38303 pci_name(dev));
38304
38305 - atomic_inc(&pci_parity_count);
38306 + atomic_inc_unchecked(&pci_parity_count);
38307 }
38308
38309 if (status & (PCI_STATUS_DETECTED_PARITY)) {
38310 @@ -595,7 +595,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
38311 "Detected Parity Error on %s\n",
38312 pci_name(dev));
38313
38314 - atomic_inc(&pci_parity_count);
38315 + atomic_inc_unchecked(&pci_parity_count);
38316 }
38317 }
38318
38319 @@ -618,7 +618,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
38320 edac_printk(KERN_CRIT, EDAC_PCI, "Bridge "
38321 "Signaled System Error on %s\n",
38322 pci_name(dev));
38323 - atomic_inc(&pci_nonparity_count);
38324 + atomic_inc_unchecked(&pci_nonparity_count);
38325 }
38326
38327 if (status & (PCI_STATUS_PARITY)) {
38328 @@ -626,7 +626,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
38329 "Master Data Parity Error on "
38330 "%s\n", pci_name(dev));
38331
38332 - atomic_inc(&pci_parity_count);
38333 + atomic_inc_unchecked(&pci_parity_count);
38334 }
38335
38336 if (status & (PCI_STATUS_DETECTED_PARITY)) {
38337 @@ -634,7 +634,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
38338 "Detected Parity Error on %s\n",
38339 pci_name(dev));
38340
38341 - atomic_inc(&pci_parity_count);
38342 + atomic_inc_unchecked(&pci_parity_count);
38343 }
38344 }
38345 }
38346 @@ -672,7 +672,7 @@ void edac_pci_do_parity_check(void)
38347 if (!check_pci_errors)
38348 return;
38349
38350 - before_count = atomic_read(&pci_parity_count);
38351 + before_count = atomic_read_unchecked(&pci_parity_count);
38352
38353 /* scan all PCI devices looking for a Parity Error on devices and
38354 * bridges.
38355 @@ -684,7 +684,7 @@ void edac_pci_do_parity_check(void)
38356 /* Only if operator has selected panic on PCI Error */
38357 if (edac_pci_get_panic_on_pe()) {
38358 /* If the count is different 'after' from 'before' */
38359 - if (before_count != atomic_read(&pci_parity_count))
38360 + if (before_count != atomic_read_unchecked(&pci_parity_count))
38361 panic("EDAC: PCI Parity Error");
38362 }
38363 }
38364 diff --git a/drivers/edac/mce_amd.h b/drivers/edac/mce_amd.h
38365 index 51b7e3a..aa8a3e8 100644
38366 --- a/drivers/edac/mce_amd.h
38367 +++ b/drivers/edac/mce_amd.h
38368 @@ -77,7 +77,7 @@ struct amd_decoder_ops {
38369 bool (*mc0_mce)(u16, u8);
38370 bool (*mc1_mce)(u16, u8);
38371 bool (*mc2_mce)(u16, u8);
38372 -};
38373 +} __no_const;
38374
38375 void amd_report_gart_errors(bool);
38376 void amd_register_ecc_decoder(void (*f)(int, struct mce *));
38377 diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c
38378 index 57ea7f4..af06b76 100644
38379 --- a/drivers/firewire/core-card.c
38380 +++ b/drivers/firewire/core-card.c
38381 @@ -528,9 +528,9 @@ void fw_card_initialize(struct fw_card *card,
38382 const struct fw_card_driver *driver,
38383 struct device *device)
38384 {
38385 - static atomic_t index = ATOMIC_INIT(-1);
38386 + static atomic_unchecked_t index = ATOMIC_INIT(-1);
38387
38388 - card->index = atomic_inc_return(&index);
38389 + card->index = atomic_inc_return_unchecked(&index);
38390 card->driver = driver;
38391 card->device = device;
38392 card->current_tlabel = 0;
38393 @@ -680,7 +680,7 @@ EXPORT_SYMBOL_GPL(fw_card_release);
38394
38395 void fw_core_remove_card(struct fw_card *card)
38396 {
38397 - struct fw_card_driver dummy_driver = dummy_driver_template;
38398 + fw_card_driver_no_const dummy_driver = dummy_driver_template;
38399
38400 card->driver->update_phy_reg(card, 4,
38401 PHY_LINK_ACTIVE | PHY_CONTENDER, 0);
38402 diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c
38403 index de4aa40..49ab1f2 100644
38404 --- a/drivers/firewire/core-device.c
38405 +++ b/drivers/firewire/core-device.c
38406 @@ -253,7 +253,7 @@ EXPORT_SYMBOL(fw_device_enable_phys_dma);
38407 struct config_rom_attribute {
38408 struct device_attribute attr;
38409 u32 key;
38410 -};
38411 +} __do_const;
38412
38413 static ssize_t show_immediate(struct device *dev,
38414 struct device_attribute *dattr, char *buf)
38415 diff --git a/drivers/firewire/core-transaction.c b/drivers/firewire/core-transaction.c
38416 index e5af0e3..d318058 100644
38417 --- a/drivers/firewire/core-transaction.c
38418 +++ b/drivers/firewire/core-transaction.c
38419 @@ -38,6 +38,7 @@
38420 #include <linux/timer.h>
38421 #include <linux/types.h>
38422 #include <linux/workqueue.h>
38423 +#include <linux/sched.h>
38424
38425 #include <asm/byteorder.h>
38426
38427 diff --git a/drivers/firewire/core.h b/drivers/firewire/core.h
38428 index 515a42c..5ecf3ba 100644
38429 --- a/drivers/firewire/core.h
38430 +++ b/drivers/firewire/core.h
38431 @@ -111,6 +111,7 @@ struct fw_card_driver {
38432
38433 int (*stop_iso)(struct fw_iso_context *ctx);
38434 };
38435 +typedef struct fw_card_driver __no_const fw_card_driver_no_const;
38436
38437 void fw_card_initialize(struct fw_card *card,
38438 const struct fw_card_driver *driver, struct device *device);
38439 diff --git a/drivers/firmware/dmi-id.c b/drivers/firmware/dmi-id.c
38440 index 94a58a0..f5eba42 100644
38441 --- a/drivers/firmware/dmi-id.c
38442 +++ b/drivers/firmware/dmi-id.c
38443 @@ -16,7 +16,7 @@
38444 struct dmi_device_attribute{
38445 struct device_attribute dev_attr;
38446 int field;
38447 -};
38448 +} __do_const;
38449 #define to_dmi_dev_attr(_dev_attr) \
38450 container_of(_dev_attr, struct dmi_device_attribute, dev_attr)
38451
38452 diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
38453 index fa0affb..aa448eb 100644
38454 --- a/drivers/firmware/dmi_scan.c
38455 +++ b/drivers/firmware/dmi_scan.c
38456 @@ -791,7 +791,7 @@ int dmi_walk(void (*decode)(const struct dmi_header *, void *),
38457 if (buf == NULL)
38458 return -1;
38459
38460 - dmi_table(buf, dmi_len, dmi_num, decode, private_data);
38461 + dmi_table((char __force_kernel *)buf, dmi_len, dmi_num, decode, private_data);
38462
38463 iounmap(buf);
38464 return 0;
38465 diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
38466 index 5145fa3..0d3babd 100644
38467 --- a/drivers/firmware/efi/efi.c
38468 +++ b/drivers/firmware/efi/efi.c
38469 @@ -65,14 +65,16 @@ static struct attribute_group efi_subsys_attr_group = {
38470 };
38471
38472 static struct efivars generic_efivars;
38473 -static struct efivar_operations generic_ops;
38474 +static efivar_operations_no_const generic_ops __read_only;
38475
38476 static int generic_ops_register(void)
38477 {
38478 - generic_ops.get_variable = efi.get_variable;
38479 - generic_ops.set_variable = efi.set_variable;
38480 - generic_ops.get_next_variable = efi.get_next_variable;
38481 - generic_ops.query_variable_store = efi_query_variable_store;
38482 + pax_open_kernel();
38483 + *(void **)&generic_ops.get_variable = efi.get_variable;
38484 + *(void **)&generic_ops.set_variable = efi.set_variable;
38485 + *(void **)&generic_ops.get_next_variable = efi.get_next_variable;
38486 + *(void **)&generic_ops.query_variable_store = efi_query_variable_store;
38487 + pax_close_kernel();
38488
38489 return efivars_register(&generic_efivars, &generic_ops, efi_kobj);
38490 }
38491 diff --git a/drivers/firmware/efi/efivars.c b/drivers/firmware/efi/efivars.c
38492 index 8c5a61a..cf07bd0 100644
38493 --- a/drivers/firmware/efi/efivars.c
38494 +++ b/drivers/firmware/efi/efivars.c
38495 @@ -456,7 +456,7 @@ efivar_create_sysfs_entry(struct efivar_entry *new_var)
38496 static int
38497 create_efivars_bin_attributes(void)
38498 {
38499 - struct bin_attribute *attr;
38500 + bin_attribute_no_const *attr;
38501 int error;
38502
38503 /* new_var */
38504 diff --git a/drivers/firmware/google/memconsole.c b/drivers/firmware/google/memconsole.c
38505 index 2a90ba6..07f3733 100644
38506 --- a/drivers/firmware/google/memconsole.c
38507 +++ b/drivers/firmware/google/memconsole.c
38508 @@ -147,7 +147,9 @@ static int __init memconsole_init(void)
38509 if (!found_memconsole())
38510 return -ENODEV;
38511
38512 - memconsole_bin_attr.size = memconsole_length;
38513 + pax_open_kernel();
38514 + *(size_t *)&memconsole_bin_attr.size = memconsole_length;
38515 + pax_close_kernel();
38516
38517 ret = sysfs_create_bin_file(firmware_kobj, &memconsole_bin_attr);
38518
38519 diff --git a/drivers/gpio/gpio-ich.c b/drivers/gpio/gpio-ich.c
38520 index 814addb..0937d7f 100644
38521 --- a/drivers/gpio/gpio-ich.c
38522 +++ b/drivers/gpio/gpio-ich.c
38523 @@ -71,7 +71,7 @@ struct ichx_desc {
38524 /* Some chipsets have quirks, let these use their own request/get */
38525 int (*request)(struct gpio_chip *chip, unsigned offset);
38526 int (*get)(struct gpio_chip *chip, unsigned offset);
38527 -};
38528 +} __do_const;
38529
38530 static struct {
38531 spinlock_t lock;
38532 diff --git a/drivers/gpio/gpio-vr41xx.c b/drivers/gpio/gpio-vr41xx.c
38533 index 9902732..64b62dd 100644
38534 --- a/drivers/gpio/gpio-vr41xx.c
38535 +++ b/drivers/gpio/gpio-vr41xx.c
38536 @@ -204,7 +204,7 @@ static int giu_get_irq(unsigned int irq)
38537 printk(KERN_ERR "spurious GIU interrupt: %04x(%04x),%04x(%04x)\n",
38538 maskl, pendl, maskh, pendh);
38539
38540 - atomic_inc(&irq_err_count);
38541 + atomic_inc_unchecked(&irq_err_count);
38542
38543 return -EINVAL;
38544 }
38545 diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c
38546 index c722c3b..2ec6040 100644
38547 --- a/drivers/gpu/drm/drm_crtc_helper.c
38548 +++ b/drivers/gpu/drm/drm_crtc_helper.c
38549 @@ -328,7 +328,7 @@ static bool drm_encoder_crtc_ok(struct drm_encoder *encoder,
38550 struct drm_crtc *tmp;
38551 int crtc_mask = 1;
38552
38553 - WARN(!crtc, "checking null crtc?\n");
38554 + BUG_ON(!crtc);
38555
38556 dev = crtc->dev;
38557
38558 diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
38559 index fe58d08..07bc38e 100644
38560 --- a/drivers/gpu/drm/drm_drv.c
38561 +++ b/drivers/gpu/drm/drm_drv.c
38562 @@ -186,7 +186,7 @@ static void drm_legacy_dev_reinit(struct drm_device *dev)
38563 atomic_set(&dev->vma_count, 0);
38564
38565 for (i = 0; i < ARRAY_SIZE(dev->counts); i++)
38566 - atomic_set(&dev->counts[i], 0);
38567 + atomic_set_unchecked(&dev->counts[i], 0);
38568
38569 dev->sigdata.lock = NULL;
38570
38571 @@ -302,7 +302,7 @@ module_exit(drm_core_exit);
38572 /**
38573 * Copy and IOCTL return string to user space
38574 */
38575 -static int drm_copy_field(char *buf, size_t *buf_len, const char *value)
38576 +static int drm_copy_field(char __user *buf, size_t *buf_len, const char *value)
38577 {
38578 int len;
38579
38580 @@ -372,7 +372,7 @@ long drm_ioctl(struct file *filp,
38581 struct drm_file *file_priv = filp->private_data;
38582 struct drm_device *dev;
38583 const struct drm_ioctl_desc *ioctl = NULL;
38584 - drm_ioctl_t *func;
38585 + drm_ioctl_no_const_t func;
38586 unsigned int nr = DRM_IOCTL_NR(cmd);
38587 int retcode = -EINVAL;
38588 char stack_kdata[128];
38589 @@ -385,7 +385,7 @@ long drm_ioctl(struct file *filp,
38590 return -ENODEV;
38591
38592 atomic_inc(&dev->ioctl_count);
38593 - atomic_inc(&dev->counts[_DRM_STAT_IOCTLS]);
38594 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_IOCTLS]);
38595 ++file_priv->ioctl_count;
38596
38597 if ((nr >= DRM_CORE_IOCTL_COUNT) &&
38598 diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
38599 index 3f84277..c627c54 100644
38600 --- a/drivers/gpu/drm/drm_fops.c
38601 +++ b/drivers/gpu/drm/drm_fops.c
38602 @@ -97,7 +97,7 @@ int drm_open(struct inode *inode, struct file *filp)
38603 if (drm_device_is_unplugged(dev))
38604 return -ENODEV;
38605
38606 - if (!dev->open_count++)
38607 + if (local_inc_return(&dev->open_count) == 1)
38608 need_setup = 1;
38609 mutex_lock(&dev->struct_mutex);
38610 old_imapping = inode->i_mapping;
38611 @@ -113,7 +113,7 @@ int drm_open(struct inode *inode, struct file *filp)
38612 retcode = drm_open_helper(inode, filp, dev);
38613 if (retcode)
38614 goto err_undo;
38615 - atomic_inc(&dev->counts[_DRM_STAT_OPENS]);
38616 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_OPENS]);
38617 if (need_setup) {
38618 retcode = drm_setup(dev);
38619 if (retcode)
38620 @@ -128,7 +128,7 @@ err_undo:
38621 iput(container_of(dev->dev_mapping, struct inode, i_data));
38622 dev->dev_mapping = old_mapping;
38623 mutex_unlock(&dev->struct_mutex);
38624 - dev->open_count--;
38625 + local_dec(&dev->open_count);
38626 return retcode;
38627 }
38628 EXPORT_SYMBOL(drm_open);
38629 @@ -405,7 +405,7 @@ int drm_release(struct inode *inode, struct file *filp)
38630
38631 mutex_lock(&drm_global_mutex);
38632
38633 - DRM_DEBUG("open_count = %d\n", dev->open_count);
38634 + DRM_DEBUG("open_count = %ld\n", local_read(&dev->open_count));
38635
38636 if (dev->driver->preclose)
38637 dev->driver->preclose(dev, file_priv);
38638 @@ -414,10 +414,10 @@ int drm_release(struct inode *inode, struct file *filp)
38639 * Begin inline drm_release
38640 */
38641
38642 - DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %d\n",
38643 + DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %ld\n",
38644 task_pid_nr(current),
38645 (long)old_encode_dev(file_priv->minor->device),
38646 - dev->open_count);
38647 + local_read(&dev->open_count));
38648
38649 /* Release any auth tokens that might point to this file_priv,
38650 (do that under the drm_global_mutex) */
38651 @@ -516,8 +516,8 @@ int drm_release(struct inode *inode, struct file *filp)
38652 * End inline drm_release
38653 */
38654
38655 - atomic_inc(&dev->counts[_DRM_STAT_CLOSES]);
38656 - if (!--dev->open_count) {
38657 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_CLOSES]);
38658 + if (local_dec_and_test(&dev->open_count)) {
38659 if (atomic_read(&dev->ioctl_count)) {
38660 DRM_ERROR("Device busy: %d\n",
38661 atomic_read(&dev->ioctl_count));
38662 diff --git a/drivers/gpu/drm/drm_global.c b/drivers/gpu/drm/drm_global.c
38663 index f731116..629842c 100644
38664 --- a/drivers/gpu/drm/drm_global.c
38665 +++ b/drivers/gpu/drm/drm_global.c
38666 @@ -36,7 +36,7 @@
38667 struct drm_global_item {
38668 struct mutex mutex;
38669 void *object;
38670 - int refcount;
38671 + atomic_t refcount;
38672 };
38673
38674 static struct drm_global_item glob[DRM_GLOBAL_NUM];
38675 @@ -49,7 +49,7 @@ void drm_global_init(void)
38676 struct drm_global_item *item = &glob[i];
38677 mutex_init(&item->mutex);
38678 item->object = NULL;
38679 - item->refcount = 0;
38680 + atomic_set(&item->refcount, 0);
38681 }
38682 }
38683
38684 @@ -59,7 +59,7 @@ void drm_global_release(void)
38685 for (i = 0; i < DRM_GLOBAL_NUM; ++i) {
38686 struct drm_global_item *item = &glob[i];
38687 BUG_ON(item->object != NULL);
38688 - BUG_ON(item->refcount != 0);
38689 + BUG_ON(atomic_read(&item->refcount) != 0);
38690 }
38691 }
38692
38693 @@ -70,7 +70,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
38694 void *object;
38695
38696 mutex_lock(&item->mutex);
38697 - if (item->refcount == 0) {
38698 + if (atomic_read(&item->refcount) == 0) {
38699 item->object = kzalloc(ref->size, GFP_KERNEL);
38700 if (unlikely(item->object == NULL)) {
38701 ret = -ENOMEM;
38702 @@ -83,7 +83,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
38703 goto out_err;
38704
38705 }
38706 - ++item->refcount;
38707 + atomic_inc(&item->refcount);
38708 ref->object = item->object;
38709 object = item->object;
38710 mutex_unlock(&item->mutex);
38711 @@ -100,9 +100,9 @@ void drm_global_item_unref(struct drm_global_reference *ref)
38712 struct drm_global_item *item = &glob[ref->global_type];
38713
38714 mutex_lock(&item->mutex);
38715 - BUG_ON(item->refcount == 0);
38716 + BUG_ON(atomic_read(&item->refcount) == 0);
38717 BUG_ON(ref->object != item->object);
38718 - if (--item->refcount == 0) {
38719 + if (atomic_dec_and_test(&item->refcount)) {
38720 ref->release(ref);
38721 item->object = NULL;
38722 }
38723 diff --git a/drivers/gpu/drm/drm_info.c b/drivers/gpu/drm/drm_info.c
38724 index 5329832..b503f49 100644
38725 --- a/drivers/gpu/drm/drm_info.c
38726 +++ b/drivers/gpu/drm/drm_info.c
38727 @@ -75,10 +75,14 @@ int drm_vm_info(struct seq_file *m, void *data)
38728 struct drm_local_map *map;
38729 struct drm_map_list *r_list;
38730
38731 - /* Hardcoded from _DRM_FRAME_BUFFER,
38732 - _DRM_REGISTERS, _DRM_SHM, _DRM_AGP, and
38733 - _DRM_SCATTER_GATHER and _DRM_CONSISTENT */
38734 - const char *types[] = { "FB", "REG", "SHM", "AGP", "SG", "PCI" };
38735 + static const char * const types[] = {
38736 + [_DRM_FRAME_BUFFER] = "FB",
38737 + [_DRM_REGISTERS] = "REG",
38738 + [_DRM_SHM] = "SHM",
38739 + [_DRM_AGP] = "AGP",
38740 + [_DRM_SCATTER_GATHER] = "SG",
38741 + [_DRM_CONSISTENT] = "PCI",
38742 + [_DRM_GEM] = "GEM" };
38743 const char *type;
38744 int i;
38745
38746 @@ -89,7 +93,7 @@ int drm_vm_info(struct seq_file *m, void *data)
38747 map = r_list->map;
38748 if (!map)
38749 continue;
38750 - if (map->type < 0 || map->type > 5)
38751 + if (map->type >= ARRAY_SIZE(types))
38752 type = "??";
38753 else
38754 type = types[map->type];
38755 @@ -257,7 +261,11 @@ int drm_vma_info(struct seq_file *m, void *data)
38756 vma->vm_flags & VM_MAYSHARE ? 's' : 'p',
38757 vma->vm_flags & VM_LOCKED ? 'l' : '-',
38758 vma->vm_flags & VM_IO ? 'i' : '-',
38759 +#ifdef CONFIG_GRKERNSEC_HIDESYM
38760 + 0);
38761 +#else
38762 vma->vm_pgoff);
38763 +#endif
38764
38765 #if defined(__i386__)
38766 pgprot = pgprot_val(vma->vm_page_prot);
38767 diff --git a/drivers/gpu/drm/drm_ioc32.c b/drivers/gpu/drm/drm_ioc32.c
38768 index 2f4c434..dd12cd2 100644
38769 --- a/drivers/gpu/drm/drm_ioc32.c
38770 +++ b/drivers/gpu/drm/drm_ioc32.c
38771 @@ -457,7 +457,7 @@ static int compat_drm_infobufs(struct file *file, unsigned int cmd,
38772 request = compat_alloc_user_space(nbytes);
38773 if (!access_ok(VERIFY_WRITE, request, nbytes))
38774 return -EFAULT;
38775 - list = (struct drm_buf_desc *) (request + 1);
38776 + list = (struct drm_buf_desc __user *) (request + 1);
38777
38778 if (__put_user(count, &request->count)
38779 || __put_user(list, &request->list))
38780 @@ -518,7 +518,7 @@ static int compat_drm_mapbufs(struct file *file, unsigned int cmd,
38781 request = compat_alloc_user_space(nbytes);
38782 if (!access_ok(VERIFY_WRITE, request, nbytes))
38783 return -EFAULT;
38784 - list = (struct drm_buf_pub *) (request + 1);
38785 + list = (struct drm_buf_pub __user *) (request + 1);
38786
38787 if (__put_user(count, &request->count)
38788 || __put_user(list, &request->list))
38789 @@ -1016,7 +1016,7 @@ static int compat_drm_wait_vblank(struct file *file, unsigned int cmd,
38790 return 0;
38791 }
38792
38793 -drm_ioctl_compat_t *drm_compat_ioctls[] = {
38794 +drm_ioctl_compat_t drm_compat_ioctls[] = {
38795 [DRM_IOCTL_NR(DRM_IOCTL_VERSION32)] = compat_drm_version,
38796 [DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE32)] = compat_drm_getunique,
38797 [DRM_IOCTL_NR(DRM_IOCTL_GET_MAP32)] = compat_drm_getmap,
38798 @@ -1062,7 +1062,6 @@ drm_ioctl_compat_t *drm_compat_ioctls[] = {
38799 long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38800 {
38801 unsigned int nr = DRM_IOCTL_NR(cmd);
38802 - drm_ioctl_compat_t *fn;
38803 int ret;
38804
38805 /* Assume that ioctls without an explicit compat routine will just
38806 @@ -1072,10 +1071,8 @@ long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38807 if (nr >= ARRAY_SIZE(drm_compat_ioctls))
38808 return drm_ioctl(filp, cmd, arg);
38809
38810 - fn = drm_compat_ioctls[nr];
38811 -
38812 - if (fn != NULL)
38813 - ret = (*fn) (filp, cmd, arg);
38814 + if (drm_compat_ioctls[nr] != NULL)
38815 + ret = (*drm_compat_ioctls[nr]) (filp, cmd, arg);
38816 else
38817 ret = drm_ioctl(filp, cmd, arg);
38818
38819 diff --git a/drivers/gpu/drm/drm_lock.c b/drivers/gpu/drm/drm_lock.c
38820 index d752c96..fe08455 100644
38821 --- a/drivers/gpu/drm/drm_lock.c
38822 +++ b/drivers/gpu/drm/drm_lock.c
38823 @@ -86,7 +86,7 @@ int drm_lock(struct drm_device *dev, void *data, struct drm_file *file_priv)
38824 if (drm_lock_take(&master->lock, lock->context)) {
38825 master->lock.file_priv = file_priv;
38826 master->lock.lock_time = jiffies;
38827 - atomic_inc(&dev->counts[_DRM_STAT_LOCKS]);
38828 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_LOCKS]);
38829 break; /* Got lock */
38830 }
38831
38832 @@ -157,7 +157,7 @@ int drm_unlock(struct drm_device *dev, void *data, struct drm_file *file_priv)
38833 return -EINVAL;
38834 }
38835
38836 - atomic_inc(&dev->counts[_DRM_STAT_UNLOCKS]);
38837 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_UNLOCKS]);
38838
38839 if (drm_lock_free(&master->lock, lock->context)) {
38840 /* FIXME: Should really bail out here. */
38841 diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
38842 index 39d8645..59e06fa 100644
38843 --- a/drivers/gpu/drm/drm_stub.c
38844 +++ b/drivers/gpu/drm/drm_stub.c
38845 @@ -484,7 +484,7 @@ void drm_unplug_dev(struct drm_device *dev)
38846
38847 drm_device_set_unplugged(dev);
38848
38849 - if (dev->open_count == 0) {
38850 + if (local_read(&dev->open_count) == 0) {
38851 drm_put_dev(dev);
38852 }
38853 mutex_unlock(&drm_global_mutex);
38854 diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
38855 index 2290b3b..22056a1 100644
38856 --- a/drivers/gpu/drm/drm_sysfs.c
38857 +++ b/drivers/gpu/drm/drm_sysfs.c
38858 @@ -524,7 +524,7 @@ EXPORT_SYMBOL(drm_sysfs_hotplug_event);
38859 int drm_sysfs_device_add(struct drm_minor *minor)
38860 {
38861 int err;
38862 - char *minor_str;
38863 + const char *minor_str;
38864
38865 minor->kdev.parent = minor->dev->dev;
38866
38867 diff --git a/drivers/gpu/drm/i810/i810_dma.c b/drivers/gpu/drm/i810/i810_dma.c
38868 index ab1892eb..d7009ca 100644
38869 --- a/drivers/gpu/drm/i810/i810_dma.c
38870 +++ b/drivers/gpu/drm/i810/i810_dma.c
38871 @@ -944,8 +944,8 @@ static int i810_dma_vertex(struct drm_device *dev, void *data,
38872 dma->buflist[vertex->idx],
38873 vertex->discard, vertex->used);
38874
38875 - atomic_add(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
38876 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
38877 + atomic_add_unchecked(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
38878 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
38879 sarea_priv->last_enqueue = dev_priv->counter - 1;
38880 sarea_priv->last_dispatch = (int)hw_status[5];
38881
38882 @@ -1105,8 +1105,8 @@ static int i810_dma_mc(struct drm_device *dev, void *data,
38883 i810_dma_dispatch_mc(dev, dma->buflist[mc->idx], mc->used,
38884 mc->last_render);
38885
38886 - atomic_add(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
38887 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
38888 + atomic_add_unchecked(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
38889 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
38890 sarea_priv->last_enqueue = dev_priv->counter - 1;
38891 sarea_priv->last_dispatch = (int)hw_status[5];
38892
38893 diff --git a/drivers/gpu/drm/i810/i810_drv.h b/drivers/gpu/drm/i810/i810_drv.h
38894 index d4d16ed..8fb0b51 100644
38895 --- a/drivers/gpu/drm/i810/i810_drv.h
38896 +++ b/drivers/gpu/drm/i810/i810_drv.h
38897 @@ -108,8 +108,8 @@ typedef struct drm_i810_private {
38898 int page_flipping;
38899
38900 wait_queue_head_t irq_queue;
38901 - atomic_t irq_received;
38902 - atomic_t irq_emitted;
38903 + atomic_unchecked_t irq_received;
38904 + atomic_unchecked_t irq_emitted;
38905
38906 int front_offset;
38907 } drm_i810_private_t;
38908 diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
38909 index a6f4cb5..6b2beb2 100644
38910 --- a/drivers/gpu/drm/i915/i915_debugfs.c
38911 +++ b/drivers/gpu/drm/i915/i915_debugfs.c
38912 @@ -624,7 +624,7 @@ static int i915_interrupt_info(struct seq_file *m, void *data)
38913 I915_READ(GTIMR));
38914 }
38915 seq_printf(m, "Interrupts received: %d\n",
38916 - atomic_read(&dev_priv->irq_received));
38917 + atomic_read_unchecked(&dev_priv->irq_received));
38918 for_each_ring(ring, dev_priv, i) {
38919 if (IS_GEN6(dev) || IS_GEN7(dev)) {
38920 seq_printf(m,
38921 diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
38922 index d5c784d..06e5c36 100644
38923 --- a/drivers/gpu/drm/i915/i915_dma.c
38924 +++ b/drivers/gpu/drm/i915/i915_dma.c
38925 @@ -1263,7 +1263,7 @@ static bool i915_switcheroo_can_switch(struct pci_dev *pdev)
38926 bool can_switch;
38927
38928 spin_lock(&dev->count_lock);
38929 - can_switch = (dev->open_count == 0);
38930 + can_switch = (local_read(&dev->open_count) == 0);
38931 spin_unlock(&dev->count_lock);
38932 return can_switch;
38933 }
38934 diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
38935 index ab0f2c0..53c1bda 100644
38936 --- a/drivers/gpu/drm/i915/i915_drv.h
38937 +++ b/drivers/gpu/drm/i915/i915_drv.h
38938 @@ -1181,7 +1181,7 @@ typedef struct drm_i915_private {
38939 drm_dma_handle_t *status_page_dmah;
38940 struct resource mch_res;
38941
38942 - atomic_t irq_received;
38943 + atomic_unchecked_t irq_received;
38944
38945 /* protects the irq masks */
38946 spinlock_t irq_lock;
38947 diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
38948 index bf34577..3fd2ffa 100644
38949 --- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
38950 +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
38951 @@ -768,9 +768,9 @@ i915_gem_check_execbuffer(struct drm_i915_gem_execbuffer2 *exec)
38952
38953 static int
38954 validate_exec_list(struct drm_i915_gem_exec_object2 *exec,
38955 - int count)
38956 + unsigned int count)
38957 {
38958 - int i;
38959 + unsigned int i;
38960 int relocs_total = 0;
38961 int relocs_max = INT_MAX / sizeof(struct drm_i915_gem_relocation_entry);
38962
38963 diff --git a/drivers/gpu/drm/i915/i915_ioc32.c b/drivers/gpu/drm/i915/i915_ioc32.c
38964 index 3c59584..500f2e9 100644
38965 --- a/drivers/gpu/drm/i915/i915_ioc32.c
38966 +++ b/drivers/gpu/drm/i915/i915_ioc32.c
38967 @@ -181,7 +181,7 @@ static int compat_i915_alloc(struct file *file, unsigned int cmd,
38968 (unsigned long)request);
38969 }
38970
38971 -static drm_ioctl_compat_t *i915_compat_ioctls[] = {
38972 +static drm_ioctl_compat_t i915_compat_ioctls[] = {
38973 [DRM_I915_BATCHBUFFER] = compat_i915_batchbuffer,
38974 [DRM_I915_CMDBUFFER] = compat_i915_cmdbuffer,
38975 [DRM_I915_GETPARAM] = compat_i915_getparam,
38976 @@ -202,18 +202,15 @@ static drm_ioctl_compat_t *i915_compat_ioctls[] = {
38977 long i915_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38978 {
38979 unsigned int nr = DRM_IOCTL_NR(cmd);
38980 - drm_ioctl_compat_t *fn = NULL;
38981 int ret;
38982
38983 if (nr < DRM_COMMAND_BASE)
38984 return drm_compat_ioctl(filp, cmd, arg);
38985
38986 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls))
38987 - fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
38988 -
38989 - if (fn != NULL)
38990 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls)) {
38991 + drm_ioctl_compat_t fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
38992 ret = (*fn) (filp, cmd, arg);
38993 - else
38994 + } else
38995 ret = drm_ioctl(filp, cmd, arg);
38996
38997 return ret;
38998 diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
38999 index 4b91228..590c643 100644
39000 --- a/drivers/gpu/drm/i915/i915_irq.c
39001 +++ b/drivers/gpu/drm/i915/i915_irq.c
39002 @@ -1085,7 +1085,7 @@ static irqreturn_t valleyview_irq_handler(int irq, void *arg)
39003 int pipe;
39004 u32 pipe_stats[I915_MAX_PIPES];
39005
39006 - atomic_inc(&dev_priv->irq_received);
39007 + atomic_inc_unchecked(&dev_priv->irq_received);
39008
39009 while (true) {
39010 iir = I915_READ(VLV_IIR);
39011 @@ -1390,7 +1390,7 @@ static irqreturn_t ironlake_irq_handler(int irq, void *arg)
39012 irqreturn_t ret = IRQ_NONE;
39013 bool err_int_reenable = false;
39014
39015 - atomic_inc(&dev_priv->irq_received);
39016 + atomic_inc_unchecked(&dev_priv->irq_received);
39017
39018 /* We get interrupts on unclaimed registers, so check for this before we
39019 * do any I915_{READ,WRITE}. */
39020 @@ -2146,7 +2146,7 @@ static void ironlake_irq_preinstall(struct drm_device *dev)
39021 {
39022 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
39023
39024 - atomic_set(&dev_priv->irq_received, 0);
39025 + atomic_set_unchecked(&dev_priv->irq_received, 0);
39026
39027 I915_WRITE(HWSTAM, 0xeffe);
39028
39029 @@ -2164,7 +2164,7 @@ static void valleyview_irq_preinstall(struct drm_device *dev)
39030 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
39031 int pipe;
39032
39033 - atomic_set(&dev_priv->irq_received, 0);
39034 + atomic_set_unchecked(&dev_priv->irq_received, 0);
39035
39036 /* VLV magic */
39037 I915_WRITE(VLV_IMR, 0);
39038 @@ -2452,7 +2452,7 @@ static void i8xx_irq_preinstall(struct drm_device * dev)
39039 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
39040 int pipe;
39041
39042 - atomic_set(&dev_priv->irq_received, 0);
39043 + atomic_set_unchecked(&dev_priv->irq_received, 0);
39044
39045 for_each_pipe(pipe)
39046 I915_WRITE(PIPESTAT(pipe), 0);
39047 @@ -2530,7 +2530,7 @@ static irqreturn_t i8xx_irq_handler(int irq, void *arg)
39048 I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT |
39049 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
39050
39051 - atomic_inc(&dev_priv->irq_received);
39052 + atomic_inc_unchecked(&dev_priv->irq_received);
39053
39054 iir = I915_READ16(IIR);
39055 if (iir == 0)
39056 @@ -2604,7 +2604,7 @@ static void i915_irq_preinstall(struct drm_device * dev)
39057 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
39058 int pipe;
39059
39060 - atomic_set(&dev_priv->irq_received, 0);
39061 + atomic_set_unchecked(&dev_priv->irq_received, 0);
39062
39063 if (I915_HAS_HOTPLUG(dev)) {
39064 I915_WRITE(PORT_HOTPLUG_EN, 0);
39065 @@ -2703,7 +2703,7 @@ static irqreturn_t i915_irq_handler(int irq, void *arg)
39066 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
39067 int pipe, ret = IRQ_NONE;
39068
39069 - atomic_inc(&dev_priv->irq_received);
39070 + atomic_inc_unchecked(&dev_priv->irq_received);
39071
39072 iir = I915_READ(IIR);
39073 do {
39074 @@ -2827,7 +2827,7 @@ static void i965_irq_preinstall(struct drm_device * dev)
39075 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
39076 int pipe;
39077
39078 - atomic_set(&dev_priv->irq_received, 0);
39079 + atomic_set_unchecked(&dev_priv->irq_received, 0);
39080
39081 I915_WRITE(PORT_HOTPLUG_EN, 0);
39082 I915_WRITE(PORT_HOTPLUG_STAT, I915_READ(PORT_HOTPLUG_STAT));
39083 @@ -2941,7 +2941,7 @@ static irqreturn_t i965_irq_handler(int irq, void *arg)
39084 I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT |
39085 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
39086
39087 - atomic_inc(&dev_priv->irq_received);
39088 + atomic_inc_unchecked(&dev_priv->irq_received);
39089
39090 iir = I915_READ(IIR);
39091
39092 diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
39093 index f535670..bde09e2 100644
39094 --- a/drivers/gpu/drm/i915/intel_display.c
39095 +++ b/drivers/gpu/drm/i915/intel_display.c
39096 @@ -10019,13 +10019,13 @@ struct intel_quirk {
39097 int subsystem_vendor;
39098 int subsystem_device;
39099 void (*hook)(struct drm_device *dev);
39100 -};
39101 +} __do_const;
39102
39103 /* For systems that don't have a meaningful PCI subdevice/subvendor ID */
39104 struct intel_dmi_quirk {
39105 void (*hook)(struct drm_device *dev);
39106 const struct dmi_system_id (*dmi_id_list)[];
39107 -};
39108 +} __do_const;
39109
39110 static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
39111 {
39112 @@ -10033,18 +10033,20 @@ static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
39113 return 1;
39114 }
39115
39116 -static const struct intel_dmi_quirk intel_dmi_quirks[] = {
39117 +static const struct dmi_system_id intel_dmi_quirks_table[] = {
39118 {
39119 - .dmi_id_list = &(const struct dmi_system_id[]) {
39120 - {
39121 - .callback = intel_dmi_reverse_brightness,
39122 - .ident = "NCR Corporation",
39123 - .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
39124 - DMI_MATCH(DMI_PRODUCT_NAME, ""),
39125 - },
39126 - },
39127 - { } /* terminating entry */
39128 + .callback = intel_dmi_reverse_brightness,
39129 + .ident = "NCR Corporation",
39130 + .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
39131 + DMI_MATCH(DMI_PRODUCT_NAME, ""),
39132 },
39133 + },
39134 + { } /* terminating entry */
39135 +};
39136 +
39137 +static const struct intel_dmi_quirk intel_dmi_quirks[] = {
39138 + {
39139 + .dmi_id_list = &intel_dmi_quirks_table,
39140 .hook = quirk_invert_brightness,
39141 },
39142 };
39143 diff --git a/drivers/gpu/drm/mga/mga_drv.h b/drivers/gpu/drm/mga/mga_drv.h
39144 index ca4bc54..ee598a2 100644
39145 --- a/drivers/gpu/drm/mga/mga_drv.h
39146 +++ b/drivers/gpu/drm/mga/mga_drv.h
39147 @@ -120,9 +120,9 @@ typedef struct drm_mga_private {
39148 u32 clear_cmd;
39149 u32 maccess;
39150
39151 - atomic_t vbl_received; /**< Number of vblanks received. */
39152 + atomic_unchecked_t vbl_received; /**< Number of vblanks received. */
39153 wait_queue_head_t fence_queue;
39154 - atomic_t last_fence_retired;
39155 + atomic_unchecked_t last_fence_retired;
39156 u32 next_fence_to_post;
39157
39158 unsigned int fb_cpp;
39159 diff --git a/drivers/gpu/drm/mga/mga_ioc32.c b/drivers/gpu/drm/mga/mga_ioc32.c
39160 index 709e90d..89a1c0d 100644
39161 --- a/drivers/gpu/drm/mga/mga_ioc32.c
39162 +++ b/drivers/gpu/drm/mga/mga_ioc32.c
39163 @@ -189,7 +189,7 @@ static int compat_mga_dma_bootstrap(struct file *file, unsigned int cmd,
39164 return 0;
39165 }
39166
39167 -drm_ioctl_compat_t *mga_compat_ioctls[] = {
39168 +drm_ioctl_compat_t mga_compat_ioctls[] = {
39169 [DRM_MGA_INIT] = compat_mga_init,
39170 [DRM_MGA_GETPARAM] = compat_mga_getparam,
39171 [DRM_MGA_DMA_BOOTSTRAP] = compat_mga_dma_bootstrap,
39172 @@ -207,18 +207,15 @@ drm_ioctl_compat_t *mga_compat_ioctls[] = {
39173 long mga_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
39174 {
39175 unsigned int nr = DRM_IOCTL_NR(cmd);
39176 - drm_ioctl_compat_t *fn = NULL;
39177 int ret;
39178
39179 if (nr < DRM_COMMAND_BASE)
39180 return drm_compat_ioctl(filp, cmd, arg);
39181
39182 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls))
39183 - fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
39184 -
39185 - if (fn != NULL)
39186 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls)) {
39187 + drm_ioctl_compat_t fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
39188 ret = (*fn) (filp, cmd, arg);
39189 - else
39190 + } else
39191 ret = drm_ioctl(filp, cmd, arg);
39192
39193 return ret;
39194 diff --git a/drivers/gpu/drm/mga/mga_irq.c b/drivers/gpu/drm/mga/mga_irq.c
39195 index 598c281..60d590e 100644
39196 --- a/drivers/gpu/drm/mga/mga_irq.c
39197 +++ b/drivers/gpu/drm/mga/mga_irq.c
39198 @@ -43,7 +43,7 @@ u32 mga_get_vblank_counter(struct drm_device *dev, int crtc)
39199 if (crtc != 0)
39200 return 0;
39201
39202 - return atomic_read(&dev_priv->vbl_received);
39203 + return atomic_read_unchecked(&dev_priv->vbl_received);
39204 }
39205
39206
39207 @@ -59,7 +59,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
39208 /* VBLANK interrupt */
39209 if (status & MGA_VLINEPEN) {
39210 MGA_WRITE(MGA_ICLEAR, MGA_VLINEICLR);
39211 - atomic_inc(&dev_priv->vbl_received);
39212 + atomic_inc_unchecked(&dev_priv->vbl_received);
39213 drm_handle_vblank(dev, 0);
39214 handled = 1;
39215 }
39216 @@ -78,7 +78,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
39217 if ((prim_start & ~0x03) != (prim_end & ~0x03))
39218 MGA_WRITE(MGA_PRIMEND, prim_end);
39219
39220 - atomic_inc(&dev_priv->last_fence_retired);
39221 + atomic_inc_unchecked(&dev_priv->last_fence_retired);
39222 DRM_WAKEUP(&dev_priv->fence_queue);
39223 handled = 1;
39224 }
39225 @@ -129,7 +129,7 @@ int mga_driver_fence_wait(struct drm_device *dev, unsigned int *sequence)
39226 * using fences.
39227 */
39228 DRM_WAIT_ON(ret, dev_priv->fence_queue, 3 * DRM_HZ,
39229 - (((cur_fence = atomic_read(&dev_priv->last_fence_retired))
39230 + (((cur_fence = atomic_read_unchecked(&dev_priv->last_fence_retired))
39231 - *sequence) <= (1 << 23)));
39232
39233 *sequence = cur_fence;
39234 diff --git a/drivers/gpu/drm/nouveau/nouveau_bios.c b/drivers/gpu/drm/nouveau/nouveau_bios.c
39235 index 3e72876..d1c15ad 100644
39236 --- a/drivers/gpu/drm/nouveau/nouveau_bios.c
39237 +++ b/drivers/gpu/drm/nouveau/nouveau_bios.c
39238 @@ -965,7 +965,7 @@ static int parse_bit_tmds_tbl_entry(struct drm_device *dev, struct nvbios *bios,
39239 struct bit_table {
39240 const char id;
39241 int (* const parse_fn)(struct drm_device *, struct nvbios *, struct bit_entry *);
39242 -};
39243 +} __no_const;
39244
39245 #define BIT_TABLE(id, funcid) ((struct bit_table){ id, parse_bit_##funcid##_tbl_entry })
39246
39247 diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.h b/drivers/gpu/drm/nouveau/nouveau_drm.h
39248 index 994fd6e..6e12565 100644
39249 --- a/drivers/gpu/drm/nouveau/nouveau_drm.h
39250 +++ b/drivers/gpu/drm/nouveau/nouveau_drm.h
39251 @@ -94,7 +94,6 @@ struct nouveau_drm {
39252 struct drm_global_reference mem_global_ref;
39253 struct ttm_bo_global_ref bo_global_ref;
39254 struct ttm_bo_device bdev;
39255 - atomic_t validate_sequence;
39256 int (*move)(struct nouveau_channel *,
39257 struct ttm_buffer_object *,
39258 struct ttm_mem_reg *, struct ttm_mem_reg *);
39259 diff --git a/drivers/gpu/drm/nouveau/nouveau_ioc32.c b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
39260 index c1a7e5a..38b8539 100644
39261 --- a/drivers/gpu/drm/nouveau/nouveau_ioc32.c
39262 +++ b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
39263 @@ -50,7 +50,7 @@ long nouveau_compat_ioctl(struct file *filp, unsigned int cmd,
39264 unsigned long arg)
39265 {
39266 unsigned int nr = DRM_IOCTL_NR(cmd);
39267 - drm_ioctl_compat_t *fn = NULL;
39268 + drm_ioctl_compat_t fn = NULL;
39269 int ret;
39270
39271 if (nr < DRM_COMMAND_BASE)
39272 diff --git a/drivers/gpu/drm/nouveau/nouveau_vga.c b/drivers/gpu/drm/nouveau/nouveau_vga.c
39273 index 81638d7..2e45854 100644
39274 --- a/drivers/gpu/drm/nouveau/nouveau_vga.c
39275 +++ b/drivers/gpu/drm/nouveau/nouveau_vga.c
39276 @@ -65,7 +65,7 @@ nouveau_switcheroo_can_switch(struct pci_dev *pdev)
39277 bool can_switch;
39278
39279 spin_lock(&dev->count_lock);
39280 - can_switch = (dev->open_count == 0);
39281 + can_switch = (local_read(&dev->open_count) == 0);
39282 spin_unlock(&dev->count_lock);
39283 return can_switch;
39284 }
39285 diff --git a/drivers/gpu/drm/qxl/qxl_cmd.c b/drivers/gpu/drm/qxl/qxl_cmd.c
39286 index eb89653..613cf71 100644
39287 --- a/drivers/gpu/drm/qxl/qxl_cmd.c
39288 +++ b/drivers/gpu/drm/qxl/qxl_cmd.c
39289 @@ -285,27 +285,27 @@ static int wait_for_io_cmd_user(struct qxl_device *qdev, uint8_t val, long port,
39290 int ret;
39291
39292 mutex_lock(&qdev->async_io_mutex);
39293 - irq_num = atomic_read(&qdev->irq_received_io_cmd);
39294 + irq_num = atomic_read_unchecked(&qdev->irq_received_io_cmd);
39295 if (qdev->last_sent_io_cmd > irq_num) {
39296 if (intr)
39297 ret = wait_event_interruptible_timeout(qdev->io_cmd_event,
39298 - atomic_read(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
39299 + atomic_read_unchecked(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
39300 else
39301 ret = wait_event_timeout(qdev->io_cmd_event,
39302 - atomic_read(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
39303 + atomic_read_unchecked(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
39304 /* 0 is timeout, just bail the "hw" has gone away */
39305 if (ret <= 0)
39306 goto out;
39307 - irq_num = atomic_read(&qdev->irq_received_io_cmd);
39308 + irq_num = atomic_read_unchecked(&qdev->irq_received_io_cmd);
39309 }
39310 outb(val, addr);
39311 qdev->last_sent_io_cmd = irq_num + 1;
39312 if (intr)
39313 ret = wait_event_interruptible_timeout(qdev->io_cmd_event,
39314 - atomic_read(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
39315 + atomic_read_unchecked(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
39316 else
39317 ret = wait_event_timeout(qdev->io_cmd_event,
39318 - atomic_read(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
39319 + atomic_read_unchecked(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
39320 out:
39321 if (ret > 0)
39322 ret = 0;
39323 diff --git a/drivers/gpu/drm/qxl/qxl_debugfs.c b/drivers/gpu/drm/qxl/qxl_debugfs.c
39324 index c3c2bbd..bc3c0fb 100644
39325 --- a/drivers/gpu/drm/qxl/qxl_debugfs.c
39326 +++ b/drivers/gpu/drm/qxl/qxl_debugfs.c
39327 @@ -42,10 +42,10 @@ qxl_debugfs_irq_received(struct seq_file *m, void *data)
39328 struct drm_info_node *node = (struct drm_info_node *) m->private;
39329 struct qxl_device *qdev = node->minor->dev->dev_private;
39330
39331 - seq_printf(m, "%d\n", atomic_read(&qdev->irq_received));
39332 - seq_printf(m, "%d\n", atomic_read(&qdev->irq_received_display));
39333 - seq_printf(m, "%d\n", atomic_read(&qdev->irq_received_cursor));
39334 - seq_printf(m, "%d\n", atomic_read(&qdev->irq_received_io_cmd));
39335 + seq_printf(m, "%d\n", atomic_read_unchecked(&qdev->irq_received));
39336 + seq_printf(m, "%d\n", atomic_read_unchecked(&qdev->irq_received_display));
39337 + seq_printf(m, "%d\n", atomic_read_unchecked(&qdev->irq_received_cursor));
39338 + seq_printf(m, "%d\n", atomic_read_unchecked(&qdev->irq_received_io_cmd));
39339 seq_printf(m, "%d\n", qdev->irq_received_error);
39340 return 0;
39341 }
39342 diff --git a/drivers/gpu/drm/qxl/qxl_drv.h b/drivers/gpu/drm/qxl/qxl_drv.h
39343 index f7c9add..fb971d2 100644
39344 --- a/drivers/gpu/drm/qxl/qxl_drv.h
39345 +++ b/drivers/gpu/drm/qxl/qxl_drv.h
39346 @@ -290,10 +290,10 @@ struct qxl_device {
39347 unsigned int last_sent_io_cmd;
39348
39349 /* interrupt handling */
39350 - atomic_t irq_received;
39351 - atomic_t irq_received_display;
39352 - atomic_t irq_received_cursor;
39353 - atomic_t irq_received_io_cmd;
39354 + atomic_unchecked_t irq_received;
39355 + atomic_unchecked_t irq_received_display;
39356 + atomic_unchecked_t irq_received_cursor;
39357 + atomic_unchecked_t irq_received_io_cmd;
39358 unsigned irq_received_error;
39359 wait_queue_head_t display_event;
39360 wait_queue_head_t cursor_event;
39361 diff --git a/drivers/gpu/drm/qxl/qxl_irq.c b/drivers/gpu/drm/qxl/qxl_irq.c
39362 index 21393dc..329f3a9 100644
39363 --- a/drivers/gpu/drm/qxl/qxl_irq.c
39364 +++ b/drivers/gpu/drm/qxl/qxl_irq.c
39365 @@ -33,19 +33,19 @@ irqreturn_t qxl_irq_handler(DRM_IRQ_ARGS)
39366
39367 pending = xchg(&qdev->ram_header->int_pending, 0);
39368
39369 - atomic_inc(&qdev->irq_received);
39370 + atomic_inc_unchecked(&qdev->irq_received);
39371
39372 if (pending & QXL_INTERRUPT_DISPLAY) {
39373 - atomic_inc(&qdev->irq_received_display);
39374 + atomic_inc_unchecked(&qdev->irq_received_display);
39375 wake_up_all(&qdev->display_event);
39376 qxl_queue_garbage_collect(qdev, false);
39377 }
39378 if (pending & QXL_INTERRUPT_CURSOR) {
39379 - atomic_inc(&qdev->irq_received_cursor);
39380 + atomic_inc_unchecked(&qdev->irq_received_cursor);
39381 wake_up_all(&qdev->cursor_event);
39382 }
39383 if (pending & QXL_INTERRUPT_IO_CMD) {
39384 - atomic_inc(&qdev->irq_received_io_cmd);
39385 + atomic_inc_unchecked(&qdev->irq_received_io_cmd);
39386 wake_up_all(&qdev->io_cmd_event);
39387 }
39388 if (pending & QXL_INTERRUPT_ERROR) {
39389 @@ -82,10 +82,10 @@ int qxl_irq_init(struct qxl_device *qdev)
39390 init_waitqueue_head(&qdev->io_cmd_event);
39391 INIT_WORK(&qdev->client_monitors_config_work,
39392 qxl_client_monitors_config_work_func);
39393 - atomic_set(&qdev->irq_received, 0);
39394 - atomic_set(&qdev->irq_received_display, 0);
39395 - atomic_set(&qdev->irq_received_cursor, 0);
39396 - atomic_set(&qdev->irq_received_io_cmd, 0);
39397 + atomic_set_unchecked(&qdev->irq_received, 0);
39398 + atomic_set_unchecked(&qdev->irq_received_display, 0);
39399 + atomic_set_unchecked(&qdev->irq_received_cursor, 0);
39400 + atomic_set_unchecked(&qdev->irq_received_io_cmd, 0);
39401 qdev->irq_received_error = 0;
39402 ret = drm_irq_install(qdev->ddev);
39403 qdev->ram_header->int_mask = QXL_INTERRUPT_MASK;
39404 diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c
39405 index 037786d..2a95e33 100644
39406 --- a/drivers/gpu/drm/qxl/qxl_ttm.c
39407 +++ b/drivers/gpu/drm/qxl/qxl_ttm.c
39408 @@ -103,7 +103,7 @@ static void qxl_ttm_global_fini(struct qxl_device *qdev)
39409 }
39410 }
39411
39412 -static struct vm_operations_struct qxl_ttm_vm_ops;
39413 +static vm_operations_struct_no_const qxl_ttm_vm_ops __read_only;
39414 static const struct vm_operations_struct *ttm_vm_ops;
39415
39416 static int qxl_ttm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
39417 @@ -147,8 +147,10 @@ int qxl_mmap(struct file *filp, struct vm_area_struct *vma)
39418 return r;
39419 if (unlikely(ttm_vm_ops == NULL)) {
39420 ttm_vm_ops = vma->vm_ops;
39421 + pax_open_kernel();
39422 qxl_ttm_vm_ops = *ttm_vm_ops;
39423 qxl_ttm_vm_ops.fault = &qxl_ttm_fault;
39424 + pax_close_kernel();
39425 }
39426 vma->vm_ops = &qxl_ttm_vm_ops;
39427 return 0;
39428 @@ -558,25 +560,23 @@ static int qxl_mm_dump_table(struct seq_file *m, void *data)
39429 static int qxl_ttm_debugfs_init(struct qxl_device *qdev)
39430 {
39431 #if defined(CONFIG_DEBUG_FS)
39432 - static struct drm_info_list qxl_mem_types_list[QXL_DEBUGFS_MEM_TYPES];
39433 - static char qxl_mem_types_names[QXL_DEBUGFS_MEM_TYPES][32];
39434 - unsigned i;
39435 + static struct drm_info_list qxl_mem_types_list[QXL_DEBUGFS_MEM_TYPES] = {
39436 + {
39437 + .name = "qxl_mem_mm",
39438 + .show = &qxl_mm_dump_table,
39439 + },
39440 + {
39441 + .name = "qxl_surf_mm",
39442 + .show = &qxl_mm_dump_table,
39443 + }
39444 + };
39445
39446 - for (i = 0; i < QXL_DEBUGFS_MEM_TYPES; i++) {
39447 - if (i == 0)
39448 - sprintf(qxl_mem_types_names[i], "qxl_mem_mm");
39449 - else
39450 - sprintf(qxl_mem_types_names[i], "qxl_surf_mm");
39451 - qxl_mem_types_list[i].name = qxl_mem_types_names[i];
39452 - qxl_mem_types_list[i].show = &qxl_mm_dump_table;
39453 - qxl_mem_types_list[i].driver_features = 0;
39454 - if (i == 0)
39455 - qxl_mem_types_list[i].data = qdev->mman.bdev.man[TTM_PL_VRAM].priv;
39456 - else
39457 - qxl_mem_types_list[i].data = qdev->mman.bdev.man[TTM_PL_PRIV0].priv;
39458 + pax_open_kernel();
39459 + *(void **)&qxl_mem_types_list[0].data = qdev->mman.bdev.man[TTM_PL_VRAM].priv;
39460 + *(void **)&qxl_mem_types_list[1].data = qdev->mman.bdev.man[TTM_PL_PRIV0].priv;
39461 + pax_close_kernel();
39462
39463 - }
39464 - return qxl_debugfs_add_files(qdev, qxl_mem_types_list, i);
39465 + return qxl_debugfs_add_files(qdev, qxl_mem_types_list, QXL_DEBUGFS_MEM_TYPES);
39466 #else
39467 return 0;
39468 #endif
39469 diff --git a/drivers/gpu/drm/r128/r128_cce.c b/drivers/gpu/drm/r128/r128_cce.c
39470 index c451257..0ad2134 100644
39471 --- a/drivers/gpu/drm/r128/r128_cce.c
39472 +++ b/drivers/gpu/drm/r128/r128_cce.c
39473 @@ -377,7 +377,7 @@ static int r128_do_init_cce(struct drm_device *dev, drm_r128_init_t *init)
39474
39475 /* GH: Simple idle check.
39476 */
39477 - atomic_set(&dev_priv->idle_count, 0);
39478 + atomic_set_unchecked(&dev_priv->idle_count, 0);
39479
39480 /* We don't support anything other than bus-mastering ring mode,
39481 * but the ring can be in either AGP or PCI space for the ring
39482 diff --git a/drivers/gpu/drm/r128/r128_drv.h b/drivers/gpu/drm/r128/r128_drv.h
39483 index 56eb5e3..c4ec43d 100644
39484 --- a/drivers/gpu/drm/r128/r128_drv.h
39485 +++ b/drivers/gpu/drm/r128/r128_drv.h
39486 @@ -90,14 +90,14 @@ typedef struct drm_r128_private {
39487 int is_pci;
39488 unsigned long cce_buffers_offset;
39489
39490 - atomic_t idle_count;
39491 + atomic_unchecked_t idle_count;
39492
39493 int page_flipping;
39494 int current_page;
39495 u32 crtc_offset;
39496 u32 crtc_offset_cntl;
39497
39498 - atomic_t vbl_received;
39499 + atomic_unchecked_t vbl_received;
39500
39501 u32 color_fmt;
39502 unsigned int front_offset;
39503 diff --git a/drivers/gpu/drm/r128/r128_ioc32.c b/drivers/gpu/drm/r128/r128_ioc32.c
39504 index a954c54..9cc595c 100644
39505 --- a/drivers/gpu/drm/r128/r128_ioc32.c
39506 +++ b/drivers/gpu/drm/r128/r128_ioc32.c
39507 @@ -177,7 +177,7 @@ static int compat_r128_getparam(struct file *file, unsigned int cmd,
39508 return drm_ioctl(file, DRM_IOCTL_R128_GETPARAM, (unsigned long)getparam);
39509 }
39510
39511 -drm_ioctl_compat_t *r128_compat_ioctls[] = {
39512 +drm_ioctl_compat_t r128_compat_ioctls[] = {
39513 [DRM_R128_INIT] = compat_r128_init,
39514 [DRM_R128_DEPTH] = compat_r128_depth,
39515 [DRM_R128_STIPPLE] = compat_r128_stipple,
39516 @@ -196,18 +196,15 @@ drm_ioctl_compat_t *r128_compat_ioctls[] = {
39517 long r128_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
39518 {
39519 unsigned int nr = DRM_IOCTL_NR(cmd);
39520 - drm_ioctl_compat_t *fn = NULL;
39521 int ret;
39522
39523 if (nr < DRM_COMMAND_BASE)
39524 return drm_compat_ioctl(filp, cmd, arg);
39525
39526 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls))
39527 - fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
39528 -
39529 - if (fn != NULL)
39530 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls)) {
39531 + drm_ioctl_compat_t fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
39532 ret = (*fn) (filp, cmd, arg);
39533 - else
39534 + } else
39535 ret = drm_ioctl(filp, cmd, arg);
39536
39537 return ret;
39538 diff --git a/drivers/gpu/drm/r128/r128_irq.c b/drivers/gpu/drm/r128/r128_irq.c
39539 index 2ea4f09..d391371 100644
39540 --- a/drivers/gpu/drm/r128/r128_irq.c
39541 +++ b/drivers/gpu/drm/r128/r128_irq.c
39542 @@ -41,7 +41,7 @@ u32 r128_get_vblank_counter(struct drm_device *dev, int crtc)
39543 if (crtc != 0)
39544 return 0;
39545
39546 - return atomic_read(&dev_priv->vbl_received);
39547 + return atomic_read_unchecked(&dev_priv->vbl_received);
39548 }
39549
39550 irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
39551 @@ -55,7 +55,7 @@ irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
39552 /* VBLANK interrupt */
39553 if (status & R128_CRTC_VBLANK_INT) {
39554 R128_WRITE(R128_GEN_INT_STATUS, R128_CRTC_VBLANK_INT_AK);
39555 - atomic_inc(&dev_priv->vbl_received);
39556 + atomic_inc_unchecked(&dev_priv->vbl_received);
39557 drm_handle_vblank(dev, 0);
39558 return IRQ_HANDLED;
39559 }
39560 diff --git a/drivers/gpu/drm/r128/r128_state.c b/drivers/gpu/drm/r128/r128_state.c
39561 index 01dd9ae..6352f04 100644
39562 --- a/drivers/gpu/drm/r128/r128_state.c
39563 +++ b/drivers/gpu/drm/r128/r128_state.c
39564 @@ -320,10 +320,10 @@ static void r128_clear_box(drm_r128_private_t *dev_priv,
39565
39566 static void r128_cce_performance_boxes(drm_r128_private_t *dev_priv)
39567 {
39568 - if (atomic_read(&dev_priv->idle_count) == 0)
39569 + if (atomic_read_unchecked(&dev_priv->idle_count) == 0)
39570 r128_clear_box(dev_priv, 64, 4, 8, 8, 0, 255, 0);
39571 else
39572 - atomic_set(&dev_priv->idle_count, 0);
39573 + atomic_set_unchecked(&dev_priv->idle_count, 0);
39574 }
39575
39576 #endif
39577 diff --git a/drivers/gpu/drm/radeon/mkregtable.c b/drivers/gpu/drm/radeon/mkregtable.c
39578 index af85299..ed9ac8d 100644
39579 --- a/drivers/gpu/drm/radeon/mkregtable.c
39580 +++ b/drivers/gpu/drm/radeon/mkregtable.c
39581 @@ -624,14 +624,14 @@ static int parser_auth(struct table *t, const char *filename)
39582 regex_t mask_rex;
39583 regmatch_t match[4];
39584 char buf[1024];
39585 - size_t end;
39586 + long end;
39587 int len;
39588 int done = 0;
39589 int r;
39590 unsigned o;
39591 struct offset *offset;
39592 char last_reg_s[10];
39593 - int last_reg;
39594 + unsigned long last_reg;
39595
39596 if (regcomp
39597 (&mask_rex, "(0x[0-9a-fA-F]*) *([_a-zA-Z0-9]*)", REG_EXTENDED)) {
39598 diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
39599 index 841d0e0..9eaa268 100644
39600 --- a/drivers/gpu/drm/radeon/radeon_device.c
39601 +++ b/drivers/gpu/drm/radeon/radeon_device.c
39602 @@ -1117,7 +1117,7 @@ static bool radeon_switcheroo_can_switch(struct pci_dev *pdev)
39603 bool can_switch;
39604
39605 spin_lock(&dev->count_lock);
39606 - can_switch = (dev->open_count == 0);
39607 + can_switch = (local_read(&dev->open_count) == 0);
39608 spin_unlock(&dev->count_lock);
39609 return can_switch;
39610 }
39611 diff --git a/drivers/gpu/drm/radeon/radeon_drv.h b/drivers/gpu/drm/radeon/radeon_drv.h
39612 index b369d42..8dd04eb 100644
39613 --- a/drivers/gpu/drm/radeon/radeon_drv.h
39614 +++ b/drivers/gpu/drm/radeon/radeon_drv.h
39615 @@ -258,7 +258,7 @@ typedef struct drm_radeon_private {
39616
39617 /* SW interrupt */
39618 wait_queue_head_t swi_queue;
39619 - atomic_t swi_emitted;
39620 + atomic_unchecked_t swi_emitted;
39621 int vblank_crtc;
39622 uint32_t irq_enable_reg;
39623 uint32_t r500_disp_irq_reg;
39624 diff --git a/drivers/gpu/drm/radeon/radeon_ioc32.c b/drivers/gpu/drm/radeon/radeon_ioc32.c
39625 index c180df8..5fd8186 100644
39626 --- a/drivers/gpu/drm/radeon/radeon_ioc32.c
39627 +++ b/drivers/gpu/drm/radeon/radeon_ioc32.c
39628 @@ -358,7 +358,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
39629 request = compat_alloc_user_space(sizeof(*request));
39630 if (!access_ok(VERIFY_WRITE, request, sizeof(*request))
39631 || __put_user(req32.param, &request->param)
39632 - || __put_user((void __user *)(unsigned long)req32.value,
39633 + || __put_user((unsigned long)req32.value,
39634 &request->value))
39635 return -EFAULT;
39636
39637 @@ -368,7 +368,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
39638 #define compat_radeon_cp_setparam NULL
39639 #endif /* X86_64 || IA64 */
39640
39641 -static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
39642 +static drm_ioctl_compat_t radeon_compat_ioctls[] = {
39643 [DRM_RADEON_CP_INIT] = compat_radeon_cp_init,
39644 [DRM_RADEON_CLEAR] = compat_radeon_cp_clear,
39645 [DRM_RADEON_STIPPLE] = compat_radeon_cp_stipple,
39646 @@ -393,18 +393,15 @@ static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
39647 long radeon_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
39648 {
39649 unsigned int nr = DRM_IOCTL_NR(cmd);
39650 - drm_ioctl_compat_t *fn = NULL;
39651 int ret;
39652
39653 if (nr < DRM_COMMAND_BASE)
39654 return drm_compat_ioctl(filp, cmd, arg);
39655
39656 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls))
39657 - fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
39658 -
39659 - if (fn != NULL)
39660 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls)) {
39661 + drm_ioctl_compat_t fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
39662 ret = (*fn) (filp, cmd, arg);
39663 - else
39664 + } else
39665 ret = drm_ioctl(filp, cmd, arg);
39666
39667 return ret;
39668 diff --git a/drivers/gpu/drm/radeon/radeon_irq.c b/drivers/gpu/drm/radeon/radeon_irq.c
39669 index 8d68e97..9dcfed8 100644
39670 --- a/drivers/gpu/drm/radeon/radeon_irq.c
39671 +++ b/drivers/gpu/drm/radeon/radeon_irq.c
39672 @@ -226,8 +226,8 @@ static int radeon_emit_irq(struct drm_device * dev)
39673 unsigned int ret;
39674 RING_LOCALS;
39675
39676 - atomic_inc(&dev_priv->swi_emitted);
39677 - ret = atomic_read(&dev_priv->swi_emitted);
39678 + atomic_inc_unchecked(&dev_priv->swi_emitted);
39679 + ret = atomic_read_unchecked(&dev_priv->swi_emitted);
39680
39681 BEGIN_RING(4);
39682 OUT_RING_REG(RADEON_LAST_SWI_REG, ret);
39683 @@ -353,7 +353,7 @@ int radeon_driver_irq_postinstall(struct drm_device *dev)
39684 drm_radeon_private_t *dev_priv =
39685 (drm_radeon_private_t *) dev->dev_private;
39686
39687 - atomic_set(&dev_priv->swi_emitted, 0);
39688 + atomic_set_unchecked(&dev_priv->swi_emitted, 0);
39689 DRM_INIT_WAITQUEUE(&dev_priv->swi_queue);
39690
39691 dev->max_vblank_count = 0x001fffff;
39692 diff --git a/drivers/gpu/drm/radeon/radeon_state.c b/drivers/gpu/drm/radeon/radeon_state.c
39693 index 4d20910..6726b6d 100644
39694 --- a/drivers/gpu/drm/radeon/radeon_state.c
39695 +++ b/drivers/gpu/drm/radeon/radeon_state.c
39696 @@ -2168,7 +2168,7 @@ static int radeon_cp_clear(struct drm_device *dev, void *data, struct drm_file *
39697 if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS)
39698 sarea_priv->nbox = RADEON_NR_SAREA_CLIPRECTS;
39699
39700 - if (DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
39701 + if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS || DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
39702 sarea_priv->nbox * sizeof(depth_boxes[0])))
39703 return -EFAULT;
39704
39705 @@ -3031,7 +3031,7 @@ static int radeon_cp_getparam(struct drm_device *dev, void *data, struct drm_fil
39706 {
39707 drm_radeon_private_t *dev_priv = dev->dev_private;
39708 drm_radeon_getparam_t *param = data;
39709 - int value;
39710 + int value = 0;
39711
39712 DRM_DEBUG("pid=%d\n", DRM_CURRENTPID);
39713
39714 diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
39715 index 71245d6..94c556d 100644
39716 --- a/drivers/gpu/drm/radeon/radeon_ttm.c
39717 +++ b/drivers/gpu/drm/radeon/radeon_ttm.c
39718 @@ -784,7 +784,7 @@ void radeon_ttm_set_active_vram_size(struct radeon_device *rdev, u64 size)
39719 man->size = size >> PAGE_SHIFT;
39720 }
39721
39722 -static struct vm_operations_struct radeon_ttm_vm_ops;
39723 +static vm_operations_struct_no_const radeon_ttm_vm_ops __read_only;
39724 static const struct vm_operations_struct *ttm_vm_ops = NULL;
39725
39726 static int radeon_ttm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
39727 @@ -825,8 +825,10 @@ int radeon_mmap(struct file *filp, struct vm_area_struct *vma)
39728 }
39729 if (unlikely(ttm_vm_ops == NULL)) {
39730 ttm_vm_ops = vma->vm_ops;
39731 + pax_open_kernel();
39732 radeon_ttm_vm_ops = *ttm_vm_ops;
39733 radeon_ttm_vm_ops.fault = &radeon_ttm_fault;
39734 + pax_close_kernel();
39735 }
39736 vma->vm_ops = &radeon_ttm_vm_ops;
39737 return 0;
39738 @@ -855,38 +857,33 @@ static int radeon_mm_dump_table(struct seq_file *m, void *data)
39739 static int radeon_ttm_debugfs_init(struct radeon_device *rdev)
39740 {
39741 #if defined(CONFIG_DEBUG_FS)
39742 - static struct drm_info_list radeon_mem_types_list[RADEON_DEBUGFS_MEM_TYPES+2];
39743 - static char radeon_mem_types_names[RADEON_DEBUGFS_MEM_TYPES+2][32];
39744 - unsigned i;
39745 + static struct drm_info_list radeon_mem_types_list[RADEON_DEBUGFS_MEM_TYPES+2] = {
39746 + {
39747 + .name = "radeon_vram_mm",
39748 + .show = &radeon_mm_dump_table,
39749 + },
39750 + {
39751 + .name = "radeon_gtt_mm",
39752 + .show = &radeon_mm_dump_table,
39753 + },
39754 + {
39755 + .name = "ttm_page_pool",
39756 + .show = &ttm_page_alloc_debugfs,
39757 + },
39758 + {
39759 + .name = "ttm_dma_page_pool",
39760 + .show = &ttm_dma_page_alloc_debugfs,
39761 + },
39762 + };
39763 + unsigned i = RADEON_DEBUGFS_MEM_TYPES + 1;
39764
39765 - for (i = 0; i < RADEON_DEBUGFS_MEM_TYPES; i++) {
39766 - if (i == 0)
39767 - sprintf(radeon_mem_types_names[i], "radeon_vram_mm");
39768 - else
39769 - sprintf(radeon_mem_types_names[i], "radeon_gtt_mm");
39770 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
39771 - radeon_mem_types_list[i].show = &radeon_mm_dump_table;
39772 - radeon_mem_types_list[i].driver_features = 0;
39773 - if (i == 0)
39774 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
39775 - else
39776 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
39777 -
39778 - }
39779 - /* Add ttm page pool to debugfs */
39780 - sprintf(radeon_mem_types_names[i], "ttm_page_pool");
39781 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
39782 - radeon_mem_types_list[i].show = &ttm_page_alloc_debugfs;
39783 - radeon_mem_types_list[i].driver_features = 0;
39784 - radeon_mem_types_list[i++].data = NULL;
39785 + pax_open_kernel();
39786 + *(void **)&radeon_mem_types_list[0].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
39787 + *(void **)&radeon_mem_types_list[1].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
39788 + pax_close_kernel();
39789 #ifdef CONFIG_SWIOTLB
39790 - if (swiotlb_nr_tbl()) {
39791 - sprintf(radeon_mem_types_names[i], "ttm_dma_page_pool");
39792 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
39793 - radeon_mem_types_list[i].show = &ttm_dma_page_alloc_debugfs;
39794 - radeon_mem_types_list[i].driver_features = 0;
39795 - radeon_mem_types_list[i++].data = NULL;
39796 - }
39797 + if (swiotlb_nr_tbl())
39798 + i++;
39799 #endif
39800 return radeon_debugfs_add_files(rdev, radeon_mem_types_list, i);
39801
39802 diff --git a/drivers/gpu/drm/radeon/rs690.c b/drivers/gpu/drm/radeon/rs690.c
39803 index 1447d79..40b2a5b 100644
39804 --- a/drivers/gpu/drm/radeon/rs690.c
39805 +++ b/drivers/gpu/drm/radeon/rs690.c
39806 @@ -345,9 +345,11 @@ static void rs690_crtc_bandwidth_compute(struct radeon_device *rdev,
39807 if (max_bandwidth.full > rdev->pm.sideport_bandwidth.full &&
39808 rdev->pm.sideport_bandwidth.full)
39809 max_bandwidth = rdev->pm.sideport_bandwidth;
39810 - read_delay_latency.full = dfixed_const(370 * 800 * 1000);
39811 + read_delay_latency.full = dfixed_const(800 * 1000);
39812 read_delay_latency.full = dfixed_div(read_delay_latency,
39813 rdev->pm.igp_sideport_mclk);
39814 + a.full = dfixed_const(370);
39815 + read_delay_latency.full = dfixed_mul(read_delay_latency, a);
39816 } else {
39817 if (max_bandwidth.full > rdev->pm.k8_bandwidth.full &&
39818 rdev->pm.k8_bandwidth.full)
39819 diff --git a/drivers/gpu/drm/ttm/ttm_memory.c b/drivers/gpu/drm/ttm/ttm_memory.c
39820 index dbc2def..0a9f710 100644
39821 --- a/drivers/gpu/drm/ttm/ttm_memory.c
39822 +++ b/drivers/gpu/drm/ttm/ttm_memory.c
39823 @@ -264,7 +264,7 @@ static int ttm_mem_init_kernel_zone(struct ttm_mem_global *glob,
39824 zone->glob = glob;
39825 glob->zone_kernel = zone;
39826 ret = kobject_init_and_add(
39827 - &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, zone->name);
39828 + &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, "%s", zone->name);
39829 if (unlikely(ret != 0)) {
39830 kobject_put(&zone->kobj);
39831 return ret;
39832 @@ -347,7 +347,7 @@ static int ttm_mem_init_dma32_zone(struct ttm_mem_global *glob,
39833 zone->glob = glob;
39834 glob->zone_dma32 = zone;
39835 ret = kobject_init_and_add(
39836 - &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, zone->name);
39837 + &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, "%s", zone->name);
39838 if (unlikely(ret != 0)) {
39839 kobject_put(&zone->kobj);
39840 return ret;
39841 diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c
39842 index 863bef9..cba15cf 100644
39843 --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c
39844 +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c
39845 @@ -391,9 +391,9 @@ out:
39846 static unsigned long
39847 ttm_pool_shrink_scan(struct shrinker *shrink, struct shrink_control *sc)
39848 {
39849 - static atomic_t start_pool = ATOMIC_INIT(0);
39850 + static atomic_unchecked_t start_pool = ATOMIC_INIT(0);
39851 unsigned i;
39852 - unsigned pool_offset = atomic_add_return(1, &start_pool);
39853 + unsigned pool_offset = atomic_add_return_unchecked(1, &start_pool);
39854 struct ttm_page_pool *pool;
39855 int shrink_pages = sc->nr_to_scan;
39856 unsigned long freed = 0;
39857 diff --git a/drivers/gpu/drm/udl/udl_fb.c b/drivers/gpu/drm/udl/udl_fb.c
39858 index 97e9d61..bf23c461 100644
39859 --- a/drivers/gpu/drm/udl/udl_fb.c
39860 +++ b/drivers/gpu/drm/udl/udl_fb.c
39861 @@ -367,7 +367,6 @@ static int udl_fb_release(struct fb_info *info, int user)
39862 fb_deferred_io_cleanup(info);
39863 kfree(info->fbdefio);
39864 info->fbdefio = NULL;
39865 - info->fbops->fb_mmap = udl_fb_mmap;
39866 }
39867
39868 pr_warn("released /dev/fb%d user=%d count=%d\n",
39869 diff --git a/drivers/gpu/drm/via/via_drv.h b/drivers/gpu/drm/via/via_drv.h
39870 index a811ef2..ff99b05 100644
39871 --- a/drivers/gpu/drm/via/via_drv.h
39872 +++ b/drivers/gpu/drm/via/via_drv.h
39873 @@ -51,7 +51,7 @@ typedef struct drm_via_ring_buffer {
39874 typedef uint32_t maskarray_t[5];
39875
39876 typedef struct drm_via_irq {
39877 - atomic_t irq_received;
39878 + atomic_unchecked_t irq_received;
39879 uint32_t pending_mask;
39880 uint32_t enable_mask;
39881 wait_queue_head_t irq_queue;
39882 @@ -75,7 +75,7 @@ typedef struct drm_via_private {
39883 struct timeval last_vblank;
39884 int last_vblank_valid;
39885 unsigned usec_per_vblank;
39886 - atomic_t vbl_received;
39887 + atomic_unchecked_t vbl_received;
39888 drm_via_state_t hc_state;
39889 char pci_buf[VIA_PCI_BUF_SIZE];
39890 const uint32_t *fire_offsets[VIA_FIRE_BUF_SIZE];
39891 diff --git a/drivers/gpu/drm/via/via_irq.c b/drivers/gpu/drm/via/via_irq.c
39892 index ac98964..5dbf512 100644
39893 --- a/drivers/gpu/drm/via/via_irq.c
39894 +++ b/drivers/gpu/drm/via/via_irq.c
39895 @@ -101,7 +101,7 @@ u32 via_get_vblank_counter(struct drm_device *dev, int crtc)
39896 if (crtc != 0)
39897 return 0;
39898
39899 - return atomic_read(&dev_priv->vbl_received);
39900 + return atomic_read_unchecked(&dev_priv->vbl_received);
39901 }
39902
39903 irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
39904 @@ -116,8 +116,8 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
39905
39906 status = VIA_READ(VIA_REG_INTERRUPT);
39907 if (status & VIA_IRQ_VBLANK_PENDING) {
39908 - atomic_inc(&dev_priv->vbl_received);
39909 - if (!(atomic_read(&dev_priv->vbl_received) & 0x0F)) {
39910 + atomic_inc_unchecked(&dev_priv->vbl_received);
39911 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0x0F)) {
39912 do_gettimeofday(&cur_vblank);
39913 if (dev_priv->last_vblank_valid) {
39914 dev_priv->usec_per_vblank =
39915 @@ -127,7 +127,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
39916 dev_priv->last_vblank = cur_vblank;
39917 dev_priv->last_vblank_valid = 1;
39918 }
39919 - if (!(atomic_read(&dev_priv->vbl_received) & 0xFF)) {
39920 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0xFF)) {
39921 DRM_DEBUG("US per vblank is: %u\n",
39922 dev_priv->usec_per_vblank);
39923 }
39924 @@ -137,7 +137,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
39925
39926 for (i = 0; i < dev_priv->num_irqs; ++i) {
39927 if (status & cur_irq->pending_mask) {
39928 - atomic_inc(&cur_irq->irq_received);
39929 + atomic_inc_unchecked(&cur_irq->irq_received);
39930 DRM_WAKEUP(&cur_irq->irq_queue);
39931 handled = 1;
39932 if (dev_priv->irq_map[drm_via_irq_dma0_td] == i)
39933 @@ -242,11 +242,11 @@ via_driver_irq_wait(struct drm_device *dev, unsigned int irq, int force_sequence
39934 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
39935 ((VIA_READ(masks[irq][2]) & masks[irq][3]) ==
39936 masks[irq][4]));
39937 - cur_irq_sequence = atomic_read(&cur_irq->irq_received);
39938 + cur_irq_sequence = atomic_read_unchecked(&cur_irq->irq_received);
39939 } else {
39940 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
39941 (((cur_irq_sequence =
39942 - atomic_read(&cur_irq->irq_received)) -
39943 + atomic_read_unchecked(&cur_irq->irq_received)) -
39944 *sequence) <= (1 << 23)));
39945 }
39946 *sequence = cur_irq_sequence;
39947 @@ -284,7 +284,7 @@ void via_driver_irq_preinstall(struct drm_device *dev)
39948 }
39949
39950 for (i = 0; i < dev_priv->num_irqs; ++i) {
39951 - atomic_set(&cur_irq->irq_received, 0);
39952 + atomic_set_unchecked(&cur_irq->irq_received, 0);
39953 cur_irq->enable_mask = dev_priv->irq_masks[i][0];
39954 cur_irq->pending_mask = dev_priv->irq_masks[i][1];
39955 DRM_INIT_WAITQUEUE(&cur_irq->irq_queue);
39956 @@ -366,7 +366,7 @@ int via_wait_irq(struct drm_device *dev, void *data, struct drm_file *file_priv)
39957 switch (irqwait->request.type & ~VIA_IRQ_FLAGS_MASK) {
39958 case VIA_IRQ_RELATIVE:
39959 irqwait->request.sequence +=
39960 - atomic_read(&cur_irq->irq_received);
39961 + atomic_read_unchecked(&cur_irq->irq_received);
39962 irqwait->request.type &= ~_DRM_VBLANK_RELATIVE;
39963 case VIA_IRQ_ABSOLUTE:
39964 break;
39965 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
39966 index 150ec64..f5165f2 100644
39967 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
39968 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
39969 @@ -290,7 +290,7 @@ struct vmw_private {
39970 * Fencing and IRQs.
39971 */
39972
39973 - atomic_t marker_seq;
39974 + atomic_unchecked_t marker_seq;
39975 wait_queue_head_t fence_queue;
39976 wait_queue_head_t fifo_queue;
39977 int fence_queue_waiters; /* Protected by hw_mutex */
39978 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
39979 index 3eb1486..0a47ee9 100644
39980 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
39981 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
39982 @@ -137,7 +137,7 @@ int vmw_fifo_init(struct vmw_private *dev_priv, struct vmw_fifo_state *fifo)
39983 (unsigned int) min,
39984 (unsigned int) fifo->capabilities);
39985
39986 - atomic_set(&dev_priv->marker_seq, dev_priv->last_read_seqno);
39987 + atomic_set_unchecked(&dev_priv->marker_seq, dev_priv->last_read_seqno);
39988 iowrite32(dev_priv->last_read_seqno, fifo_mem + SVGA_FIFO_FENCE);
39989 vmw_marker_queue_init(&fifo->marker_queue);
39990 return vmw_fifo_send_fence(dev_priv, &dummy);
39991 @@ -355,7 +355,7 @@ void *vmw_fifo_reserve(struct vmw_private *dev_priv, uint32_t bytes)
39992 if (reserveable)
39993 iowrite32(bytes, fifo_mem +
39994 SVGA_FIFO_RESERVED);
39995 - return fifo_mem + (next_cmd >> 2);
39996 + return (__le32 __force_kernel *)fifo_mem + (next_cmd >> 2);
39997 } else {
39998 need_bounce = true;
39999 }
40000 @@ -475,7 +475,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
40001
40002 fm = vmw_fifo_reserve(dev_priv, bytes);
40003 if (unlikely(fm == NULL)) {
40004 - *seqno = atomic_read(&dev_priv->marker_seq);
40005 + *seqno = atomic_read_unchecked(&dev_priv->marker_seq);
40006 ret = -ENOMEM;
40007 (void)vmw_fallback_wait(dev_priv, false, true, *seqno,
40008 false, 3*HZ);
40009 @@ -483,7 +483,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
40010 }
40011
40012 do {
40013 - *seqno = atomic_add_return(1, &dev_priv->marker_seq);
40014 + *seqno = atomic_add_return_unchecked(1, &dev_priv->marker_seq);
40015 } while (*seqno == 0);
40016
40017 if (!(fifo_state->capabilities & SVGA_FIFO_CAP_FENCE)) {
40018 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
40019 index c509d40..3b640c3 100644
40020 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
40021 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
40022 @@ -138,7 +138,7 @@ int vmw_present_ioctl(struct drm_device *dev, void *data,
40023 int ret;
40024
40025 num_clips = arg->num_clips;
40026 - clips_ptr = (struct drm_vmw_rect *)(unsigned long)arg->clips_ptr;
40027 + clips_ptr = (struct drm_vmw_rect __user *)(unsigned long)arg->clips_ptr;
40028
40029 if (unlikely(num_clips == 0))
40030 return 0;
40031 @@ -222,7 +222,7 @@ int vmw_present_readback_ioctl(struct drm_device *dev, void *data,
40032 int ret;
40033
40034 num_clips = arg->num_clips;
40035 - clips_ptr = (struct drm_vmw_rect *)(unsigned long)arg->clips_ptr;
40036 + clips_ptr = (struct drm_vmw_rect __user *)(unsigned long)arg->clips_ptr;
40037
40038 if (unlikely(num_clips == 0))
40039 return 0;
40040 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
40041 index 4640adb..e1384ed 100644
40042 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
40043 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
40044 @@ -107,7 +107,7 @@ bool vmw_seqno_passed(struct vmw_private *dev_priv,
40045 * emitted. Then the fence is stale and signaled.
40046 */
40047
40048 - ret = ((atomic_read(&dev_priv->marker_seq) - seqno)
40049 + ret = ((atomic_read_unchecked(&dev_priv->marker_seq) - seqno)
40050 > VMW_FENCE_WRAP);
40051
40052 return ret;
40053 @@ -138,7 +138,7 @@ int vmw_fallback_wait(struct vmw_private *dev_priv,
40054
40055 if (fifo_idle)
40056 down_read(&fifo_state->rwsem);
40057 - signal_seq = atomic_read(&dev_priv->marker_seq);
40058 + signal_seq = atomic_read_unchecked(&dev_priv->marker_seq);
40059 ret = 0;
40060
40061 for (;;) {
40062 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
40063 index 8a8725c2..afed796 100644
40064 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
40065 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
40066 @@ -151,7 +151,7 @@ int vmw_wait_lag(struct vmw_private *dev_priv,
40067 while (!vmw_lag_lt(queue, us)) {
40068 spin_lock(&queue->lock);
40069 if (list_empty(&queue->head))
40070 - seqno = atomic_read(&dev_priv->marker_seq);
40071 + seqno = atomic_read_unchecked(&dev_priv->marker_seq);
40072 else {
40073 marker = list_first_entry(&queue->head,
40074 struct vmw_marker, head);
40075 diff --git a/drivers/gpu/host1x/drm/dc.c b/drivers/gpu/host1x/drm/dc.c
40076 index b1a05ad..1c9d899 100644
40077 --- a/drivers/gpu/host1x/drm/dc.c
40078 +++ b/drivers/gpu/host1x/drm/dc.c
40079 @@ -1004,7 +1004,7 @@ static int tegra_dc_debugfs_init(struct tegra_dc *dc, struct drm_minor *minor)
40080 }
40081
40082 for (i = 0; i < ARRAY_SIZE(debugfs_files); i++)
40083 - dc->debugfs_files[i].data = dc;
40084 + *(void **)&dc->debugfs_files[i].data = dc;
40085
40086 err = drm_debugfs_create_files(dc->debugfs_files,
40087 ARRAY_SIZE(debugfs_files),
40088 diff --git a/drivers/gpu/vga/vga_switcheroo.c b/drivers/gpu/vga/vga_switcheroo.c
40089 index ec0ae2d..dc0780b 100644
40090 --- a/drivers/gpu/vga/vga_switcheroo.c
40091 +++ b/drivers/gpu/vga/vga_switcheroo.c
40092 @@ -643,7 +643,7 @@ static int vga_switcheroo_runtime_resume(struct device *dev)
40093
40094 /* this version is for the case where the power switch is separate
40095 to the device being powered down. */
40096 -int vga_switcheroo_init_domain_pm_ops(struct device *dev, struct dev_pm_domain *domain)
40097 +int vga_switcheroo_init_domain_pm_ops(struct device *dev, dev_pm_domain_no_const *domain)
40098 {
40099 /* copy over all the bus versions */
40100 if (dev->bus && dev->bus->pm) {
40101 @@ -688,7 +688,7 @@ static int vga_switcheroo_runtime_resume_hdmi_audio(struct device *dev)
40102 return ret;
40103 }
40104
40105 -int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, struct dev_pm_domain *domain)
40106 +int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, dev_pm_domain_no_const *domain)
40107 {
40108 /* copy over all the bus versions */
40109 if (dev->bus && dev->bus->pm) {
40110 diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
40111 index aedfe50..1dc929b 100644
40112 --- a/drivers/hid/hid-core.c
40113 +++ b/drivers/hid/hid-core.c
40114 @@ -2416,7 +2416,7 @@ EXPORT_SYMBOL_GPL(hid_ignore);
40115
40116 int hid_add_device(struct hid_device *hdev)
40117 {
40118 - static atomic_t id = ATOMIC_INIT(0);
40119 + static atomic_unchecked_t id = ATOMIC_INIT(0);
40120 int ret;
40121
40122 if (WARN_ON(hdev->status & HID_STAT_ADDED))
40123 @@ -2450,7 +2450,7 @@ int hid_add_device(struct hid_device *hdev)
40124 /* XXX hack, any other cleaner solution after the driver core
40125 * is converted to allow more than 20 bytes as the device name? */
40126 dev_set_name(&hdev->dev, "%04X:%04X:%04X.%04X", hdev->bus,
40127 - hdev->vendor, hdev->product, atomic_inc_return(&id));
40128 + hdev->vendor, hdev->product, atomic_inc_return_unchecked(&id));
40129
40130 hid_debug_register(hdev, dev_name(&hdev->dev));
40131 ret = device_add(&hdev->dev);
40132 diff --git a/drivers/hid/hid-wiimote-debug.c b/drivers/hid/hid-wiimote-debug.c
40133 index c13fb5b..55a3802 100644
40134 --- a/drivers/hid/hid-wiimote-debug.c
40135 +++ b/drivers/hid/hid-wiimote-debug.c
40136 @@ -66,7 +66,7 @@ static ssize_t wiidebug_eeprom_read(struct file *f, char __user *u, size_t s,
40137 else if (size == 0)
40138 return -EIO;
40139
40140 - if (copy_to_user(u, buf, size))
40141 + if (size > sizeof(buf) || copy_to_user(u, buf, size))
40142 return -EFAULT;
40143
40144 *off += size;
40145 diff --git a/drivers/hid/uhid.c b/drivers/hid/uhid.c
40146 index cedc6da..2c3da2a 100644
40147 --- a/drivers/hid/uhid.c
40148 +++ b/drivers/hid/uhid.c
40149 @@ -47,7 +47,7 @@ struct uhid_device {
40150 struct mutex report_lock;
40151 wait_queue_head_t report_wait;
40152 atomic_t report_done;
40153 - atomic_t report_id;
40154 + atomic_unchecked_t report_id;
40155 struct uhid_event report_buf;
40156 };
40157
40158 @@ -163,7 +163,7 @@ static int uhid_hid_get_raw(struct hid_device *hid, unsigned char rnum,
40159
40160 spin_lock_irqsave(&uhid->qlock, flags);
40161 ev->type = UHID_FEATURE;
40162 - ev->u.feature.id = atomic_inc_return(&uhid->report_id);
40163 + ev->u.feature.id = atomic_inc_return_unchecked(&uhid->report_id);
40164 ev->u.feature.rnum = rnum;
40165 ev->u.feature.rtype = report_type;
40166
40167 @@ -446,7 +446,7 @@ static int uhid_dev_feature_answer(struct uhid_device *uhid,
40168 spin_lock_irqsave(&uhid->qlock, flags);
40169
40170 /* id for old report; drop it silently */
40171 - if (atomic_read(&uhid->report_id) != ev->u.feature_answer.id)
40172 + if (atomic_read_unchecked(&uhid->report_id) != ev->u.feature_answer.id)
40173 goto unlock;
40174 if (atomic_read(&uhid->report_done))
40175 goto unlock;
40176 diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
40177 index 6de6c98..18319e9 100644
40178 --- a/drivers/hv/channel.c
40179 +++ b/drivers/hv/channel.c
40180 @@ -406,8 +406,8 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
40181 int ret = 0;
40182 int t;
40183
40184 - next_gpadl_handle = atomic_read(&vmbus_connection.next_gpadl_handle);
40185 - atomic_inc(&vmbus_connection.next_gpadl_handle);
40186 + next_gpadl_handle = atomic_read_unchecked(&vmbus_connection.next_gpadl_handle);
40187 + atomic_inc_unchecked(&vmbus_connection.next_gpadl_handle);
40188
40189 ret = create_gpadl_header(kbuffer, size, &msginfo, &msgcount);
40190 if (ret)
40191 diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
40192 index 88f4096..e50452e 100644
40193 --- a/drivers/hv/hv.c
40194 +++ b/drivers/hv/hv.c
40195 @@ -112,7 +112,7 @@ static u64 do_hypercall(u64 control, void *input, void *output)
40196 u64 output_address = (output) ? virt_to_phys(output) : 0;
40197 u32 output_address_hi = output_address >> 32;
40198 u32 output_address_lo = output_address & 0xFFFFFFFF;
40199 - void *hypercall_page = hv_context.hypercall_page;
40200 + void *hypercall_page = ktva_ktla(hv_context.hypercall_page);
40201
40202 __asm__ __volatile__ ("call *%8" : "=d"(hv_status_hi),
40203 "=a"(hv_status_lo) : "d" (control_hi),
40204 diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c
40205 index 7e17a54..a50a33d 100644
40206 --- a/drivers/hv/hv_balloon.c
40207 +++ b/drivers/hv/hv_balloon.c
40208 @@ -464,7 +464,7 @@ MODULE_PARM_DESC(hot_add, "If set attempt memory hot_add");
40209
40210 module_param(pressure_report_delay, uint, (S_IRUGO | S_IWUSR));
40211 MODULE_PARM_DESC(pressure_report_delay, "Delay in secs in reporting pressure");
40212 -static atomic_t trans_id = ATOMIC_INIT(0);
40213 +static atomic_unchecked_t trans_id = ATOMIC_INIT(0);
40214
40215 static int dm_ring_size = (5 * PAGE_SIZE);
40216
40217 @@ -886,7 +886,7 @@ static void hot_add_req(struct work_struct *dummy)
40218 pr_info("Memory hot add failed\n");
40219
40220 dm->state = DM_INITIALIZED;
40221 - resp.hdr.trans_id = atomic_inc_return(&trans_id);
40222 + resp.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
40223 vmbus_sendpacket(dm->dev->channel, &resp,
40224 sizeof(struct dm_hot_add_response),
40225 (unsigned long)NULL,
40226 @@ -960,7 +960,7 @@ static void post_status(struct hv_dynmem_device *dm)
40227 memset(&status, 0, sizeof(struct dm_status));
40228 status.hdr.type = DM_STATUS_REPORT;
40229 status.hdr.size = sizeof(struct dm_status);
40230 - status.hdr.trans_id = atomic_inc_return(&trans_id);
40231 + status.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
40232
40233 /*
40234 * The host expects the guest to report free memory.
40235 @@ -980,7 +980,7 @@ static void post_status(struct hv_dynmem_device *dm)
40236 * send the status. This can happen if we were interrupted
40237 * after we picked our transaction ID.
40238 */
40239 - if (status.hdr.trans_id != atomic_read(&trans_id))
40240 + if (status.hdr.trans_id != atomic_read_unchecked(&trans_id))
40241 return;
40242
40243 vmbus_sendpacket(dm->dev->channel, &status,
40244 @@ -1108,7 +1108,7 @@ static void balloon_up(struct work_struct *dummy)
40245 */
40246
40247 do {
40248 - bl_resp->hdr.trans_id = atomic_inc_return(&trans_id);
40249 + bl_resp->hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
40250 ret = vmbus_sendpacket(dm_device.dev->channel,
40251 bl_resp,
40252 bl_resp->hdr.size,
40253 @@ -1152,7 +1152,7 @@ static void balloon_down(struct hv_dynmem_device *dm,
40254
40255 memset(&resp, 0, sizeof(struct dm_unballoon_response));
40256 resp.hdr.type = DM_UNBALLOON_RESPONSE;
40257 - resp.hdr.trans_id = atomic_inc_return(&trans_id);
40258 + resp.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
40259 resp.hdr.size = sizeof(struct dm_unballoon_response);
40260
40261 vmbus_sendpacket(dm_device.dev->channel, &resp,
40262 @@ -1215,7 +1215,7 @@ static void version_resp(struct hv_dynmem_device *dm,
40263 memset(&version_req, 0, sizeof(struct dm_version_request));
40264 version_req.hdr.type = DM_VERSION_REQUEST;
40265 version_req.hdr.size = sizeof(struct dm_version_request);
40266 - version_req.hdr.trans_id = atomic_inc_return(&trans_id);
40267 + version_req.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
40268 version_req.version.version = DYNMEM_PROTOCOL_VERSION_WIN7;
40269 version_req.is_last_attempt = 1;
40270
40271 @@ -1385,7 +1385,7 @@ static int balloon_probe(struct hv_device *dev,
40272 memset(&version_req, 0, sizeof(struct dm_version_request));
40273 version_req.hdr.type = DM_VERSION_REQUEST;
40274 version_req.hdr.size = sizeof(struct dm_version_request);
40275 - version_req.hdr.trans_id = atomic_inc_return(&trans_id);
40276 + version_req.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
40277 version_req.version.version = DYNMEM_PROTOCOL_VERSION_WIN8;
40278 version_req.is_last_attempt = 0;
40279
40280 @@ -1416,7 +1416,7 @@ static int balloon_probe(struct hv_device *dev,
40281 memset(&cap_msg, 0, sizeof(struct dm_capabilities));
40282 cap_msg.hdr.type = DM_CAPABILITIES_REPORT;
40283 cap_msg.hdr.size = sizeof(struct dm_capabilities);
40284 - cap_msg.hdr.trans_id = atomic_inc_return(&trans_id);
40285 + cap_msg.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
40286
40287 cap_msg.caps.cap_bits.balloon = 1;
40288 cap_msg.caps.cap_bits.hot_add = 1;
40289 diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
40290 index d84918f..7f38f9f 100644
40291 --- a/drivers/hv/hyperv_vmbus.h
40292 +++ b/drivers/hv/hyperv_vmbus.h
40293 @@ -595,7 +595,7 @@ enum vmbus_connect_state {
40294 struct vmbus_connection {
40295 enum vmbus_connect_state conn_state;
40296
40297 - atomic_t next_gpadl_handle;
40298 + atomic_unchecked_t next_gpadl_handle;
40299
40300 /*
40301 * Represents channel interrupts. Each bit position represents a
40302 diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
40303 index f9fe46f..356b119 100644
40304 --- a/drivers/hv/vmbus_drv.c
40305 +++ b/drivers/hv/vmbus_drv.c
40306 @@ -672,10 +672,10 @@ int vmbus_device_register(struct hv_device *child_device_obj)
40307 {
40308 int ret = 0;
40309
40310 - static atomic_t device_num = ATOMIC_INIT(0);
40311 + static atomic_unchecked_t device_num = ATOMIC_INIT(0);
40312
40313 dev_set_name(&child_device_obj->device, "vmbus_0_%d",
40314 - atomic_inc_return(&device_num));
40315 + atomic_inc_return_unchecked(&device_num));
40316
40317 child_device_obj->device.bus = &hv_bus;
40318 child_device_obj->device.parent = &hv_acpi_dev->dev;
40319 diff --git a/drivers/hwmon/acpi_power_meter.c b/drivers/hwmon/acpi_power_meter.c
40320 index a9e3d01..9dd246e 100644
40321 --- a/drivers/hwmon/acpi_power_meter.c
40322 +++ b/drivers/hwmon/acpi_power_meter.c
40323 @@ -117,7 +117,7 @@ struct sensor_template {
40324 struct device_attribute *devattr,
40325 const char *buf, size_t count);
40326 int index;
40327 -};
40328 +} __do_const;
40329
40330 /* Averaging interval */
40331 static int update_avg_interval(struct acpi_power_meter_resource *resource)
40332 @@ -629,7 +629,7 @@ static int register_attrs(struct acpi_power_meter_resource *resource,
40333 struct sensor_template *attrs)
40334 {
40335 struct device *dev = &resource->acpi_dev->dev;
40336 - struct sensor_device_attribute *sensors =
40337 + sensor_device_attribute_no_const *sensors =
40338 &resource->sensors[resource->num_sensors];
40339 int res = 0;
40340
40341 diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
40342 index 3288f13..71cfb4e 100644
40343 --- a/drivers/hwmon/applesmc.c
40344 +++ b/drivers/hwmon/applesmc.c
40345 @@ -1106,7 +1106,7 @@ static int applesmc_create_nodes(struct applesmc_node_group *groups, int num)
40346 {
40347 struct applesmc_node_group *grp;
40348 struct applesmc_dev_attr *node;
40349 - struct attribute *attr;
40350 + attribute_no_const *attr;
40351 int ret, i;
40352
40353 for (grp = groups; grp->format; grp++) {
40354 diff --git a/drivers/hwmon/asus_atk0110.c b/drivers/hwmon/asus_atk0110.c
40355 index b25c643..a13460d 100644
40356 --- a/drivers/hwmon/asus_atk0110.c
40357 +++ b/drivers/hwmon/asus_atk0110.c
40358 @@ -152,10 +152,10 @@ MODULE_DEVICE_TABLE(acpi, atk_ids);
40359 struct atk_sensor_data {
40360 struct list_head list;
40361 struct atk_data *data;
40362 - struct device_attribute label_attr;
40363 - struct device_attribute input_attr;
40364 - struct device_attribute limit1_attr;
40365 - struct device_attribute limit2_attr;
40366 + device_attribute_no_const label_attr;
40367 + device_attribute_no_const input_attr;
40368 + device_attribute_no_const limit1_attr;
40369 + device_attribute_no_const limit2_attr;
40370 char label_attr_name[ATTR_NAME_SIZE];
40371 char input_attr_name[ATTR_NAME_SIZE];
40372 char limit1_attr_name[ATTR_NAME_SIZE];
40373 @@ -275,7 +275,7 @@ static ssize_t atk_name_show(struct device *dev,
40374 static struct device_attribute atk_name_attr =
40375 __ATTR(name, 0444, atk_name_show, NULL);
40376
40377 -static void atk_init_attribute(struct device_attribute *attr, char *name,
40378 +static void atk_init_attribute(device_attribute_no_const *attr, char *name,
40379 sysfs_show_func show)
40380 {
40381 sysfs_attr_init(&attr->attr);
40382 diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
40383 index 78be661..4dd032f 100644
40384 --- a/drivers/hwmon/coretemp.c
40385 +++ b/drivers/hwmon/coretemp.c
40386 @@ -797,7 +797,7 @@ static int coretemp_cpu_callback(struct notifier_block *nfb,
40387 return NOTIFY_OK;
40388 }
40389
40390 -static struct notifier_block coretemp_cpu_notifier __refdata = {
40391 +static struct notifier_block coretemp_cpu_notifier = {
40392 .notifier_call = coretemp_cpu_callback,
40393 };
40394
40395 diff --git a/drivers/hwmon/ibmaem.c b/drivers/hwmon/ibmaem.c
40396 index 632f1dc..57e6a58 100644
40397 --- a/drivers/hwmon/ibmaem.c
40398 +++ b/drivers/hwmon/ibmaem.c
40399 @@ -926,7 +926,7 @@ static int aem_register_sensors(struct aem_data *data,
40400 struct aem_rw_sensor_template *rw)
40401 {
40402 struct device *dev = &data->pdev->dev;
40403 - struct sensor_device_attribute *sensors = data->sensors;
40404 + sensor_device_attribute_no_const *sensors = data->sensors;
40405 int err;
40406
40407 /* Set up read-only sensors */
40408 diff --git a/drivers/hwmon/iio_hwmon.c b/drivers/hwmon/iio_hwmon.c
40409 index 708081b..fe2d4ab 100644
40410 --- a/drivers/hwmon/iio_hwmon.c
40411 +++ b/drivers/hwmon/iio_hwmon.c
40412 @@ -73,7 +73,7 @@ static int iio_hwmon_probe(struct platform_device *pdev)
40413 {
40414 struct device *dev = &pdev->dev;
40415 struct iio_hwmon_state *st;
40416 - struct sensor_device_attribute *a;
40417 + sensor_device_attribute_no_const *a;
40418 int ret, i;
40419 int in_i = 1, temp_i = 1, curr_i = 1;
40420 enum iio_chan_type type;
40421 diff --git a/drivers/hwmon/nct6775.c b/drivers/hwmon/nct6775.c
40422 index 6eb03ce..bea7e3e 100644
40423 --- a/drivers/hwmon/nct6775.c
40424 +++ b/drivers/hwmon/nct6775.c
40425 @@ -936,10 +936,10 @@ static struct attribute_group *
40426 nct6775_create_attr_group(struct device *dev, struct sensor_template_group *tg,
40427 int repeat)
40428 {
40429 - struct attribute_group *group;
40430 + attribute_group_no_const *group;
40431 struct sensor_device_attr_u *su;
40432 - struct sensor_device_attribute *a;
40433 - struct sensor_device_attribute_2 *a2;
40434 + sensor_device_attribute_no_const *a;
40435 + sensor_device_attribute_2_no_const *a2;
40436 struct attribute **attrs;
40437 struct sensor_device_template **t;
40438 int err, i, j, count;
40439 diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
40440 index 9319fcf..189ff45 100644
40441 --- a/drivers/hwmon/pmbus/pmbus_core.c
40442 +++ b/drivers/hwmon/pmbus/pmbus_core.c
40443 @@ -781,7 +781,7 @@ static int pmbus_add_attribute(struct pmbus_data *data, struct attribute *attr)
40444 return 0;
40445 }
40446
40447 -static void pmbus_dev_attr_init(struct device_attribute *dev_attr,
40448 +static void pmbus_dev_attr_init(device_attribute_no_const *dev_attr,
40449 const char *name,
40450 umode_t mode,
40451 ssize_t (*show)(struct device *dev,
40452 @@ -798,7 +798,7 @@ static void pmbus_dev_attr_init(struct device_attribute *dev_attr,
40453 dev_attr->store = store;
40454 }
40455
40456 -static void pmbus_attr_init(struct sensor_device_attribute *a,
40457 +static void pmbus_attr_init(sensor_device_attribute_no_const *a,
40458 const char *name,
40459 umode_t mode,
40460 ssize_t (*show)(struct device *dev,
40461 @@ -820,7 +820,7 @@ static int pmbus_add_boolean(struct pmbus_data *data,
40462 u16 reg, u8 mask)
40463 {
40464 struct pmbus_boolean *boolean;
40465 - struct sensor_device_attribute *a;
40466 + sensor_device_attribute_no_const *a;
40467
40468 boolean = devm_kzalloc(data->dev, sizeof(*boolean), GFP_KERNEL);
40469 if (!boolean)
40470 @@ -845,7 +845,7 @@ static struct pmbus_sensor *pmbus_add_sensor(struct pmbus_data *data,
40471 bool update, bool readonly)
40472 {
40473 struct pmbus_sensor *sensor;
40474 - struct device_attribute *a;
40475 + device_attribute_no_const *a;
40476
40477 sensor = devm_kzalloc(data->dev, sizeof(*sensor), GFP_KERNEL);
40478 if (!sensor)
40479 @@ -876,7 +876,7 @@ static int pmbus_add_label(struct pmbus_data *data,
40480 const char *lstring, int index)
40481 {
40482 struct pmbus_label *label;
40483 - struct device_attribute *a;
40484 + device_attribute_no_const *a;
40485
40486 label = devm_kzalloc(data->dev, sizeof(*label), GFP_KERNEL);
40487 if (!label)
40488 diff --git a/drivers/hwmon/sht15.c b/drivers/hwmon/sht15.c
40489 index 97cd45a..ac54d8b 100644
40490 --- a/drivers/hwmon/sht15.c
40491 +++ b/drivers/hwmon/sht15.c
40492 @@ -169,7 +169,7 @@ struct sht15_data {
40493 int supply_uv;
40494 bool supply_uv_valid;
40495 struct work_struct update_supply_work;
40496 - atomic_t interrupt_handled;
40497 + atomic_unchecked_t interrupt_handled;
40498 };
40499
40500 /**
40501 @@ -542,13 +542,13 @@ static int sht15_measurement(struct sht15_data *data,
40502 ret = gpio_direction_input(data->pdata->gpio_data);
40503 if (ret)
40504 return ret;
40505 - atomic_set(&data->interrupt_handled, 0);
40506 + atomic_set_unchecked(&data->interrupt_handled, 0);
40507
40508 enable_irq(gpio_to_irq(data->pdata->gpio_data));
40509 if (gpio_get_value(data->pdata->gpio_data) == 0) {
40510 disable_irq_nosync(gpio_to_irq(data->pdata->gpio_data));
40511 /* Only relevant if the interrupt hasn't occurred. */
40512 - if (!atomic_read(&data->interrupt_handled))
40513 + if (!atomic_read_unchecked(&data->interrupt_handled))
40514 schedule_work(&data->read_work);
40515 }
40516 ret = wait_event_timeout(data->wait_queue,
40517 @@ -820,7 +820,7 @@ static irqreturn_t sht15_interrupt_fired(int irq, void *d)
40518
40519 /* First disable the interrupt */
40520 disable_irq_nosync(irq);
40521 - atomic_inc(&data->interrupt_handled);
40522 + atomic_inc_unchecked(&data->interrupt_handled);
40523 /* Then schedule a reading work struct */
40524 if (data->state != SHT15_READING_NOTHING)
40525 schedule_work(&data->read_work);
40526 @@ -842,11 +842,11 @@ static void sht15_bh_read_data(struct work_struct *work_s)
40527 * If not, then start the interrupt again - care here as could
40528 * have gone low in meantime so verify it hasn't!
40529 */
40530 - atomic_set(&data->interrupt_handled, 0);
40531 + atomic_set_unchecked(&data->interrupt_handled, 0);
40532 enable_irq(gpio_to_irq(data->pdata->gpio_data));
40533 /* If still not occurred or another handler was scheduled */
40534 if (gpio_get_value(data->pdata->gpio_data)
40535 - || atomic_read(&data->interrupt_handled))
40536 + || atomic_read_unchecked(&data->interrupt_handled))
40537 return;
40538 }
40539
40540 diff --git a/drivers/hwmon/via-cputemp.c b/drivers/hwmon/via-cputemp.c
40541 index 38944e9..ae9e5ed 100644
40542 --- a/drivers/hwmon/via-cputemp.c
40543 +++ b/drivers/hwmon/via-cputemp.c
40544 @@ -296,7 +296,7 @@ static int via_cputemp_cpu_callback(struct notifier_block *nfb,
40545 return NOTIFY_OK;
40546 }
40547
40548 -static struct notifier_block via_cputemp_cpu_notifier __refdata = {
40549 +static struct notifier_block via_cputemp_cpu_notifier = {
40550 .notifier_call = via_cputemp_cpu_callback,
40551 };
40552
40553 diff --git a/drivers/i2c/busses/i2c-amd756-s4882.c b/drivers/i2c/busses/i2c-amd756-s4882.c
40554 index 07f01ac..d79ad3d 100644
40555 --- a/drivers/i2c/busses/i2c-amd756-s4882.c
40556 +++ b/drivers/i2c/busses/i2c-amd756-s4882.c
40557 @@ -43,7 +43,7 @@
40558 extern struct i2c_adapter amd756_smbus;
40559
40560 static struct i2c_adapter *s4882_adapter;
40561 -static struct i2c_algorithm *s4882_algo;
40562 +static i2c_algorithm_no_const *s4882_algo;
40563
40564 /* Wrapper access functions for multiplexed SMBus */
40565 static DEFINE_MUTEX(amd756_lock);
40566 diff --git a/drivers/i2c/busses/i2c-diolan-u2c.c b/drivers/i2c/busses/i2c-diolan-u2c.c
40567 index dae3ddf..26e21d1 100644
40568 --- a/drivers/i2c/busses/i2c-diolan-u2c.c
40569 +++ b/drivers/i2c/busses/i2c-diolan-u2c.c
40570 @@ -99,7 +99,7 @@ MODULE_PARM_DESC(frequency, "I2C clock frequency in hertz");
40571 /* usb layer */
40572
40573 /* Send command to device, and get response. */
40574 -static int diolan_usb_transfer(struct i2c_diolan_u2c *dev)
40575 +static int __intentional_overflow(-1) diolan_usb_transfer(struct i2c_diolan_u2c *dev)
40576 {
40577 int ret = 0;
40578 int actual;
40579 diff --git a/drivers/i2c/busses/i2c-nforce2-s4985.c b/drivers/i2c/busses/i2c-nforce2-s4985.c
40580 index 2ca268d..c6acbdf 100644
40581 --- a/drivers/i2c/busses/i2c-nforce2-s4985.c
40582 +++ b/drivers/i2c/busses/i2c-nforce2-s4985.c
40583 @@ -41,7 +41,7 @@
40584 extern struct i2c_adapter *nforce2_smbus;
40585
40586 static struct i2c_adapter *s4985_adapter;
40587 -static struct i2c_algorithm *s4985_algo;
40588 +static i2c_algorithm_no_const *s4985_algo;
40589
40590 /* Wrapper access functions for multiplexed SMBus */
40591 static DEFINE_MUTEX(nforce2_lock);
40592 diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
40593 index c3ccdea..5b3dc1a 100644
40594 --- a/drivers/i2c/i2c-dev.c
40595 +++ b/drivers/i2c/i2c-dev.c
40596 @@ -271,7 +271,7 @@ static noinline int i2cdev_ioctl_rdrw(struct i2c_client *client,
40597 break;
40598 }
40599
40600 - data_ptrs[i] = (u8 __user *)rdwr_pa[i].buf;
40601 + data_ptrs[i] = (u8 __force_user *)rdwr_pa[i].buf;
40602 rdwr_pa[i].buf = memdup_user(data_ptrs[i], rdwr_pa[i].len);
40603 if (IS_ERR(rdwr_pa[i].buf)) {
40604 res = PTR_ERR(rdwr_pa[i].buf);
40605 diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
40606 index 0b510ba..4fbb5085 100644
40607 --- a/drivers/ide/ide-cd.c
40608 +++ b/drivers/ide/ide-cd.c
40609 @@ -768,7 +768,7 @@ static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
40610 alignment = queue_dma_alignment(q) | q->dma_pad_mask;
40611 if ((unsigned long)buf & alignment
40612 || blk_rq_bytes(rq) & q->dma_pad_mask
40613 - || object_is_on_stack(buf))
40614 + || object_starts_on_stack(buf))
40615 drive->dma = 0;
40616 }
40617 }
40618 diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
40619 index f95c697..0a1b05c 100644
40620 --- a/drivers/iio/industrialio-core.c
40621 +++ b/drivers/iio/industrialio-core.c
40622 @@ -506,7 +506,7 @@ static ssize_t iio_write_channel_info(struct device *dev,
40623 }
40624
40625 static
40626 -int __iio_device_attr_init(struct device_attribute *dev_attr,
40627 +int __iio_device_attr_init(device_attribute_no_const *dev_attr,
40628 const char *postfix,
40629 struct iio_chan_spec const *chan,
40630 ssize_t (*readfunc)(struct device *dev,
40631 diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
40632 index 784b97c..c9ceadf 100644
40633 --- a/drivers/infiniband/core/cm.c
40634 +++ b/drivers/infiniband/core/cm.c
40635 @@ -114,7 +114,7 @@ static char const counter_group_names[CM_COUNTER_GROUPS]
40636
40637 struct cm_counter_group {
40638 struct kobject obj;
40639 - atomic_long_t counter[CM_ATTR_COUNT];
40640 + atomic_long_unchecked_t counter[CM_ATTR_COUNT];
40641 };
40642
40643 struct cm_counter_attribute {
40644 @@ -1395,7 +1395,7 @@ static void cm_dup_req_handler(struct cm_work *work,
40645 struct ib_mad_send_buf *msg = NULL;
40646 int ret;
40647
40648 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40649 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40650 counter[CM_REQ_COUNTER]);
40651
40652 /* Quick state check to discard duplicate REQs. */
40653 @@ -1779,7 +1779,7 @@ static void cm_dup_rep_handler(struct cm_work *work)
40654 if (!cm_id_priv)
40655 return;
40656
40657 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40658 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40659 counter[CM_REP_COUNTER]);
40660 ret = cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg);
40661 if (ret)
40662 @@ -1946,7 +1946,7 @@ static int cm_rtu_handler(struct cm_work *work)
40663 if (cm_id_priv->id.state != IB_CM_REP_SENT &&
40664 cm_id_priv->id.state != IB_CM_MRA_REP_RCVD) {
40665 spin_unlock_irq(&cm_id_priv->lock);
40666 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40667 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40668 counter[CM_RTU_COUNTER]);
40669 goto out;
40670 }
40671 @@ -2129,7 +2129,7 @@ static int cm_dreq_handler(struct cm_work *work)
40672 cm_id_priv = cm_acquire_id(dreq_msg->remote_comm_id,
40673 dreq_msg->local_comm_id);
40674 if (!cm_id_priv) {
40675 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40676 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40677 counter[CM_DREQ_COUNTER]);
40678 cm_issue_drep(work->port, work->mad_recv_wc);
40679 return -EINVAL;
40680 @@ -2154,7 +2154,7 @@ static int cm_dreq_handler(struct cm_work *work)
40681 case IB_CM_MRA_REP_RCVD:
40682 break;
40683 case IB_CM_TIMEWAIT:
40684 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40685 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40686 counter[CM_DREQ_COUNTER]);
40687 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
40688 goto unlock;
40689 @@ -2168,7 +2168,7 @@ static int cm_dreq_handler(struct cm_work *work)
40690 cm_free_msg(msg);
40691 goto deref;
40692 case IB_CM_DREQ_RCVD:
40693 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40694 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40695 counter[CM_DREQ_COUNTER]);
40696 goto unlock;
40697 default:
40698 @@ -2535,7 +2535,7 @@ static int cm_mra_handler(struct cm_work *work)
40699 ib_modify_mad(cm_id_priv->av.port->mad_agent,
40700 cm_id_priv->msg, timeout)) {
40701 if (cm_id_priv->id.lap_state == IB_CM_MRA_LAP_RCVD)
40702 - atomic_long_inc(&work->port->
40703 + atomic_long_inc_unchecked(&work->port->
40704 counter_group[CM_RECV_DUPLICATES].
40705 counter[CM_MRA_COUNTER]);
40706 goto out;
40707 @@ -2544,7 +2544,7 @@ static int cm_mra_handler(struct cm_work *work)
40708 break;
40709 case IB_CM_MRA_REQ_RCVD:
40710 case IB_CM_MRA_REP_RCVD:
40711 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40712 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40713 counter[CM_MRA_COUNTER]);
40714 /* fall through */
40715 default:
40716 @@ -2706,7 +2706,7 @@ static int cm_lap_handler(struct cm_work *work)
40717 case IB_CM_LAP_IDLE:
40718 break;
40719 case IB_CM_MRA_LAP_SENT:
40720 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40721 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40722 counter[CM_LAP_COUNTER]);
40723 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
40724 goto unlock;
40725 @@ -2722,7 +2722,7 @@ static int cm_lap_handler(struct cm_work *work)
40726 cm_free_msg(msg);
40727 goto deref;
40728 case IB_CM_LAP_RCVD:
40729 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40730 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40731 counter[CM_LAP_COUNTER]);
40732 goto unlock;
40733 default:
40734 @@ -3006,7 +3006,7 @@ static int cm_sidr_req_handler(struct cm_work *work)
40735 cur_cm_id_priv = cm_insert_remote_sidr(cm_id_priv);
40736 if (cur_cm_id_priv) {
40737 spin_unlock_irq(&cm.lock);
40738 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40739 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40740 counter[CM_SIDR_REQ_COUNTER]);
40741 goto out; /* Duplicate message. */
40742 }
40743 @@ -3218,10 +3218,10 @@ static void cm_send_handler(struct ib_mad_agent *mad_agent,
40744 if (!msg->context[0] && (attr_index != CM_REJ_COUNTER))
40745 msg->retries = 1;
40746
40747 - atomic_long_add(1 + msg->retries,
40748 + atomic_long_add_unchecked(1 + msg->retries,
40749 &port->counter_group[CM_XMIT].counter[attr_index]);
40750 if (msg->retries)
40751 - atomic_long_add(msg->retries,
40752 + atomic_long_add_unchecked(msg->retries,
40753 &port->counter_group[CM_XMIT_RETRIES].
40754 counter[attr_index]);
40755
40756 @@ -3431,7 +3431,7 @@ static void cm_recv_handler(struct ib_mad_agent *mad_agent,
40757 }
40758
40759 attr_id = be16_to_cpu(mad_recv_wc->recv_buf.mad->mad_hdr.attr_id);
40760 - atomic_long_inc(&port->counter_group[CM_RECV].
40761 + atomic_long_inc_unchecked(&port->counter_group[CM_RECV].
40762 counter[attr_id - CM_ATTR_ID_OFFSET]);
40763
40764 work = kmalloc(sizeof *work + sizeof(struct ib_sa_path_rec) * paths,
40765 @@ -3636,7 +3636,7 @@ static ssize_t cm_show_counter(struct kobject *obj, struct attribute *attr,
40766 cm_attr = container_of(attr, struct cm_counter_attribute, attr);
40767
40768 return sprintf(buf, "%ld\n",
40769 - atomic_long_read(&group->counter[cm_attr->index]));
40770 + atomic_long_read_unchecked(&group->counter[cm_attr->index]));
40771 }
40772
40773 static const struct sysfs_ops cm_counter_ops = {
40774 diff --git a/drivers/infiniband/core/fmr_pool.c b/drivers/infiniband/core/fmr_pool.c
40775 index 9f5ad7c..588cd84 100644
40776 --- a/drivers/infiniband/core/fmr_pool.c
40777 +++ b/drivers/infiniband/core/fmr_pool.c
40778 @@ -98,8 +98,8 @@ struct ib_fmr_pool {
40779
40780 struct task_struct *thread;
40781
40782 - atomic_t req_ser;
40783 - atomic_t flush_ser;
40784 + atomic_unchecked_t req_ser;
40785 + atomic_unchecked_t flush_ser;
40786
40787 wait_queue_head_t force_wait;
40788 };
40789 @@ -179,10 +179,10 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
40790 struct ib_fmr_pool *pool = pool_ptr;
40791
40792 do {
40793 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) < 0) {
40794 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) < 0) {
40795 ib_fmr_batch_release(pool);
40796
40797 - atomic_inc(&pool->flush_ser);
40798 + atomic_inc_unchecked(&pool->flush_ser);
40799 wake_up_interruptible(&pool->force_wait);
40800
40801 if (pool->flush_function)
40802 @@ -190,7 +190,7 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
40803 }
40804
40805 set_current_state(TASK_INTERRUPTIBLE);
40806 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) >= 0 &&
40807 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) >= 0 &&
40808 !kthread_should_stop())
40809 schedule();
40810 __set_current_state(TASK_RUNNING);
40811 @@ -282,8 +282,8 @@ struct ib_fmr_pool *ib_create_fmr_pool(struct ib_pd *pd,
40812 pool->dirty_watermark = params->dirty_watermark;
40813 pool->dirty_len = 0;
40814 spin_lock_init(&pool->pool_lock);
40815 - atomic_set(&pool->req_ser, 0);
40816 - atomic_set(&pool->flush_ser, 0);
40817 + atomic_set_unchecked(&pool->req_ser, 0);
40818 + atomic_set_unchecked(&pool->flush_ser, 0);
40819 init_waitqueue_head(&pool->force_wait);
40820
40821 pool->thread = kthread_run(ib_fmr_cleanup_thread,
40822 @@ -411,11 +411,11 @@ int ib_flush_fmr_pool(struct ib_fmr_pool *pool)
40823 }
40824 spin_unlock_irq(&pool->pool_lock);
40825
40826 - serial = atomic_inc_return(&pool->req_ser);
40827 + serial = atomic_inc_return_unchecked(&pool->req_ser);
40828 wake_up_process(pool->thread);
40829
40830 if (wait_event_interruptible(pool->force_wait,
40831 - atomic_read(&pool->flush_ser) - serial >= 0))
40832 + atomic_read_unchecked(&pool->flush_ser) - serial >= 0))
40833 return -EINTR;
40834
40835 return 0;
40836 @@ -525,7 +525,7 @@ int ib_fmr_pool_unmap(struct ib_pool_fmr *fmr)
40837 } else {
40838 list_add_tail(&fmr->list, &pool->dirty_list);
40839 if (++pool->dirty_len >= pool->dirty_watermark) {
40840 - atomic_inc(&pool->req_ser);
40841 + atomic_inc_unchecked(&pool->req_ser);
40842 wake_up_process(pool->thread);
40843 }
40844 }
40845 diff --git a/drivers/infiniband/hw/cxgb4/mem.c b/drivers/infiniband/hw/cxgb4/mem.c
40846 index 4cb8eb2..146bf60 100644
40847 --- a/drivers/infiniband/hw/cxgb4/mem.c
40848 +++ b/drivers/infiniband/hw/cxgb4/mem.c
40849 @@ -249,7 +249,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
40850 int err;
40851 struct fw_ri_tpte tpt;
40852 u32 stag_idx;
40853 - static atomic_t key;
40854 + static atomic_unchecked_t key;
40855
40856 if (c4iw_fatal_error(rdev))
40857 return -EIO;
40858 @@ -266,7 +266,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
40859 if (rdev->stats.stag.cur > rdev->stats.stag.max)
40860 rdev->stats.stag.max = rdev->stats.stag.cur;
40861 mutex_unlock(&rdev->stats.lock);
40862 - *stag = (stag_idx << 8) | (atomic_inc_return(&key) & 0xff);
40863 + *stag = (stag_idx << 8) | (atomic_inc_return_unchecked(&key) & 0xff);
40864 }
40865 PDBG("%s stag_state 0x%0x type 0x%0x pdid 0x%0x, stag_idx 0x%x\n",
40866 __func__, stag_state, type, pdid, stag_idx);
40867 diff --git a/drivers/infiniband/hw/ipath/ipath_rc.c b/drivers/infiniband/hw/ipath/ipath_rc.c
40868 index 79b3dbc..96e5fcc 100644
40869 --- a/drivers/infiniband/hw/ipath/ipath_rc.c
40870 +++ b/drivers/infiniband/hw/ipath/ipath_rc.c
40871 @@ -1868,7 +1868,7 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
40872 struct ib_atomic_eth *ateth;
40873 struct ipath_ack_entry *e;
40874 u64 vaddr;
40875 - atomic64_t *maddr;
40876 + atomic64_unchecked_t *maddr;
40877 u64 sdata;
40878 u32 rkey;
40879 u8 next;
40880 @@ -1903,11 +1903,11 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
40881 IB_ACCESS_REMOTE_ATOMIC)))
40882 goto nack_acc_unlck;
40883 /* Perform atomic OP and save result. */
40884 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
40885 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
40886 sdata = be64_to_cpu(ateth->swap_data);
40887 e = &qp->s_ack_queue[qp->r_head_ack_queue];
40888 e->atomic_data = (opcode == OP(FETCH_ADD)) ?
40889 - (u64) atomic64_add_return(sdata, maddr) - sdata :
40890 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
40891 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
40892 be64_to_cpu(ateth->compare_data),
40893 sdata);
40894 diff --git a/drivers/infiniband/hw/ipath/ipath_ruc.c b/drivers/infiniband/hw/ipath/ipath_ruc.c
40895 index 1f95bba..9530f87 100644
40896 --- a/drivers/infiniband/hw/ipath/ipath_ruc.c
40897 +++ b/drivers/infiniband/hw/ipath/ipath_ruc.c
40898 @@ -266,7 +266,7 @@ static void ipath_ruc_loopback(struct ipath_qp *sqp)
40899 unsigned long flags;
40900 struct ib_wc wc;
40901 u64 sdata;
40902 - atomic64_t *maddr;
40903 + atomic64_unchecked_t *maddr;
40904 enum ib_wc_status send_status;
40905
40906 /*
40907 @@ -382,11 +382,11 @@ again:
40908 IB_ACCESS_REMOTE_ATOMIC)))
40909 goto acc_err;
40910 /* Perform atomic OP and save result. */
40911 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
40912 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
40913 sdata = wqe->wr.wr.atomic.compare_add;
40914 *(u64 *) sqp->s_sge.sge.vaddr =
40915 (wqe->wr.opcode == IB_WR_ATOMIC_FETCH_AND_ADD) ?
40916 - (u64) atomic64_add_return(sdata, maddr) - sdata :
40917 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
40918 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
40919 sdata, wqe->wr.wr.atomic.swap);
40920 goto send_comp;
40921 diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
40922 index f2a3f48..673ec79 100644
40923 --- a/drivers/infiniband/hw/mlx4/mad.c
40924 +++ b/drivers/infiniband/hw/mlx4/mad.c
40925 @@ -98,7 +98,7 @@ __be64 mlx4_ib_gen_node_guid(void)
40926
40927 __be64 mlx4_ib_get_new_demux_tid(struct mlx4_ib_demux_ctx *ctx)
40928 {
40929 - return cpu_to_be64(atomic_inc_return(&ctx->tid)) |
40930 + return cpu_to_be64(atomic_inc_return_unchecked(&ctx->tid)) |
40931 cpu_to_be64(0xff00000000000000LL);
40932 }
40933
40934 diff --git a/drivers/infiniband/hw/mlx4/mcg.c b/drivers/infiniband/hw/mlx4/mcg.c
40935 index 25b2cdf..099ff97 100644
40936 --- a/drivers/infiniband/hw/mlx4/mcg.c
40937 +++ b/drivers/infiniband/hw/mlx4/mcg.c
40938 @@ -1040,7 +1040,7 @@ int mlx4_ib_mcg_port_init(struct mlx4_ib_demux_ctx *ctx)
40939 {
40940 char name[20];
40941
40942 - atomic_set(&ctx->tid, 0);
40943 + atomic_set_unchecked(&ctx->tid, 0);
40944 sprintf(name, "mlx4_ib_mcg%d", ctx->port);
40945 ctx->mcg_wq = create_singlethread_workqueue(name);
40946 if (!ctx->mcg_wq)
40947 diff --git a/drivers/infiniband/hw/mlx4/mlx4_ib.h b/drivers/infiniband/hw/mlx4/mlx4_ib.h
40948 index 036b663..c9a8c73 100644
40949 --- a/drivers/infiniband/hw/mlx4/mlx4_ib.h
40950 +++ b/drivers/infiniband/hw/mlx4/mlx4_ib.h
40951 @@ -404,7 +404,7 @@ struct mlx4_ib_demux_ctx {
40952 struct list_head mcg_mgid0_list;
40953 struct workqueue_struct *mcg_wq;
40954 struct mlx4_ib_demux_pv_ctx **tun;
40955 - atomic_t tid;
40956 + atomic_unchecked_t tid;
40957 int flushing; /* flushing the work queue */
40958 };
40959
40960 diff --git a/drivers/infiniband/hw/mthca/mthca_cmd.c b/drivers/infiniband/hw/mthca/mthca_cmd.c
40961 index 9d3e5c1..6f166df 100644
40962 --- a/drivers/infiniband/hw/mthca/mthca_cmd.c
40963 +++ b/drivers/infiniband/hw/mthca/mthca_cmd.c
40964 @@ -772,7 +772,7 @@ static void mthca_setup_cmd_doorbells(struct mthca_dev *dev, u64 base)
40965 mthca_dbg(dev, "Mapped doorbell page for posting FW commands\n");
40966 }
40967
40968 -int mthca_QUERY_FW(struct mthca_dev *dev)
40969 +int __intentional_overflow(-1) mthca_QUERY_FW(struct mthca_dev *dev)
40970 {
40971 struct mthca_mailbox *mailbox;
40972 u32 *outbox;
40973 @@ -1612,7 +1612,7 @@ int mthca_HW2SW_MPT(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
40974 CMD_TIME_CLASS_B);
40975 }
40976
40977 -int mthca_WRITE_MTT(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
40978 +int __intentional_overflow(-1) mthca_WRITE_MTT(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
40979 int num_mtt)
40980 {
40981 return mthca_cmd(dev, mailbox->dma, num_mtt, 0, CMD_WRITE_MTT,
40982 @@ -1634,7 +1634,7 @@ int mthca_MAP_EQ(struct mthca_dev *dev, u64 event_mask, int unmap,
40983 0, CMD_MAP_EQ, CMD_TIME_CLASS_B);
40984 }
40985
40986 -int mthca_SW2HW_EQ(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
40987 +int __intentional_overflow(-1) mthca_SW2HW_EQ(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
40988 int eq_num)
40989 {
40990 return mthca_cmd(dev, mailbox->dma, eq_num, 0, CMD_SW2HW_EQ,
40991 @@ -1857,7 +1857,7 @@ int mthca_CONF_SPECIAL_QP(struct mthca_dev *dev, int type, u32 qpn)
40992 CMD_TIME_CLASS_B);
40993 }
40994
40995 -int mthca_MAD_IFC(struct mthca_dev *dev, int ignore_mkey, int ignore_bkey,
40996 +int __intentional_overflow(-1) mthca_MAD_IFC(struct mthca_dev *dev, int ignore_mkey, int ignore_bkey,
40997 int port, struct ib_wc *in_wc, struct ib_grh *in_grh,
40998 void *in_mad, void *response_mad)
40999 {
41000 diff --git a/drivers/infiniband/hw/mthca/mthca_main.c b/drivers/infiniband/hw/mthca/mthca_main.c
41001 index 87897b9..7e79542 100644
41002 --- a/drivers/infiniband/hw/mthca/mthca_main.c
41003 +++ b/drivers/infiniband/hw/mthca/mthca_main.c
41004 @@ -692,7 +692,7 @@ err_close:
41005 return err;
41006 }
41007
41008 -static int mthca_setup_hca(struct mthca_dev *dev)
41009 +static int __intentional_overflow(-1) mthca_setup_hca(struct mthca_dev *dev)
41010 {
41011 int err;
41012
41013 diff --git a/drivers/infiniband/hw/mthca/mthca_mr.c b/drivers/infiniband/hw/mthca/mthca_mr.c
41014 index ed9a989..6aa5dc2 100644
41015 --- a/drivers/infiniband/hw/mthca/mthca_mr.c
41016 +++ b/drivers/infiniband/hw/mthca/mthca_mr.c
41017 @@ -81,7 +81,7 @@ struct mthca_mpt_entry {
41018 * through the bitmaps)
41019 */
41020
41021 -static u32 mthca_buddy_alloc(struct mthca_buddy *buddy, int order)
41022 +static u32 __intentional_overflow(-1) mthca_buddy_alloc(struct mthca_buddy *buddy, int order)
41023 {
41024 int o;
41025 int m;
41026 @@ -426,7 +426,7 @@ static inline u32 adjust_key(struct mthca_dev *dev, u32 key)
41027 return key;
41028 }
41029
41030 -int mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
41031 +int __intentional_overflow(-1) mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
41032 u64 iova, u64 total_size, u32 access, struct mthca_mr *mr)
41033 {
41034 struct mthca_mailbox *mailbox;
41035 @@ -516,7 +516,7 @@ int mthca_mr_alloc_notrans(struct mthca_dev *dev, u32 pd,
41036 return mthca_mr_alloc(dev, pd, 12, 0, ~0ULL, access, mr);
41037 }
41038
41039 -int mthca_mr_alloc_phys(struct mthca_dev *dev, u32 pd,
41040 +int __intentional_overflow(-1) mthca_mr_alloc_phys(struct mthca_dev *dev, u32 pd,
41041 u64 *buffer_list, int buffer_size_shift,
41042 int list_len, u64 iova, u64 total_size,
41043 u32 access, struct mthca_mr *mr)
41044 diff --git a/drivers/infiniband/hw/mthca/mthca_provider.c b/drivers/infiniband/hw/mthca/mthca_provider.c
41045 index 5b71d43..35a9e14 100644
41046 --- a/drivers/infiniband/hw/mthca/mthca_provider.c
41047 +++ b/drivers/infiniband/hw/mthca/mthca_provider.c
41048 @@ -763,7 +763,7 @@ unlock:
41049 return 0;
41050 }
41051
41052 -static int mthca_resize_cq(struct ib_cq *ibcq, int entries, struct ib_udata *udata)
41053 +static int __intentional_overflow(-1) mthca_resize_cq(struct ib_cq *ibcq, int entries, struct ib_udata *udata)
41054 {
41055 struct mthca_dev *dev = to_mdev(ibcq->device);
41056 struct mthca_cq *cq = to_mcq(ibcq);
41057 diff --git a/drivers/infiniband/hw/nes/nes.c b/drivers/infiniband/hw/nes/nes.c
41058 index 4291410..d2ab1fb 100644
41059 --- a/drivers/infiniband/hw/nes/nes.c
41060 +++ b/drivers/infiniband/hw/nes/nes.c
41061 @@ -98,7 +98,7 @@ MODULE_PARM_DESC(limit_maxrdreqsz, "Limit max read request size to 256 Bytes");
41062 LIST_HEAD(nes_adapter_list);
41063 static LIST_HEAD(nes_dev_list);
41064
41065 -atomic_t qps_destroyed;
41066 +atomic_unchecked_t qps_destroyed;
41067
41068 static unsigned int ee_flsh_adapter;
41069 static unsigned int sysfs_nonidx_addr;
41070 @@ -269,7 +269,7 @@ static void nes_cqp_rem_ref_callback(struct nes_device *nesdev, struct nes_cqp_r
41071 struct nes_qp *nesqp = cqp_request->cqp_callback_pointer;
41072 struct nes_adapter *nesadapter = nesdev->nesadapter;
41073
41074 - atomic_inc(&qps_destroyed);
41075 + atomic_inc_unchecked(&qps_destroyed);
41076
41077 /* Free the control structures */
41078
41079 diff --git a/drivers/infiniband/hw/nes/nes.h b/drivers/infiniband/hw/nes/nes.h
41080 index 33cc589..3bd6538 100644
41081 --- a/drivers/infiniband/hw/nes/nes.h
41082 +++ b/drivers/infiniband/hw/nes/nes.h
41083 @@ -177,17 +177,17 @@ extern unsigned int nes_debug_level;
41084 extern unsigned int wqm_quanta;
41085 extern struct list_head nes_adapter_list;
41086
41087 -extern atomic_t cm_connects;
41088 -extern atomic_t cm_accepts;
41089 -extern atomic_t cm_disconnects;
41090 -extern atomic_t cm_closes;
41091 -extern atomic_t cm_connecteds;
41092 -extern atomic_t cm_connect_reqs;
41093 -extern atomic_t cm_rejects;
41094 -extern atomic_t mod_qp_timouts;
41095 -extern atomic_t qps_created;
41096 -extern atomic_t qps_destroyed;
41097 -extern atomic_t sw_qps_destroyed;
41098 +extern atomic_unchecked_t cm_connects;
41099 +extern atomic_unchecked_t cm_accepts;
41100 +extern atomic_unchecked_t cm_disconnects;
41101 +extern atomic_unchecked_t cm_closes;
41102 +extern atomic_unchecked_t cm_connecteds;
41103 +extern atomic_unchecked_t cm_connect_reqs;
41104 +extern atomic_unchecked_t cm_rejects;
41105 +extern atomic_unchecked_t mod_qp_timouts;
41106 +extern atomic_unchecked_t qps_created;
41107 +extern atomic_unchecked_t qps_destroyed;
41108 +extern atomic_unchecked_t sw_qps_destroyed;
41109 extern u32 mh_detected;
41110 extern u32 mh_pauses_sent;
41111 extern u32 cm_packets_sent;
41112 @@ -196,16 +196,16 @@ extern u32 cm_packets_created;
41113 extern u32 cm_packets_received;
41114 extern u32 cm_packets_dropped;
41115 extern u32 cm_packets_retrans;
41116 -extern atomic_t cm_listens_created;
41117 -extern atomic_t cm_listens_destroyed;
41118 +extern atomic_unchecked_t cm_listens_created;
41119 +extern atomic_unchecked_t cm_listens_destroyed;
41120 extern u32 cm_backlog_drops;
41121 -extern atomic_t cm_loopbacks;
41122 -extern atomic_t cm_nodes_created;
41123 -extern atomic_t cm_nodes_destroyed;
41124 -extern atomic_t cm_accel_dropped_pkts;
41125 -extern atomic_t cm_resets_recvd;
41126 -extern atomic_t pau_qps_created;
41127 -extern atomic_t pau_qps_destroyed;
41128 +extern atomic_unchecked_t cm_loopbacks;
41129 +extern atomic_unchecked_t cm_nodes_created;
41130 +extern atomic_unchecked_t cm_nodes_destroyed;
41131 +extern atomic_unchecked_t cm_accel_dropped_pkts;
41132 +extern atomic_unchecked_t cm_resets_recvd;
41133 +extern atomic_unchecked_t pau_qps_created;
41134 +extern atomic_unchecked_t pau_qps_destroyed;
41135
41136 extern u32 int_mod_timer_init;
41137 extern u32 int_mod_cq_depth_256;
41138 diff --git a/drivers/infiniband/hw/nes/nes_cm.c b/drivers/infiniband/hw/nes/nes_cm.c
41139 index 6b29249..57081dd 100644
41140 --- a/drivers/infiniband/hw/nes/nes_cm.c
41141 +++ b/drivers/infiniband/hw/nes/nes_cm.c
41142 @@ -68,14 +68,14 @@ u32 cm_packets_dropped;
41143 u32 cm_packets_retrans;
41144 u32 cm_packets_created;
41145 u32 cm_packets_received;
41146 -atomic_t cm_listens_created;
41147 -atomic_t cm_listens_destroyed;
41148 +atomic_unchecked_t cm_listens_created;
41149 +atomic_unchecked_t cm_listens_destroyed;
41150 u32 cm_backlog_drops;
41151 -atomic_t cm_loopbacks;
41152 -atomic_t cm_nodes_created;
41153 -atomic_t cm_nodes_destroyed;
41154 -atomic_t cm_accel_dropped_pkts;
41155 -atomic_t cm_resets_recvd;
41156 +atomic_unchecked_t cm_loopbacks;
41157 +atomic_unchecked_t cm_nodes_created;
41158 +atomic_unchecked_t cm_nodes_destroyed;
41159 +atomic_unchecked_t cm_accel_dropped_pkts;
41160 +atomic_unchecked_t cm_resets_recvd;
41161
41162 static inline int mini_cm_accelerated(struct nes_cm_core *, struct nes_cm_node *);
41163 static struct nes_cm_listener *mini_cm_listen(struct nes_cm_core *, struct nes_vnic *, struct nes_cm_info *);
41164 @@ -148,13 +148,13 @@ static struct nes_cm_ops nes_cm_api = {
41165
41166 static struct nes_cm_core *g_cm_core;
41167
41168 -atomic_t cm_connects;
41169 -atomic_t cm_accepts;
41170 -atomic_t cm_disconnects;
41171 -atomic_t cm_closes;
41172 -atomic_t cm_connecteds;
41173 -atomic_t cm_connect_reqs;
41174 -atomic_t cm_rejects;
41175 +atomic_unchecked_t cm_connects;
41176 +atomic_unchecked_t cm_accepts;
41177 +atomic_unchecked_t cm_disconnects;
41178 +atomic_unchecked_t cm_closes;
41179 +atomic_unchecked_t cm_connecteds;
41180 +atomic_unchecked_t cm_connect_reqs;
41181 +atomic_unchecked_t cm_rejects;
41182
41183 int nes_add_ref_cm_node(struct nes_cm_node *cm_node)
41184 {
41185 @@ -1272,7 +1272,7 @@ static int mini_cm_dec_refcnt_listen(struct nes_cm_core *cm_core,
41186 kfree(listener);
41187 listener = NULL;
41188 ret = 0;
41189 - atomic_inc(&cm_listens_destroyed);
41190 + atomic_inc_unchecked(&cm_listens_destroyed);
41191 } else {
41192 spin_unlock_irqrestore(&cm_core->listen_list_lock, flags);
41193 }
41194 @@ -1466,7 +1466,7 @@ static struct nes_cm_node *make_cm_node(struct nes_cm_core *cm_core,
41195 cm_node->rem_mac);
41196
41197 add_hte_node(cm_core, cm_node);
41198 - atomic_inc(&cm_nodes_created);
41199 + atomic_inc_unchecked(&cm_nodes_created);
41200
41201 return cm_node;
41202 }
41203 @@ -1524,7 +1524,7 @@ static int rem_ref_cm_node(struct nes_cm_core *cm_core,
41204 }
41205
41206 atomic_dec(&cm_core->node_cnt);
41207 - atomic_inc(&cm_nodes_destroyed);
41208 + atomic_inc_unchecked(&cm_nodes_destroyed);
41209 nesqp = cm_node->nesqp;
41210 if (nesqp) {
41211 nesqp->cm_node = NULL;
41212 @@ -1588,7 +1588,7 @@ static int process_options(struct nes_cm_node *cm_node, u8 *optionsloc,
41213
41214 static void drop_packet(struct sk_buff *skb)
41215 {
41216 - atomic_inc(&cm_accel_dropped_pkts);
41217 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
41218 dev_kfree_skb_any(skb);
41219 }
41220
41221 @@ -1651,7 +1651,7 @@ static void handle_rst_pkt(struct nes_cm_node *cm_node, struct sk_buff *skb,
41222 {
41223
41224 int reset = 0; /* whether to send reset in case of err.. */
41225 - atomic_inc(&cm_resets_recvd);
41226 + atomic_inc_unchecked(&cm_resets_recvd);
41227 nes_debug(NES_DBG_CM, "Received Reset, cm_node = %p, state = %u."
41228 " refcnt=%d\n", cm_node, cm_node->state,
41229 atomic_read(&cm_node->ref_count));
41230 @@ -2292,7 +2292,7 @@ static struct nes_cm_node *mini_cm_connect(struct nes_cm_core *cm_core,
41231 rem_ref_cm_node(cm_node->cm_core, cm_node);
41232 return NULL;
41233 }
41234 - atomic_inc(&cm_loopbacks);
41235 + atomic_inc_unchecked(&cm_loopbacks);
41236 loopbackremotenode->loopbackpartner = cm_node;
41237 loopbackremotenode->tcp_cntxt.rcv_wscale =
41238 NES_CM_DEFAULT_RCV_WND_SCALE;
41239 @@ -2567,7 +2567,7 @@ static int mini_cm_recv_pkt(struct nes_cm_core *cm_core,
41240 nes_queue_mgt_skbs(skb, nesvnic, cm_node->nesqp);
41241 else {
41242 rem_ref_cm_node(cm_core, cm_node);
41243 - atomic_inc(&cm_accel_dropped_pkts);
41244 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
41245 dev_kfree_skb_any(skb);
41246 }
41247 break;
41248 @@ -2875,7 +2875,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
41249
41250 if ((cm_id) && (cm_id->event_handler)) {
41251 if (issue_disconn) {
41252 - atomic_inc(&cm_disconnects);
41253 + atomic_inc_unchecked(&cm_disconnects);
41254 cm_event.event = IW_CM_EVENT_DISCONNECT;
41255 cm_event.status = disconn_status;
41256 cm_event.local_addr = cm_id->local_addr;
41257 @@ -2897,7 +2897,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
41258 }
41259
41260 if (issue_close) {
41261 - atomic_inc(&cm_closes);
41262 + atomic_inc_unchecked(&cm_closes);
41263 nes_disconnect(nesqp, 1);
41264
41265 cm_id->provider_data = nesqp;
41266 @@ -3035,7 +3035,7 @@ int nes_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
41267
41268 nes_debug(NES_DBG_CM, "QP%u, cm_node=%p, jiffies = %lu listener = %p\n",
41269 nesqp->hwqp.qp_id, cm_node, jiffies, cm_node->listener);
41270 - atomic_inc(&cm_accepts);
41271 + atomic_inc_unchecked(&cm_accepts);
41272
41273 nes_debug(NES_DBG_CM, "netdev refcnt = %u.\n",
41274 netdev_refcnt_read(nesvnic->netdev));
41275 @@ -3224,7 +3224,7 @@ int nes_reject(struct iw_cm_id *cm_id, const void *pdata, u8 pdata_len)
41276 struct nes_cm_core *cm_core;
41277 u8 *start_buff;
41278
41279 - atomic_inc(&cm_rejects);
41280 + atomic_inc_unchecked(&cm_rejects);
41281 cm_node = (struct nes_cm_node *)cm_id->provider_data;
41282 loopback = cm_node->loopbackpartner;
41283 cm_core = cm_node->cm_core;
41284 @@ -3286,7 +3286,7 @@ int nes_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
41285 ntohs(raddr->sin_port), ntohl(laddr->sin_addr.s_addr),
41286 ntohs(laddr->sin_port));
41287
41288 - atomic_inc(&cm_connects);
41289 + atomic_inc_unchecked(&cm_connects);
41290 nesqp->active_conn = 1;
41291
41292 /* cache the cm_id in the qp */
41293 @@ -3398,7 +3398,7 @@ int nes_create_listen(struct iw_cm_id *cm_id, int backlog)
41294 g_cm_core->api->stop_listener(g_cm_core, (void *)cm_node);
41295 return err;
41296 }
41297 - atomic_inc(&cm_listens_created);
41298 + atomic_inc_unchecked(&cm_listens_created);
41299 }
41300
41301 cm_id->add_ref(cm_id);
41302 @@ -3505,7 +3505,7 @@ static void cm_event_connected(struct nes_cm_event *event)
41303
41304 if (nesqp->destroyed)
41305 return;
41306 - atomic_inc(&cm_connecteds);
41307 + atomic_inc_unchecked(&cm_connecteds);
41308 nes_debug(NES_DBG_CM, "QP%u attempting to connect to 0x%08X:0x%04X on"
41309 " local port 0x%04X. jiffies = %lu.\n",
41310 nesqp->hwqp.qp_id, ntohl(raddr->sin_addr.s_addr),
41311 @@ -3686,7 +3686,7 @@ static void cm_event_reset(struct nes_cm_event *event)
41312
41313 cm_id->add_ref(cm_id);
41314 ret = cm_id->event_handler(cm_id, &cm_event);
41315 - atomic_inc(&cm_closes);
41316 + atomic_inc_unchecked(&cm_closes);
41317 cm_event.event = IW_CM_EVENT_CLOSE;
41318 cm_event.status = 0;
41319 cm_event.provider_data = cm_id->provider_data;
41320 @@ -3726,7 +3726,7 @@ static void cm_event_mpa_req(struct nes_cm_event *event)
41321 return;
41322 cm_id = cm_node->cm_id;
41323
41324 - atomic_inc(&cm_connect_reqs);
41325 + atomic_inc_unchecked(&cm_connect_reqs);
41326 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
41327 cm_node, cm_id, jiffies);
41328
41329 @@ -3770,7 +3770,7 @@ static void cm_event_mpa_reject(struct nes_cm_event *event)
41330 return;
41331 cm_id = cm_node->cm_id;
41332
41333 - atomic_inc(&cm_connect_reqs);
41334 + atomic_inc_unchecked(&cm_connect_reqs);
41335 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
41336 cm_node, cm_id, jiffies);
41337
41338 diff --git a/drivers/infiniband/hw/nes/nes_mgt.c b/drivers/infiniband/hw/nes/nes_mgt.c
41339 index 4166452..fc952c3 100644
41340 --- a/drivers/infiniband/hw/nes/nes_mgt.c
41341 +++ b/drivers/infiniband/hw/nes/nes_mgt.c
41342 @@ -40,8 +40,8 @@
41343 #include "nes.h"
41344 #include "nes_mgt.h"
41345
41346 -atomic_t pau_qps_created;
41347 -atomic_t pau_qps_destroyed;
41348 +atomic_unchecked_t pau_qps_created;
41349 +atomic_unchecked_t pau_qps_destroyed;
41350
41351 static void nes_replenish_mgt_rq(struct nes_vnic_mgt *mgtvnic)
41352 {
41353 @@ -621,7 +621,7 @@ void nes_destroy_pau_qp(struct nes_device *nesdev, struct nes_qp *nesqp)
41354 {
41355 struct sk_buff *skb;
41356 unsigned long flags;
41357 - atomic_inc(&pau_qps_destroyed);
41358 + atomic_inc_unchecked(&pau_qps_destroyed);
41359
41360 /* Free packets that have not yet been forwarded */
41361 /* Lock is acquired by skb_dequeue when removing the skb */
41362 @@ -810,7 +810,7 @@ static void nes_mgt_ce_handler(struct nes_device *nesdev, struct nes_hw_nic_cq *
41363 cq->cq_vbase[head].cqe_words[NES_NIC_CQE_HASH_RCVNXT]);
41364 skb_queue_head_init(&nesqp->pau_list);
41365 spin_lock_init(&nesqp->pau_lock);
41366 - atomic_inc(&pau_qps_created);
41367 + atomic_inc_unchecked(&pau_qps_created);
41368 nes_change_quad_hash(nesdev, mgtvnic->nesvnic, nesqp);
41369 }
41370
41371 diff --git a/drivers/infiniband/hw/nes/nes_nic.c b/drivers/infiniband/hw/nes/nes_nic.c
41372 index 49eb511..a774366 100644
41373 --- a/drivers/infiniband/hw/nes/nes_nic.c
41374 +++ b/drivers/infiniband/hw/nes/nes_nic.c
41375 @@ -1273,39 +1273,39 @@ static void nes_netdev_get_ethtool_stats(struct net_device *netdev,
41376 target_stat_values[++index] = mh_detected;
41377 target_stat_values[++index] = mh_pauses_sent;
41378 target_stat_values[++index] = nesvnic->endnode_ipv4_tcp_retransmits;
41379 - target_stat_values[++index] = atomic_read(&cm_connects);
41380 - target_stat_values[++index] = atomic_read(&cm_accepts);
41381 - target_stat_values[++index] = atomic_read(&cm_disconnects);
41382 - target_stat_values[++index] = atomic_read(&cm_connecteds);
41383 - target_stat_values[++index] = atomic_read(&cm_connect_reqs);
41384 - target_stat_values[++index] = atomic_read(&cm_rejects);
41385 - target_stat_values[++index] = atomic_read(&mod_qp_timouts);
41386 - target_stat_values[++index] = atomic_read(&qps_created);
41387 - target_stat_values[++index] = atomic_read(&sw_qps_destroyed);
41388 - target_stat_values[++index] = atomic_read(&qps_destroyed);
41389 - target_stat_values[++index] = atomic_read(&cm_closes);
41390 + target_stat_values[++index] = atomic_read_unchecked(&cm_connects);
41391 + target_stat_values[++index] = atomic_read_unchecked(&cm_accepts);
41392 + target_stat_values[++index] = atomic_read_unchecked(&cm_disconnects);
41393 + target_stat_values[++index] = atomic_read_unchecked(&cm_connecteds);
41394 + target_stat_values[++index] = atomic_read_unchecked(&cm_connect_reqs);
41395 + target_stat_values[++index] = atomic_read_unchecked(&cm_rejects);
41396 + target_stat_values[++index] = atomic_read_unchecked(&mod_qp_timouts);
41397 + target_stat_values[++index] = atomic_read_unchecked(&qps_created);
41398 + target_stat_values[++index] = atomic_read_unchecked(&sw_qps_destroyed);
41399 + target_stat_values[++index] = atomic_read_unchecked(&qps_destroyed);
41400 + target_stat_values[++index] = atomic_read_unchecked(&cm_closes);
41401 target_stat_values[++index] = cm_packets_sent;
41402 target_stat_values[++index] = cm_packets_bounced;
41403 target_stat_values[++index] = cm_packets_created;
41404 target_stat_values[++index] = cm_packets_received;
41405 target_stat_values[++index] = cm_packets_dropped;
41406 target_stat_values[++index] = cm_packets_retrans;
41407 - target_stat_values[++index] = atomic_read(&cm_listens_created);
41408 - target_stat_values[++index] = atomic_read(&cm_listens_destroyed);
41409 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_created);
41410 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_destroyed);
41411 target_stat_values[++index] = cm_backlog_drops;
41412 - target_stat_values[++index] = atomic_read(&cm_loopbacks);
41413 - target_stat_values[++index] = atomic_read(&cm_nodes_created);
41414 - target_stat_values[++index] = atomic_read(&cm_nodes_destroyed);
41415 - target_stat_values[++index] = atomic_read(&cm_accel_dropped_pkts);
41416 - target_stat_values[++index] = atomic_read(&cm_resets_recvd);
41417 + target_stat_values[++index] = atomic_read_unchecked(&cm_loopbacks);
41418 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_created);
41419 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_destroyed);
41420 + target_stat_values[++index] = atomic_read_unchecked(&cm_accel_dropped_pkts);
41421 + target_stat_values[++index] = atomic_read_unchecked(&cm_resets_recvd);
41422 target_stat_values[++index] = nesadapter->free_4kpbl;
41423 target_stat_values[++index] = nesadapter->free_256pbl;
41424 target_stat_values[++index] = int_mod_timer_init;
41425 target_stat_values[++index] = nesvnic->lro_mgr.stats.aggregated;
41426 target_stat_values[++index] = nesvnic->lro_mgr.stats.flushed;
41427 target_stat_values[++index] = nesvnic->lro_mgr.stats.no_desc;
41428 - target_stat_values[++index] = atomic_read(&pau_qps_created);
41429 - target_stat_values[++index] = atomic_read(&pau_qps_destroyed);
41430 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_created);
41431 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_destroyed);
41432 }
41433
41434 /**
41435 diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c
41436 index 5b53ca5..443da3c 100644
41437 --- a/drivers/infiniband/hw/nes/nes_verbs.c
41438 +++ b/drivers/infiniband/hw/nes/nes_verbs.c
41439 @@ -46,9 +46,9 @@
41440
41441 #include <rdma/ib_umem.h>
41442
41443 -atomic_t mod_qp_timouts;
41444 -atomic_t qps_created;
41445 -atomic_t sw_qps_destroyed;
41446 +atomic_unchecked_t mod_qp_timouts;
41447 +atomic_unchecked_t qps_created;
41448 +atomic_unchecked_t sw_qps_destroyed;
41449
41450 static void nes_unregister_ofa_device(struct nes_ib_device *nesibdev);
41451
41452 @@ -1134,7 +1134,7 @@ static struct ib_qp *nes_create_qp(struct ib_pd *ibpd,
41453 if (init_attr->create_flags)
41454 return ERR_PTR(-EINVAL);
41455
41456 - atomic_inc(&qps_created);
41457 + atomic_inc_unchecked(&qps_created);
41458 switch (init_attr->qp_type) {
41459 case IB_QPT_RC:
41460 if (nes_drv_opt & NES_DRV_OPT_NO_INLINE_DATA) {
41461 @@ -1466,7 +1466,7 @@ static int nes_destroy_qp(struct ib_qp *ibqp)
41462 struct iw_cm_event cm_event;
41463 int ret = 0;
41464
41465 - atomic_inc(&sw_qps_destroyed);
41466 + atomic_inc_unchecked(&sw_qps_destroyed);
41467 nesqp->destroyed = 1;
41468
41469 /* Blow away the connection if it exists. */
41470 diff --git a/drivers/infiniband/hw/qib/qib.h b/drivers/infiniband/hw/qib/qib.h
41471 index 1946101..09766d2 100644
41472 --- a/drivers/infiniband/hw/qib/qib.h
41473 +++ b/drivers/infiniband/hw/qib/qib.h
41474 @@ -52,6 +52,7 @@
41475 #include <linux/kref.h>
41476 #include <linux/sched.h>
41477 #include <linux/kthread.h>
41478 +#include <linux/slab.h>
41479
41480 #include "qib_common.h"
41481 #include "qib_verbs.h"
41482 diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c
41483 index 922a7fe..bb035db 100644
41484 --- a/drivers/input/gameport/gameport.c
41485 +++ b/drivers/input/gameport/gameport.c
41486 @@ -487,14 +487,14 @@ EXPORT_SYMBOL(gameport_set_phys);
41487 */
41488 static void gameport_init_port(struct gameport *gameport)
41489 {
41490 - static atomic_t gameport_no = ATOMIC_INIT(0);
41491 + static atomic_unchecked_t gameport_no = ATOMIC_INIT(0);
41492
41493 __module_get(THIS_MODULE);
41494
41495 mutex_init(&gameport->drv_mutex);
41496 device_initialize(&gameport->dev);
41497 dev_set_name(&gameport->dev, "gameport%lu",
41498 - (unsigned long)atomic_inc_return(&gameport_no) - 1);
41499 + (unsigned long)atomic_inc_return_unchecked(&gameport_no) - 1);
41500 gameport->dev.bus = &gameport_bus;
41501 gameport->dev.release = gameport_release_port;
41502 if (gameport->parent)
41503 diff --git a/drivers/input/input.c b/drivers/input/input.c
41504 index e75d015..57d1c28 100644
41505 --- a/drivers/input/input.c
41506 +++ b/drivers/input/input.c
41507 @@ -1734,7 +1734,7 @@ EXPORT_SYMBOL_GPL(input_class);
41508 */
41509 struct input_dev *input_allocate_device(void)
41510 {
41511 - static atomic_t input_no = ATOMIC_INIT(0);
41512 + static atomic_unchecked_t input_no = ATOMIC_INIT(0);
41513 struct input_dev *dev;
41514
41515 dev = kzalloc(sizeof(struct input_dev), GFP_KERNEL);
41516 @@ -1749,7 +1749,7 @@ struct input_dev *input_allocate_device(void)
41517 INIT_LIST_HEAD(&dev->node);
41518
41519 dev_set_name(&dev->dev, "input%ld",
41520 - (unsigned long) atomic_inc_return(&input_no) - 1);
41521 + (unsigned long) atomic_inc_return_unchecked(&input_no) - 1);
41522
41523 __module_get(THIS_MODULE);
41524 }
41525 diff --git a/drivers/input/joystick/sidewinder.c b/drivers/input/joystick/sidewinder.c
41526 index 04c69af..5f92d00 100644
41527 --- a/drivers/input/joystick/sidewinder.c
41528 +++ b/drivers/input/joystick/sidewinder.c
41529 @@ -30,6 +30,7 @@
41530 #include <linux/kernel.h>
41531 #include <linux/module.h>
41532 #include <linux/slab.h>
41533 +#include <linux/sched.h>
41534 #include <linux/init.h>
41535 #include <linux/input.h>
41536 #include <linux/gameport.h>
41537 diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
41538 index 75e3b10..fb390fd 100644
41539 --- a/drivers/input/joystick/xpad.c
41540 +++ b/drivers/input/joystick/xpad.c
41541 @@ -736,7 +736,7 @@ static void xpad_led_set(struct led_classdev *led_cdev,
41542
41543 static int xpad_led_probe(struct usb_xpad *xpad)
41544 {
41545 - static atomic_t led_seq = ATOMIC_INIT(0);
41546 + static atomic_unchecked_t led_seq = ATOMIC_INIT(0);
41547 long led_no;
41548 struct xpad_led *led;
41549 struct led_classdev *led_cdev;
41550 @@ -749,7 +749,7 @@ static int xpad_led_probe(struct usb_xpad *xpad)
41551 if (!led)
41552 return -ENOMEM;
41553
41554 - led_no = (long)atomic_inc_return(&led_seq) - 1;
41555 + led_no = (long)atomic_inc_return_unchecked(&led_seq) - 1;
41556
41557 snprintf(led->name, sizeof(led->name), "xpad%ld", led_no);
41558 led->xpad = xpad;
41559 diff --git a/drivers/input/misc/ims-pcu.c b/drivers/input/misc/ims-pcu.c
41560 index e204f26..8459f15 100644
41561 --- a/drivers/input/misc/ims-pcu.c
41562 +++ b/drivers/input/misc/ims-pcu.c
41563 @@ -1621,7 +1621,7 @@ static int ims_pcu_identify_type(struct ims_pcu *pcu, u8 *device_id)
41564
41565 static int ims_pcu_init_application_mode(struct ims_pcu *pcu)
41566 {
41567 - static atomic_t device_no = ATOMIC_INIT(0);
41568 + static atomic_unchecked_t device_no = ATOMIC_INIT(0);
41569
41570 const struct ims_pcu_device_info *info;
41571 u8 device_id;
41572 @@ -1653,7 +1653,7 @@ static int ims_pcu_init_application_mode(struct ims_pcu *pcu)
41573 }
41574
41575 /* Device appears to be operable, complete initialization */
41576 - pcu->device_no = atomic_inc_return(&device_no) - 1;
41577 + pcu->device_no = atomic_inc_return_unchecked(&device_no) - 1;
41578
41579 error = ims_pcu_setup_backlight(pcu);
41580 if (error)
41581 diff --git a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h
41582 index 2f0b39d..7370f13 100644
41583 --- a/drivers/input/mouse/psmouse.h
41584 +++ b/drivers/input/mouse/psmouse.h
41585 @@ -116,7 +116,7 @@ struct psmouse_attribute {
41586 ssize_t (*set)(struct psmouse *psmouse, void *data,
41587 const char *buf, size_t count);
41588 bool protect;
41589 -};
41590 +} __do_const;
41591 #define to_psmouse_attr(a) container_of((a), struct psmouse_attribute, dattr)
41592
41593 ssize_t psmouse_attr_show_helper(struct device *dev, struct device_attribute *attr,
41594 diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c
41595 index 4c842c3..590b0bf 100644
41596 --- a/drivers/input/mousedev.c
41597 +++ b/drivers/input/mousedev.c
41598 @@ -738,7 +738,7 @@ static ssize_t mousedev_read(struct file *file, char __user *buffer,
41599
41600 spin_unlock_irq(&client->packet_lock);
41601
41602 - if (copy_to_user(buffer, data, count))
41603 + if (count > sizeof(data) || copy_to_user(buffer, data, count))
41604 return -EFAULT;
41605
41606 return count;
41607 diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
41608 index 2b56855..5a55837 100644
41609 --- a/drivers/input/serio/serio.c
41610 +++ b/drivers/input/serio/serio.c
41611 @@ -496,7 +496,7 @@ static void serio_release_port(struct device *dev)
41612 */
41613 static void serio_init_port(struct serio *serio)
41614 {
41615 - static atomic_t serio_no = ATOMIC_INIT(0);
41616 + static atomic_unchecked_t serio_no = ATOMIC_INIT(0);
41617
41618 __module_get(THIS_MODULE);
41619
41620 @@ -507,7 +507,7 @@ static void serio_init_port(struct serio *serio)
41621 mutex_init(&serio->drv_mutex);
41622 device_initialize(&serio->dev);
41623 dev_set_name(&serio->dev, "serio%ld",
41624 - (long)atomic_inc_return(&serio_no) - 1);
41625 + (long)atomic_inc_return_unchecked(&serio_no) - 1);
41626 serio->dev.bus = &serio_bus;
41627 serio->dev.release = serio_release_port;
41628 serio->dev.groups = serio_device_attr_groups;
41629 diff --git a/drivers/input/serio/serio_raw.c b/drivers/input/serio/serio_raw.c
41630 index 59df2e7..8f1cafb 100644
41631 --- a/drivers/input/serio/serio_raw.c
41632 +++ b/drivers/input/serio/serio_raw.c
41633 @@ -293,7 +293,7 @@ static irqreturn_t serio_raw_interrupt(struct serio *serio, unsigned char data,
41634
41635 static int serio_raw_connect(struct serio *serio, struct serio_driver *drv)
41636 {
41637 - static atomic_t serio_raw_no = ATOMIC_INIT(0);
41638 + static atomic_unchecked_t serio_raw_no = ATOMIC_INIT(0);
41639 struct serio_raw *serio_raw;
41640 int err;
41641
41642 @@ -304,7 +304,7 @@ static int serio_raw_connect(struct serio *serio, struct serio_driver *drv)
41643 }
41644
41645 snprintf(serio_raw->name, sizeof(serio_raw->name),
41646 - "serio_raw%ld", (long)atomic_inc_return(&serio_raw_no) - 1);
41647 + "serio_raw%ld", (long)atomic_inc_return_unchecked(&serio_raw_no) - 1);
41648 kref_init(&serio_raw->kref);
41649 INIT_LIST_HEAD(&serio_raw->client_list);
41650 init_waitqueue_head(&serio_raw->wait);
41651 diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
41652 index fbe9ca7..dbee61d 100644
41653 --- a/drivers/iommu/iommu.c
41654 +++ b/drivers/iommu/iommu.c
41655 @@ -583,7 +583,7 @@ static struct notifier_block iommu_bus_nb = {
41656 static void iommu_bus_init(struct bus_type *bus, struct iommu_ops *ops)
41657 {
41658 bus_register_notifier(bus, &iommu_bus_nb);
41659 - bus_for_each_dev(bus, NULL, ops, add_iommu_group);
41660 + bus_for_each_dev(bus, NULL, (void *)ops, add_iommu_group);
41661 }
41662
41663 /**
41664 diff --git a/drivers/iommu/irq_remapping.c b/drivers/iommu/irq_remapping.c
41665 index 39f81ae..2660096 100644
41666 --- a/drivers/iommu/irq_remapping.c
41667 +++ b/drivers/iommu/irq_remapping.c
41668 @@ -356,7 +356,7 @@ int setup_hpet_msi_remapped(unsigned int irq, unsigned int id)
41669 void panic_if_irq_remap(const char *msg)
41670 {
41671 if (irq_remapping_enabled)
41672 - panic(msg);
41673 + panic("%s", msg);
41674 }
41675
41676 static void ir_ack_apic_edge(struct irq_data *data)
41677 @@ -377,10 +377,12 @@ static void ir_print_prefix(struct irq_data *data, struct seq_file *p)
41678
41679 void irq_remap_modify_chip_defaults(struct irq_chip *chip)
41680 {
41681 - chip->irq_print_chip = ir_print_prefix;
41682 - chip->irq_ack = ir_ack_apic_edge;
41683 - chip->irq_eoi = ir_ack_apic_level;
41684 - chip->irq_set_affinity = x86_io_apic_ops.set_affinity;
41685 + pax_open_kernel();
41686 + *(void **)&chip->irq_print_chip = ir_print_prefix;
41687 + *(void **)&chip->irq_ack = ir_ack_apic_edge;
41688 + *(void **)&chip->irq_eoi = ir_ack_apic_level;
41689 + *(void **)&chip->irq_set_affinity = x86_io_apic_ops.set_affinity;
41690 + pax_close_kernel();
41691 }
41692
41693 bool setup_remapped_irq(int irq, struct irq_cfg *cfg, struct irq_chip *chip)
41694 diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c
41695 index d0e9480..d2b6340 100644
41696 --- a/drivers/irqchip/irq-gic.c
41697 +++ b/drivers/irqchip/irq-gic.c
41698 @@ -84,7 +84,7 @@ static u8 gic_cpu_map[NR_GIC_CPU_IF] __read_mostly;
41699 * Supported arch specific GIC irq extension.
41700 * Default make them NULL.
41701 */
41702 -struct irq_chip gic_arch_extn = {
41703 +irq_chip_no_const gic_arch_extn = {
41704 .irq_eoi = NULL,
41705 .irq_mask = NULL,
41706 .irq_unmask = NULL,
41707 @@ -333,7 +333,7 @@ static void gic_handle_cascade_irq(unsigned int irq, struct irq_desc *desc)
41708 chained_irq_exit(chip, desc);
41709 }
41710
41711 -static struct irq_chip gic_chip = {
41712 +static irq_chip_no_const gic_chip __read_only = {
41713 .name = "GIC",
41714 .irq_mask = gic_mask_irq,
41715 .irq_unmask = gic_unmask_irq,
41716 diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
41717 index ac6f72b..81150f2 100644
41718 --- a/drivers/isdn/capi/capi.c
41719 +++ b/drivers/isdn/capi/capi.c
41720 @@ -81,8 +81,8 @@ struct capiminor {
41721
41722 struct capi20_appl *ap;
41723 u32 ncci;
41724 - atomic_t datahandle;
41725 - atomic_t msgid;
41726 + atomic_unchecked_t datahandle;
41727 + atomic_unchecked_t msgid;
41728
41729 struct tty_port port;
41730 int ttyinstop;
41731 @@ -391,7 +391,7 @@ gen_data_b3_resp_for(struct capiminor *mp, struct sk_buff *skb)
41732 capimsg_setu16(s, 2, mp->ap->applid);
41733 capimsg_setu8 (s, 4, CAPI_DATA_B3);
41734 capimsg_setu8 (s, 5, CAPI_RESP);
41735 - capimsg_setu16(s, 6, atomic_inc_return(&mp->msgid));
41736 + capimsg_setu16(s, 6, atomic_inc_return_unchecked(&mp->msgid));
41737 capimsg_setu32(s, 8, mp->ncci);
41738 capimsg_setu16(s, 12, datahandle);
41739 }
41740 @@ -512,14 +512,14 @@ static void handle_minor_send(struct capiminor *mp)
41741 mp->outbytes -= len;
41742 spin_unlock_bh(&mp->outlock);
41743
41744 - datahandle = atomic_inc_return(&mp->datahandle);
41745 + datahandle = atomic_inc_return_unchecked(&mp->datahandle);
41746 skb_push(skb, CAPI_DATA_B3_REQ_LEN);
41747 memset(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
41748 capimsg_setu16(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
41749 capimsg_setu16(skb->data, 2, mp->ap->applid);
41750 capimsg_setu8 (skb->data, 4, CAPI_DATA_B3);
41751 capimsg_setu8 (skb->data, 5, CAPI_REQ);
41752 - capimsg_setu16(skb->data, 6, atomic_inc_return(&mp->msgid));
41753 + capimsg_setu16(skb->data, 6, atomic_inc_return_unchecked(&mp->msgid));
41754 capimsg_setu32(skb->data, 8, mp->ncci); /* NCCI */
41755 capimsg_setu32(skb->data, 12, (u32)(long)skb->data);/* Data32 */
41756 capimsg_setu16(skb->data, 16, len); /* Data length */
41757 diff --git a/drivers/isdn/gigaset/interface.c b/drivers/isdn/gigaset/interface.c
41758 index 600c79b..3752bab 100644
41759 --- a/drivers/isdn/gigaset/interface.c
41760 +++ b/drivers/isdn/gigaset/interface.c
41761 @@ -130,9 +130,9 @@ static int if_open(struct tty_struct *tty, struct file *filp)
41762 }
41763 tty->driver_data = cs;
41764
41765 - ++cs->port.count;
41766 + atomic_inc(&cs->port.count);
41767
41768 - if (cs->port.count == 1) {
41769 + if (atomic_read(&cs->port.count) == 1) {
41770 tty_port_tty_set(&cs->port, tty);
41771 cs->port.low_latency = 1;
41772 }
41773 @@ -156,9 +156,9 @@ static void if_close(struct tty_struct *tty, struct file *filp)
41774
41775 if (!cs->connected)
41776 gig_dbg(DEBUG_IF, "not connected"); /* nothing to do */
41777 - else if (!cs->port.count)
41778 + else if (!atomic_read(&cs->port.count))
41779 dev_warn(cs->dev, "%s: device not opened\n", __func__);
41780 - else if (!--cs->port.count)
41781 + else if (!atomic_dec_return(&cs->port.count))
41782 tty_port_tty_set(&cs->port, NULL);
41783
41784 mutex_unlock(&cs->mutex);
41785 diff --git a/drivers/isdn/gigaset/usb-gigaset.c b/drivers/isdn/gigaset/usb-gigaset.c
41786 index d0a41cb..f0cdb8c 100644
41787 --- a/drivers/isdn/gigaset/usb-gigaset.c
41788 +++ b/drivers/isdn/gigaset/usb-gigaset.c
41789 @@ -547,7 +547,7 @@ static int gigaset_brkchars(struct cardstate *cs, const unsigned char buf[6])
41790 gigaset_dbg_buffer(DEBUG_USBREQ, "brkchars", 6, buf);
41791 memcpy(cs->hw.usb->bchars, buf, 6);
41792 return usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x19, 0x41,
41793 - 0, 0, &buf, 6, 2000);
41794 + 0, 0, buf, 6, 2000);
41795 }
41796
41797 static void gigaset_freebcshw(struct bc_state *bcs)
41798 diff --git a/drivers/isdn/hardware/avm/b1.c b/drivers/isdn/hardware/avm/b1.c
41799 index 4d9b195..455075c 100644
41800 --- a/drivers/isdn/hardware/avm/b1.c
41801 +++ b/drivers/isdn/hardware/avm/b1.c
41802 @@ -176,7 +176,7 @@ int b1_load_t4file(avmcard *card, capiloaddatapart *t4file)
41803 }
41804 if (left) {
41805 if (t4file->user) {
41806 - if (copy_from_user(buf, dp, left))
41807 + if (left > sizeof buf || copy_from_user(buf, dp, left))
41808 return -EFAULT;
41809 } else {
41810 memcpy(buf, dp, left);
41811 @@ -224,7 +224,7 @@ int b1_load_config(avmcard *card, capiloaddatapart *config)
41812 }
41813 if (left) {
41814 if (config->user) {
41815 - if (copy_from_user(buf, dp, left))
41816 + if (left > sizeof buf || copy_from_user(buf, dp, left))
41817 return -EFAULT;
41818 } else {
41819 memcpy(buf, dp, left);
41820 diff --git a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c
41821 index 9bb12ba..d4262f7 100644
41822 --- a/drivers/isdn/i4l/isdn_common.c
41823 +++ b/drivers/isdn/i4l/isdn_common.c
41824 @@ -1651,6 +1651,8 @@ isdn_ioctl(struct file *file, uint cmd, ulong arg)
41825 } else
41826 return -EINVAL;
41827 case IIOCDBGVAR:
41828 + if (!capable(CAP_SYS_RAWIO))
41829 + return -EPERM;
41830 if (arg) {
41831 if (copy_to_user(argp, &dev, sizeof(ulong)))
41832 return -EFAULT;
41833 diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c
41834 index 3c5f249..5fac4d0 100644
41835 --- a/drivers/isdn/i4l/isdn_tty.c
41836 +++ b/drivers/isdn/i4l/isdn_tty.c
41837 @@ -1508,9 +1508,9 @@ isdn_tty_open(struct tty_struct *tty, struct file *filp)
41838
41839 #ifdef ISDN_DEBUG_MODEM_OPEN
41840 printk(KERN_DEBUG "isdn_tty_open %s, count = %d\n", tty->name,
41841 - port->count);
41842 + atomic_read(&port->count));
41843 #endif
41844 - port->count++;
41845 + atomic_inc(&port->count);
41846 port->tty = tty;
41847 /*
41848 * Start up serial port
41849 @@ -1554,7 +1554,7 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
41850 #endif
41851 return;
41852 }
41853 - if ((tty->count == 1) && (port->count != 1)) {
41854 + if ((tty->count == 1) && (atomic_read(&port->count) != 1)) {
41855 /*
41856 * Uh, oh. tty->count is 1, which means that the tty
41857 * structure will be freed. Info->count should always
41858 @@ -1563,15 +1563,15 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
41859 * serial port won't be shutdown.
41860 */
41861 printk(KERN_ERR "isdn_tty_close: bad port count; tty->count is 1, "
41862 - "info->count is %d\n", port->count);
41863 - port->count = 1;
41864 + "info->count is %d\n", atomic_read(&port->count));
41865 + atomic_set(&port->count, 1);
41866 }
41867 - if (--port->count < 0) {
41868 + if (atomic_dec_return(&port->count) < 0) {
41869 printk(KERN_ERR "isdn_tty_close: bad port count for ttyi%d: %d\n",
41870 - info->line, port->count);
41871 - port->count = 0;
41872 + info->line, atomic_read(&port->count));
41873 + atomic_set(&port->count, 0);
41874 }
41875 - if (port->count) {
41876 + if (atomic_read(&port->count)) {
41877 #ifdef ISDN_DEBUG_MODEM_OPEN
41878 printk(KERN_DEBUG "isdn_tty_close after info->count != 0\n");
41879 #endif
41880 @@ -1625,7 +1625,7 @@ isdn_tty_hangup(struct tty_struct *tty)
41881 if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_hangup"))
41882 return;
41883 isdn_tty_shutdown(info);
41884 - port->count = 0;
41885 + atomic_set(&port->count, 0);
41886 port->flags &= ~ASYNC_NORMAL_ACTIVE;
41887 port->tty = NULL;
41888 wake_up_interruptible(&port->open_wait);
41889 @@ -1970,7 +1970,7 @@ isdn_tty_find_icall(int di, int ch, setup_parm *setup)
41890 for (i = 0; i < ISDN_MAX_CHANNELS; i++) {
41891 modem_info *info = &dev->mdm.info[i];
41892
41893 - if (info->port.count == 0)
41894 + if (atomic_read(&info->port.count) == 0)
41895 continue;
41896 if ((info->emu.mdmreg[REG_SI1] & si2bit[si1]) && /* SI1 is matching */
41897 (info->emu.mdmreg[REG_SI2] == si2)) { /* SI2 is matching */
41898 diff --git a/drivers/isdn/icn/icn.c b/drivers/isdn/icn/icn.c
41899 index e74df7c..03a03ba 100644
41900 --- a/drivers/isdn/icn/icn.c
41901 +++ b/drivers/isdn/icn/icn.c
41902 @@ -1045,7 +1045,7 @@ icn_writecmd(const u_char *buf, int len, int user, icn_card *card)
41903 if (count > len)
41904 count = len;
41905 if (user) {
41906 - if (copy_from_user(msg, buf, count))
41907 + if (count > sizeof msg || copy_from_user(msg, buf, count))
41908 return -EFAULT;
41909 } else
41910 memcpy(msg, buf, count);
41911 diff --git a/drivers/isdn/mISDN/dsp_cmx.c b/drivers/isdn/mISDN/dsp_cmx.c
41912 index a4f05c5..1433bc5 100644
41913 --- a/drivers/isdn/mISDN/dsp_cmx.c
41914 +++ b/drivers/isdn/mISDN/dsp_cmx.c
41915 @@ -1628,7 +1628,7 @@ unsigned long dsp_spl_jiffies; /* calculate the next time to fire */
41916 static u16 dsp_count; /* last sample count */
41917 static int dsp_count_valid; /* if we have last sample count */
41918
41919 -void
41920 +void __intentional_overflow(-1)
41921 dsp_cmx_send(void *arg)
41922 {
41923 struct dsp_conf *conf;
41924 diff --git a/drivers/leds/leds-clevo-mail.c b/drivers/leds/leds-clevo-mail.c
41925 index d93e245..e7ece6b 100644
41926 --- a/drivers/leds/leds-clevo-mail.c
41927 +++ b/drivers/leds/leds-clevo-mail.c
41928 @@ -40,7 +40,7 @@ static int __init clevo_mail_led_dmi_callback(const struct dmi_system_id *id)
41929 * detected as working, but in reality it is not) as low as
41930 * possible.
41931 */
41932 -static struct dmi_system_id clevo_mail_led_dmi_table[] __initdata = {
41933 +static struct dmi_system_id clevo_mail_led_dmi_table[] __initconst = {
41934 {
41935 .callback = clevo_mail_led_dmi_callback,
41936 .ident = "Clevo D410J",
41937 diff --git a/drivers/leds/leds-ss4200.c b/drivers/leds/leds-ss4200.c
41938 index 5b8f938..b73d657 100644
41939 --- a/drivers/leds/leds-ss4200.c
41940 +++ b/drivers/leds/leds-ss4200.c
41941 @@ -91,7 +91,7 @@ MODULE_PARM_DESC(nodetect, "Skip DMI-based hardware detection");
41942 * detected as working, but in reality it is not) as low as
41943 * possible.
41944 */
41945 -static struct dmi_system_id nas_led_whitelist[] __initdata = {
41946 +static struct dmi_system_id nas_led_whitelist[] __initconst = {
41947 {
41948 .callback = ss4200_led_dmi_callback,
41949 .ident = "Intel SS4200-E",
41950 diff --git a/drivers/lguest/core.c b/drivers/lguest/core.c
41951 index 0bf1e4e..b4bf44e 100644
41952 --- a/drivers/lguest/core.c
41953 +++ b/drivers/lguest/core.c
41954 @@ -97,9 +97,17 @@ static __init int map_switcher(void)
41955 * The end address needs +1 because __get_vm_area allocates an
41956 * extra guard page, so we need space for that.
41957 */
41958 +
41959 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
41960 + switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
41961 + VM_ALLOC | VM_KERNEXEC, switcher_addr, switcher_addr
41962 + + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
41963 +#else
41964 switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
41965 VM_ALLOC, switcher_addr, switcher_addr
41966 + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
41967 +#endif
41968 +
41969 if (!switcher_vma) {
41970 err = -ENOMEM;
41971 printk("lguest: could not map switcher pages high\n");
41972 @@ -124,7 +132,7 @@ static __init int map_switcher(void)
41973 * Now the Switcher is mapped at the right address, we can't fail!
41974 * Copy in the compiled-in Switcher code (from x86/switcher_32.S).
41975 */
41976 - memcpy(switcher_vma->addr, start_switcher_text,
41977 + memcpy(switcher_vma->addr, ktla_ktva(start_switcher_text),
41978 end_switcher_text - start_switcher_text);
41979
41980 printk(KERN_INFO "lguest: mapped switcher at %p\n",
41981 diff --git a/drivers/lguest/page_tables.c b/drivers/lguest/page_tables.c
41982 index bfb39bb..08a603b 100644
41983 --- a/drivers/lguest/page_tables.c
41984 +++ b/drivers/lguest/page_tables.c
41985 @@ -559,7 +559,7 @@ void pin_page(struct lg_cpu *cpu, unsigned long vaddr)
41986 /*:*/
41987
41988 #ifdef CONFIG_X86_PAE
41989 -static void release_pmd(pmd_t *spmd)
41990 +static void __intentional_overflow(-1) release_pmd(pmd_t *spmd)
41991 {
41992 /* If the entry's not present, there's nothing to release. */
41993 if (pmd_flags(*spmd) & _PAGE_PRESENT) {
41994 diff --git a/drivers/lguest/x86/core.c b/drivers/lguest/x86/core.c
41995 index 5169239..47cb4db 100644
41996 --- a/drivers/lguest/x86/core.c
41997 +++ b/drivers/lguest/x86/core.c
41998 @@ -59,7 +59,7 @@ static struct {
41999 /* Offset from where switcher.S was compiled to where we've copied it */
42000 static unsigned long switcher_offset(void)
42001 {
42002 - return switcher_addr - (unsigned long)start_switcher_text;
42003 + return switcher_addr - (unsigned long)ktla_ktva(start_switcher_text);
42004 }
42005
42006 /* This cpu's struct lguest_pages (after the Switcher text page) */
42007 @@ -99,7 +99,13 @@ static void copy_in_guest_info(struct lg_cpu *cpu, struct lguest_pages *pages)
42008 * These copies are pretty cheap, so we do them unconditionally: */
42009 /* Save the current Host top-level page directory.
42010 */
42011 +
42012 +#ifdef CONFIG_PAX_PER_CPU_PGD
42013 + pages->state.host_cr3 = read_cr3();
42014 +#else
42015 pages->state.host_cr3 = __pa(current->mm->pgd);
42016 +#endif
42017 +
42018 /*
42019 * Set up the Guest's page tables to see this CPU's pages (and no
42020 * other CPU's pages).
42021 @@ -475,7 +481,7 @@ void __init lguest_arch_host_init(void)
42022 * compiled-in switcher code and the high-mapped copy we just made.
42023 */
42024 for (i = 0; i < IDT_ENTRIES; i++)
42025 - default_idt_entries[i] += switcher_offset();
42026 + default_idt_entries[i] = ktla_ktva(default_idt_entries[i]) + switcher_offset();
42027
42028 /*
42029 * Set up the Switcher's per-cpu areas.
42030 @@ -558,7 +564,7 @@ void __init lguest_arch_host_init(void)
42031 * it will be undisturbed when we switch. To change %cs and jump we
42032 * need this structure to feed to Intel's "lcall" instruction.
42033 */
42034 - lguest_entry.offset = (long)switch_to_guest + switcher_offset();
42035 + lguest_entry.offset = (long)ktla_ktva(switch_to_guest) + switcher_offset();
42036 lguest_entry.segment = LGUEST_CS;
42037
42038 /*
42039 diff --git a/drivers/lguest/x86/switcher_32.S b/drivers/lguest/x86/switcher_32.S
42040 index 40634b0..4f5855e 100644
42041 --- a/drivers/lguest/x86/switcher_32.S
42042 +++ b/drivers/lguest/x86/switcher_32.S
42043 @@ -87,6 +87,7 @@
42044 #include <asm/page.h>
42045 #include <asm/segment.h>
42046 #include <asm/lguest.h>
42047 +#include <asm/processor-flags.h>
42048
42049 // We mark the start of the code to copy
42050 // It's placed in .text tho it's never run here
42051 @@ -149,6 +150,13 @@ ENTRY(switch_to_guest)
42052 // Changes type when we load it: damn Intel!
42053 // For after we switch over our page tables
42054 // That entry will be read-only: we'd crash.
42055 +
42056 +#ifdef CONFIG_PAX_KERNEXEC
42057 + mov %cr0, %edx
42058 + xor $X86_CR0_WP, %edx
42059 + mov %edx, %cr0
42060 +#endif
42061 +
42062 movl $(GDT_ENTRY_TSS*8), %edx
42063 ltr %dx
42064
42065 @@ -157,9 +165,15 @@ ENTRY(switch_to_guest)
42066 // Let's clear it again for our return.
42067 // The GDT descriptor of the Host
42068 // Points to the table after two "size" bytes
42069 - movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %edx
42070 + movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %eax
42071 // Clear "used" from type field (byte 5, bit 2)
42072 - andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%edx)
42073 + andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%eax)
42074 +
42075 +#ifdef CONFIG_PAX_KERNEXEC
42076 + mov %cr0, %eax
42077 + xor $X86_CR0_WP, %eax
42078 + mov %eax, %cr0
42079 +#endif
42080
42081 // Once our page table's switched, the Guest is live!
42082 // The Host fades as we run this final step.
42083 @@ -295,13 +309,12 @@ deliver_to_host:
42084 // I consulted gcc, and it gave
42085 // These instructions, which I gladly credit:
42086 leal (%edx,%ebx,8), %eax
42087 - movzwl (%eax),%edx
42088 - movl 4(%eax), %eax
42089 - xorw %ax, %ax
42090 - orl %eax, %edx
42091 + movl 4(%eax), %edx
42092 + movw (%eax), %dx
42093 // Now the address of the handler's in %edx
42094 // We call it now: its "iret" drops us home.
42095 - jmp *%edx
42096 + ljmp $__KERNEL_CS, $1f
42097 +1: jmp *%edx
42098
42099 // Every interrupt can come to us here
42100 // But we must truly tell each apart.
42101 diff --git a/drivers/md/bcache/closure.h b/drivers/md/bcache/closure.h
42102 index 0003992..854bbce 100644
42103 --- a/drivers/md/bcache/closure.h
42104 +++ b/drivers/md/bcache/closure.h
42105 @@ -622,7 +622,7 @@ static inline void closure_wake_up(struct closure_waitlist *list)
42106 static inline void set_closure_fn(struct closure *cl, closure_fn *fn,
42107 struct workqueue_struct *wq)
42108 {
42109 - BUG_ON(object_is_on_stack(cl));
42110 + BUG_ON(object_starts_on_stack(cl));
42111 closure_set_ip(cl);
42112 cl->fn = fn;
42113 cl->wq = wq;
42114 diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
42115 index 547c4c5..5be1de4 100644
42116 --- a/drivers/md/bcache/super.c
42117 +++ b/drivers/md/bcache/super.c
42118 @@ -1644,7 +1644,7 @@ err_unlock_gc:
42119 err:
42120 closure_sync(&op.cl);
42121 /* XXX: test this, it's broken */
42122 - bch_cache_set_error(c, err);
42123 + bch_cache_set_error(c, "%s", err);
42124 }
42125
42126 static bool can_attach_cache(struct cache *ca, struct cache_set *c)
42127 diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
42128 index a7fd821..9dcf6c3 100644
42129 --- a/drivers/md/bitmap.c
42130 +++ b/drivers/md/bitmap.c
42131 @@ -1779,7 +1779,7 @@ void bitmap_status(struct seq_file *seq, struct bitmap *bitmap)
42132 chunk_kb ? "KB" : "B");
42133 if (bitmap->storage.file) {
42134 seq_printf(seq, ", file: ");
42135 - seq_path(seq, &bitmap->storage.file->f_path, " \t\n");
42136 + seq_path(seq, &bitmap->storage.file->f_path, " \t\n\\");
42137 }
42138
42139 seq_printf(seq, "\n");
42140 diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
42141 index afe0814..8cf3794 100644
42142 --- a/drivers/md/dm-ioctl.c
42143 +++ b/drivers/md/dm-ioctl.c
42144 @@ -1745,7 +1745,7 @@ static int validate_params(uint cmd, struct dm_ioctl *param)
42145 cmd == DM_LIST_VERSIONS_CMD)
42146 return 0;
42147
42148 - if ((cmd == DM_DEV_CREATE_CMD)) {
42149 + if (cmd == DM_DEV_CREATE_CMD) {
42150 if (!*param->name) {
42151 DMWARN("name not supplied when creating device");
42152 return -EINVAL;
42153 diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
42154 index 9584443..9fc9ac9 100644
42155 --- a/drivers/md/dm-raid1.c
42156 +++ b/drivers/md/dm-raid1.c
42157 @@ -40,7 +40,7 @@ enum dm_raid1_error {
42158
42159 struct mirror {
42160 struct mirror_set *ms;
42161 - atomic_t error_count;
42162 + atomic_unchecked_t error_count;
42163 unsigned long error_type;
42164 struct dm_dev *dev;
42165 sector_t offset;
42166 @@ -186,7 +186,7 @@ static struct mirror *get_valid_mirror(struct mirror_set *ms)
42167 struct mirror *m;
42168
42169 for (m = ms->mirror; m < ms->mirror + ms->nr_mirrors; m++)
42170 - if (!atomic_read(&m->error_count))
42171 + if (!atomic_read_unchecked(&m->error_count))
42172 return m;
42173
42174 return NULL;
42175 @@ -218,7 +218,7 @@ static void fail_mirror(struct mirror *m, enum dm_raid1_error error_type)
42176 * simple way to tell if a device has encountered
42177 * errors.
42178 */
42179 - atomic_inc(&m->error_count);
42180 + atomic_inc_unchecked(&m->error_count);
42181
42182 if (test_and_set_bit(error_type, &m->error_type))
42183 return;
42184 @@ -409,7 +409,7 @@ static struct mirror *choose_mirror(struct mirror_set *ms, sector_t sector)
42185 struct mirror *m = get_default_mirror(ms);
42186
42187 do {
42188 - if (likely(!atomic_read(&m->error_count)))
42189 + if (likely(!atomic_read_unchecked(&m->error_count)))
42190 return m;
42191
42192 if (m-- == ms->mirror)
42193 @@ -423,7 +423,7 @@ static int default_ok(struct mirror *m)
42194 {
42195 struct mirror *default_mirror = get_default_mirror(m->ms);
42196
42197 - return !atomic_read(&default_mirror->error_count);
42198 + return !atomic_read_unchecked(&default_mirror->error_count);
42199 }
42200
42201 static int mirror_available(struct mirror_set *ms, struct bio *bio)
42202 @@ -560,7 +560,7 @@ static void do_reads(struct mirror_set *ms, struct bio_list *reads)
42203 */
42204 if (likely(region_in_sync(ms, region, 1)))
42205 m = choose_mirror(ms, bio->bi_sector);
42206 - else if (m && atomic_read(&m->error_count))
42207 + else if (m && atomic_read_unchecked(&m->error_count))
42208 m = NULL;
42209
42210 if (likely(m))
42211 @@ -927,7 +927,7 @@ static int get_mirror(struct mirror_set *ms, struct dm_target *ti,
42212 }
42213
42214 ms->mirror[mirror].ms = ms;
42215 - atomic_set(&(ms->mirror[mirror].error_count), 0);
42216 + atomic_set_unchecked(&(ms->mirror[mirror].error_count), 0);
42217 ms->mirror[mirror].error_type = 0;
42218 ms->mirror[mirror].offset = offset;
42219
42220 @@ -1339,7 +1339,7 @@ static void mirror_resume(struct dm_target *ti)
42221 */
42222 static char device_status_char(struct mirror *m)
42223 {
42224 - if (!atomic_read(&(m->error_count)))
42225 + if (!atomic_read_unchecked(&(m->error_count)))
42226 return 'A';
42227
42228 return (test_bit(DM_RAID1_FLUSH_ERROR, &(m->error_type))) ? 'F' :
42229 diff --git a/drivers/md/dm-stats.c b/drivers/md/dm-stats.c
42230 index 28a9012..9c0f6a5 100644
42231 --- a/drivers/md/dm-stats.c
42232 +++ b/drivers/md/dm-stats.c
42233 @@ -382,7 +382,7 @@ do_sync_free:
42234 synchronize_rcu_expedited();
42235 dm_stat_free(&s->rcu_head);
42236 } else {
42237 - ACCESS_ONCE(dm_stat_need_rcu_barrier) = 1;
42238 + ACCESS_ONCE_RW(dm_stat_need_rcu_barrier) = 1;
42239 call_rcu(&s->rcu_head, dm_stat_free);
42240 }
42241 return 0;
42242 @@ -554,8 +554,8 @@ void dm_stats_account_io(struct dm_stats *stats, unsigned long bi_rw,
42243 ((bi_rw & (REQ_WRITE | REQ_DISCARD)) ==
42244 (ACCESS_ONCE(last->last_rw) & (REQ_WRITE | REQ_DISCARD)))
42245 ));
42246 - ACCESS_ONCE(last->last_sector) = end_sector;
42247 - ACCESS_ONCE(last->last_rw) = bi_rw;
42248 + ACCESS_ONCE_RW(last->last_sector) = end_sector;
42249 + ACCESS_ONCE_RW(last->last_rw) = bi_rw;
42250 }
42251
42252 rcu_read_lock();
42253 diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c
42254 index 73c1712..7347292 100644
42255 --- a/drivers/md/dm-stripe.c
42256 +++ b/drivers/md/dm-stripe.c
42257 @@ -21,7 +21,7 @@ struct stripe {
42258 struct dm_dev *dev;
42259 sector_t physical_start;
42260
42261 - atomic_t error_count;
42262 + atomic_unchecked_t error_count;
42263 };
42264
42265 struct stripe_c {
42266 @@ -186,7 +186,7 @@ static int stripe_ctr(struct dm_target *ti, unsigned int argc, char **argv)
42267 kfree(sc);
42268 return r;
42269 }
42270 - atomic_set(&(sc->stripe[i].error_count), 0);
42271 + atomic_set_unchecked(&(sc->stripe[i].error_count), 0);
42272 }
42273
42274 ti->private = sc;
42275 @@ -327,7 +327,7 @@ static void stripe_status(struct dm_target *ti, status_type_t type,
42276 DMEMIT("%d ", sc->stripes);
42277 for (i = 0; i < sc->stripes; i++) {
42278 DMEMIT("%s ", sc->stripe[i].dev->name);
42279 - buffer[i] = atomic_read(&(sc->stripe[i].error_count)) ?
42280 + buffer[i] = atomic_read_unchecked(&(sc->stripe[i].error_count)) ?
42281 'D' : 'A';
42282 }
42283 buffer[i] = '\0';
42284 @@ -372,8 +372,8 @@ static int stripe_end_io(struct dm_target *ti, struct bio *bio, int error)
42285 */
42286 for (i = 0; i < sc->stripes; i++)
42287 if (!strcmp(sc->stripe[i].dev->name, major_minor)) {
42288 - atomic_inc(&(sc->stripe[i].error_count));
42289 - if (atomic_read(&(sc->stripe[i].error_count)) <
42290 + atomic_inc_unchecked(&(sc->stripe[i].error_count));
42291 + if (atomic_read_unchecked(&(sc->stripe[i].error_count)) <
42292 DM_IO_ERROR_THRESHOLD)
42293 schedule_work(&sc->trigger_event);
42294 }
42295 diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
42296 index 20a8cc0..5447b11 100644
42297 --- a/drivers/md/dm-table.c
42298 +++ b/drivers/md/dm-table.c
42299 @@ -291,7 +291,7 @@ static struct dm_dev_internal *find_device(struct list_head *l, dev_t dev)
42300 static int open_dev(struct dm_dev_internal *d, dev_t dev,
42301 struct mapped_device *md)
42302 {
42303 - static char *_claim_ptr = "I belong to device-mapper";
42304 + static char _claim_ptr[] = "I belong to device-mapper";
42305 struct block_device *bdev;
42306
42307 int r;
42308 @@ -359,7 +359,7 @@ static int device_area_is_invalid(struct dm_target *ti, struct dm_dev *dev,
42309 if (!dev_size)
42310 return 0;
42311
42312 - if ((start >= dev_size) || (start + len > dev_size)) {
42313 + if ((start >= dev_size) || (len > dev_size - start)) {
42314 DMWARN("%s: %s too small for target: "
42315 "start=%llu, len=%llu, dev_size=%llu",
42316 dm_device_name(ti->table->md), bdevname(bdev, b),
42317 diff --git a/drivers/md/dm-thin-metadata.c b/drivers/md/dm-thin-metadata.c
42318 index 8a30ad5..72792d3 100644
42319 --- a/drivers/md/dm-thin-metadata.c
42320 +++ b/drivers/md/dm-thin-metadata.c
42321 @@ -397,7 +397,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
42322 {
42323 pmd->info.tm = pmd->tm;
42324 pmd->info.levels = 2;
42325 - pmd->info.value_type.context = pmd->data_sm;
42326 + pmd->info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
42327 pmd->info.value_type.size = sizeof(__le64);
42328 pmd->info.value_type.inc = data_block_inc;
42329 pmd->info.value_type.dec = data_block_dec;
42330 @@ -416,7 +416,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
42331
42332 pmd->bl_info.tm = pmd->tm;
42333 pmd->bl_info.levels = 1;
42334 - pmd->bl_info.value_type.context = pmd->data_sm;
42335 + pmd->bl_info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
42336 pmd->bl_info.value_type.size = sizeof(__le64);
42337 pmd->bl_info.value_type.inc = data_block_inc;
42338 pmd->bl_info.value_type.dec = data_block_dec;
42339 diff --git a/drivers/md/dm.c b/drivers/md/dm.c
42340 index b3e26c7..1efca94 100644
42341 --- a/drivers/md/dm.c
42342 +++ b/drivers/md/dm.c
42343 @@ -179,9 +179,9 @@ struct mapped_device {
42344 /*
42345 * Event handling.
42346 */
42347 - atomic_t event_nr;
42348 + atomic_unchecked_t event_nr;
42349 wait_queue_head_t eventq;
42350 - atomic_t uevent_seq;
42351 + atomic_unchecked_t uevent_seq;
42352 struct list_head uevent_list;
42353 spinlock_t uevent_lock; /* Protect access to uevent_list */
42354
42355 @@ -1985,8 +1985,8 @@ static struct mapped_device *alloc_dev(int minor)
42356 spin_lock_init(&md->deferred_lock);
42357 atomic_set(&md->holders, 1);
42358 atomic_set(&md->open_count, 0);
42359 - atomic_set(&md->event_nr, 0);
42360 - atomic_set(&md->uevent_seq, 0);
42361 + atomic_set_unchecked(&md->event_nr, 0);
42362 + atomic_set_unchecked(&md->uevent_seq, 0);
42363 INIT_LIST_HEAD(&md->uevent_list);
42364 spin_lock_init(&md->uevent_lock);
42365
42366 @@ -2139,7 +2139,7 @@ static void event_callback(void *context)
42367
42368 dm_send_uevents(&uevents, &disk_to_dev(md->disk)->kobj);
42369
42370 - atomic_inc(&md->event_nr);
42371 + atomic_inc_unchecked(&md->event_nr);
42372 wake_up(&md->eventq);
42373 }
42374
42375 @@ -2832,18 +2832,18 @@ int dm_kobject_uevent(struct mapped_device *md, enum kobject_action action,
42376
42377 uint32_t dm_next_uevent_seq(struct mapped_device *md)
42378 {
42379 - return atomic_add_return(1, &md->uevent_seq);
42380 + return atomic_add_return_unchecked(1, &md->uevent_seq);
42381 }
42382
42383 uint32_t dm_get_event_nr(struct mapped_device *md)
42384 {
42385 - return atomic_read(&md->event_nr);
42386 + return atomic_read_unchecked(&md->event_nr);
42387 }
42388
42389 int dm_wait_event(struct mapped_device *md, int event_nr)
42390 {
42391 return wait_event_interruptible(md->eventq,
42392 - (event_nr != atomic_read(&md->event_nr)));
42393 + (event_nr != atomic_read_unchecked(&md->event_nr)));
42394 }
42395
42396 void dm_uevent_add(struct mapped_device *md, struct list_head *elist)
42397 diff --git a/drivers/md/md.c b/drivers/md/md.c
42398 index ba46d97..f8f5019 100644
42399 --- a/drivers/md/md.c
42400 +++ b/drivers/md/md.c
42401 @@ -234,10 +234,10 @@ EXPORT_SYMBOL_GPL(md_trim_bio);
42402 * start build, activate spare
42403 */
42404 static DECLARE_WAIT_QUEUE_HEAD(md_event_waiters);
42405 -static atomic_t md_event_count;
42406 +static atomic_unchecked_t md_event_count;
42407 void md_new_event(struct mddev *mddev)
42408 {
42409 - atomic_inc(&md_event_count);
42410 + atomic_inc_unchecked(&md_event_count);
42411 wake_up(&md_event_waiters);
42412 }
42413 EXPORT_SYMBOL_GPL(md_new_event);
42414 @@ -247,7 +247,7 @@ EXPORT_SYMBOL_GPL(md_new_event);
42415 */
42416 static void md_new_event_inintr(struct mddev *mddev)
42417 {
42418 - atomic_inc(&md_event_count);
42419 + atomic_inc_unchecked(&md_event_count);
42420 wake_up(&md_event_waiters);
42421 }
42422
42423 @@ -1502,7 +1502,7 @@ static int super_1_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor_
42424 if ((le32_to_cpu(sb->feature_map) & MD_FEATURE_RESHAPE_ACTIVE) &&
42425 (le32_to_cpu(sb->feature_map) & MD_FEATURE_NEW_OFFSET))
42426 rdev->new_data_offset += (s32)le32_to_cpu(sb->new_offset);
42427 - atomic_set(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
42428 + atomic_set_unchecked(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
42429
42430 rdev->sb_size = le32_to_cpu(sb->max_dev) * 2 + 256;
42431 bmask = queue_logical_block_size(rdev->bdev->bd_disk->queue)-1;
42432 @@ -1746,7 +1746,7 @@ static void super_1_sync(struct mddev *mddev, struct md_rdev *rdev)
42433 else
42434 sb->resync_offset = cpu_to_le64(0);
42435
42436 - sb->cnt_corrected_read = cpu_to_le32(atomic_read(&rdev->corrected_errors));
42437 + sb->cnt_corrected_read = cpu_to_le32(atomic_read_unchecked(&rdev->corrected_errors));
42438
42439 sb->raid_disks = cpu_to_le32(mddev->raid_disks);
42440 sb->size = cpu_to_le64(mddev->dev_sectors);
42441 @@ -2751,7 +2751,7 @@ __ATTR(state, S_IRUGO|S_IWUSR, state_show, state_store);
42442 static ssize_t
42443 errors_show(struct md_rdev *rdev, char *page)
42444 {
42445 - return sprintf(page, "%d\n", atomic_read(&rdev->corrected_errors));
42446 + return sprintf(page, "%d\n", atomic_read_unchecked(&rdev->corrected_errors));
42447 }
42448
42449 static ssize_t
42450 @@ -2760,7 +2760,7 @@ errors_store(struct md_rdev *rdev, const char *buf, size_t len)
42451 char *e;
42452 unsigned long n = simple_strtoul(buf, &e, 10);
42453 if (*buf && (*e == 0 || *e == '\n')) {
42454 - atomic_set(&rdev->corrected_errors, n);
42455 + atomic_set_unchecked(&rdev->corrected_errors, n);
42456 return len;
42457 }
42458 return -EINVAL;
42459 @@ -3208,8 +3208,8 @@ int md_rdev_init(struct md_rdev *rdev)
42460 rdev->sb_loaded = 0;
42461 rdev->bb_page = NULL;
42462 atomic_set(&rdev->nr_pending, 0);
42463 - atomic_set(&rdev->read_errors, 0);
42464 - atomic_set(&rdev->corrected_errors, 0);
42465 + atomic_set_unchecked(&rdev->read_errors, 0);
42466 + atomic_set_unchecked(&rdev->corrected_errors, 0);
42467
42468 INIT_LIST_HEAD(&rdev->same_set);
42469 init_waitqueue_head(&rdev->blocked_wait);
42470 @@ -7043,7 +7043,7 @@ static int md_seq_show(struct seq_file *seq, void *v)
42471
42472 spin_unlock(&pers_lock);
42473 seq_printf(seq, "\n");
42474 - seq->poll_event = atomic_read(&md_event_count);
42475 + seq->poll_event = atomic_read_unchecked(&md_event_count);
42476 return 0;
42477 }
42478 if (v == (void*)2) {
42479 @@ -7146,7 +7146,7 @@ static int md_seq_open(struct inode *inode, struct file *file)
42480 return error;
42481
42482 seq = file->private_data;
42483 - seq->poll_event = atomic_read(&md_event_count);
42484 + seq->poll_event = atomic_read_unchecked(&md_event_count);
42485 return error;
42486 }
42487
42488 @@ -7160,7 +7160,7 @@ static unsigned int mdstat_poll(struct file *filp, poll_table *wait)
42489 /* always allow read */
42490 mask = POLLIN | POLLRDNORM;
42491
42492 - if (seq->poll_event != atomic_read(&md_event_count))
42493 + if (seq->poll_event != atomic_read_unchecked(&md_event_count))
42494 mask |= POLLERR | POLLPRI;
42495 return mask;
42496 }
42497 @@ -7204,7 +7204,7 @@ static int is_mddev_idle(struct mddev *mddev, int init)
42498 struct gendisk *disk = rdev->bdev->bd_contains->bd_disk;
42499 curr_events = (int)part_stat_read(&disk->part0, sectors[0]) +
42500 (int)part_stat_read(&disk->part0, sectors[1]) -
42501 - atomic_read(&disk->sync_io);
42502 + atomic_read_unchecked(&disk->sync_io);
42503 /* sync IO will cause sync_io to increase before the disk_stats
42504 * as sync_io is counted when a request starts, and
42505 * disk_stats is counted when it completes.
42506 diff --git a/drivers/md/md.h b/drivers/md/md.h
42507 index 608050c..6e77db5d 100644
42508 --- a/drivers/md/md.h
42509 +++ b/drivers/md/md.h
42510 @@ -94,13 +94,13 @@ struct md_rdev {
42511 * only maintained for arrays that
42512 * support hot removal
42513 */
42514 - atomic_t read_errors; /* number of consecutive read errors that
42515 + atomic_unchecked_t read_errors; /* number of consecutive read errors that
42516 * we have tried to ignore.
42517 */
42518 struct timespec last_read_error; /* monotonic time since our
42519 * last read error
42520 */
42521 - atomic_t corrected_errors; /* number of corrected read errors,
42522 + atomic_unchecked_t corrected_errors; /* number of corrected read errors,
42523 * for reporting to userspace and storing
42524 * in superblock.
42525 */
42526 @@ -446,7 +446,7 @@ static inline void rdev_dec_pending(struct md_rdev *rdev, struct mddev *mddev)
42527
42528 static inline void md_sync_acct(struct block_device *bdev, unsigned long nr_sectors)
42529 {
42530 - atomic_add(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
42531 + atomic_add_unchecked(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
42532 }
42533
42534 struct md_personality
42535 diff --git a/drivers/md/persistent-data/dm-space-map.h b/drivers/md/persistent-data/dm-space-map.h
42536 index 3e6d115..ffecdeb 100644
42537 --- a/drivers/md/persistent-data/dm-space-map.h
42538 +++ b/drivers/md/persistent-data/dm-space-map.h
42539 @@ -71,6 +71,7 @@ struct dm_space_map {
42540 dm_sm_threshold_fn fn,
42541 void *context);
42542 };
42543 +typedef struct dm_space_map __no_const dm_space_map_no_const;
42544
42545 /*----------------------------------------------------------------*/
42546
42547 diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
42548 index aacf6bf..67d63f2 100644
42549 --- a/drivers/md/raid1.c
42550 +++ b/drivers/md/raid1.c
42551 @@ -1824,7 +1824,7 @@ static int fix_sync_read_error(struct r1bio *r1_bio)
42552 if (r1_sync_page_io(rdev, sect, s,
42553 bio->bi_io_vec[idx].bv_page,
42554 READ) != 0)
42555 - atomic_add(s, &rdev->corrected_errors);
42556 + atomic_add_unchecked(s, &rdev->corrected_errors);
42557 }
42558 sectors -= s;
42559 sect += s;
42560 @@ -2051,7 +2051,7 @@ static void fix_read_error(struct r1conf *conf, int read_disk,
42561 test_bit(In_sync, &rdev->flags)) {
42562 if (r1_sync_page_io(rdev, sect, s,
42563 conf->tmppage, READ)) {
42564 - atomic_add(s, &rdev->corrected_errors);
42565 + atomic_add_unchecked(s, &rdev->corrected_errors);
42566 printk(KERN_INFO
42567 "md/raid1:%s: read error corrected "
42568 "(%d sectors at %llu on %s)\n",
42569 diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
42570 index 73dc8a3..bdd515a 100644
42571 --- a/drivers/md/raid10.c
42572 +++ b/drivers/md/raid10.c
42573 @@ -1963,7 +1963,7 @@ static void end_sync_read(struct bio *bio, int error)
42574 /* The write handler will notice the lack of
42575 * R10BIO_Uptodate and record any errors etc
42576 */
42577 - atomic_add(r10_bio->sectors,
42578 + atomic_add_unchecked(r10_bio->sectors,
42579 &conf->mirrors[d].rdev->corrected_errors);
42580
42581 /* for reconstruct, we always reschedule after a read.
42582 @@ -2321,7 +2321,7 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
42583 {
42584 struct timespec cur_time_mon;
42585 unsigned long hours_since_last;
42586 - unsigned int read_errors = atomic_read(&rdev->read_errors);
42587 + unsigned int read_errors = atomic_read_unchecked(&rdev->read_errors);
42588
42589 ktime_get_ts(&cur_time_mon);
42590
42591 @@ -2343,9 +2343,9 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
42592 * overflowing the shift of read_errors by hours_since_last.
42593 */
42594 if (hours_since_last >= 8 * sizeof(read_errors))
42595 - atomic_set(&rdev->read_errors, 0);
42596 + atomic_set_unchecked(&rdev->read_errors, 0);
42597 else
42598 - atomic_set(&rdev->read_errors, read_errors >> hours_since_last);
42599 + atomic_set_unchecked(&rdev->read_errors, read_errors >> hours_since_last);
42600 }
42601
42602 static int r10_sync_page_io(struct md_rdev *rdev, sector_t sector,
42603 @@ -2399,8 +2399,8 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
42604 return;
42605
42606 check_decay_read_errors(mddev, rdev);
42607 - atomic_inc(&rdev->read_errors);
42608 - if (atomic_read(&rdev->read_errors) > max_read_errors) {
42609 + atomic_inc_unchecked(&rdev->read_errors);
42610 + if (atomic_read_unchecked(&rdev->read_errors) > max_read_errors) {
42611 char b[BDEVNAME_SIZE];
42612 bdevname(rdev->bdev, b);
42613
42614 @@ -2408,7 +2408,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
42615 "md/raid10:%s: %s: Raid device exceeded "
42616 "read_error threshold [cur %d:max %d]\n",
42617 mdname(mddev), b,
42618 - atomic_read(&rdev->read_errors), max_read_errors);
42619 + atomic_read_unchecked(&rdev->read_errors), max_read_errors);
42620 printk(KERN_NOTICE
42621 "md/raid10:%s: %s: Failing raid device\n",
42622 mdname(mddev), b);
42623 @@ -2563,7 +2563,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
42624 sect +
42625 choose_data_offset(r10_bio, rdev)),
42626 bdevname(rdev->bdev, b));
42627 - atomic_add(s, &rdev->corrected_errors);
42628 + atomic_add_unchecked(s, &rdev->corrected_errors);
42629 }
42630
42631 rdev_dec_pending(rdev, mddev);
42632 diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
42633 index 8a0665d..984c46d 100644
42634 --- a/drivers/md/raid5.c
42635 +++ b/drivers/md/raid5.c
42636 @@ -1887,21 +1887,21 @@ static void raid5_end_read_request(struct bio * bi, int error)
42637 mdname(conf->mddev), STRIPE_SECTORS,
42638 (unsigned long long)s,
42639 bdevname(rdev->bdev, b));
42640 - atomic_add(STRIPE_SECTORS, &rdev->corrected_errors);
42641 + atomic_add_unchecked(STRIPE_SECTORS, &rdev->corrected_errors);
42642 clear_bit(R5_ReadError, &sh->dev[i].flags);
42643 clear_bit(R5_ReWrite, &sh->dev[i].flags);
42644 } else if (test_bit(R5_ReadNoMerge, &sh->dev[i].flags))
42645 clear_bit(R5_ReadNoMerge, &sh->dev[i].flags);
42646
42647 - if (atomic_read(&rdev->read_errors))
42648 - atomic_set(&rdev->read_errors, 0);
42649 + if (atomic_read_unchecked(&rdev->read_errors))
42650 + atomic_set_unchecked(&rdev->read_errors, 0);
42651 } else {
42652 const char *bdn = bdevname(rdev->bdev, b);
42653 int retry = 0;
42654 int set_bad = 0;
42655
42656 clear_bit(R5_UPTODATE, &sh->dev[i].flags);
42657 - atomic_inc(&rdev->read_errors);
42658 + atomic_inc_unchecked(&rdev->read_errors);
42659 if (test_bit(R5_ReadRepl, &sh->dev[i].flags))
42660 printk_ratelimited(
42661 KERN_WARNING
42662 @@ -1929,7 +1929,7 @@ static void raid5_end_read_request(struct bio * bi, int error)
42663 mdname(conf->mddev),
42664 (unsigned long long)s,
42665 bdn);
42666 - } else if (atomic_read(&rdev->read_errors)
42667 + } else if (atomic_read_unchecked(&rdev->read_errors)
42668 > conf->max_nr_stripes)
42669 printk(KERN_WARNING
42670 "md/raid:%s: Too many read errors, failing device %s.\n",
42671 diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
42672 index 401ef64..836e563 100644
42673 --- a/drivers/media/dvb-core/dvbdev.c
42674 +++ b/drivers/media/dvb-core/dvbdev.c
42675 @@ -192,7 +192,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
42676 const struct dvb_device *template, void *priv, int type)
42677 {
42678 struct dvb_device *dvbdev;
42679 - struct file_operations *dvbdevfops;
42680 + file_operations_no_const *dvbdevfops;
42681 struct device *clsdev;
42682 int minor;
42683 int id;
42684 diff --git a/drivers/media/dvb-frontends/dib3000.h b/drivers/media/dvb-frontends/dib3000.h
42685 index 9b6c3bb..baeb5c7 100644
42686 --- a/drivers/media/dvb-frontends/dib3000.h
42687 +++ b/drivers/media/dvb-frontends/dib3000.h
42688 @@ -39,7 +39,7 @@ struct dib_fe_xfer_ops
42689 int (*fifo_ctrl)(struct dvb_frontend *fe, int onoff);
42690 int (*pid_ctrl)(struct dvb_frontend *fe, int index, int pid, int onoff);
42691 int (*tuner_pass_ctrl)(struct dvb_frontend *fe, int onoff, u8 pll_ctrl);
42692 -};
42693 +} __no_const;
42694
42695 #if IS_ENABLED(CONFIG_DVB_DIB3000MB)
42696 extern struct dvb_frontend* dib3000mb_attach(const struct dib3000_config* config,
42697 diff --git a/drivers/media/pci/cx88/cx88-video.c b/drivers/media/pci/cx88/cx88-video.c
42698 index ecf21d9..b992428d 100644
42699 --- a/drivers/media/pci/cx88/cx88-video.c
42700 +++ b/drivers/media/pci/cx88/cx88-video.c
42701 @@ -50,9 +50,9 @@ MODULE_VERSION(CX88_VERSION);
42702
42703 /* ------------------------------------------------------------------ */
42704
42705 -static unsigned int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42706 -static unsigned int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42707 -static unsigned int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42708 +static int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42709 +static int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42710 +static int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42711
42712 module_param_array(video_nr, int, NULL, 0444);
42713 module_param_array(vbi_nr, int, NULL, 0444);
42714 diff --git a/drivers/media/pci/ivtv/ivtv-driver.c b/drivers/media/pci/ivtv/ivtv-driver.c
42715 index c08ae3e..eb59af1 100644
42716 --- a/drivers/media/pci/ivtv/ivtv-driver.c
42717 +++ b/drivers/media/pci/ivtv/ivtv-driver.c
42718 @@ -83,7 +83,7 @@ static struct pci_device_id ivtv_pci_tbl[] = {
42719 MODULE_DEVICE_TABLE(pci,ivtv_pci_tbl);
42720
42721 /* ivtv instance counter */
42722 -static atomic_t ivtv_instance = ATOMIC_INIT(0);
42723 +static atomic_unchecked_t ivtv_instance = ATOMIC_INIT(0);
42724
42725 /* Parameter declarations */
42726 static int cardtype[IVTV_MAX_CARDS];
42727 diff --git a/drivers/media/platform/omap/omap_vout.c b/drivers/media/platform/omap/omap_vout.c
42728 index dfd0a21..6bbb465 100644
42729 --- a/drivers/media/platform/omap/omap_vout.c
42730 +++ b/drivers/media/platform/omap/omap_vout.c
42731 @@ -63,7 +63,6 @@ enum omap_vout_channels {
42732 OMAP_VIDEO2,
42733 };
42734
42735 -static struct videobuf_queue_ops video_vbq_ops;
42736 /* Variables configurable through module params*/
42737 static u32 video1_numbuffers = 3;
42738 static u32 video2_numbuffers = 3;
42739 @@ -1014,6 +1013,12 @@ static int omap_vout_open(struct file *file)
42740 {
42741 struct videobuf_queue *q;
42742 struct omap_vout_device *vout = NULL;
42743 + static struct videobuf_queue_ops video_vbq_ops = {
42744 + .buf_setup = omap_vout_buffer_setup,
42745 + .buf_prepare = omap_vout_buffer_prepare,
42746 + .buf_release = omap_vout_buffer_release,
42747 + .buf_queue = omap_vout_buffer_queue,
42748 + };
42749
42750 vout = video_drvdata(file);
42751 v4l2_dbg(1, debug, &vout->vid_dev->v4l2_dev, "Entering %s\n", __func__);
42752 @@ -1031,10 +1036,6 @@ static int omap_vout_open(struct file *file)
42753 vout->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
42754
42755 q = &vout->vbq;
42756 - video_vbq_ops.buf_setup = omap_vout_buffer_setup;
42757 - video_vbq_ops.buf_prepare = omap_vout_buffer_prepare;
42758 - video_vbq_ops.buf_release = omap_vout_buffer_release;
42759 - video_vbq_ops.buf_queue = omap_vout_buffer_queue;
42760 spin_lock_init(&vout->vbq_lock);
42761
42762 videobuf_queue_dma_contig_init(q, &video_vbq_ops, q->dev,
42763 diff --git a/drivers/media/platform/s5p-tv/mixer.h b/drivers/media/platform/s5p-tv/mixer.h
42764 index 04e6490..2df65bf 100644
42765 --- a/drivers/media/platform/s5p-tv/mixer.h
42766 +++ b/drivers/media/platform/s5p-tv/mixer.h
42767 @@ -156,7 +156,7 @@ struct mxr_layer {
42768 /** layer index (unique identifier) */
42769 int idx;
42770 /** callbacks for layer methods */
42771 - struct mxr_layer_ops ops;
42772 + struct mxr_layer_ops *ops;
42773 /** format array */
42774 const struct mxr_format **fmt_array;
42775 /** size of format array */
42776 diff --git a/drivers/media/platform/s5p-tv/mixer_grp_layer.c b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
42777 index b93a21f..2535195 100644
42778 --- a/drivers/media/platform/s5p-tv/mixer_grp_layer.c
42779 +++ b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
42780 @@ -235,7 +235,7 @@ struct mxr_layer *mxr_graph_layer_create(struct mxr_device *mdev, int idx)
42781 {
42782 struct mxr_layer *layer;
42783 int ret;
42784 - struct mxr_layer_ops ops = {
42785 + static struct mxr_layer_ops ops = {
42786 .release = mxr_graph_layer_release,
42787 .buffer_set = mxr_graph_buffer_set,
42788 .stream_set = mxr_graph_stream_set,
42789 diff --git a/drivers/media/platform/s5p-tv/mixer_reg.c b/drivers/media/platform/s5p-tv/mixer_reg.c
42790 index b713403..53cb5ad 100644
42791 --- a/drivers/media/platform/s5p-tv/mixer_reg.c
42792 +++ b/drivers/media/platform/s5p-tv/mixer_reg.c
42793 @@ -276,7 +276,7 @@ static void mxr_irq_layer_handle(struct mxr_layer *layer)
42794 layer->update_buf = next;
42795 }
42796
42797 - layer->ops.buffer_set(layer, layer->update_buf);
42798 + layer->ops->buffer_set(layer, layer->update_buf);
42799
42800 if (done && done != layer->shadow_buf)
42801 vb2_buffer_done(&done->vb, VB2_BUF_STATE_DONE);
42802 diff --git a/drivers/media/platform/s5p-tv/mixer_video.c b/drivers/media/platform/s5p-tv/mixer_video.c
42803 index 641b1f0..49cff30 100644
42804 --- a/drivers/media/platform/s5p-tv/mixer_video.c
42805 +++ b/drivers/media/platform/s5p-tv/mixer_video.c
42806 @@ -210,7 +210,7 @@ static void mxr_layer_default_geo(struct mxr_layer *layer)
42807 layer->geo.src.height = layer->geo.src.full_height;
42808
42809 mxr_geometry_dump(mdev, &layer->geo);
42810 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
42811 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
42812 mxr_geometry_dump(mdev, &layer->geo);
42813 }
42814
42815 @@ -228,7 +228,7 @@ static void mxr_layer_update_output(struct mxr_layer *layer)
42816 layer->geo.dst.full_width = mbus_fmt.width;
42817 layer->geo.dst.full_height = mbus_fmt.height;
42818 layer->geo.dst.field = mbus_fmt.field;
42819 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
42820 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
42821
42822 mxr_geometry_dump(mdev, &layer->geo);
42823 }
42824 @@ -334,7 +334,7 @@ static int mxr_s_fmt(struct file *file, void *priv,
42825 /* set source size to highest accepted value */
42826 geo->src.full_width = max(geo->dst.full_width, pix->width);
42827 geo->src.full_height = max(geo->dst.full_height, pix->height);
42828 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
42829 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
42830 mxr_geometry_dump(mdev, &layer->geo);
42831 /* set cropping to total visible screen */
42832 geo->src.width = pix->width;
42833 @@ -342,12 +342,12 @@ static int mxr_s_fmt(struct file *file, void *priv,
42834 geo->src.x_offset = 0;
42835 geo->src.y_offset = 0;
42836 /* assure consistency of geometry */
42837 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
42838 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
42839 mxr_geometry_dump(mdev, &layer->geo);
42840 /* set full size to lowest possible value */
42841 geo->src.full_width = 0;
42842 geo->src.full_height = 0;
42843 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
42844 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
42845 mxr_geometry_dump(mdev, &layer->geo);
42846
42847 /* returning results */
42848 @@ -474,7 +474,7 @@ static int mxr_s_selection(struct file *file, void *fh,
42849 target->width = s->r.width;
42850 target->height = s->r.height;
42851
42852 - layer->ops.fix_geometry(layer, stage, s->flags);
42853 + layer->ops->fix_geometry(layer, stage, s->flags);
42854
42855 /* retrieve update selection rectangle */
42856 res.left = target->x_offset;
42857 @@ -955,13 +955,13 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count)
42858 mxr_output_get(mdev);
42859
42860 mxr_layer_update_output(layer);
42861 - layer->ops.format_set(layer);
42862 + layer->ops->format_set(layer);
42863 /* enabling layer in hardware */
42864 spin_lock_irqsave(&layer->enq_slock, flags);
42865 layer->state = MXR_LAYER_STREAMING;
42866 spin_unlock_irqrestore(&layer->enq_slock, flags);
42867
42868 - layer->ops.stream_set(layer, MXR_ENABLE);
42869 + layer->ops->stream_set(layer, MXR_ENABLE);
42870 mxr_streamer_get(mdev);
42871
42872 return 0;
42873 @@ -1031,7 +1031,7 @@ static int stop_streaming(struct vb2_queue *vq)
42874 spin_unlock_irqrestore(&layer->enq_slock, flags);
42875
42876 /* disabling layer in hardware */
42877 - layer->ops.stream_set(layer, MXR_DISABLE);
42878 + layer->ops->stream_set(layer, MXR_DISABLE);
42879 /* remove one streamer */
42880 mxr_streamer_put(mdev);
42881 /* allow changes in output configuration */
42882 @@ -1070,8 +1070,8 @@ void mxr_base_layer_unregister(struct mxr_layer *layer)
42883
42884 void mxr_layer_release(struct mxr_layer *layer)
42885 {
42886 - if (layer->ops.release)
42887 - layer->ops.release(layer);
42888 + if (layer->ops->release)
42889 + layer->ops->release(layer);
42890 }
42891
42892 void mxr_base_layer_release(struct mxr_layer *layer)
42893 @@ -1097,7 +1097,7 @@ struct mxr_layer *mxr_base_layer_create(struct mxr_device *mdev,
42894
42895 layer->mdev = mdev;
42896 layer->idx = idx;
42897 - layer->ops = *ops;
42898 + layer->ops = ops;
42899
42900 spin_lock_init(&layer->enq_slock);
42901 INIT_LIST_HEAD(&layer->enq_list);
42902 diff --git a/drivers/media/platform/s5p-tv/mixer_vp_layer.c b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
42903 index 3d13a63..da31bf1 100644
42904 --- a/drivers/media/platform/s5p-tv/mixer_vp_layer.c
42905 +++ b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
42906 @@ -206,7 +206,7 @@ struct mxr_layer *mxr_vp_layer_create(struct mxr_device *mdev, int idx)
42907 {
42908 struct mxr_layer *layer;
42909 int ret;
42910 - struct mxr_layer_ops ops = {
42911 + static struct mxr_layer_ops ops = {
42912 .release = mxr_vp_layer_release,
42913 .buffer_set = mxr_vp_buffer_set,
42914 .stream_set = mxr_vp_stream_set,
42915 diff --git a/drivers/media/radio/radio-cadet.c b/drivers/media/radio/radio-cadet.c
42916 index 545c04c..a14bded 100644
42917 --- a/drivers/media/radio/radio-cadet.c
42918 +++ b/drivers/media/radio/radio-cadet.c
42919 @@ -324,6 +324,8 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
42920 unsigned char readbuf[RDS_BUFFER];
42921 int i = 0;
42922
42923 + if (count > RDS_BUFFER)
42924 + return -EFAULT;
42925 mutex_lock(&dev->lock);
42926 if (dev->rdsstat == 0)
42927 cadet_start_rds(dev);
42928 @@ -339,7 +341,7 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
42929 while (i < count && dev->rdsin != dev->rdsout)
42930 readbuf[i++] = dev->rdsbuf[dev->rdsout++];
42931
42932 - if (i && copy_to_user(data, readbuf, i))
42933 + if (i > sizeof(readbuf) || copy_to_user(data, readbuf, i))
42934 i = -EFAULT;
42935 unlock:
42936 mutex_unlock(&dev->lock);
42937 diff --git a/drivers/media/radio/radio-maxiradio.c b/drivers/media/radio/radio-maxiradio.c
42938 index 5236035..c622c74 100644
42939 --- a/drivers/media/radio/radio-maxiradio.c
42940 +++ b/drivers/media/radio/radio-maxiradio.c
42941 @@ -61,7 +61,7 @@ MODULE_PARM_DESC(radio_nr, "Radio device number");
42942 /* TEA5757 pin mappings */
42943 static const int clk = 1, data = 2, wren = 4, mo_st = 8, power = 16;
42944
42945 -static atomic_t maxiradio_instance = ATOMIC_INIT(0);
42946 +static atomic_unchecked_t maxiradio_instance = ATOMIC_INIT(0);
42947
42948 #define PCI_VENDOR_ID_GUILLEMOT 0x5046
42949 #define PCI_DEVICE_ID_GUILLEMOT_MAXIRADIO 0x1001
42950 diff --git a/drivers/media/radio/radio-shark.c b/drivers/media/radio/radio-shark.c
42951 index b914772..7ddbf9b 100644
42952 --- a/drivers/media/radio/radio-shark.c
42953 +++ b/drivers/media/radio/radio-shark.c
42954 @@ -79,7 +79,7 @@ struct shark_device {
42955 u32 last_val;
42956 };
42957
42958 -static atomic_t shark_instance = ATOMIC_INIT(0);
42959 +static atomic_unchecked_t shark_instance = ATOMIC_INIT(0);
42960
42961 static void shark_write_val(struct snd_tea575x *tea, u32 val)
42962 {
42963 diff --git a/drivers/media/radio/radio-shark2.c b/drivers/media/radio/radio-shark2.c
42964 index 9fb6697..f167415 100644
42965 --- a/drivers/media/radio/radio-shark2.c
42966 +++ b/drivers/media/radio/radio-shark2.c
42967 @@ -74,7 +74,7 @@ struct shark_device {
42968 u8 *transfer_buffer;
42969 };
42970
42971 -static atomic_t shark_instance = ATOMIC_INIT(0);
42972 +static atomic_unchecked_t shark_instance = ATOMIC_INIT(0);
42973
42974 static int shark_write_reg(struct radio_tea5777 *tea, u64 reg)
42975 {
42976 diff --git a/drivers/media/radio/radio-si476x.c b/drivers/media/radio/radio-si476x.c
42977 index 9c9084c..a9e8dfb 100644
42978 --- a/drivers/media/radio/radio-si476x.c
42979 +++ b/drivers/media/radio/radio-si476x.c
42980 @@ -1445,7 +1445,7 @@ static int si476x_radio_probe(struct platform_device *pdev)
42981 struct si476x_radio *radio;
42982 struct v4l2_ctrl *ctrl;
42983
42984 - static atomic_t instance = ATOMIC_INIT(0);
42985 + static atomic_unchecked_t instance = ATOMIC_INIT(0);
42986
42987 radio = devm_kzalloc(&pdev->dev, sizeof(*radio), GFP_KERNEL);
42988 if (!radio)
42989 diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
42990 index 46da365..3ba4206 100644
42991 --- a/drivers/media/rc/rc-main.c
42992 +++ b/drivers/media/rc/rc-main.c
42993 @@ -1065,7 +1065,7 @@ EXPORT_SYMBOL_GPL(rc_free_device);
42994 int rc_register_device(struct rc_dev *dev)
42995 {
42996 static bool raw_init = false; /* raw decoders loaded? */
42997 - static atomic_t devno = ATOMIC_INIT(0);
42998 + static atomic_unchecked_t devno = ATOMIC_INIT(0);
42999 struct rc_map *rc_map;
43000 const char *path;
43001 int rc;
43002 @@ -1096,7 +1096,7 @@ int rc_register_device(struct rc_dev *dev)
43003 */
43004 mutex_lock(&dev->lock);
43005
43006 - dev->devno = (unsigned long)(atomic_inc_return(&devno) - 1);
43007 + dev->devno = (unsigned long)(atomic_inc_return_unchecked(&devno) - 1);
43008 dev_set_name(&dev->dev, "rc%ld", dev->devno);
43009 dev_set_drvdata(&dev->dev, dev);
43010 rc = device_add(&dev->dev);
43011 diff --git a/drivers/media/usb/dvb-usb/cxusb.c b/drivers/media/usb/dvb-usb/cxusb.c
43012 index 20e345d..da56fe4 100644
43013 --- a/drivers/media/usb/dvb-usb/cxusb.c
43014 +++ b/drivers/media/usb/dvb-usb/cxusb.c
43015 @@ -1101,7 +1101,7 @@ static struct dib0070_config dib7070p_dib0070_config = {
43016
43017 struct dib0700_adapter_state {
43018 int (*set_param_save) (struct dvb_frontend *);
43019 -};
43020 +} __no_const;
43021
43022 static int dib7070_set_param_override(struct dvb_frontend *fe)
43023 {
43024 diff --git a/drivers/media/usb/dvb-usb/dw2102.c b/drivers/media/usb/dvb-usb/dw2102.c
43025 index 71b22f5..a63b33f 100644
43026 --- a/drivers/media/usb/dvb-usb/dw2102.c
43027 +++ b/drivers/media/usb/dvb-usb/dw2102.c
43028 @@ -121,7 +121,7 @@ struct su3000_state {
43029
43030 struct s6x0_state {
43031 int (*old_set_voltage)(struct dvb_frontend *f, fe_sec_voltage_t v);
43032 -};
43033 +} __no_const;
43034
43035 /* debug */
43036 static int dvb_usb_dw2102_debug;
43037 diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
43038 index 8f7a6a4..59502dd 100644
43039 --- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
43040 +++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
43041 @@ -326,7 +326,7 @@ struct v4l2_buffer32 {
43042 __u32 reserved;
43043 };
43044
43045 -static int get_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
43046 +static int get_v4l2_plane32(struct v4l2_plane __user *up, struct v4l2_plane32 __user *up32,
43047 enum v4l2_memory memory)
43048 {
43049 void __user *up_pln;
43050 @@ -355,7 +355,7 @@ static int get_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
43051 return 0;
43052 }
43053
43054 -static int put_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
43055 +static int put_v4l2_plane32(struct v4l2_plane __user *up, struct v4l2_plane32 __user *up32,
43056 enum v4l2_memory memory)
43057 {
43058 if (copy_in_user(up32, up, 2 * sizeof(__u32)) ||
43059 @@ -772,7 +772,7 @@ static int put_v4l2_subdev_edid32(struct v4l2_subdev_edid *kp, struct v4l2_subde
43060 put_user(kp->start_block, &up->start_block) ||
43061 put_user(kp->blocks, &up->blocks) ||
43062 put_user(tmp, &up->edid) ||
43063 - copy_to_user(kp->reserved, up->reserved, sizeof(kp->reserved)))
43064 + copy_to_user(up->reserved, kp->reserved, sizeof(kp->reserved)))
43065 return -EFAULT;
43066 return 0;
43067 }
43068 diff --git a/drivers/media/v4l2-core/v4l2-device.c b/drivers/media/v4l2-core/v4l2-device.c
43069 index 02d1b63..5fd6b16 100644
43070 --- a/drivers/media/v4l2-core/v4l2-device.c
43071 +++ b/drivers/media/v4l2-core/v4l2-device.c
43072 @@ -75,9 +75,9 @@ int v4l2_device_put(struct v4l2_device *v4l2_dev)
43073 EXPORT_SYMBOL_GPL(v4l2_device_put);
43074
43075 int v4l2_device_set_name(struct v4l2_device *v4l2_dev, const char *basename,
43076 - atomic_t *instance)
43077 + atomic_unchecked_t *instance)
43078 {
43079 - int num = atomic_inc_return(instance) - 1;
43080 + int num = atomic_inc_return_unchecked(instance) - 1;
43081 int len = strlen(basename);
43082
43083 if (basename[len - 1] >= '0' && basename[len - 1] <= '9')
43084 diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
43085 index 68e6b5e..d8b923e 100644
43086 --- a/drivers/media/v4l2-core/v4l2-ioctl.c
43087 +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
43088 @@ -1939,7 +1939,8 @@ struct v4l2_ioctl_info {
43089 struct file *file, void *fh, void *p);
43090 } u;
43091 void (*debug)(const void *arg, bool write_only);
43092 -};
43093 +} __do_const;
43094 +typedef struct v4l2_ioctl_info __no_const v4l2_ioctl_info_no_const;
43095
43096 /* This control needs a priority check */
43097 #define INFO_FL_PRIO (1 << 0)
43098 @@ -2120,7 +2121,7 @@ static long __video_do_ioctl(struct file *file,
43099 struct video_device *vfd = video_devdata(file);
43100 const struct v4l2_ioctl_ops *ops = vfd->ioctl_ops;
43101 bool write_only = false;
43102 - struct v4l2_ioctl_info default_info;
43103 + v4l2_ioctl_info_no_const default_info;
43104 const struct v4l2_ioctl_info *info;
43105 void *fh = file->private_data;
43106 struct v4l2_fh *vfh = NULL;
43107 @@ -2194,7 +2195,7 @@ done:
43108 }
43109
43110 static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
43111 - void * __user *user_ptr, void ***kernel_ptr)
43112 + void __user **user_ptr, void ***kernel_ptr)
43113 {
43114 int ret = 0;
43115
43116 @@ -2210,7 +2211,7 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
43117 ret = -EINVAL;
43118 break;
43119 }
43120 - *user_ptr = (void __user *)buf->m.planes;
43121 + *user_ptr = (void __force_user *)buf->m.planes;
43122 *kernel_ptr = (void *)&buf->m.planes;
43123 *array_size = sizeof(struct v4l2_plane) * buf->length;
43124 ret = 1;
43125 @@ -2245,7 +2246,7 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
43126 ret = -EINVAL;
43127 break;
43128 }
43129 - *user_ptr = (void __user *)ctrls->controls;
43130 + *user_ptr = (void __force_user *)ctrls->controls;
43131 *kernel_ptr = (void *)&ctrls->controls;
43132 *array_size = sizeof(struct v4l2_ext_control)
43133 * ctrls->count;
43134 diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
43135 index 767ff4d..c69d259 100644
43136 --- a/drivers/message/fusion/mptbase.c
43137 +++ b/drivers/message/fusion/mptbase.c
43138 @@ -6755,8 +6755,13 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
43139 seq_printf(m, " MaxChainDepth = 0x%02x frames\n", ioc->facts.MaxChainDepth);
43140 seq_printf(m, " MinBlockSize = 0x%02x bytes\n", 4*ioc->facts.BlockSize);
43141
43142 +#ifdef CONFIG_GRKERNSEC_HIDESYM
43143 + seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n", NULL, NULL);
43144 +#else
43145 seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n",
43146 (void *)ioc->req_frames, (void *)(ulong)ioc->req_frames_dma);
43147 +#endif
43148 +
43149 /*
43150 * Rounding UP to nearest 4-kB boundary here...
43151 */
43152 @@ -6769,7 +6774,11 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
43153 ioc->facts.GlobalCredits);
43154
43155 seq_printf(m, " Frames @ 0x%p (Dma @ 0x%p)\n",
43156 +#ifdef CONFIG_GRKERNSEC_HIDESYM
43157 + NULL, NULL);
43158 +#else
43159 (void *)ioc->alloc, (void *)(ulong)ioc->alloc_dma);
43160 +#endif
43161 sz = (ioc->reply_sz * ioc->reply_depth) + 128;
43162 seq_printf(m, " {CurRepSz=%d} x {CurRepDepth=%d} = %d bytes ^= 0x%x\n",
43163 ioc->reply_sz, ioc->reply_depth, ioc->reply_sz*ioc->reply_depth, sz);
43164 diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
43165 index dd239bd..689c4f7 100644
43166 --- a/drivers/message/fusion/mptsas.c
43167 +++ b/drivers/message/fusion/mptsas.c
43168 @@ -446,6 +446,23 @@ mptsas_is_end_device(struct mptsas_devinfo * attached)
43169 return 0;
43170 }
43171
43172 +static inline void
43173 +mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
43174 +{
43175 + if (phy_info->port_details) {
43176 + phy_info->port_details->rphy = rphy;
43177 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
43178 + ioc->name, rphy));
43179 + }
43180 +
43181 + if (rphy) {
43182 + dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
43183 + &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
43184 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
43185 + ioc->name, rphy, rphy->dev.release));
43186 + }
43187 +}
43188 +
43189 /* no mutex */
43190 static void
43191 mptsas_port_delete(MPT_ADAPTER *ioc, struct mptsas_portinfo_details * port_details)
43192 @@ -484,23 +501,6 @@ mptsas_get_rphy(struct mptsas_phyinfo *phy_info)
43193 return NULL;
43194 }
43195
43196 -static inline void
43197 -mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
43198 -{
43199 - if (phy_info->port_details) {
43200 - phy_info->port_details->rphy = rphy;
43201 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
43202 - ioc->name, rphy));
43203 - }
43204 -
43205 - if (rphy) {
43206 - dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
43207 - &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
43208 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
43209 - ioc->name, rphy, rphy->dev.release));
43210 - }
43211 -}
43212 -
43213 static inline struct sas_port *
43214 mptsas_get_port(struct mptsas_phyinfo *phy_info)
43215 {
43216 diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
43217 index 727819c..ad74694 100644
43218 --- a/drivers/message/fusion/mptscsih.c
43219 +++ b/drivers/message/fusion/mptscsih.c
43220 @@ -1271,15 +1271,16 @@ mptscsih_info(struct Scsi_Host *SChost)
43221
43222 h = shost_priv(SChost);
43223
43224 - if (h) {
43225 - if (h->info_kbuf == NULL)
43226 - if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
43227 - return h->info_kbuf;
43228 - h->info_kbuf[0] = '\0';
43229 + if (!h)
43230 + return NULL;
43231
43232 - mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
43233 - h->info_kbuf[size-1] = '\0';
43234 - }
43235 + if (h->info_kbuf == NULL)
43236 + if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
43237 + return h->info_kbuf;
43238 + h->info_kbuf[0] = '\0';
43239 +
43240 + mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
43241 + h->info_kbuf[size-1] = '\0';
43242
43243 return h->info_kbuf;
43244 }
43245 diff --git a/drivers/message/i2o/i2o_proc.c b/drivers/message/i2o/i2o_proc.c
43246 index b7d87cd..3fb36da 100644
43247 --- a/drivers/message/i2o/i2o_proc.c
43248 +++ b/drivers/message/i2o/i2o_proc.c
43249 @@ -255,12 +255,6 @@ static char *scsi_devices[] = {
43250 "Array Controller Device"
43251 };
43252
43253 -static char *chtostr(char *tmp, u8 *chars, int n)
43254 -{
43255 - tmp[0] = 0;
43256 - return strncat(tmp, (char *)chars, n);
43257 -}
43258 -
43259 static int i2o_report_query_status(struct seq_file *seq, int block_status,
43260 char *group)
43261 {
43262 @@ -707,9 +701,9 @@ static int i2o_seq_show_status(struct seq_file *seq, void *v)
43263 static int i2o_seq_show_hw(struct seq_file *seq, void *v)
43264 {
43265 struct i2o_controller *c = (struct i2o_controller *)seq->private;
43266 - static u32 work32[5];
43267 - static u8 *work8 = (u8 *) work32;
43268 - static u16 *work16 = (u16 *) work32;
43269 + u32 work32[5];
43270 + u8 *work8 = (u8 *) work32;
43271 + u16 *work16 = (u16 *) work32;
43272 int token;
43273 u32 hwcap;
43274
43275 @@ -790,7 +784,6 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
43276 } *result;
43277
43278 i2o_exec_execute_ddm_table ddm_table;
43279 - char tmp[28 + 1];
43280
43281 result = kmalloc(sizeof(*result), GFP_KERNEL);
43282 if (!result)
43283 @@ -825,8 +818,7 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
43284
43285 seq_printf(seq, "%-#7x", ddm_table.i2o_vendor_id);
43286 seq_printf(seq, "%-#8x", ddm_table.module_id);
43287 - seq_printf(seq, "%-29s",
43288 - chtostr(tmp, ddm_table.module_name_version, 28));
43289 + seq_printf(seq, "%-.28s", ddm_table.module_name_version);
43290 seq_printf(seq, "%9d ", ddm_table.data_size);
43291 seq_printf(seq, "%8d", ddm_table.code_size);
43292
43293 @@ -893,7 +885,6 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
43294
43295 i2o_driver_result_table *result;
43296 i2o_driver_store_table *dst;
43297 - char tmp[28 + 1];
43298
43299 result = kmalloc(sizeof(i2o_driver_result_table), GFP_KERNEL);
43300 if (result == NULL)
43301 @@ -928,9 +919,8 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
43302
43303 seq_printf(seq, "%-#7x", dst->i2o_vendor_id);
43304 seq_printf(seq, "%-#8x", dst->module_id);
43305 - seq_printf(seq, "%-29s",
43306 - chtostr(tmp, dst->module_name_version, 28));
43307 - seq_printf(seq, "%-9s", chtostr(tmp, dst->date, 8));
43308 + seq_printf(seq, "%-.28s", dst->module_name_version);
43309 + seq_printf(seq, "%-.8s", dst->date);
43310 seq_printf(seq, "%8d ", dst->module_size);
43311 seq_printf(seq, "%8d ", dst->mpb_size);
43312 seq_printf(seq, "0x%04x", dst->module_flags);
43313 @@ -1246,11 +1236,10 @@ static int i2o_seq_show_authorized_users(struct seq_file *seq, void *v)
43314 static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
43315 {
43316 struct i2o_device *d = (struct i2o_device *)seq->private;
43317 - static u32 work32[128]; // allow for "stuff" + up to 256 byte (max) serial number
43318 + u32 work32[128]; // allow for "stuff" + up to 256 byte (max) serial number
43319 // == (allow) 512d bytes (max)
43320 - static u16 *work16 = (u16 *) work32;
43321 + u16 *work16 = (u16 *) work32;
43322 int token;
43323 - char tmp[16 + 1];
43324
43325 token = i2o_parm_field_get(d, 0xF100, -1, &work32, sizeof(work32));
43326
43327 @@ -1262,14 +1251,10 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
43328 seq_printf(seq, "Device Class : %s\n", i2o_get_class_name(work16[0]));
43329 seq_printf(seq, "Owner TID : %0#5x\n", work16[2]);
43330 seq_printf(seq, "Parent TID : %0#5x\n", work16[3]);
43331 - seq_printf(seq, "Vendor info : %s\n",
43332 - chtostr(tmp, (u8 *) (work32 + 2), 16));
43333 - seq_printf(seq, "Product info : %s\n",
43334 - chtostr(tmp, (u8 *) (work32 + 6), 16));
43335 - seq_printf(seq, "Description : %s\n",
43336 - chtostr(tmp, (u8 *) (work32 + 10), 16));
43337 - seq_printf(seq, "Product rev. : %s\n",
43338 - chtostr(tmp, (u8 *) (work32 + 14), 8));
43339 + seq_printf(seq, "Vendor info : %.16s\n", (u8 *) (work32 + 2));
43340 + seq_printf(seq, "Product info : %.16s\n", (u8 *) (work32 + 6));
43341 + seq_printf(seq, "Description : %.16s\n", (u8 *) (work32 + 10));
43342 + seq_printf(seq, "Product rev. : %.8s\n", (u8 *) (work32 + 14));
43343
43344 seq_printf(seq, "Serial number : ");
43345 print_serial_number(seq, (u8 *) (work32 + 16),
43346 @@ -1306,8 +1291,6 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
43347 u8 pad[256]; // allow up to 256 byte (max) serial number
43348 } result;
43349
43350 - char tmp[24 + 1];
43351 -
43352 token = i2o_parm_field_get(d, 0xF101, -1, &result, sizeof(result));
43353
43354 if (token < 0) {
43355 @@ -1316,10 +1299,8 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
43356 }
43357
43358 seq_printf(seq, "Registering DDM TID : 0x%03x\n", result.ddm_tid);
43359 - seq_printf(seq, "Module name : %s\n",
43360 - chtostr(tmp, result.module_name, 24));
43361 - seq_printf(seq, "Module revision : %s\n",
43362 - chtostr(tmp, result.module_rev, 8));
43363 + seq_printf(seq, "Module name : %.24s\n", result.module_name);
43364 + seq_printf(seq, "Module revision : %.8s\n", result.module_rev);
43365
43366 seq_printf(seq, "Serial number : ");
43367 print_serial_number(seq, result.serial_number, sizeof(result) - 36);
43368 @@ -1343,8 +1324,6 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
43369 u8 instance_number[4];
43370 } result;
43371
43372 - char tmp[64 + 1];
43373 -
43374 token = i2o_parm_field_get(d, 0xF102, -1, &result, sizeof(result));
43375
43376 if (token < 0) {
43377 @@ -1352,14 +1331,10 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
43378 return 0;
43379 }
43380
43381 - seq_printf(seq, "Device name : %s\n",
43382 - chtostr(tmp, result.device_name, 64));
43383 - seq_printf(seq, "Service name : %s\n",
43384 - chtostr(tmp, result.service_name, 64));
43385 - seq_printf(seq, "Physical name : %s\n",
43386 - chtostr(tmp, result.physical_location, 64));
43387 - seq_printf(seq, "Instance number : %s\n",
43388 - chtostr(tmp, result.instance_number, 4));
43389 + seq_printf(seq, "Device name : %.64s\n", result.device_name);
43390 + seq_printf(seq, "Service name : %.64s\n", result.service_name);
43391 + seq_printf(seq, "Physical name : %.64s\n", result.physical_location);
43392 + seq_printf(seq, "Instance number : %.4s\n", result.instance_number);
43393
43394 return 0;
43395 }
43396 @@ -1368,9 +1343,9 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
43397 static int i2o_seq_show_sgl_limits(struct seq_file *seq, void *v)
43398 {
43399 struct i2o_device *d = (struct i2o_device *)seq->private;
43400 - static u32 work32[12];
43401 - static u16 *work16 = (u16 *) work32;
43402 - static u8 *work8 = (u8 *) work32;
43403 + u32 work32[12];
43404 + u16 *work16 = (u16 *) work32;
43405 + u8 *work8 = (u8 *) work32;
43406 int token;
43407
43408 token = i2o_parm_field_get(d, 0xF103, -1, &work32, sizeof(work32));
43409 diff --git a/drivers/message/i2o/iop.c b/drivers/message/i2o/iop.c
43410 index a8c08f3..155fe3d 100644
43411 --- a/drivers/message/i2o/iop.c
43412 +++ b/drivers/message/i2o/iop.c
43413 @@ -111,10 +111,10 @@ u32 i2o_cntxt_list_add(struct i2o_controller * c, void *ptr)
43414
43415 spin_lock_irqsave(&c->context_list_lock, flags);
43416
43417 - if (unlikely(atomic_inc_and_test(&c->context_list_counter)))
43418 - atomic_inc(&c->context_list_counter);
43419 + if (unlikely(atomic_inc_and_test_unchecked(&c->context_list_counter)))
43420 + atomic_inc_unchecked(&c->context_list_counter);
43421
43422 - entry->context = atomic_read(&c->context_list_counter);
43423 + entry->context = atomic_read_unchecked(&c->context_list_counter);
43424
43425 list_add(&entry->list, &c->context_list);
43426
43427 @@ -1077,7 +1077,7 @@ struct i2o_controller *i2o_iop_alloc(void)
43428
43429 #if BITS_PER_LONG == 64
43430 spin_lock_init(&c->context_list_lock);
43431 - atomic_set(&c->context_list_counter, 0);
43432 + atomic_set_unchecked(&c->context_list_counter, 0);
43433 INIT_LIST_HEAD(&c->context_list);
43434 #endif
43435
43436 diff --git a/drivers/mfd/janz-cmodio.c b/drivers/mfd/janz-cmodio.c
43437 index fcbb2e9..2635e11 100644
43438 --- a/drivers/mfd/janz-cmodio.c
43439 +++ b/drivers/mfd/janz-cmodio.c
43440 @@ -13,6 +13,7 @@
43441
43442 #include <linux/kernel.h>
43443 #include <linux/module.h>
43444 +#include <linux/slab.h>
43445 #include <linux/init.h>
43446 #include <linux/pci.h>
43447 #include <linux/interrupt.h>
43448 diff --git a/drivers/mfd/max8925-i2c.c b/drivers/mfd/max8925-i2c.c
43449 index de7fb80..7c1b931 100644
43450 --- a/drivers/mfd/max8925-i2c.c
43451 +++ b/drivers/mfd/max8925-i2c.c
43452 @@ -152,7 +152,7 @@ static int max8925_probe(struct i2c_client *client,
43453 const struct i2c_device_id *id)
43454 {
43455 struct max8925_platform_data *pdata = dev_get_platdata(&client->dev);
43456 - static struct max8925_chip *chip;
43457 + struct max8925_chip *chip;
43458 struct device_node *node = client->dev.of_node;
43459
43460 if (node && !pdata) {
43461 diff --git a/drivers/mfd/tps65910.c b/drivers/mfd/tps65910.c
43462 index d792772..cd73ba3 100644
43463 --- a/drivers/mfd/tps65910.c
43464 +++ b/drivers/mfd/tps65910.c
43465 @@ -229,7 +229,7 @@ static int tps65910_irq_init(struct tps65910 *tps65910, int irq,
43466 struct tps65910_platform_data *pdata)
43467 {
43468 int ret = 0;
43469 - static struct regmap_irq_chip *tps6591x_irqs_chip;
43470 + struct regmap_irq_chip *tps6591x_irqs_chip;
43471
43472 if (!irq) {
43473 dev_warn(tps65910->dev, "No interrupt support, no core IRQ\n");
43474 diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c
43475 index 9aa6d1e..1631bfc 100644
43476 --- a/drivers/mfd/twl4030-irq.c
43477 +++ b/drivers/mfd/twl4030-irq.c
43478 @@ -35,6 +35,7 @@
43479 #include <linux/of.h>
43480 #include <linux/irqdomain.h>
43481 #include <linux/i2c/twl.h>
43482 +#include <asm/pgtable.h>
43483
43484 #include "twl-core.h"
43485
43486 @@ -726,10 +727,12 @@ int twl4030_init_irq(struct device *dev, int irq_num)
43487 * Install an irq handler for each of the SIH modules;
43488 * clone dummy irq_chip since PIH can't *do* anything
43489 */
43490 - twl4030_irq_chip = dummy_irq_chip;
43491 - twl4030_irq_chip.name = "twl4030";
43492 + pax_open_kernel();
43493 + memcpy((void *)&twl4030_irq_chip, &dummy_irq_chip, sizeof twl4030_irq_chip);
43494 + *(const char **)&twl4030_irq_chip.name = "twl4030";
43495
43496 - twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
43497 + *(void **)&twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
43498 + pax_close_kernel();
43499
43500 for (i = irq_base; i < irq_end; i++) {
43501 irq_set_chip_and_handler(i, &twl4030_irq_chip,
43502 diff --git a/drivers/misc/c2port/core.c b/drivers/misc/c2port/core.c
43503 index 464419b..64bae8d 100644
43504 --- a/drivers/misc/c2port/core.c
43505 +++ b/drivers/misc/c2port/core.c
43506 @@ -922,7 +922,9 @@ struct c2port_device *c2port_device_register(char *name,
43507 goto error_idr_alloc;
43508 c2dev->id = ret;
43509
43510 - bin_attr_flash_data.size = ops->blocks_num * ops->block_size;
43511 + pax_open_kernel();
43512 + *(size_t *)&bin_attr_flash_data.size = ops->blocks_num * ops->block_size;
43513 + pax_close_kernel();
43514
43515 c2dev->dev = device_create(c2port_class, NULL, 0, c2dev,
43516 "c2port%d", c2dev->id);
43517 diff --git a/drivers/misc/kgdbts.c b/drivers/misc/kgdbts.c
43518 index 36f5d52..32311c3 100644
43519 --- a/drivers/misc/kgdbts.c
43520 +++ b/drivers/misc/kgdbts.c
43521 @@ -834,7 +834,7 @@ static void run_plant_and_detach_test(int is_early)
43522 char before[BREAK_INSTR_SIZE];
43523 char after[BREAK_INSTR_SIZE];
43524
43525 - probe_kernel_read(before, (char *)kgdbts_break_test,
43526 + probe_kernel_read(before, ktla_ktva((char *)kgdbts_break_test),
43527 BREAK_INSTR_SIZE);
43528 init_simple_test();
43529 ts.tst = plant_and_detach_test;
43530 @@ -842,7 +842,7 @@ static void run_plant_and_detach_test(int is_early)
43531 /* Activate test with initial breakpoint */
43532 if (!is_early)
43533 kgdb_breakpoint();
43534 - probe_kernel_read(after, (char *)kgdbts_break_test,
43535 + probe_kernel_read(after, ktla_ktva((char *)kgdbts_break_test),
43536 BREAK_INSTR_SIZE);
43537 if (memcmp(before, after, BREAK_INSTR_SIZE)) {
43538 printk(KERN_CRIT "kgdbts: ERROR kgdb corrupted memory\n");
43539 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.c b/drivers/misc/lis3lv02d/lis3lv02d.c
43540 index 036effe..b3a6336 100644
43541 --- a/drivers/misc/lis3lv02d/lis3lv02d.c
43542 +++ b/drivers/misc/lis3lv02d/lis3lv02d.c
43543 @@ -498,7 +498,7 @@ static irqreturn_t lis302dl_interrupt(int irq, void *data)
43544 * the lid is closed. This leads to interrupts as soon as a little move
43545 * is done.
43546 */
43547 - atomic_inc(&lis3->count);
43548 + atomic_inc_unchecked(&lis3->count);
43549
43550 wake_up_interruptible(&lis3->misc_wait);
43551 kill_fasync(&lis3->async_queue, SIGIO, POLL_IN);
43552 @@ -584,7 +584,7 @@ static int lis3lv02d_misc_open(struct inode *inode, struct file *file)
43553 if (lis3->pm_dev)
43554 pm_runtime_get_sync(lis3->pm_dev);
43555
43556 - atomic_set(&lis3->count, 0);
43557 + atomic_set_unchecked(&lis3->count, 0);
43558 return 0;
43559 }
43560
43561 @@ -616,7 +616,7 @@ static ssize_t lis3lv02d_misc_read(struct file *file, char __user *buf,
43562 add_wait_queue(&lis3->misc_wait, &wait);
43563 while (true) {
43564 set_current_state(TASK_INTERRUPTIBLE);
43565 - data = atomic_xchg(&lis3->count, 0);
43566 + data = atomic_xchg_unchecked(&lis3->count, 0);
43567 if (data)
43568 break;
43569
43570 @@ -657,7 +657,7 @@ static unsigned int lis3lv02d_misc_poll(struct file *file, poll_table *wait)
43571 struct lis3lv02d, miscdev);
43572
43573 poll_wait(file, &lis3->misc_wait, wait);
43574 - if (atomic_read(&lis3->count))
43575 + if (atomic_read_unchecked(&lis3->count))
43576 return POLLIN | POLLRDNORM;
43577 return 0;
43578 }
43579 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.h b/drivers/misc/lis3lv02d/lis3lv02d.h
43580 index c439c82..1f20f57 100644
43581 --- a/drivers/misc/lis3lv02d/lis3lv02d.h
43582 +++ b/drivers/misc/lis3lv02d/lis3lv02d.h
43583 @@ -297,7 +297,7 @@ struct lis3lv02d {
43584 struct input_polled_dev *idev; /* input device */
43585 struct platform_device *pdev; /* platform device */
43586 struct regulator_bulk_data regulators[2];
43587 - atomic_t count; /* interrupt count after last read */
43588 + atomic_unchecked_t count; /* interrupt count after last read */
43589 union axis_conversion ac; /* hw -> logical axis */
43590 int mapped_btns[3];
43591
43592 diff --git a/drivers/misc/sgi-gru/gruhandles.c b/drivers/misc/sgi-gru/gruhandles.c
43593 index 2f30bad..c4c13d0 100644
43594 --- a/drivers/misc/sgi-gru/gruhandles.c
43595 +++ b/drivers/misc/sgi-gru/gruhandles.c
43596 @@ -44,8 +44,8 @@ static void update_mcs_stats(enum mcs_op op, unsigned long clks)
43597 unsigned long nsec;
43598
43599 nsec = CLKS2NSEC(clks);
43600 - atomic_long_inc(&mcs_op_statistics[op].count);
43601 - atomic_long_add(nsec, &mcs_op_statistics[op].total);
43602 + atomic_long_inc_unchecked(&mcs_op_statistics[op].count);
43603 + atomic_long_add_unchecked(nsec, &mcs_op_statistics[op].total);
43604 if (mcs_op_statistics[op].max < nsec)
43605 mcs_op_statistics[op].max = nsec;
43606 }
43607 diff --git a/drivers/misc/sgi-gru/gruprocfs.c b/drivers/misc/sgi-gru/gruprocfs.c
43608 index 4f76359..cdfcb2e 100644
43609 --- a/drivers/misc/sgi-gru/gruprocfs.c
43610 +++ b/drivers/misc/sgi-gru/gruprocfs.c
43611 @@ -32,9 +32,9 @@
43612
43613 #define printstat(s, f) printstat_val(s, &gru_stats.f, #f)
43614
43615 -static void printstat_val(struct seq_file *s, atomic_long_t *v, char *id)
43616 +static void printstat_val(struct seq_file *s, atomic_long_unchecked_t *v, char *id)
43617 {
43618 - unsigned long val = atomic_long_read(v);
43619 + unsigned long val = atomic_long_read_unchecked(v);
43620
43621 seq_printf(s, "%16lu %s\n", val, id);
43622 }
43623 @@ -134,8 +134,8 @@ static int mcs_statistics_show(struct seq_file *s, void *p)
43624
43625 seq_printf(s, "%-20s%12s%12s%12s\n", "#id", "count", "aver-clks", "max-clks");
43626 for (op = 0; op < mcsop_last; op++) {
43627 - count = atomic_long_read(&mcs_op_statistics[op].count);
43628 - total = atomic_long_read(&mcs_op_statistics[op].total);
43629 + count = atomic_long_read_unchecked(&mcs_op_statistics[op].count);
43630 + total = atomic_long_read_unchecked(&mcs_op_statistics[op].total);
43631 max = mcs_op_statistics[op].max;
43632 seq_printf(s, "%-20s%12ld%12ld%12ld\n", id[op], count,
43633 count ? total / count : 0, max);
43634 diff --git a/drivers/misc/sgi-gru/grutables.h b/drivers/misc/sgi-gru/grutables.h
43635 index 5c3ce24..4915ccb 100644
43636 --- a/drivers/misc/sgi-gru/grutables.h
43637 +++ b/drivers/misc/sgi-gru/grutables.h
43638 @@ -167,82 +167,82 @@ extern unsigned int gru_max_gids;
43639 * GRU statistics.
43640 */
43641 struct gru_stats_s {
43642 - atomic_long_t vdata_alloc;
43643 - atomic_long_t vdata_free;
43644 - atomic_long_t gts_alloc;
43645 - atomic_long_t gts_free;
43646 - atomic_long_t gms_alloc;
43647 - atomic_long_t gms_free;
43648 - atomic_long_t gts_double_allocate;
43649 - atomic_long_t assign_context;
43650 - atomic_long_t assign_context_failed;
43651 - atomic_long_t free_context;
43652 - atomic_long_t load_user_context;
43653 - atomic_long_t load_kernel_context;
43654 - atomic_long_t lock_kernel_context;
43655 - atomic_long_t unlock_kernel_context;
43656 - atomic_long_t steal_user_context;
43657 - atomic_long_t steal_kernel_context;
43658 - atomic_long_t steal_context_failed;
43659 - atomic_long_t nopfn;
43660 - atomic_long_t asid_new;
43661 - atomic_long_t asid_next;
43662 - atomic_long_t asid_wrap;
43663 - atomic_long_t asid_reuse;
43664 - atomic_long_t intr;
43665 - atomic_long_t intr_cbr;
43666 - atomic_long_t intr_tfh;
43667 - atomic_long_t intr_spurious;
43668 - atomic_long_t intr_mm_lock_failed;
43669 - atomic_long_t call_os;
43670 - atomic_long_t call_os_wait_queue;
43671 - atomic_long_t user_flush_tlb;
43672 - atomic_long_t user_unload_context;
43673 - atomic_long_t user_exception;
43674 - atomic_long_t set_context_option;
43675 - atomic_long_t check_context_retarget_intr;
43676 - atomic_long_t check_context_unload;
43677 - atomic_long_t tlb_dropin;
43678 - atomic_long_t tlb_preload_page;
43679 - atomic_long_t tlb_dropin_fail_no_asid;
43680 - atomic_long_t tlb_dropin_fail_upm;
43681 - atomic_long_t tlb_dropin_fail_invalid;
43682 - atomic_long_t tlb_dropin_fail_range_active;
43683 - atomic_long_t tlb_dropin_fail_idle;
43684 - atomic_long_t tlb_dropin_fail_fmm;
43685 - atomic_long_t tlb_dropin_fail_no_exception;
43686 - atomic_long_t tfh_stale_on_fault;
43687 - atomic_long_t mmu_invalidate_range;
43688 - atomic_long_t mmu_invalidate_page;
43689 - atomic_long_t flush_tlb;
43690 - atomic_long_t flush_tlb_gru;
43691 - atomic_long_t flush_tlb_gru_tgh;
43692 - atomic_long_t flush_tlb_gru_zero_asid;
43693 + atomic_long_unchecked_t vdata_alloc;
43694 + atomic_long_unchecked_t vdata_free;
43695 + atomic_long_unchecked_t gts_alloc;
43696 + atomic_long_unchecked_t gts_free;
43697 + atomic_long_unchecked_t gms_alloc;
43698 + atomic_long_unchecked_t gms_free;
43699 + atomic_long_unchecked_t gts_double_allocate;
43700 + atomic_long_unchecked_t assign_context;
43701 + atomic_long_unchecked_t assign_context_failed;
43702 + atomic_long_unchecked_t free_context;
43703 + atomic_long_unchecked_t load_user_context;
43704 + atomic_long_unchecked_t load_kernel_context;
43705 + atomic_long_unchecked_t lock_kernel_context;
43706 + atomic_long_unchecked_t unlock_kernel_context;
43707 + atomic_long_unchecked_t steal_user_context;
43708 + atomic_long_unchecked_t steal_kernel_context;
43709 + atomic_long_unchecked_t steal_context_failed;
43710 + atomic_long_unchecked_t nopfn;
43711 + atomic_long_unchecked_t asid_new;
43712 + atomic_long_unchecked_t asid_next;
43713 + atomic_long_unchecked_t asid_wrap;
43714 + atomic_long_unchecked_t asid_reuse;
43715 + atomic_long_unchecked_t intr;
43716 + atomic_long_unchecked_t intr_cbr;
43717 + atomic_long_unchecked_t intr_tfh;
43718 + atomic_long_unchecked_t intr_spurious;
43719 + atomic_long_unchecked_t intr_mm_lock_failed;
43720 + atomic_long_unchecked_t call_os;
43721 + atomic_long_unchecked_t call_os_wait_queue;
43722 + atomic_long_unchecked_t user_flush_tlb;
43723 + atomic_long_unchecked_t user_unload_context;
43724 + atomic_long_unchecked_t user_exception;
43725 + atomic_long_unchecked_t set_context_option;
43726 + atomic_long_unchecked_t check_context_retarget_intr;
43727 + atomic_long_unchecked_t check_context_unload;
43728 + atomic_long_unchecked_t tlb_dropin;
43729 + atomic_long_unchecked_t tlb_preload_page;
43730 + atomic_long_unchecked_t tlb_dropin_fail_no_asid;
43731 + atomic_long_unchecked_t tlb_dropin_fail_upm;
43732 + atomic_long_unchecked_t tlb_dropin_fail_invalid;
43733 + atomic_long_unchecked_t tlb_dropin_fail_range_active;
43734 + atomic_long_unchecked_t tlb_dropin_fail_idle;
43735 + atomic_long_unchecked_t tlb_dropin_fail_fmm;
43736 + atomic_long_unchecked_t tlb_dropin_fail_no_exception;
43737 + atomic_long_unchecked_t tfh_stale_on_fault;
43738 + atomic_long_unchecked_t mmu_invalidate_range;
43739 + atomic_long_unchecked_t mmu_invalidate_page;
43740 + atomic_long_unchecked_t flush_tlb;
43741 + atomic_long_unchecked_t flush_tlb_gru;
43742 + atomic_long_unchecked_t flush_tlb_gru_tgh;
43743 + atomic_long_unchecked_t flush_tlb_gru_zero_asid;
43744
43745 - atomic_long_t copy_gpa;
43746 - atomic_long_t read_gpa;
43747 + atomic_long_unchecked_t copy_gpa;
43748 + atomic_long_unchecked_t read_gpa;
43749
43750 - atomic_long_t mesq_receive;
43751 - atomic_long_t mesq_receive_none;
43752 - atomic_long_t mesq_send;
43753 - atomic_long_t mesq_send_failed;
43754 - atomic_long_t mesq_noop;
43755 - atomic_long_t mesq_send_unexpected_error;
43756 - atomic_long_t mesq_send_lb_overflow;
43757 - atomic_long_t mesq_send_qlimit_reached;
43758 - atomic_long_t mesq_send_amo_nacked;
43759 - atomic_long_t mesq_send_put_nacked;
43760 - atomic_long_t mesq_page_overflow;
43761 - atomic_long_t mesq_qf_locked;
43762 - atomic_long_t mesq_qf_noop_not_full;
43763 - atomic_long_t mesq_qf_switch_head_failed;
43764 - atomic_long_t mesq_qf_unexpected_error;
43765 - atomic_long_t mesq_noop_unexpected_error;
43766 - atomic_long_t mesq_noop_lb_overflow;
43767 - atomic_long_t mesq_noop_qlimit_reached;
43768 - atomic_long_t mesq_noop_amo_nacked;
43769 - atomic_long_t mesq_noop_put_nacked;
43770 - atomic_long_t mesq_noop_page_overflow;
43771 + atomic_long_unchecked_t mesq_receive;
43772 + atomic_long_unchecked_t mesq_receive_none;
43773 + atomic_long_unchecked_t mesq_send;
43774 + atomic_long_unchecked_t mesq_send_failed;
43775 + atomic_long_unchecked_t mesq_noop;
43776 + atomic_long_unchecked_t mesq_send_unexpected_error;
43777 + atomic_long_unchecked_t mesq_send_lb_overflow;
43778 + atomic_long_unchecked_t mesq_send_qlimit_reached;
43779 + atomic_long_unchecked_t mesq_send_amo_nacked;
43780 + atomic_long_unchecked_t mesq_send_put_nacked;
43781 + atomic_long_unchecked_t mesq_page_overflow;
43782 + atomic_long_unchecked_t mesq_qf_locked;
43783 + atomic_long_unchecked_t mesq_qf_noop_not_full;
43784 + atomic_long_unchecked_t mesq_qf_switch_head_failed;
43785 + atomic_long_unchecked_t mesq_qf_unexpected_error;
43786 + atomic_long_unchecked_t mesq_noop_unexpected_error;
43787 + atomic_long_unchecked_t mesq_noop_lb_overflow;
43788 + atomic_long_unchecked_t mesq_noop_qlimit_reached;
43789 + atomic_long_unchecked_t mesq_noop_amo_nacked;
43790 + atomic_long_unchecked_t mesq_noop_put_nacked;
43791 + atomic_long_unchecked_t mesq_noop_page_overflow;
43792
43793 };
43794
43795 @@ -251,8 +251,8 @@ enum mcs_op {cchop_allocate, cchop_start, cchop_interrupt, cchop_interrupt_sync,
43796 tghop_invalidate, mcsop_last};
43797
43798 struct mcs_op_statistic {
43799 - atomic_long_t count;
43800 - atomic_long_t total;
43801 + atomic_long_unchecked_t count;
43802 + atomic_long_unchecked_t total;
43803 unsigned long max;
43804 };
43805
43806 @@ -275,7 +275,7 @@ extern struct mcs_op_statistic mcs_op_statistics[mcsop_last];
43807
43808 #define STAT(id) do { \
43809 if (gru_options & OPT_STATS) \
43810 - atomic_long_inc(&gru_stats.id); \
43811 + atomic_long_inc_unchecked(&gru_stats.id); \
43812 } while (0)
43813
43814 #ifdef CONFIG_SGI_GRU_DEBUG
43815 diff --git a/drivers/misc/sgi-xp/xp.h b/drivers/misc/sgi-xp/xp.h
43816 index c862cd4..0d176fe 100644
43817 --- a/drivers/misc/sgi-xp/xp.h
43818 +++ b/drivers/misc/sgi-xp/xp.h
43819 @@ -288,7 +288,7 @@ struct xpc_interface {
43820 xpc_notify_func, void *);
43821 void (*received) (short, int, void *);
43822 enum xp_retval (*partid_to_nasids) (short, void *);
43823 -};
43824 +} __no_const;
43825
43826 extern struct xpc_interface xpc_interface;
43827
43828 diff --git a/drivers/misc/sgi-xp/xpc.h b/drivers/misc/sgi-xp/xpc.h
43829 index b94d5f7..7f494c5 100644
43830 --- a/drivers/misc/sgi-xp/xpc.h
43831 +++ b/drivers/misc/sgi-xp/xpc.h
43832 @@ -835,6 +835,7 @@ struct xpc_arch_operations {
43833 void (*received_payload) (struct xpc_channel *, void *);
43834 void (*notify_senders_of_disconnect) (struct xpc_channel *);
43835 };
43836 +typedef struct xpc_arch_operations __no_const xpc_arch_operations_no_const;
43837
43838 /* struct xpc_partition act_state values (for XPC HB) */
43839
43840 @@ -876,7 +877,7 @@ extern struct xpc_registration xpc_registrations[];
43841 /* found in xpc_main.c */
43842 extern struct device *xpc_part;
43843 extern struct device *xpc_chan;
43844 -extern struct xpc_arch_operations xpc_arch_ops;
43845 +extern xpc_arch_operations_no_const xpc_arch_ops;
43846 extern int xpc_disengage_timelimit;
43847 extern int xpc_disengage_timedout;
43848 extern int xpc_activate_IRQ_rcvd;
43849 diff --git a/drivers/misc/sgi-xp/xpc_main.c b/drivers/misc/sgi-xp/xpc_main.c
43850 index 82dc574..8539ab2 100644
43851 --- a/drivers/misc/sgi-xp/xpc_main.c
43852 +++ b/drivers/misc/sgi-xp/xpc_main.c
43853 @@ -166,7 +166,7 @@ static struct notifier_block xpc_die_notifier = {
43854 .notifier_call = xpc_system_die,
43855 };
43856
43857 -struct xpc_arch_operations xpc_arch_ops;
43858 +xpc_arch_operations_no_const xpc_arch_ops;
43859
43860 /*
43861 * Timer function to enforce the timelimit on the partition disengage.
43862 @@ -1210,7 +1210,7 @@ xpc_system_die(struct notifier_block *nb, unsigned long event, void *_die_args)
43863
43864 if (((die_args->trapnr == X86_TRAP_MF) ||
43865 (die_args->trapnr == X86_TRAP_XF)) &&
43866 - !user_mode_vm(die_args->regs))
43867 + !user_mode(die_args->regs))
43868 xpc_die_deactivate();
43869
43870 break;
43871 diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
43872 index ef18348..1b53cf0 100644
43873 --- a/drivers/mmc/core/mmc_ops.c
43874 +++ b/drivers/mmc/core/mmc_ops.c
43875 @@ -213,7 +213,7 @@ mmc_send_cxd_data(struct mmc_card *card, struct mmc_host *host,
43876 void *data_buf;
43877 int is_on_stack;
43878
43879 - is_on_stack = object_is_on_stack(buf);
43880 + is_on_stack = object_starts_on_stack(buf);
43881 if (is_on_stack) {
43882 /*
43883 * dma onto stack is unsafe/nonportable, but callers to this
43884 diff --git a/drivers/mmc/host/dw_mmc.h b/drivers/mmc/host/dw_mmc.h
43885 index 81b2994..dce857e 100644
43886 --- a/drivers/mmc/host/dw_mmc.h
43887 +++ b/drivers/mmc/host/dw_mmc.h
43888 @@ -203,5 +203,5 @@ struct dw_mci_drv_data {
43889 void (*prepare_command)(struct dw_mci *host, u32 *cmdr);
43890 void (*set_ios)(struct dw_mci *host, struct mmc_ios *ios);
43891 int (*parse_dt)(struct dw_mci *host);
43892 -};
43893 +} __do_const;
43894 #endif /* _DW_MMC_H_ */
43895 diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
43896 index c3785ed..1984c44 100644
43897 --- a/drivers/mmc/host/mmci.c
43898 +++ b/drivers/mmc/host/mmci.c
43899 @@ -1482,7 +1482,9 @@ static int mmci_probe(struct amba_device *dev,
43900 }
43901
43902 if (variant->busy_detect) {
43903 - mmci_ops.card_busy = mmci_card_busy;
43904 + pax_open_kernel();
43905 + *(void **)&mmci_ops.card_busy = mmci_card_busy;
43906 + pax_close_kernel();
43907 mmci_write_datactrlreg(host, MCI_ST_DPSM_BUSYMODE);
43908 }
43909
43910 diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
43911 index 6debda9..2ba7427 100644
43912 --- a/drivers/mmc/host/sdhci-s3c.c
43913 +++ b/drivers/mmc/host/sdhci-s3c.c
43914 @@ -668,9 +668,11 @@ static int sdhci_s3c_probe(struct platform_device *pdev)
43915 * we can use overriding functions instead of default.
43916 */
43917 if (host->quirks & SDHCI_QUIRK_NONSTANDARD_CLOCK) {
43918 - sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
43919 - sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
43920 - sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
43921 + pax_open_kernel();
43922 + *(void **)&sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
43923 + *(void **)&sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
43924 + *(void **)&sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
43925 + pax_close_kernel();
43926 }
43927
43928 /* It supports additional host capabilities if needed */
43929 diff --git a/drivers/mtd/chips/cfi_cmdset_0020.c b/drivers/mtd/chips/cfi_cmdset_0020.c
43930 index 096993f..f02c23b 100644
43931 --- a/drivers/mtd/chips/cfi_cmdset_0020.c
43932 +++ b/drivers/mtd/chips/cfi_cmdset_0020.c
43933 @@ -669,7 +669,7 @@ cfi_staa_writev(struct mtd_info *mtd, const struct kvec *vecs,
43934 size_t totlen = 0, thislen;
43935 int ret = 0;
43936 size_t buflen = 0;
43937 - static char *buffer;
43938 + char *buffer;
43939
43940 if (!ECCBUF_SIZE) {
43941 /* We should fall back to a general writev implementation.
43942 diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c
43943 index 2ed2bb3..2d0b82e 100644
43944 --- a/drivers/mtd/nand/denali.c
43945 +++ b/drivers/mtd/nand/denali.c
43946 @@ -24,6 +24,7 @@
43947 #include <linux/slab.h>
43948 #include <linux/mtd/mtd.h>
43949 #include <linux/module.h>
43950 +#include <linux/slab.h>
43951
43952 #include "denali.h"
43953
43954 diff --git a/drivers/mtd/nftlmount.c b/drivers/mtd/nftlmount.c
43955 index 51b9d6a..52af9a7 100644
43956 --- a/drivers/mtd/nftlmount.c
43957 +++ b/drivers/mtd/nftlmount.c
43958 @@ -24,6 +24,7 @@
43959 #include <asm/errno.h>
43960 #include <linux/delay.h>
43961 #include <linux/slab.h>
43962 +#include <linux/sched.h>
43963 #include <linux/mtd/mtd.h>
43964 #include <linux/mtd/nand.h>
43965 #include <linux/mtd/nftl.h>
43966 diff --git a/drivers/mtd/sm_ftl.c b/drivers/mtd/sm_ftl.c
43967 index 4b8e895..6b3c498 100644
43968 --- a/drivers/mtd/sm_ftl.c
43969 +++ b/drivers/mtd/sm_ftl.c
43970 @@ -56,7 +56,7 @@ static ssize_t sm_attr_show(struct device *dev, struct device_attribute *attr,
43971 #define SM_CIS_VENDOR_OFFSET 0x59
43972 static struct attribute_group *sm_create_sysfs_attributes(struct sm_ftl *ftl)
43973 {
43974 - struct attribute_group *attr_group;
43975 + attribute_group_no_const *attr_group;
43976 struct attribute **attributes;
43977 struct sm_sysfs_attribute *vendor_attribute;
43978
43979 diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
43980 index dd8057d..22aaf36 100644
43981 --- a/drivers/net/bonding/bond_main.c
43982 +++ b/drivers/net/bonding/bond_main.c
43983 @@ -4511,7 +4511,7 @@ static unsigned int bond_get_num_tx_queues(void)
43984 return tx_queues;
43985 }
43986
43987 -static struct rtnl_link_ops bond_link_ops __read_mostly = {
43988 +static struct rtnl_link_ops bond_link_ops = {
43989 .kind = "bond",
43990 .priv_size = sizeof(struct bonding),
43991 .setup = bond_setup,
43992 @@ -4636,8 +4636,8 @@ static void __exit bonding_exit(void)
43993
43994 bond_destroy_debugfs();
43995
43996 - rtnl_link_unregister(&bond_link_ops);
43997 unregister_pernet_subsys(&bond_net_ops);
43998 + rtnl_link_unregister(&bond_link_ops);
43999
44000 #ifdef CONFIG_NET_POLL_CONTROLLER
44001 /*
44002 diff --git a/drivers/net/ethernet/8390/ax88796.c b/drivers/net/ethernet/8390/ax88796.c
44003 index f92f001..0b2f9bf 100644
44004 --- a/drivers/net/ethernet/8390/ax88796.c
44005 +++ b/drivers/net/ethernet/8390/ax88796.c
44006 @@ -872,9 +872,11 @@ static int ax_probe(struct platform_device *pdev)
44007 if (ax->plat->reg_offsets)
44008 ei_local->reg_offset = ax->plat->reg_offsets;
44009 else {
44010 + resource_size_t _mem_size = mem_size;
44011 + do_div(_mem_size, 0x18);
44012 ei_local->reg_offset = ax->reg_offsets;
44013 for (ret = 0; ret < 0x18; ret++)
44014 - ax->reg_offsets[ret] = (mem_size / 0x18) * ret;
44015 + ax->reg_offsets[ret] = _mem_size * ret;
44016 }
44017
44018 if (!request_mem_region(mem->start, mem_size, pdev->name)) {
44019 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
44020 index da8fcaa..f4b5d3b 100644
44021 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
44022 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
44023 @@ -1138,7 +1138,7 @@ static inline u8 bnx2x_get_path_func_num(struct bnx2x *bp)
44024 static inline void bnx2x_init_bp_objs(struct bnx2x *bp)
44025 {
44026 /* RX_MODE controlling object */
44027 - bnx2x_init_rx_mode_obj(bp, &bp->rx_mode_obj);
44028 + bnx2x_init_rx_mode_obj(bp);
44029
44030 /* multicast configuration controlling object */
44031 bnx2x_init_mcast_obj(bp, &bp->mcast_obj, bp->fp->cl_id, bp->fp->cid,
44032 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
44033 index 9fbeee5..5e3e37a 100644
44034 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
44035 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
44036 @@ -2590,15 +2590,14 @@ int bnx2x_config_rx_mode(struct bnx2x *bp,
44037 return rc;
44038 }
44039
44040 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
44041 - struct bnx2x_rx_mode_obj *o)
44042 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp)
44043 {
44044 if (CHIP_IS_E1x(bp)) {
44045 - o->wait_comp = bnx2x_empty_rx_mode_wait;
44046 - o->config_rx_mode = bnx2x_set_rx_mode_e1x;
44047 + bp->rx_mode_obj.wait_comp = bnx2x_empty_rx_mode_wait;
44048 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e1x;
44049 } else {
44050 - o->wait_comp = bnx2x_wait_rx_mode_comp_e2;
44051 - o->config_rx_mode = bnx2x_set_rx_mode_e2;
44052 + bp->rx_mode_obj.wait_comp = bnx2x_wait_rx_mode_comp_e2;
44053 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e2;
44054 }
44055 }
44056
44057 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
44058 index 658f4e3..15074a6 100644
44059 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
44060 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
44061 @@ -1325,8 +1325,7 @@ int bnx2x_vlan_mac_move(struct bnx2x *bp,
44062
44063 /********************* RX MODE ****************/
44064
44065 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
44066 - struct bnx2x_rx_mode_obj *o);
44067 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp);
44068
44069 /**
44070 * bnx2x_config_rx_mode - Send and RX_MODE ramrod according to the provided parameters.
44071 diff --git a/drivers/net/ethernet/broadcom/tg3.h b/drivers/net/ethernet/broadcom/tg3.h
44072 index 7025780..e55a71c 100644
44073 --- a/drivers/net/ethernet/broadcom/tg3.h
44074 +++ b/drivers/net/ethernet/broadcom/tg3.h
44075 @@ -147,6 +147,7 @@
44076 #define CHIPREV_ID_5750_A0 0x4000
44077 #define CHIPREV_ID_5750_A1 0x4001
44078 #define CHIPREV_ID_5750_A3 0x4003
44079 +#define CHIPREV_ID_5750_C1 0x4201
44080 #define CHIPREV_ID_5750_C2 0x4202
44081 #define CHIPREV_ID_5752_A0_HW 0x5000
44082 #define CHIPREV_ID_5752_A0 0x6000
44083 diff --git a/drivers/net/ethernet/chelsio/cxgb3/l2t.h b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
44084 index 8cffcdf..aadf043 100644
44085 --- a/drivers/net/ethernet/chelsio/cxgb3/l2t.h
44086 +++ b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
44087 @@ -87,7 +87,7 @@ typedef void (*arp_failure_handler_func)(struct t3cdev * dev,
44088 */
44089 struct l2t_skb_cb {
44090 arp_failure_handler_func arp_failure_handler;
44091 -};
44092 +} __no_const;
44093
44094 #define L2T_SKB_CB(skb) ((struct l2t_skb_cb *)(skb)->cb)
44095
44096 diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
44097 index c73cabd..cd278b1 100644
44098 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
44099 +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
44100 @@ -2186,7 +2186,7 @@ static void get_regs(struct net_device *dev, struct ethtool_regs *regs,
44101
44102 int i;
44103 struct adapter *ap = netdev2adap(dev);
44104 - static const unsigned int *reg_ranges;
44105 + const unsigned int *reg_ranges;
44106 int arr_size = 0, buf_size = 0;
44107
44108 if (is_t4(ap->chip)) {
44109 diff --git a/drivers/net/ethernet/dec/tulip/de4x5.c b/drivers/net/ethernet/dec/tulip/de4x5.c
44110 index 263b92c..f05134b 100644
44111 --- a/drivers/net/ethernet/dec/tulip/de4x5.c
44112 +++ b/drivers/net/ethernet/dec/tulip/de4x5.c
44113 @@ -5388,7 +5388,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
44114 for (i=0; i<ETH_ALEN; i++) {
44115 tmp.addr[i] = dev->dev_addr[i];
44116 }
44117 - if (copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
44118 + if (ioc->len > sizeof tmp.addr || copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
44119 break;
44120
44121 case DE4X5_SET_HWADDR: /* Set the hardware address */
44122 @@ -5428,7 +5428,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
44123 spin_lock_irqsave(&lp->lock, flags);
44124 memcpy(&statbuf, &lp->pktStats, ioc->len);
44125 spin_unlock_irqrestore(&lp->lock, flags);
44126 - if (copy_to_user(ioc->data, &statbuf, ioc->len))
44127 + if (ioc->len > sizeof statbuf || copy_to_user(ioc->data, &statbuf, ioc->len))
44128 return -EFAULT;
44129 break;
44130 }
44131 diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
44132 index 2c38cc4..0323f6e 100644
44133 --- a/drivers/net/ethernet/emulex/benet/be_main.c
44134 +++ b/drivers/net/ethernet/emulex/benet/be_main.c
44135 @@ -470,7 +470,7 @@ static void accumulate_16bit_val(u32 *acc, u16 val)
44136
44137 if (wrapped)
44138 newacc += 65536;
44139 - ACCESS_ONCE(*acc) = newacc;
44140 + ACCESS_ONCE_RW(*acc) = newacc;
44141 }
44142
44143 static void populate_erx_stats(struct be_adapter *adapter,
44144 diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
44145 index 212f44b..fb69959 100644
44146 --- a/drivers/net/ethernet/faraday/ftgmac100.c
44147 +++ b/drivers/net/ethernet/faraday/ftgmac100.c
44148 @@ -31,6 +31,8 @@
44149 #include <linux/netdevice.h>
44150 #include <linux/phy.h>
44151 #include <linux/platform_device.h>
44152 +#include <linux/interrupt.h>
44153 +#include <linux/irqreturn.h>
44154 #include <net/ip.h>
44155
44156 #include "ftgmac100.h"
44157 diff --git a/drivers/net/ethernet/faraday/ftmac100.c b/drivers/net/ethernet/faraday/ftmac100.c
44158 index 8be5b40..081bc1b 100644
44159 --- a/drivers/net/ethernet/faraday/ftmac100.c
44160 +++ b/drivers/net/ethernet/faraday/ftmac100.c
44161 @@ -31,6 +31,8 @@
44162 #include <linux/module.h>
44163 #include <linux/netdevice.h>
44164 #include <linux/platform_device.h>
44165 +#include <linux/interrupt.h>
44166 +#include <linux/irqreturn.h>
44167
44168 #include "ftmac100.h"
44169
44170 diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
44171 index 5184e2a..acb28c3 100644
44172 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
44173 +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
44174 @@ -776,7 +776,7 @@ void ixgbe_ptp_start_cyclecounter(struct ixgbe_adapter *adapter)
44175 }
44176
44177 /* update the base incval used to calculate frequency adjustment */
44178 - ACCESS_ONCE(adapter->base_incval) = incval;
44179 + ACCESS_ONCE_RW(adapter->base_incval) = incval;
44180 smp_mb();
44181
44182 /* need lock to prevent incorrect read while modifying cyclecounter */
44183 diff --git a/drivers/net/ethernet/neterion/vxge/vxge-config.c b/drivers/net/ethernet/neterion/vxge/vxge-config.c
44184 index fbe5363..266b4e3 100644
44185 --- a/drivers/net/ethernet/neterion/vxge/vxge-config.c
44186 +++ b/drivers/net/ethernet/neterion/vxge/vxge-config.c
44187 @@ -3461,7 +3461,10 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
44188 struct __vxge_hw_fifo *fifo;
44189 struct vxge_hw_fifo_config *config;
44190 u32 txdl_size, txdl_per_memblock;
44191 - struct vxge_hw_mempool_cbs fifo_mp_callback;
44192 + static struct vxge_hw_mempool_cbs fifo_mp_callback = {
44193 + .item_func_alloc = __vxge_hw_fifo_mempool_item_alloc,
44194 + };
44195 +
44196 struct __vxge_hw_virtualpath *vpath;
44197
44198 if ((vp == NULL) || (attr == NULL)) {
44199 @@ -3544,8 +3547,6 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
44200 goto exit;
44201 }
44202
44203 - fifo_mp_callback.item_func_alloc = __vxge_hw_fifo_mempool_item_alloc;
44204 -
44205 fifo->mempool =
44206 __vxge_hw_mempool_create(vpath->hldev,
44207 fifo->config->memblock_size,
44208 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
44209 index f09e787..f3916a8 100644
44210 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
44211 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
44212 @@ -2055,7 +2055,9 @@ int qlcnic_83xx_configure_opmode(struct qlcnic_adapter *adapter)
44213
44214 } else if (ret == QLC_83XX_DEFAULT_OPMODE) {
44215 ahw->nic_mode = QLC_83XX_DEFAULT_MODE;
44216 - adapter->nic_ops->init_driver = qlcnic_83xx_init_default_driver;
44217 + pax_open_kernel();
44218 + *(void **)&adapter->nic_ops->init_driver = qlcnic_83xx_init_default_driver;
44219 + pax_close_kernel();
44220 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
44221 } else {
44222 return -EIO;
44223 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
44224 index 0248a4c..9648d96 100644
44225 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
44226 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
44227 @@ -191,17 +191,23 @@ int qlcnic_83xx_config_vnic_opmode(struct qlcnic_adapter *adapter)
44228 case QLCNIC_NON_PRIV_FUNC:
44229 ahw->op_mode = QLCNIC_NON_PRIV_FUNC;
44230 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
44231 - nic_ops->init_driver = qlcnic_83xx_init_non_privileged_vnic;
44232 + pax_open_kernel();
44233 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_non_privileged_vnic;
44234 + pax_close_kernel();
44235 break;
44236 case QLCNIC_PRIV_FUNC:
44237 ahw->op_mode = QLCNIC_PRIV_FUNC;
44238 ahw->idc.state_entry = qlcnic_83xx_idc_vnic_pf_entry;
44239 - nic_ops->init_driver = qlcnic_83xx_init_privileged_vnic;
44240 + pax_open_kernel();
44241 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_privileged_vnic;
44242 + pax_close_kernel();
44243 break;
44244 case QLCNIC_MGMT_FUNC:
44245 ahw->op_mode = QLCNIC_MGMT_FUNC;
44246 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
44247 - nic_ops->init_driver = qlcnic_83xx_init_mgmt_vnic;
44248 + pax_open_kernel();
44249 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_mgmt_vnic;
44250 + pax_close_kernel();
44251 break;
44252 default:
44253 dev_err(&adapter->pdev->dev, "Invalid Virtual NIC opmode\n");
44254 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c
44255 index 1551360..ed6510f 100644
44256 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c
44257 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c
44258 @@ -1108,7 +1108,7 @@ int qlcnic_dump_fw(struct qlcnic_adapter *adapter)
44259 struct qlcnic_dump_entry *entry;
44260 struct qlcnic_fw_dump *fw_dump = &adapter->ahw->fw_dump;
44261 struct qlcnic_dump_template_hdr *tmpl_hdr = fw_dump->tmpl_hdr;
44262 - static const struct qlcnic_dump_operations *fw_dump_ops;
44263 + const struct qlcnic_dump_operations *fw_dump_ops;
44264 struct device *dev = &adapter->pdev->dev;
44265 struct qlcnic_hardware_context *ahw;
44266 void *temp_buffer;
44267 diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
44268 index fb3f8dc..9d2ff38 100644
44269 --- a/drivers/net/ethernet/realtek/r8169.c
44270 +++ b/drivers/net/ethernet/realtek/r8169.c
44271 @@ -759,22 +759,22 @@ struct rtl8169_private {
44272 struct mdio_ops {
44273 void (*write)(struct rtl8169_private *, int, int);
44274 int (*read)(struct rtl8169_private *, int);
44275 - } mdio_ops;
44276 + } __no_const mdio_ops;
44277
44278 struct pll_power_ops {
44279 void (*down)(struct rtl8169_private *);
44280 void (*up)(struct rtl8169_private *);
44281 - } pll_power_ops;
44282 + } __no_const pll_power_ops;
44283
44284 struct jumbo_ops {
44285 void (*enable)(struct rtl8169_private *);
44286 void (*disable)(struct rtl8169_private *);
44287 - } jumbo_ops;
44288 + } __no_const jumbo_ops;
44289
44290 struct csi_ops {
44291 void (*write)(struct rtl8169_private *, int, int);
44292 u32 (*read)(struct rtl8169_private *, int);
44293 - } csi_ops;
44294 + } __no_const csi_ops;
44295
44296 int (*set_speed)(struct net_device *, u8 aneg, u16 sp, u8 dpx, u32 adv);
44297 int (*get_settings)(struct net_device *, struct ethtool_cmd *);
44298 diff --git a/drivers/net/ethernet/sfc/ptp.c b/drivers/net/ethernet/sfc/ptp.c
44299 index 03acf57..e1251ff 100644
44300 --- a/drivers/net/ethernet/sfc/ptp.c
44301 +++ b/drivers/net/ethernet/sfc/ptp.c
44302 @@ -539,7 +539,7 @@ static int efx_ptp_synchronize(struct efx_nic *efx, unsigned int num_readings)
44303 ptp->start.dma_addr);
44304
44305 /* Clear flag that signals MC ready */
44306 - ACCESS_ONCE(*start) = 0;
44307 + ACCESS_ONCE_RW(*start) = 0;
44308 rc = efx_mcdi_rpc_start(efx, MC_CMD_PTP, synch_buf,
44309 MC_CMD_PTP_IN_SYNCHRONIZE_LEN);
44310 EFX_BUG_ON_PARANOID(rc);
44311 diff --git a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
44312 index 50617c5..b13724c 100644
44313 --- a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
44314 +++ b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
44315 @@ -140,8 +140,8 @@ void dwmac_mmc_ctrl(void __iomem *ioaddr, unsigned int mode)
44316
44317 writel(value, ioaddr + MMC_CNTRL);
44318
44319 - pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
44320 - MMC_CNTRL, value);
44321 +// pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
44322 +// MMC_CNTRL, value);
44323 }
44324
44325 /* To mask all all interrupts.*/
44326 diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
44327 index e6fe0d8..2b7d752 100644
44328 --- a/drivers/net/hyperv/hyperv_net.h
44329 +++ b/drivers/net/hyperv/hyperv_net.h
44330 @@ -101,7 +101,7 @@ struct rndis_device {
44331
44332 enum rndis_device_state state;
44333 bool link_state;
44334 - atomic_t new_req_id;
44335 + atomic_unchecked_t new_req_id;
44336
44337 spinlock_t request_lock;
44338 struct list_head req_list;
44339 diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c
44340 index 0775f0a..d4fb316 100644
44341 --- a/drivers/net/hyperv/rndis_filter.c
44342 +++ b/drivers/net/hyperv/rndis_filter.c
44343 @@ -104,7 +104,7 @@ static struct rndis_request *get_rndis_request(struct rndis_device *dev,
44344 * template
44345 */
44346 set = &rndis_msg->msg.set_req;
44347 - set->req_id = atomic_inc_return(&dev->new_req_id);
44348 + set->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
44349
44350 /* Add to the request list */
44351 spin_lock_irqsave(&dev->request_lock, flags);
44352 @@ -752,7 +752,7 @@ static void rndis_filter_halt_device(struct rndis_device *dev)
44353
44354 /* Setup the rndis set */
44355 halt = &request->request_msg.msg.halt_req;
44356 - halt->req_id = atomic_inc_return(&dev->new_req_id);
44357 + halt->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
44358
44359 /* Ignore return since this msg is optional. */
44360 rndis_filter_send_request(dev, request);
44361 diff --git a/drivers/net/ieee802154/fakehard.c b/drivers/net/ieee802154/fakehard.c
44362 index bf0d55e..82bcfbd1 100644
44363 --- a/drivers/net/ieee802154/fakehard.c
44364 +++ b/drivers/net/ieee802154/fakehard.c
44365 @@ -364,7 +364,7 @@ static int ieee802154fake_probe(struct platform_device *pdev)
44366 phy->transmit_power = 0xbf;
44367
44368 dev->netdev_ops = &fake_ops;
44369 - dev->ml_priv = &fake_mlme;
44370 + dev->ml_priv = (void *)&fake_mlme;
44371
44372 priv = netdev_priv(dev);
44373 priv->phy = phy;
44374 diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
44375 index 9bf46bd..bfdaa84 100644
44376 --- a/drivers/net/macvlan.c
44377 +++ b/drivers/net/macvlan.c
44378 @@ -939,13 +939,15 @@ static const struct nla_policy macvlan_policy[IFLA_MACVLAN_MAX + 1] = {
44379 int macvlan_link_register(struct rtnl_link_ops *ops)
44380 {
44381 /* common fields */
44382 - ops->priv_size = sizeof(struct macvlan_dev);
44383 - ops->validate = macvlan_validate;
44384 - ops->maxtype = IFLA_MACVLAN_MAX;
44385 - ops->policy = macvlan_policy;
44386 - ops->changelink = macvlan_changelink;
44387 - ops->get_size = macvlan_get_size;
44388 - ops->fill_info = macvlan_fill_info;
44389 + pax_open_kernel();
44390 + *(size_t *)&ops->priv_size = sizeof(struct macvlan_dev);
44391 + *(void **)&ops->validate = macvlan_validate;
44392 + *(int *)&ops->maxtype = IFLA_MACVLAN_MAX;
44393 + *(const void **)&ops->policy = macvlan_policy;
44394 + *(void **)&ops->changelink = macvlan_changelink;
44395 + *(void **)&ops->get_size = macvlan_get_size;
44396 + *(void **)&ops->fill_info = macvlan_fill_info;
44397 + pax_close_kernel();
44398
44399 return rtnl_link_register(ops);
44400 };
44401 @@ -1001,7 +1003,7 @@ static int macvlan_device_event(struct notifier_block *unused,
44402 return NOTIFY_DONE;
44403 }
44404
44405 -static struct notifier_block macvlan_notifier_block __read_mostly = {
44406 +static struct notifier_block macvlan_notifier_block = {
44407 .notifier_call = macvlan_device_event,
44408 };
44409
44410 diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
44411 index dc76670..e18f39c 100644
44412 --- a/drivers/net/macvtap.c
44413 +++ b/drivers/net/macvtap.c
44414 @@ -1189,7 +1189,7 @@ static int macvtap_device_event(struct notifier_block *unused,
44415 return NOTIFY_DONE;
44416 }
44417
44418 -static struct notifier_block macvtap_notifier_block __read_mostly = {
44419 +static struct notifier_block macvtap_notifier_block = {
44420 .notifier_call = macvtap_device_event,
44421 };
44422
44423 diff --git a/drivers/net/phy/mdio-bitbang.c b/drivers/net/phy/mdio-bitbang.c
44424 index daec9b0..6428fcb 100644
44425 --- a/drivers/net/phy/mdio-bitbang.c
44426 +++ b/drivers/net/phy/mdio-bitbang.c
44427 @@ -234,6 +234,7 @@ void free_mdio_bitbang(struct mii_bus *bus)
44428 struct mdiobb_ctrl *ctrl = bus->priv;
44429
44430 module_put(ctrl->ops->owner);
44431 + mdiobus_unregister(bus);
44432 mdiobus_free(bus);
44433 }
44434 EXPORT_SYMBOL(free_mdio_bitbang);
44435 diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
44436 index 72ff14b..11d442d 100644
44437 --- a/drivers/net/ppp/ppp_generic.c
44438 +++ b/drivers/net/ppp/ppp_generic.c
44439 @@ -999,7 +999,6 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
44440 void __user *addr = (void __user *) ifr->ifr_ifru.ifru_data;
44441 struct ppp_stats stats;
44442 struct ppp_comp_stats cstats;
44443 - char *vers;
44444
44445 switch (cmd) {
44446 case SIOCGPPPSTATS:
44447 @@ -1021,8 +1020,7 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
44448 break;
44449
44450 case SIOCGPPPVER:
44451 - vers = PPP_VERSION;
44452 - if (copy_to_user(addr, vers, strlen(vers) + 1))
44453 + if (copy_to_user(addr, PPP_VERSION, sizeof(PPP_VERSION)))
44454 break;
44455 err = 0;
44456 break;
44457 diff --git a/drivers/net/slip/slhc.c b/drivers/net/slip/slhc.c
44458 index 1252d9c..80e660b 100644
44459 --- a/drivers/net/slip/slhc.c
44460 +++ b/drivers/net/slip/slhc.c
44461 @@ -488,7 +488,7 @@ slhc_uncompress(struct slcompress *comp, unsigned char *icp, int isize)
44462 register struct tcphdr *thp;
44463 register struct iphdr *ip;
44464 register struct cstate *cs;
44465 - int len, hdrlen;
44466 + long len, hdrlen;
44467 unsigned char *cp = icp;
44468
44469 /* We've got a compressed packet; read the change byte */
44470 diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
44471 index 6327df2..e6e1ebe 100644
44472 --- a/drivers/net/team/team.c
44473 +++ b/drivers/net/team/team.c
44474 @@ -2873,7 +2873,7 @@ static int team_device_event(struct notifier_block *unused,
44475 return NOTIFY_DONE;
44476 }
44477
44478 -static struct notifier_block team_notifier_block __read_mostly = {
44479 +static struct notifier_block team_notifier_block = {
44480 .notifier_call = team_device_event,
44481 };
44482
44483 diff --git a/drivers/net/tun.c b/drivers/net/tun.c
44484 index 782e38b..d076fdc 100644
44485 --- a/drivers/net/tun.c
44486 +++ b/drivers/net/tun.c
44487 @@ -1834,7 +1834,7 @@ unlock:
44488 }
44489
44490 static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
44491 - unsigned long arg, int ifreq_len)
44492 + unsigned long arg, size_t ifreq_len)
44493 {
44494 struct tun_file *tfile = file->private_data;
44495 struct tun_struct *tun;
44496 @@ -1847,6 +1847,9 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
44497 unsigned int ifindex;
44498 int ret;
44499
44500 + if (ifreq_len > sizeof ifr)
44501 + return -EFAULT;
44502 +
44503 if (cmd == TUNSETIFF || cmd == TUNSETQUEUE || _IOC_TYPE(cmd) == 0x89) {
44504 if (copy_from_user(&ifr, argp, ifreq_len))
44505 return -EFAULT;
44506 diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
44507 index 86292e6..8d34433 100644
44508 --- a/drivers/net/usb/hso.c
44509 +++ b/drivers/net/usb/hso.c
44510 @@ -71,7 +71,7 @@
44511 #include <asm/byteorder.h>
44512 #include <linux/serial_core.h>
44513 #include <linux/serial.h>
44514 -
44515 +#include <asm/local.h>
44516
44517 #define MOD_AUTHOR "Option Wireless"
44518 #define MOD_DESCRIPTION "USB High Speed Option driver"
44519 @@ -1180,7 +1180,7 @@ static void put_rxbuf_data_and_resubmit_ctrl_urb(struct hso_serial *serial)
44520 struct urb *urb;
44521
44522 urb = serial->rx_urb[0];
44523 - if (serial->port.count > 0) {
44524 + if (atomic_read(&serial->port.count) > 0) {
44525 count = put_rxbuf_data(urb, serial);
44526 if (count == -1)
44527 return;
44528 @@ -1216,7 +1216,7 @@ static void hso_std_serial_read_bulk_callback(struct urb *urb)
44529 DUMP1(urb->transfer_buffer, urb->actual_length);
44530
44531 /* Anyone listening? */
44532 - if (serial->port.count == 0)
44533 + if (atomic_read(&serial->port.count) == 0)
44534 return;
44535
44536 if (status == 0) {
44537 @@ -1298,8 +1298,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
44538 tty_port_tty_set(&serial->port, tty);
44539
44540 /* check for port already opened, if not set the termios */
44541 - serial->port.count++;
44542 - if (serial->port.count == 1) {
44543 + if (atomic_inc_return(&serial->port.count) == 1) {
44544 serial->rx_state = RX_IDLE;
44545 /* Force default termio settings */
44546 _hso_serial_set_termios(tty, NULL);
44547 @@ -1311,7 +1310,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
44548 result = hso_start_serial_device(serial->parent, GFP_KERNEL);
44549 if (result) {
44550 hso_stop_serial_device(serial->parent);
44551 - serial->port.count--;
44552 + atomic_dec(&serial->port.count);
44553 kref_put(&serial->parent->ref, hso_serial_ref_free);
44554 }
44555 } else {
44556 @@ -1348,10 +1347,10 @@ static void hso_serial_close(struct tty_struct *tty, struct file *filp)
44557
44558 /* reset the rts and dtr */
44559 /* do the actual close */
44560 - serial->port.count--;
44561 + atomic_dec(&serial->port.count);
44562
44563 - if (serial->port.count <= 0) {
44564 - serial->port.count = 0;
44565 + if (atomic_read(&serial->port.count) <= 0) {
44566 + atomic_set(&serial->port.count, 0);
44567 tty_port_tty_set(&serial->port, NULL);
44568 if (!usb_gone)
44569 hso_stop_serial_device(serial->parent);
44570 @@ -1427,7 +1426,7 @@ static void hso_serial_set_termios(struct tty_struct *tty, struct ktermios *old)
44571
44572 /* the actual setup */
44573 spin_lock_irqsave(&serial->serial_lock, flags);
44574 - if (serial->port.count)
44575 + if (atomic_read(&serial->port.count))
44576 _hso_serial_set_termios(tty, old);
44577 else
44578 tty->termios = *old;
44579 @@ -1886,7 +1885,7 @@ static void intr_callback(struct urb *urb)
44580 D1("Pending read interrupt on port %d\n", i);
44581 spin_lock(&serial->serial_lock);
44582 if (serial->rx_state == RX_IDLE &&
44583 - serial->port.count > 0) {
44584 + atomic_read(&serial->port.count) > 0) {
44585 /* Setup and send a ctrl req read on
44586 * port i */
44587 if (!serial->rx_urb_filled[0]) {
44588 @@ -3062,7 +3061,7 @@ static int hso_resume(struct usb_interface *iface)
44589 /* Start all serial ports */
44590 for (i = 0; i < HSO_SERIAL_TTY_MINORS; i++) {
44591 if (serial_table[i] && (serial_table[i]->interface == iface)) {
44592 - if (dev2ser(serial_table[i])->port.count) {
44593 + if (atomic_read(&dev2ser(serial_table[i])->port.count)) {
44594 result =
44595 hso_start_serial_device(serial_table[i], GFP_NOIO);
44596 hso_kick_transmit(dev2ser(serial_table[i]));
44597 diff --git a/drivers/net/usb/sierra_net.c b/drivers/net/usb/sierra_net.c
44598 index a79e9d3..78cd4fa 100644
44599 --- a/drivers/net/usb/sierra_net.c
44600 +++ b/drivers/net/usb/sierra_net.c
44601 @@ -52,7 +52,7 @@ static const char driver_name[] = "sierra_net";
44602 /* atomic counter partially included in MAC address to make sure 2 devices
44603 * do not end up with the same MAC - concept breaks in case of > 255 ifaces
44604 */
44605 -static atomic_t iface_counter = ATOMIC_INIT(0);
44606 +static atomic_unchecked_t iface_counter = ATOMIC_INIT(0);
44607
44608 /*
44609 * SYNC Timer Delay definition used to set the expiry time
44610 @@ -698,7 +698,7 @@ static int sierra_net_bind(struct usbnet *dev, struct usb_interface *intf)
44611 dev->net->netdev_ops = &sierra_net_device_ops;
44612
44613 /* change MAC addr to include, ifacenum, and to be unique */
44614 - dev->net->dev_addr[ETH_ALEN-2] = atomic_inc_return(&iface_counter);
44615 + dev->net->dev_addr[ETH_ALEN-2] = atomic_inc_return_unchecked(&iface_counter);
44616 dev->net->dev_addr[ETH_ALEN-1] = ifacenum;
44617
44618 /* we will have to manufacture ethernet headers, prepare template */
44619 diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
44620 index 2ef5b62..6fa0ec3 100644
44621 --- a/drivers/net/vxlan.c
44622 +++ b/drivers/net/vxlan.c
44623 @@ -2615,7 +2615,7 @@ nla_put_failure:
44624 return -EMSGSIZE;
44625 }
44626
44627 -static struct rtnl_link_ops vxlan_link_ops __read_mostly = {
44628 +static struct rtnl_link_ops vxlan_link_ops = {
44629 .kind = "vxlan",
44630 .maxtype = IFLA_VXLAN_MAX,
44631 .policy = vxlan_policy,
44632 diff --git a/drivers/net/wimax/i2400m/rx.c b/drivers/net/wimax/i2400m/rx.c
44633 index 0b60295..b8bfa5b 100644
44634 --- a/drivers/net/wimax/i2400m/rx.c
44635 +++ b/drivers/net/wimax/i2400m/rx.c
44636 @@ -1359,7 +1359,7 @@ int i2400m_rx_setup(struct i2400m *i2400m)
44637 if (i2400m->rx_roq == NULL)
44638 goto error_roq_alloc;
44639
44640 - rd = kcalloc(I2400M_RO_CIN + 1, sizeof(*i2400m->rx_roq[0].log),
44641 + rd = kcalloc(sizeof(*i2400m->rx_roq[0].log), I2400M_RO_CIN + 1,
44642 GFP_KERNEL);
44643 if (rd == NULL) {
44644 result = -ENOMEM;
44645 diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
44646 index 7fe1964..7016de0 100644
44647 --- a/drivers/net/wireless/airo.c
44648 +++ b/drivers/net/wireless/airo.c
44649 @@ -7844,7 +7844,7 @@ static int writerids(struct net_device *dev, aironet_ioctl *comp) {
44650 struct airo_info *ai = dev->ml_priv;
44651 int ridcode;
44652 int enabled;
44653 - static int (* writer)(struct airo_info *, u16 rid, const void *, int, int);
44654 + int (* writer)(struct airo_info *, u16 rid, const void *, int, int);
44655 unsigned char *iobuf;
44656
44657 /* Only super-user can write RIDs */
44658 diff --git a/drivers/net/wireless/at76c50x-usb.c b/drivers/net/wireless/at76c50x-usb.c
44659 index 34c8a33..3261fdc 100644
44660 --- a/drivers/net/wireless/at76c50x-usb.c
44661 +++ b/drivers/net/wireless/at76c50x-usb.c
44662 @@ -353,7 +353,7 @@ static int at76_dfu_get_state(struct usb_device *udev, u8 *state)
44663 }
44664
44665 /* Convert timeout from the DFU status to jiffies */
44666 -static inline unsigned long at76_get_timeout(struct dfu_status *s)
44667 +static inline unsigned long __intentional_overflow(-1) at76_get_timeout(struct dfu_status *s)
44668 {
44669 return msecs_to_jiffies((s->poll_timeout[2] << 16)
44670 | (s->poll_timeout[1] << 8)
44671 diff --git a/drivers/net/wireless/ath/ath10k/htc.c b/drivers/net/wireless/ath/ath10k/htc.c
44672 index ef3329e..c28ff5d 100644
44673 --- a/drivers/net/wireless/ath/ath10k/htc.c
44674 +++ b/drivers/net/wireless/ath/ath10k/htc.c
44675 @@ -963,7 +963,10 @@ void ath10k_htc_stop(struct ath10k_htc *htc)
44676 /* registered target arrival callback from the HIF layer */
44677 int ath10k_htc_init(struct ath10k *ar)
44678 {
44679 - struct ath10k_hif_cb htc_callbacks;
44680 + static struct ath10k_hif_cb htc_callbacks = {
44681 + .rx_completion = ath10k_htc_rx_completion_handler,
44682 + .tx_completion = ath10k_htc_tx_completion_handler,
44683 + };
44684 struct ath10k_htc_ep *ep = NULL;
44685 struct ath10k_htc *htc = &ar->htc;
44686
44687 @@ -973,8 +976,6 @@ int ath10k_htc_init(struct ath10k *ar)
44688 ath10k_htc_reset_endpoint_states(htc);
44689
44690 /* setup HIF layer callbacks */
44691 - htc_callbacks.rx_completion = ath10k_htc_rx_completion_handler;
44692 - htc_callbacks.tx_completion = ath10k_htc_tx_completion_handler;
44693 htc->ar = ar;
44694
44695 /* Get HIF default pipe for HTC message exchange */
44696 diff --git a/drivers/net/wireless/ath/ath10k/htc.h b/drivers/net/wireless/ath/ath10k/htc.h
44697 index e1dd8c7..9f91b3f 100644
44698 --- a/drivers/net/wireless/ath/ath10k/htc.h
44699 +++ b/drivers/net/wireless/ath/ath10k/htc.h
44700 @@ -271,12 +271,12 @@ enum ath10k_htc_ep_id {
44701
44702 struct ath10k_htc_ops {
44703 void (*target_send_suspend_complete)(struct ath10k *ar);
44704 -};
44705 +} __no_const;
44706
44707 struct ath10k_htc_ep_ops {
44708 void (*ep_tx_complete)(struct ath10k *, struct sk_buff *);
44709 void (*ep_rx_complete)(struct ath10k *, struct sk_buff *);
44710 -};
44711 +} __no_const;
44712
44713 /* service connection information */
44714 struct ath10k_htc_svc_conn_req {
44715 diff --git a/drivers/net/wireless/ath/ath9k/ar9002_mac.c b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
44716 index 8d78253..bebbb68 100644
44717 --- a/drivers/net/wireless/ath/ath9k/ar9002_mac.c
44718 +++ b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
44719 @@ -184,8 +184,8 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44720 ads->ds_txstatus6 = ads->ds_txstatus7 = 0;
44721 ads->ds_txstatus8 = ads->ds_txstatus9 = 0;
44722
44723 - ACCESS_ONCE(ads->ds_link) = i->link;
44724 - ACCESS_ONCE(ads->ds_data) = i->buf_addr[0];
44725 + ACCESS_ONCE_RW(ads->ds_link) = i->link;
44726 + ACCESS_ONCE_RW(ads->ds_data) = i->buf_addr[0];
44727
44728 ctl1 = i->buf_len[0] | (i->is_last ? 0 : AR_TxMore);
44729 ctl6 = SM(i->keytype, AR_EncrType);
44730 @@ -199,26 +199,26 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44731
44732 if ((i->is_first || i->is_last) &&
44733 i->aggr != AGGR_BUF_MIDDLE && i->aggr != AGGR_BUF_LAST) {
44734 - ACCESS_ONCE(ads->ds_ctl2) = set11nTries(i->rates, 0)
44735 + ACCESS_ONCE_RW(ads->ds_ctl2) = set11nTries(i->rates, 0)
44736 | set11nTries(i->rates, 1)
44737 | set11nTries(i->rates, 2)
44738 | set11nTries(i->rates, 3)
44739 | (i->dur_update ? AR_DurUpdateEna : 0)
44740 | SM(0, AR_BurstDur);
44741
44742 - ACCESS_ONCE(ads->ds_ctl3) = set11nRate(i->rates, 0)
44743 + ACCESS_ONCE_RW(ads->ds_ctl3) = set11nRate(i->rates, 0)
44744 | set11nRate(i->rates, 1)
44745 | set11nRate(i->rates, 2)
44746 | set11nRate(i->rates, 3);
44747 } else {
44748 - ACCESS_ONCE(ads->ds_ctl2) = 0;
44749 - ACCESS_ONCE(ads->ds_ctl3) = 0;
44750 + ACCESS_ONCE_RW(ads->ds_ctl2) = 0;
44751 + ACCESS_ONCE_RW(ads->ds_ctl3) = 0;
44752 }
44753
44754 if (!i->is_first) {
44755 - ACCESS_ONCE(ads->ds_ctl0) = 0;
44756 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
44757 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
44758 + ACCESS_ONCE_RW(ads->ds_ctl0) = 0;
44759 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
44760 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
44761 return;
44762 }
44763
44764 @@ -243,7 +243,7 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44765 break;
44766 }
44767
44768 - ACCESS_ONCE(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
44769 + ACCESS_ONCE_RW(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
44770 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
44771 | SM(i->txpower, AR_XmitPower)
44772 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
44773 @@ -253,19 +253,19 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44774 | (i->flags & ATH9K_TXDESC_RTSENA ? AR_RTSEnable :
44775 (i->flags & ATH9K_TXDESC_CTSENA ? AR_CTSEnable : 0));
44776
44777 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
44778 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
44779 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
44780 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
44781
44782 if (i->aggr == AGGR_BUF_MIDDLE || i->aggr == AGGR_BUF_LAST)
44783 return;
44784
44785 - ACCESS_ONCE(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
44786 + ACCESS_ONCE_RW(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
44787 | set11nPktDurRTSCTS(i->rates, 1);
44788
44789 - ACCESS_ONCE(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
44790 + ACCESS_ONCE_RW(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
44791 | set11nPktDurRTSCTS(i->rates, 3);
44792
44793 - ACCESS_ONCE(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
44794 + ACCESS_ONCE_RW(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
44795 | set11nRateFlags(i->rates, 1)
44796 | set11nRateFlags(i->rates, 2)
44797 | set11nRateFlags(i->rates, 3)
44798 diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mac.c b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
44799 index f6c5c1b..6058354 100644
44800 --- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c
44801 +++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
44802 @@ -39,47 +39,47 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44803 (i->qcu << AR_TxQcuNum_S) | desc_len;
44804
44805 checksum += val;
44806 - ACCESS_ONCE(ads->info) = val;
44807 + ACCESS_ONCE_RW(ads->info) = val;
44808
44809 checksum += i->link;
44810 - ACCESS_ONCE(ads->link) = i->link;
44811 + ACCESS_ONCE_RW(ads->link) = i->link;
44812
44813 checksum += i->buf_addr[0];
44814 - ACCESS_ONCE(ads->data0) = i->buf_addr[0];
44815 + ACCESS_ONCE_RW(ads->data0) = i->buf_addr[0];
44816 checksum += i->buf_addr[1];
44817 - ACCESS_ONCE(ads->data1) = i->buf_addr[1];
44818 + ACCESS_ONCE_RW(ads->data1) = i->buf_addr[1];
44819 checksum += i->buf_addr[2];
44820 - ACCESS_ONCE(ads->data2) = i->buf_addr[2];
44821 + ACCESS_ONCE_RW(ads->data2) = i->buf_addr[2];
44822 checksum += i->buf_addr[3];
44823 - ACCESS_ONCE(ads->data3) = i->buf_addr[3];
44824 + ACCESS_ONCE_RW(ads->data3) = i->buf_addr[3];
44825
44826 checksum += (val = (i->buf_len[0] << AR_BufLen_S) & AR_BufLen);
44827 - ACCESS_ONCE(ads->ctl3) = val;
44828 + ACCESS_ONCE_RW(ads->ctl3) = val;
44829 checksum += (val = (i->buf_len[1] << AR_BufLen_S) & AR_BufLen);
44830 - ACCESS_ONCE(ads->ctl5) = val;
44831 + ACCESS_ONCE_RW(ads->ctl5) = val;
44832 checksum += (val = (i->buf_len[2] << AR_BufLen_S) & AR_BufLen);
44833 - ACCESS_ONCE(ads->ctl7) = val;
44834 + ACCESS_ONCE_RW(ads->ctl7) = val;
44835 checksum += (val = (i->buf_len[3] << AR_BufLen_S) & AR_BufLen);
44836 - ACCESS_ONCE(ads->ctl9) = val;
44837 + ACCESS_ONCE_RW(ads->ctl9) = val;
44838
44839 checksum = (u16) (((checksum & 0xffff) + (checksum >> 16)) & 0xffff);
44840 - ACCESS_ONCE(ads->ctl10) = checksum;
44841 + ACCESS_ONCE_RW(ads->ctl10) = checksum;
44842
44843 if (i->is_first || i->is_last) {
44844 - ACCESS_ONCE(ads->ctl13) = set11nTries(i->rates, 0)
44845 + ACCESS_ONCE_RW(ads->ctl13) = set11nTries(i->rates, 0)
44846 | set11nTries(i->rates, 1)
44847 | set11nTries(i->rates, 2)
44848 | set11nTries(i->rates, 3)
44849 | (i->dur_update ? AR_DurUpdateEna : 0)
44850 | SM(0, AR_BurstDur);
44851
44852 - ACCESS_ONCE(ads->ctl14) = set11nRate(i->rates, 0)
44853 + ACCESS_ONCE_RW(ads->ctl14) = set11nRate(i->rates, 0)
44854 | set11nRate(i->rates, 1)
44855 | set11nRate(i->rates, 2)
44856 | set11nRate(i->rates, 3);
44857 } else {
44858 - ACCESS_ONCE(ads->ctl13) = 0;
44859 - ACCESS_ONCE(ads->ctl14) = 0;
44860 + ACCESS_ONCE_RW(ads->ctl13) = 0;
44861 + ACCESS_ONCE_RW(ads->ctl14) = 0;
44862 }
44863
44864 ads->ctl20 = 0;
44865 @@ -89,17 +89,17 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44866
44867 ctl17 = SM(i->keytype, AR_EncrType);
44868 if (!i->is_first) {
44869 - ACCESS_ONCE(ads->ctl11) = 0;
44870 - ACCESS_ONCE(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
44871 - ACCESS_ONCE(ads->ctl15) = 0;
44872 - ACCESS_ONCE(ads->ctl16) = 0;
44873 - ACCESS_ONCE(ads->ctl17) = ctl17;
44874 - ACCESS_ONCE(ads->ctl18) = 0;
44875 - ACCESS_ONCE(ads->ctl19) = 0;
44876 + ACCESS_ONCE_RW(ads->ctl11) = 0;
44877 + ACCESS_ONCE_RW(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
44878 + ACCESS_ONCE_RW(ads->ctl15) = 0;
44879 + ACCESS_ONCE_RW(ads->ctl16) = 0;
44880 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
44881 + ACCESS_ONCE_RW(ads->ctl18) = 0;
44882 + ACCESS_ONCE_RW(ads->ctl19) = 0;
44883 return;
44884 }
44885
44886 - ACCESS_ONCE(ads->ctl11) = (i->pkt_len & AR_FrameLen)
44887 + ACCESS_ONCE_RW(ads->ctl11) = (i->pkt_len & AR_FrameLen)
44888 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
44889 | SM(i->txpower, AR_XmitPower)
44890 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
44891 @@ -135,22 +135,22 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44892 val = (i->flags & ATH9K_TXDESC_PAPRD) >> ATH9K_TXDESC_PAPRD_S;
44893 ctl12 |= SM(val, AR_PAPRDChainMask);
44894
44895 - ACCESS_ONCE(ads->ctl12) = ctl12;
44896 - ACCESS_ONCE(ads->ctl17) = ctl17;
44897 + ACCESS_ONCE_RW(ads->ctl12) = ctl12;
44898 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
44899
44900 - ACCESS_ONCE(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
44901 + ACCESS_ONCE_RW(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
44902 | set11nPktDurRTSCTS(i->rates, 1);
44903
44904 - ACCESS_ONCE(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
44905 + ACCESS_ONCE_RW(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
44906 | set11nPktDurRTSCTS(i->rates, 3);
44907
44908 - ACCESS_ONCE(ads->ctl18) = set11nRateFlags(i->rates, 0)
44909 + ACCESS_ONCE_RW(ads->ctl18) = set11nRateFlags(i->rates, 0)
44910 | set11nRateFlags(i->rates, 1)
44911 | set11nRateFlags(i->rates, 2)
44912 | set11nRateFlags(i->rates, 3)
44913 | SM(i->rtscts_rate, AR_RTSCTSRate);
44914
44915 - ACCESS_ONCE(ads->ctl19) = AR_Not_Sounding;
44916 + ACCESS_ONCE_RW(ads->ctl19) = AR_Not_Sounding;
44917 }
44918
44919 static u16 ar9003_calc_ptr_chksum(struct ar9003_txc *ads)
44920 diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
44921 index 69a907b..91e071c 100644
44922 --- a/drivers/net/wireless/ath/ath9k/hw.h
44923 +++ b/drivers/net/wireless/ath/ath9k/hw.h
44924 @@ -657,7 +657,7 @@ struct ath_hw_private_ops {
44925
44926 /* ANI */
44927 void (*ani_cache_ini_regs)(struct ath_hw *ah);
44928 -};
44929 +} __no_const;
44930
44931 /**
44932 * struct ath_spec_scan - parameters for Atheros spectral scan
44933 @@ -729,7 +729,7 @@ struct ath_hw_ops {
44934 #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT
44935 void (*set_bt_ant_diversity)(struct ath_hw *hw, bool enable);
44936 #endif
44937 -};
44938 +} __no_const;
44939
44940 struct ath_nf_limits {
44941 s16 max;
44942 diff --git a/drivers/net/wireless/b43/phy_lp.c b/drivers/net/wireless/b43/phy_lp.c
44943 index 92190da..f3a4c4c 100644
44944 --- a/drivers/net/wireless/b43/phy_lp.c
44945 +++ b/drivers/net/wireless/b43/phy_lp.c
44946 @@ -2514,7 +2514,7 @@ static int lpphy_b2063_tune(struct b43_wldev *dev,
44947 {
44948 struct ssb_bus *bus = dev->dev->sdev->bus;
44949
44950 - static const struct b206x_channel *chandata = NULL;
44951 + const struct b206x_channel *chandata = NULL;
44952 u32 crystal_freq = bus->chipco.pmu.crystalfreq * 1000;
44953 u32 freqref, vco_freq, val1, val2, val3, timeout, timeoutref, count;
44954 u16 old_comm15, scale;
44955 diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c
44956 index 9581d07..84f6a76 100644
44957 --- a/drivers/net/wireless/iwlegacy/3945-mac.c
44958 +++ b/drivers/net/wireless/iwlegacy/3945-mac.c
44959 @@ -3639,7 +3639,9 @@ il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
44960 */
44961 if (il3945_mod_params.disable_hw_scan) {
44962 D_INFO("Disabling hw_scan\n");
44963 - il3945_mac_ops.hw_scan = NULL;
44964 + pax_open_kernel();
44965 + *(void **)&il3945_mac_ops.hw_scan = NULL;
44966 + pax_close_kernel();
44967 }
44968
44969 D_INFO("*** LOAD DRIVER ***\n");
44970 diff --git a/drivers/net/wireless/iwlwifi/dvm/debugfs.c b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
44971 index d94f8ab..5b568c8 100644
44972 --- a/drivers/net/wireless/iwlwifi/dvm/debugfs.c
44973 +++ b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
44974 @@ -188,7 +188,7 @@ static ssize_t iwl_dbgfs_sram_write(struct file *file,
44975 {
44976 struct iwl_priv *priv = file->private_data;
44977 char buf[64];
44978 - int buf_size;
44979 + size_t buf_size;
44980 u32 offset, len;
44981
44982 memset(buf, 0, sizeof(buf));
44983 @@ -458,7 +458,7 @@ static ssize_t iwl_dbgfs_rx_handlers_write(struct file *file,
44984 struct iwl_priv *priv = file->private_data;
44985
44986 char buf[8];
44987 - int buf_size;
44988 + size_t buf_size;
44989 u32 reset_flag;
44990
44991 memset(buf, 0, sizeof(buf));
44992 @@ -539,7 +539,7 @@ static ssize_t iwl_dbgfs_disable_ht40_write(struct file *file,
44993 {
44994 struct iwl_priv *priv = file->private_data;
44995 char buf[8];
44996 - int buf_size;
44997 + size_t buf_size;
44998 int ht40;
44999
45000 memset(buf, 0, sizeof(buf));
45001 @@ -591,7 +591,7 @@ static ssize_t iwl_dbgfs_sleep_level_override_write(struct file *file,
45002 {
45003 struct iwl_priv *priv = file->private_data;
45004 char buf[8];
45005 - int buf_size;
45006 + size_t buf_size;
45007 int value;
45008
45009 memset(buf, 0, sizeof(buf));
45010 @@ -683,10 +683,10 @@ DEBUGFS_READ_FILE_OPS(temperature);
45011 DEBUGFS_READ_WRITE_FILE_OPS(sleep_level_override);
45012 DEBUGFS_READ_FILE_OPS(current_sleep_command);
45013
45014 -static const char *fmt_value = " %-30s %10u\n";
45015 -static const char *fmt_hex = " %-30s 0x%02X\n";
45016 -static const char *fmt_table = " %-30s %10u %10u %10u %10u\n";
45017 -static const char *fmt_header =
45018 +static const char fmt_value[] = " %-30s %10u\n";
45019 +static const char fmt_hex[] = " %-30s 0x%02X\n";
45020 +static const char fmt_table[] = " %-30s %10u %10u %10u %10u\n";
45021 +static const char fmt_header[] =
45022 "%-32s current cumulative delta max\n";
45023
45024 static int iwl_statistics_flag(struct iwl_priv *priv, char *buf, int bufsz)
45025 @@ -1856,7 +1856,7 @@ static ssize_t iwl_dbgfs_clear_ucode_statistics_write(struct file *file,
45026 {
45027 struct iwl_priv *priv = file->private_data;
45028 char buf[8];
45029 - int buf_size;
45030 + size_t buf_size;
45031 int clear;
45032
45033 memset(buf, 0, sizeof(buf));
45034 @@ -1901,7 +1901,7 @@ static ssize_t iwl_dbgfs_ucode_tracing_write(struct file *file,
45035 {
45036 struct iwl_priv *priv = file->private_data;
45037 char buf[8];
45038 - int buf_size;
45039 + size_t buf_size;
45040 int trace;
45041
45042 memset(buf, 0, sizeof(buf));
45043 @@ -1972,7 +1972,7 @@ static ssize_t iwl_dbgfs_missed_beacon_write(struct file *file,
45044 {
45045 struct iwl_priv *priv = file->private_data;
45046 char buf[8];
45047 - int buf_size;
45048 + size_t buf_size;
45049 int missed;
45050
45051 memset(buf, 0, sizeof(buf));
45052 @@ -2013,7 +2013,7 @@ static ssize_t iwl_dbgfs_plcp_delta_write(struct file *file,
45053
45054 struct iwl_priv *priv = file->private_data;
45055 char buf[8];
45056 - int buf_size;
45057 + size_t buf_size;
45058 int plcp;
45059
45060 memset(buf, 0, sizeof(buf));
45061 @@ -2073,7 +2073,7 @@ static ssize_t iwl_dbgfs_txfifo_flush_write(struct file *file,
45062
45063 struct iwl_priv *priv = file->private_data;
45064 char buf[8];
45065 - int buf_size;
45066 + size_t buf_size;
45067 int flush;
45068
45069 memset(buf, 0, sizeof(buf));
45070 @@ -2163,7 +2163,7 @@ static ssize_t iwl_dbgfs_protection_mode_write(struct file *file,
45071
45072 struct iwl_priv *priv = file->private_data;
45073 char buf[8];
45074 - int buf_size;
45075 + size_t buf_size;
45076 int rts;
45077
45078 if (!priv->cfg->ht_params)
45079 @@ -2205,7 +2205,7 @@ static ssize_t iwl_dbgfs_echo_test_write(struct file *file,
45080 {
45081 struct iwl_priv *priv = file->private_data;
45082 char buf[8];
45083 - int buf_size;
45084 + size_t buf_size;
45085
45086 memset(buf, 0, sizeof(buf));
45087 buf_size = min(count, sizeof(buf) - 1);
45088 @@ -2239,7 +2239,7 @@ static ssize_t iwl_dbgfs_log_event_write(struct file *file,
45089 struct iwl_priv *priv = file->private_data;
45090 u32 event_log_flag;
45091 char buf[8];
45092 - int buf_size;
45093 + size_t buf_size;
45094
45095 /* check that the interface is up */
45096 if (!iwl_is_ready(priv))
45097 @@ -2293,7 +2293,7 @@ static ssize_t iwl_dbgfs_calib_disabled_write(struct file *file,
45098 struct iwl_priv *priv = file->private_data;
45099 char buf[8];
45100 u32 calib_disabled;
45101 - int buf_size;
45102 + size_t buf_size;
45103
45104 memset(buf, 0, sizeof(buf));
45105 buf_size = min(count, sizeof(buf) - 1);
45106 diff --git a/drivers/net/wireless/iwlwifi/dvm/main.c b/drivers/net/wireless/iwlwifi/dvm/main.c
45107 index 7aad766..06addb4 100644
45108 --- a/drivers/net/wireless/iwlwifi/dvm/main.c
45109 +++ b/drivers/net/wireless/iwlwifi/dvm/main.c
45110 @@ -1123,7 +1123,7 @@ static void iwl_option_config(struct iwl_priv *priv)
45111 static int iwl_eeprom_init_hw_params(struct iwl_priv *priv)
45112 {
45113 struct iwl_nvm_data *data = priv->nvm_data;
45114 - char *debug_msg;
45115 + static const char debug_msg[] = "Device SKU: 24GHz %s %s, 52GHz %s %s, 11.n %s %s\n";
45116
45117 if (data->sku_cap_11n_enable &&
45118 !priv->cfg->ht_params) {
45119 @@ -1137,7 +1137,6 @@ static int iwl_eeprom_init_hw_params(struct iwl_priv *priv)
45120 return -EINVAL;
45121 }
45122
45123 - debug_msg = "Device SKU: 24GHz %s %s, 52GHz %s %s, 11.n %s %s\n";
45124 IWL_DEBUG_INFO(priv, debug_msg,
45125 data->sku_cap_band_24GHz_enable ? "" : "NOT", "enabled",
45126 data->sku_cap_band_52GHz_enable ? "" : "NOT", "enabled",
45127 diff --git a/drivers/net/wireless/iwlwifi/pcie/trans.c b/drivers/net/wireless/iwlwifi/pcie/trans.c
45128 index 6bc3100..dd1b80d 100644
45129 --- a/drivers/net/wireless/iwlwifi/pcie/trans.c
45130 +++ b/drivers/net/wireless/iwlwifi/pcie/trans.c
45131 @@ -1249,7 +1249,7 @@ static ssize_t iwl_dbgfs_interrupt_write(struct file *file,
45132 struct isr_statistics *isr_stats = &trans_pcie->isr_stats;
45133
45134 char buf[8];
45135 - int buf_size;
45136 + size_t buf_size;
45137 u32 reset_flag;
45138
45139 memset(buf, 0, sizeof(buf));
45140 @@ -1270,7 +1270,7 @@ static ssize_t iwl_dbgfs_csr_write(struct file *file,
45141 {
45142 struct iwl_trans *trans = file->private_data;
45143 char buf[8];
45144 - int buf_size;
45145 + size_t buf_size;
45146 int csr;
45147
45148 memset(buf, 0, sizeof(buf));
45149 diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
45150 index 2cd3f54..e936f90 100644
45151 --- a/drivers/net/wireless/mac80211_hwsim.c
45152 +++ b/drivers/net/wireless/mac80211_hwsim.c
45153 @@ -2196,25 +2196,19 @@ static int __init init_mac80211_hwsim(void)
45154
45155 if (channels > 1) {
45156 hwsim_if_comb.num_different_channels = channels;
45157 - mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
45158 - mac80211_hwsim_ops.cancel_hw_scan =
45159 - mac80211_hwsim_cancel_hw_scan;
45160 - mac80211_hwsim_ops.sw_scan_start = NULL;
45161 - mac80211_hwsim_ops.sw_scan_complete = NULL;
45162 - mac80211_hwsim_ops.remain_on_channel =
45163 - mac80211_hwsim_roc;
45164 - mac80211_hwsim_ops.cancel_remain_on_channel =
45165 - mac80211_hwsim_croc;
45166 - mac80211_hwsim_ops.add_chanctx =
45167 - mac80211_hwsim_add_chanctx;
45168 - mac80211_hwsim_ops.remove_chanctx =
45169 - mac80211_hwsim_remove_chanctx;
45170 - mac80211_hwsim_ops.change_chanctx =
45171 - mac80211_hwsim_change_chanctx;
45172 - mac80211_hwsim_ops.assign_vif_chanctx =
45173 - mac80211_hwsim_assign_vif_chanctx;
45174 - mac80211_hwsim_ops.unassign_vif_chanctx =
45175 - mac80211_hwsim_unassign_vif_chanctx;
45176 + pax_open_kernel();
45177 + *(void **)&mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
45178 + *(void **)&mac80211_hwsim_ops.cancel_hw_scan = mac80211_hwsim_cancel_hw_scan;
45179 + *(void **)&mac80211_hwsim_ops.sw_scan_start = NULL;
45180 + *(void **)&mac80211_hwsim_ops.sw_scan_complete = NULL;
45181 + *(void **)&mac80211_hwsim_ops.remain_on_channel = mac80211_hwsim_roc;
45182 + *(void **)&mac80211_hwsim_ops.cancel_remain_on_channel = mac80211_hwsim_croc;
45183 + *(void **)&mac80211_hwsim_ops.add_chanctx = mac80211_hwsim_add_chanctx;
45184 + *(void **)&mac80211_hwsim_ops.remove_chanctx = mac80211_hwsim_remove_chanctx;
45185 + *(void **)&mac80211_hwsim_ops.change_chanctx = mac80211_hwsim_change_chanctx;
45186 + *(void **)&mac80211_hwsim_ops.assign_vif_chanctx = mac80211_hwsim_assign_vif_chanctx;
45187 + *(void **)&mac80211_hwsim_ops.unassign_vif_chanctx = mac80211_hwsim_unassign_vif_chanctx;
45188 + pax_close_kernel();
45189 }
45190
45191 spin_lock_init(&hwsim_radio_lock);
45192 diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
45193 index 8169a85..7fa3b47 100644
45194 --- a/drivers/net/wireless/rndis_wlan.c
45195 +++ b/drivers/net/wireless/rndis_wlan.c
45196 @@ -1238,7 +1238,7 @@ static int set_rts_threshold(struct usbnet *usbdev, u32 rts_threshold)
45197
45198 netdev_dbg(usbdev->net, "%s(): %i\n", __func__, rts_threshold);
45199
45200 - if (rts_threshold < 0 || rts_threshold > 2347)
45201 + if (rts_threshold > 2347)
45202 rts_threshold = 2347;
45203
45204 tmp = cpu_to_le32(rts_threshold);
45205 diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
45206 index fe4c572..99dedfa 100644
45207 --- a/drivers/net/wireless/rt2x00/rt2x00.h
45208 +++ b/drivers/net/wireless/rt2x00/rt2x00.h
45209 @@ -387,7 +387,7 @@ struct rt2x00_intf {
45210 * for hardware which doesn't support hardware
45211 * sequence counting.
45212 */
45213 - atomic_t seqno;
45214 + atomic_unchecked_t seqno;
45215 };
45216
45217 static inline struct rt2x00_intf* vif_to_intf(struct ieee80211_vif *vif)
45218 diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c
45219 index 66a2db8..70cad04 100644
45220 --- a/drivers/net/wireless/rt2x00/rt2x00queue.c
45221 +++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
45222 @@ -252,9 +252,9 @@ static void rt2x00queue_create_tx_descriptor_seq(struct rt2x00_dev *rt2x00dev,
45223 * sequence counter given by mac80211.
45224 */
45225 if (test_bit(ENTRY_TXD_FIRST_FRAGMENT, &txdesc->flags))
45226 - seqno = atomic_add_return(0x10, &intf->seqno);
45227 + seqno = atomic_add_return_unchecked(0x10, &intf->seqno);
45228 else
45229 - seqno = atomic_read(&intf->seqno);
45230 + seqno = atomic_read_unchecked(&intf->seqno);
45231
45232 hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG);
45233 hdr->seq_ctrl |= cpu_to_le16(seqno);
45234 diff --git a/drivers/net/wireless/ti/wl1251/sdio.c b/drivers/net/wireless/ti/wl1251/sdio.c
45235 index e2b3d9c..67a5184 100644
45236 --- a/drivers/net/wireless/ti/wl1251/sdio.c
45237 +++ b/drivers/net/wireless/ti/wl1251/sdio.c
45238 @@ -271,13 +271,17 @@ static int wl1251_sdio_probe(struct sdio_func *func,
45239
45240 irq_set_irq_type(wl->irq, IRQ_TYPE_EDGE_RISING);
45241
45242 - wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
45243 - wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
45244 + pax_open_kernel();
45245 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
45246 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
45247 + pax_close_kernel();
45248
45249 wl1251_info("using dedicated interrupt line");
45250 } else {
45251 - wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
45252 - wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
45253 + pax_open_kernel();
45254 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
45255 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
45256 + pax_close_kernel();
45257
45258 wl1251_info("using SDIO interrupt");
45259 }
45260 diff --git a/drivers/net/wireless/ti/wl12xx/main.c b/drivers/net/wireless/ti/wl12xx/main.c
45261 index 1c627da..69f7d17 100644
45262 --- a/drivers/net/wireless/ti/wl12xx/main.c
45263 +++ b/drivers/net/wireless/ti/wl12xx/main.c
45264 @@ -656,7 +656,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
45265 sizeof(wl->conf.mem));
45266
45267 /* read data preparation is only needed by wl127x */
45268 - wl->ops->prepare_read = wl127x_prepare_read;
45269 + pax_open_kernel();
45270 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
45271 + pax_close_kernel();
45272
45273 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER,
45274 WL127X_IFTYPE_SR_VER, WL127X_MAJOR_SR_VER,
45275 @@ -681,7 +683,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
45276 sizeof(wl->conf.mem));
45277
45278 /* read data preparation is only needed by wl127x */
45279 - wl->ops->prepare_read = wl127x_prepare_read;
45280 + pax_open_kernel();
45281 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
45282 + pax_close_kernel();
45283
45284 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER,
45285 WL127X_IFTYPE_SR_VER, WL127X_MAJOR_SR_VER,
45286 diff --git a/drivers/net/wireless/ti/wl18xx/main.c b/drivers/net/wireless/ti/wl18xx/main.c
45287 index 7aa0eb8..5a9ef38 100644
45288 --- a/drivers/net/wireless/ti/wl18xx/main.c
45289 +++ b/drivers/net/wireless/ti/wl18xx/main.c
45290 @@ -1730,8 +1730,10 @@ static int wl18xx_setup(struct wl1271 *wl)
45291 }
45292
45293 if (!checksum_param) {
45294 - wl18xx_ops.set_rx_csum = NULL;
45295 - wl18xx_ops.init_vif = NULL;
45296 + pax_open_kernel();
45297 + *(void **)&wl18xx_ops.set_rx_csum = NULL;
45298 + *(void **)&wl18xx_ops.init_vif = NULL;
45299 + pax_close_kernel();
45300 }
45301
45302 /* Enable 11a Band only if we have 5G antennas */
45303 diff --git a/drivers/net/wireless/zd1211rw/zd_usb.c b/drivers/net/wireless/zd1211rw/zd_usb.c
45304 index 7ef0b4a..ff65c28 100644
45305 --- a/drivers/net/wireless/zd1211rw/zd_usb.c
45306 +++ b/drivers/net/wireless/zd1211rw/zd_usb.c
45307 @@ -386,7 +386,7 @@ static inline void handle_regs_int(struct urb *urb)
45308 {
45309 struct zd_usb *usb = urb->context;
45310 struct zd_usb_interrupt *intr = &usb->intr;
45311 - int len;
45312 + unsigned int len;
45313 u16 int_num;
45314
45315 ZD_ASSERT(in_interrupt());
45316 diff --git a/drivers/nfc/nfcwilink.c b/drivers/nfc/nfcwilink.c
45317 index 59f95d8..53e0e7f 100644
45318 --- a/drivers/nfc/nfcwilink.c
45319 +++ b/drivers/nfc/nfcwilink.c
45320 @@ -513,7 +513,7 @@ static struct nci_ops nfcwilink_ops = {
45321
45322 static int nfcwilink_probe(struct platform_device *pdev)
45323 {
45324 - static struct nfcwilink *drv;
45325 + struct nfcwilink *drv;
45326 int rc;
45327 __u32 protocols;
45328
45329 diff --git a/drivers/oprofile/buffer_sync.c b/drivers/oprofile/buffer_sync.c
45330 index d93b2b6..ae50401 100644
45331 --- a/drivers/oprofile/buffer_sync.c
45332 +++ b/drivers/oprofile/buffer_sync.c
45333 @@ -332,7 +332,7 @@ static void add_data(struct op_entry *entry, struct mm_struct *mm)
45334 if (cookie == NO_COOKIE)
45335 offset = pc;
45336 if (cookie == INVALID_COOKIE) {
45337 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
45338 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
45339 offset = pc;
45340 }
45341 if (cookie != last_cookie) {
45342 @@ -376,14 +376,14 @@ add_sample(struct mm_struct *mm, struct op_sample *s, int in_kernel)
45343 /* add userspace sample */
45344
45345 if (!mm) {
45346 - atomic_inc(&oprofile_stats.sample_lost_no_mm);
45347 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mm);
45348 return 0;
45349 }
45350
45351 cookie = lookup_dcookie(mm, s->eip, &offset);
45352
45353 if (cookie == INVALID_COOKIE) {
45354 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
45355 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
45356 return 0;
45357 }
45358
45359 @@ -552,7 +552,7 @@ void sync_buffer(int cpu)
45360 /* ignore backtraces if failed to add a sample */
45361 if (state == sb_bt_start) {
45362 state = sb_bt_ignore;
45363 - atomic_inc(&oprofile_stats.bt_lost_no_mapping);
45364 + atomic_inc_unchecked(&oprofile_stats.bt_lost_no_mapping);
45365 }
45366 }
45367 release_mm(mm);
45368 diff --git a/drivers/oprofile/event_buffer.c b/drivers/oprofile/event_buffer.c
45369 index c0cc4e7..44d4e54 100644
45370 --- a/drivers/oprofile/event_buffer.c
45371 +++ b/drivers/oprofile/event_buffer.c
45372 @@ -53,7 +53,7 @@ void add_event_entry(unsigned long value)
45373 }
45374
45375 if (buffer_pos == buffer_size) {
45376 - atomic_inc(&oprofile_stats.event_lost_overflow);
45377 + atomic_inc_unchecked(&oprofile_stats.event_lost_overflow);
45378 return;
45379 }
45380
45381 diff --git a/drivers/oprofile/oprof.c b/drivers/oprofile/oprof.c
45382 index ed2c3ec..deda85a 100644
45383 --- a/drivers/oprofile/oprof.c
45384 +++ b/drivers/oprofile/oprof.c
45385 @@ -110,7 +110,7 @@ static void switch_worker(struct work_struct *work)
45386 if (oprofile_ops.switch_events())
45387 return;
45388
45389 - atomic_inc(&oprofile_stats.multiplex_counter);
45390 + atomic_inc_unchecked(&oprofile_stats.multiplex_counter);
45391 start_switch_worker();
45392 }
45393
45394 diff --git a/drivers/oprofile/oprofile_files.c b/drivers/oprofile/oprofile_files.c
45395 index ee2cfce..7f8f699 100644
45396 --- a/drivers/oprofile/oprofile_files.c
45397 +++ b/drivers/oprofile/oprofile_files.c
45398 @@ -27,7 +27,7 @@ unsigned long oprofile_time_slice;
45399
45400 #ifdef CONFIG_OPROFILE_EVENT_MULTIPLEX
45401
45402 -static ssize_t timeout_read(struct file *file, char __user *buf,
45403 +static ssize_t __intentional_overflow(-1) timeout_read(struct file *file, char __user *buf,
45404 size_t count, loff_t *offset)
45405 {
45406 return oprofilefs_ulong_to_user(jiffies_to_msecs(oprofile_time_slice),
45407 diff --git a/drivers/oprofile/oprofile_stats.c b/drivers/oprofile/oprofile_stats.c
45408 index 59659ce..6c860a0 100644
45409 --- a/drivers/oprofile/oprofile_stats.c
45410 +++ b/drivers/oprofile/oprofile_stats.c
45411 @@ -30,11 +30,11 @@ void oprofile_reset_stats(void)
45412 cpu_buf->sample_invalid_eip = 0;
45413 }
45414
45415 - atomic_set(&oprofile_stats.sample_lost_no_mm, 0);
45416 - atomic_set(&oprofile_stats.sample_lost_no_mapping, 0);
45417 - atomic_set(&oprofile_stats.event_lost_overflow, 0);
45418 - atomic_set(&oprofile_stats.bt_lost_no_mapping, 0);
45419 - atomic_set(&oprofile_stats.multiplex_counter, 0);
45420 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mm, 0);
45421 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mapping, 0);
45422 + atomic_set_unchecked(&oprofile_stats.event_lost_overflow, 0);
45423 + atomic_set_unchecked(&oprofile_stats.bt_lost_no_mapping, 0);
45424 + atomic_set_unchecked(&oprofile_stats.multiplex_counter, 0);
45425 }
45426
45427
45428 diff --git a/drivers/oprofile/oprofile_stats.h b/drivers/oprofile/oprofile_stats.h
45429 index 1fc622b..8c48fc3 100644
45430 --- a/drivers/oprofile/oprofile_stats.h
45431 +++ b/drivers/oprofile/oprofile_stats.h
45432 @@ -13,11 +13,11 @@
45433 #include <linux/atomic.h>
45434
45435 struct oprofile_stat_struct {
45436 - atomic_t sample_lost_no_mm;
45437 - atomic_t sample_lost_no_mapping;
45438 - atomic_t bt_lost_no_mapping;
45439 - atomic_t event_lost_overflow;
45440 - atomic_t multiplex_counter;
45441 + atomic_unchecked_t sample_lost_no_mm;
45442 + atomic_unchecked_t sample_lost_no_mapping;
45443 + atomic_unchecked_t bt_lost_no_mapping;
45444 + atomic_unchecked_t event_lost_overflow;
45445 + atomic_unchecked_t multiplex_counter;
45446 };
45447
45448 extern struct oprofile_stat_struct oprofile_stats;
45449 diff --git a/drivers/oprofile/oprofilefs.c b/drivers/oprofile/oprofilefs.c
45450 index 3f49345..c750d0b 100644
45451 --- a/drivers/oprofile/oprofilefs.c
45452 +++ b/drivers/oprofile/oprofilefs.c
45453 @@ -176,8 +176,8 @@ int oprofilefs_create_ro_ulong(struct dentry *root,
45454
45455 static ssize_t atomic_read_file(struct file *file, char __user *buf, size_t count, loff_t *offset)
45456 {
45457 - atomic_t *val = file->private_data;
45458 - return oprofilefs_ulong_to_user(atomic_read(val), buf, count, offset);
45459 + atomic_unchecked_t *val = file->private_data;
45460 + return oprofilefs_ulong_to_user(atomic_read_unchecked(val), buf, count, offset);
45461 }
45462
45463
45464 @@ -189,7 +189,7 @@ static const struct file_operations atomic_ro_fops = {
45465
45466
45467 int oprofilefs_create_ro_atomic(struct dentry *root,
45468 - char const *name, atomic_t *val)
45469 + char const *name, atomic_unchecked_t *val)
45470 {
45471 return __oprofilefs_create_file(root, name,
45472 &atomic_ro_fops, 0444, val);
45473 diff --git a/drivers/oprofile/timer_int.c b/drivers/oprofile/timer_int.c
45474 index 61be1d9..dec05d7 100644
45475 --- a/drivers/oprofile/timer_int.c
45476 +++ b/drivers/oprofile/timer_int.c
45477 @@ -93,7 +93,7 @@ static int oprofile_cpu_notify(struct notifier_block *self,
45478 return NOTIFY_OK;
45479 }
45480
45481 -static struct notifier_block __refdata oprofile_cpu_notifier = {
45482 +static struct notifier_block oprofile_cpu_notifier = {
45483 .notifier_call = oprofile_cpu_notify,
45484 };
45485
45486 diff --git a/drivers/parport/procfs.c b/drivers/parport/procfs.c
45487 index 92ed045..62d39bd7 100644
45488 --- a/drivers/parport/procfs.c
45489 +++ b/drivers/parport/procfs.c
45490 @@ -64,7 +64,7 @@ static int do_active_device(ctl_table *table, int write,
45491
45492 *ppos += len;
45493
45494 - return copy_to_user(result, buffer, len) ? -EFAULT : 0;
45495 + return (len > sizeof buffer || copy_to_user(result, buffer, len)) ? -EFAULT : 0;
45496 }
45497
45498 #ifdef CONFIG_PARPORT_1284
45499 @@ -106,7 +106,7 @@ static int do_autoprobe(ctl_table *table, int write,
45500
45501 *ppos += len;
45502
45503 - return copy_to_user (result, buffer, len) ? -EFAULT : 0;
45504 + return (len > sizeof buffer || copy_to_user (result, buffer, len)) ? -EFAULT : 0;
45505 }
45506 #endif /* IEEE1284.3 support. */
45507
45508 diff --git a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c
45509 index 2f5786c..61ab4d1 100644
45510 --- a/drivers/pci/hotplug/acpiphp_ibm.c
45511 +++ b/drivers/pci/hotplug/acpiphp_ibm.c
45512 @@ -463,7 +463,9 @@ static int __init ibm_acpiphp_init(void)
45513 goto init_cleanup;
45514 }
45515
45516 - ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
45517 + pax_open_kernel();
45518 + *(size_t *)&ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
45519 + pax_close_kernel();
45520 retval = sysfs_create_bin_file(sysdir, &ibm_apci_table_attr);
45521
45522 return retval;
45523 diff --git a/drivers/pci/hotplug/cpcihp_generic.c b/drivers/pci/hotplug/cpcihp_generic.c
45524 index a6a71c4..c91097b 100644
45525 --- a/drivers/pci/hotplug/cpcihp_generic.c
45526 +++ b/drivers/pci/hotplug/cpcihp_generic.c
45527 @@ -73,7 +73,6 @@ static u16 port;
45528 static unsigned int enum_bit;
45529 static u8 enum_mask;
45530
45531 -static struct cpci_hp_controller_ops generic_hpc_ops;
45532 static struct cpci_hp_controller generic_hpc;
45533
45534 static int __init validate_parameters(void)
45535 @@ -139,6 +138,10 @@ static int query_enum(void)
45536 return ((value & enum_mask) == enum_mask);
45537 }
45538
45539 +static struct cpci_hp_controller_ops generic_hpc_ops = {
45540 + .query_enum = query_enum,
45541 +};
45542 +
45543 static int __init cpcihp_generic_init(void)
45544 {
45545 int status;
45546 @@ -165,7 +168,6 @@ static int __init cpcihp_generic_init(void)
45547 pci_dev_put(dev);
45548
45549 memset(&generic_hpc, 0, sizeof (struct cpci_hp_controller));
45550 - generic_hpc_ops.query_enum = query_enum;
45551 generic_hpc.ops = &generic_hpc_ops;
45552
45553 status = cpci_hp_register_controller(&generic_hpc);
45554 diff --git a/drivers/pci/hotplug/cpcihp_zt5550.c b/drivers/pci/hotplug/cpcihp_zt5550.c
45555 index 449b4bb..257e2e8 100644
45556 --- a/drivers/pci/hotplug/cpcihp_zt5550.c
45557 +++ b/drivers/pci/hotplug/cpcihp_zt5550.c
45558 @@ -59,7 +59,6 @@
45559 /* local variables */
45560 static bool debug;
45561 static bool poll;
45562 -static struct cpci_hp_controller_ops zt5550_hpc_ops;
45563 static struct cpci_hp_controller zt5550_hpc;
45564
45565 /* Primary cPCI bus bridge device */
45566 @@ -205,6 +204,10 @@ static int zt5550_hc_disable_irq(void)
45567 return 0;
45568 }
45569
45570 +static struct cpci_hp_controller_ops zt5550_hpc_ops = {
45571 + .query_enum = zt5550_hc_query_enum,
45572 +};
45573 +
45574 static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
45575 {
45576 int status;
45577 @@ -216,16 +219,17 @@ static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id
45578 dbg("returned from zt5550_hc_config");
45579
45580 memset(&zt5550_hpc, 0, sizeof (struct cpci_hp_controller));
45581 - zt5550_hpc_ops.query_enum = zt5550_hc_query_enum;
45582 zt5550_hpc.ops = &zt5550_hpc_ops;
45583 if(!poll) {
45584 zt5550_hpc.irq = hc_dev->irq;
45585 zt5550_hpc.irq_flags = IRQF_SHARED;
45586 zt5550_hpc.dev_id = hc_dev;
45587
45588 - zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
45589 - zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
45590 - zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
45591 + pax_open_kernel();
45592 + *(void **)&zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
45593 + *(void **)&zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
45594 + *(void **)&zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
45595 + pax_open_kernel();
45596 } else {
45597 info("using ENUM# polling mode");
45598 }
45599 diff --git a/drivers/pci/hotplug/cpqphp_nvram.c b/drivers/pci/hotplug/cpqphp_nvram.c
45600 index 76ba8a1..20ca857 100644
45601 --- a/drivers/pci/hotplug/cpqphp_nvram.c
45602 +++ b/drivers/pci/hotplug/cpqphp_nvram.c
45603 @@ -428,9 +428,13 @@ static u32 store_HRT (void __iomem *rom_start)
45604
45605 void compaq_nvram_init (void __iomem *rom_start)
45606 {
45607 +
45608 +#ifndef CONFIG_PAX_KERNEXEC
45609 if (rom_start) {
45610 compaq_int15_entry_point = (rom_start + ROM_INT15_PHY_ADDR - ROM_PHY_ADDR);
45611 }
45612 +#endif
45613 +
45614 dbg("int15 entry = %p\n", compaq_int15_entry_point);
45615
45616 /* initialize our int15 lock */
45617 diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c
45618 index ec20f74..c1d961e 100644
45619 --- a/drivers/pci/hotplug/pci_hotplug_core.c
45620 +++ b/drivers/pci/hotplug/pci_hotplug_core.c
45621 @@ -441,8 +441,10 @@ int __pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus,
45622 return -EINVAL;
45623 }
45624
45625 - slot->ops->owner = owner;
45626 - slot->ops->mod_name = mod_name;
45627 + pax_open_kernel();
45628 + *(struct module **)&slot->ops->owner = owner;
45629 + *(const char **)&slot->ops->mod_name = mod_name;
45630 + pax_close_kernel();
45631
45632 mutex_lock(&pci_hp_mutex);
45633 /*
45634 diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
45635 index f4a18f5..ff2463c 100644
45636 --- a/drivers/pci/hotplug/pciehp_core.c
45637 +++ b/drivers/pci/hotplug/pciehp_core.c
45638 @@ -92,7 +92,7 @@ static int init_slot(struct controller *ctrl)
45639 struct slot *slot = ctrl->slot;
45640 struct hotplug_slot *hotplug = NULL;
45641 struct hotplug_slot_info *info = NULL;
45642 - struct hotplug_slot_ops *ops = NULL;
45643 + hotplug_slot_ops_no_const *ops = NULL;
45644 char name[SLOT_NAME_SIZE];
45645 int retval = -ENOMEM;
45646
45647 diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
45648 index 7128cfd..a0640d6 100644
45649 --- a/drivers/pci/pci-sysfs.c
45650 +++ b/drivers/pci/pci-sysfs.c
45651 @@ -1083,7 +1083,7 @@ static int pci_create_attr(struct pci_dev *pdev, int num, int write_combine)
45652 {
45653 /* allocate attribute structure, piggyback attribute name */
45654 int name_len = write_combine ? 13 : 10;
45655 - struct bin_attribute *res_attr;
45656 + bin_attribute_no_const *res_attr;
45657 int retval;
45658
45659 res_attr = kzalloc(sizeof(*res_attr) + name_len, GFP_ATOMIC);
45660 @@ -1268,7 +1268,7 @@ static struct device_attribute reset_attr = __ATTR(reset, 0200, NULL, reset_stor
45661 static int pci_create_capabilities_sysfs(struct pci_dev *dev)
45662 {
45663 int retval;
45664 - struct bin_attribute *attr;
45665 + bin_attribute_no_const *attr;
45666
45667 /* If the device has VPD, try to expose it in sysfs. */
45668 if (dev->vpd) {
45669 @@ -1315,7 +1315,7 @@ int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev)
45670 {
45671 int retval;
45672 int rom_size = 0;
45673 - struct bin_attribute *attr;
45674 + bin_attribute_no_const *attr;
45675
45676 if (!sysfs_initialized)
45677 return -EACCES;
45678 diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
45679 index 8a00c06..18a9715 100644
45680 --- a/drivers/pci/pci.h
45681 +++ b/drivers/pci/pci.h
45682 @@ -95,7 +95,7 @@ struct pci_vpd_ops {
45683 struct pci_vpd {
45684 unsigned int len;
45685 const struct pci_vpd_ops *ops;
45686 - struct bin_attribute *attr; /* descriptor for sysfs VPD entry */
45687 + bin_attribute_no_const *attr; /* descriptor for sysfs VPD entry */
45688 };
45689
45690 int pci_vpd_pci22_init(struct pci_dev *dev);
45691 diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
45692 index 403a443..034e050 100644
45693 --- a/drivers/pci/pcie/aspm.c
45694 +++ b/drivers/pci/pcie/aspm.c
45695 @@ -27,9 +27,9 @@
45696 #define MODULE_PARAM_PREFIX "pcie_aspm."
45697
45698 /* Note: those are not register definitions */
45699 -#define ASPM_STATE_L0S_UP (1) /* Upstream direction L0s state */
45700 -#define ASPM_STATE_L0S_DW (2) /* Downstream direction L0s state */
45701 -#define ASPM_STATE_L1 (4) /* L1 state */
45702 +#define ASPM_STATE_L0S_UP (1U) /* Upstream direction L0s state */
45703 +#define ASPM_STATE_L0S_DW (2U) /* Downstream direction L0s state */
45704 +#define ASPM_STATE_L1 (4U) /* L1 state */
45705 #define ASPM_STATE_L0S (ASPM_STATE_L0S_UP | ASPM_STATE_L0S_DW)
45706 #define ASPM_STATE_ALL (ASPM_STATE_L0S | ASPM_STATE_L1)
45707
45708 diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
45709 index 7ef0f86..17b710f 100644
45710 --- a/drivers/pci/probe.c
45711 +++ b/drivers/pci/probe.c
45712 @@ -175,7 +175,7 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
45713 struct pci_bus_region region, inverted_region;
45714 bool bar_too_big = false, bar_disabled = false;
45715
45716 - mask = type ? PCI_ROM_ADDRESS_MASK : ~0;
45717 + mask = type ? (u32)PCI_ROM_ADDRESS_MASK : ~0;
45718
45719 /* No printks while decoding is disabled! */
45720 if (!dev->mmio_always_on) {
45721 diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
45722 index cdc7836..528635c 100644
45723 --- a/drivers/pci/proc.c
45724 +++ b/drivers/pci/proc.c
45725 @@ -434,7 +434,16 @@ static const struct file_operations proc_bus_pci_dev_operations = {
45726 static int __init pci_proc_init(void)
45727 {
45728 struct pci_dev *dev = NULL;
45729 +
45730 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
45731 +#ifdef CONFIG_GRKERNSEC_PROC_USER
45732 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR, NULL);
45733 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
45734 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
45735 +#endif
45736 +#else
45737 proc_bus_pci_dir = proc_mkdir("bus/pci", NULL);
45738 +#endif
45739 proc_create("devices", 0, proc_bus_pci_dir,
45740 &proc_bus_pci_dev_operations);
45741 proc_initialized = 1;
45742 diff --git a/drivers/platform/x86/chromeos_laptop.c b/drivers/platform/x86/chromeos_laptop.c
45743 index 3e5b4497..dcdfb70 100644
45744 --- a/drivers/platform/x86/chromeos_laptop.c
45745 +++ b/drivers/platform/x86/chromeos_laptop.c
45746 @@ -301,7 +301,7 @@ static int __init setup_tsl2563_als(const struct dmi_system_id *id)
45747 return 0;
45748 }
45749
45750 -static struct dmi_system_id __initdata chromeos_laptop_dmi_table[] = {
45751 +static struct dmi_system_id __initconst chromeos_laptop_dmi_table[] = {
45752 {
45753 .ident = "Samsung Series 5 550 - Touchpad",
45754 .matches = {
45755 diff --git a/drivers/platform/x86/msi-laptop.c b/drivers/platform/x86/msi-laptop.c
45756 index 62f8030..c7f2a45 100644
45757 --- a/drivers/platform/x86/msi-laptop.c
45758 +++ b/drivers/platform/x86/msi-laptop.c
45759 @@ -1000,12 +1000,14 @@ static int __init load_scm_model_init(struct platform_device *sdev)
45760
45761 if (!quirks->ec_read_only) {
45762 /* allow userland write sysfs file */
45763 - dev_attr_bluetooth.store = store_bluetooth;
45764 - dev_attr_wlan.store = store_wlan;
45765 - dev_attr_threeg.store = store_threeg;
45766 - dev_attr_bluetooth.attr.mode |= S_IWUSR;
45767 - dev_attr_wlan.attr.mode |= S_IWUSR;
45768 - dev_attr_threeg.attr.mode |= S_IWUSR;
45769 + pax_open_kernel();
45770 + *(void **)&dev_attr_bluetooth.store = store_bluetooth;
45771 + *(void **)&dev_attr_wlan.store = store_wlan;
45772 + *(void **)&dev_attr_threeg.store = store_threeg;
45773 + *(umode_t *)&dev_attr_bluetooth.attr.mode |= S_IWUSR;
45774 + *(umode_t *)&dev_attr_wlan.attr.mode |= S_IWUSR;
45775 + *(umode_t *)&dev_attr_threeg.attr.mode |= S_IWUSR;
45776 + pax_close_kernel();
45777 }
45778
45779 /* disable hardware control by fn key */
45780 diff --git a/drivers/platform/x86/msi-wmi.c b/drivers/platform/x86/msi-wmi.c
45781 index 70222f2..8c8ce66 100644
45782 --- a/drivers/platform/x86/msi-wmi.c
45783 +++ b/drivers/platform/x86/msi-wmi.c
45784 @@ -183,7 +183,7 @@ static const struct backlight_ops msi_backlight_ops = {
45785 static void msi_wmi_notify(u32 value, void *context)
45786 {
45787 struct acpi_buffer response = { ACPI_ALLOCATE_BUFFER, NULL };
45788 - static struct key_entry *key;
45789 + struct key_entry *key;
45790 union acpi_object *obj;
45791 acpi_status status;
45792
45793 diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
45794 index 3484dd2..13ee730 100644
45795 --- a/drivers/platform/x86/sony-laptop.c
45796 +++ b/drivers/platform/x86/sony-laptop.c
45797 @@ -2448,7 +2448,7 @@ static void sony_nc_gfx_switch_cleanup(struct platform_device *pd)
45798 }
45799
45800 /* High speed charging function */
45801 -static struct device_attribute *hsc_handle;
45802 +static device_attribute_no_const *hsc_handle;
45803
45804 static ssize_t sony_nc_highspeed_charging_store(struct device *dev,
45805 struct device_attribute *attr,
45806 diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
45807 index 4e86e97..04d50d1 100644
45808 --- a/drivers/platform/x86/thinkpad_acpi.c
45809 +++ b/drivers/platform/x86/thinkpad_acpi.c
45810 @@ -2091,7 +2091,7 @@ static int hotkey_mask_get(void)
45811 return 0;
45812 }
45813
45814 -void static hotkey_mask_warn_incomplete_mask(void)
45815 +static void hotkey_mask_warn_incomplete_mask(void)
45816 {
45817 /* log only what the user can fix... */
45818 const u32 wantedmask = hotkey_driver_mask &
45819 @@ -2318,11 +2318,6 @@ static void hotkey_read_nvram(struct tp_nvram_state *n, const u32 m)
45820 }
45821 }
45822
45823 -static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45824 - struct tp_nvram_state *newn,
45825 - const u32 event_mask)
45826 -{
45827 -
45828 #define TPACPI_COMPARE_KEY(__scancode, __member) \
45829 do { \
45830 if ((event_mask & (1 << __scancode)) && \
45831 @@ -2336,36 +2331,42 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45832 tpacpi_hotkey_send_key(__scancode); \
45833 } while (0)
45834
45835 - void issue_volchange(const unsigned int oldvol,
45836 - const unsigned int newvol)
45837 - {
45838 - unsigned int i = oldvol;
45839 +static void issue_volchange(const unsigned int oldvol,
45840 + const unsigned int newvol,
45841 + const u32 event_mask)
45842 +{
45843 + unsigned int i = oldvol;
45844
45845 - while (i > newvol) {
45846 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
45847 - i--;
45848 - }
45849 - while (i < newvol) {
45850 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
45851 - i++;
45852 - }
45853 + while (i > newvol) {
45854 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
45855 + i--;
45856 }
45857 + while (i < newvol) {
45858 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
45859 + i++;
45860 + }
45861 +}
45862
45863 - void issue_brightnesschange(const unsigned int oldbrt,
45864 - const unsigned int newbrt)
45865 - {
45866 - unsigned int i = oldbrt;
45867 +static void issue_brightnesschange(const unsigned int oldbrt,
45868 + const unsigned int newbrt,
45869 + const u32 event_mask)
45870 +{
45871 + unsigned int i = oldbrt;
45872
45873 - while (i > newbrt) {
45874 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
45875 - i--;
45876 - }
45877 - while (i < newbrt) {
45878 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
45879 - i++;
45880 - }
45881 + while (i > newbrt) {
45882 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
45883 + i--;
45884 + }
45885 + while (i < newbrt) {
45886 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
45887 + i++;
45888 }
45889 +}
45890
45891 +static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45892 + struct tp_nvram_state *newn,
45893 + const u32 event_mask)
45894 +{
45895 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_THINKPAD, thinkpad_toggle);
45896 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNSPACE, zoom_toggle);
45897 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNF7, display_toggle);
45898 @@ -2399,7 +2400,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45899 oldn->volume_level != newn->volume_level) {
45900 /* recently muted, or repeated mute keypress, or
45901 * multiple presses ending in mute */
45902 - issue_volchange(oldn->volume_level, newn->volume_level);
45903 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
45904 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_MUTE);
45905 }
45906 } else {
45907 @@ -2409,7 +2410,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45908 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
45909 }
45910 if (oldn->volume_level != newn->volume_level) {
45911 - issue_volchange(oldn->volume_level, newn->volume_level);
45912 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
45913 } else if (oldn->volume_toggle != newn->volume_toggle) {
45914 /* repeated vol up/down keypress at end of scale ? */
45915 if (newn->volume_level == 0)
45916 @@ -2422,7 +2423,8 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45917 /* handle brightness */
45918 if (oldn->brightness_level != newn->brightness_level) {
45919 issue_brightnesschange(oldn->brightness_level,
45920 - newn->brightness_level);
45921 + newn->brightness_level,
45922 + event_mask);
45923 } else if (oldn->brightness_toggle != newn->brightness_toggle) {
45924 /* repeated key presses that didn't change state */
45925 if (newn->brightness_level == 0)
45926 @@ -2431,10 +2433,10 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45927 && !tp_features.bright_unkfw)
45928 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
45929 }
45930 +}
45931
45932 #undef TPACPI_COMPARE_KEY
45933 #undef TPACPI_MAY_SEND_KEY
45934 -}
45935
45936 /*
45937 * Polling driver
45938 diff --git a/drivers/pnp/pnpbios/bioscalls.c b/drivers/pnp/pnpbios/bioscalls.c
45939 index 769d265..a3a05ca 100644
45940 --- a/drivers/pnp/pnpbios/bioscalls.c
45941 +++ b/drivers/pnp/pnpbios/bioscalls.c
45942 @@ -58,7 +58,7 @@ do { \
45943 set_desc_limit(&gdt[(selname) >> 3], (size) - 1); \
45944 } while(0)
45945
45946 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
45947 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
45948 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
45949
45950 /*
45951 @@ -95,7 +95,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
45952
45953 cpu = get_cpu();
45954 save_desc_40 = get_cpu_gdt_table(cpu)[0x40 / 8];
45955 +
45956 + pax_open_kernel();
45957 get_cpu_gdt_table(cpu)[0x40 / 8] = bad_bios_desc;
45958 + pax_close_kernel();
45959
45960 /* On some boxes IRQ's during PnP BIOS calls are deadly. */
45961 spin_lock_irqsave(&pnp_bios_lock, flags);
45962 @@ -133,7 +136,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
45963 :"memory");
45964 spin_unlock_irqrestore(&pnp_bios_lock, flags);
45965
45966 + pax_open_kernel();
45967 get_cpu_gdt_table(cpu)[0x40 / 8] = save_desc_40;
45968 + pax_close_kernel();
45969 +
45970 put_cpu();
45971
45972 /* If we get here and this is set then the PnP BIOS faulted on us. */
45973 @@ -467,7 +473,7 @@ int pnp_bios_read_escd(char *data, u32 nvram_base)
45974 return status;
45975 }
45976
45977 -void pnpbios_calls_init(union pnp_bios_install_struct *header)
45978 +void __init pnpbios_calls_init(union pnp_bios_install_struct *header)
45979 {
45980 int i;
45981
45982 @@ -475,6 +481,8 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
45983 pnp_bios_callpoint.offset = header->fields.pm16offset;
45984 pnp_bios_callpoint.segment = PNP_CS16;
45985
45986 + pax_open_kernel();
45987 +
45988 for_each_possible_cpu(i) {
45989 struct desc_struct *gdt = get_cpu_gdt_table(i);
45990 if (!gdt)
45991 @@ -486,4 +494,6 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
45992 set_desc_base(&gdt[GDT_ENTRY_PNPBIOS_DS],
45993 (unsigned long)__va(header->fields.pm16dseg));
45994 }
45995 +
45996 + pax_close_kernel();
45997 }
45998 diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c
45999 index d95e101..67f0c3f 100644
46000 --- a/drivers/pnp/resource.c
46001 +++ b/drivers/pnp/resource.c
46002 @@ -360,7 +360,7 @@ int pnp_check_irq(struct pnp_dev *dev, struct resource *res)
46003 return 1;
46004
46005 /* check if the resource is valid */
46006 - if (*irq < 0 || *irq > 15)
46007 + if (*irq > 15)
46008 return 0;
46009
46010 /* check if the resource is reserved */
46011 @@ -424,7 +424,7 @@ int pnp_check_dma(struct pnp_dev *dev, struct resource *res)
46012 return 1;
46013
46014 /* check if the resource is valid */
46015 - if (*dma < 0 || *dma == 4 || *dma > 7)
46016 + if (*dma == 4 || *dma > 7)
46017 return 0;
46018
46019 /* check if the resource is reserved */
46020 diff --git a/drivers/power/pda_power.c b/drivers/power/pda_power.c
46021 index 0c52e2a..3421ab7 100644
46022 --- a/drivers/power/pda_power.c
46023 +++ b/drivers/power/pda_power.c
46024 @@ -37,7 +37,11 @@ static int polling;
46025
46026 #if IS_ENABLED(CONFIG_USB_PHY)
46027 static struct usb_phy *transceiver;
46028 -static struct notifier_block otg_nb;
46029 +static int otg_handle_notification(struct notifier_block *nb,
46030 + unsigned long event, void *unused);
46031 +static struct notifier_block otg_nb = {
46032 + .notifier_call = otg_handle_notification
46033 +};
46034 #endif
46035
46036 static struct regulator *ac_draw;
46037 @@ -369,7 +373,6 @@ static int pda_power_probe(struct platform_device *pdev)
46038
46039 #if IS_ENABLED(CONFIG_USB_PHY)
46040 if (!IS_ERR_OR_NULL(transceiver) && pdata->use_otg_notifier) {
46041 - otg_nb.notifier_call = otg_handle_notification;
46042 ret = usb_register_notifier(transceiver, &otg_nb);
46043 if (ret) {
46044 dev_err(dev, "failure to register otg notifier\n");
46045 diff --git a/drivers/power/power_supply.h b/drivers/power/power_supply.h
46046 index cc439fd..8fa30df 100644
46047 --- a/drivers/power/power_supply.h
46048 +++ b/drivers/power/power_supply.h
46049 @@ -16,12 +16,12 @@ struct power_supply;
46050
46051 #ifdef CONFIG_SYSFS
46052
46053 -extern void power_supply_init_attrs(struct device_type *dev_type);
46054 +extern void power_supply_init_attrs(void);
46055 extern int power_supply_uevent(struct device *dev, struct kobj_uevent_env *env);
46056
46057 #else
46058
46059 -static inline void power_supply_init_attrs(struct device_type *dev_type) {}
46060 +static inline void power_supply_init_attrs(void) {}
46061 #define power_supply_uevent NULL
46062
46063 #endif /* CONFIG_SYSFS */
46064 diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c
46065 index 00e6672..2642c08 100644
46066 --- a/drivers/power/power_supply_core.c
46067 +++ b/drivers/power/power_supply_core.c
46068 @@ -24,7 +24,10 @@
46069 struct class *power_supply_class;
46070 EXPORT_SYMBOL_GPL(power_supply_class);
46071
46072 -static struct device_type power_supply_dev_type;
46073 +extern const struct attribute_group *power_supply_attr_groups[];
46074 +static struct device_type power_supply_dev_type = {
46075 + .groups = power_supply_attr_groups,
46076 +};
46077
46078 static bool __power_supply_is_supplied_by(struct power_supply *supplier,
46079 struct power_supply *supply)
46080 @@ -584,7 +587,7 @@ static int __init power_supply_class_init(void)
46081 return PTR_ERR(power_supply_class);
46082
46083 power_supply_class->dev_uevent = power_supply_uevent;
46084 - power_supply_init_attrs(&power_supply_dev_type);
46085 + power_supply_init_attrs();
46086
46087 return 0;
46088 }
46089 diff --git a/drivers/power/power_supply_sysfs.c b/drivers/power/power_supply_sysfs.c
46090 index 44420d1..967126e 100644
46091 --- a/drivers/power/power_supply_sysfs.c
46092 +++ b/drivers/power/power_supply_sysfs.c
46093 @@ -230,17 +230,15 @@ static struct attribute_group power_supply_attr_group = {
46094 .is_visible = power_supply_attr_is_visible,
46095 };
46096
46097 -static const struct attribute_group *power_supply_attr_groups[] = {
46098 +const struct attribute_group *power_supply_attr_groups[] = {
46099 &power_supply_attr_group,
46100 NULL,
46101 };
46102
46103 -void power_supply_init_attrs(struct device_type *dev_type)
46104 +void power_supply_init_attrs(void)
46105 {
46106 int i;
46107
46108 - dev_type->groups = power_supply_attr_groups;
46109 -
46110 for (i = 0; i < ARRAY_SIZE(power_supply_attrs); i++)
46111 __power_supply_attrs[i] = &power_supply_attrs[i].attr;
46112 }
46113 diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
46114 index a01b8b3..37c2afe 100644
46115 --- a/drivers/regulator/core.c
46116 +++ b/drivers/regulator/core.c
46117 @@ -3307,7 +3307,7 @@ regulator_register(const struct regulator_desc *regulator_desc,
46118 {
46119 const struct regulation_constraints *constraints = NULL;
46120 const struct regulator_init_data *init_data;
46121 - static atomic_t regulator_no = ATOMIC_INIT(0);
46122 + static atomic_unchecked_t regulator_no = ATOMIC_INIT(0);
46123 struct regulator_dev *rdev;
46124 struct device *dev;
46125 int ret, i;
46126 @@ -3377,7 +3377,7 @@ regulator_register(const struct regulator_desc *regulator_desc,
46127 rdev->dev.of_node = config->of_node;
46128 rdev->dev.parent = dev;
46129 dev_set_name(&rdev->dev, "regulator.%d",
46130 - atomic_inc_return(&regulator_no) - 1);
46131 + atomic_inc_return_unchecked(&regulator_no) - 1);
46132 ret = device_register(&rdev->dev);
46133 if (ret != 0) {
46134 put_device(&rdev->dev);
46135 diff --git a/drivers/regulator/max8660.c b/drivers/regulator/max8660.c
46136 index 144bcac..d20e7db 100644
46137 --- a/drivers/regulator/max8660.c
46138 +++ b/drivers/regulator/max8660.c
46139 @@ -420,8 +420,10 @@ static int max8660_probe(struct i2c_client *client,
46140 max8660->shadow_regs[MAX8660_OVER1] = 5;
46141 } else {
46142 /* Otherwise devices can be toggled via software */
46143 - max8660_dcdc_ops.enable = max8660_dcdc_enable;
46144 - max8660_dcdc_ops.disable = max8660_dcdc_disable;
46145 + pax_open_kernel();
46146 + *(void **)&max8660_dcdc_ops.enable = max8660_dcdc_enable;
46147 + *(void **)&max8660_dcdc_ops.disable = max8660_dcdc_disable;
46148 + pax_close_kernel();
46149 }
46150
46151 /*
46152 diff --git a/drivers/regulator/max8973-regulator.c b/drivers/regulator/max8973-regulator.c
46153 index 5b77ab7..a62f061 100644
46154 --- a/drivers/regulator/max8973-regulator.c
46155 +++ b/drivers/regulator/max8973-regulator.c
46156 @@ -406,9 +406,11 @@ static int max8973_probe(struct i2c_client *client,
46157 if (!pdata || !pdata->enable_ext_control) {
46158 max->desc.enable_reg = MAX8973_VOUT;
46159 max->desc.enable_mask = MAX8973_VOUT_ENABLE;
46160 - max->ops.enable = regulator_enable_regmap;
46161 - max->ops.disable = regulator_disable_regmap;
46162 - max->ops.is_enabled = regulator_is_enabled_regmap;
46163 + pax_open_kernel();
46164 + *(void **)&max->ops.enable = regulator_enable_regmap;
46165 + *(void **)&max->ops.disable = regulator_disable_regmap;
46166 + *(void **)&max->ops.is_enabled = regulator_is_enabled_regmap;
46167 + pax_close_kernel();
46168 }
46169
46170 if (pdata) {
46171 diff --git a/drivers/regulator/mc13892-regulator.c b/drivers/regulator/mc13892-regulator.c
46172 index 1037e07..e64dea1 100644
46173 --- a/drivers/regulator/mc13892-regulator.c
46174 +++ b/drivers/regulator/mc13892-regulator.c
46175 @@ -582,10 +582,12 @@ static int mc13892_regulator_probe(struct platform_device *pdev)
46176 }
46177 mc13xxx_unlock(mc13892);
46178
46179 - mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
46180 + pax_open_kernel();
46181 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
46182 = mc13892_vcam_set_mode;
46183 - mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
46184 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
46185 = mc13892_vcam_get_mode;
46186 + pax_close_kernel();
46187
46188 mc13xxx_data = mc13xxx_parse_regulators_dt(pdev, mc13892_regulators,
46189 ARRAY_SIZE(mc13892_regulators));
46190 diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
46191 index 24e733c..bfbaa3e 100644
46192 --- a/drivers/rtc/rtc-cmos.c
46193 +++ b/drivers/rtc/rtc-cmos.c
46194 @@ -731,7 +731,9 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
46195 hpet_rtc_timer_init();
46196
46197 /* export at least the first block of NVRAM */
46198 - nvram.size = address_space - NVRAM_OFFSET;
46199 + pax_open_kernel();
46200 + *(size_t *)&nvram.size = address_space - NVRAM_OFFSET;
46201 + pax_close_kernel();
46202 retval = sysfs_create_bin_file(&dev->kobj, &nvram);
46203 if (retval < 0) {
46204 dev_dbg(dev, "can't create nvram file? %d\n", retval);
46205 diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c
46206 index d049393..bb20be0 100644
46207 --- a/drivers/rtc/rtc-dev.c
46208 +++ b/drivers/rtc/rtc-dev.c
46209 @@ -16,6 +16,7 @@
46210 #include <linux/module.h>
46211 #include <linux/rtc.h>
46212 #include <linux/sched.h>
46213 +#include <linux/grsecurity.h>
46214 #include "rtc-core.h"
46215
46216 static dev_t rtc_devt;
46217 @@ -347,6 +348,8 @@ static long rtc_dev_ioctl(struct file *file,
46218 if (copy_from_user(&tm, uarg, sizeof(tm)))
46219 return -EFAULT;
46220
46221 + gr_log_timechange();
46222 +
46223 return rtc_set_time(rtc, &tm);
46224
46225 case RTC_PIE_ON:
46226 diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
46227 index ca18fd1..055e42d 100644
46228 --- a/drivers/rtc/rtc-ds1307.c
46229 +++ b/drivers/rtc/rtc-ds1307.c
46230 @@ -107,7 +107,7 @@ struct ds1307 {
46231 u8 offset; /* register's offset */
46232 u8 regs[11];
46233 u16 nvram_offset;
46234 - struct bin_attribute *nvram;
46235 + bin_attribute_no_const *nvram;
46236 enum ds_type type;
46237 unsigned long flags;
46238 #define HAS_NVRAM 0 /* bit 0 == sysfs file active */
46239 diff --git a/drivers/rtc/rtc-m48t59.c b/drivers/rtc/rtc-m48t59.c
46240 index fcb0329..d77b7f2 100644
46241 --- a/drivers/rtc/rtc-m48t59.c
46242 +++ b/drivers/rtc/rtc-m48t59.c
46243 @@ -483,7 +483,9 @@ static int m48t59_rtc_probe(struct platform_device *pdev)
46244 if (IS_ERR(m48t59->rtc))
46245 return PTR_ERR(m48t59->rtc);
46246
46247 - m48t59_nvram_attr.size = pdata->offset;
46248 + pax_open_kernel();
46249 + *(size_t *)&m48t59_nvram_attr.size = pdata->offset;
46250 + pax_close_kernel();
46251
46252 ret = sysfs_create_bin_file(&pdev->dev.kobj, &m48t59_nvram_attr);
46253 if (ret)
46254 diff --git a/drivers/scsi/aic7xxx/aic79xx_pci.c b/drivers/scsi/aic7xxx/aic79xx_pci.c
46255 index 14b5f8d..cc9bd26 100644
46256 --- a/drivers/scsi/aic7xxx/aic79xx_pci.c
46257 +++ b/drivers/scsi/aic7xxx/aic79xx_pci.c
46258 @@ -827,7 +827,7 @@ ahd_pci_intr(struct ahd_softc *ahd)
46259 for (bit = 0; bit < 8; bit++) {
46260
46261 if ((pci_status[i] & (0x1 << bit)) != 0) {
46262 - static const char *s;
46263 + const char *s;
46264
46265 s = pci_status_strings[bit];
46266 if (i == 7/*TARG*/ && bit == 3)
46267 @@ -887,23 +887,15 @@ ahd_pci_split_intr(struct ahd_softc *ahd, u_int intstat)
46268
46269 for (bit = 0; bit < 8; bit++) {
46270
46271 - if ((split_status[i] & (0x1 << bit)) != 0) {
46272 - static const char *s;
46273 -
46274 - s = split_status_strings[bit];
46275 - printk(s, ahd_name(ahd),
46276 + if ((split_status[i] & (0x1 << bit)) != 0)
46277 + printk(split_status_strings[bit], ahd_name(ahd),
46278 split_status_source[i]);
46279 - }
46280
46281 if (i > 1)
46282 continue;
46283
46284 - if ((sg_split_status[i] & (0x1 << bit)) != 0) {
46285 - static const char *s;
46286 -
46287 - s = split_status_strings[bit];
46288 - printk(s, ahd_name(ahd), "SG");
46289 - }
46290 + if ((sg_split_status[i] & (0x1 << bit)) != 0)
46291 + printk(split_status_strings[bit], ahd_name(ahd), "SG");
46292 }
46293 }
46294 /*
46295 diff --git a/drivers/scsi/bfa/bfa_fcpim.h b/drivers/scsi/bfa/bfa_fcpim.h
46296 index e693af6..2e525b6 100644
46297 --- a/drivers/scsi/bfa/bfa_fcpim.h
46298 +++ b/drivers/scsi/bfa/bfa_fcpim.h
46299 @@ -36,7 +36,7 @@ struct bfa_iotag_s {
46300
46301 struct bfa_itn_s {
46302 bfa_isr_func_t isr;
46303 -};
46304 +} __no_const;
46305
46306 void bfa_itn_create(struct bfa_s *bfa, struct bfa_rport_s *rport,
46307 void (*isr)(struct bfa_s *bfa, struct bfi_msg_s *m));
46308 diff --git a/drivers/scsi/bfa/bfa_ioc.h b/drivers/scsi/bfa/bfa_ioc.h
46309 index 90814fe..4384138 100644
46310 --- a/drivers/scsi/bfa/bfa_ioc.h
46311 +++ b/drivers/scsi/bfa/bfa_ioc.h
46312 @@ -258,7 +258,7 @@ struct bfa_ioc_cbfn_s {
46313 bfa_ioc_disable_cbfn_t disable_cbfn;
46314 bfa_ioc_hbfail_cbfn_t hbfail_cbfn;
46315 bfa_ioc_reset_cbfn_t reset_cbfn;
46316 -};
46317 +} __no_const;
46318
46319 /*
46320 * IOC event notification mechanism.
46321 @@ -352,7 +352,7 @@ struct bfa_ioc_hwif_s {
46322 void (*ioc_set_alt_fwstate) (struct bfa_ioc_s *ioc,
46323 enum bfi_ioc_state fwstate);
46324 enum bfi_ioc_state (*ioc_get_alt_fwstate) (struct bfa_ioc_s *ioc);
46325 -};
46326 +} __no_const;
46327
46328 /*
46329 * Queue element to wait for room in request queue. FIFO order is
46330 diff --git a/drivers/scsi/fcoe/fcoe_sysfs.c b/drivers/scsi/fcoe/fcoe_sysfs.c
46331 index c9382d6..6619864 100644
46332 --- a/drivers/scsi/fcoe/fcoe_sysfs.c
46333 +++ b/drivers/scsi/fcoe/fcoe_sysfs.c
46334 @@ -33,8 +33,8 @@
46335 */
46336 #include "libfcoe.h"
46337
46338 -static atomic_t ctlr_num;
46339 -static atomic_t fcf_num;
46340 +static atomic_unchecked_t ctlr_num;
46341 +static atomic_unchecked_t fcf_num;
46342
46343 /*
46344 * fcoe_fcf_dev_loss_tmo: the default number of seconds that fcoe sysfs
46345 @@ -681,7 +681,7 @@ struct fcoe_ctlr_device *fcoe_ctlr_device_add(struct device *parent,
46346 if (!ctlr)
46347 goto out;
46348
46349 - ctlr->id = atomic_inc_return(&ctlr_num) - 1;
46350 + ctlr->id = atomic_inc_return_unchecked(&ctlr_num) - 1;
46351 ctlr->f = f;
46352 ctlr->mode = FIP_CONN_TYPE_FABRIC;
46353 INIT_LIST_HEAD(&ctlr->fcfs);
46354 @@ -898,7 +898,7 @@ struct fcoe_fcf_device *fcoe_fcf_device_add(struct fcoe_ctlr_device *ctlr,
46355 fcf->dev.parent = &ctlr->dev;
46356 fcf->dev.bus = &fcoe_bus_type;
46357 fcf->dev.type = &fcoe_fcf_device_type;
46358 - fcf->id = atomic_inc_return(&fcf_num) - 1;
46359 + fcf->id = atomic_inc_return_unchecked(&fcf_num) - 1;
46360 fcf->state = FCOE_FCF_STATE_UNKNOWN;
46361
46362 fcf->dev_loss_tmo = ctlr->fcf_dev_loss_tmo;
46363 @@ -934,8 +934,8 @@ int __init fcoe_sysfs_setup(void)
46364 {
46365 int error;
46366
46367 - atomic_set(&ctlr_num, 0);
46368 - atomic_set(&fcf_num, 0);
46369 + atomic_set_unchecked(&ctlr_num, 0);
46370 + atomic_set_unchecked(&fcf_num, 0);
46371
46372 error = bus_register(&fcoe_bus_type);
46373 if (error)
46374 diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
46375 index 3cafe0d..f1e87f8 100644
46376 --- a/drivers/scsi/hosts.c
46377 +++ b/drivers/scsi/hosts.c
46378 @@ -42,7 +42,7 @@
46379 #include "scsi_logging.h"
46380
46381
46382 -static atomic_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
46383 +static atomic_unchecked_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
46384
46385
46386 static void scsi_host_cls_release(struct device *dev)
46387 @@ -361,7 +361,7 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
46388 * subtract one because we increment first then return, but we need to
46389 * know what the next host number was before increment
46390 */
46391 - shost->host_no = atomic_inc_return(&scsi_host_next_hn) - 1;
46392 + shost->host_no = atomic_inc_return_unchecked(&scsi_host_next_hn) - 1;
46393 shost->dma_channel = 0xff;
46394
46395 /* These three are default values which can be overridden */
46396 diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
46397 index 0eb0940..3ca9b79 100644
46398 --- a/drivers/scsi/hpsa.c
46399 +++ b/drivers/scsi/hpsa.c
46400 @@ -579,7 +579,7 @@ static inline u32 next_command(struct ctlr_info *h, u8 q)
46401 unsigned long flags;
46402
46403 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
46404 - return h->access.command_completed(h, q);
46405 + return h->access->command_completed(h, q);
46406
46407 if ((rq->head[rq->current_entry] & 1) == rq->wraparound) {
46408 a = rq->head[rq->current_entry];
46409 @@ -3445,7 +3445,7 @@ static void start_io(struct ctlr_info *h)
46410 while (!list_empty(&h->reqQ)) {
46411 c = list_entry(h->reqQ.next, struct CommandList, list);
46412 /* can't do anything if fifo is full */
46413 - if ((h->access.fifo_full(h))) {
46414 + if ((h->access->fifo_full(h))) {
46415 dev_warn(&h->pdev->dev, "fifo full\n");
46416 break;
46417 }
46418 @@ -3467,7 +3467,7 @@ static void start_io(struct ctlr_info *h)
46419
46420 /* Tell the controller execute command */
46421 spin_unlock_irqrestore(&h->lock, flags);
46422 - h->access.submit_command(h, c);
46423 + h->access->submit_command(h, c);
46424 spin_lock_irqsave(&h->lock, flags);
46425 }
46426 spin_unlock_irqrestore(&h->lock, flags);
46427 @@ -3475,17 +3475,17 @@ static void start_io(struct ctlr_info *h)
46428
46429 static inline unsigned long get_next_completion(struct ctlr_info *h, u8 q)
46430 {
46431 - return h->access.command_completed(h, q);
46432 + return h->access->command_completed(h, q);
46433 }
46434
46435 static inline bool interrupt_pending(struct ctlr_info *h)
46436 {
46437 - return h->access.intr_pending(h);
46438 + return h->access->intr_pending(h);
46439 }
46440
46441 static inline long interrupt_not_for_us(struct ctlr_info *h)
46442 {
46443 - return (h->access.intr_pending(h) == 0) ||
46444 + return (h->access->intr_pending(h) == 0) ||
46445 (h->interrupts_enabled == 0);
46446 }
46447
46448 @@ -4387,7 +4387,7 @@ static int hpsa_pci_init(struct ctlr_info *h)
46449 if (prod_index < 0)
46450 return -ENODEV;
46451 h->product_name = products[prod_index].product_name;
46452 - h->access = *(products[prod_index].access);
46453 + h->access = products[prod_index].access;
46454
46455 pci_disable_link_state(h->pdev, PCIE_LINK_STATE_L0S |
46456 PCIE_LINK_STATE_L1 | PCIE_LINK_STATE_CLKPM);
46457 @@ -4669,7 +4669,7 @@ static void controller_lockup_detected(struct ctlr_info *h)
46458
46459 assert_spin_locked(&lockup_detector_lock);
46460 remove_ctlr_from_lockup_detector_list(h);
46461 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
46462 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
46463 spin_lock_irqsave(&h->lock, flags);
46464 h->lockup_detected = readl(h->vaddr + SA5_SCRATCHPAD_OFFSET);
46465 spin_unlock_irqrestore(&h->lock, flags);
46466 @@ -4846,7 +4846,7 @@ reinit_after_soft_reset:
46467 }
46468
46469 /* make sure the board interrupts are off */
46470 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
46471 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
46472
46473 if (hpsa_request_irq(h, do_hpsa_intr_msi, do_hpsa_intr_intx))
46474 goto clean2;
46475 @@ -4880,7 +4880,7 @@ reinit_after_soft_reset:
46476 * fake ones to scoop up any residual completions.
46477 */
46478 spin_lock_irqsave(&h->lock, flags);
46479 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
46480 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
46481 spin_unlock_irqrestore(&h->lock, flags);
46482 free_irqs(h);
46483 rc = hpsa_request_irq(h, hpsa_msix_discard_completions,
46484 @@ -4899,9 +4899,9 @@ reinit_after_soft_reset:
46485 dev_info(&h->pdev->dev, "Board READY.\n");
46486 dev_info(&h->pdev->dev,
46487 "Waiting for stale completions to drain.\n");
46488 - h->access.set_intr_mask(h, HPSA_INTR_ON);
46489 + h->access->set_intr_mask(h, HPSA_INTR_ON);
46490 msleep(10000);
46491 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
46492 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
46493
46494 rc = controller_reset_failed(h->cfgtable);
46495 if (rc)
46496 @@ -4922,7 +4922,7 @@ reinit_after_soft_reset:
46497 }
46498
46499 /* Turn the interrupts on so we can service requests */
46500 - h->access.set_intr_mask(h, HPSA_INTR_ON);
46501 + h->access->set_intr_mask(h, HPSA_INTR_ON);
46502
46503 hpsa_hba_inquiry(h);
46504 hpsa_register_scsi(h); /* hook ourselves into SCSI subsystem */
46505 @@ -4977,7 +4977,7 @@ static void hpsa_shutdown(struct pci_dev *pdev)
46506 * To write all data in the battery backed cache to disks
46507 */
46508 hpsa_flush_cache(h);
46509 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
46510 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
46511 hpsa_free_irqs_and_disable_msix(h);
46512 }
46513
46514 @@ -5145,7 +5145,7 @@ static void hpsa_enter_performant_mode(struct ctlr_info *h, u32 use_short_tags)
46515 return;
46516 }
46517 /* Change the access methods to the performant access methods */
46518 - h->access = SA5_performant_access;
46519 + h->access = &SA5_performant_access;
46520 h->transMethod = CFGTBL_Trans_Performant;
46521 }
46522
46523 diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
46524 index bc85e72..ae04a39 100644
46525 --- a/drivers/scsi/hpsa.h
46526 +++ b/drivers/scsi/hpsa.h
46527 @@ -79,7 +79,7 @@ struct ctlr_info {
46528 unsigned int msix_vector;
46529 unsigned int msi_vector;
46530 int intr_mode; /* either PERF_MODE_INT or SIMPLE_MODE_INT */
46531 - struct access_method access;
46532 + struct access_method *access;
46533
46534 /* queue and queue Info */
46535 struct list_head reqQ;
46536 diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c
46537 index 5879929..32b241d 100644
46538 --- a/drivers/scsi/libfc/fc_exch.c
46539 +++ b/drivers/scsi/libfc/fc_exch.c
46540 @@ -100,12 +100,12 @@ struct fc_exch_mgr {
46541 u16 pool_max_index;
46542
46543 struct {
46544 - atomic_t no_free_exch;
46545 - atomic_t no_free_exch_xid;
46546 - atomic_t xid_not_found;
46547 - atomic_t xid_busy;
46548 - atomic_t seq_not_found;
46549 - atomic_t non_bls_resp;
46550 + atomic_unchecked_t no_free_exch;
46551 + atomic_unchecked_t no_free_exch_xid;
46552 + atomic_unchecked_t xid_not_found;
46553 + atomic_unchecked_t xid_busy;
46554 + atomic_unchecked_t seq_not_found;
46555 + atomic_unchecked_t non_bls_resp;
46556 } stats;
46557 };
46558
46559 @@ -736,7 +736,7 @@ static struct fc_exch *fc_exch_em_alloc(struct fc_lport *lport,
46560 /* allocate memory for exchange */
46561 ep = mempool_alloc(mp->ep_pool, GFP_ATOMIC);
46562 if (!ep) {
46563 - atomic_inc(&mp->stats.no_free_exch);
46564 + atomic_inc_unchecked(&mp->stats.no_free_exch);
46565 goto out;
46566 }
46567 memset(ep, 0, sizeof(*ep));
46568 @@ -797,7 +797,7 @@ out:
46569 return ep;
46570 err:
46571 spin_unlock_bh(&pool->lock);
46572 - atomic_inc(&mp->stats.no_free_exch_xid);
46573 + atomic_inc_unchecked(&mp->stats.no_free_exch_xid);
46574 mempool_free(ep, mp->ep_pool);
46575 return NULL;
46576 }
46577 @@ -940,7 +940,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
46578 xid = ntohs(fh->fh_ox_id); /* we originated exch */
46579 ep = fc_exch_find(mp, xid);
46580 if (!ep) {
46581 - atomic_inc(&mp->stats.xid_not_found);
46582 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46583 reject = FC_RJT_OX_ID;
46584 goto out;
46585 }
46586 @@ -970,7 +970,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
46587 ep = fc_exch_find(mp, xid);
46588 if ((f_ctl & FC_FC_FIRST_SEQ) && fc_sof_is_init(fr_sof(fp))) {
46589 if (ep) {
46590 - atomic_inc(&mp->stats.xid_busy);
46591 + atomic_inc_unchecked(&mp->stats.xid_busy);
46592 reject = FC_RJT_RX_ID;
46593 goto rel;
46594 }
46595 @@ -981,7 +981,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
46596 }
46597 xid = ep->xid; /* get our XID */
46598 } else if (!ep) {
46599 - atomic_inc(&mp->stats.xid_not_found);
46600 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46601 reject = FC_RJT_RX_ID; /* XID not found */
46602 goto out;
46603 }
46604 @@ -998,7 +998,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
46605 } else {
46606 sp = &ep->seq;
46607 if (sp->id != fh->fh_seq_id) {
46608 - atomic_inc(&mp->stats.seq_not_found);
46609 + atomic_inc_unchecked(&mp->stats.seq_not_found);
46610 if (f_ctl & FC_FC_END_SEQ) {
46611 /*
46612 * Update sequence_id based on incoming last
46613 @@ -1448,22 +1448,22 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
46614
46615 ep = fc_exch_find(mp, ntohs(fh->fh_ox_id));
46616 if (!ep) {
46617 - atomic_inc(&mp->stats.xid_not_found);
46618 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46619 goto out;
46620 }
46621 if (ep->esb_stat & ESB_ST_COMPLETE) {
46622 - atomic_inc(&mp->stats.xid_not_found);
46623 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46624 goto rel;
46625 }
46626 if (ep->rxid == FC_XID_UNKNOWN)
46627 ep->rxid = ntohs(fh->fh_rx_id);
46628 if (ep->sid != 0 && ep->sid != ntoh24(fh->fh_d_id)) {
46629 - atomic_inc(&mp->stats.xid_not_found);
46630 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46631 goto rel;
46632 }
46633 if (ep->did != ntoh24(fh->fh_s_id) &&
46634 ep->did != FC_FID_FLOGI) {
46635 - atomic_inc(&mp->stats.xid_not_found);
46636 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46637 goto rel;
46638 }
46639 sof = fr_sof(fp);
46640 @@ -1472,7 +1472,7 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
46641 sp->ssb_stat |= SSB_ST_RESP;
46642 sp->id = fh->fh_seq_id;
46643 } else if (sp->id != fh->fh_seq_id) {
46644 - atomic_inc(&mp->stats.seq_not_found);
46645 + atomic_inc_unchecked(&mp->stats.seq_not_found);
46646 goto rel;
46647 }
46648
46649 @@ -1536,9 +1536,9 @@ static void fc_exch_recv_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
46650 sp = fc_seq_lookup_orig(mp, fp); /* doesn't hold sequence */
46651
46652 if (!sp)
46653 - atomic_inc(&mp->stats.xid_not_found);
46654 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46655 else
46656 - atomic_inc(&mp->stats.non_bls_resp);
46657 + atomic_inc_unchecked(&mp->stats.non_bls_resp);
46658
46659 fc_frame_free(fp);
46660 }
46661 @@ -2185,13 +2185,13 @@ void fc_exch_update_stats(struct fc_lport *lport)
46662
46663 list_for_each_entry(ema, &lport->ema_list, ema_list) {
46664 mp = ema->mp;
46665 - st->fc_no_free_exch += atomic_read(&mp->stats.no_free_exch);
46666 + st->fc_no_free_exch += atomic_read_unchecked(&mp->stats.no_free_exch);
46667 st->fc_no_free_exch_xid +=
46668 - atomic_read(&mp->stats.no_free_exch_xid);
46669 - st->fc_xid_not_found += atomic_read(&mp->stats.xid_not_found);
46670 - st->fc_xid_busy += atomic_read(&mp->stats.xid_busy);
46671 - st->fc_seq_not_found += atomic_read(&mp->stats.seq_not_found);
46672 - st->fc_non_bls_resp += atomic_read(&mp->stats.non_bls_resp);
46673 + atomic_read_unchecked(&mp->stats.no_free_exch_xid);
46674 + st->fc_xid_not_found += atomic_read_unchecked(&mp->stats.xid_not_found);
46675 + st->fc_xid_busy += atomic_read_unchecked(&mp->stats.xid_busy);
46676 + st->fc_seq_not_found += atomic_read_unchecked(&mp->stats.seq_not_found);
46677 + st->fc_non_bls_resp += atomic_read_unchecked(&mp->stats.non_bls_resp);
46678 }
46679 }
46680 EXPORT_SYMBOL(fc_exch_update_stats);
46681 diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c
46682 index d289583..b745eec 100644
46683 --- a/drivers/scsi/libsas/sas_ata.c
46684 +++ b/drivers/scsi/libsas/sas_ata.c
46685 @@ -554,7 +554,7 @@ static struct ata_port_operations sas_sata_ops = {
46686 .postreset = ata_std_postreset,
46687 .error_handler = ata_std_error_handler,
46688 .post_internal_cmd = sas_ata_post_internal,
46689 - .qc_defer = ata_std_qc_defer,
46690 + .qc_defer = ata_std_qc_defer,
46691 .qc_prep = ata_noop_qc_prep,
46692 .qc_issue = sas_ata_qc_issue,
46693 .qc_fill_rtf = sas_ata_qc_fill_rtf,
46694 diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
46695 index 4e1b75c..0bbdfa9 100644
46696 --- a/drivers/scsi/lpfc/lpfc.h
46697 +++ b/drivers/scsi/lpfc/lpfc.h
46698 @@ -432,7 +432,7 @@ struct lpfc_vport {
46699 struct dentry *debug_nodelist;
46700 struct dentry *vport_debugfs_root;
46701 struct lpfc_debugfs_trc *disc_trc;
46702 - atomic_t disc_trc_cnt;
46703 + atomic_unchecked_t disc_trc_cnt;
46704 #endif
46705 uint8_t stat_data_enabled;
46706 uint8_t stat_data_blocked;
46707 @@ -865,8 +865,8 @@ struct lpfc_hba {
46708 struct timer_list fabric_block_timer;
46709 unsigned long bit_flags;
46710 #define FABRIC_COMANDS_BLOCKED 0
46711 - atomic_t num_rsrc_err;
46712 - atomic_t num_cmd_success;
46713 + atomic_unchecked_t num_rsrc_err;
46714 + atomic_unchecked_t num_cmd_success;
46715 unsigned long last_rsrc_error_time;
46716 unsigned long last_ramp_down_time;
46717 unsigned long last_ramp_up_time;
46718 @@ -902,7 +902,7 @@ struct lpfc_hba {
46719
46720 struct dentry *debug_slow_ring_trc;
46721 struct lpfc_debugfs_trc *slow_ring_trc;
46722 - atomic_t slow_ring_trc_cnt;
46723 + atomic_unchecked_t slow_ring_trc_cnt;
46724 /* iDiag debugfs sub-directory */
46725 struct dentry *idiag_root;
46726 struct dentry *idiag_pci_cfg;
46727 diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
46728 index 60084e6..0e2e700 100644
46729 --- a/drivers/scsi/lpfc/lpfc_debugfs.c
46730 +++ b/drivers/scsi/lpfc/lpfc_debugfs.c
46731 @@ -106,7 +106,7 @@ MODULE_PARM_DESC(lpfc_debugfs_mask_disc_trc,
46732
46733 #include <linux/debugfs.h>
46734
46735 -static atomic_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
46736 +static atomic_unchecked_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
46737 static unsigned long lpfc_debugfs_start_time = 0L;
46738
46739 /* iDiag */
46740 @@ -147,7 +147,7 @@ lpfc_debugfs_disc_trc_data(struct lpfc_vport *vport, char *buf, int size)
46741 lpfc_debugfs_enable = 0;
46742
46743 len = 0;
46744 - index = (atomic_read(&vport->disc_trc_cnt) + 1) &
46745 + index = (atomic_read_unchecked(&vport->disc_trc_cnt) + 1) &
46746 (lpfc_debugfs_max_disc_trc - 1);
46747 for (i = index; i < lpfc_debugfs_max_disc_trc; i++) {
46748 dtp = vport->disc_trc + i;
46749 @@ -213,7 +213,7 @@ lpfc_debugfs_slow_ring_trc_data(struct lpfc_hba *phba, char *buf, int size)
46750 lpfc_debugfs_enable = 0;
46751
46752 len = 0;
46753 - index = (atomic_read(&phba->slow_ring_trc_cnt) + 1) &
46754 + index = (atomic_read_unchecked(&phba->slow_ring_trc_cnt) + 1) &
46755 (lpfc_debugfs_max_slow_ring_trc - 1);
46756 for (i = index; i < lpfc_debugfs_max_slow_ring_trc; i++) {
46757 dtp = phba->slow_ring_trc + i;
46758 @@ -646,14 +646,14 @@ lpfc_debugfs_disc_trc(struct lpfc_vport *vport, int mask, char *fmt,
46759 !vport || !vport->disc_trc)
46760 return;
46761
46762 - index = atomic_inc_return(&vport->disc_trc_cnt) &
46763 + index = atomic_inc_return_unchecked(&vport->disc_trc_cnt) &
46764 (lpfc_debugfs_max_disc_trc - 1);
46765 dtp = vport->disc_trc + index;
46766 dtp->fmt = fmt;
46767 dtp->data1 = data1;
46768 dtp->data2 = data2;
46769 dtp->data3 = data3;
46770 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
46771 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
46772 dtp->jif = jiffies;
46773 #endif
46774 return;
46775 @@ -684,14 +684,14 @@ lpfc_debugfs_slow_ring_trc(struct lpfc_hba *phba, char *fmt,
46776 !phba || !phba->slow_ring_trc)
46777 return;
46778
46779 - index = atomic_inc_return(&phba->slow_ring_trc_cnt) &
46780 + index = atomic_inc_return_unchecked(&phba->slow_ring_trc_cnt) &
46781 (lpfc_debugfs_max_slow_ring_trc - 1);
46782 dtp = phba->slow_ring_trc + index;
46783 dtp->fmt = fmt;
46784 dtp->data1 = data1;
46785 dtp->data2 = data2;
46786 dtp->data3 = data3;
46787 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
46788 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
46789 dtp->jif = jiffies;
46790 #endif
46791 return;
46792 @@ -4168,7 +4168,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
46793 "slow_ring buffer\n");
46794 goto debug_failed;
46795 }
46796 - atomic_set(&phba->slow_ring_trc_cnt, 0);
46797 + atomic_set_unchecked(&phba->slow_ring_trc_cnt, 0);
46798 memset(phba->slow_ring_trc, 0,
46799 (sizeof(struct lpfc_debugfs_trc) *
46800 lpfc_debugfs_max_slow_ring_trc));
46801 @@ -4214,7 +4214,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
46802 "buffer\n");
46803 goto debug_failed;
46804 }
46805 - atomic_set(&vport->disc_trc_cnt, 0);
46806 + atomic_set_unchecked(&vport->disc_trc_cnt, 0);
46807
46808 snprintf(name, sizeof(name), "discovery_trace");
46809 vport->debug_disc_trc =
46810 diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
46811 index 647f5bf..d0068b9 100644
46812 --- a/drivers/scsi/lpfc/lpfc_init.c
46813 +++ b/drivers/scsi/lpfc/lpfc_init.c
46814 @@ -10952,8 +10952,10 @@ lpfc_init(void)
46815 "misc_register returned with status %d", error);
46816
46817 if (lpfc_enable_npiv) {
46818 - lpfc_transport_functions.vport_create = lpfc_vport_create;
46819 - lpfc_transport_functions.vport_delete = lpfc_vport_delete;
46820 + pax_open_kernel();
46821 + *(void **)&lpfc_transport_functions.vport_create = lpfc_vport_create;
46822 + *(void **)&lpfc_transport_functions.vport_delete = lpfc_vport_delete;
46823 + pax_close_kernel();
46824 }
46825 lpfc_transport_template =
46826 fc_attach_transport(&lpfc_transport_functions);
46827 diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
46828 index c913e8c..d34a119 100644
46829 --- a/drivers/scsi/lpfc/lpfc_scsi.c
46830 +++ b/drivers/scsi/lpfc/lpfc_scsi.c
46831 @@ -353,7 +353,7 @@ lpfc_rampdown_queue_depth(struct lpfc_hba *phba)
46832 uint32_t evt_posted;
46833
46834 spin_lock_irqsave(&phba->hbalock, flags);
46835 - atomic_inc(&phba->num_rsrc_err);
46836 + atomic_inc_unchecked(&phba->num_rsrc_err);
46837 phba->last_rsrc_error_time = jiffies;
46838
46839 if ((phba->last_ramp_down_time + QUEUE_RAMP_DOWN_INTERVAL) > jiffies) {
46840 @@ -394,7 +394,7 @@ lpfc_rampup_queue_depth(struct lpfc_vport *vport,
46841 unsigned long flags;
46842 struct lpfc_hba *phba = vport->phba;
46843 uint32_t evt_posted;
46844 - atomic_inc(&phba->num_cmd_success);
46845 + atomic_inc_unchecked(&phba->num_cmd_success);
46846
46847 if (vport->cfg_lun_queue_depth <= queue_depth)
46848 return;
46849 @@ -438,8 +438,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
46850 unsigned long num_rsrc_err, num_cmd_success;
46851 int i;
46852
46853 - num_rsrc_err = atomic_read(&phba->num_rsrc_err);
46854 - num_cmd_success = atomic_read(&phba->num_cmd_success);
46855 + num_rsrc_err = atomic_read_unchecked(&phba->num_rsrc_err);
46856 + num_cmd_success = atomic_read_unchecked(&phba->num_cmd_success);
46857
46858 /*
46859 * The error and success command counters are global per
46860 @@ -467,8 +467,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
46861 }
46862 }
46863 lpfc_destroy_vport_work_array(phba, vports);
46864 - atomic_set(&phba->num_rsrc_err, 0);
46865 - atomic_set(&phba->num_cmd_success, 0);
46866 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
46867 + atomic_set_unchecked(&phba->num_cmd_success, 0);
46868 }
46869
46870 /**
46871 @@ -502,8 +502,8 @@ lpfc_ramp_up_queue_handler(struct lpfc_hba *phba)
46872 }
46873 }
46874 lpfc_destroy_vport_work_array(phba, vports);
46875 - atomic_set(&phba->num_rsrc_err, 0);
46876 - atomic_set(&phba->num_cmd_success, 0);
46877 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
46878 + atomic_set_unchecked(&phba->num_cmd_success, 0);
46879 }
46880
46881 /**
46882 diff --git a/drivers/scsi/mpt2sas/mpt2sas_scsih.c b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
46883 index 7f0af4f..193ac3e 100644
46884 --- a/drivers/scsi/mpt2sas/mpt2sas_scsih.c
46885 +++ b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
46886 @@ -1557,7 +1557,7 @@ _scsih_get_resync(struct device *dev)
46887 {
46888 struct scsi_device *sdev = to_scsi_device(dev);
46889 struct MPT2SAS_ADAPTER *ioc = shost_priv(sdev->host);
46890 - static struct _raid_device *raid_device;
46891 + struct _raid_device *raid_device;
46892 unsigned long flags;
46893 Mpi2RaidVolPage0_t vol_pg0;
46894 Mpi2ConfigReply_t mpi_reply;
46895 @@ -1609,7 +1609,7 @@ _scsih_get_state(struct device *dev)
46896 {
46897 struct scsi_device *sdev = to_scsi_device(dev);
46898 struct MPT2SAS_ADAPTER *ioc = shost_priv(sdev->host);
46899 - static struct _raid_device *raid_device;
46900 + struct _raid_device *raid_device;
46901 unsigned long flags;
46902 Mpi2RaidVolPage0_t vol_pg0;
46903 Mpi2ConfigReply_t mpi_reply;
46904 @@ -6637,7 +6637,7 @@ _scsih_sas_ir_operation_status_event(struct MPT2SAS_ADAPTER *ioc,
46905 struct fw_event_work *fw_event)
46906 {
46907 Mpi2EventDataIrOperationStatus_t *event_data = fw_event->event_data;
46908 - static struct _raid_device *raid_device;
46909 + struct _raid_device *raid_device;
46910 unsigned long flags;
46911 u16 handle;
46912
46913 @@ -7108,7 +7108,7 @@ _scsih_scan_for_devices_after_reset(struct MPT2SAS_ADAPTER *ioc)
46914 u64 sas_address;
46915 struct _sas_device *sas_device;
46916 struct _sas_node *expander_device;
46917 - static struct _raid_device *raid_device;
46918 + struct _raid_device *raid_device;
46919 u8 retry_count;
46920 unsigned long flags;
46921
46922 diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
46923 index a38f71b..f3bc572 100644
46924 --- a/drivers/scsi/pmcraid.c
46925 +++ b/drivers/scsi/pmcraid.c
46926 @@ -200,8 +200,8 @@ static int pmcraid_slave_alloc(struct scsi_device *scsi_dev)
46927 res->scsi_dev = scsi_dev;
46928 scsi_dev->hostdata = res;
46929 res->change_detected = 0;
46930 - atomic_set(&res->read_failures, 0);
46931 - atomic_set(&res->write_failures, 0);
46932 + atomic_set_unchecked(&res->read_failures, 0);
46933 + atomic_set_unchecked(&res->write_failures, 0);
46934 rc = 0;
46935 }
46936 spin_unlock_irqrestore(&pinstance->resource_lock, lock_flags);
46937 @@ -2676,9 +2676,9 @@ static int pmcraid_error_handler(struct pmcraid_cmd *cmd)
46938
46939 /* If this was a SCSI read/write command keep count of errors */
46940 if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_READ_CMD)
46941 - atomic_inc(&res->read_failures);
46942 + atomic_inc_unchecked(&res->read_failures);
46943 else if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_WRITE_CMD)
46944 - atomic_inc(&res->write_failures);
46945 + atomic_inc_unchecked(&res->write_failures);
46946
46947 if (!RES_IS_GSCSI(res->cfg_entry) &&
46948 masked_ioasc != PMCRAID_IOASC_HW_DEVICE_BUS_STATUS_ERROR) {
46949 @@ -3534,7 +3534,7 @@ static int pmcraid_queuecommand_lck(
46950 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
46951 * hrrq_id assigned here in queuecommand
46952 */
46953 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
46954 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
46955 pinstance->num_hrrq;
46956 cmd->cmd_done = pmcraid_io_done;
46957
46958 @@ -3846,7 +3846,7 @@ static long pmcraid_ioctl_passthrough(
46959 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
46960 * hrrq_id assigned here in queuecommand
46961 */
46962 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
46963 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
46964 pinstance->num_hrrq;
46965
46966 if (request_size) {
46967 @@ -4484,7 +4484,7 @@ static void pmcraid_worker_function(struct work_struct *workp)
46968
46969 pinstance = container_of(workp, struct pmcraid_instance, worker_q);
46970 /* add resources only after host is added into system */
46971 - if (!atomic_read(&pinstance->expose_resources))
46972 + if (!atomic_read_unchecked(&pinstance->expose_resources))
46973 return;
46974
46975 fw_version = be16_to_cpu(pinstance->inq_data->fw_version);
46976 @@ -5311,8 +5311,8 @@ static int pmcraid_init_instance(struct pci_dev *pdev, struct Scsi_Host *host,
46977 init_waitqueue_head(&pinstance->reset_wait_q);
46978
46979 atomic_set(&pinstance->outstanding_cmds, 0);
46980 - atomic_set(&pinstance->last_message_id, 0);
46981 - atomic_set(&pinstance->expose_resources, 0);
46982 + atomic_set_unchecked(&pinstance->last_message_id, 0);
46983 + atomic_set_unchecked(&pinstance->expose_resources, 0);
46984
46985 INIT_LIST_HEAD(&pinstance->free_res_q);
46986 INIT_LIST_HEAD(&pinstance->used_res_q);
46987 @@ -6025,7 +6025,7 @@ static int pmcraid_probe(struct pci_dev *pdev,
46988 /* Schedule worker thread to handle CCN and take care of adding and
46989 * removing devices to OS
46990 */
46991 - atomic_set(&pinstance->expose_resources, 1);
46992 + atomic_set_unchecked(&pinstance->expose_resources, 1);
46993 schedule_work(&pinstance->worker_q);
46994 return rc;
46995
46996 diff --git a/drivers/scsi/pmcraid.h b/drivers/scsi/pmcraid.h
46997 index e1d150f..6c6df44 100644
46998 --- a/drivers/scsi/pmcraid.h
46999 +++ b/drivers/scsi/pmcraid.h
47000 @@ -748,7 +748,7 @@ struct pmcraid_instance {
47001 struct pmcraid_isr_param hrrq_vector[PMCRAID_NUM_MSIX_VECTORS];
47002
47003 /* Message id as filled in last fired IOARCB, used to identify HRRQ */
47004 - atomic_t last_message_id;
47005 + atomic_unchecked_t last_message_id;
47006
47007 /* configuration table */
47008 struct pmcraid_config_table *cfg_table;
47009 @@ -777,7 +777,7 @@ struct pmcraid_instance {
47010 atomic_t outstanding_cmds;
47011
47012 /* should add/delete resources to mid-layer now ?*/
47013 - atomic_t expose_resources;
47014 + atomic_unchecked_t expose_resources;
47015
47016
47017
47018 @@ -813,8 +813,8 @@ struct pmcraid_resource_entry {
47019 struct pmcraid_config_table_entry_ext cfg_entry_ext;
47020 };
47021 struct scsi_device *scsi_dev; /* Link scsi_device structure */
47022 - atomic_t read_failures; /* count of failed READ commands */
47023 - atomic_t write_failures; /* count of failed WRITE commands */
47024 + atomic_unchecked_t read_failures; /* count of failed READ commands */
47025 + atomic_unchecked_t write_failures; /* count of failed WRITE commands */
47026
47027 /* To indicate add/delete/modify during CCN */
47028 u8 change_detected;
47029 diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
47030 index 5f174b8..98d32b0 100644
47031 --- a/drivers/scsi/qla2xxx/qla_attr.c
47032 +++ b/drivers/scsi/qla2xxx/qla_attr.c
47033 @@ -2040,7 +2040,7 @@ qla24xx_vport_disable(struct fc_vport *fc_vport, bool disable)
47034 return 0;
47035 }
47036
47037 -struct fc_function_template qla2xxx_transport_functions = {
47038 +fc_function_template_no_const qla2xxx_transport_functions = {
47039
47040 .show_host_node_name = 1,
47041 .show_host_port_name = 1,
47042 @@ -2088,7 +2088,7 @@ struct fc_function_template qla2xxx_transport_functions = {
47043 .bsg_timeout = qla24xx_bsg_timeout,
47044 };
47045
47046 -struct fc_function_template qla2xxx_transport_vport_functions = {
47047 +fc_function_template_no_const qla2xxx_transport_vport_functions = {
47048
47049 .show_host_node_name = 1,
47050 .show_host_port_name = 1,
47051 diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
47052 index 4446bf5..9a3574d 100644
47053 --- a/drivers/scsi/qla2xxx/qla_gbl.h
47054 +++ b/drivers/scsi/qla2xxx/qla_gbl.h
47055 @@ -538,8 +538,8 @@ extern void qla2x00_get_sym_node_name(scsi_qla_host_t *, uint8_t *);
47056 struct device_attribute;
47057 extern struct device_attribute *qla2x00_host_attrs[];
47058 struct fc_function_template;
47059 -extern struct fc_function_template qla2xxx_transport_functions;
47060 -extern struct fc_function_template qla2xxx_transport_vport_functions;
47061 +extern fc_function_template_no_const qla2xxx_transport_functions;
47062 +extern fc_function_template_no_const qla2xxx_transport_vport_functions;
47063 extern void qla2x00_alloc_sysfs_attr(scsi_qla_host_t *);
47064 extern void qla2x00_free_sysfs_attr(scsi_qla_host_t *);
47065 extern void qla2x00_init_host_attr(scsi_qla_host_t *);
47066 diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
47067 index 9f01bbb..5e1dcee 100644
47068 --- a/drivers/scsi/qla2xxx/qla_os.c
47069 +++ b/drivers/scsi/qla2xxx/qla_os.c
47070 @@ -1572,8 +1572,10 @@ qla2x00_config_dma_addressing(struct qla_hw_data *ha)
47071 !pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(64))) {
47072 /* Ok, a 64bit DMA mask is applicable. */
47073 ha->flags.enable_64bit_addressing = 1;
47074 - ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
47075 - ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
47076 + pax_open_kernel();
47077 + *(void **)&ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
47078 + *(void **)&ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
47079 + pax_close_kernel();
47080 return;
47081 }
47082 }
47083 diff --git a/drivers/scsi/qla4xxx/ql4_def.h b/drivers/scsi/qla4xxx/ql4_def.h
47084 index 41327d4..feb03d479 100644
47085 --- a/drivers/scsi/qla4xxx/ql4_def.h
47086 +++ b/drivers/scsi/qla4xxx/ql4_def.h
47087 @@ -296,7 +296,7 @@ struct ddb_entry {
47088 * (4000 only) */
47089 atomic_t relogin_timer; /* Max Time to wait for
47090 * relogin to complete */
47091 - atomic_t relogin_retry_count; /* Num of times relogin has been
47092 + atomic_unchecked_t relogin_retry_count; /* Num of times relogin has been
47093 * retried */
47094 uint32_t default_time2wait; /* Default Min time between
47095 * relogins (+aens) */
47096 diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
47097 index f8a0a26..ec03cee 100644
47098 --- a/drivers/scsi/qla4xxx/ql4_os.c
47099 +++ b/drivers/scsi/qla4xxx/ql4_os.c
47100 @@ -3066,12 +3066,12 @@ static void qla4xxx_check_relogin_flash_ddb(struct iscsi_cls_session *cls_sess)
47101 */
47102 if (!iscsi_is_session_online(cls_sess)) {
47103 /* Reset retry relogin timer */
47104 - atomic_inc(&ddb_entry->relogin_retry_count);
47105 + atomic_inc_unchecked(&ddb_entry->relogin_retry_count);
47106 DEBUG2(ql4_printk(KERN_INFO, ha,
47107 "%s: index[%d] relogin timed out-retrying"
47108 " relogin (%d), retry (%d)\n", __func__,
47109 ddb_entry->fw_ddb_index,
47110 - atomic_read(&ddb_entry->relogin_retry_count),
47111 + atomic_read_unchecked(&ddb_entry->relogin_retry_count),
47112 ddb_entry->default_time2wait + 4));
47113 set_bit(DPC_RELOGIN_DEVICE, &ha->dpc_flags);
47114 atomic_set(&ddb_entry->retry_relogin_timer,
47115 @@ -5209,7 +5209,7 @@ static void qla4xxx_setup_flash_ddb_entry(struct scsi_qla_host *ha,
47116
47117 atomic_set(&ddb_entry->retry_relogin_timer, INVALID_ENTRY);
47118 atomic_set(&ddb_entry->relogin_timer, 0);
47119 - atomic_set(&ddb_entry->relogin_retry_count, 0);
47120 + atomic_set_unchecked(&ddb_entry->relogin_retry_count, 0);
47121 def_timeout = le16_to_cpu(ddb_entry->fw_ddb_entry.def_timeout);
47122 ddb_entry->default_relogin_timeout =
47123 (def_timeout > LOGIN_TOV) && (def_timeout < LOGIN_TOV * 10) ?
47124 diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
47125 index eaa808e..95f8841 100644
47126 --- a/drivers/scsi/scsi.c
47127 +++ b/drivers/scsi/scsi.c
47128 @@ -661,7 +661,7 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
47129 unsigned long timeout;
47130 int rtn = 0;
47131
47132 - atomic_inc(&cmd->device->iorequest_cnt);
47133 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
47134
47135 /* check if the device is still usable */
47136 if (unlikely(cmd->device->sdev_state == SDEV_DEL)) {
47137 diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
47138 index d1549b7..2f60767 100644
47139 --- a/drivers/scsi/scsi_lib.c
47140 +++ b/drivers/scsi/scsi_lib.c
47141 @@ -1474,7 +1474,7 @@ static void scsi_kill_request(struct request *req, struct request_queue *q)
47142 shost = sdev->host;
47143 scsi_init_cmd_errh(cmd);
47144 cmd->result = DID_NO_CONNECT << 16;
47145 - atomic_inc(&cmd->device->iorequest_cnt);
47146 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
47147
47148 /*
47149 * SCSI request completion path will do scsi_device_unbusy(),
47150 @@ -1500,9 +1500,9 @@ static void scsi_softirq_done(struct request *rq)
47151
47152 INIT_LIST_HEAD(&cmd->eh_entry);
47153
47154 - atomic_inc(&cmd->device->iodone_cnt);
47155 + atomic_inc_unchecked(&cmd->device->iodone_cnt);
47156 if (cmd->result)
47157 - atomic_inc(&cmd->device->ioerr_cnt);
47158 + atomic_inc_unchecked(&cmd->device->ioerr_cnt);
47159
47160 disposition = scsi_decide_disposition(cmd);
47161 if (disposition != SUCCESS &&
47162 diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
47163 index 40c6394..62356c2 100644
47164 --- a/drivers/scsi/scsi_sysfs.c
47165 +++ b/drivers/scsi/scsi_sysfs.c
47166 @@ -687,7 +687,7 @@ show_iostat_##field(struct device *dev, struct device_attribute *attr, \
47167 char *buf) \
47168 { \
47169 struct scsi_device *sdev = to_scsi_device(dev); \
47170 - unsigned long long count = atomic_read(&sdev->field); \
47171 + unsigned long long count = atomic_read_unchecked(&sdev->field); \
47172 return snprintf(buf, 20, "0x%llx\n", count); \
47173 } \
47174 static DEVICE_ATTR(field, S_IRUGO, show_iostat_##field, NULL)
47175 diff --git a/drivers/scsi/scsi_tgt_lib.c b/drivers/scsi/scsi_tgt_lib.c
47176 index 84a1fdf..693b0d6 100644
47177 --- a/drivers/scsi/scsi_tgt_lib.c
47178 +++ b/drivers/scsi/scsi_tgt_lib.c
47179 @@ -362,7 +362,7 @@ static int scsi_map_user_pages(struct scsi_tgt_cmd *tcmd, struct scsi_cmnd *cmd,
47180 int err;
47181
47182 dprintk("%lx %u\n", uaddr, len);
47183 - err = blk_rq_map_user(q, rq, NULL, (void *)uaddr, len, GFP_KERNEL);
47184 + err = blk_rq_map_user(q, rq, NULL, (void __user *)uaddr, len, GFP_KERNEL);
47185 if (err) {
47186 /*
47187 * TODO: need to fixup sg_tablesize, max_segment_size,
47188 diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
47189 index 4628fd5..a94a1c2 100644
47190 --- a/drivers/scsi/scsi_transport_fc.c
47191 +++ b/drivers/scsi/scsi_transport_fc.c
47192 @@ -497,7 +497,7 @@ static DECLARE_TRANSPORT_CLASS(fc_vport_class,
47193 * Netlink Infrastructure
47194 */
47195
47196 -static atomic_t fc_event_seq;
47197 +static atomic_unchecked_t fc_event_seq;
47198
47199 /**
47200 * fc_get_event_number - Obtain the next sequential FC event number
47201 @@ -510,7 +510,7 @@ static atomic_t fc_event_seq;
47202 u32
47203 fc_get_event_number(void)
47204 {
47205 - return atomic_add_return(1, &fc_event_seq);
47206 + return atomic_add_return_unchecked(1, &fc_event_seq);
47207 }
47208 EXPORT_SYMBOL(fc_get_event_number);
47209
47210 @@ -654,7 +654,7 @@ static __init int fc_transport_init(void)
47211 {
47212 int error;
47213
47214 - atomic_set(&fc_event_seq, 0);
47215 + atomic_set_unchecked(&fc_event_seq, 0);
47216
47217 error = transport_class_register(&fc_host_class);
47218 if (error)
47219 @@ -844,7 +844,7 @@ static int fc_str_to_dev_loss(const char *buf, unsigned long *val)
47220 char *cp;
47221
47222 *val = simple_strtoul(buf, &cp, 0);
47223 - if ((*cp && (*cp != '\n')) || (*val < 0))
47224 + if (*cp && (*cp != '\n'))
47225 return -EINVAL;
47226 /*
47227 * Check for overflow; dev_loss_tmo is u32
47228 diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
47229 index e4a989f..293090c 100644
47230 --- a/drivers/scsi/scsi_transport_iscsi.c
47231 +++ b/drivers/scsi/scsi_transport_iscsi.c
47232 @@ -79,7 +79,7 @@ struct iscsi_internal {
47233 struct transport_container session_cont;
47234 };
47235
47236 -static atomic_t iscsi_session_nr; /* sysfs session id for next new session */
47237 +static atomic_unchecked_t iscsi_session_nr; /* sysfs session id for next new session */
47238 static struct workqueue_struct *iscsi_eh_timer_workq;
47239
47240 static DEFINE_IDA(iscsi_sess_ida);
47241 @@ -1737,7 +1737,7 @@ int iscsi_add_session(struct iscsi_cls_session *session, unsigned int target_id)
47242 int err;
47243
47244 ihost = shost->shost_data;
47245 - session->sid = atomic_add_return(1, &iscsi_session_nr);
47246 + session->sid = atomic_add_return_unchecked(1, &iscsi_session_nr);
47247
47248 if (target_id == ISCSI_MAX_TARGET) {
47249 id = ida_simple_get(&iscsi_sess_ida, 0, 0, GFP_KERNEL);
47250 @@ -4077,7 +4077,7 @@ static __init int iscsi_transport_init(void)
47251 printk(KERN_INFO "Loading iSCSI transport class v%s.\n",
47252 ISCSI_TRANSPORT_VERSION);
47253
47254 - atomic_set(&iscsi_session_nr, 0);
47255 + atomic_set_unchecked(&iscsi_session_nr, 0);
47256
47257 err = class_register(&iscsi_transport_class);
47258 if (err)
47259 diff --git a/drivers/scsi/scsi_transport_srp.c b/drivers/scsi/scsi_transport_srp.c
47260 index f379c7f..e8fc69c 100644
47261 --- a/drivers/scsi/scsi_transport_srp.c
47262 +++ b/drivers/scsi/scsi_transport_srp.c
47263 @@ -33,7 +33,7 @@
47264 #include "scsi_transport_srp_internal.h"
47265
47266 struct srp_host_attrs {
47267 - atomic_t next_port_id;
47268 + atomic_unchecked_t next_port_id;
47269 };
47270 #define to_srp_host_attrs(host) ((struct srp_host_attrs *)(host)->shost_data)
47271
47272 @@ -61,7 +61,7 @@ static int srp_host_setup(struct transport_container *tc, struct device *dev,
47273 struct Scsi_Host *shost = dev_to_shost(dev);
47274 struct srp_host_attrs *srp_host = to_srp_host_attrs(shost);
47275
47276 - atomic_set(&srp_host->next_port_id, 0);
47277 + atomic_set_unchecked(&srp_host->next_port_id, 0);
47278 return 0;
47279 }
47280
47281 @@ -210,7 +210,7 @@ struct srp_rport *srp_rport_add(struct Scsi_Host *shost,
47282 memcpy(rport->port_id, ids->port_id, sizeof(rport->port_id));
47283 rport->roles = ids->roles;
47284
47285 - id = atomic_inc_return(&to_srp_host_attrs(shost)->next_port_id);
47286 + id = atomic_inc_return_unchecked(&to_srp_host_attrs(shost)->next_port_id);
47287 dev_set_name(&rport->dev, "port-%d:%d", shost->host_no, id);
47288
47289 transport_setup_device(&rport->dev);
47290 diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
47291 index 2634d69..fcf7a81 100644
47292 --- a/drivers/scsi/sd.c
47293 +++ b/drivers/scsi/sd.c
47294 @@ -2940,7 +2940,7 @@ static int sd_probe(struct device *dev)
47295 sdkp->disk = gd;
47296 sdkp->index = index;
47297 atomic_set(&sdkp->openers, 0);
47298 - atomic_set(&sdkp->device->ioerr_cnt, 0);
47299 + atomic_set_unchecked(&sdkp->device->ioerr_cnt, 0);
47300
47301 if (!sdp->request_queue->rq_timeout) {
47302 if (sdp->type != TYPE_MOD)
47303 diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
47304 index df5e961..df6b97f 100644
47305 --- a/drivers/scsi/sg.c
47306 +++ b/drivers/scsi/sg.c
47307 @@ -1102,7 +1102,7 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
47308 sdp->disk->disk_name,
47309 MKDEV(SCSI_GENERIC_MAJOR, sdp->index),
47310 NULL,
47311 - (char *)arg);
47312 + (char __user *)arg);
47313 case BLKTRACESTART:
47314 return blk_trace_startstop(sdp->device->request_queue, 1);
47315 case BLKTRACESTOP:
47316 diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
47317 index 9e039c6..ae9e800 100644
47318 --- a/drivers/spi/spi.c
47319 +++ b/drivers/spi/spi.c
47320 @@ -1762,7 +1762,7 @@ int spi_bus_unlock(struct spi_master *master)
47321 EXPORT_SYMBOL_GPL(spi_bus_unlock);
47322
47323 /* portable code must never pass more than 32 bytes */
47324 -#define SPI_BUFSIZ max(32,SMP_CACHE_BYTES)
47325 +#define SPI_BUFSIZ max(32UL,SMP_CACHE_BYTES)
47326
47327 static u8 *buf;
47328
47329 diff --git a/drivers/staging/android/timed_output.c b/drivers/staging/android/timed_output.c
47330 index 2c61783..4d49e4e 100644
47331 --- a/drivers/staging/android/timed_output.c
47332 +++ b/drivers/staging/android/timed_output.c
47333 @@ -25,7 +25,7 @@
47334 #include "timed_output.h"
47335
47336 static struct class *timed_output_class;
47337 -static atomic_t device_count;
47338 +static atomic_unchecked_t device_count;
47339
47340 static ssize_t enable_show(struct device *dev, struct device_attribute *attr,
47341 char *buf)
47342 @@ -63,7 +63,7 @@ static int create_timed_output_class(void)
47343 timed_output_class = class_create(THIS_MODULE, "timed_output");
47344 if (IS_ERR(timed_output_class))
47345 return PTR_ERR(timed_output_class);
47346 - atomic_set(&device_count, 0);
47347 + atomic_set_unchecked(&device_count, 0);
47348 timed_output_class->dev_groups = timed_output_groups;
47349 }
47350
47351 @@ -81,7 +81,7 @@ int timed_output_dev_register(struct timed_output_dev *tdev)
47352 if (ret < 0)
47353 return ret;
47354
47355 - tdev->index = atomic_inc_return(&device_count);
47356 + tdev->index = atomic_inc_return_unchecked(&device_count);
47357 tdev->dev = device_create(timed_output_class, NULL,
47358 MKDEV(0, tdev->index), NULL, "%s", tdev->name);
47359 if (IS_ERR(tdev->dev))
47360 diff --git a/drivers/staging/gdm724x/gdm_tty.c b/drivers/staging/gdm724x/gdm_tty.c
47361 index 0247a20..cb9595c 100644
47362 --- a/drivers/staging/gdm724x/gdm_tty.c
47363 +++ b/drivers/staging/gdm724x/gdm_tty.c
47364 @@ -45,7 +45,7 @@
47365 #define gdm_tty_send_control(n, r, v, d, l) (\
47366 n->tty_dev->send_control(n->tty_dev->priv_dev, r, v, d, l))
47367
47368 -#define GDM_TTY_READY(gdm) (gdm && gdm->tty_dev && gdm->port.count)
47369 +#define GDM_TTY_READY(gdm) (gdm && gdm->tty_dev && atomic_read(&gdm->port.count))
47370
47371 static struct tty_driver *gdm_driver[TTY_MAX_COUNT];
47372 static struct gdm *gdm_table[TTY_MAX_COUNT][GDM_TTY_MINOR];
47373 diff --git a/drivers/staging/lustre/lnet/selftest/brw_test.c b/drivers/staging/lustre/lnet/selftest/brw_test.c
47374 index ef5064e..fce01db 100644
47375 --- a/drivers/staging/lustre/lnet/selftest/brw_test.c
47376 +++ b/drivers/staging/lustre/lnet/selftest/brw_test.c
47377 @@ -478,13 +478,11 @@ brw_server_handle(struct srpc_server_rpc *rpc)
47378 return 0;
47379 }
47380
47381 -sfw_test_client_ops_t brw_test_client;
47382 -void brw_init_test_client(void)
47383 -{
47384 - brw_test_client.tso_init = brw_client_init;
47385 - brw_test_client.tso_fini = brw_client_fini;
47386 - brw_test_client.tso_prep_rpc = brw_client_prep_rpc;
47387 - brw_test_client.tso_done_rpc = brw_client_done_rpc;
47388 +sfw_test_client_ops_t brw_test_client = {
47389 + .tso_init = brw_client_init,
47390 + .tso_fini = brw_client_fini,
47391 + .tso_prep_rpc = brw_client_prep_rpc,
47392 + .tso_done_rpc = brw_client_done_rpc,
47393 };
47394
47395 srpc_service_t brw_test_service;
47396 diff --git a/drivers/staging/lustre/lnet/selftest/framework.c b/drivers/staging/lustre/lnet/selftest/framework.c
47397 index 483c785..e1a2a7b 100644
47398 --- a/drivers/staging/lustre/lnet/selftest/framework.c
47399 +++ b/drivers/staging/lustre/lnet/selftest/framework.c
47400 @@ -1635,12 +1635,10 @@ static srpc_service_t sfw_services[] =
47401
47402 extern sfw_test_client_ops_t ping_test_client;
47403 extern srpc_service_t ping_test_service;
47404 -extern void ping_init_test_client(void);
47405 extern void ping_init_test_service(void);
47406
47407 extern sfw_test_client_ops_t brw_test_client;
47408 extern srpc_service_t brw_test_service;
47409 -extern void brw_init_test_client(void);
47410 extern void brw_init_test_service(void);
47411
47412
47413 @@ -1684,12 +1682,10 @@ sfw_startup (void)
47414 INIT_LIST_HEAD(&sfw_data.fw_zombie_rpcs);
47415 INIT_LIST_HEAD(&sfw_data.fw_zombie_sessions);
47416
47417 - brw_init_test_client();
47418 brw_init_test_service();
47419 rc = sfw_register_test(&brw_test_service, &brw_test_client);
47420 LASSERT (rc == 0);
47421
47422 - ping_init_test_client();
47423 ping_init_test_service();
47424 rc = sfw_register_test(&ping_test_service, &ping_test_client);
47425 LASSERT (rc == 0);
47426 diff --git a/drivers/staging/lustre/lnet/selftest/ping_test.c b/drivers/staging/lustre/lnet/selftest/ping_test.c
47427 index f0f9194..b589047 100644
47428 --- a/drivers/staging/lustre/lnet/selftest/ping_test.c
47429 +++ b/drivers/staging/lustre/lnet/selftest/ping_test.c
47430 @@ -210,14 +210,12 @@ ping_server_handle(struct srpc_server_rpc *rpc)
47431 return 0;
47432 }
47433
47434 -sfw_test_client_ops_t ping_test_client;
47435 -void ping_init_test_client(void)
47436 -{
47437 - ping_test_client.tso_init = ping_client_init;
47438 - ping_test_client.tso_fini = ping_client_fini;
47439 - ping_test_client.tso_prep_rpc = ping_client_prep_rpc;
47440 - ping_test_client.tso_done_rpc = ping_client_done_rpc;
47441 -}
47442 +sfw_test_client_ops_t ping_test_client = {
47443 + .tso_init = ping_client_init,
47444 + .tso_fini = ping_client_fini,
47445 + .tso_prep_rpc = ping_client_prep_rpc,
47446 + .tso_done_rpc = ping_client_done_rpc,
47447 +};
47448
47449 srpc_service_t ping_test_service;
47450 void ping_init_test_service(void)
47451 diff --git a/drivers/staging/lustre/lustre/include/lustre_dlm.h b/drivers/staging/lustre/lustre/include/lustre_dlm.h
47452 index 7020d9c..0d3b580 100644
47453 --- a/drivers/staging/lustre/lustre/include/lustre_dlm.h
47454 +++ b/drivers/staging/lustre/lustre/include/lustre_dlm.h
47455 @@ -1141,7 +1141,7 @@ struct ldlm_callback_suite {
47456 ldlm_completion_callback lcs_completion;
47457 ldlm_blocking_callback lcs_blocking;
47458 ldlm_glimpse_callback lcs_glimpse;
47459 -};
47460 +} __no_const;
47461
47462 /* ldlm_lockd.c */
47463 int ldlm_del_waiting_lock(struct ldlm_lock *lock);
47464 diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h
47465 index a612255..9a9e2dd 100644
47466 --- a/drivers/staging/lustre/lustre/include/obd.h
47467 +++ b/drivers/staging/lustre/lustre/include/obd.h
47468 @@ -1417,7 +1417,7 @@ struct md_ops {
47469 * lprocfs_alloc_md_stats() in obdclass/lprocfs_status.c. Also, add a
47470 * wrapper function in include/linux/obd_class.h.
47471 */
47472 -};
47473 +} __no_const;
47474
47475 struct lsm_operations {
47476 void (*lsm_free)(struct lov_stripe_md *);
47477 diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-proc.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-proc.c
47478 index fc6c977..df1f956 100644
47479 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-proc.c
47480 +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-proc.c
47481 @@ -219,7 +219,7 @@ DECLARE_PROC_HANDLER(proc_debug_mb)
47482 int LL_PROC_PROTO(proc_console_max_delay_cs)
47483 {
47484 int rc, max_delay_cs;
47485 - ctl_table_t dummy = *table;
47486 + ctl_table_no_const dummy = *table;
47487 cfs_duration_t d;
47488
47489 dummy.data = &max_delay_cs;
47490 @@ -250,7 +250,7 @@ int LL_PROC_PROTO(proc_console_max_delay_cs)
47491 int LL_PROC_PROTO(proc_console_min_delay_cs)
47492 {
47493 int rc, min_delay_cs;
47494 - ctl_table_t dummy = *table;
47495 + ctl_table_no_const dummy = *table;
47496 cfs_duration_t d;
47497
47498 dummy.data = &min_delay_cs;
47499 @@ -281,7 +281,7 @@ int LL_PROC_PROTO(proc_console_min_delay_cs)
47500 int LL_PROC_PROTO(proc_console_backoff)
47501 {
47502 int rc, backoff;
47503 - ctl_table_t dummy = *table;
47504 + ctl_table_no_const dummy = *table;
47505
47506 dummy.data = &backoff;
47507 dummy.proc_handler = &proc_dointvec;
47508 diff --git a/drivers/staging/media/solo6x10/solo6x10-core.c b/drivers/staging/media/solo6x10/solo6x10-core.c
47509 index 3675020..e80d92c 100644
47510 --- a/drivers/staging/media/solo6x10/solo6x10-core.c
47511 +++ b/drivers/staging/media/solo6x10/solo6x10-core.c
47512 @@ -434,7 +434,7 @@ static void solo_device_release(struct device *dev)
47513
47514 static int solo_sysfs_init(struct solo_dev *solo_dev)
47515 {
47516 - struct bin_attribute *sdram_attr = &solo_dev->sdram_attr;
47517 + bin_attribute_no_const *sdram_attr = &solo_dev->sdram_attr;
47518 struct device *dev = &solo_dev->dev;
47519 const char *driver;
47520 int i;
47521 diff --git a/drivers/staging/media/solo6x10/solo6x10-p2m.c b/drivers/staging/media/solo6x10/solo6x10-p2m.c
47522 index 3335941..2b26186 100644
47523 --- a/drivers/staging/media/solo6x10/solo6x10-p2m.c
47524 +++ b/drivers/staging/media/solo6x10/solo6x10-p2m.c
47525 @@ -77,7 +77,7 @@ int solo_p2m_dma_desc(struct solo_dev *solo_dev,
47526
47527 /* Get next ID. According to Softlogic, 6110 has problems on !=0 P2M */
47528 if (solo_dev->type != SOLO_DEV_6110 && multi_p2m) {
47529 - p2m_id = atomic_inc_return(&solo_dev->p2m_count) % SOLO_NR_P2M;
47530 + p2m_id = atomic_inc_return_unchecked(&solo_dev->p2m_count) % SOLO_NR_P2M;
47531 if (p2m_id < 0)
47532 p2m_id = -p2m_id;
47533 }
47534 diff --git a/drivers/staging/media/solo6x10/solo6x10.h b/drivers/staging/media/solo6x10/solo6x10.h
47535 index 6f91d2e..3f011d2 100644
47536 --- a/drivers/staging/media/solo6x10/solo6x10.h
47537 +++ b/drivers/staging/media/solo6x10/solo6x10.h
47538 @@ -238,7 +238,7 @@ struct solo_dev {
47539
47540 /* P2M DMA Engine */
47541 struct solo_p2m_dev p2m_dev[SOLO_NR_P2M];
47542 - atomic_t p2m_count;
47543 + atomic_unchecked_t p2m_count;
47544 int p2m_jiffies;
47545 unsigned int p2m_timeouts;
47546
47547 diff --git a/drivers/staging/octeon/ethernet-rx.c b/drivers/staging/octeon/ethernet-rx.c
47548 index e14a1bb..9cb9bbe 100644
47549 --- a/drivers/staging/octeon/ethernet-rx.c
47550 +++ b/drivers/staging/octeon/ethernet-rx.c
47551 @@ -419,11 +419,11 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
47552 /* Increment RX stats for virtual ports */
47553 if (work->ipprt >= CVMX_PIP_NUM_INPUT_PORTS) {
47554 #ifdef CONFIG_64BIT
47555 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_packets);
47556 - atomic64_add(skb->len, (atomic64_t *)&priv->stats.rx_bytes);
47557 + atomic64_add_unchecked(1, (atomic64_unchecked_t *)&priv->stats.rx_packets);
47558 + atomic64_add_unchecked(skb->len, (atomic64_unchecked_t *)&priv->stats.rx_bytes);
47559 #else
47560 - atomic_add(1, (atomic_t *)&priv->stats.rx_packets);
47561 - atomic_add(skb->len, (atomic_t *)&priv->stats.rx_bytes);
47562 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_packets);
47563 + atomic_add_unchecked(skb->len, (atomic_unchecked_t *)&priv->stats.rx_bytes);
47564 #endif
47565 }
47566 netif_receive_skb(skb);
47567 @@ -434,9 +434,9 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
47568 dev->name);
47569 */
47570 #ifdef CONFIG_64BIT
47571 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_dropped);
47572 + atomic64_unchecked_add(1, (atomic64_unchecked_t *)&priv->stats.rx_dropped);
47573 #else
47574 - atomic_add(1, (atomic_t *)&priv->stats.rx_dropped);
47575 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_dropped);
47576 #endif
47577 dev_kfree_skb_irq(skb);
47578 }
47579 diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c
47580 index c3a90e7..023619a 100644
47581 --- a/drivers/staging/octeon/ethernet.c
47582 +++ b/drivers/staging/octeon/ethernet.c
47583 @@ -252,11 +252,11 @@ static struct net_device_stats *cvm_oct_common_get_stats(struct net_device *dev)
47584 * since the RX tasklet also increments it.
47585 */
47586 #ifdef CONFIG_64BIT
47587 - atomic64_add(rx_status.dropped_packets,
47588 - (atomic64_t *)&priv->stats.rx_dropped);
47589 + atomic64_add_unchecked(rx_status.dropped_packets,
47590 + (atomic64_unchecked_t *)&priv->stats.rx_dropped);
47591 #else
47592 - atomic_add(rx_status.dropped_packets,
47593 - (atomic_t *)&priv->stats.rx_dropped);
47594 + atomic_add_unchecked(rx_status.dropped_packets,
47595 + (atomic_unchecked_t *)&priv->stats.rx_dropped);
47596 #endif
47597 }
47598
47599 diff --git a/drivers/staging/rtl8188eu/include/hal_intf.h b/drivers/staging/rtl8188eu/include/hal_intf.h
47600 index 439c3c9..2d74293 100644
47601 --- a/drivers/staging/rtl8188eu/include/hal_intf.h
47602 +++ b/drivers/staging/rtl8188eu/include/hal_intf.h
47603 @@ -271,7 +271,7 @@ struct hal_ops {
47604 s32 (*c2h_handler)(struct adapter *padapter,
47605 struct c2h_evt_hdr *c2h_evt);
47606 c2h_id_filter c2h_id_filter_ccx;
47607 -};
47608 +} __no_const;
47609
47610 enum rt_eeprom_type {
47611 EEPROM_93C46,
47612 diff --git a/drivers/staging/rtl8188eu/include/rtw_io.h b/drivers/staging/rtl8188eu/include/rtw_io.h
47613 index eb6f0e5..e6a0958 100644
47614 --- a/drivers/staging/rtl8188eu/include/rtw_io.h
47615 +++ b/drivers/staging/rtl8188eu/include/rtw_io.h
47616 @@ -126,7 +126,7 @@ struct _io_ops {
47617 u32 (*_write_scsi)(struct intf_hdl *pintfhdl,u32 cnt, u8 *pmem);
47618 void (*_read_port_cancel)(struct intf_hdl *pintfhdl);
47619 void (*_write_port_cancel)(struct intf_hdl *pintfhdl);
47620 -};
47621 +} __no_const;
47622
47623 struct io_req {
47624 struct list_head list;
47625 diff --git a/drivers/staging/rtl8712/rtl871x_io.h b/drivers/staging/rtl8712/rtl871x_io.h
47626 index dc23395..cf7e9b1 100644
47627 --- a/drivers/staging/rtl8712/rtl871x_io.h
47628 +++ b/drivers/staging/rtl8712/rtl871x_io.h
47629 @@ -108,7 +108,7 @@ struct _io_ops {
47630 u8 *pmem);
47631 u32 (*_write_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt,
47632 u8 *pmem);
47633 -};
47634 +} __no_const;
47635
47636 struct io_req {
47637 struct list_head list;
47638 diff --git a/drivers/staging/sbe-2t3e3/netdev.c b/drivers/staging/sbe-2t3e3/netdev.c
47639 index 1f5088b..0e59820 100644
47640 --- a/drivers/staging/sbe-2t3e3/netdev.c
47641 +++ b/drivers/staging/sbe-2t3e3/netdev.c
47642 @@ -51,7 +51,7 @@ static int t3e3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
47643 t3e3_if_config(sc, cmd_2t3e3, (char *)&param, &resp, &rlen);
47644
47645 if (rlen)
47646 - if (copy_to_user(data, &resp, rlen))
47647 + if (rlen > sizeof resp || copy_to_user(data, &resp, rlen))
47648 return -EFAULT;
47649
47650 return 0;
47651 diff --git a/drivers/staging/usbip/vhci.h b/drivers/staging/usbip/vhci.h
47652 index a863a98..d272795 100644
47653 --- a/drivers/staging/usbip/vhci.h
47654 +++ b/drivers/staging/usbip/vhci.h
47655 @@ -83,7 +83,7 @@ struct vhci_hcd {
47656 unsigned resuming:1;
47657 unsigned long re_timeout;
47658
47659 - atomic_t seqnum;
47660 + atomic_unchecked_t seqnum;
47661
47662 /*
47663 * NOTE:
47664 diff --git a/drivers/staging/usbip/vhci_hcd.c b/drivers/staging/usbip/vhci_hcd.c
47665 index d7974cb..d78076b 100644
47666 --- a/drivers/staging/usbip/vhci_hcd.c
47667 +++ b/drivers/staging/usbip/vhci_hcd.c
47668 @@ -441,7 +441,7 @@ static void vhci_tx_urb(struct urb *urb)
47669
47670 spin_lock(&vdev->priv_lock);
47671
47672 - priv->seqnum = atomic_inc_return(&the_controller->seqnum);
47673 + priv->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
47674 if (priv->seqnum == 0xffff)
47675 dev_info(&urb->dev->dev, "seqnum max\n");
47676
47677 @@ -687,7 +687,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
47678 return -ENOMEM;
47679 }
47680
47681 - unlink->seqnum = atomic_inc_return(&the_controller->seqnum);
47682 + unlink->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
47683 if (unlink->seqnum == 0xffff)
47684 pr_info("seqnum max\n");
47685
47686 @@ -891,7 +891,7 @@ static int vhci_start(struct usb_hcd *hcd)
47687 vdev->rhport = rhport;
47688 }
47689
47690 - atomic_set(&vhci->seqnum, 0);
47691 + atomic_set_unchecked(&vhci->seqnum, 0);
47692 spin_lock_init(&vhci->lock);
47693
47694 hcd->power_budget = 0; /* no limit */
47695 diff --git a/drivers/staging/usbip/vhci_rx.c b/drivers/staging/usbip/vhci_rx.c
47696 index d07fcb5..358e1e1 100644
47697 --- a/drivers/staging/usbip/vhci_rx.c
47698 +++ b/drivers/staging/usbip/vhci_rx.c
47699 @@ -80,7 +80,7 @@ static void vhci_recv_ret_submit(struct vhci_device *vdev,
47700 if (!urb) {
47701 pr_err("cannot find a urb of seqnum %u\n", pdu->base.seqnum);
47702 pr_info("max seqnum %d\n",
47703 - atomic_read(&the_controller->seqnum));
47704 + atomic_read_unchecked(&the_controller->seqnum));
47705 usbip_event_add(ud, VDEV_EVENT_ERROR_TCP);
47706 return;
47707 }
47708 diff --git a/drivers/staging/vt6655/hostap.c b/drivers/staging/vt6655/hostap.c
47709 index 8acff44..bdb2fca 100644
47710 --- a/drivers/staging/vt6655/hostap.c
47711 +++ b/drivers/staging/vt6655/hostap.c
47712 @@ -69,14 +69,13 @@ static int msglevel = MSG_LEVEL_INFO;
47713 *
47714 */
47715
47716 +static net_device_ops_no_const apdev_netdev_ops;
47717 +
47718 static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
47719 {
47720 PSDevice apdev_priv;
47721 struct net_device *dev = pDevice->dev;
47722 int ret;
47723 - const struct net_device_ops apdev_netdev_ops = {
47724 - .ndo_start_xmit = pDevice->tx_80211,
47725 - };
47726
47727 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
47728
47729 @@ -88,6 +87,8 @@ static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
47730 *apdev_priv = *pDevice;
47731 eth_hw_addr_inherit(pDevice->apdev, dev);
47732
47733 + /* only half broken now */
47734 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
47735 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
47736
47737 pDevice->apdev->type = ARPHRD_IEEE80211;
47738 diff --git a/drivers/staging/vt6656/hostap.c b/drivers/staging/vt6656/hostap.c
47739 index c699a30..b90a5fd 100644
47740 --- a/drivers/staging/vt6656/hostap.c
47741 +++ b/drivers/staging/vt6656/hostap.c
47742 @@ -60,14 +60,13 @@ static int msglevel =MSG_LEVEL_INFO;
47743 *
47744 */
47745
47746 +static net_device_ops_no_const apdev_netdev_ops;
47747 +
47748 static int hostap_enable_hostapd(struct vnt_private *pDevice, int rtnl_locked)
47749 {
47750 struct vnt_private *apdev_priv;
47751 struct net_device *dev = pDevice->dev;
47752 int ret;
47753 - const struct net_device_ops apdev_netdev_ops = {
47754 - .ndo_start_xmit = pDevice->tx_80211,
47755 - };
47756
47757 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
47758
47759 @@ -79,6 +78,8 @@ static int hostap_enable_hostapd(struct vnt_private *pDevice, int rtnl_locked)
47760 *apdev_priv = *pDevice;
47761 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
47762
47763 + /* only half broken now */
47764 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
47765 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
47766
47767 pDevice->apdev->type = ARPHRD_IEEE80211;
47768 diff --git a/drivers/target/sbp/sbp_target.c b/drivers/target/sbp/sbp_target.c
47769 index e51b09a..5ebac31 100644
47770 --- a/drivers/target/sbp/sbp_target.c
47771 +++ b/drivers/target/sbp/sbp_target.c
47772 @@ -62,7 +62,7 @@ static const u32 sbp_unit_directory_template[] = {
47773
47774 #define SESSION_MAINTENANCE_INTERVAL HZ
47775
47776 -static atomic_t login_id = ATOMIC_INIT(0);
47777 +static atomic_unchecked_t login_id = ATOMIC_INIT(0);
47778
47779 static void session_maintenance_work(struct work_struct *);
47780 static int sbp_run_transaction(struct fw_card *, int, int, int, int,
47781 @@ -444,7 +444,7 @@ static void sbp_management_request_login(
47782 login->lun = se_lun;
47783 login->status_fifo_addr = sbp2_pointer_to_addr(&req->orb.status_fifo);
47784 login->exclusive = LOGIN_ORB_EXCLUSIVE(be32_to_cpu(req->orb.misc));
47785 - login->login_id = atomic_inc_return(&login_id);
47786 + login->login_id = atomic_inc_return_unchecked(&login_id);
47787
47788 login->tgt_agt = sbp_target_agent_register(login);
47789 if (IS_ERR(login->tgt_agt)) {
47790 diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
47791 index d90dbb0..6cbe585 100644
47792 --- a/drivers/target/target_core_device.c
47793 +++ b/drivers/target/target_core_device.c
47794 @@ -1431,7 +1431,7 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name)
47795 spin_lock_init(&dev->se_tmr_lock);
47796 spin_lock_init(&dev->qf_cmd_lock);
47797 sema_init(&dev->caw_sem, 1);
47798 - atomic_set(&dev->dev_ordered_id, 0);
47799 + atomic_set_unchecked(&dev->dev_ordered_id, 0);
47800 INIT_LIST_HEAD(&dev->t10_wwn.t10_vpd_list);
47801 spin_lock_init(&dev->t10_wwn.t10_vpd_lock);
47802 INIT_LIST_HEAD(&dev->t10_pr.registration_list);
47803 diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
47804 index 0b0009b..215e88e 100644
47805 --- a/drivers/target/target_core_transport.c
47806 +++ b/drivers/target/target_core_transport.c
47807 @@ -1137,7 +1137,7 @@ transport_check_alloc_task_attr(struct se_cmd *cmd)
47808 * Used to determine when ORDERED commands should go from
47809 * Dormant to Active status.
47810 */
47811 - cmd->se_ordered_id = atomic_inc_return(&dev->dev_ordered_id);
47812 + cmd->se_ordered_id = atomic_inc_return_unchecked(&dev->dev_ordered_id);
47813 smp_mb__after_atomic_inc();
47814 pr_debug("Allocated se_ordered_id: %u for Task Attr: 0x%02x on %s\n",
47815 cmd->se_ordered_id, cmd->sam_task_attr,
47816 diff --git a/drivers/tty/cyclades.c b/drivers/tty/cyclades.c
47817 index 33f83fe..d80f8e1 100644
47818 --- a/drivers/tty/cyclades.c
47819 +++ b/drivers/tty/cyclades.c
47820 @@ -1570,10 +1570,10 @@ static int cy_open(struct tty_struct *tty, struct file *filp)
47821 printk(KERN_DEBUG "cyc:cy_open ttyC%d, count = %d\n", info->line,
47822 info->port.count);
47823 #endif
47824 - info->port.count++;
47825 + atomic_inc(&info->port.count);
47826 #ifdef CY_DEBUG_COUNT
47827 printk(KERN_DEBUG "cyc:cy_open (%d): incrementing count to %d\n",
47828 - current->pid, info->port.count);
47829 + current->pid, atomic_read(&info->port.count));
47830 #endif
47831
47832 /*
47833 @@ -3972,7 +3972,7 @@ static int cyclades_proc_show(struct seq_file *m, void *v)
47834 for (j = 0; j < cy_card[i].nports; j++) {
47835 info = &cy_card[i].ports[j];
47836
47837 - if (info->port.count) {
47838 + if (atomic_read(&info->port.count)) {
47839 /* XXX is the ldisc num worth this? */
47840 struct tty_struct *tty;
47841 struct tty_ldisc *ld;
47842 diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
47843 index 9eba119..5070303 100644
47844 --- a/drivers/tty/hvc/hvc_console.c
47845 +++ b/drivers/tty/hvc/hvc_console.c
47846 @@ -338,7 +338,7 @@ static int hvc_open(struct tty_struct *tty, struct file * filp)
47847
47848 spin_lock_irqsave(&hp->port.lock, flags);
47849 /* Check and then increment for fast path open. */
47850 - if (hp->port.count++ > 0) {
47851 + if (atomic_inc_return(&hp->port.count) > 1) {
47852 spin_unlock_irqrestore(&hp->port.lock, flags);
47853 hvc_kick();
47854 return 0;
47855 @@ -393,7 +393,7 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
47856
47857 spin_lock_irqsave(&hp->port.lock, flags);
47858
47859 - if (--hp->port.count == 0) {
47860 + if (atomic_dec_return(&hp->port.count) == 0) {
47861 spin_unlock_irqrestore(&hp->port.lock, flags);
47862 /* We are done with the tty pointer now. */
47863 tty_port_tty_set(&hp->port, NULL);
47864 @@ -415,9 +415,9 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
47865 */
47866 tty_wait_until_sent_from_close(tty, HVC_CLOSE_WAIT);
47867 } else {
47868 - if (hp->port.count < 0)
47869 + if (atomic_read(&hp->port.count) < 0)
47870 printk(KERN_ERR "hvc_close %X: oops, count is %d\n",
47871 - hp->vtermno, hp->port.count);
47872 + hp->vtermno, atomic_read(&hp->port.count));
47873 spin_unlock_irqrestore(&hp->port.lock, flags);
47874 }
47875 }
47876 @@ -447,12 +447,12 @@ static void hvc_hangup(struct tty_struct *tty)
47877 * open->hangup case this can be called after the final close so prevent
47878 * that from happening for now.
47879 */
47880 - if (hp->port.count <= 0) {
47881 + if (atomic_read(&hp->port.count) <= 0) {
47882 spin_unlock_irqrestore(&hp->port.lock, flags);
47883 return;
47884 }
47885
47886 - hp->port.count = 0;
47887 + atomic_set(&hp->port.count, 0);
47888 spin_unlock_irqrestore(&hp->port.lock, flags);
47889 tty_port_tty_set(&hp->port, NULL);
47890
47891 @@ -500,7 +500,7 @@ static int hvc_write(struct tty_struct *tty, const unsigned char *buf, int count
47892 return -EPIPE;
47893
47894 /* FIXME what's this (unprotected) check for? */
47895 - if (hp->port.count <= 0)
47896 + if (atomic_read(&hp->port.count) <= 0)
47897 return -EIO;
47898
47899 spin_lock_irqsave(&hp->lock, flags);
47900 diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c
47901 index 81e939e..95ead10 100644
47902 --- a/drivers/tty/hvc/hvcs.c
47903 +++ b/drivers/tty/hvc/hvcs.c
47904 @@ -83,6 +83,7 @@
47905 #include <asm/hvcserver.h>
47906 #include <asm/uaccess.h>
47907 #include <asm/vio.h>
47908 +#include <asm/local.h>
47909
47910 /*
47911 * 1.3.0 -> 1.3.1 In hvcs_open memset(..,0x00,..) instead of memset(..,0x3F,00).
47912 @@ -416,7 +417,7 @@ static ssize_t hvcs_vterm_state_store(struct device *dev, struct device_attribut
47913
47914 spin_lock_irqsave(&hvcsd->lock, flags);
47915
47916 - if (hvcsd->port.count > 0) {
47917 + if (atomic_read(&hvcsd->port.count) > 0) {
47918 spin_unlock_irqrestore(&hvcsd->lock, flags);
47919 printk(KERN_INFO "HVCS: vterm state unchanged. "
47920 "The hvcs device node is still in use.\n");
47921 @@ -1127,7 +1128,7 @@ static int hvcs_install(struct tty_driver *driver, struct tty_struct *tty)
47922 }
47923 }
47924
47925 - hvcsd->port.count = 0;
47926 + atomic_set(&hvcsd->port.count, 0);
47927 hvcsd->port.tty = tty;
47928 tty->driver_data = hvcsd;
47929
47930 @@ -1180,7 +1181,7 @@ static int hvcs_open(struct tty_struct *tty, struct file *filp)
47931 unsigned long flags;
47932
47933 spin_lock_irqsave(&hvcsd->lock, flags);
47934 - hvcsd->port.count++;
47935 + atomic_inc(&hvcsd->port.count);
47936 hvcsd->todo_mask |= HVCS_SCHED_READ;
47937 spin_unlock_irqrestore(&hvcsd->lock, flags);
47938
47939 @@ -1216,7 +1217,7 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
47940 hvcsd = tty->driver_data;
47941
47942 spin_lock_irqsave(&hvcsd->lock, flags);
47943 - if (--hvcsd->port.count == 0) {
47944 + if (atomic_dec_and_test(&hvcsd->port.count)) {
47945
47946 vio_disable_interrupts(hvcsd->vdev);
47947
47948 @@ -1241,10 +1242,10 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
47949
47950 free_irq(irq, hvcsd);
47951 return;
47952 - } else if (hvcsd->port.count < 0) {
47953 + } else if (atomic_read(&hvcsd->port.count) < 0) {
47954 printk(KERN_ERR "HVCS: vty-server@%X open_count: %d"
47955 " is missmanaged.\n",
47956 - hvcsd->vdev->unit_address, hvcsd->port.count);
47957 + hvcsd->vdev->unit_address, atomic_read(&hvcsd->port.count));
47958 }
47959
47960 spin_unlock_irqrestore(&hvcsd->lock, flags);
47961 @@ -1266,7 +1267,7 @@ static void hvcs_hangup(struct tty_struct * tty)
47962
47963 spin_lock_irqsave(&hvcsd->lock, flags);
47964 /* Preserve this so that we know how many kref refs to put */
47965 - temp_open_count = hvcsd->port.count;
47966 + temp_open_count = atomic_read(&hvcsd->port.count);
47967
47968 /*
47969 * Don't kref put inside the spinlock because the destruction
47970 @@ -1281,7 +1282,7 @@ static void hvcs_hangup(struct tty_struct * tty)
47971 tty->driver_data = NULL;
47972 hvcsd->port.tty = NULL;
47973
47974 - hvcsd->port.count = 0;
47975 + atomic_set(&hvcsd->port.count, 0);
47976
47977 /* This will drop any buffered data on the floor which is OK in a hangup
47978 * scenario. */
47979 @@ -1352,7 +1353,7 @@ static int hvcs_write(struct tty_struct *tty,
47980 * the middle of a write operation? This is a crummy place to do this
47981 * but we want to keep it all in the spinlock.
47982 */
47983 - if (hvcsd->port.count <= 0) {
47984 + if (atomic_read(&hvcsd->port.count) <= 0) {
47985 spin_unlock_irqrestore(&hvcsd->lock, flags);
47986 return -ENODEV;
47987 }
47988 @@ -1426,7 +1427,7 @@ static int hvcs_write_room(struct tty_struct *tty)
47989 {
47990 struct hvcs_struct *hvcsd = tty->driver_data;
47991
47992 - if (!hvcsd || hvcsd->port.count <= 0)
47993 + if (!hvcsd || atomic_read(&hvcsd->port.count) <= 0)
47994 return 0;
47995
47996 return HVCS_BUFF_LEN - hvcsd->chars_in_buffer;
47997 diff --git a/drivers/tty/hvc/hvsi.c b/drivers/tty/hvc/hvsi.c
47998 index 4190199..48f2920 100644
47999 --- a/drivers/tty/hvc/hvsi.c
48000 +++ b/drivers/tty/hvc/hvsi.c
48001 @@ -85,7 +85,7 @@ struct hvsi_struct {
48002 int n_outbuf;
48003 uint32_t vtermno;
48004 uint32_t virq;
48005 - atomic_t seqno; /* HVSI packet sequence number */
48006 + atomic_unchecked_t seqno; /* HVSI packet sequence number */
48007 uint16_t mctrl;
48008 uint8_t state; /* HVSI protocol state */
48009 uint8_t flags;
48010 @@ -295,7 +295,7 @@ static int hvsi_version_respond(struct hvsi_struct *hp, uint16_t query_seqno)
48011
48012 packet.hdr.type = VS_QUERY_RESPONSE_PACKET_HEADER;
48013 packet.hdr.len = sizeof(struct hvsi_query_response);
48014 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
48015 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
48016 packet.verb = VSV_SEND_VERSION_NUMBER;
48017 packet.u.version = HVSI_VERSION;
48018 packet.query_seqno = query_seqno+1;
48019 @@ -555,7 +555,7 @@ static int hvsi_query(struct hvsi_struct *hp, uint16_t verb)
48020
48021 packet.hdr.type = VS_QUERY_PACKET_HEADER;
48022 packet.hdr.len = sizeof(struct hvsi_query);
48023 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
48024 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
48025 packet.verb = verb;
48026
48027 pr_debug("%s: sending %i bytes\n", __func__, packet.hdr.len);
48028 @@ -597,7 +597,7 @@ static int hvsi_set_mctrl(struct hvsi_struct *hp, uint16_t mctrl)
48029 int wrote;
48030
48031 packet.hdr.type = VS_CONTROL_PACKET_HEADER,
48032 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
48033 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
48034 packet.hdr.len = sizeof(struct hvsi_control);
48035 packet.verb = VSV_SET_MODEM_CTL;
48036 packet.mask = HVSI_TSDTR;
48037 @@ -680,7 +680,7 @@ static int hvsi_put_chars(struct hvsi_struct *hp, const char *buf, int count)
48038 BUG_ON(count > HVSI_MAX_OUTGOING_DATA);
48039
48040 packet.hdr.type = VS_DATA_PACKET_HEADER;
48041 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
48042 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
48043 packet.hdr.len = count + sizeof(struct hvsi_header);
48044 memcpy(&packet.data, buf, count);
48045
48046 @@ -697,7 +697,7 @@ static void hvsi_close_protocol(struct hvsi_struct *hp)
48047 struct hvsi_control packet __ALIGNED__;
48048
48049 packet.hdr.type = VS_CONTROL_PACKET_HEADER;
48050 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
48051 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
48052 packet.hdr.len = 6;
48053 packet.verb = VSV_CLOSE_PROTOCOL;
48054
48055 diff --git a/drivers/tty/hvc/hvsi_lib.c b/drivers/tty/hvc/hvsi_lib.c
48056 index ac27671..0f627ee 100644
48057 --- a/drivers/tty/hvc/hvsi_lib.c
48058 +++ b/drivers/tty/hvc/hvsi_lib.c
48059 @@ -9,7 +9,7 @@
48060
48061 static int hvsi_send_packet(struct hvsi_priv *pv, struct hvsi_header *packet)
48062 {
48063 - packet->seqno = atomic_inc_return(&pv->seqno);
48064 + packet->seqno = atomic_inc_return_unchecked(&pv->seqno);
48065
48066 /* Assumes that always succeeds, works in practice */
48067 return pv->put_chars(pv->termno, (char *)packet, packet->len);
48068 @@ -21,7 +21,7 @@ static void hvsi_start_handshake(struct hvsi_priv *pv)
48069
48070 /* Reset state */
48071 pv->established = 0;
48072 - atomic_set(&pv->seqno, 0);
48073 + atomic_set_unchecked(&pv->seqno, 0);
48074
48075 pr_devel("HVSI@%x: Handshaking started\n", pv->termno);
48076
48077 @@ -265,7 +265,7 @@ int hvsilib_read_mctrl(struct hvsi_priv *pv)
48078 pv->mctrl_update = 0;
48079 q.hdr.type = VS_QUERY_PACKET_HEADER;
48080 q.hdr.len = sizeof(struct hvsi_query);
48081 - q.hdr.seqno = atomic_inc_return(&pv->seqno);
48082 + q.hdr.seqno = atomic_inc_return_unchecked(&pv->seqno);
48083 q.verb = VSV_SEND_MODEM_CTL_STATUS;
48084 rc = hvsi_send_packet(pv, &q.hdr);
48085 if (rc <= 0) {
48086 diff --git a/drivers/tty/ipwireless/tty.c b/drivers/tty/ipwireless/tty.c
48087 index 8fd72ff..34a0bed 100644
48088 --- a/drivers/tty/ipwireless/tty.c
48089 +++ b/drivers/tty/ipwireless/tty.c
48090 @@ -29,6 +29,7 @@
48091 #include <linux/tty_driver.h>
48092 #include <linux/tty_flip.h>
48093 #include <linux/uaccess.h>
48094 +#include <asm/local.h>
48095
48096 #include "tty.h"
48097 #include "network.h"
48098 @@ -99,10 +100,10 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
48099 mutex_unlock(&tty->ipw_tty_mutex);
48100 return -ENODEV;
48101 }
48102 - if (tty->port.count == 0)
48103 + if (atomic_read(&tty->port.count) == 0)
48104 tty->tx_bytes_queued = 0;
48105
48106 - tty->port.count++;
48107 + atomic_inc(&tty->port.count);
48108
48109 tty->port.tty = linux_tty;
48110 linux_tty->driver_data = tty;
48111 @@ -118,9 +119,7 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
48112
48113 static void do_ipw_close(struct ipw_tty *tty)
48114 {
48115 - tty->port.count--;
48116 -
48117 - if (tty->port.count == 0) {
48118 + if (atomic_dec_return(&tty->port.count) == 0) {
48119 struct tty_struct *linux_tty = tty->port.tty;
48120
48121 if (linux_tty != NULL) {
48122 @@ -141,7 +140,7 @@ static void ipw_hangup(struct tty_struct *linux_tty)
48123 return;
48124
48125 mutex_lock(&tty->ipw_tty_mutex);
48126 - if (tty->port.count == 0) {
48127 + if (atomic_read(&tty->port.count) == 0) {
48128 mutex_unlock(&tty->ipw_tty_mutex);
48129 return;
48130 }
48131 @@ -164,7 +163,7 @@ void ipwireless_tty_received(struct ipw_tty *tty, unsigned char *data,
48132
48133 mutex_lock(&tty->ipw_tty_mutex);
48134
48135 - if (!tty->port.count) {
48136 + if (!atomic_read(&tty->port.count)) {
48137 mutex_unlock(&tty->ipw_tty_mutex);
48138 return;
48139 }
48140 @@ -206,7 +205,7 @@ static int ipw_write(struct tty_struct *linux_tty,
48141 return -ENODEV;
48142
48143 mutex_lock(&tty->ipw_tty_mutex);
48144 - if (!tty->port.count) {
48145 + if (!atomic_read(&tty->port.count)) {
48146 mutex_unlock(&tty->ipw_tty_mutex);
48147 return -EINVAL;
48148 }
48149 @@ -246,7 +245,7 @@ static int ipw_write_room(struct tty_struct *linux_tty)
48150 if (!tty)
48151 return -ENODEV;
48152
48153 - if (!tty->port.count)
48154 + if (!atomic_read(&tty->port.count))
48155 return -EINVAL;
48156
48157 room = IPWIRELESS_TX_QUEUE_SIZE - tty->tx_bytes_queued;
48158 @@ -288,7 +287,7 @@ static int ipw_chars_in_buffer(struct tty_struct *linux_tty)
48159 if (!tty)
48160 return 0;
48161
48162 - if (!tty->port.count)
48163 + if (!atomic_read(&tty->port.count))
48164 return 0;
48165
48166 return tty->tx_bytes_queued;
48167 @@ -369,7 +368,7 @@ static int ipw_tiocmget(struct tty_struct *linux_tty)
48168 if (!tty)
48169 return -ENODEV;
48170
48171 - if (!tty->port.count)
48172 + if (!atomic_read(&tty->port.count))
48173 return -EINVAL;
48174
48175 return get_control_lines(tty);
48176 @@ -385,7 +384,7 @@ ipw_tiocmset(struct tty_struct *linux_tty,
48177 if (!tty)
48178 return -ENODEV;
48179
48180 - if (!tty->port.count)
48181 + if (!atomic_read(&tty->port.count))
48182 return -EINVAL;
48183
48184 return set_control_lines(tty, set, clear);
48185 @@ -399,7 +398,7 @@ static int ipw_ioctl(struct tty_struct *linux_tty,
48186 if (!tty)
48187 return -ENODEV;
48188
48189 - if (!tty->port.count)
48190 + if (!atomic_read(&tty->port.count))
48191 return -EINVAL;
48192
48193 /* FIXME: Exactly how is the tty object locked here .. */
48194 @@ -555,7 +554,7 @@ void ipwireless_tty_free(struct ipw_tty *tty)
48195 * are gone */
48196 mutex_lock(&ttyj->ipw_tty_mutex);
48197 }
48198 - while (ttyj->port.count)
48199 + while (atomic_read(&ttyj->port.count))
48200 do_ipw_close(ttyj);
48201 ipwireless_disassociate_network_ttys(network,
48202 ttyj->channel_idx);
48203 diff --git a/drivers/tty/moxa.c b/drivers/tty/moxa.c
48204 index 1deaca4..c8582d4 100644
48205 --- a/drivers/tty/moxa.c
48206 +++ b/drivers/tty/moxa.c
48207 @@ -1189,7 +1189,7 @@ static int moxa_open(struct tty_struct *tty, struct file *filp)
48208 }
48209
48210 ch = &brd->ports[port % MAX_PORTS_PER_BOARD];
48211 - ch->port.count++;
48212 + atomic_inc(&ch->port.count);
48213 tty->driver_data = ch;
48214 tty_port_tty_set(&ch->port, tty);
48215 mutex_lock(&ch->port.mutex);
48216 diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
48217 index c0f76da..d974c32 100644
48218 --- a/drivers/tty/n_gsm.c
48219 +++ b/drivers/tty/n_gsm.c
48220 @@ -1632,7 +1632,7 @@ static struct gsm_dlci *gsm_dlci_alloc(struct gsm_mux *gsm, int addr)
48221 spin_lock_init(&dlci->lock);
48222 mutex_init(&dlci->mutex);
48223 dlci->fifo = &dlci->_fifo;
48224 - if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL) < 0) {
48225 + if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL)) {
48226 kfree(dlci);
48227 return NULL;
48228 }
48229 @@ -2935,7 +2935,7 @@ static int gsmtty_open(struct tty_struct *tty, struct file *filp)
48230 struct gsm_dlci *dlci = tty->driver_data;
48231 struct tty_port *port = &dlci->port;
48232
48233 - port->count++;
48234 + atomic_inc(&port->count);
48235 dlci_get(dlci);
48236 dlci_get(dlci->gsm->dlci[0]);
48237 mux_get(dlci->gsm);
48238 diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
48239 index 4d6f430..0810fa9 100644
48240 --- a/drivers/tty/n_tty.c
48241 +++ b/drivers/tty/n_tty.c
48242 @@ -2504,6 +2504,7 @@ void n_tty_inherit_ops(struct tty_ldisc_ops *ops)
48243 {
48244 *ops = tty_ldisc_N_TTY;
48245 ops->owner = NULL;
48246 - ops->refcount = ops->flags = 0;
48247 + atomic_set(&ops->refcount, 0);
48248 + ops->flags = 0;
48249 }
48250 EXPORT_SYMBOL_GPL(n_tty_inherit_ops);
48251 diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
48252 index 25c9bc7..24077b7 100644
48253 --- a/drivers/tty/pty.c
48254 +++ b/drivers/tty/pty.c
48255 @@ -790,8 +790,10 @@ static void __init unix98_pty_init(void)
48256 panic("Couldn't register Unix98 pts driver");
48257
48258 /* Now create the /dev/ptmx special device */
48259 + pax_open_kernel();
48260 tty_default_fops(&ptmx_fops);
48261 - ptmx_fops.open = ptmx_open;
48262 + *(void **)&ptmx_fops.open = ptmx_open;
48263 + pax_close_kernel();
48264
48265 cdev_init(&ptmx_cdev, &ptmx_fops);
48266 if (cdev_add(&ptmx_cdev, MKDEV(TTYAUX_MAJOR, 2), 1) ||
48267 diff --git a/drivers/tty/rocket.c b/drivers/tty/rocket.c
48268 index 354564e..fe50d9a 100644
48269 --- a/drivers/tty/rocket.c
48270 +++ b/drivers/tty/rocket.c
48271 @@ -914,7 +914,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
48272 tty->driver_data = info;
48273 tty_port_tty_set(port, tty);
48274
48275 - if (port->count++ == 0) {
48276 + if (atomic_inc_return(&port->count) == 1) {
48277 atomic_inc(&rp_num_ports_open);
48278
48279 #ifdef ROCKET_DEBUG_OPEN
48280 @@ -923,7 +923,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
48281 #endif
48282 }
48283 #ifdef ROCKET_DEBUG_OPEN
48284 - printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, info->port.count);
48285 + printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, atomic-read(&info->port.count));
48286 #endif
48287
48288 /*
48289 @@ -1515,7 +1515,7 @@ static void rp_hangup(struct tty_struct *tty)
48290 spin_unlock_irqrestore(&info->port.lock, flags);
48291 return;
48292 }
48293 - if (info->port.count)
48294 + if (atomic_read(&info->port.count))
48295 atomic_dec(&rp_num_ports_open);
48296 clear_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]);
48297 spin_unlock_irqrestore(&info->port.lock, flags);
48298 diff --git a/drivers/tty/serial/ioc4_serial.c b/drivers/tty/serial/ioc4_serial.c
48299 index 1274499..f541382 100644
48300 --- a/drivers/tty/serial/ioc4_serial.c
48301 +++ b/drivers/tty/serial/ioc4_serial.c
48302 @@ -437,7 +437,7 @@ struct ioc4_soft {
48303 } is_intr_info[MAX_IOC4_INTR_ENTS];
48304
48305 /* Number of entries active in the above array */
48306 - atomic_t is_num_intrs;
48307 + atomic_unchecked_t is_num_intrs;
48308 } is_intr_type[IOC4_NUM_INTR_TYPES];
48309
48310 /* is_ir_lock must be held while
48311 @@ -974,7 +974,7 @@ intr_connect(struct ioc4_soft *soft, int type,
48312 BUG_ON(!((type == IOC4_SIO_INTR_TYPE)
48313 || (type == IOC4_OTHER_INTR_TYPE)));
48314
48315 - i = atomic_inc_return(&soft-> is_intr_type[type].is_num_intrs) - 1;
48316 + i = atomic_inc_return_unchecked(&soft-> is_intr_type[type].is_num_intrs) - 1;
48317 BUG_ON(!(i < MAX_IOC4_INTR_ENTS || (printk("i %d\n", i), 0)));
48318
48319 /* Save off the lower level interrupt handler */
48320 @@ -1001,7 +1001,7 @@ static irqreturn_t ioc4_intr(int irq, void *arg)
48321
48322 soft = arg;
48323 for (intr_type = 0; intr_type < IOC4_NUM_INTR_TYPES; intr_type++) {
48324 - num_intrs = (int)atomic_read(
48325 + num_intrs = (int)atomic_read_unchecked(
48326 &soft->is_intr_type[intr_type].is_num_intrs);
48327
48328 this_mir = this_ir = pending_intrs(soft, intr_type);
48329 diff --git a/drivers/tty/serial/kgdboc.c b/drivers/tty/serial/kgdboc.c
48330 index a260cde..6b2b5ce 100644
48331 --- a/drivers/tty/serial/kgdboc.c
48332 +++ b/drivers/tty/serial/kgdboc.c
48333 @@ -24,8 +24,9 @@
48334 #define MAX_CONFIG_LEN 40
48335
48336 static struct kgdb_io kgdboc_io_ops;
48337 +static struct kgdb_io kgdboc_io_ops_console;
48338
48339 -/* -1 = init not run yet, 0 = unconfigured, 1 = configured. */
48340 +/* -1 = init not run yet, 0 = unconfigured, 1/2 = configured. */
48341 static int configured = -1;
48342
48343 static char config[MAX_CONFIG_LEN];
48344 @@ -151,6 +152,8 @@ static void cleanup_kgdboc(void)
48345 kgdboc_unregister_kbd();
48346 if (configured == 1)
48347 kgdb_unregister_io_module(&kgdboc_io_ops);
48348 + else if (configured == 2)
48349 + kgdb_unregister_io_module(&kgdboc_io_ops_console);
48350 }
48351
48352 static int configure_kgdboc(void)
48353 @@ -160,13 +163,13 @@ static int configure_kgdboc(void)
48354 int err;
48355 char *cptr = config;
48356 struct console *cons;
48357 + int is_console = 0;
48358
48359 err = kgdboc_option_setup(config);
48360 if (err || !strlen(config) || isspace(config[0]))
48361 goto noconfig;
48362
48363 err = -ENODEV;
48364 - kgdboc_io_ops.is_console = 0;
48365 kgdb_tty_driver = NULL;
48366
48367 kgdboc_use_kms = 0;
48368 @@ -187,7 +190,7 @@ static int configure_kgdboc(void)
48369 int idx;
48370 if (cons->device && cons->device(cons, &idx) == p &&
48371 idx == tty_line) {
48372 - kgdboc_io_ops.is_console = 1;
48373 + is_console = 1;
48374 break;
48375 }
48376 cons = cons->next;
48377 @@ -197,7 +200,13 @@ static int configure_kgdboc(void)
48378 kgdb_tty_line = tty_line;
48379
48380 do_register:
48381 - err = kgdb_register_io_module(&kgdboc_io_ops);
48382 + if (is_console) {
48383 + err = kgdb_register_io_module(&kgdboc_io_ops_console);
48384 + configured = 2;
48385 + } else {
48386 + err = kgdb_register_io_module(&kgdboc_io_ops);
48387 + configured = 1;
48388 + }
48389 if (err)
48390 goto noconfig;
48391
48392 @@ -205,8 +214,6 @@ do_register:
48393 if (err)
48394 goto nmi_con_failed;
48395
48396 - configured = 1;
48397 -
48398 return 0;
48399
48400 nmi_con_failed:
48401 @@ -223,7 +230,7 @@ noconfig:
48402 static int __init init_kgdboc(void)
48403 {
48404 /* Already configured? */
48405 - if (configured == 1)
48406 + if (configured >= 1)
48407 return 0;
48408
48409 return configure_kgdboc();
48410 @@ -272,7 +279,7 @@ static int param_set_kgdboc_var(const char *kmessage, struct kernel_param *kp)
48411 if (config[len - 1] == '\n')
48412 config[len - 1] = '\0';
48413
48414 - if (configured == 1)
48415 + if (configured >= 1)
48416 cleanup_kgdboc();
48417
48418 /* Go and configure with the new params. */
48419 @@ -312,6 +319,15 @@ static struct kgdb_io kgdboc_io_ops = {
48420 .post_exception = kgdboc_post_exp_handler,
48421 };
48422
48423 +static struct kgdb_io kgdboc_io_ops_console = {
48424 + .name = "kgdboc",
48425 + .read_char = kgdboc_get_char,
48426 + .write_char = kgdboc_put_char,
48427 + .pre_exception = kgdboc_pre_exp_handler,
48428 + .post_exception = kgdboc_post_exp_handler,
48429 + .is_console = 1
48430 +};
48431 +
48432 #ifdef CONFIG_KGDB_SERIAL_CONSOLE
48433 /* This is only available if kgdboc is a built in for early debugging */
48434 static int __init kgdboc_early_init(char *opt)
48435 diff --git a/drivers/tty/serial/msm_serial.c b/drivers/tty/serial/msm_serial.c
48436 index b5d779c..3622cfe 100644
48437 --- a/drivers/tty/serial/msm_serial.c
48438 +++ b/drivers/tty/serial/msm_serial.c
48439 @@ -897,7 +897,7 @@ static struct uart_driver msm_uart_driver = {
48440 .cons = MSM_CONSOLE,
48441 };
48442
48443 -static atomic_t msm_uart_next_id = ATOMIC_INIT(0);
48444 +static atomic_unchecked_t msm_uart_next_id = ATOMIC_INIT(0);
48445
48446 static const struct of_device_id msm_uartdm_table[] = {
48447 { .compatible = "qcom,msm-uartdm" },
48448 @@ -912,7 +912,7 @@ static int __init msm_serial_probe(struct platform_device *pdev)
48449 int irq;
48450
48451 if (pdev->id == -1)
48452 - pdev->id = atomic_inc_return(&msm_uart_next_id) - 1;
48453 + pdev->id = atomic_inc_return_unchecked(&msm_uart_next_id) - 1;
48454
48455 if (unlikely(pdev->id < 0 || pdev->id >= UART_NR))
48456 return -ENXIO;
48457 diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c
48458 index f3dfa19..342f2ff 100644
48459 --- a/drivers/tty/serial/samsung.c
48460 +++ b/drivers/tty/serial/samsung.c
48461 @@ -456,11 +456,16 @@ static void s3c24xx_serial_shutdown(struct uart_port *port)
48462 }
48463 }
48464
48465 +static int s3c64xx_serial_startup(struct uart_port *port);
48466 static int s3c24xx_serial_startup(struct uart_port *port)
48467 {
48468 struct s3c24xx_uart_port *ourport = to_ourport(port);
48469 int ret;
48470
48471 + /* Startup sequence is different for s3c64xx and higher SoC's */
48472 + if (s3c24xx_serial_has_interrupt_mask(port))
48473 + return s3c64xx_serial_startup(port);
48474 +
48475 dbg("s3c24xx_serial_startup: port=%p (%08lx,%p)\n",
48476 port->mapbase, port->membase);
48477
48478 @@ -1127,10 +1132,6 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport,
48479 /* setup info for port */
48480 port->dev = &platdev->dev;
48481
48482 - /* Startup sequence is different for s3c64xx and higher SoC's */
48483 - if (s3c24xx_serial_has_interrupt_mask(port))
48484 - s3c24xx_serial_ops.startup = s3c64xx_serial_startup;
48485 -
48486 port->uartclk = 1;
48487
48488 if (cfg->uart_flags & UPF_CONS_FLOW) {
48489 diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
48490 index 0f02351..07c59c5 100644
48491 --- a/drivers/tty/serial/serial_core.c
48492 +++ b/drivers/tty/serial/serial_core.c
48493 @@ -1448,7 +1448,7 @@ static void uart_hangup(struct tty_struct *tty)
48494 uart_flush_buffer(tty);
48495 uart_shutdown(tty, state);
48496 spin_lock_irqsave(&port->lock, flags);
48497 - port->count = 0;
48498 + atomic_set(&port->count, 0);
48499 clear_bit(ASYNCB_NORMAL_ACTIVE, &port->flags);
48500 spin_unlock_irqrestore(&port->lock, flags);
48501 tty_port_tty_set(port, NULL);
48502 @@ -1544,7 +1544,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
48503 goto end;
48504 }
48505
48506 - port->count++;
48507 + atomic_inc(&port->count);
48508 if (!state->uart_port || state->uart_port->flags & UPF_DEAD) {
48509 retval = -ENXIO;
48510 goto err_dec_count;
48511 @@ -1572,7 +1572,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
48512 /*
48513 * Make sure the device is in D0 state.
48514 */
48515 - if (port->count == 1)
48516 + if (atomic_read(&port->count) == 1)
48517 uart_change_pm(state, UART_PM_STATE_ON);
48518
48519 /*
48520 @@ -1590,7 +1590,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
48521 end:
48522 return retval;
48523 err_dec_count:
48524 - port->count--;
48525 + atomic_inc(&port->count);
48526 mutex_unlock(&port->mutex);
48527 goto end;
48528 }
48529 diff --git a/drivers/tty/synclink.c b/drivers/tty/synclink.c
48530 index e1ce141..6d4ed80 100644
48531 --- a/drivers/tty/synclink.c
48532 +++ b/drivers/tty/synclink.c
48533 @@ -3090,7 +3090,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
48534
48535 if (debug_level >= DEBUG_LEVEL_INFO)
48536 printk("%s(%d):mgsl_close(%s) entry, count=%d\n",
48537 - __FILE__,__LINE__, info->device_name, info->port.count);
48538 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
48539
48540 if (tty_port_close_start(&info->port, tty, filp) == 0)
48541 goto cleanup;
48542 @@ -3108,7 +3108,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
48543 cleanup:
48544 if (debug_level >= DEBUG_LEVEL_INFO)
48545 printk("%s(%d):mgsl_close(%s) exit, count=%d\n", __FILE__,__LINE__,
48546 - tty->driver->name, info->port.count);
48547 + tty->driver->name, atomic_read(&info->port.count));
48548
48549 } /* end of mgsl_close() */
48550
48551 @@ -3207,8 +3207,8 @@ static void mgsl_hangup(struct tty_struct *tty)
48552
48553 mgsl_flush_buffer(tty);
48554 shutdown(info);
48555 -
48556 - info->port.count = 0;
48557 +
48558 + atomic_set(&info->port.count, 0);
48559 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
48560 info->port.tty = NULL;
48561
48562 @@ -3297,12 +3297,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
48563
48564 if (debug_level >= DEBUG_LEVEL_INFO)
48565 printk("%s(%d):block_til_ready before block on %s count=%d\n",
48566 - __FILE__,__LINE__, tty->driver->name, port->count );
48567 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48568
48569 spin_lock_irqsave(&info->irq_spinlock, flags);
48570 if (!tty_hung_up_p(filp)) {
48571 extra_count = true;
48572 - port->count--;
48573 + atomic_dec(&port->count);
48574 }
48575 spin_unlock_irqrestore(&info->irq_spinlock, flags);
48576 port->blocked_open++;
48577 @@ -3331,7 +3331,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
48578
48579 if (debug_level >= DEBUG_LEVEL_INFO)
48580 printk("%s(%d):block_til_ready blocking on %s count=%d\n",
48581 - __FILE__,__LINE__, tty->driver->name, port->count );
48582 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48583
48584 tty_unlock(tty);
48585 schedule();
48586 @@ -3343,12 +3343,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
48587
48588 /* FIXME: Racy on hangup during close wait */
48589 if (extra_count)
48590 - port->count++;
48591 + atomic_inc(&port->count);
48592 port->blocked_open--;
48593
48594 if (debug_level >= DEBUG_LEVEL_INFO)
48595 printk("%s(%d):block_til_ready after blocking on %s count=%d\n",
48596 - __FILE__,__LINE__, tty->driver->name, port->count );
48597 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48598
48599 if (!retval)
48600 port->flags |= ASYNC_NORMAL_ACTIVE;
48601 @@ -3400,7 +3400,7 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
48602
48603 if (debug_level >= DEBUG_LEVEL_INFO)
48604 printk("%s(%d):mgsl_open(%s), old ref count = %d\n",
48605 - __FILE__,__LINE__,tty->driver->name, info->port.count);
48606 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
48607
48608 /* If port is closing, signal caller to try again */
48609 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
48610 @@ -3419,10 +3419,10 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
48611 spin_unlock_irqrestore(&info->netlock, flags);
48612 goto cleanup;
48613 }
48614 - info->port.count++;
48615 + atomic_inc(&info->port.count);
48616 spin_unlock_irqrestore(&info->netlock, flags);
48617
48618 - if (info->port.count == 1) {
48619 + if (atomic_read(&info->port.count) == 1) {
48620 /* 1st open on this device, init hardware */
48621 retval = startup(info);
48622 if (retval < 0)
48623 @@ -3446,8 +3446,8 @@ cleanup:
48624 if (retval) {
48625 if (tty->count == 1)
48626 info->port.tty = NULL; /* tty layer will release tty struct */
48627 - if(info->port.count)
48628 - info->port.count--;
48629 + if (atomic_read(&info->port.count))
48630 + atomic_dec(&info->port.count);
48631 }
48632
48633 return retval;
48634 @@ -7665,7 +7665,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
48635 unsigned short new_crctype;
48636
48637 /* return error if TTY interface open */
48638 - if (info->port.count)
48639 + if (atomic_read(&info->port.count))
48640 return -EBUSY;
48641
48642 switch (encoding)
48643 @@ -7760,7 +7760,7 @@ static int hdlcdev_open(struct net_device *dev)
48644
48645 /* arbitrate between network and tty opens */
48646 spin_lock_irqsave(&info->netlock, flags);
48647 - if (info->port.count != 0 || info->netcount != 0) {
48648 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
48649 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
48650 spin_unlock_irqrestore(&info->netlock, flags);
48651 return -EBUSY;
48652 @@ -7846,7 +7846,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
48653 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
48654
48655 /* return error if TTY interface open */
48656 - if (info->port.count)
48657 + if (atomic_read(&info->port.count))
48658 return -EBUSY;
48659
48660 if (cmd != SIOCWANDEV)
48661 diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c
48662 index 1abf946..1ee34fc 100644
48663 --- a/drivers/tty/synclink_gt.c
48664 +++ b/drivers/tty/synclink_gt.c
48665 @@ -670,7 +670,7 @@ static int open(struct tty_struct *tty, struct file *filp)
48666 tty->driver_data = info;
48667 info->port.tty = tty;
48668
48669 - DBGINFO(("%s open, old ref count = %d\n", info->device_name, info->port.count));
48670 + DBGINFO(("%s open, old ref count = %d\n", info->device_name, atomic_read(&info->port.count)));
48671
48672 /* If port is closing, signal caller to try again */
48673 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
48674 @@ -691,10 +691,10 @@ static int open(struct tty_struct *tty, struct file *filp)
48675 mutex_unlock(&info->port.mutex);
48676 goto cleanup;
48677 }
48678 - info->port.count++;
48679 + atomic_inc(&info->port.count);
48680 spin_unlock_irqrestore(&info->netlock, flags);
48681
48682 - if (info->port.count == 1) {
48683 + if (atomic_read(&info->port.count) == 1) {
48684 /* 1st open on this device, init hardware */
48685 retval = startup(info);
48686 if (retval < 0) {
48687 @@ -715,8 +715,8 @@ cleanup:
48688 if (retval) {
48689 if (tty->count == 1)
48690 info->port.tty = NULL; /* tty layer will release tty struct */
48691 - if(info->port.count)
48692 - info->port.count--;
48693 + if(atomic_read(&info->port.count))
48694 + atomic_dec(&info->port.count);
48695 }
48696
48697 DBGINFO(("%s open rc=%d\n", info->device_name, retval));
48698 @@ -729,7 +729,7 @@ static void close(struct tty_struct *tty, struct file *filp)
48699
48700 if (sanity_check(info, tty->name, "close"))
48701 return;
48702 - DBGINFO(("%s close entry, count=%d\n", info->device_name, info->port.count));
48703 + DBGINFO(("%s close entry, count=%d\n", info->device_name, atomic_read(&info->port.count)));
48704
48705 if (tty_port_close_start(&info->port, tty, filp) == 0)
48706 goto cleanup;
48707 @@ -746,7 +746,7 @@ static void close(struct tty_struct *tty, struct file *filp)
48708 tty_port_close_end(&info->port, tty);
48709 info->port.tty = NULL;
48710 cleanup:
48711 - DBGINFO(("%s close exit, count=%d\n", tty->driver->name, info->port.count));
48712 + DBGINFO(("%s close exit, count=%d\n", tty->driver->name, atomic_read(&info->port.count)));
48713 }
48714
48715 static void hangup(struct tty_struct *tty)
48716 @@ -764,7 +764,7 @@ static void hangup(struct tty_struct *tty)
48717 shutdown(info);
48718
48719 spin_lock_irqsave(&info->port.lock, flags);
48720 - info->port.count = 0;
48721 + atomic_set(&info->port.count, 0);
48722 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
48723 info->port.tty = NULL;
48724 spin_unlock_irqrestore(&info->port.lock, flags);
48725 @@ -1449,7 +1449,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
48726 unsigned short new_crctype;
48727
48728 /* return error if TTY interface open */
48729 - if (info->port.count)
48730 + if (atomic_read(&info->port.count))
48731 return -EBUSY;
48732
48733 DBGINFO(("%s hdlcdev_attach\n", info->device_name));
48734 @@ -1544,7 +1544,7 @@ static int hdlcdev_open(struct net_device *dev)
48735
48736 /* arbitrate between network and tty opens */
48737 spin_lock_irqsave(&info->netlock, flags);
48738 - if (info->port.count != 0 || info->netcount != 0) {
48739 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
48740 DBGINFO(("%s hdlc_open busy\n", dev->name));
48741 spin_unlock_irqrestore(&info->netlock, flags);
48742 return -EBUSY;
48743 @@ -1629,7 +1629,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
48744 DBGINFO(("%s hdlcdev_ioctl\n", dev->name));
48745
48746 /* return error if TTY interface open */
48747 - if (info->port.count)
48748 + if (atomic_read(&info->port.count))
48749 return -EBUSY;
48750
48751 if (cmd != SIOCWANDEV)
48752 @@ -2413,7 +2413,7 @@ static irqreturn_t slgt_interrupt(int dummy, void *dev_id)
48753 if (port == NULL)
48754 continue;
48755 spin_lock(&port->lock);
48756 - if ((port->port.count || port->netcount) &&
48757 + if ((atomic_read(&port->port.count) || port->netcount) &&
48758 port->pending_bh && !port->bh_running &&
48759 !port->bh_requested) {
48760 DBGISR(("%s bh queued\n", port->device_name));
48761 @@ -3302,7 +3302,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48762 spin_lock_irqsave(&info->lock, flags);
48763 if (!tty_hung_up_p(filp)) {
48764 extra_count = true;
48765 - port->count--;
48766 + atomic_dec(&port->count);
48767 }
48768 spin_unlock_irqrestore(&info->lock, flags);
48769 port->blocked_open++;
48770 @@ -3339,7 +3339,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48771 remove_wait_queue(&port->open_wait, &wait);
48772
48773 if (extra_count)
48774 - port->count++;
48775 + atomic_inc(&port->count);
48776 port->blocked_open--;
48777
48778 if (!retval)
48779 diff --git a/drivers/tty/synclinkmp.c b/drivers/tty/synclinkmp.c
48780 index dc6e969..5dc8786 100644
48781 --- a/drivers/tty/synclinkmp.c
48782 +++ b/drivers/tty/synclinkmp.c
48783 @@ -750,7 +750,7 @@ static int open(struct tty_struct *tty, struct file *filp)
48784
48785 if (debug_level >= DEBUG_LEVEL_INFO)
48786 printk("%s(%d):%s open(), old ref count = %d\n",
48787 - __FILE__,__LINE__,tty->driver->name, info->port.count);
48788 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
48789
48790 /* If port is closing, signal caller to try again */
48791 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
48792 @@ -769,10 +769,10 @@ static int open(struct tty_struct *tty, struct file *filp)
48793 spin_unlock_irqrestore(&info->netlock, flags);
48794 goto cleanup;
48795 }
48796 - info->port.count++;
48797 + atomic_inc(&info->port.count);
48798 spin_unlock_irqrestore(&info->netlock, flags);
48799
48800 - if (info->port.count == 1) {
48801 + if (atomic_read(&info->port.count) == 1) {
48802 /* 1st open on this device, init hardware */
48803 retval = startup(info);
48804 if (retval < 0)
48805 @@ -796,8 +796,8 @@ cleanup:
48806 if (retval) {
48807 if (tty->count == 1)
48808 info->port.tty = NULL; /* tty layer will release tty struct */
48809 - if(info->port.count)
48810 - info->port.count--;
48811 + if(atomic_read(&info->port.count))
48812 + atomic_dec(&info->port.count);
48813 }
48814
48815 return retval;
48816 @@ -815,7 +815,7 @@ static void close(struct tty_struct *tty, struct file *filp)
48817
48818 if (debug_level >= DEBUG_LEVEL_INFO)
48819 printk("%s(%d):%s close() entry, count=%d\n",
48820 - __FILE__,__LINE__, info->device_name, info->port.count);
48821 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
48822
48823 if (tty_port_close_start(&info->port, tty, filp) == 0)
48824 goto cleanup;
48825 @@ -834,7 +834,7 @@ static void close(struct tty_struct *tty, struct file *filp)
48826 cleanup:
48827 if (debug_level >= DEBUG_LEVEL_INFO)
48828 printk("%s(%d):%s close() exit, count=%d\n", __FILE__,__LINE__,
48829 - tty->driver->name, info->port.count);
48830 + tty->driver->name, atomic_read(&info->port.count));
48831 }
48832
48833 /* Called by tty_hangup() when a hangup is signaled.
48834 @@ -857,7 +857,7 @@ static void hangup(struct tty_struct *tty)
48835 shutdown(info);
48836
48837 spin_lock_irqsave(&info->port.lock, flags);
48838 - info->port.count = 0;
48839 + atomic_set(&info->port.count, 0);
48840 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
48841 info->port.tty = NULL;
48842 spin_unlock_irqrestore(&info->port.lock, flags);
48843 @@ -1565,7 +1565,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
48844 unsigned short new_crctype;
48845
48846 /* return error if TTY interface open */
48847 - if (info->port.count)
48848 + if (atomic_read(&info->port.count))
48849 return -EBUSY;
48850
48851 switch (encoding)
48852 @@ -1660,7 +1660,7 @@ static int hdlcdev_open(struct net_device *dev)
48853
48854 /* arbitrate between network and tty opens */
48855 spin_lock_irqsave(&info->netlock, flags);
48856 - if (info->port.count != 0 || info->netcount != 0) {
48857 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
48858 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
48859 spin_unlock_irqrestore(&info->netlock, flags);
48860 return -EBUSY;
48861 @@ -1746,7 +1746,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
48862 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
48863
48864 /* return error if TTY interface open */
48865 - if (info->port.count)
48866 + if (atomic_read(&info->port.count))
48867 return -EBUSY;
48868
48869 if (cmd != SIOCWANDEV)
48870 @@ -2620,7 +2620,7 @@ static irqreturn_t synclinkmp_interrupt(int dummy, void *dev_id)
48871 * do not request bottom half processing if the
48872 * device is not open in a normal mode.
48873 */
48874 - if ( port && (port->port.count || port->netcount) &&
48875 + if ( port && (atomic_read(&port->port.count) || port->netcount) &&
48876 port->pending_bh && !port->bh_running &&
48877 !port->bh_requested ) {
48878 if ( debug_level >= DEBUG_LEVEL_ISR )
48879 @@ -3318,12 +3318,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48880
48881 if (debug_level >= DEBUG_LEVEL_INFO)
48882 printk("%s(%d):%s block_til_ready() before block, count=%d\n",
48883 - __FILE__,__LINE__, tty->driver->name, port->count );
48884 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48885
48886 spin_lock_irqsave(&info->lock, flags);
48887 if (!tty_hung_up_p(filp)) {
48888 extra_count = true;
48889 - port->count--;
48890 + atomic_dec(&port->count);
48891 }
48892 spin_unlock_irqrestore(&info->lock, flags);
48893 port->blocked_open++;
48894 @@ -3352,7 +3352,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48895
48896 if (debug_level >= DEBUG_LEVEL_INFO)
48897 printk("%s(%d):%s block_til_ready() count=%d\n",
48898 - __FILE__,__LINE__, tty->driver->name, port->count );
48899 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48900
48901 tty_unlock(tty);
48902 schedule();
48903 @@ -3363,12 +3363,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48904 remove_wait_queue(&port->open_wait, &wait);
48905
48906 if (extra_count)
48907 - port->count++;
48908 + atomic_inc(&port->count);
48909 port->blocked_open--;
48910
48911 if (debug_level >= DEBUG_LEVEL_INFO)
48912 printk("%s(%d):%s block_til_ready() after, count=%d\n",
48913 - __FILE__,__LINE__, tty->driver->name, port->count );
48914 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48915
48916 if (!retval)
48917 port->flags |= ASYNC_NORMAL_ACTIVE;
48918 diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
48919 index 40a9fe9..a3f10cc 100644
48920 --- a/drivers/tty/sysrq.c
48921 +++ b/drivers/tty/sysrq.c
48922 @@ -1075,7 +1075,7 @@ EXPORT_SYMBOL(unregister_sysrq_key);
48923 static ssize_t write_sysrq_trigger(struct file *file, const char __user *buf,
48924 size_t count, loff_t *ppos)
48925 {
48926 - if (count) {
48927 + if (count && capable(CAP_SYS_ADMIN)) {
48928 char c;
48929
48930 if (get_user(c, buf))
48931 diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
48932 index c74a00a..02cf211a 100644
48933 --- a/drivers/tty/tty_io.c
48934 +++ b/drivers/tty/tty_io.c
48935 @@ -3474,7 +3474,7 @@ EXPORT_SYMBOL_GPL(get_current_tty);
48936
48937 void tty_default_fops(struct file_operations *fops)
48938 {
48939 - *fops = tty_fops;
48940 + memcpy((void *)fops, &tty_fops, sizeof(tty_fops));
48941 }
48942
48943 /*
48944 diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
48945 index 6458e11..6cfc218 100644
48946 --- a/drivers/tty/tty_ldisc.c
48947 +++ b/drivers/tty/tty_ldisc.c
48948 @@ -72,7 +72,7 @@ int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc)
48949 raw_spin_lock_irqsave(&tty_ldiscs_lock, flags);
48950 tty_ldiscs[disc] = new_ldisc;
48951 new_ldisc->num = disc;
48952 - new_ldisc->refcount = 0;
48953 + atomic_set(&new_ldisc->refcount, 0);
48954 raw_spin_unlock_irqrestore(&tty_ldiscs_lock, flags);
48955
48956 return ret;
48957 @@ -100,7 +100,7 @@ int tty_unregister_ldisc(int disc)
48958 return -EINVAL;
48959
48960 raw_spin_lock_irqsave(&tty_ldiscs_lock, flags);
48961 - if (tty_ldiscs[disc]->refcount)
48962 + if (atomic_read(&tty_ldiscs[disc]->refcount))
48963 ret = -EBUSY;
48964 else
48965 tty_ldiscs[disc] = NULL;
48966 @@ -121,7 +121,7 @@ static struct tty_ldisc_ops *get_ldops(int disc)
48967 if (ldops) {
48968 ret = ERR_PTR(-EAGAIN);
48969 if (try_module_get(ldops->owner)) {
48970 - ldops->refcount++;
48971 + atomic_inc(&ldops->refcount);
48972 ret = ldops;
48973 }
48974 }
48975 @@ -134,7 +134,7 @@ static void put_ldops(struct tty_ldisc_ops *ldops)
48976 unsigned long flags;
48977
48978 raw_spin_lock_irqsave(&tty_ldiscs_lock, flags);
48979 - ldops->refcount--;
48980 + atomic_dec(&ldops->refcount);
48981 module_put(ldops->owner);
48982 raw_spin_unlock_irqrestore(&tty_ldiscs_lock, flags);
48983 }
48984 diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c
48985 index f597e88..b7f68ed 100644
48986 --- a/drivers/tty/tty_port.c
48987 +++ b/drivers/tty/tty_port.c
48988 @@ -232,7 +232,7 @@ void tty_port_hangup(struct tty_port *port)
48989 unsigned long flags;
48990
48991 spin_lock_irqsave(&port->lock, flags);
48992 - port->count = 0;
48993 + atomic_set(&port->count, 0);
48994 port->flags &= ~ASYNC_NORMAL_ACTIVE;
48995 tty = port->tty;
48996 if (tty)
48997 @@ -390,7 +390,7 @@ int tty_port_block_til_ready(struct tty_port *port,
48998 /* The port lock protects the port counts */
48999 spin_lock_irqsave(&port->lock, flags);
49000 if (!tty_hung_up_p(filp))
49001 - port->count--;
49002 + atomic_dec(&port->count);
49003 port->blocked_open++;
49004 spin_unlock_irqrestore(&port->lock, flags);
49005
49006 @@ -432,7 +432,7 @@ int tty_port_block_til_ready(struct tty_port *port,
49007 we must not mess that up further */
49008 spin_lock_irqsave(&port->lock, flags);
49009 if (!tty_hung_up_p(filp))
49010 - port->count++;
49011 + atomic_inc(&port->count);
49012 port->blocked_open--;
49013 if (retval == 0)
49014 port->flags |= ASYNC_NORMAL_ACTIVE;
49015 @@ -466,19 +466,19 @@ int tty_port_close_start(struct tty_port *port,
49016 return 0;
49017 }
49018
49019 - if (tty->count == 1 && port->count != 1) {
49020 + if (tty->count == 1 && atomic_read(&port->count) != 1) {
49021 printk(KERN_WARNING
49022 "tty_port_close_start: tty->count = 1 port count = %d.\n",
49023 - port->count);
49024 - port->count = 1;
49025 + atomic_read(&port->count));
49026 + atomic_set(&port->count, 1);
49027 }
49028 - if (--port->count < 0) {
49029 + if (atomic_dec_return(&port->count) < 0) {
49030 printk(KERN_WARNING "tty_port_close_start: count = %d\n",
49031 - port->count);
49032 - port->count = 0;
49033 + atomic_read(&port->count));
49034 + atomic_set(&port->count, 0);
49035 }
49036
49037 - if (port->count) {
49038 + if (atomic_read(&port->count)) {
49039 spin_unlock_irqrestore(&port->lock, flags);
49040 if (port->ops->drop)
49041 port->ops->drop(port);
49042 @@ -564,7 +564,7 @@ int tty_port_open(struct tty_port *port, struct tty_struct *tty,
49043 {
49044 spin_lock_irq(&port->lock);
49045 if (!tty_hung_up_p(filp))
49046 - ++port->count;
49047 + atomic_inc(&port->count);
49048 spin_unlock_irq(&port->lock);
49049 tty_port_tty_set(port, tty);
49050
49051 diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
49052 index d0e3a44..5f8b754 100644
49053 --- a/drivers/tty/vt/keyboard.c
49054 +++ b/drivers/tty/vt/keyboard.c
49055 @@ -641,6 +641,16 @@ static void k_spec(struct vc_data *vc, unsigned char value, char up_flag)
49056 kbd->kbdmode == VC_OFF) &&
49057 value != KVAL(K_SAK))
49058 return; /* SAK is allowed even in raw mode */
49059 +
49060 +#if defined(CONFIG_GRKERNSEC_PROC) || defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
49061 + {
49062 + void *func = fn_handler[value];
49063 + if (func == fn_show_state || func == fn_show_ptregs ||
49064 + func == fn_show_mem)
49065 + return;
49066 + }
49067 +#endif
49068 +
49069 fn_handler[value](vc);
49070 }
49071
49072 @@ -1776,9 +1786,6 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
49073 if (copy_from_user(&tmp, user_kbe, sizeof(struct kbentry)))
49074 return -EFAULT;
49075
49076 - if (!capable(CAP_SYS_TTY_CONFIG))
49077 - perm = 0;
49078 -
49079 switch (cmd) {
49080 case KDGKBENT:
49081 /* Ensure another thread doesn't free it under us */
49082 @@ -1793,6 +1800,9 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
49083 spin_unlock_irqrestore(&kbd_event_lock, flags);
49084 return put_user(val, &user_kbe->kb_value);
49085 case KDSKBENT:
49086 + if (!capable(CAP_SYS_TTY_CONFIG))
49087 + perm = 0;
49088 +
49089 if (!perm)
49090 return -EPERM;
49091 if (!i && v == K_NOSUCHMAP) {
49092 @@ -1883,9 +1893,6 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
49093 int i, j, k;
49094 int ret;
49095
49096 - if (!capable(CAP_SYS_TTY_CONFIG))
49097 - perm = 0;
49098 -
49099 kbs = kmalloc(sizeof(*kbs), GFP_KERNEL);
49100 if (!kbs) {
49101 ret = -ENOMEM;
49102 @@ -1919,6 +1926,9 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
49103 kfree(kbs);
49104 return ((p && *p) ? -EOVERFLOW : 0);
49105 case KDSKBSENT:
49106 + if (!capable(CAP_SYS_TTY_CONFIG))
49107 + perm = 0;
49108 +
49109 if (!perm) {
49110 ret = -EPERM;
49111 goto reterr;
49112 diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
49113 index 0e808cf..d7d274b 100644
49114 --- a/drivers/uio/uio.c
49115 +++ b/drivers/uio/uio.c
49116 @@ -25,6 +25,7 @@
49117 #include <linux/kobject.h>
49118 #include <linux/cdev.h>
49119 #include <linux/uio_driver.h>
49120 +#include <asm/local.h>
49121
49122 #define UIO_MAX_DEVICES (1U << MINORBITS)
49123
49124 @@ -32,7 +33,7 @@ struct uio_device {
49125 struct module *owner;
49126 struct device *dev;
49127 int minor;
49128 - atomic_t event;
49129 + atomic_unchecked_t event;
49130 struct fasync_struct *async_queue;
49131 wait_queue_head_t wait;
49132 struct uio_info *info;
49133 @@ -243,7 +244,7 @@ static ssize_t event_show(struct device *dev,
49134 struct device_attribute *attr, char *buf)
49135 {
49136 struct uio_device *idev = dev_get_drvdata(dev);
49137 - return sprintf(buf, "%u\n", (unsigned int)atomic_read(&idev->event));
49138 + return sprintf(buf, "%u\n", (unsigned int)atomic_read_unchecked(&idev->event));
49139 }
49140 static DEVICE_ATTR_RO(event);
49141
49142 @@ -401,7 +402,7 @@ void uio_event_notify(struct uio_info *info)
49143 {
49144 struct uio_device *idev = info->uio_dev;
49145
49146 - atomic_inc(&idev->event);
49147 + atomic_inc_unchecked(&idev->event);
49148 wake_up_interruptible(&idev->wait);
49149 kill_fasync(&idev->async_queue, SIGIO, POLL_IN);
49150 }
49151 @@ -454,7 +455,7 @@ static int uio_open(struct inode *inode, struct file *filep)
49152 }
49153
49154 listener->dev = idev;
49155 - listener->event_count = atomic_read(&idev->event);
49156 + listener->event_count = atomic_read_unchecked(&idev->event);
49157 filep->private_data = listener;
49158
49159 if (idev->info->open) {
49160 @@ -505,7 +506,7 @@ static unsigned int uio_poll(struct file *filep, poll_table *wait)
49161 return -EIO;
49162
49163 poll_wait(filep, &idev->wait, wait);
49164 - if (listener->event_count != atomic_read(&idev->event))
49165 + if (listener->event_count != atomic_read_unchecked(&idev->event))
49166 return POLLIN | POLLRDNORM;
49167 return 0;
49168 }
49169 @@ -530,7 +531,7 @@ static ssize_t uio_read(struct file *filep, char __user *buf,
49170 do {
49171 set_current_state(TASK_INTERRUPTIBLE);
49172
49173 - event_count = atomic_read(&idev->event);
49174 + event_count = atomic_read_unchecked(&idev->event);
49175 if (event_count != listener->event_count) {
49176 if (copy_to_user(buf, &event_count, count))
49177 retval = -EFAULT;
49178 @@ -587,9 +588,13 @@ static ssize_t uio_write(struct file *filep, const char __user *buf,
49179 static int uio_find_mem_index(struct vm_area_struct *vma)
49180 {
49181 struct uio_device *idev = vma->vm_private_data;
49182 + unsigned long size;
49183
49184 if (vma->vm_pgoff < MAX_UIO_MAPS) {
49185 - if (idev->info->mem[vma->vm_pgoff].size == 0)
49186 + size = idev->info->mem[vma->vm_pgoff].size;
49187 + if (size == 0)
49188 + return -1;
49189 + if (vma->vm_end - vma->vm_start > size)
49190 return -1;
49191 return (int)vma->vm_pgoff;
49192 }
49193 @@ -647,6 +652,8 @@ static int uio_mmap_physical(struct vm_area_struct *vma)
49194 return -EINVAL;
49195 mem = idev->info->mem + mi;
49196
49197 + if (mem->addr & ~PAGE_MASK)
49198 + return -ENODEV;
49199 if (vma->vm_end - vma->vm_start > mem->size)
49200 return -EINVAL;
49201
49202 @@ -818,7 +825,7 @@ int __uio_register_device(struct module *owner,
49203 idev->owner = owner;
49204 idev->info = info;
49205 init_waitqueue_head(&idev->wait);
49206 - atomic_set(&idev->event, 0);
49207 + atomic_set_unchecked(&idev->event, 0);
49208
49209 ret = uio_get_minor(idev);
49210 if (ret)
49211 diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
49212 index 8a7eb77..c00402f 100644
49213 --- a/drivers/usb/atm/cxacru.c
49214 +++ b/drivers/usb/atm/cxacru.c
49215 @@ -473,7 +473,7 @@ static ssize_t cxacru_sysfs_store_adsl_config(struct device *dev,
49216 ret = sscanf(buf + pos, "%x=%x%n", &index, &value, &tmp);
49217 if (ret < 2)
49218 return -EINVAL;
49219 - if (index < 0 || index > 0x7f)
49220 + if (index > 0x7f)
49221 return -EINVAL;
49222 pos += tmp;
49223
49224 diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c
49225 index 25a7bfc..57f3cf5 100644
49226 --- a/drivers/usb/atm/usbatm.c
49227 +++ b/drivers/usb/atm/usbatm.c
49228 @@ -331,7 +331,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
49229 if (printk_ratelimit())
49230 atm_warn(instance, "%s: OAM not supported (vpi %d, vci %d)!\n",
49231 __func__, vpi, vci);
49232 - atomic_inc(&vcc->stats->rx_err);
49233 + atomic_inc_unchecked(&vcc->stats->rx_err);
49234 return;
49235 }
49236
49237 @@ -358,7 +358,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
49238 if (length > ATM_MAX_AAL5_PDU) {
49239 atm_rldbg(instance, "%s: bogus length %u (vcc: 0x%p)!\n",
49240 __func__, length, vcc);
49241 - atomic_inc(&vcc->stats->rx_err);
49242 + atomic_inc_unchecked(&vcc->stats->rx_err);
49243 goto out;
49244 }
49245
49246 @@ -367,14 +367,14 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
49247 if (sarb->len < pdu_length) {
49248 atm_rldbg(instance, "%s: bogus pdu_length %u (sarb->len: %u, vcc: 0x%p)!\n",
49249 __func__, pdu_length, sarb->len, vcc);
49250 - atomic_inc(&vcc->stats->rx_err);
49251 + atomic_inc_unchecked(&vcc->stats->rx_err);
49252 goto out;
49253 }
49254
49255 if (crc32_be(~0, skb_tail_pointer(sarb) - pdu_length, pdu_length) != 0xc704dd7b) {
49256 atm_rldbg(instance, "%s: packet failed crc check (vcc: 0x%p)!\n",
49257 __func__, vcc);
49258 - atomic_inc(&vcc->stats->rx_err);
49259 + atomic_inc_unchecked(&vcc->stats->rx_err);
49260 goto out;
49261 }
49262
49263 @@ -386,7 +386,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
49264 if (printk_ratelimit())
49265 atm_err(instance, "%s: no memory for skb (length: %u)!\n",
49266 __func__, length);
49267 - atomic_inc(&vcc->stats->rx_drop);
49268 + atomic_inc_unchecked(&vcc->stats->rx_drop);
49269 goto out;
49270 }
49271
49272 @@ -414,7 +414,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
49273
49274 vcc->push(vcc, skb);
49275
49276 - atomic_inc(&vcc->stats->rx);
49277 + atomic_inc_unchecked(&vcc->stats->rx);
49278 out:
49279 skb_trim(sarb, 0);
49280 }
49281 @@ -612,7 +612,7 @@ static void usbatm_tx_process(unsigned long data)
49282 struct atm_vcc *vcc = UDSL_SKB(skb)->atm.vcc;
49283
49284 usbatm_pop(vcc, skb);
49285 - atomic_inc(&vcc->stats->tx);
49286 + atomic_inc_unchecked(&vcc->stats->tx);
49287
49288 skb = skb_dequeue(&instance->sndqueue);
49289 }
49290 @@ -756,11 +756,11 @@ static int usbatm_atm_proc_read(struct atm_dev *atm_dev, loff_t * pos, char *pag
49291 if (!left--)
49292 return sprintf(page,
49293 "AAL5: tx %d ( %d err ), rx %d ( %d err, %d drop )\n",
49294 - atomic_read(&atm_dev->stats.aal5.tx),
49295 - atomic_read(&atm_dev->stats.aal5.tx_err),
49296 - atomic_read(&atm_dev->stats.aal5.rx),
49297 - atomic_read(&atm_dev->stats.aal5.rx_err),
49298 - atomic_read(&atm_dev->stats.aal5.rx_drop));
49299 + atomic_read_unchecked(&atm_dev->stats.aal5.tx),
49300 + atomic_read_unchecked(&atm_dev->stats.aal5.tx_err),
49301 + atomic_read_unchecked(&atm_dev->stats.aal5.rx),
49302 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_err),
49303 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_drop));
49304
49305 if (!left--) {
49306 if (instance->disconnected)
49307 diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c
49308 index 2a3bbdf..91d72cf 100644
49309 --- a/drivers/usb/core/devices.c
49310 +++ b/drivers/usb/core/devices.c
49311 @@ -126,7 +126,7 @@ static const char format_endpt[] =
49312 * time it gets called.
49313 */
49314 static struct device_connect_event {
49315 - atomic_t count;
49316 + atomic_unchecked_t count;
49317 wait_queue_head_t wait;
49318 } device_event = {
49319 .count = ATOMIC_INIT(1),
49320 @@ -164,7 +164,7 @@ static const struct class_info clas_info[] = {
49321
49322 void usbfs_conn_disc_event(void)
49323 {
49324 - atomic_add(2, &device_event.count);
49325 + atomic_add_unchecked(2, &device_event.count);
49326 wake_up(&device_event.wait);
49327 }
49328
49329 @@ -652,7 +652,7 @@ static unsigned int usb_device_poll(struct file *file,
49330
49331 poll_wait(file, &device_event.wait, wait);
49332
49333 - event_count = atomic_read(&device_event.count);
49334 + event_count = atomic_read_unchecked(&device_event.count);
49335 if (file->f_version != event_count) {
49336 file->f_version = event_count;
49337 return POLLIN | POLLRDNORM;
49338 diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
49339 index 71dc5d7..300db0e 100644
49340 --- a/drivers/usb/core/devio.c
49341 +++ b/drivers/usb/core/devio.c
49342 @@ -187,7 +187,7 @@ static ssize_t usbdev_read(struct file *file, char __user *buf, size_t nbytes,
49343 struct dev_state *ps = file->private_data;
49344 struct usb_device *dev = ps->dev;
49345 ssize_t ret = 0;
49346 - unsigned len;
49347 + size_t len;
49348 loff_t pos;
49349 int i;
49350
49351 @@ -229,16 +229,16 @@ static ssize_t usbdev_read(struct file *file, char __user *buf, size_t nbytes,
49352 for (i = 0; nbytes && i < dev->descriptor.bNumConfigurations; i++) {
49353 struct usb_config_descriptor *config =
49354 (struct usb_config_descriptor *)dev->rawdescriptors[i];
49355 - unsigned int length = le16_to_cpu(config->wTotalLength);
49356 + size_t length = le16_to_cpu(config->wTotalLength);
49357
49358 if (*ppos < pos + length) {
49359
49360 /* The descriptor may claim to be longer than it
49361 * really is. Here is the actual allocated length. */
49362 - unsigned alloclen =
49363 + size_t alloclen =
49364 le16_to_cpu(dev->config[i].desc.wTotalLength);
49365
49366 - len = length - (*ppos - pos);
49367 + len = length + pos - *ppos;
49368 if (len > nbytes)
49369 len = nbytes;
49370
49371 diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
49372 index f20a044..d1059aa 100644
49373 --- a/drivers/usb/core/hcd.c
49374 +++ b/drivers/usb/core/hcd.c
49375 @@ -1552,7 +1552,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
49376 */
49377 usb_get_urb(urb);
49378 atomic_inc(&urb->use_count);
49379 - atomic_inc(&urb->dev->urbnum);
49380 + atomic_inc_unchecked(&urb->dev->urbnum);
49381 usbmon_urb_submit(&hcd->self, urb);
49382
49383 /* NOTE requirements on root-hub callers (usbfs and the hub
49384 @@ -1579,7 +1579,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
49385 urb->hcpriv = NULL;
49386 INIT_LIST_HEAD(&urb->urb_list);
49387 atomic_dec(&urb->use_count);
49388 - atomic_dec(&urb->dev->urbnum);
49389 + atomic_dec_unchecked(&urb->dev->urbnum);
49390 if (atomic_read(&urb->reject))
49391 wake_up(&usb_kill_urb_queue);
49392 usb_put_urb(urb);
49393 diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
49394 index c5c3667..e54e5cd 100644
49395 --- a/drivers/usb/core/hub.c
49396 +++ b/drivers/usb/core/hub.c
49397 @@ -27,6 +27,7 @@
49398 #include <linux/freezer.h>
49399 #include <linux/random.h>
49400 #include <linux/pm_qos.h>
49401 +#include <linux/grsecurity.h>
49402
49403 #include <asm/uaccess.h>
49404 #include <asm/byteorder.h>
49405 @@ -4467,6 +4468,10 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1,
49406 goto done;
49407 return;
49408 }
49409 +
49410 + if (gr_handle_new_usb())
49411 + goto done;
49412 +
49413 if (hub_is_superspeed(hub->hdev))
49414 unit_load = 150;
49415 else
49416 diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
49417 index 82927e1..4993dbf 100644
49418 --- a/drivers/usb/core/message.c
49419 +++ b/drivers/usb/core/message.c
49420 @@ -129,7 +129,7 @@ static int usb_internal_control_msg(struct usb_device *usb_dev,
49421 * Return: If successful, the number of bytes transferred. Otherwise, a negative
49422 * error number.
49423 */
49424 -int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
49425 +int __intentional_overflow(-1) usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
49426 __u8 requesttype, __u16 value, __u16 index, void *data,
49427 __u16 size, int timeout)
49428 {
49429 @@ -181,7 +181,7 @@ EXPORT_SYMBOL_GPL(usb_control_msg);
49430 * If successful, 0. Otherwise a negative error number. The number of actual
49431 * bytes transferred will be stored in the @actual_length paramater.
49432 */
49433 -int usb_interrupt_msg(struct usb_device *usb_dev, unsigned int pipe,
49434 +int __intentional_overflow(-1) usb_interrupt_msg(struct usb_device *usb_dev, unsigned int pipe,
49435 void *data, int len, int *actual_length, int timeout)
49436 {
49437 return usb_bulk_msg(usb_dev, pipe, data, len, actual_length, timeout);
49438 @@ -221,7 +221,7 @@ EXPORT_SYMBOL_GPL(usb_interrupt_msg);
49439 * bytes transferred will be stored in the @actual_length paramater.
49440 *
49441 */
49442 -int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,
49443 +int __intentional_overflow(-1) usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,
49444 void *data, int len, int *actual_length, int timeout)
49445 {
49446 struct urb *urb;
49447 diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
49448 index ca516ac..6c36ee4 100644
49449 --- a/drivers/usb/core/sysfs.c
49450 +++ b/drivers/usb/core/sysfs.c
49451 @@ -236,7 +236,7 @@ static ssize_t urbnum_show(struct device *dev, struct device_attribute *attr,
49452 struct usb_device *udev;
49453
49454 udev = to_usb_device(dev);
49455 - return sprintf(buf, "%d\n", atomic_read(&udev->urbnum));
49456 + return sprintf(buf, "%d\n", atomic_read_unchecked(&udev->urbnum));
49457 }
49458 static DEVICE_ATTR_RO(urbnum);
49459
49460 diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
49461 index 0a6ee2e..6f8d7e8 100644
49462 --- a/drivers/usb/core/usb.c
49463 +++ b/drivers/usb/core/usb.c
49464 @@ -433,7 +433,7 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent,
49465 set_dev_node(&dev->dev, dev_to_node(bus->controller));
49466 dev->state = USB_STATE_ATTACHED;
49467 dev->lpm_disable_count = 1;
49468 - atomic_set(&dev->urbnum, 0);
49469 + atomic_set_unchecked(&dev->urbnum, 0);
49470
49471 INIT_LIST_HEAD(&dev->ep0.urb_list);
49472 dev->ep0.desc.bLength = USB_DT_ENDPOINT_SIZE;
49473 diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
49474 index 02e44fc..3c4fe64 100644
49475 --- a/drivers/usb/dwc3/gadget.c
49476 +++ b/drivers/usb/dwc3/gadget.c
49477 @@ -532,8 +532,6 @@ static int __dwc3_gadget_ep_enable(struct dwc3_ep *dep,
49478 if (!usb_endpoint_xfer_isoc(desc))
49479 return 0;
49480
49481 - memset(&trb_link, 0, sizeof(trb_link));
49482 -
49483 /* Link TRB for ISOC. The HWO bit is never reset */
49484 trb_st_hw = &dep->trb_pool[0];
49485
49486 diff --git a/drivers/usb/early/ehci-dbgp.c b/drivers/usb/early/ehci-dbgp.c
49487 index 5e29dde..eca992f 100644
49488 --- a/drivers/usb/early/ehci-dbgp.c
49489 +++ b/drivers/usb/early/ehci-dbgp.c
49490 @@ -98,7 +98,8 @@ static inline u32 dbgp_len_update(u32 x, u32 len)
49491
49492 #ifdef CONFIG_KGDB
49493 static struct kgdb_io kgdbdbgp_io_ops;
49494 -#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops)
49495 +static struct kgdb_io kgdbdbgp_io_ops_console;
49496 +#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops || dbg_io_ops == &kgdbdbgp_io_ops_console)
49497 #else
49498 #define dbgp_kgdb_mode (0)
49499 #endif
49500 @@ -1047,6 +1048,13 @@ static struct kgdb_io kgdbdbgp_io_ops = {
49501 .write_char = kgdbdbgp_write_char,
49502 };
49503
49504 +static struct kgdb_io kgdbdbgp_io_ops_console = {
49505 + .name = "kgdbdbgp",
49506 + .read_char = kgdbdbgp_read_char,
49507 + .write_char = kgdbdbgp_write_char,
49508 + .is_console = 1
49509 +};
49510 +
49511 static int kgdbdbgp_wait_time;
49512
49513 static int __init kgdbdbgp_parse_config(char *str)
49514 @@ -1062,8 +1070,10 @@ static int __init kgdbdbgp_parse_config(char *str)
49515 ptr++;
49516 kgdbdbgp_wait_time = simple_strtoul(ptr, &ptr, 10);
49517 }
49518 - kgdb_register_io_module(&kgdbdbgp_io_ops);
49519 - kgdbdbgp_io_ops.is_console = early_dbgp_console.index != -1;
49520 + if (early_dbgp_console.index != -1)
49521 + kgdb_register_io_module(&kgdbdbgp_io_ops_console);
49522 + else
49523 + kgdb_register_io_module(&kgdbdbgp_io_ops);
49524
49525 return 0;
49526 }
49527 diff --git a/drivers/usb/gadget/u_serial.c b/drivers/usb/gadget/u_serial.c
49528 index b369292..9f3ba40 100644
49529 --- a/drivers/usb/gadget/u_serial.c
49530 +++ b/drivers/usb/gadget/u_serial.c
49531 @@ -733,9 +733,9 @@ static int gs_open(struct tty_struct *tty, struct file *file)
49532 spin_lock_irq(&port->port_lock);
49533
49534 /* already open? Great. */
49535 - if (port->port.count) {
49536 + if (atomic_read(&port->port.count)) {
49537 status = 0;
49538 - port->port.count++;
49539 + atomic_inc(&port->port.count);
49540
49541 /* currently opening/closing? wait ... */
49542 } else if (port->openclose) {
49543 @@ -794,7 +794,7 @@ static int gs_open(struct tty_struct *tty, struct file *file)
49544 tty->driver_data = port;
49545 port->port.tty = tty;
49546
49547 - port->port.count = 1;
49548 + atomic_set(&port->port.count, 1);
49549 port->openclose = false;
49550
49551 /* if connected, start the I/O stream */
49552 @@ -836,11 +836,11 @@ static void gs_close(struct tty_struct *tty, struct file *file)
49553
49554 spin_lock_irq(&port->port_lock);
49555
49556 - if (port->port.count != 1) {
49557 - if (port->port.count == 0)
49558 + if (atomic_read(&port->port.count) != 1) {
49559 + if (atomic_read(&port->port.count) == 0)
49560 WARN_ON(1);
49561 else
49562 - --port->port.count;
49563 + atomic_dec(&port->port.count);
49564 goto exit;
49565 }
49566
49567 @@ -850,7 +850,7 @@ static void gs_close(struct tty_struct *tty, struct file *file)
49568 * and sleep if necessary
49569 */
49570 port->openclose = true;
49571 - port->port.count = 0;
49572 + atomic_set(&port->port.count, 0);
49573
49574 gser = port->port_usb;
49575 if (gser && gser->disconnect)
49576 @@ -1066,7 +1066,7 @@ static int gs_closed(struct gs_port *port)
49577 int cond;
49578
49579 spin_lock_irq(&port->port_lock);
49580 - cond = (port->port.count == 0) && !port->openclose;
49581 + cond = (atomic_read(&port->port.count) == 0) && !port->openclose;
49582 spin_unlock_irq(&port->port_lock);
49583 return cond;
49584 }
49585 @@ -1209,7 +1209,7 @@ int gserial_connect(struct gserial *gser, u8 port_num)
49586 /* if it's already open, start I/O ... and notify the serial
49587 * protocol about open/close status (connect/disconnect).
49588 */
49589 - if (port->port.count) {
49590 + if (atomic_read(&port->port.count)) {
49591 pr_debug("gserial_connect: start ttyGS%d\n", port->port_num);
49592 gs_start_io(port);
49593 if (gser->connect)
49594 @@ -1256,7 +1256,7 @@ void gserial_disconnect(struct gserial *gser)
49595
49596 port->port_usb = NULL;
49597 gser->ioport = NULL;
49598 - if (port->port.count > 0 || port->openclose) {
49599 + if (atomic_read(&port->port.count) > 0 || port->openclose) {
49600 wake_up_interruptible(&port->drain_wait);
49601 if (port->port.tty)
49602 tty_hangup(port->port.tty);
49603 @@ -1272,7 +1272,7 @@ void gserial_disconnect(struct gserial *gser)
49604
49605 /* finally, free any unused/unusable I/O buffers */
49606 spin_lock_irqsave(&port->port_lock, flags);
49607 - if (port->port.count == 0 && !port->openclose)
49608 + if (atomic_read(&port->port.count) == 0 && !port->openclose)
49609 gs_buf_free(&port->port_write_buf);
49610 gs_free_requests(gser->out, &port->read_pool, NULL);
49611 gs_free_requests(gser->out, &port->read_queue, NULL);
49612 diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c
49613 index 835fc08..f8b22bf 100644
49614 --- a/drivers/usb/host/ehci-hub.c
49615 +++ b/drivers/usb/host/ehci-hub.c
49616 @@ -762,7 +762,7 @@ static struct urb *request_single_step_set_feature_urb(
49617 urb->transfer_flags = URB_DIR_IN;
49618 usb_get_urb(urb);
49619 atomic_inc(&urb->use_count);
49620 - atomic_inc(&urb->dev->urbnum);
49621 + atomic_inc_unchecked(&urb->dev->urbnum);
49622 urb->setup_dma = dma_map_single(
49623 hcd->self.controller,
49624 urb->setup_packet,
49625 @@ -829,7 +829,7 @@ static int ehset_single_step_set_feature(struct usb_hcd *hcd, int port)
49626 urb->status = -EINPROGRESS;
49627 usb_get_urb(urb);
49628 atomic_inc(&urb->use_count);
49629 - atomic_inc(&urb->dev->urbnum);
49630 + atomic_inc_unchecked(&urb->dev->urbnum);
49631 retval = submit_single_step_set_feature(hcd, urb, 0);
49632 if (!retval && !wait_for_completion_timeout(&done,
49633 msecs_to_jiffies(2000))) {
49634 diff --git a/drivers/usb/misc/appledisplay.c b/drivers/usb/misc/appledisplay.c
49635 index ba6a5d6..f88f7f3 100644
49636 --- a/drivers/usb/misc/appledisplay.c
49637 +++ b/drivers/usb/misc/appledisplay.c
49638 @@ -83,7 +83,7 @@ struct appledisplay {
49639 spinlock_t lock;
49640 };
49641
49642 -static atomic_t count_displays = ATOMIC_INIT(0);
49643 +static atomic_unchecked_t count_displays = ATOMIC_INIT(0);
49644 static struct workqueue_struct *wq;
49645
49646 static void appledisplay_complete(struct urb *urb)
49647 @@ -281,7 +281,7 @@ static int appledisplay_probe(struct usb_interface *iface,
49648
49649 /* Register backlight device */
49650 snprintf(bl_name, sizeof(bl_name), "appledisplay%d",
49651 - atomic_inc_return(&count_displays) - 1);
49652 + atomic_inc_return_unchecked(&count_displays) - 1);
49653 memset(&props, 0, sizeof(struct backlight_properties));
49654 props.type = BACKLIGHT_RAW;
49655 props.max_brightness = 0xff;
49656 diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c
49657 index c69bb50..215ef37 100644
49658 --- a/drivers/usb/serial/console.c
49659 +++ b/drivers/usb/serial/console.c
49660 @@ -124,7 +124,7 @@ static int usb_console_setup(struct console *co, char *options)
49661
49662 info->port = port;
49663
49664 - ++port->port.count;
49665 + atomic_inc(&port->port.count);
49666 if (!test_bit(ASYNCB_INITIALIZED, &port->port.flags)) {
49667 if (serial->type->set_termios) {
49668 /*
49669 @@ -170,7 +170,7 @@ static int usb_console_setup(struct console *co, char *options)
49670 }
49671 /* Now that any required fake tty operations are completed restore
49672 * the tty port count */
49673 - --port->port.count;
49674 + atomic_dec(&port->port.count);
49675 /* The console is special in terms of closing the device so
49676 * indicate this port is now acting as a system console. */
49677 port->port.console = 1;
49678 @@ -183,7 +183,7 @@ static int usb_console_setup(struct console *co, char *options)
49679 free_tty:
49680 kfree(tty);
49681 reset_open_count:
49682 - port->port.count = 0;
49683 + atomic_set(&port->port.count, 0);
49684 usb_autopm_put_interface(serial->interface);
49685 error_get_interface:
49686 usb_serial_put(serial);
49687 @@ -194,7 +194,7 @@ static int usb_console_setup(struct console *co, char *options)
49688 static void usb_console_write(struct console *co,
49689 const char *buf, unsigned count)
49690 {
49691 - static struct usbcons_info *info = &usbcons_info;
49692 + struct usbcons_info *info = &usbcons_info;
49693 struct usb_serial_port *port = info->port;
49694 struct usb_serial *serial;
49695 int retval = -ENODEV;
49696 diff --git a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h
49697 index 75f70f0..d467e1a 100644
49698 --- a/drivers/usb/storage/usb.h
49699 +++ b/drivers/usb/storage/usb.h
49700 @@ -63,7 +63,7 @@ struct us_unusual_dev {
49701 __u8 useProtocol;
49702 __u8 useTransport;
49703 int (*initFunction)(struct us_data *);
49704 -};
49705 +} __do_const;
49706
49707
49708 /* Dynamic bitflag definitions (us->dflags): used in set_bit() etc. */
49709 diff --git a/drivers/usb/wusbcore/wa-hc.h b/drivers/usb/wusbcore/wa-hc.h
49710 index cf250c2..ad9d904 100644
49711 --- a/drivers/usb/wusbcore/wa-hc.h
49712 +++ b/drivers/usb/wusbcore/wa-hc.h
49713 @@ -199,7 +199,7 @@ struct wahc {
49714 spinlock_t xfer_list_lock;
49715 struct work_struct xfer_enqueue_work;
49716 struct work_struct xfer_error_work;
49717 - atomic_t xfer_id_count;
49718 + atomic_unchecked_t xfer_id_count;
49719 };
49720
49721
49722 @@ -255,7 +255,7 @@ static inline void wa_init(struct wahc *wa)
49723 spin_lock_init(&wa->xfer_list_lock);
49724 INIT_WORK(&wa->xfer_enqueue_work, wa_urb_enqueue_run);
49725 INIT_WORK(&wa->xfer_error_work, wa_process_errored_transfers_run);
49726 - atomic_set(&wa->xfer_id_count, 1);
49727 + atomic_set_unchecked(&wa->xfer_id_count, 1);
49728 }
49729
49730 /**
49731 diff --git a/drivers/usb/wusbcore/wa-xfer.c b/drivers/usb/wusbcore/wa-xfer.c
49732 index 3dcf66f..8faaf6e 100644
49733 --- a/drivers/usb/wusbcore/wa-xfer.c
49734 +++ b/drivers/usb/wusbcore/wa-xfer.c
49735 @@ -300,7 +300,7 @@ out:
49736 */
49737 static void wa_xfer_id_init(struct wa_xfer *xfer)
49738 {
49739 - xfer->id = atomic_add_return(1, &xfer->wa->xfer_id_count);
49740 + xfer->id = atomic_add_return_unchecked(1, &xfer->wa->xfer_id_count);
49741 }
49742
49743 /*
49744 diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c
49745 index 1eab4ac..e21efc9 100644
49746 --- a/drivers/vfio/vfio.c
49747 +++ b/drivers/vfio/vfio.c
49748 @@ -488,7 +488,7 @@ static int vfio_group_nb_add_dev(struct vfio_group *group, struct device *dev)
49749 return 0;
49750
49751 /* TODO Prevent device auto probing */
49752 - WARN("Device %s added to live group %d!\n", dev_name(dev),
49753 + WARN(1, "Device %s added to live group %d!\n", dev_name(dev),
49754 iommu_group_id(group->iommu_group));
49755
49756 return 0;
49757 diff --git a/drivers/vhost/vringh.c b/drivers/vhost/vringh.c
49758 index 5174eba..86e764a 100644
49759 --- a/drivers/vhost/vringh.c
49760 +++ b/drivers/vhost/vringh.c
49761 @@ -800,7 +800,7 @@ static inline int getu16_kern(u16 *val, const u16 *p)
49762
49763 static inline int putu16_kern(u16 *p, u16 val)
49764 {
49765 - ACCESS_ONCE(*p) = val;
49766 + ACCESS_ONCE_RW(*p) = val;
49767 return 0;
49768 }
49769
49770 diff --git a/drivers/video/arcfb.c b/drivers/video/arcfb.c
49771 index e43401a..dd49b3f 100644
49772 --- a/drivers/video/arcfb.c
49773 +++ b/drivers/video/arcfb.c
49774 @@ -458,7 +458,7 @@ static ssize_t arcfb_write(struct fb_info *info, const char __user *buf,
49775 return -ENOSPC;
49776
49777 err = 0;
49778 - if ((count + p) > fbmemlength) {
49779 + if (count > (fbmemlength - p)) {
49780 count = fbmemlength - p;
49781 err = -ENOSPC;
49782 }
49783 diff --git a/drivers/video/aty/aty128fb.c b/drivers/video/aty/aty128fb.c
49784 index a4dfe8c..297ddd9 100644
49785 --- a/drivers/video/aty/aty128fb.c
49786 +++ b/drivers/video/aty/aty128fb.c
49787 @@ -149,7 +149,7 @@ enum {
49788 };
49789
49790 /* Must match above enum */
49791 -static char * const r128_family[] = {
49792 +static const char * const r128_family[] = {
49793 "AGP",
49794 "PCI",
49795 "PRO AGP",
49796 diff --git a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c
49797 index 9b0f12c..024673d 100644
49798 --- a/drivers/video/aty/atyfb_base.c
49799 +++ b/drivers/video/aty/atyfb_base.c
49800 @@ -1326,10 +1326,14 @@ static int atyfb_set_par(struct fb_info *info)
49801 par->accel_flags = var->accel_flags; /* hack */
49802
49803 if (var->accel_flags) {
49804 - info->fbops->fb_sync = atyfb_sync;
49805 + pax_open_kernel();
49806 + *(void **)&info->fbops->fb_sync = atyfb_sync;
49807 + pax_close_kernel();
49808 info->flags &= ~FBINFO_HWACCEL_DISABLED;
49809 } else {
49810 - info->fbops->fb_sync = NULL;
49811 + pax_open_kernel();
49812 + *(void **)&info->fbops->fb_sync = NULL;
49813 + pax_close_kernel();
49814 info->flags |= FBINFO_HWACCEL_DISABLED;
49815 }
49816
49817 diff --git a/drivers/video/aty/mach64_cursor.c b/drivers/video/aty/mach64_cursor.c
49818 index 95ec042..e6affdd 100644
49819 --- a/drivers/video/aty/mach64_cursor.c
49820 +++ b/drivers/video/aty/mach64_cursor.c
49821 @@ -7,6 +7,7 @@
49822 #include <linux/string.h>
49823
49824 #include <asm/io.h>
49825 +#include <asm/pgtable.h>
49826
49827 #ifdef __sparc__
49828 #include <asm/fbio.h>
49829 @@ -208,7 +209,9 @@ int aty_init_cursor(struct fb_info *info)
49830 info->sprite.buf_align = 16; /* and 64 lines tall. */
49831 info->sprite.flags = FB_PIXMAP_IO;
49832
49833 - info->fbops->fb_cursor = atyfb_cursor;
49834 + pax_open_kernel();
49835 + *(void **)&info->fbops->fb_cursor = atyfb_cursor;
49836 + pax_close_kernel();
49837
49838 return 0;
49839 }
49840 diff --git a/drivers/video/backlight/kb3886_bl.c b/drivers/video/backlight/kb3886_bl.c
49841 index bca6ccc..252107e 100644
49842 --- a/drivers/video/backlight/kb3886_bl.c
49843 +++ b/drivers/video/backlight/kb3886_bl.c
49844 @@ -78,7 +78,7 @@ static struct kb3886bl_machinfo *bl_machinfo;
49845 static unsigned long kb3886bl_flags;
49846 #define KB3886BL_SUSPENDED 0x01
49847
49848 -static struct dmi_system_id __initdata kb3886bl_device_table[] = {
49849 +static const struct dmi_system_id __initconst kb3886bl_device_table[] = {
49850 {
49851 .ident = "Sahara Touch-iT",
49852 .matches = {
49853 diff --git a/drivers/video/fb_defio.c b/drivers/video/fb_defio.c
49854 index 900aa4e..6d49418 100644
49855 --- a/drivers/video/fb_defio.c
49856 +++ b/drivers/video/fb_defio.c
49857 @@ -206,7 +206,9 @@ void fb_deferred_io_init(struct fb_info *info)
49858
49859 BUG_ON(!fbdefio);
49860 mutex_init(&fbdefio->lock);
49861 - info->fbops->fb_mmap = fb_deferred_io_mmap;
49862 + pax_open_kernel();
49863 + *(void **)&info->fbops->fb_mmap = fb_deferred_io_mmap;
49864 + pax_close_kernel();
49865 INIT_DELAYED_WORK(&info->deferred_work, fb_deferred_io_work);
49866 INIT_LIST_HEAD(&fbdefio->pagelist);
49867 if (fbdefio->delay == 0) /* set a default of 1 s */
49868 @@ -237,7 +239,7 @@ void fb_deferred_io_cleanup(struct fb_info *info)
49869 page->mapping = NULL;
49870 }
49871
49872 - info->fbops->fb_mmap = NULL;
49873 + *(void **)&info->fbops->fb_mmap = NULL;
49874 mutex_destroy(&fbdefio->lock);
49875 }
49876 EXPORT_SYMBOL_GPL(fb_deferred_io_cleanup);
49877 diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
49878 index dacaf74..8478a46 100644
49879 --- a/drivers/video/fbmem.c
49880 +++ b/drivers/video/fbmem.c
49881 @@ -433,7 +433,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
49882 image->dx += image->width + 8;
49883 }
49884 } else if (rotate == FB_ROTATE_UD) {
49885 - for (x = 0; x < num && image->dx >= 0; x++) {
49886 + for (x = 0; x < num && (__s32)image->dx >= 0; x++) {
49887 info->fbops->fb_imageblit(info, image);
49888 image->dx -= image->width + 8;
49889 }
49890 @@ -445,7 +445,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
49891 image->dy += image->height + 8;
49892 }
49893 } else if (rotate == FB_ROTATE_CCW) {
49894 - for (x = 0; x < num && image->dy >= 0; x++) {
49895 + for (x = 0; x < num && (__s32)image->dy >= 0; x++) {
49896 info->fbops->fb_imageblit(info, image);
49897 image->dy -= image->height + 8;
49898 }
49899 @@ -1175,7 +1175,7 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
49900 return -EFAULT;
49901 if (con2fb.console < 1 || con2fb.console > MAX_NR_CONSOLES)
49902 return -EINVAL;
49903 - if (con2fb.framebuffer < 0 || con2fb.framebuffer >= FB_MAX)
49904 + if (con2fb.framebuffer >= FB_MAX)
49905 return -EINVAL;
49906 if (!registered_fb[con2fb.framebuffer])
49907 request_module("fb%d", con2fb.framebuffer);
49908 diff --git a/drivers/video/hyperv_fb.c b/drivers/video/hyperv_fb.c
49909 index 8d456dc..b4fa44b 100644
49910 --- a/drivers/video/hyperv_fb.c
49911 +++ b/drivers/video/hyperv_fb.c
49912 @@ -233,7 +233,7 @@ static uint screen_fb_size;
49913 static inline int synthvid_send(struct hv_device *hdev,
49914 struct synthvid_msg *msg)
49915 {
49916 - static atomic64_t request_id = ATOMIC64_INIT(0);
49917 + static atomic64_unchecked_t request_id = ATOMIC64_INIT(0);
49918 int ret;
49919
49920 msg->pipe_hdr.type = PIPE_MSG_DATA;
49921 @@ -241,7 +241,7 @@ static inline int synthvid_send(struct hv_device *hdev,
49922
49923 ret = vmbus_sendpacket(hdev->channel, msg,
49924 msg->vid_hdr.size + sizeof(struct pipe_msg_hdr),
49925 - atomic64_inc_return(&request_id),
49926 + atomic64_inc_return_unchecked(&request_id),
49927 VM_PKT_DATA_INBAND, 0);
49928
49929 if (ret)
49930 diff --git a/drivers/video/i810/i810_accel.c b/drivers/video/i810/i810_accel.c
49931 index 7672d2e..b56437f 100644
49932 --- a/drivers/video/i810/i810_accel.c
49933 +++ b/drivers/video/i810/i810_accel.c
49934 @@ -73,6 +73,7 @@ static inline int wait_for_space(struct fb_info *info, u32 space)
49935 }
49936 }
49937 printk("ringbuffer lockup!!!\n");
49938 + printk("head:%u tail:%u iring.size:%u space:%u\n", head, tail, par->iring.size, space);
49939 i810_report_error(mmio);
49940 par->dev_flags |= LOCKUP;
49941 info->pixmap.scan_align = 1;
49942 diff --git a/drivers/video/logo/logo_linux_clut224.ppm b/drivers/video/logo/logo_linux_clut224.ppm
49943 index 3c14e43..2630570 100644
49944 --- a/drivers/video/logo/logo_linux_clut224.ppm
49945 +++ b/drivers/video/logo/logo_linux_clut224.ppm
49946 @@ -2,1603 +2,1123 @@ P3
49947 # Standard 224-color Linux logo
49948 80 80
49949 255
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 - 0 0 0 0 0 0 0 0 0 0 0 0
49956 - 0 0 0 0 0 0 0 0 0 0 0 0
49957 - 0 0 0 0 0 0 0 0 0 0 0 0
49958 - 0 0 0 0 0 0 0 0 0 0 0 0
49959 - 6 6 6 6 6 6 10 10 10 10 10 10
49960 - 10 10 10 6 6 6 6 6 6 6 6 6
49961 - 0 0 0 0 0 0 0 0 0 0 0 0
49962 - 0 0 0 0 0 0 0 0 0 0 0 0
49963 - 0 0 0 0 0 0 0 0 0 0 0 0
49964 - 0 0 0 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 0 0 0
49975 - 0 0 0 0 0 0 0 0 0 0 0 0
49976 - 0 0 0 0 0 0 0 0 0 0 0 0
49977 - 0 0 0 0 0 0 0 0 0 0 0 0
49978 - 0 0 0 6 6 6 10 10 10 14 14 14
49979 - 22 22 22 26 26 26 30 30 30 34 34 34
49980 - 30 30 30 30 30 30 26 26 26 18 18 18
49981 - 14 14 14 10 10 10 6 6 6 0 0 0
49982 - 0 0 0 0 0 0 0 0 0 0 0 0
49983 - 0 0 0 0 0 0 0 0 0 0 0 0
49984 - 0 0 0 0 0 0 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 1 0 0 1 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 0 0 0
49995 - 0 0 0 0 0 0 0 0 0 0 0 0
49996 - 0 0 0 0 0 0 0 0 0 0 0 0
49997 - 0 0 0 0 0 0 0 0 0 0 0 0
49998 - 6 6 6 14 14 14 26 26 26 42 42 42
49999 - 54 54 54 66 66 66 78 78 78 78 78 78
50000 - 78 78 78 74 74 74 66 66 66 54 54 54
50001 - 42 42 42 26 26 26 18 18 18 10 10 10
50002 - 6 6 6 0 0 0 0 0 0 0 0 0
50003 - 0 0 0 0 0 0 0 0 0 0 0 0
50004 - 0 0 0 0 0 0 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 1 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 0 0 0 0 0 0
50015 - 0 0 0 0 0 0 0 0 0 0 0 0
50016 - 0 0 0 0 0 0 0 0 0 0 0 0
50017 - 0 0 0 0 0 0 0 0 0 10 10 10
50018 - 22 22 22 42 42 42 66 66 66 86 86 86
50019 - 66 66 66 38 38 38 38 38 38 22 22 22
50020 - 26 26 26 34 34 34 54 54 54 66 66 66
50021 - 86 86 86 70 70 70 46 46 46 26 26 26
50022 - 14 14 14 6 6 6 0 0 0 0 0 0
50023 - 0 0 0 0 0 0 0 0 0 0 0 0
50024 - 0 0 0 0 0 0 0 0 0 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 1 0 0 1 0 0 1 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 0 0 0 0 0 0 0 0 0
50035 - 0 0 0 0 0 0 0 0 0 0 0 0
50036 - 0 0 0 0 0 0 0 0 0 0 0 0
50037 - 0 0 0 0 0 0 10 10 10 26 26 26
50038 - 50 50 50 82 82 82 58 58 58 6 6 6
50039 - 2 2 6 2 2 6 2 2 6 2 2 6
50040 - 2 2 6 2 2 6 2 2 6 2 2 6
50041 - 6 6 6 54 54 54 86 86 86 66 66 66
50042 - 38 38 38 18 18 18 6 6 6 0 0 0
50043 - 0 0 0 0 0 0 0 0 0 0 0 0
50044 - 0 0 0 0 0 0 0 0 0 0 0 0
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 - 0 0 0 0 0 0 0 0 0 0 0 0
50055 - 0 0 0 0 0 0 0 0 0 0 0 0
50056 - 0 0 0 0 0 0 0 0 0 0 0 0
50057 - 0 0 0 6 6 6 22 22 22 50 50 50
50058 - 78 78 78 34 34 34 2 2 6 2 2 6
50059 - 2 2 6 2 2 6 2 2 6 2 2 6
50060 - 2 2 6 2 2 6 2 2 6 2 2 6
50061 - 2 2 6 2 2 6 6 6 6 70 70 70
50062 - 78 78 78 46 46 46 22 22 22 6 6 6
50063 - 0 0 0 0 0 0 0 0 0 0 0 0
50064 - 0 0 0 0 0 0 0 0 0 0 0 0
50065 - 0 0 0 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 1 0 0 1 0 0 1 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 - 0 0 0 0 0 0 0 0 0 0 0 0
50075 - 0 0 0 0 0 0 0 0 0 0 0 0
50076 - 0 0 0 0 0 0 0 0 0 0 0 0
50077 - 6 6 6 18 18 18 42 42 42 82 82 82
50078 - 26 26 26 2 2 6 2 2 6 2 2 6
50079 - 2 2 6 2 2 6 2 2 6 2 2 6
50080 - 2 2 6 2 2 6 2 2 6 14 14 14
50081 - 46 46 46 34 34 34 6 6 6 2 2 6
50082 - 42 42 42 78 78 78 42 42 42 18 18 18
50083 - 6 6 6 0 0 0 0 0 0 0 0 0
50084 - 0 0 0 0 0 0 0 0 0 0 0 0
50085 - 0 0 0 0 0 0 0 0 0 0 0 0
50086 - 0 0 0 0 0 0 0 0 0 0 0 0
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 1 0 0 0 0 0 1 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 - 0 0 0 0 0 0 0 0 0 0 0 0
50095 - 0 0 0 0 0 0 0 0 0 0 0 0
50096 - 0 0 0 0 0 0 0 0 0 0 0 0
50097 - 10 10 10 30 30 30 66 66 66 58 58 58
50098 - 2 2 6 2 2 6 2 2 6 2 2 6
50099 - 2 2 6 2 2 6 2 2 6 2 2 6
50100 - 2 2 6 2 2 6 2 2 6 26 26 26
50101 - 86 86 86 101 101 101 46 46 46 10 10 10
50102 - 2 2 6 58 58 58 70 70 70 34 34 34
50103 - 10 10 10 0 0 0 0 0 0 0 0 0
50104 - 0 0 0 0 0 0 0 0 0 0 0 0
50105 - 0 0 0 0 0 0 0 0 0 0 0 0
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 1 0 0 1 0 0 1 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 0 0 0
50114 - 0 0 0 0 0 0 0 0 0 0 0 0
50115 - 0 0 0 0 0 0 0 0 0 0 0 0
50116 - 0 0 0 0 0 0 0 0 0 0 0 0
50117 - 14 14 14 42 42 42 86 86 86 10 10 10
50118 - 2 2 6 2 2 6 2 2 6 2 2 6
50119 - 2 2 6 2 2 6 2 2 6 2 2 6
50120 - 2 2 6 2 2 6 2 2 6 30 30 30
50121 - 94 94 94 94 94 94 58 58 58 26 26 26
50122 - 2 2 6 6 6 6 78 78 78 54 54 54
50123 - 22 22 22 6 6 6 0 0 0 0 0 0
50124 - 0 0 0 0 0 0 0 0 0 0 0 0
50125 - 0 0 0 0 0 0 0 0 0 0 0 0
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 0 0 0
50134 - 0 0 0 0 0 0 0 0 0 0 0 0
50135 - 0 0 0 0 0 0 0 0 0 0 0 0
50136 - 0 0 0 0 0 0 0 0 0 6 6 6
50137 - 22 22 22 62 62 62 62 62 62 2 2 6
50138 - 2 2 6 2 2 6 2 2 6 2 2 6
50139 - 2 2 6 2 2 6 2 2 6 2 2 6
50140 - 2 2 6 2 2 6 2 2 6 26 26 26
50141 - 54 54 54 38 38 38 18 18 18 10 10 10
50142 - 2 2 6 2 2 6 34 34 34 82 82 82
50143 - 38 38 38 14 14 14 0 0 0 0 0 0
50144 - 0 0 0 0 0 0 0 0 0 0 0 0
50145 - 0 0 0 0 0 0 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 1 0 0 1 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 0 0 0
50154 - 0 0 0 0 0 0 0 0 0 0 0 0
50155 - 0 0 0 0 0 0 0 0 0 0 0 0
50156 - 0 0 0 0 0 0 0 0 0 6 6 6
50157 - 30 30 30 78 78 78 30 30 30 2 2 6
50158 - 2 2 6 2 2 6 2 2 6 2 2 6
50159 - 2 2 6 2 2 6 2 2 6 2 2 6
50160 - 2 2 6 2 2 6 2 2 6 10 10 10
50161 - 10 10 10 2 2 6 2 2 6 2 2 6
50162 - 2 2 6 2 2 6 2 2 6 78 78 78
50163 - 50 50 50 18 18 18 6 6 6 0 0 0
50164 - 0 0 0 0 0 0 0 0 0 0 0 0
50165 - 0 0 0 0 0 0 0 0 0 0 0 0
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 1 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 0 0 0 0 0 0
50174 - 0 0 0 0 0 0 0 0 0 0 0 0
50175 - 0 0 0 0 0 0 0 0 0 0 0 0
50176 - 0 0 0 0 0 0 0 0 0 10 10 10
50177 - 38 38 38 86 86 86 14 14 14 2 2 6
50178 - 2 2 6 2 2 6 2 2 6 2 2 6
50179 - 2 2 6 2 2 6 2 2 6 2 2 6
50180 - 2 2 6 2 2 6 2 2 6 2 2 6
50181 - 2 2 6 2 2 6 2 2 6 2 2 6
50182 - 2 2 6 2 2 6 2 2 6 54 54 54
50183 - 66 66 66 26 26 26 6 6 6 0 0 0
50184 - 0 0 0 0 0 0 0 0 0 0 0 0
50185 - 0 0 0 0 0 0 0 0 0 0 0 0
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 1 0 0 1 0 0 0
50192 - 0 0 0 0 0 0 0 0 0 0 0 0
50193 - 0 0 0 0 0 0 0 0 0 0 0 0
50194 - 0 0 0 0 0 0 0 0 0 0 0 0
50195 - 0 0 0 0 0 0 0 0 0 0 0 0
50196 - 0 0 0 0 0 0 0 0 0 14 14 14
50197 - 42 42 42 82 82 82 2 2 6 2 2 6
50198 - 2 2 6 6 6 6 10 10 10 2 2 6
50199 - 2 2 6 2 2 6 2 2 6 2 2 6
50200 - 2 2 6 2 2 6 2 2 6 6 6 6
50201 - 14 14 14 10 10 10 2 2 6 2 2 6
50202 - 2 2 6 2 2 6 2 2 6 18 18 18
50203 - 82 82 82 34 34 34 10 10 10 0 0 0
50204 - 0 0 0 0 0 0 0 0 0 0 0 0
50205 - 0 0 0 0 0 0 0 0 0 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 1 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 0 0 0 0 0 0 0 0 0
50214 - 0 0 0 0 0 0 0 0 0 0 0 0
50215 - 0 0 0 0 0 0 0 0 0 0 0 0
50216 - 0 0 0 0 0 0 0 0 0 14 14 14
50217 - 46 46 46 86 86 86 2 2 6 2 2 6
50218 - 6 6 6 6 6 6 22 22 22 34 34 34
50219 - 6 6 6 2 2 6 2 2 6 2 2 6
50220 - 2 2 6 2 2 6 18 18 18 34 34 34
50221 - 10 10 10 50 50 50 22 22 22 2 2 6
50222 - 2 2 6 2 2 6 2 2 6 10 10 10
50223 - 86 86 86 42 42 42 14 14 14 0 0 0
50224 - 0 0 0 0 0 0 0 0 0 0 0 0
50225 - 0 0 0 0 0 0 0 0 0 0 0 0
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 1 0 0 1 0 0 1 0 0 0
50232 - 0 0 0 0 0 0 0 0 0 0 0 0
50233 - 0 0 0 0 0 0 0 0 0 0 0 0
50234 - 0 0 0 0 0 0 0 0 0 0 0 0
50235 - 0 0 0 0 0 0 0 0 0 0 0 0
50236 - 0 0 0 0 0 0 0 0 0 14 14 14
50237 - 46 46 46 86 86 86 2 2 6 2 2 6
50238 - 38 38 38 116 116 116 94 94 94 22 22 22
50239 - 22 22 22 2 2 6 2 2 6 2 2 6
50240 - 14 14 14 86 86 86 138 138 138 162 162 162
50241 -154 154 154 38 38 38 26 26 26 6 6 6
50242 - 2 2 6 2 2 6 2 2 6 2 2 6
50243 - 86 86 86 46 46 46 14 14 14 0 0 0
50244 - 0 0 0 0 0 0 0 0 0 0 0 0
50245 - 0 0 0 0 0 0 0 0 0 0 0 0
50246 - 0 0 0 0 0 0 0 0 0 0 0 0
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 - 0 0 0 0 0 0 0 0 0 0 0 0
50254 - 0 0 0 0 0 0 0 0 0 0 0 0
50255 - 0 0 0 0 0 0 0 0 0 0 0 0
50256 - 0 0 0 0 0 0 0 0 0 14 14 14
50257 - 46 46 46 86 86 86 2 2 6 14 14 14
50258 -134 134 134 198 198 198 195 195 195 116 116 116
50259 - 10 10 10 2 2 6 2 2 6 6 6 6
50260 -101 98 89 187 187 187 210 210 210 218 218 218
50261 -214 214 214 134 134 134 14 14 14 6 6 6
50262 - 2 2 6 2 2 6 2 2 6 2 2 6
50263 - 86 86 86 50 50 50 18 18 18 6 6 6
50264 - 0 0 0 0 0 0 0 0 0 0 0 0
50265 - 0 0 0 0 0 0 0 0 0 0 0 0
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 1 0 0 0
50271 - 0 0 1 0 0 1 0 0 1 0 0 0
50272 - 0 0 0 0 0 0 0 0 0 0 0 0
50273 - 0 0 0 0 0 0 0 0 0 0 0 0
50274 - 0 0 0 0 0 0 0 0 0 0 0 0
50275 - 0 0 0 0 0 0 0 0 0 0 0 0
50276 - 0 0 0 0 0 0 0 0 0 14 14 14
50277 - 46 46 46 86 86 86 2 2 6 54 54 54
50278 -218 218 218 195 195 195 226 226 226 246 246 246
50279 - 58 58 58 2 2 6 2 2 6 30 30 30
50280 -210 210 210 253 253 253 174 174 174 123 123 123
50281 -221 221 221 234 234 234 74 74 74 2 2 6
50282 - 2 2 6 2 2 6 2 2 6 2 2 6
50283 - 70 70 70 58 58 58 22 22 22 6 6 6
50284 - 0 0 0 0 0 0 0 0 0 0 0 0
50285 - 0 0 0 0 0 0 0 0 0 0 0 0
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 0 0 0
50293 - 0 0 0 0 0 0 0 0 0 0 0 0
50294 - 0 0 0 0 0 0 0 0 0 0 0 0
50295 - 0 0 0 0 0 0 0 0 0 0 0 0
50296 - 0 0 0 0 0 0 0 0 0 14 14 14
50297 - 46 46 46 82 82 82 2 2 6 106 106 106
50298 -170 170 170 26 26 26 86 86 86 226 226 226
50299 -123 123 123 10 10 10 14 14 14 46 46 46
50300 -231 231 231 190 190 190 6 6 6 70 70 70
50301 - 90 90 90 238 238 238 158 158 158 2 2 6
50302 - 2 2 6 2 2 6 2 2 6 2 2 6
50303 - 70 70 70 58 58 58 22 22 22 6 6 6
50304 - 0 0 0 0 0 0 0 0 0 0 0 0
50305 - 0 0 0 0 0 0 0 0 0 0 0 0
50306 - 0 0 0 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 1 0 0 0
50311 - 0 0 1 0 0 1 0 0 1 0 0 0
50312 - 0 0 0 0 0 0 0 0 0 0 0 0
50313 - 0 0 0 0 0 0 0 0 0 0 0 0
50314 - 0 0 0 0 0 0 0 0 0 0 0 0
50315 - 0 0 0 0 0 0 0 0 0 0 0 0
50316 - 0 0 0 0 0 0 0 0 0 14 14 14
50317 - 42 42 42 86 86 86 6 6 6 116 116 116
50318 -106 106 106 6 6 6 70 70 70 149 149 149
50319 -128 128 128 18 18 18 38 38 38 54 54 54
50320 -221 221 221 106 106 106 2 2 6 14 14 14
50321 - 46 46 46 190 190 190 198 198 198 2 2 6
50322 - 2 2 6 2 2 6 2 2 6 2 2 6
50323 - 74 74 74 62 62 62 22 22 22 6 6 6
50324 - 0 0 0 0 0 0 0 0 0 0 0 0
50325 - 0 0 0 0 0 0 0 0 0 0 0 0
50326 - 0 0 0 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 1 0 0 0
50331 - 0 0 1 0 0 0 0 0 1 0 0 0
50332 - 0 0 0 0 0 0 0 0 0 0 0 0
50333 - 0 0 0 0 0 0 0 0 0 0 0 0
50334 - 0 0 0 0 0 0 0 0 0 0 0 0
50335 - 0 0 0 0 0 0 0 0 0 0 0 0
50336 - 0 0 0 0 0 0 0 0 0 14 14 14
50337 - 42 42 42 94 94 94 14 14 14 101 101 101
50338 -128 128 128 2 2 6 18 18 18 116 116 116
50339 -118 98 46 121 92 8 121 92 8 98 78 10
50340 -162 162 162 106 106 106 2 2 6 2 2 6
50341 - 2 2 6 195 195 195 195 195 195 6 6 6
50342 - 2 2 6 2 2 6 2 2 6 2 2 6
50343 - 74 74 74 62 62 62 22 22 22 6 6 6
50344 - 0 0 0 0 0 0 0 0 0 0 0 0
50345 - 0 0 0 0 0 0 0 0 0 0 0 0
50346 - 0 0 0 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 1 0 0 1
50351 - 0 0 1 0 0 0 0 0 1 0 0 0
50352 - 0 0 0 0 0 0 0 0 0 0 0 0
50353 - 0 0 0 0 0 0 0 0 0 0 0 0
50354 - 0 0 0 0 0 0 0 0 0 0 0 0
50355 - 0 0 0 0 0 0 0 0 0 0 0 0
50356 - 0 0 0 0 0 0 0 0 0 10 10 10
50357 - 38 38 38 90 90 90 14 14 14 58 58 58
50358 -210 210 210 26 26 26 54 38 6 154 114 10
50359 -226 170 11 236 186 11 225 175 15 184 144 12
50360 -215 174 15 175 146 61 37 26 9 2 2 6
50361 - 70 70 70 246 246 246 138 138 138 2 2 6
50362 - 2 2 6 2 2 6 2 2 6 2 2 6
50363 - 70 70 70 66 66 66 26 26 26 6 6 6
50364 - 0 0 0 0 0 0 0 0 0 0 0 0
50365 - 0 0 0 0 0 0 0 0 0 0 0 0
50366 - 0 0 0 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 0 0 0 0 0 0
50373 - 0 0 0 0 0 0 0 0 0 0 0 0
50374 - 0 0 0 0 0 0 0 0 0 0 0 0
50375 - 0 0 0 0 0 0 0 0 0 0 0 0
50376 - 0 0 0 0 0 0 0 0 0 10 10 10
50377 - 38 38 38 86 86 86 14 14 14 10 10 10
50378 -195 195 195 188 164 115 192 133 9 225 175 15
50379 -239 182 13 234 190 10 232 195 16 232 200 30
50380 -245 207 45 241 208 19 232 195 16 184 144 12
50381 -218 194 134 211 206 186 42 42 42 2 2 6
50382 - 2 2 6 2 2 6 2 2 6 2 2 6
50383 - 50 50 50 74 74 74 30 30 30 6 6 6
50384 - 0 0 0 0 0 0 0 0 0 0 0 0
50385 - 0 0 0 0 0 0 0 0 0 0 0 0
50386 - 0 0 0 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 0 0 0 0 0 0
50393 - 0 0 0 0 0 0 0 0 0 0 0 0
50394 - 0 0 0 0 0 0 0 0 0 0 0 0
50395 - 0 0 0 0 0 0 0 0 0 0 0 0
50396 - 0 0 0 0 0 0 0 0 0 10 10 10
50397 - 34 34 34 86 86 86 14 14 14 2 2 6
50398 -121 87 25 192 133 9 219 162 10 239 182 13
50399 -236 186 11 232 195 16 241 208 19 244 214 54
50400 -246 218 60 246 218 38 246 215 20 241 208 19
50401 -241 208 19 226 184 13 121 87 25 2 2 6
50402 - 2 2 6 2 2 6 2 2 6 2 2 6
50403 - 50 50 50 82 82 82 34 34 34 10 10 10
50404 - 0 0 0 0 0 0 0 0 0 0 0 0
50405 - 0 0 0 0 0 0 0 0 0 0 0 0
50406 - 0 0 0 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 0 0 0 0 0 0
50413 - 0 0 0 0 0 0 0 0 0 0 0 0
50414 - 0 0 0 0 0 0 0 0 0 0 0 0
50415 - 0 0 0 0 0 0 0 0 0 0 0 0
50416 - 0 0 0 0 0 0 0 0 0 10 10 10
50417 - 34 34 34 82 82 82 30 30 30 61 42 6
50418 -180 123 7 206 145 10 230 174 11 239 182 13
50419 -234 190 10 238 202 15 241 208 19 246 218 74
50420 -246 218 38 246 215 20 246 215 20 246 215 20
50421 -226 184 13 215 174 15 184 144 12 6 6 6
50422 - 2 2 6 2 2 6 2 2 6 2 2 6
50423 - 26 26 26 94 94 94 42 42 42 14 14 14
50424 - 0 0 0 0 0 0 0 0 0 0 0 0
50425 - 0 0 0 0 0 0 0 0 0 0 0 0
50426 - 0 0 0 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 0 0 0
50432 - 0 0 0 0 0 0 0 0 0 0 0 0
50433 - 0 0 0 0 0 0 0 0 0 0 0 0
50434 - 0 0 0 0 0 0 0 0 0 0 0 0
50435 - 0 0 0 0 0 0 0 0 0 0 0 0
50436 - 0 0 0 0 0 0 0 0 0 10 10 10
50437 - 30 30 30 78 78 78 50 50 50 104 69 6
50438 -192 133 9 216 158 10 236 178 12 236 186 11
50439 -232 195 16 241 208 19 244 214 54 245 215 43
50440 -246 215 20 246 215 20 241 208 19 198 155 10
50441 -200 144 11 216 158 10 156 118 10 2 2 6
50442 - 2 2 6 2 2 6 2 2 6 2 2 6
50443 - 6 6 6 90 90 90 54 54 54 18 18 18
50444 - 6 6 6 0 0 0 0 0 0 0 0 0
50445 - 0 0 0 0 0 0 0 0 0 0 0 0
50446 - 0 0 0 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 0 0 0 0 0 0 0 0 0
50452 - 0 0 0 0 0 0 0 0 0 0 0 0
50453 - 0 0 0 0 0 0 0 0 0 0 0 0
50454 - 0 0 0 0 0 0 0 0 0 0 0 0
50455 - 0 0 0 0 0 0 0 0 0 0 0 0
50456 - 0 0 0 0 0 0 0 0 0 10 10 10
50457 - 30 30 30 78 78 78 46 46 46 22 22 22
50458 -137 92 6 210 162 10 239 182 13 238 190 10
50459 -238 202 15 241 208 19 246 215 20 246 215 20
50460 -241 208 19 203 166 17 185 133 11 210 150 10
50461 -216 158 10 210 150 10 102 78 10 2 2 6
50462 - 6 6 6 54 54 54 14 14 14 2 2 6
50463 - 2 2 6 62 62 62 74 74 74 30 30 30
50464 - 10 10 10 0 0 0 0 0 0 0 0 0
50465 - 0 0 0 0 0 0 0 0 0 0 0 0
50466 - 0 0 0 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 - 0 0 0 0 0 0 0 0 0 0 0 0
50472 - 0 0 0 0 0 0 0 0 0 0 0 0
50473 - 0 0 0 0 0 0 0 0 0 0 0 0
50474 - 0 0 0 0 0 0 0 0 0 0 0 0
50475 - 0 0 0 0 0 0 0 0 0 0 0 0
50476 - 0 0 0 0 0 0 0 0 0 10 10 10
50477 - 34 34 34 78 78 78 50 50 50 6 6 6
50478 - 94 70 30 139 102 15 190 146 13 226 184 13
50479 -232 200 30 232 195 16 215 174 15 190 146 13
50480 -168 122 10 192 133 9 210 150 10 213 154 11
50481 -202 150 34 182 157 106 101 98 89 2 2 6
50482 - 2 2 6 78 78 78 116 116 116 58 58 58
50483 - 2 2 6 22 22 22 90 90 90 46 46 46
50484 - 18 18 18 6 6 6 0 0 0 0 0 0
50485 - 0 0 0 0 0 0 0 0 0 0 0 0
50486 - 0 0 0 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 - 0 0 0 0 0 0 0 0 0 0 0 0
50492 - 0 0 0 0 0 0 0 0 0 0 0 0
50493 - 0 0 0 0 0 0 0 0 0 0 0 0
50494 - 0 0 0 0 0 0 0 0 0 0 0 0
50495 - 0 0 0 0 0 0 0 0 0 0 0 0
50496 - 0 0 0 0 0 0 0 0 0 10 10 10
50497 - 38 38 38 86 86 86 50 50 50 6 6 6
50498 -128 128 128 174 154 114 156 107 11 168 122 10
50499 -198 155 10 184 144 12 197 138 11 200 144 11
50500 -206 145 10 206 145 10 197 138 11 188 164 115
50501 -195 195 195 198 198 198 174 174 174 14 14 14
50502 - 2 2 6 22 22 22 116 116 116 116 116 116
50503 - 22 22 22 2 2 6 74 74 74 70 70 70
50504 - 30 30 30 10 10 10 0 0 0 0 0 0
50505 - 0 0 0 0 0 0 0 0 0 0 0 0
50506 - 0 0 0 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 0 0 0
50511 - 0 0 0 0 0 0 0 0 0 0 0 0
50512 - 0 0 0 0 0 0 0 0 0 0 0 0
50513 - 0 0 0 0 0 0 0 0 0 0 0 0
50514 - 0 0 0 0 0 0 0 0 0 0 0 0
50515 - 0 0 0 0 0 0 0 0 0 0 0 0
50516 - 0 0 0 0 0 0 6 6 6 18 18 18
50517 - 50 50 50 101 101 101 26 26 26 10 10 10
50518 -138 138 138 190 190 190 174 154 114 156 107 11
50519 -197 138 11 200 144 11 197 138 11 192 133 9
50520 -180 123 7 190 142 34 190 178 144 187 187 187
50521 -202 202 202 221 221 221 214 214 214 66 66 66
50522 - 2 2 6 2 2 6 50 50 50 62 62 62
50523 - 6 6 6 2 2 6 10 10 10 90 90 90
50524 - 50 50 50 18 18 18 6 6 6 0 0 0
50525 - 0 0 0 0 0 0 0 0 0 0 0 0
50526 - 0 0 0 0 0 0 0 0 0 0 0 0
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 0 0 0
50531 - 0 0 0 0 0 0 0 0 0 0 0 0
50532 - 0 0 0 0 0 0 0 0 0 0 0 0
50533 - 0 0 0 0 0 0 0 0 0 0 0 0
50534 - 0 0 0 0 0 0 0 0 0 0 0 0
50535 - 0 0 0 0 0 0 0 0 0 0 0 0
50536 - 0 0 0 0 0 0 10 10 10 34 34 34
50537 - 74 74 74 74 74 74 2 2 6 6 6 6
50538 -144 144 144 198 198 198 190 190 190 178 166 146
50539 -154 121 60 156 107 11 156 107 11 168 124 44
50540 -174 154 114 187 187 187 190 190 190 210 210 210
50541 -246 246 246 253 253 253 253 253 253 182 182 182
50542 - 6 6 6 2 2 6 2 2 6 2 2 6
50543 - 2 2 6 2 2 6 2 2 6 62 62 62
50544 - 74 74 74 34 34 34 14 14 14 0 0 0
50545 - 0 0 0 0 0 0 0 0 0 0 0 0
50546 - 0 0 0 0 0 0 0 0 0 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 0 0 0
50551 - 0 0 0 0 0 0 0 0 0 0 0 0
50552 - 0 0 0 0 0 0 0 0 0 0 0 0
50553 - 0 0 0 0 0 0 0 0 0 0 0 0
50554 - 0 0 0 0 0 0 0 0 0 0 0 0
50555 - 0 0 0 0 0 0 0 0 0 0 0 0
50556 - 0 0 0 10 10 10 22 22 22 54 54 54
50557 - 94 94 94 18 18 18 2 2 6 46 46 46
50558 -234 234 234 221 221 221 190 190 190 190 190 190
50559 -190 190 190 187 187 187 187 187 187 190 190 190
50560 -190 190 190 195 195 195 214 214 214 242 242 242
50561 -253 253 253 253 253 253 253 253 253 253 253 253
50562 - 82 82 82 2 2 6 2 2 6 2 2 6
50563 - 2 2 6 2 2 6 2 2 6 14 14 14
50564 - 86 86 86 54 54 54 22 22 22 6 6 6
50565 - 0 0 0 0 0 0 0 0 0 0 0 0
50566 - 0 0 0 0 0 0 0 0 0 0 0 0
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 0 0 0
50571 - 0 0 0 0 0 0 0 0 0 0 0 0
50572 - 0 0 0 0 0 0 0 0 0 0 0 0
50573 - 0 0 0 0 0 0 0 0 0 0 0 0
50574 - 0 0 0 0 0 0 0 0 0 0 0 0
50575 - 0 0 0 0 0 0 0 0 0 0 0 0
50576 - 6 6 6 18 18 18 46 46 46 90 90 90
50577 - 46 46 46 18 18 18 6 6 6 182 182 182
50578 -253 253 253 246 246 246 206 206 206 190 190 190
50579 -190 190 190 190 190 190 190 190 190 190 190 190
50580 -206 206 206 231 231 231 250 250 250 253 253 253
50581 -253 253 253 253 253 253 253 253 253 253 253 253
50582 -202 202 202 14 14 14 2 2 6 2 2 6
50583 - 2 2 6 2 2 6 2 2 6 2 2 6
50584 - 42 42 42 86 86 86 42 42 42 18 18 18
50585 - 6 6 6 0 0 0 0 0 0 0 0 0
50586 - 0 0 0 0 0 0 0 0 0 0 0 0
50587 - 0 0 0 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 0 0 0
50591 - 0 0 0 0 0 0 0 0 0 0 0 0
50592 - 0 0 0 0 0 0 0 0 0 0 0 0
50593 - 0 0 0 0 0 0 0 0 0 0 0 0
50594 - 0 0 0 0 0 0 0 0 0 0 0 0
50595 - 0 0 0 0 0 0 0 0 0 6 6 6
50596 - 14 14 14 38 38 38 74 74 74 66 66 66
50597 - 2 2 6 6 6 6 90 90 90 250 250 250
50598 -253 253 253 253 253 253 238 238 238 198 198 198
50599 -190 190 190 190 190 190 195 195 195 221 221 221
50600 -246 246 246 253 253 253 253 253 253 253 253 253
50601 -253 253 253 253 253 253 253 253 253 253 253 253
50602 -253 253 253 82 82 82 2 2 6 2 2 6
50603 - 2 2 6 2 2 6 2 2 6 2 2 6
50604 - 2 2 6 78 78 78 70 70 70 34 34 34
50605 - 14 14 14 6 6 6 0 0 0 0 0 0
50606 - 0 0 0 0 0 0 0 0 0 0 0 0
50607 - 0 0 0 0 0 0 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 0 0 0
50611 - 0 0 0 0 0 0 0 0 0 0 0 0
50612 - 0 0 0 0 0 0 0 0 0 0 0 0
50613 - 0 0 0 0 0 0 0 0 0 0 0 0
50614 - 0 0 0 0 0 0 0 0 0 0 0 0
50615 - 0 0 0 0 0 0 0 0 0 14 14 14
50616 - 34 34 34 66 66 66 78 78 78 6 6 6
50617 - 2 2 6 18 18 18 218 218 218 253 253 253
50618 -253 253 253 253 253 253 253 253 253 246 246 246
50619 -226 226 226 231 231 231 246 246 246 253 253 253
50620 -253 253 253 253 253 253 253 253 253 253 253 253
50621 -253 253 253 253 253 253 253 253 253 253 253 253
50622 -253 253 253 178 178 178 2 2 6 2 2 6
50623 - 2 2 6 2 2 6 2 2 6 2 2 6
50624 - 2 2 6 18 18 18 90 90 90 62 62 62
50625 - 30 30 30 10 10 10 0 0 0 0 0 0
50626 - 0 0 0 0 0 0 0 0 0 0 0 0
50627 - 0 0 0 0 0 0 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 0 0 0
50631 - 0 0 0 0 0 0 0 0 0 0 0 0
50632 - 0 0 0 0 0 0 0 0 0 0 0 0
50633 - 0 0 0 0 0 0 0 0 0 0 0 0
50634 - 0 0 0 0 0 0 0 0 0 0 0 0
50635 - 0 0 0 0 0 0 10 10 10 26 26 26
50636 - 58 58 58 90 90 90 18 18 18 2 2 6
50637 - 2 2 6 110 110 110 253 253 253 253 253 253
50638 -253 253 253 253 253 253 253 253 253 253 253 253
50639 -250 250 250 253 253 253 253 253 253 253 253 253
50640 -253 253 253 253 253 253 253 253 253 253 253 253
50641 -253 253 253 253 253 253 253 253 253 253 253 253
50642 -253 253 253 231 231 231 18 18 18 2 2 6
50643 - 2 2 6 2 2 6 2 2 6 2 2 6
50644 - 2 2 6 2 2 6 18 18 18 94 94 94
50645 - 54 54 54 26 26 26 10 10 10 0 0 0
50646 - 0 0 0 0 0 0 0 0 0 0 0 0
50647 - 0 0 0 0 0 0 0 0 0 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 0 0 0
50651 - 0 0 0 0 0 0 0 0 0 0 0 0
50652 - 0 0 0 0 0 0 0 0 0 0 0 0
50653 - 0 0 0 0 0 0 0 0 0 0 0 0
50654 - 0 0 0 0 0 0 0 0 0 0 0 0
50655 - 0 0 0 6 6 6 22 22 22 50 50 50
50656 - 90 90 90 26 26 26 2 2 6 2 2 6
50657 - 14 14 14 195 195 195 250 250 250 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 253 253 253
50661 -253 253 253 253 253 253 253 253 253 253 253 253
50662 -250 250 250 242 242 242 54 54 54 2 2 6
50663 - 2 2 6 2 2 6 2 2 6 2 2 6
50664 - 2 2 6 2 2 6 2 2 6 38 38 38
50665 - 86 86 86 50 50 50 22 22 22 6 6 6
50666 - 0 0 0 0 0 0 0 0 0 0 0 0
50667 - 0 0 0 0 0 0 0 0 0 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 0 0 0
50671 - 0 0 0 0 0 0 0 0 0 0 0 0
50672 - 0 0 0 0 0 0 0 0 0 0 0 0
50673 - 0 0 0 0 0 0 0 0 0 0 0 0
50674 - 0 0 0 0 0 0 0 0 0 0 0 0
50675 - 6 6 6 14 14 14 38 38 38 82 82 82
50676 - 34 34 34 2 2 6 2 2 6 2 2 6
50677 - 42 42 42 195 195 195 246 246 246 253 253 253
50678 -253 253 253 253 253 253 253 253 253 250 250 250
50679 -242 242 242 242 242 242 250 250 250 253 253 253
50680 -253 253 253 253 253 253 253 253 253 253 253 253
50681 -253 253 253 250 250 250 246 246 246 238 238 238
50682 -226 226 226 231 231 231 101 101 101 6 6 6
50683 - 2 2 6 2 2 6 2 2 6 2 2 6
50684 - 2 2 6 2 2 6 2 2 6 2 2 6
50685 - 38 38 38 82 82 82 42 42 42 14 14 14
50686 - 6 6 6 0 0 0 0 0 0 0 0 0
50687 - 0 0 0 0 0 0 0 0 0 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 0 0 0 0 0 0
50691 - 0 0 0 0 0 0 0 0 0 0 0 0
50692 - 0 0 0 0 0 0 0 0 0 0 0 0
50693 - 0 0 0 0 0 0 0 0 0 0 0 0
50694 - 0 0 0 0 0 0 0 0 0 0 0 0
50695 - 10 10 10 26 26 26 62 62 62 66 66 66
50696 - 2 2 6 2 2 6 2 2 6 6 6 6
50697 - 70 70 70 170 170 170 206 206 206 234 234 234
50698 -246 246 246 250 250 250 250 250 250 238 238 238
50699 -226 226 226 231 231 231 238 238 238 250 250 250
50700 -250 250 250 250 250 250 246 246 246 231 231 231
50701 -214 214 214 206 206 206 202 202 202 202 202 202
50702 -198 198 198 202 202 202 182 182 182 18 18 18
50703 - 2 2 6 2 2 6 2 2 6 2 2 6
50704 - 2 2 6 2 2 6 2 2 6 2 2 6
50705 - 2 2 6 62 62 62 66 66 66 30 30 30
50706 - 10 10 10 0 0 0 0 0 0 0 0 0
50707 - 0 0 0 0 0 0 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 0 0 0 0 0 0
50711 - 0 0 0 0 0 0 0 0 0 0 0 0
50712 - 0 0 0 0 0 0 0 0 0 0 0 0
50713 - 0 0 0 0 0 0 0 0 0 0 0 0
50714 - 0 0 0 0 0 0 0 0 0 0 0 0
50715 - 14 14 14 42 42 42 82 82 82 18 18 18
50716 - 2 2 6 2 2 6 2 2 6 10 10 10
50717 - 94 94 94 182 182 182 218 218 218 242 242 242
50718 -250 250 250 253 253 253 253 253 253 250 250 250
50719 -234 234 234 253 253 253 253 253 253 253 253 253
50720 -253 253 253 253 253 253 253 253 253 246 246 246
50721 -238 238 238 226 226 226 210 210 210 202 202 202
50722 -195 195 195 195 195 195 210 210 210 158 158 158
50723 - 6 6 6 14 14 14 50 50 50 14 14 14
50724 - 2 2 6 2 2 6 2 2 6 2 2 6
50725 - 2 2 6 6 6 6 86 86 86 46 46 46
50726 - 18 18 18 6 6 6 0 0 0 0 0 0
50727 - 0 0 0 0 0 0 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 0 0 0 0 0 0
50731 - 0 0 0 0 0 0 0 0 0 0 0 0
50732 - 0 0 0 0 0 0 0 0 0 0 0 0
50733 - 0 0 0 0 0 0 0 0 0 0 0 0
50734 - 0 0 0 0 0 0 0 0 0 6 6 6
50735 - 22 22 22 54 54 54 70 70 70 2 2 6
50736 - 2 2 6 10 10 10 2 2 6 22 22 22
50737 -166 166 166 231 231 231 250 250 250 253 253 253
50738 -253 253 253 253 253 253 253 253 253 250 250 250
50739 -242 242 242 253 253 253 253 253 253 253 253 253
50740 -253 253 253 253 253 253 253 253 253 253 253 253
50741 -253 253 253 253 253 253 253 253 253 246 246 246
50742 -231 231 231 206 206 206 198 198 198 226 226 226
50743 - 94 94 94 2 2 6 6 6 6 38 38 38
50744 - 30 30 30 2 2 6 2 2 6 2 2 6
50745 - 2 2 6 2 2 6 62 62 62 66 66 66
50746 - 26 26 26 10 10 10 0 0 0 0 0 0
50747 - 0 0 0 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 0 0 0 0 0 0
50751 - 0 0 0 0 0 0 0 0 0 0 0 0
50752 - 0 0 0 0 0 0 0 0 0 0 0 0
50753 - 0 0 0 0 0 0 0 0 0 0 0 0
50754 - 0 0 0 0 0 0 0 0 0 10 10 10
50755 - 30 30 30 74 74 74 50 50 50 2 2 6
50756 - 26 26 26 26 26 26 2 2 6 106 106 106
50757 -238 238 238 253 253 253 253 253 253 253 253 253
50758 -253 253 253 253 253 253 253 253 253 253 253 253
50759 -253 253 253 253 253 253 253 253 253 253 253 253
50760 -253 253 253 253 253 253 253 253 253 253 253 253
50761 -253 253 253 253 253 253 253 253 253 253 253 253
50762 -253 253 253 246 246 246 218 218 218 202 202 202
50763 -210 210 210 14 14 14 2 2 6 2 2 6
50764 - 30 30 30 22 22 22 2 2 6 2 2 6
50765 - 2 2 6 2 2 6 18 18 18 86 86 86
50766 - 42 42 42 14 14 14 0 0 0 0 0 0
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 0 0 0
50771 - 0 0 0 0 0 0 0 0 0 0 0 0
50772 - 0 0 0 0 0 0 0 0 0 0 0 0
50773 - 0 0 0 0 0 0 0 0 0 0 0 0
50774 - 0 0 0 0 0 0 0 0 0 14 14 14
50775 - 42 42 42 90 90 90 22 22 22 2 2 6
50776 - 42 42 42 2 2 6 18 18 18 218 218 218
50777 -253 253 253 253 253 253 253 253 253 253 253 253
50778 -253 253 253 253 253 253 253 253 253 253 253 253
50779 -253 253 253 253 253 253 253 253 253 253 253 253
50780 -253 253 253 253 253 253 253 253 253 253 253 253
50781 -253 253 253 253 253 253 253 253 253 253 253 253
50782 -253 253 253 253 253 253 250 250 250 221 221 221
50783 -218 218 218 101 101 101 2 2 6 14 14 14
50784 - 18 18 18 38 38 38 10 10 10 2 2 6
50785 - 2 2 6 2 2 6 2 2 6 78 78 78
50786 - 58 58 58 22 22 22 6 6 6 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 0 0 0
50791 - 0 0 0 0 0 0 0 0 0 0 0 0
50792 - 0 0 0 0 0 0 0 0 0 0 0 0
50793 - 0 0 0 0 0 0 0 0 0 0 0 0
50794 - 0 0 0 0 0 0 6 6 6 18 18 18
50795 - 54 54 54 82 82 82 2 2 6 26 26 26
50796 - 22 22 22 2 2 6 123 123 123 253 253 253
50797 -253 253 253 253 253 253 253 253 253 253 253 253
50798 -253 253 253 253 253 253 253 253 253 253 253 253
50799 -253 253 253 253 253 253 253 253 253 253 253 253
50800 -253 253 253 253 253 253 253 253 253 253 253 253
50801 -253 253 253 253 253 253 253 253 253 253 253 253
50802 -253 253 253 253 253 253 253 253 253 250 250 250
50803 -238 238 238 198 198 198 6 6 6 38 38 38
50804 - 58 58 58 26 26 26 38 38 38 2 2 6
50805 - 2 2 6 2 2 6 2 2 6 46 46 46
50806 - 78 78 78 30 30 30 10 10 10 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 - 0 0 0 0 0 0 0 0 0 0 0 0
50812 - 0 0 0 0 0 0 0 0 0 0 0 0
50813 - 0 0 0 0 0 0 0 0 0 0 0 0
50814 - 0 0 0 0 0 0 10 10 10 30 30 30
50815 - 74 74 74 58 58 58 2 2 6 42 42 42
50816 - 2 2 6 22 22 22 231 231 231 253 253 253
50817 -253 253 253 253 253 253 253 253 253 253 253 253
50818 -253 253 253 253 253 253 253 253 253 250 250 250
50819 -253 253 253 253 253 253 253 253 253 253 253 253
50820 -253 253 253 253 253 253 253 253 253 253 253 253
50821 -253 253 253 253 253 253 253 253 253 253 253 253
50822 -253 253 253 253 253 253 253 253 253 253 253 253
50823 -253 253 253 246 246 246 46 46 46 38 38 38
50824 - 42 42 42 14 14 14 38 38 38 14 14 14
50825 - 2 2 6 2 2 6 2 2 6 6 6 6
50826 - 86 86 86 46 46 46 14 14 14 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 0 0 0 0 0 0
50832 - 0 0 0 0 0 0 0 0 0 0 0 0
50833 - 0 0 0 0 0 0 0 0 0 0 0 0
50834 - 0 0 0 6 6 6 14 14 14 42 42 42
50835 - 90 90 90 18 18 18 18 18 18 26 26 26
50836 - 2 2 6 116 116 116 253 253 253 253 253 253
50837 -253 253 253 253 253 253 253 253 253 253 253 253
50838 -253 253 253 253 253 253 250 250 250 238 238 238
50839 -253 253 253 253 253 253 253 253 253 253 253 253
50840 -253 253 253 253 253 253 253 253 253 253 253 253
50841 -253 253 253 253 253 253 253 253 253 253 253 253
50842 -253 253 253 253 253 253 253 253 253 253 253 253
50843 -253 253 253 253 253 253 94 94 94 6 6 6
50844 - 2 2 6 2 2 6 10 10 10 34 34 34
50845 - 2 2 6 2 2 6 2 2 6 2 2 6
50846 - 74 74 74 58 58 58 22 22 22 6 6 6
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 0 0 0 0 0 0 0 0 0
50853 - 0 0 0 0 0 0 0 0 0 0 0 0
50854 - 0 0 0 10 10 10 26 26 26 66 66 66
50855 - 82 82 82 2 2 6 38 38 38 6 6 6
50856 - 14 14 14 210 210 210 253 253 253 253 253 253
50857 -253 253 253 253 253 253 253 253 253 253 253 253
50858 -253 253 253 253 253 253 246 246 246 242 242 242
50859 -253 253 253 253 253 253 253 253 253 253 253 253
50860 -253 253 253 253 253 253 253 253 253 253 253 253
50861 -253 253 253 253 253 253 253 253 253 253 253 253
50862 -253 253 253 253 253 253 253 253 253 253 253 253
50863 -253 253 253 253 253 253 144 144 144 2 2 6
50864 - 2 2 6 2 2 6 2 2 6 46 46 46
50865 - 2 2 6 2 2 6 2 2 6 2 2 6
50866 - 42 42 42 74 74 74 30 30 30 10 10 10
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 0 0 0 0 0 0 0 0 0
50874 - 6 6 6 14 14 14 42 42 42 90 90 90
50875 - 26 26 26 6 6 6 42 42 42 2 2 6
50876 - 74 74 74 250 250 250 253 253 253 253 253 253
50877 -253 253 253 253 253 253 253 253 253 253 253 253
50878 -253 253 253 253 253 253 242 242 242 242 242 242
50879 -253 253 253 253 253 253 253 253 253 253 253 253
50880 -253 253 253 253 253 253 253 253 253 253 253 253
50881 -253 253 253 253 253 253 253 253 253 253 253 253
50882 -253 253 253 253 253 253 253 253 253 253 253 253
50883 -253 253 253 253 253 253 182 182 182 2 2 6
50884 - 2 2 6 2 2 6 2 2 6 46 46 46
50885 - 2 2 6 2 2 6 2 2 6 2 2 6
50886 - 10 10 10 86 86 86 38 38 38 10 10 10
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 - 10 10 10 26 26 26 66 66 66 82 82 82
50895 - 2 2 6 22 22 22 18 18 18 2 2 6
50896 -149 149 149 253 253 253 253 253 253 253 253 253
50897 -253 253 253 253 253 253 253 253 253 253 253 253
50898 -253 253 253 253 253 253 234 234 234 242 242 242
50899 -253 253 253 253 253 253 253 253 253 253 253 253
50900 -253 253 253 253 253 253 253 253 253 253 253 253
50901 -253 253 253 253 253 253 253 253 253 253 253 253
50902 -253 253 253 253 253 253 253 253 253 253 253 253
50903 -253 253 253 253 253 253 206 206 206 2 2 6
50904 - 2 2 6 2 2 6 2 2 6 38 38 38
50905 - 2 2 6 2 2 6 2 2 6 2 2 6
50906 - 6 6 6 86 86 86 46 46 46 14 14 14
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 6 6 6
50914 - 18 18 18 46 46 46 86 86 86 18 18 18
50915 - 2 2 6 34 34 34 10 10 10 6 6 6
50916 -210 210 210 253 253 253 253 253 253 253 253 253
50917 -253 253 253 253 253 253 253 253 253 253 253 253
50918 -253 253 253 253 253 253 234 234 234 242 242 242
50919 -253 253 253 253 253 253 253 253 253 253 253 253
50920 -253 253 253 253 253 253 253 253 253 253 253 253
50921 -253 253 253 253 253 253 253 253 253 253 253 253
50922 -253 253 253 253 253 253 253 253 253 253 253 253
50923 -253 253 253 253 253 253 221 221 221 6 6 6
50924 - 2 2 6 2 2 6 6 6 6 30 30 30
50925 - 2 2 6 2 2 6 2 2 6 2 2 6
50926 - 2 2 6 82 82 82 54 54 54 18 18 18
50927 - 6 6 6 0 0 0 0 0 0 0 0 0
50928 - 0 0 0 0 0 0 0 0 0 0 0 0
50929 - 0 0 0 0 0 0 0 0 0 0 0 0
50930 - 0 0 0 0 0 0 0 0 0 0 0 0
50931 - 0 0 0 0 0 0 0 0 0 0 0 0
50932 - 0 0 0 0 0 0 0 0 0 0 0 0
50933 - 0 0 0 0 0 0 0 0 0 10 10 10
50934 - 26 26 26 66 66 66 62 62 62 2 2 6
50935 - 2 2 6 38 38 38 10 10 10 26 26 26
50936 -238 238 238 253 253 253 253 253 253 253 253 253
50937 -253 253 253 253 253 253 253 253 253 253 253 253
50938 -253 253 253 253 253 253 231 231 231 238 238 238
50939 -253 253 253 253 253 253 253 253 253 253 253 253
50940 -253 253 253 253 253 253 253 253 253 253 253 253
50941 -253 253 253 253 253 253 253 253 253 253 253 253
50942 -253 253 253 253 253 253 253 253 253 253 253 253
50943 -253 253 253 253 253 253 231 231 231 6 6 6
50944 - 2 2 6 2 2 6 10 10 10 30 30 30
50945 - 2 2 6 2 2 6 2 2 6 2 2 6
50946 - 2 2 6 66 66 66 58 58 58 22 22 22
50947 - 6 6 6 0 0 0 0 0 0 0 0 0
50948 - 0 0 0 0 0 0 0 0 0 0 0 0
50949 - 0 0 0 0 0 0 0 0 0 0 0 0
50950 - 0 0 0 0 0 0 0 0 0 0 0 0
50951 - 0 0 0 0 0 0 0 0 0 0 0 0
50952 - 0 0 0 0 0 0 0 0 0 0 0 0
50953 - 0 0 0 0 0 0 0 0 0 10 10 10
50954 - 38 38 38 78 78 78 6 6 6 2 2 6
50955 - 2 2 6 46 46 46 14 14 14 42 42 42
50956 -246 246 246 253 253 253 253 253 253 253 253 253
50957 -253 253 253 253 253 253 253 253 253 253 253 253
50958 -253 253 253 253 253 253 231 231 231 242 242 242
50959 -253 253 253 253 253 253 253 253 253 253 253 253
50960 -253 253 253 253 253 253 253 253 253 253 253 253
50961 -253 253 253 253 253 253 253 253 253 253 253 253
50962 -253 253 253 253 253 253 253 253 253 253 253 253
50963 -253 253 253 253 253 253 234 234 234 10 10 10
50964 - 2 2 6 2 2 6 22 22 22 14 14 14
50965 - 2 2 6 2 2 6 2 2 6 2 2 6
50966 - 2 2 6 66 66 66 62 62 62 22 22 22
50967 - 6 6 6 0 0 0 0 0 0 0 0 0
50968 - 0 0 0 0 0 0 0 0 0 0 0 0
50969 - 0 0 0 0 0 0 0 0 0 0 0 0
50970 - 0 0 0 0 0 0 0 0 0 0 0 0
50971 - 0 0 0 0 0 0 0 0 0 0 0 0
50972 - 0 0 0 0 0 0 0 0 0 0 0 0
50973 - 0 0 0 0 0 0 6 6 6 18 18 18
50974 - 50 50 50 74 74 74 2 2 6 2 2 6
50975 - 14 14 14 70 70 70 34 34 34 62 62 62
50976 -250 250 250 253 253 253 253 253 253 253 253 253
50977 -253 253 253 253 253 253 253 253 253 253 253 253
50978 -253 253 253 253 253 253 231 231 231 246 246 246
50979 -253 253 253 253 253 253 253 253 253 253 253 253
50980 -253 253 253 253 253 253 253 253 253 253 253 253
50981 -253 253 253 253 253 253 253 253 253 253 253 253
50982 -253 253 253 253 253 253 253 253 253 253 253 253
50983 -253 253 253 253 253 253 234 234 234 14 14 14
50984 - 2 2 6 2 2 6 30 30 30 2 2 6
50985 - 2 2 6 2 2 6 2 2 6 2 2 6
50986 - 2 2 6 66 66 66 62 62 62 22 22 22
50987 - 6 6 6 0 0 0 0 0 0 0 0 0
50988 - 0 0 0 0 0 0 0 0 0 0 0 0
50989 - 0 0 0 0 0 0 0 0 0 0 0 0
50990 - 0 0 0 0 0 0 0 0 0 0 0 0
50991 - 0 0 0 0 0 0 0 0 0 0 0 0
50992 - 0 0 0 0 0 0 0 0 0 0 0 0
50993 - 0 0 0 0 0 0 6 6 6 18 18 18
50994 - 54 54 54 62 62 62 2 2 6 2 2 6
50995 - 2 2 6 30 30 30 46 46 46 70 70 70
50996 -250 250 250 253 253 253 253 253 253 253 253 253
50997 -253 253 253 253 253 253 253 253 253 253 253 253
50998 -253 253 253 253 253 253 231 231 231 246 246 246
50999 -253 253 253 253 253 253 253 253 253 253 253 253
51000 -253 253 253 253 253 253 253 253 253 253 253 253
51001 -253 253 253 253 253 253 253 253 253 253 253 253
51002 -253 253 253 253 253 253 253 253 253 253 253 253
51003 -253 253 253 253 253 253 226 226 226 10 10 10
51004 - 2 2 6 6 6 6 30 30 30 2 2 6
51005 - 2 2 6 2 2 6 2 2 6 2 2 6
51006 - 2 2 6 66 66 66 58 58 58 22 22 22
51007 - 6 6 6 0 0 0 0 0 0 0 0 0
51008 - 0 0 0 0 0 0 0 0 0 0 0 0
51009 - 0 0 0 0 0 0 0 0 0 0 0 0
51010 - 0 0 0 0 0 0 0 0 0 0 0 0
51011 - 0 0 0 0 0 0 0 0 0 0 0 0
51012 - 0 0 0 0 0 0 0 0 0 0 0 0
51013 - 0 0 0 0 0 0 6 6 6 22 22 22
51014 - 58 58 58 62 62 62 2 2 6 2 2 6
51015 - 2 2 6 2 2 6 30 30 30 78 78 78
51016 -250 250 250 253 253 253 253 253 253 253 253 253
51017 -253 253 253 253 253 253 253 253 253 253 253 253
51018 -253 253 253 253 253 253 231 231 231 246 246 246
51019 -253 253 253 253 253 253 253 253 253 253 253 253
51020 -253 253 253 253 253 253 253 253 253 253 253 253
51021 -253 253 253 253 253 253 253 253 253 253 253 253
51022 -253 253 253 253 253 253 253 253 253 253 253 253
51023 -253 253 253 253 253 253 206 206 206 2 2 6
51024 - 22 22 22 34 34 34 18 14 6 22 22 22
51025 - 26 26 26 18 18 18 6 6 6 2 2 6
51026 - 2 2 6 82 82 82 54 54 54 18 18 18
51027 - 6 6 6 0 0 0 0 0 0 0 0 0
51028 - 0 0 0 0 0 0 0 0 0 0 0 0
51029 - 0 0 0 0 0 0 0 0 0 0 0 0
51030 - 0 0 0 0 0 0 0 0 0 0 0 0
51031 - 0 0 0 0 0 0 0 0 0 0 0 0
51032 - 0 0 0 0 0 0 0 0 0 0 0 0
51033 - 0 0 0 0 0 0 6 6 6 26 26 26
51034 - 62 62 62 106 106 106 74 54 14 185 133 11
51035 -210 162 10 121 92 8 6 6 6 62 62 62
51036 -238 238 238 253 253 253 253 253 253 253 253 253
51037 -253 253 253 253 253 253 253 253 253 253 253 253
51038 -253 253 253 253 253 253 231 231 231 246 246 246
51039 -253 253 253 253 253 253 253 253 253 253 253 253
51040 -253 253 253 253 253 253 253 253 253 253 253 253
51041 -253 253 253 253 253 253 253 253 253 253 253 253
51042 -253 253 253 253 253 253 253 253 253 253 253 253
51043 -253 253 253 253 253 253 158 158 158 18 18 18
51044 - 14 14 14 2 2 6 2 2 6 2 2 6
51045 - 6 6 6 18 18 18 66 66 66 38 38 38
51046 - 6 6 6 94 94 94 50 50 50 18 18 18
51047 - 6 6 6 0 0 0 0 0 0 0 0 0
51048 - 0 0 0 0 0 0 0 0 0 0 0 0
51049 - 0 0 0 0 0 0 0 0 0 0 0 0
51050 - 0 0 0 0 0 0 0 0 0 0 0 0
51051 - 0 0 0 0 0 0 0 0 0 0 0 0
51052 - 0 0 0 0 0 0 0 0 0 6 6 6
51053 - 10 10 10 10 10 10 18 18 18 38 38 38
51054 - 78 78 78 142 134 106 216 158 10 242 186 14
51055 -246 190 14 246 190 14 156 118 10 10 10 10
51056 - 90 90 90 238 238 238 253 253 253 253 253 253
51057 -253 253 253 253 253 253 253 253 253 253 253 253
51058 -253 253 253 253 253 253 231 231 231 250 250 250
51059 -253 253 253 253 253 253 253 253 253 253 253 253
51060 -253 253 253 253 253 253 253 253 253 253 253 253
51061 -253 253 253 253 253 253 253 253 253 253 253 253
51062 -253 253 253 253 253 253 253 253 253 246 230 190
51063 -238 204 91 238 204 91 181 142 44 37 26 9
51064 - 2 2 6 2 2 6 2 2 6 2 2 6
51065 - 2 2 6 2 2 6 38 38 38 46 46 46
51066 - 26 26 26 106 106 106 54 54 54 18 18 18
51067 - 6 6 6 0 0 0 0 0 0 0 0 0
51068 - 0 0 0 0 0 0 0 0 0 0 0 0
51069 - 0 0 0 0 0 0 0 0 0 0 0 0
51070 - 0 0 0 0 0 0 0 0 0 0 0 0
51071 - 0 0 0 0 0 0 0 0 0 0 0 0
51072 - 0 0 0 6 6 6 14 14 14 22 22 22
51073 - 30 30 30 38 38 38 50 50 50 70 70 70
51074 -106 106 106 190 142 34 226 170 11 242 186 14
51075 -246 190 14 246 190 14 246 190 14 154 114 10
51076 - 6 6 6 74 74 74 226 226 226 253 253 253
51077 -253 253 253 253 253 253 253 253 253 253 253 253
51078 -253 253 253 253 253 253 231 231 231 250 250 250
51079 -253 253 253 253 253 253 253 253 253 253 253 253
51080 -253 253 253 253 253 253 253 253 253 253 253 253
51081 -253 253 253 253 253 253 253 253 253 253 253 253
51082 -253 253 253 253 253 253 253 253 253 228 184 62
51083 -241 196 14 241 208 19 232 195 16 38 30 10
51084 - 2 2 6 2 2 6 2 2 6 2 2 6
51085 - 2 2 6 6 6 6 30 30 30 26 26 26
51086 -203 166 17 154 142 90 66 66 66 26 26 26
51087 - 6 6 6 0 0 0 0 0 0 0 0 0
51088 - 0 0 0 0 0 0 0 0 0 0 0 0
51089 - 0 0 0 0 0 0 0 0 0 0 0 0
51090 - 0 0 0 0 0 0 0 0 0 0 0 0
51091 - 0 0 0 0 0 0 0 0 0 0 0 0
51092 - 6 6 6 18 18 18 38 38 38 58 58 58
51093 - 78 78 78 86 86 86 101 101 101 123 123 123
51094 -175 146 61 210 150 10 234 174 13 246 186 14
51095 -246 190 14 246 190 14 246 190 14 238 190 10
51096 -102 78 10 2 2 6 46 46 46 198 198 198
51097 -253 253 253 253 253 253 253 253 253 253 253 253
51098 -253 253 253 253 253 253 234 234 234 242 242 242
51099 -253 253 253 253 253 253 253 253 253 253 253 253
51100 -253 253 253 253 253 253 253 253 253 253 253 253
51101 -253 253 253 253 253 253 253 253 253 253 253 253
51102 -253 253 253 253 253 253 253 253 253 224 178 62
51103 -242 186 14 241 196 14 210 166 10 22 18 6
51104 - 2 2 6 2 2 6 2 2 6 2 2 6
51105 - 2 2 6 2 2 6 6 6 6 121 92 8
51106 -238 202 15 232 195 16 82 82 82 34 34 34
51107 - 10 10 10 0 0 0 0 0 0 0 0 0
51108 - 0 0 0 0 0 0 0 0 0 0 0 0
51109 - 0 0 0 0 0 0 0 0 0 0 0 0
51110 - 0 0 0 0 0 0 0 0 0 0 0 0
51111 - 0 0 0 0 0 0 0 0 0 0 0 0
51112 - 14 14 14 38 38 38 70 70 70 154 122 46
51113 -190 142 34 200 144 11 197 138 11 197 138 11
51114 -213 154 11 226 170 11 242 186 14 246 190 14
51115 -246 190 14 246 190 14 246 190 14 246 190 14
51116 -225 175 15 46 32 6 2 2 6 22 22 22
51117 -158 158 158 250 250 250 253 253 253 253 253 253
51118 -253 253 253 253 253 253 253 253 253 253 253 253
51119 -253 253 253 253 253 253 253 253 253 253 253 253
51120 -253 253 253 253 253 253 253 253 253 253 253 253
51121 -253 253 253 253 253 253 253 253 253 253 253 253
51122 -253 253 253 250 250 250 242 242 242 224 178 62
51123 -239 182 13 236 186 11 213 154 11 46 32 6
51124 - 2 2 6 2 2 6 2 2 6 2 2 6
51125 - 2 2 6 2 2 6 61 42 6 225 175 15
51126 -238 190 10 236 186 11 112 100 78 42 42 42
51127 - 14 14 14 0 0 0 0 0 0 0 0 0
51128 - 0 0 0 0 0 0 0 0 0 0 0 0
51129 - 0 0 0 0 0 0 0 0 0 0 0 0
51130 - 0 0 0 0 0 0 0 0 0 0 0 0
51131 - 0 0 0 0 0 0 0 0 0 6 6 6
51132 - 22 22 22 54 54 54 154 122 46 213 154 11
51133 -226 170 11 230 174 11 226 170 11 226 170 11
51134 -236 178 12 242 186 14 246 190 14 246 190 14
51135 -246 190 14 246 190 14 246 190 14 246 190 14
51136 -241 196 14 184 144 12 10 10 10 2 2 6
51137 - 6 6 6 116 116 116 242 242 242 253 253 253
51138 -253 253 253 253 253 253 253 253 253 253 253 253
51139 -253 253 253 253 253 253 253 253 253 253 253 253
51140 -253 253 253 253 253 253 253 253 253 253 253 253
51141 -253 253 253 253 253 253 253 253 253 253 253 253
51142 -253 253 253 231 231 231 198 198 198 214 170 54
51143 -236 178 12 236 178 12 210 150 10 137 92 6
51144 - 18 14 6 2 2 6 2 2 6 2 2 6
51145 - 6 6 6 70 47 6 200 144 11 236 178 12
51146 -239 182 13 239 182 13 124 112 88 58 58 58
51147 - 22 22 22 6 6 6 0 0 0 0 0 0
51148 - 0 0 0 0 0 0 0 0 0 0 0 0
51149 - 0 0 0 0 0 0 0 0 0 0 0 0
51150 - 0 0 0 0 0 0 0 0 0 0 0 0
51151 - 0 0 0 0 0 0 0 0 0 10 10 10
51152 - 30 30 30 70 70 70 180 133 36 226 170 11
51153 -239 182 13 242 186 14 242 186 14 246 186 14
51154 -246 190 14 246 190 14 246 190 14 246 190 14
51155 -246 190 14 246 190 14 246 190 14 246 190 14
51156 -246 190 14 232 195 16 98 70 6 2 2 6
51157 - 2 2 6 2 2 6 66 66 66 221 221 221
51158 -253 253 253 253 253 253 253 253 253 253 253 253
51159 -253 253 253 253 253 253 253 253 253 253 253 253
51160 -253 253 253 253 253 253 253 253 253 253 253 253
51161 -253 253 253 253 253 253 253 253 253 253 253 253
51162 -253 253 253 206 206 206 198 198 198 214 166 58
51163 -230 174 11 230 174 11 216 158 10 192 133 9
51164 -163 110 8 116 81 8 102 78 10 116 81 8
51165 -167 114 7 197 138 11 226 170 11 239 182 13
51166 -242 186 14 242 186 14 162 146 94 78 78 78
51167 - 34 34 34 14 14 14 6 6 6 0 0 0
51168 - 0 0 0 0 0 0 0 0 0 0 0 0
51169 - 0 0 0 0 0 0 0 0 0 0 0 0
51170 - 0 0 0 0 0 0 0 0 0 0 0 0
51171 - 0 0 0 0 0 0 0 0 0 6 6 6
51172 - 30 30 30 78 78 78 190 142 34 226 170 11
51173 -239 182 13 246 190 14 246 190 14 246 190 14
51174 -246 190 14 246 190 14 246 190 14 246 190 14
51175 -246 190 14 246 190 14 246 190 14 246 190 14
51176 -246 190 14 241 196 14 203 166 17 22 18 6
51177 - 2 2 6 2 2 6 2 2 6 38 38 38
51178 -218 218 218 253 253 253 253 253 253 253 253 253
51179 -253 253 253 253 253 253 253 253 253 253 253 253
51180 -253 253 253 253 253 253 253 253 253 253 253 253
51181 -253 253 253 253 253 253 253 253 253 253 253 253
51182 -250 250 250 206 206 206 198 198 198 202 162 69
51183 -226 170 11 236 178 12 224 166 10 210 150 10
51184 -200 144 11 197 138 11 192 133 9 197 138 11
51185 -210 150 10 226 170 11 242 186 14 246 190 14
51186 -246 190 14 246 186 14 225 175 15 124 112 88
51187 - 62 62 62 30 30 30 14 14 14 6 6 6
51188 - 0 0 0 0 0 0 0 0 0 0 0 0
51189 - 0 0 0 0 0 0 0 0 0 0 0 0
51190 - 0 0 0 0 0 0 0 0 0 0 0 0
51191 - 0 0 0 0 0 0 0 0 0 10 10 10
51192 - 30 30 30 78 78 78 174 135 50 224 166 10
51193 -239 182 13 246 190 14 246 190 14 246 190 14
51194 -246 190 14 246 190 14 246 190 14 246 190 14
51195 -246 190 14 246 190 14 246 190 14 246 190 14
51196 -246 190 14 246 190 14 241 196 14 139 102 15
51197 - 2 2 6 2 2 6 2 2 6 2 2 6
51198 - 78 78 78 250 250 250 253 253 253 253 253 253
51199 -253 253 253 253 253 253 253 253 253 253 253 253
51200 -253 253 253 253 253 253 253 253 253 253 253 253
51201 -253 253 253 253 253 253 253 253 253 253 253 253
51202 -250 250 250 214 214 214 198 198 198 190 150 46
51203 -219 162 10 236 178 12 234 174 13 224 166 10
51204 -216 158 10 213 154 11 213 154 11 216 158 10
51205 -226 170 11 239 182 13 246 190 14 246 190 14
51206 -246 190 14 246 190 14 242 186 14 206 162 42
51207 -101 101 101 58 58 58 30 30 30 14 14 14
51208 - 6 6 6 0 0 0 0 0 0 0 0 0
51209 - 0 0 0 0 0 0 0 0 0 0 0 0
51210 - 0 0 0 0 0 0 0 0 0 0 0 0
51211 - 0 0 0 0 0 0 0 0 0 10 10 10
51212 - 30 30 30 74 74 74 174 135 50 216 158 10
51213 -236 178 12 246 190 14 246 190 14 246 190 14
51214 -246 190 14 246 190 14 246 190 14 246 190 14
51215 -246 190 14 246 190 14 246 190 14 246 190 14
51216 -246 190 14 246 190 14 241 196 14 226 184 13
51217 - 61 42 6 2 2 6 2 2 6 2 2 6
51218 - 22 22 22 238 238 238 253 253 253 253 253 253
51219 -253 253 253 253 253 253 253 253 253 253 253 253
51220 -253 253 253 253 253 253 253 253 253 253 253 253
51221 -253 253 253 253 253 253 253 253 253 253 253 253
51222 -253 253 253 226 226 226 187 187 187 180 133 36
51223 -216 158 10 236 178 12 239 182 13 236 178 12
51224 -230 174 11 226 170 11 226 170 11 230 174 11
51225 -236 178 12 242 186 14 246 190 14 246 190 14
51226 -246 190 14 246 190 14 246 186 14 239 182 13
51227 -206 162 42 106 106 106 66 66 66 34 34 34
51228 - 14 14 14 6 6 6 0 0 0 0 0 0
51229 - 0 0 0 0 0 0 0 0 0 0 0 0
51230 - 0 0 0 0 0 0 0 0 0 0 0 0
51231 - 0 0 0 0 0 0 0 0 0 6 6 6
51232 - 26 26 26 70 70 70 163 133 67 213 154 11
51233 -236 178 12 246 190 14 246 190 14 246 190 14
51234 -246 190 14 246 190 14 246 190 14 246 190 14
51235 -246 190 14 246 190 14 246 190 14 246 190 14
51236 -246 190 14 246 190 14 246 190 14 241 196 14
51237 -190 146 13 18 14 6 2 2 6 2 2 6
51238 - 46 46 46 246 246 246 253 253 253 253 253 253
51239 -253 253 253 253 253 253 253 253 253 253 253 253
51240 -253 253 253 253 253 253 253 253 253 253 253 253
51241 -253 253 253 253 253 253 253 253 253 253 253 253
51242 -253 253 253 221 221 221 86 86 86 156 107 11
51243 -216 158 10 236 178 12 242 186 14 246 186 14
51244 -242 186 14 239 182 13 239 182 13 242 186 14
51245 -242 186 14 246 186 14 246 190 14 246 190 14
51246 -246 190 14 246 190 14 246 190 14 246 190 14
51247 -242 186 14 225 175 15 142 122 72 66 66 66
51248 - 30 30 30 10 10 10 0 0 0 0 0 0
51249 - 0 0 0 0 0 0 0 0 0 0 0 0
51250 - 0 0 0 0 0 0 0 0 0 0 0 0
51251 - 0 0 0 0 0 0 0 0 0 6 6 6
51252 - 26 26 26 70 70 70 163 133 67 210 150 10
51253 -236 178 12 246 190 14 246 190 14 246 190 14
51254 -246 190 14 246 190 14 246 190 14 246 190 14
51255 -246 190 14 246 190 14 246 190 14 246 190 14
51256 -246 190 14 246 190 14 246 190 14 246 190 14
51257 -232 195 16 121 92 8 34 34 34 106 106 106
51258 -221 221 221 253 253 253 253 253 253 253 253 253
51259 -253 253 253 253 253 253 253 253 253 253 253 253
51260 -253 253 253 253 253 253 253 253 253 253 253 253
51261 -253 253 253 253 253 253 253 253 253 253 253 253
51262 -242 242 242 82 82 82 18 14 6 163 110 8
51263 -216 158 10 236 178 12 242 186 14 246 190 14
51264 -246 190 14 246 190 14 246 190 14 246 190 14
51265 -246 190 14 246 190 14 246 190 14 246 190 14
51266 -246 190 14 246 190 14 246 190 14 246 190 14
51267 -246 190 14 246 190 14 242 186 14 163 133 67
51268 - 46 46 46 18 18 18 6 6 6 0 0 0
51269 - 0 0 0 0 0 0 0 0 0 0 0 0
51270 - 0 0 0 0 0 0 0 0 0 0 0 0
51271 - 0 0 0 0 0 0 0 0 0 10 10 10
51272 - 30 30 30 78 78 78 163 133 67 210 150 10
51273 -236 178 12 246 186 14 246 190 14 246 190 14
51274 -246 190 14 246 190 14 246 190 14 246 190 14
51275 -246 190 14 246 190 14 246 190 14 246 190 14
51276 -246 190 14 246 190 14 246 190 14 246 190 14
51277 -241 196 14 215 174 15 190 178 144 253 253 253
51278 -253 253 253 253 253 253 253 253 253 253 253 253
51279 -253 253 253 253 253 253 253 253 253 253 253 253
51280 -253 253 253 253 253 253 253 253 253 253 253 253
51281 -253 253 253 253 253 253 253 253 253 218 218 218
51282 - 58 58 58 2 2 6 22 18 6 167 114 7
51283 -216 158 10 236 178 12 246 186 14 246 190 14
51284 -246 190 14 246 190 14 246 190 14 246 190 14
51285 -246 190 14 246 190 14 246 190 14 246 190 14
51286 -246 190 14 246 190 14 246 190 14 246 190 14
51287 -246 190 14 246 186 14 242 186 14 190 150 46
51288 - 54 54 54 22 22 22 6 6 6 0 0 0
51289 - 0 0 0 0 0 0 0 0 0 0 0 0
51290 - 0 0 0 0 0 0 0 0 0 0 0 0
51291 - 0 0 0 0 0 0 0 0 0 14 14 14
51292 - 38 38 38 86 86 86 180 133 36 213 154 11
51293 -236 178 12 246 186 14 246 190 14 246 190 14
51294 -246 190 14 246 190 14 246 190 14 246 190 14
51295 -246 190 14 246 190 14 246 190 14 246 190 14
51296 -246 190 14 246 190 14 246 190 14 246 190 14
51297 -246 190 14 232 195 16 190 146 13 214 214 214
51298 -253 253 253 253 253 253 253 253 253 253 253 253
51299 -253 253 253 253 253 253 253 253 253 253 253 253
51300 -253 253 253 253 253 253 253 253 253 253 253 253
51301 -253 253 253 250 250 250 170 170 170 26 26 26
51302 - 2 2 6 2 2 6 37 26 9 163 110 8
51303 -219 162 10 239 182 13 246 186 14 246 190 14
51304 -246 190 14 246 190 14 246 190 14 246 190 14
51305 -246 190 14 246 190 14 246 190 14 246 190 14
51306 -246 190 14 246 190 14 246 190 14 246 190 14
51307 -246 186 14 236 178 12 224 166 10 142 122 72
51308 - 46 46 46 18 18 18 6 6 6 0 0 0
51309 - 0 0 0 0 0 0 0 0 0 0 0 0
51310 - 0 0 0 0 0 0 0 0 0 0 0 0
51311 - 0 0 0 0 0 0 6 6 6 18 18 18
51312 - 50 50 50 109 106 95 192 133 9 224 166 10
51313 -242 186 14 246 190 14 246 190 14 246 190 14
51314 -246 190 14 246 190 14 246 190 14 246 190 14
51315 -246 190 14 246 190 14 246 190 14 246 190 14
51316 -246 190 14 246 190 14 246 190 14 246 190 14
51317 -242 186 14 226 184 13 210 162 10 142 110 46
51318 -226 226 226 253 253 253 253 253 253 253 253 253
51319 -253 253 253 253 253 253 253 253 253 253 253 253
51320 -253 253 253 253 253 253 253 253 253 253 253 253
51321 -198 198 198 66 66 66 2 2 6 2 2 6
51322 - 2 2 6 2 2 6 50 34 6 156 107 11
51323 -219 162 10 239 182 13 246 186 14 246 190 14
51324 -246 190 14 246 190 14 246 190 14 246 190 14
51325 -246 190 14 246 190 14 246 190 14 246 190 14
51326 -246 190 14 246 190 14 246 190 14 242 186 14
51327 -234 174 13 213 154 11 154 122 46 66 66 66
51328 - 30 30 30 10 10 10 0 0 0 0 0 0
51329 - 0 0 0 0 0 0 0 0 0 0 0 0
51330 - 0 0 0 0 0 0 0 0 0 0 0 0
51331 - 0 0 0 0 0 0 6 6 6 22 22 22
51332 - 58 58 58 154 121 60 206 145 10 234 174 13
51333 -242 186 14 246 186 14 246 190 14 246 190 14
51334 -246 190 14 246 190 14 246 190 14 246 190 14
51335 -246 190 14 246 190 14 246 190 14 246 190 14
51336 -246 190 14 246 190 14 246 190 14 246 190 14
51337 -246 186 14 236 178 12 210 162 10 163 110 8
51338 - 61 42 6 138 138 138 218 218 218 250 250 250
51339 -253 253 253 253 253 253 253 253 253 250 250 250
51340 -242 242 242 210 210 210 144 144 144 66 66 66
51341 - 6 6 6 2 2 6 2 2 6 2 2 6
51342 - 2 2 6 2 2 6 61 42 6 163 110 8
51343 -216 158 10 236 178 12 246 190 14 246 190 14
51344 -246 190 14 246 190 14 246 190 14 246 190 14
51345 -246 190 14 246 190 14 246 190 14 246 190 14
51346 -246 190 14 239 182 13 230 174 11 216 158 10
51347 -190 142 34 124 112 88 70 70 70 38 38 38
51348 - 18 18 18 6 6 6 0 0 0 0 0 0
51349 - 0 0 0 0 0 0 0 0 0 0 0 0
51350 - 0 0 0 0 0 0 0 0 0 0 0 0
51351 - 0 0 0 0 0 0 6 6 6 22 22 22
51352 - 62 62 62 168 124 44 206 145 10 224 166 10
51353 -236 178 12 239 182 13 242 186 14 242 186 14
51354 -246 186 14 246 190 14 246 190 14 246 190 14
51355 -246 190 14 246 190 14 246 190 14 246 190 14
51356 -246 190 14 246 190 14 246 190 14 246 190 14
51357 -246 190 14 236 178 12 216 158 10 175 118 6
51358 - 80 54 7 2 2 6 6 6 6 30 30 30
51359 - 54 54 54 62 62 62 50 50 50 38 38 38
51360 - 14 14 14 2 2 6 2 2 6 2 2 6
51361 - 2 2 6 2 2 6 2 2 6 2 2 6
51362 - 2 2 6 6 6 6 80 54 7 167 114 7
51363 -213 154 11 236 178 12 246 190 14 246 190 14
51364 -246 190 14 246 190 14 246 190 14 246 190 14
51365 -246 190 14 242 186 14 239 182 13 239 182 13
51366 -230 174 11 210 150 10 174 135 50 124 112 88
51367 - 82 82 82 54 54 54 34 34 34 18 18 18
51368 - 6 6 6 0 0 0 0 0 0 0 0 0
51369 - 0 0 0 0 0 0 0 0 0 0 0 0
51370 - 0 0 0 0 0 0 0 0 0 0 0 0
51371 - 0 0 0 0 0 0 6 6 6 18 18 18
51372 - 50 50 50 158 118 36 192 133 9 200 144 11
51373 -216 158 10 219 162 10 224 166 10 226 170 11
51374 -230 174 11 236 178 12 239 182 13 239 182 13
51375 -242 186 14 246 186 14 246 190 14 246 190 14
51376 -246 190 14 246 190 14 246 190 14 246 190 14
51377 -246 186 14 230 174 11 210 150 10 163 110 8
51378 -104 69 6 10 10 10 2 2 6 2 2 6
51379 - 2 2 6 2 2 6 2 2 6 2 2 6
51380 - 2 2 6 2 2 6 2 2 6 2 2 6
51381 - 2 2 6 2 2 6 2 2 6 2 2 6
51382 - 2 2 6 6 6 6 91 60 6 167 114 7
51383 -206 145 10 230 174 11 242 186 14 246 190 14
51384 -246 190 14 246 190 14 246 186 14 242 186 14
51385 -239 182 13 230 174 11 224 166 10 213 154 11
51386 -180 133 36 124 112 88 86 86 86 58 58 58
51387 - 38 38 38 22 22 22 10 10 10 6 6 6
51388 - 0 0 0 0 0 0 0 0 0 0 0 0
51389 - 0 0 0 0 0 0 0 0 0 0 0 0
51390 - 0 0 0 0 0 0 0 0 0 0 0 0
51391 - 0 0 0 0 0 0 0 0 0 14 14 14
51392 - 34 34 34 70 70 70 138 110 50 158 118 36
51393 -167 114 7 180 123 7 192 133 9 197 138 11
51394 -200 144 11 206 145 10 213 154 11 219 162 10
51395 -224 166 10 230 174 11 239 182 13 242 186 14
51396 -246 186 14 246 186 14 246 186 14 246 186 14
51397 -239 182 13 216 158 10 185 133 11 152 99 6
51398 -104 69 6 18 14 6 2 2 6 2 2 6
51399 - 2 2 6 2 2 6 2 2 6 2 2 6
51400 - 2 2 6 2 2 6 2 2 6 2 2 6
51401 - 2 2 6 2 2 6 2 2 6 2 2 6
51402 - 2 2 6 6 6 6 80 54 7 152 99 6
51403 -192 133 9 219 162 10 236 178 12 239 182 13
51404 -246 186 14 242 186 14 239 182 13 236 178 12
51405 -224 166 10 206 145 10 192 133 9 154 121 60
51406 - 94 94 94 62 62 62 42 42 42 22 22 22
51407 - 14 14 14 6 6 6 0 0 0 0 0 0
51408 - 0 0 0 0 0 0 0 0 0 0 0 0
51409 - 0 0 0 0 0 0 0 0 0 0 0 0
51410 - 0 0 0 0 0 0 0 0 0 0 0 0
51411 - 0 0 0 0 0 0 0 0 0 6 6 6
51412 - 18 18 18 34 34 34 58 58 58 78 78 78
51413 -101 98 89 124 112 88 142 110 46 156 107 11
51414 -163 110 8 167 114 7 175 118 6 180 123 7
51415 -185 133 11 197 138 11 210 150 10 219 162 10
51416 -226 170 11 236 178 12 236 178 12 234 174 13
51417 -219 162 10 197 138 11 163 110 8 130 83 6
51418 - 91 60 6 10 10 10 2 2 6 2 2 6
51419 - 18 18 18 38 38 38 38 38 38 38 38 38
51420 - 38 38 38 38 38 38 38 38 38 38 38 38
51421 - 38 38 38 38 38 38 26 26 26 2 2 6
51422 - 2 2 6 6 6 6 70 47 6 137 92 6
51423 -175 118 6 200 144 11 219 162 10 230 174 11
51424 -234 174 13 230 174 11 219 162 10 210 150 10
51425 -192 133 9 163 110 8 124 112 88 82 82 82
51426 - 50 50 50 30 30 30 14 14 14 6 6 6
51427 - 0 0 0 0 0 0 0 0 0 0 0 0
51428 - 0 0 0 0 0 0 0 0 0 0 0 0
51429 - 0 0 0 0 0 0 0 0 0 0 0 0
51430 - 0 0 0 0 0 0 0 0 0 0 0 0
51431 - 0 0 0 0 0 0 0 0 0 0 0 0
51432 - 6 6 6 14 14 14 22 22 22 34 34 34
51433 - 42 42 42 58 58 58 74 74 74 86 86 86
51434 -101 98 89 122 102 70 130 98 46 121 87 25
51435 -137 92 6 152 99 6 163 110 8 180 123 7
51436 -185 133 11 197 138 11 206 145 10 200 144 11
51437 -180 123 7 156 107 11 130 83 6 104 69 6
51438 - 50 34 6 54 54 54 110 110 110 101 98 89
51439 - 86 86 86 82 82 82 78 78 78 78 78 78
51440 - 78 78 78 78 78 78 78 78 78 78 78 78
51441 - 78 78 78 82 82 82 86 86 86 94 94 94
51442 -106 106 106 101 101 101 86 66 34 124 80 6
51443 -156 107 11 180 123 7 192 133 9 200 144 11
51444 -206 145 10 200 144 11 192 133 9 175 118 6
51445 -139 102 15 109 106 95 70 70 70 42 42 42
51446 - 22 22 22 10 10 10 0 0 0 0 0 0
51447 - 0 0 0 0 0 0 0 0 0 0 0 0
51448 - 0 0 0 0 0 0 0 0 0 0 0 0
51449 - 0 0 0 0 0 0 0 0 0 0 0 0
51450 - 0 0 0 0 0 0 0 0 0 0 0 0
51451 - 0 0 0 0 0 0 0 0 0 0 0 0
51452 - 0 0 0 0 0 0 6 6 6 10 10 10
51453 - 14 14 14 22 22 22 30 30 30 38 38 38
51454 - 50 50 50 62 62 62 74 74 74 90 90 90
51455 -101 98 89 112 100 78 121 87 25 124 80 6
51456 -137 92 6 152 99 6 152 99 6 152 99 6
51457 -138 86 6 124 80 6 98 70 6 86 66 30
51458 -101 98 89 82 82 82 58 58 58 46 46 46
51459 - 38 38 38 34 34 34 34 34 34 34 34 34
51460 - 34 34 34 34 34 34 34 34 34 34 34 34
51461 - 34 34 34 34 34 34 38 38 38 42 42 42
51462 - 54 54 54 82 82 82 94 86 76 91 60 6
51463 -134 86 6 156 107 11 167 114 7 175 118 6
51464 -175 118 6 167 114 7 152 99 6 121 87 25
51465 -101 98 89 62 62 62 34 34 34 18 18 18
51466 - 6 6 6 0 0 0 0 0 0 0 0 0
51467 - 0 0 0 0 0 0 0 0 0 0 0 0
51468 - 0 0 0 0 0 0 0 0 0 0 0 0
51469 - 0 0 0 0 0 0 0 0 0 0 0 0
51470 - 0 0 0 0 0 0 0 0 0 0 0 0
51471 - 0 0 0 0 0 0 0 0 0 0 0 0
51472 - 0 0 0 0 0 0 0 0 0 0 0 0
51473 - 0 0 0 6 6 6 6 6 6 10 10 10
51474 - 18 18 18 22 22 22 30 30 30 42 42 42
51475 - 50 50 50 66 66 66 86 86 86 101 98 89
51476 -106 86 58 98 70 6 104 69 6 104 69 6
51477 -104 69 6 91 60 6 82 62 34 90 90 90
51478 - 62 62 62 38 38 38 22 22 22 14 14 14
51479 - 10 10 10 10 10 10 10 10 10 10 10 10
51480 - 10 10 10 10 10 10 6 6 6 10 10 10
51481 - 10 10 10 10 10 10 10 10 10 14 14 14
51482 - 22 22 22 42 42 42 70 70 70 89 81 66
51483 - 80 54 7 104 69 6 124 80 6 137 92 6
51484 -134 86 6 116 81 8 100 82 52 86 86 86
51485 - 58 58 58 30 30 30 14 14 14 6 6 6
51486 - 0 0 0 0 0 0 0 0 0 0 0 0
51487 - 0 0 0 0 0 0 0 0 0 0 0 0
51488 - 0 0 0 0 0 0 0 0 0 0 0 0
51489 - 0 0 0 0 0 0 0 0 0 0 0 0
51490 - 0 0 0 0 0 0 0 0 0 0 0 0
51491 - 0 0 0 0 0 0 0 0 0 0 0 0
51492 - 0 0 0 0 0 0 0 0 0 0 0 0
51493 - 0 0 0 0 0 0 0 0 0 0 0 0
51494 - 0 0 0 6 6 6 10 10 10 14 14 14
51495 - 18 18 18 26 26 26 38 38 38 54 54 54
51496 - 70 70 70 86 86 86 94 86 76 89 81 66
51497 - 89 81 66 86 86 86 74 74 74 50 50 50
51498 - 30 30 30 14 14 14 6 6 6 0 0 0
51499 - 0 0 0 0 0 0 0 0 0 0 0 0
51500 - 0 0 0 0 0 0 0 0 0 0 0 0
51501 - 0 0 0 0 0 0 0 0 0 0 0 0
51502 - 6 6 6 18 18 18 34 34 34 58 58 58
51503 - 82 82 82 89 81 66 89 81 66 89 81 66
51504 - 94 86 66 94 86 76 74 74 74 50 50 50
51505 - 26 26 26 14 14 14 6 6 6 0 0 0
51506 - 0 0 0 0 0 0 0 0 0 0 0 0
51507 - 0 0 0 0 0 0 0 0 0 0 0 0
51508 - 0 0 0 0 0 0 0 0 0 0 0 0
51509 - 0 0 0 0 0 0 0 0 0 0 0 0
51510 - 0 0 0 0 0 0 0 0 0 0 0 0
51511 - 0 0 0 0 0 0 0 0 0 0 0 0
51512 - 0 0 0 0 0 0 0 0 0 0 0 0
51513 - 0 0 0 0 0 0 0 0 0 0 0 0
51514 - 0 0 0 0 0 0 0 0 0 0 0 0
51515 - 6 6 6 6 6 6 14 14 14 18 18 18
51516 - 30 30 30 38 38 38 46 46 46 54 54 54
51517 - 50 50 50 42 42 42 30 30 30 18 18 18
51518 - 10 10 10 0 0 0 0 0 0 0 0 0
51519 - 0 0 0 0 0 0 0 0 0 0 0 0
51520 - 0 0 0 0 0 0 0 0 0 0 0 0
51521 - 0 0 0 0 0 0 0 0 0 0 0 0
51522 - 0 0 0 6 6 6 14 14 14 26 26 26
51523 - 38 38 38 50 50 50 58 58 58 58 58 58
51524 - 54 54 54 42 42 42 30 30 30 18 18 18
51525 - 10 10 10 0 0 0 0 0 0 0 0 0
51526 - 0 0 0 0 0 0 0 0 0 0 0 0
51527 - 0 0 0 0 0 0 0 0 0 0 0 0
51528 - 0 0 0 0 0 0 0 0 0 0 0 0
51529 - 0 0 0 0 0 0 0 0 0 0 0 0
51530 - 0 0 0 0 0 0 0 0 0 0 0 0
51531 - 0 0 0 0 0 0 0 0 0 0 0 0
51532 - 0 0 0 0 0 0 0 0 0 0 0 0
51533 - 0 0 0 0 0 0 0 0 0 0 0 0
51534 - 0 0 0 0 0 0 0 0 0 0 0 0
51535 - 0 0 0 0 0 0 0 0 0 6 6 6
51536 - 6 6 6 10 10 10 14 14 14 18 18 18
51537 - 18 18 18 14 14 14 10 10 10 6 6 6
51538 - 0 0 0 0 0 0 0 0 0 0 0 0
51539 - 0 0 0 0 0 0 0 0 0 0 0 0
51540 - 0 0 0 0 0 0 0 0 0 0 0 0
51541 - 0 0 0 0 0 0 0 0 0 0 0 0
51542 - 0 0 0 0 0 0 0 0 0 6 6 6
51543 - 14 14 14 18 18 18 22 22 22 22 22 22
51544 - 18 18 18 14 14 14 10 10 10 6 6 6
51545 - 0 0 0 0 0 0 0 0 0 0 0 0
51546 - 0 0 0 0 0 0 0 0 0 0 0 0
51547 - 0 0 0 0 0 0 0 0 0 0 0 0
51548 - 0 0 0 0 0 0 0 0 0 0 0 0
51549 - 0 0 0 0 0 0 0 0 0 0 0 0
51550 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51551 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51552 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51553 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51554 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51555 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51556 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51557 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51558 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51559 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51560 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51561 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51562 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51563 +4 4 4 4 4 4
51564 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51565 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51566 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51567 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51568 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51569 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51570 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51571 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51572 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51573 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51574 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51575 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51576 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51577 +4 4 4 4 4 4
51578 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51579 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51580 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51581 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51582 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51583 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51584 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51585 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51586 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51587 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51588 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51589 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51590 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51591 +4 4 4 4 4 4
51592 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51593 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51594 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51595 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51596 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51597 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51598 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51599 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51600 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51601 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51602 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51603 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51604 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51605 +4 4 4 4 4 4
51606 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51607 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51608 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51609 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51610 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51611 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51612 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51613 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51614 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51615 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51616 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51617 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51618 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51619 +4 4 4 4 4 4
51620 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51621 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51622 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51623 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51624 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51625 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51626 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51627 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51628 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51629 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51630 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51631 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51632 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51633 +4 4 4 4 4 4
51634 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51635 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51636 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51637 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51638 +4 4 4 4 4 4 4 4 4 3 3 3 0 0 0 0 0 0
51639 +0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 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 4 4 4 4 4 4 4 4 4 4 4 4
51643 +4 4 4 4 4 4 4 4 4 4 4 4 1 1 1 0 0 0
51644 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
51645 +4 4 4 4 4 4 4 4 4 2 1 0 2 1 0 3 2 2
51646 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51647 +4 4 4 4 4 4
51648 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51649 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51650 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51651 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51652 +4 4 4 4 4 4 2 2 2 0 0 0 3 4 3 26 28 28
51653 +37 38 37 37 38 37 14 17 19 2 2 2 0 0 0 2 2 2
51654 +5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4
51657 +4 4 4 4 4 4 3 3 3 0 0 0 1 1 1 6 6 6
51658 +2 2 2 0 0 0 3 3 3 4 4 4 4 4 4 4 4 4
51659 +4 4 5 3 3 3 1 0 0 0 0 0 1 0 0 0 0 0
51660 +1 1 1 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51661 +4 4 4 4 4 4
51662 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51663 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51664 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51665 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51666 +2 2 2 0 0 0 0 0 0 14 17 19 60 74 84 137 136 137
51667 +153 152 153 137 136 137 125 124 125 60 73 81 6 6 6 3 1 0
51668 +0 0 0 3 3 3 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 4 4 4 4 4 4 4 4 4 4 4 4
51671 +4 4 4 4 4 4 0 0 0 4 4 4 41 54 63 125 124 125
51672 +60 73 81 6 6 6 4 0 0 3 3 3 4 4 4 4 4 4
51673 +4 4 4 0 0 0 6 9 11 41 54 63 41 65 82 22 30 35
51674 +2 2 2 2 1 0 4 4 4 4 4 4 4 4 4 4 4 4
51675 +4 4 4 4 4 4
51676 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51677 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51678 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51679 +4 4 4 4 4 4 5 5 5 5 5 5 2 2 2 0 0 0
51680 +4 0 0 6 6 6 41 54 63 137 136 137 174 174 174 167 166 167
51681 +165 164 165 165 164 165 163 162 163 163 162 163 125 124 125 41 54 63
51682 +1 1 1 0 0 0 0 0 0 3 3 3 5 5 5 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 4 4 4 4 4 4 5 5 5 5 5 5
51685 +3 3 3 2 0 0 4 0 0 60 73 81 156 155 156 167 166 167
51686 +163 162 163 85 115 134 5 7 8 0 0 0 4 4 4 5 5 5
51687 +0 0 0 2 5 5 55 98 126 90 154 193 90 154 193 72 125 159
51688 +37 51 59 2 0 0 1 1 1 4 5 5 4 4 4 4 4 4
51689 +4 4 4 4 4 4
51690 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51691 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51692 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51693 +4 4 4 5 5 5 4 4 4 1 1 1 0 0 0 3 3 3
51694 +37 38 37 125 124 125 163 162 163 174 174 174 158 157 158 158 157 158
51695 +156 155 156 156 155 156 158 157 158 165 164 165 174 174 174 166 165 166
51696 +125 124 125 16 19 21 1 0 0 0 0 0 0 0 0 4 4 4
51697 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
51698 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 1 1 1
51699 +0 0 0 0 0 0 37 38 37 153 152 153 174 174 174 158 157 158
51700 +174 174 174 163 162 163 37 38 37 4 3 3 4 0 0 1 1 1
51701 +0 0 0 22 40 52 101 161 196 101 161 196 90 154 193 101 161 196
51702 +64 123 161 14 17 19 0 0 0 4 4 4 4 4 4 4 4 4
51703 +4 4 4 4 4 4
51704 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51705 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51706 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
51707 +5 5 5 2 2 2 0 0 0 4 0 0 24 26 27 85 115 134
51708 +156 155 156 174 174 174 167 166 167 156 155 156 154 153 154 157 156 157
51709 +156 155 156 156 155 156 155 154 155 153 152 153 158 157 158 167 166 167
51710 +174 174 174 156 155 156 60 74 84 16 19 21 0 0 0 0 0 0
51711 +1 1 1 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
51712 +4 4 4 5 5 5 6 6 6 3 3 3 0 0 0 4 0 0
51713 +13 16 17 60 73 81 137 136 137 165 164 165 156 155 156 153 152 153
51714 +174 174 174 177 184 187 60 73 81 3 1 0 0 0 0 1 1 2
51715 +22 30 35 64 123 161 136 185 209 90 154 193 90 154 193 90 154 193
51716 +90 154 193 21 29 34 0 0 0 3 2 2 4 4 5 4 4 4
51717 +4 4 4 4 4 4
51718 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51719 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51720 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 3 3 3
51721 +0 0 0 0 0 0 10 13 16 60 74 84 157 156 157 174 174 174
51722 +174 174 174 158 157 158 153 152 153 154 153 154 156 155 156 155 154 155
51723 +156 155 156 155 154 155 154 153 154 157 156 157 154 153 154 153 152 153
51724 +163 162 163 174 174 174 177 184 187 137 136 137 60 73 81 13 16 17
51725 +4 0 0 0 0 0 3 3 3 5 5 5 4 4 4 4 4 4
51726 +5 5 5 4 4 4 1 1 1 0 0 0 3 3 3 41 54 63
51727 +131 129 131 174 174 174 174 174 174 174 174 174 167 166 167 174 174 174
51728 +190 197 201 137 136 137 24 26 27 4 0 0 16 21 25 50 82 103
51729 +90 154 193 136 185 209 90 154 193 101 161 196 101 161 196 101 161 196
51730 +31 91 132 3 6 7 0 0 0 4 4 4 4 4 4 4 4 4
51731 +4 4 4 4 4 4
51732 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51733 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51734 +4 4 4 4 4 4 4 4 4 2 2 2 0 0 0 4 0 0
51735 +4 0 0 43 57 68 137 136 137 177 184 187 174 174 174 163 162 163
51736 +155 154 155 155 154 155 156 155 156 155 154 155 158 157 158 165 164 165
51737 +167 166 167 166 165 166 163 162 163 157 156 157 155 154 155 155 154 155
51738 +153 152 153 156 155 156 167 166 167 174 174 174 174 174 174 131 129 131
51739 +41 54 63 5 5 5 0 0 0 0 0 0 3 3 3 4 4 4
51740 +1 1 1 0 0 0 1 0 0 26 28 28 125 124 125 174 174 174
51741 +177 184 187 174 174 174 174 174 174 156 155 156 131 129 131 137 136 137
51742 +125 124 125 24 26 27 4 0 0 41 65 82 90 154 193 136 185 209
51743 +136 185 209 101 161 196 53 118 160 37 112 160 90 154 193 34 86 122
51744 +7 12 15 0 0 0 4 4 4 4 4 4 4 4 4 4 4 4
51745 +4 4 4 4 4 4
51746 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51747 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51748 +4 4 4 3 3 3 0 0 0 0 0 0 5 5 5 37 38 37
51749 +125 124 125 167 166 167 174 174 174 167 166 167 158 157 158 155 154 155
51750 +156 155 156 156 155 156 156 155 156 163 162 163 167 166 167 155 154 155
51751 +137 136 137 153 152 153 156 155 156 165 164 165 163 162 163 156 155 156
51752 +156 155 156 156 155 156 155 154 155 158 157 158 166 165 166 174 174 174
51753 +167 166 167 125 124 125 37 38 37 1 0 0 0 0 0 0 0 0
51754 +0 0 0 24 26 27 60 74 84 158 157 158 174 174 174 174 174 174
51755 +166 165 166 158 157 158 125 124 125 41 54 63 13 16 17 6 6 6
51756 +6 6 6 37 38 37 80 127 157 136 185 209 101 161 196 101 161 196
51757 +90 154 193 28 67 93 6 10 14 13 20 25 13 20 25 6 10 14
51758 +1 1 2 4 3 3 4 4 4 4 4 4 4 4 4 4 4 4
51759 +4 4 4 4 4 4
51760 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51761 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51762 +1 1 1 1 0 0 4 3 3 37 38 37 60 74 84 153 152 153
51763 +167 166 167 167 166 167 158 157 158 154 153 154 155 154 155 156 155 156
51764 +157 156 157 158 157 158 167 166 167 167 166 167 131 129 131 43 57 68
51765 +26 28 28 37 38 37 60 73 81 131 129 131 165 164 165 166 165 166
51766 +158 157 158 155 154 155 156 155 156 156 155 156 156 155 156 158 157 158
51767 +165 164 165 174 174 174 163 162 163 60 74 84 16 19 21 13 16 17
51768 +60 73 81 131 129 131 174 174 174 174 174 174 167 166 167 165 164 165
51769 +137 136 137 60 73 81 24 26 27 4 0 0 4 0 0 16 19 21
51770 +52 104 138 101 161 196 136 185 209 136 185 209 90 154 193 27 99 146
51771 +13 20 25 4 5 7 2 5 5 4 5 7 1 1 2 0 0 0
51772 +4 4 4 4 4 4 3 3 3 2 2 2 2 2 2 4 4 4
51773 +4 4 4 4 4 4
51774 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51775 +4 4 4 4 4 4 4 4 4 4 4 4 3 3 3 0 0 0
51776 +0 0 0 13 16 17 60 73 81 137 136 137 174 174 174 166 165 166
51777 +158 157 158 156 155 156 157 156 157 156 155 156 155 154 155 158 157 158
51778 +167 166 167 174 174 174 153 152 153 60 73 81 16 19 21 4 0 0
51779 +4 0 0 4 0 0 6 6 6 26 28 28 60 74 84 158 157 158
51780 +174 174 174 166 165 166 157 156 157 155 154 155 156 155 156 156 155 156
51781 +155 154 155 158 157 158 167 166 167 167 166 167 131 129 131 125 124 125
51782 +137 136 137 167 166 167 167 166 167 174 174 174 158 157 158 125 124 125
51783 +16 19 21 4 0 0 4 0 0 10 13 16 49 76 92 107 159 188
51784 +136 185 209 136 185 209 90 154 193 26 108 161 22 40 52 6 10 14
51785 +2 3 3 1 1 2 1 1 2 4 4 5 4 4 5 4 4 5
51786 +4 4 5 2 2 1 0 0 0 0 0 0 0 0 0 2 2 2
51787 +4 4 4 4 4 4
51788 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51789 +4 4 4 5 5 5 3 3 3 0 0 0 1 0 0 4 0 0
51790 +37 51 59 131 129 131 167 166 167 167 166 167 163 162 163 157 156 157
51791 +157 156 157 155 154 155 153 152 153 157 156 157 167 166 167 174 174 174
51792 +153 152 153 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
51793 +4 3 3 4 3 3 4 0 0 6 6 6 4 0 0 37 38 37
51794 +125 124 125 174 174 174 174 174 174 165 164 165 156 155 156 154 153 154
51795 +156 155 156 156 155 156 155 154 155 163 162 163 158 157 158 163 162 163
51796 +174 174 174 174 174 174 174 174 174 125 124 125 37 38 37 0 0 0
51797 +4 0 0 6 9 11 41 54 63 90 154 193 136 185 209 146 190 211
51798 +136 185 209 37 112 160 22 40 52 6 10 14 3 6 7 1 1 2
51799 +1 1 2 3 3 3 1 1 2 3 3 3 4 4 4 4 4 4
51800 +2 2 2 2 0 0 16 19 21 37 38 37 24 26 27 0 0 0
51801 +0 0 0 4 4 4
51802 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
51803 +4 4 4 0 0 0 0 0 0 0 0 0 26 28 28 120 125 127
51804 +158 157 158 174 174 174 165 164 165 157 156 157 155 154 155 156 155 156
51805 +153 152 153 153 152 153 167 166 167 174 174 174 174 174 174 125 124 125
51806 +37 38 37 4 0 0 0 0 0 4 0 0 4 3 3 4 4 4
51807 +4 4 4 4 4 4 5 5 5 4 0 0 4 0 0 4 0 0
51808 +4 3 3 43 57 68 137 136 137 174 174 174 174 174 174 165 164 165
51809 +154 153 154 153 152 153 153 152 153 153 152 153 163 162 163 174 174 174
51810 +174 174 174 153 152 153 60 73 81 6 6 6 4 0 0 4 3 3
51811 +32 43 50 80 127 157 136 185 209 146 190 211 146 190 211 90 154 193
51812 +28 67 93 28 67 93 40 71 93 3 6 7 1 1 2 2 5 5
51813 +50 82 103 79 117 143 26 37 45 0 0 0 3 3 3 1 1 1
51814 +0 0 0 41 54 63 137 136 137 174 174 174 153 152 153 60 73 81
51815 +2 0 0 0 0 0
51816 +4 4 4 4 4 4 4 4 4 4 4 4 6 6 6 2 2 2
51817 +0 0 0 2 0 0 24 26 27 60 74 84 153 152 153 174 174 174
51818 +174 174 174 157 156 157 154 153 154 156 155 156 154 153 154 153 152 153
51819 +165 164 165 174 174 174 177 184 187 137 136 137 43 57 68 6 6 6
51820 +4 0 0 2 0 0 3 3 3 5 5 5 5 5 5 4 4 4
51821 +4 4 4 4 4 4 4 4 4 5 5 5 6 6 6 4 3 3
51822 +4 0 0 4 0 0 24 26 27 60 73 81 153 152 153 174 174 174
51823 +174 174 174 158 157 158 158 157 158 174 174 174 174 174 174 158 157 158
51824 +60 74 84 24 26 27 4 0 0 4 0 0 17 23 27 59 113 148
51825 +136 185 209 191 222 234 146 190 211 136 185 209 31 91 132 7 11 13
51826 +22 40 52 101 161 196 90 154 193 6 9 11 3 4 4 43 95 132
51827 +136 185 209 172 205 220 55 98 126 0 0 0 0 0 0 2 0 0
51828 +26 28 28 153 152 153 177 184 187 167 166 167 177 184 187 165 164 165
51829 +37 38 37 0 0 0
51830 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
51831 +13 16 17 60 73 81 137 136 137 174 174 174 174 174 174 165 164 165
51832 +153 152 153 153 152 153 155 154 155 154 153 154 158 157 158 174 174 174
51833 +177 184 187 163 162 163 60 73 81 16 19 21 4 0 0 4 0 0
51834 +4 3 3 4 4 4 5 5 5 5 5 5 4 4 4 5 5 5
51835 +5 5 5 5 5 5 5 5 5 4 4 4 4 4 4 5 5 5
51836 +6 6 6 4 0 0 4 0 0 4 0 0 24 26 27 60 74 84
51837 +166 165 166 174 174 174 177 184 187 165 164 165 125 124 125 24 26 27
51838 +4 0 0 4 0 0 5 5 5 50 82 103 136 185 209 172 205 220
51839 +146 190 211 136 185 209 26 108 161 22 40 52 7 12 15 44 81 103
51840 +71 116 144 28 67 93 37 51 59 41 65 82 100 139 164 101 161 196
51841 +90 154 193 90 154 193 28 67 93 0 0 0 0 0 0 26 28 28
51842 +125 124 125 167 166 167 163 162 163 153 152 153 163 162 163 174 174 174
51843 +85 115 134 4 0 0
51844 +4 4 4 5 5 5 4 4 4 1 0 0 4 0 0 34 47 55
51845 +125 124 125 174 174 174 174 174 174 167 166 167 157 156 157 153 152 153
51846 +155 154 155 155 154 155 158 157 158 166 165 166 167 166 167 154 153 154
51847 +125 124 125 26 28 28 4 0 0 4 0 0 4 0 0 5 5 5
51848 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 1 1 1
51849 +0 0 0 0 0 0 1 1 1 4 4 4 4 4 4 4 4 4
51850 +5 5 5 5 5 5 4 3 3 4 0 0 4 0 0 6 6 6
51851 +37 38 37 131 129 131 137 136 137 37 38 37 0 0 0 4 0 0
51852 +4 5 5 43 61 72 90 154 193 172 205 220 146 190 211 136 185 209
51853 +90 154 193 28 67 93 13 20 25 43 61 72 71 116 144 44 81 103
51854 +2 5 5 7 11 13 59 113 148 101 161 196 90 154 193 28 67 93
51855 +13 20 25 6 10 14 0 0 0 13 16 17 60 73 81 137 136 137
51856 +166 165 166 158 157 158 156 155 156 154 153 154 167 166 167 174 174 174
51857 +60 73 81 4 0 0
51858 +4 4 4 4 4 4 0 0 0 3 3 3 60 74 84 174 174 174
51859 +174 174 174 167 166 167 163 162 163 155 154 155 157 156 157 155 154 155
51860 +156 155 156 163 162 163 167 166 167 158 157 158 125 124 125 37 38 37
51861 +4 3 3 4 0 0 4 0 0 6 6 6 6 6 6 5 5 5
51862 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 2 3 3
51863 +10 13 16 7 11 13 1 0 0 0 0 0 2 2 1 4 4 4
51864 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 4 0 0
51865 +4 0 0 7 11 13 13 16 17 4 0 0 3 3 3 34 47 55
51866 +80 127 157 146 190 211 172 205 220 136 185 209 136 185 209 136 185 209
51867 +28 67 93 22 40 52 55 98 126 55 98 126 21 29 34 7 11 13
51868 +50 82 103 101 161 196 101 161 196 35 83 115 13 20 25 2 2 1
51869 +1 1 2 1 1 2 37 51 59 131 129 131 174 174 174 174 174 174
51870 +167 166 167 163 162 163 163 162 163 167 166 167 174 174 174 125 124 125
51871 +16 19 21 4 0 0
51872 +4 4 4 4 0 0 4 0 0 60 74 84 174 174 174 174 174 174
51873 +158 157 158 155 154 155 155 154 155 156 155 156 155 154 155 158 157 158
51874 +167 166 167 165 164 165 131 129 131 60 73 81 13 16 17 4 0 0
51875 +4 0 0 4 3 3 6 6 6 4 3 3 5 5 5 4 4 4
51876 +4 4 4 3 2 2 0 0 0 0 0 0 7 11 13 45 69 86
51877 +80 127 157 71 116 144 43 61 72 7 11 13 0 0 0 1 1 1
51878 +4 3 3 4 4 4 4 4 4 4 4 4 6 6 6 5 5 5
51879 +3 2 2 4 0 0 1 0 0 21 29 34 59 113 148 136 185 209
51880 +146 190 211 136 185 209 136 185 209 136 185 209 136 185 209 136 185 209
51881 +68 124 159 44 81 103 22 40 52 13 16 17 43 61 72 90 154 193
51882 +136 185 209 59 113 148 21 29 34 3 4 3 1 1 1 0 0 0
51883 +24 26 27 125 124 125 163 162 163 174 174 174 166 165 166 165 164 165
51884 +163 162 163 125 124 125 125 124 125 125 124 125 125 124 125 26 28 28
51885 +4 0 0 4 3 3
51886 +3 3 3 0 0 0 24 26 27 153 152 153 177 184 187 158 157 158
51887 +156 155 156 156 155 156 155 154 155 155 154 155 165 164 165 174 174 174
51888 +155 154 155 60 74 84 26 28 28 4 0 0 4 0 0 3 1 0
51889 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 3 3
51890 +2 0 0 0 0 0 0 0 0 32 43 50 72 125 159 101 161 196
51891 +136 185 209 101 161 196 101 161 196 79 117 143 32 43 50 0 0 0
51892 +0 0 0 2 2 2 4 4 4 4 4 4 3 3 3 1 0 0
51893 +0 0 0 4 5 5 49 76 92 101 161 196 146 190 211 146 190 211
51894 +136 185 209 136 185 209 136 185 209 136 185 209 136 185 209 90 154 193
51895 +28 67 93 13 16 17 37 51 59 80 127 157 136 185 209 90 154 193
51896 +22 40 52 6 9 11 3 4 3 2 2 1 16 19 21 60 73 81
51897 +137 136 137 163 162 163 158 157 158 166 165 166 167 166 167 153 152 153
51898 +60 74 84 37 38 37 6 6 6 13 16 17 4 0 0 1 0 0
51899 +3 2 2 4 4 4
51900 +3 2 2 4 0 0 37 38 37 137 136 137 167 166 167 158 157 158
51901 +157 156 157 154 153 154 157 156 157 167 166 167 174 174 174 125 124 125
51902 +37 38 37 4 0 0 4 0 0 4 0 0 4 3 3 4 4 4
51903 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
51904 +0 0 0 16 21 25 55 98 126 90 154 193 136 185 209 101 161 196
51905 +101 161 196 101 161 196 136 185 209 136 185 209 101 161 196 55 98 126
51906 +14 17 19 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
51907 +22 40 52 90 154 193 146 190 211 146 190 211 136 185 209 136 185 209
51908 +136 185 209 136 185 209 136 185 209 101 161 196 35 83 115 7 11 13
51909 +17 23 27 59 113 148 136 185 209 101 161 196 34 86 122 7 12 15
51910 +2 5 5 3 4 3 6 6 6 60 73 81 131 129 131 163 162 163
51911 +166 165 166 174 174 174 174 174 174 163 162 163 125 124 125 41 54 63
51912 +13 16 17 4 0 0 4 0 0 4 0 0 1 0 0 2 2 2
51913 +4 4 4 4 4 4
51914 +1 1 1 2 1 0 43 57 68 137 136 137 153 152 153 153 152 153
51915 +163 162 163 156 155 156 165 164 165 167 166 167 60 74 84 6 6 6
51916 +4 0 0 4 0 0 5 5 5 4 4 4 4 4 4 4 4 4
51917 +4 5 5 6 6 6 4 3 3 0 0 0 0 0 0 11 15 18
51918 +40 71 93 100 139 164 101 161 196 101 161 196 101 161 196 101 161 196
51919 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 136 185 209
51920 +101 161 196 45 69 86 6 6 6 0 0 0 17 23 27 55 98 126
51921 +136 185 209 146 190 211 136 185 209 136 185 209 136 185 209 136 185 209
51922 +136 185 209 136 185 209 90 154 193 22 40 52 7 11 13 50 82 103
51923 +136 185 209 136 185 209 53 118 160 22 40 52 7 11 13 2 5 5
51924 +3 4 3 37 38 37 125 124 125 157 156 157 166 165 166 167 166 167
51925 +174 174 174 174 174 174 137 136 137 60 73 81 4 0 0 4 0 0
51926 +4 0 0 4 0 0 5 5 5 3 3 3 3 3 3 4 4 4
51927 +4 4 4 4 4 4
51928 +4 0 0 4 0 0 41 54 63 137 136 137 125 124 125 131 129 131
51929 +155 154 155 167 166 167 174 174 174 60 74 84 6 6 6 4 0 0
51930 +4 3 3 6 6 6 4 4 4 4 4 4 4 4 4 5 5 5
51931 +4 4 4 1 1 1 0 0 0 3 6 7 41 65 82 72 125 159
51932 +101 161 196 101 161 196 101 161 196 90 154 193 90 154 193 101 161 196
51933 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
51934 +136 185 209 136 185 209 80 127 157 55 98 126 101 161 196 146 190 211
51935 +136 185 209 136 185 209 136 185 209 101 161 196 136 185 209 101 161 196
51936 +136 185 209 101 161 196 35 83 115 22 30 35 101 161 196 172 205 220
51937 +90 154 193 28 67 93 7 11 13 2 5 5 3 4 3 13 16 17
51938 +85 115 134 167 166 167 174 174 174 174 174 174 174 174 174 174 174 174
51939 +167 166 167 60 74 84 13 16 17 4 0 0 4 0 0 4 3 3
51940 +6 6 6 5 5 5 4 4 4 5 5 5 4 4 4 5 5 5
51941 +5 5 5 5 5 5
51942 +1 1 1 4 0 0 41 54 63 137 136 137 137 136 137 125 124 125
51943 +131 129 131 167 166 167 157 156 157 37 38 37 6 6 6 4 0 0
51944 +6 6 6 5 5 5 4 4 4 4 4 4 4 5 5 2 2 1
51945 +0 0 0 0 0 0 26 37 45 58 111 146 101 161 196 101 161 196
51946 +101 161 196 90 154 193 90 154 193 90 154 193 101 161 196 101 161 196
51947 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
51948 +101 161 196 136 185 209 136 185 209 136 185 209 146 190 211 136 185 209
51949 +136 185 209 101 161 196 136 185 209 136 185 209 101 161 196 136 185 209
51950 +101 161 196 136 185 209 136 185 209 136 185 209 136 185 209 16 89 141
51951 +7 11 13 2 5 5 2 5 5 13 16 17 60 73 81 154 154 154
51952 +174 174 174 174 174 174 174 174 174 174 174 174 163 162 163 125 124 125
51953 +24 26 27 4 0 0 4 0 0 4 0 0 5 5 5 5 5 5
51954 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
51955 +5 5 5 4 4 4
51956 +4 0 0 6 6 6 37 38 37 137 136 137 137 136 137 131 129 131
51957 +131 129 131 153 152 153 131 129 131 26 28 28 4 0 0 4 3 3
51958 +6 6 6 4 4 4 4 4 4 4 4 4 0 0 0 0 0 0
51959 +13 20 25 51 88 114 90 154 193 101 161 196 101 161 196 90 154 193
51960 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
51961 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 101 161 196
51962 +101 161 196 136 185 209 101 161 196 136 185 209 136 185 209 101 161 196
51963 +136 185 209 101 161 196 136 185 209 101 161 196 101 161 196 101 161 196
51964 +136 185 209 136 185 209 136 185 209 37 112 160 21 29 34 5 7 8
51965 +2 5 5 13 16 17 43 57 68 131 129 131 174 174 174 174 174 174
51966 +174 174 174 167 166 167 157 156 157 125 124 125 37 38 37 4 0 0
51967 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
51968 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51969 +4 4 4 4 4 4
51970 +1 1 1 4 0 0 41 54 63 153 152 153 137 136 137 137 136 137
51971 +137 136 137 153 152 153 125 124 125 24 26 27 4 0 0 3 2 2
51972 +4 4 4 4 4 4 4 3 3 4 0 0 3 6 7 43 61 72
51973 +64 123 161 101 161 196 90 154 193 90 154 193 90 154 193 90 154 193
51974 +90 154 193 90 154 193 90 154 193 90 154 193 101 161 196 90 154 193
51975 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
51976 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
51977 +136 185 209 101 161 196 101 161 196 136 185 209 136 185 209 101 161 196
51978 +101 161 196 90 154 193 28 67 93 13 16 17 7 11 13 3 6 7
51979 +37 51 59 125 124 125 163 162 163 174 174 174 167 166 167 166 165 166
51980 +167 166 167 131 129 131 60 73 81 4 0 0 4 0 0 4 0 0
51981 +3 3 3 5 5 5 6 6 6 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 4 4 4
51983 +4 4 4 4 4 4
51984 +4 0 0 4 0 0 41 54 63 137 136 137 153 152 153 137 136 137
51985 +153 152 153 157 156 157 125 124 125 24 26 27 0 0 0 2 2 2
51986 +4 4 4 4 4 4 2 0 0 0 0 0 28 67 93 90 154 193
51987 +90 154 193 90 154 193 90 154 193 90 154 193 64 123 161 90 154 193
51988 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
51989 +90 154 193 101 161 196 101 161 196 101 161 196 90 154 193 136 185 209
51990 +101 161 196 101 161 196 136 185 209 101 161 196 136 185 209 101 161 196
51991 +101 161 196 101 161 196 136 185 209 101 161 196 101 161 196 90 154 193
51992 +35 83 115 13 16 17 3 6 7 2 5 5 13 16 17 60 74 84
51993 +154 154 154 166 165 166 165 164 165 158 157 158 163 162 163 157 156 157
51994 +60 74 84 13 16 17 4 0 0 4 0 0 3 2 2 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 4 4 4
51998 +1 1 1 4 0 0 41 54 63 157 156 157 155 154 155 137 136 137
51999 +153 152 153 158 157 158 137 136 137 26 28 28 2 0 0 2 2 2
52000 +4 4 4 4 4 4 1 0 0 6 10 14 34 86 122 90 154 193
52001 +64 123 161 90 154 193 64 123 161 90 154 193 90 154 193 90 154 193
52002 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
52003 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
52004 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
52005 +136 185 209 101 161 196 136 185 209 90 154 193 26 108 161 22 40 52
52006 +13 16 17 5 7 8 2 5 5 2 5 5 37 38 37 165 164 165
52007 +174 174 174 163 162 163 154 154 154 165 164 165 167 166 167 60 73 81
52008 +6 6 6 4 0 0 4 0 0 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 4 4 4
52012 +4 0 0 6 6 6 41 54 63 156 155 156 158 157 158 153 152 153
52013 +156 155 156 165 164 165 137 136 137 26 28 28 0 0 0 2 2 2
52014 +4 4 5 4 4 4 2 0 0 7 12 15 31 96 139 64 123 161
52015 +90 154 193 64 123 161 90 154 193 90 154 193 64 123 161 90 154 193
52016 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
52017 +90 154 193 90 154 193 90 154 193 101 161 196 101 161 196 101 161 196
52018 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
52019 +101 161 196 136 185 209 26 108 161 22 40 52 7 11 13 5 7 8
52020 +2 5 5 2 5 5 2 5 5 2 2 1 37 38 37 158 157 158
52021 +174 174 174 154 154 154 156 155 156 167 166 167 165 164 165 37 38 37
52022 +4 0 0 4 3 3 5 5 5 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
52026 +3 1 0 4 0 0 60 73 81 157 156 157 163 162 163 153 152 153
52027 +158 157 158 167 166 167 137 136 137 26 28 28 2 0 0 2 2 2
52028 +4 5 5 4 4 4 4 0 0 7 12 15 24 86 132 26 108 161
52029 +37 112 160 64 123 161 90 154 193 64 123 161 90 154 193 90 154 193
52030 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
52031 +90 154 193 101 161 196 90 154 193 101 161 196 101 161 196 101 161 196
52032 +101 161 196 101 161 196 101 161 196 136 185 209 101 161 196 136 185 209
52033 +90 154 193 35 83 115 13 16 17 13 16 17 7 11 13 3 6 7
52034 +5 7 8 6 6 6 3 4 3 2 2 1 30 32 34 154 154 154
52035 +167 166 167 154 154 154 154 154 154 174 174 174 165 164 165 37 38 37
52036 +6 6 6 4 0 0 6 6 6 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
52040 +4 0 0 4 0 0 41 54 63 163 162 163 166 165 166 154 154 154
52041 +163 162 163 174 174 174 137 136 137 26 28 28 0 0 0 2 2 2
52042 +4 5 5 4 4 5 1 1 2 6 10 14 28 67 93 18 97 151
52043 +18 97 151 18 97 151 26 108 161 37 112 160 37 112 160 90 154 193
52044 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
52045 +90 154 193 101 161 196 101 161 196 90 154 193 101 161 196 101 161 196
52046 +101 161 196 101 161 196 101 161 196 136 185 209 90 154 193 16 89 141
52047 +13 20 25 7 11 13 5 7 8 5 7 8 2 5 5 4 5 5
52048 +3 4 3 4 5 5 3 4 3 0 0 0 37 38 37 158 157 158
52049 +174 174 174 158 157 158 158 157 158 167 166 167 174 174 174 41 54 63
52050 +4 0 0 3 2 2 5 5 5 4 4 4 4 4 4 4 4 4
52051 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52052 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52053 +4 4 4 4 4 4
52054 +1 1 1 4 0 0 60 73 81 165 164 165 174 174 174 158 157 158
52055 +167 166 167 174 174 174 153 152 153 26 28 28 2 0 0 2 2 2
52056 +4 5 5 4 4 4 4 0 0 7 12 15 10 87 144 10 87 144
52057 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
52058 +26 108 161 37 112 160 53 118 160 90 154 193 90 154 193 90 154 193
52059 +90 154 193 90 154 193 101 161 196 101 161 196 101 161 196 101 161 196
52060 +101 161 196 136 185 209 90 154 193 26 108 161 22 40 52 13 16 17
52061 +7 11 13 3 6 7 5 7 8 5 7 8 2 5 5 4 5 5
52062 +4 5 5 6 6 6 3 4 3 0 0 0 30 32 34 158 157 158
52063 +174 174 174 156 155 156 155 154 155 165 164 165 154 153 154 37 38 37
52064 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52065 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52066 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52067 +4 4 4 4 4 4
52068 +4 0 0 4 0 0 60 73 81 167 166 167 174 174 174 163 162 163
52069 +174 174 174 174 174 174 153 152 153 26 28 28 0 0 0 3 3 3
52070 +5 5 5 4 4 4 1 1 2 7 12 15 28 67 93 18 97 151
52071 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
52072 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
52073 +90 154 193 26 108 161 90 154 193 90 154 193 90 154 193 101 161 196
52074 +101 161 196 26 108 161 22 40 52 13 16 17 7 11 13 2 5 5
52075 +2 5 5 6 6 6 2 5 5 4 5 5 4 5 5 4 5 5
52076 +3 4 3 5 5 5 3 4 3 2 0 0 30 32 34 137 136 137
52077 +153 152 153 137 136 137 131 129 131 137 136 137 131 129 131 37 38 37
52078 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52079 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52080 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52081 +4 4 4 4 4 4
52082 +1 1 1 4 0 0 60 73 81 167 166 167 174 174 174 166 165 166
52083 +174 174 174 177 184 187 153 152 153 30 32 34 1 0 0 3 3 3
52084 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
52085 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
52086 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
52087 +26 108 161 26 108 161 26 108 161 90 154 193 90 154 193 26 108 161
52088 +35 83 115 13 16 17 7 11 13 5 7 8 3 6 7 5 7 8
52089 +2 5 5 6 6 6 4 5 5 4 5 5 3 4 3 4 5 5
52090 +3 4 3 6 6 6 3 4 3 0 0 0 26 28 28 125 124 125
52091 +131 129 131 125 124 125 125 124 125 131 129 131 131 129 131 37 38 37
52092 +4 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52093 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52094 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52095 +4 4 4 4 4 4
52096 +3 1 0 4 0 0 60 73 81 174 174 174 177 184 187 167 166 167
52097 +174 174 174 177 184 187 153 152 153 30 32 34 0 0 0 3 3 3
52098 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
52099 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
52100 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
52101 +26 108 161 90 154 193 26 108 161 26 108 161 24 86 132 13 20 25
52102 +7 11 13 13 20 25 22 40 52 5 7 8 3 4 3 3 4 3
52103 +4 5 5 3 4 3 4 5 5 3 4 3 4 5 5 3 4 3
52104 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
52105 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
52106 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52107 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52108 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52109 +4 4 4 4 4 4
52110 +1 1 1 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
52111 +174 174 174 190 197 201 157 156 157 30 32 34 1 0 0 3 3 3
52112 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
52113 +18 97 151 19 95 150 19 95 150 18 97 151 18 97 151 26 108 161
52114 +18 97 151 26 108 161 26 108 161 26 108 161 26 108 161 90 154 193
52115 +26 108 161 26 108 161 26 108 161 22 40 52 2 5 5 3 4 3
52116 +28 67 93 37 112 160 34 86 122 2 5 5 3 4 3 3 4 3
52117 +3 4 3 3 4 3 3 4 3 2 2 1 3 4 3 4 4 4
52118 +4 5 5 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
52119 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
52120 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52121 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52122 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52123 +4 4 4 4 4 4
52124 +4 0 0 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
52125 +174 174 174 190 197 201 158 157 158 30 32 34 0 0 0 2 2 2
52126 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
52127 +10 87 144 19 95 150 19 95 150 18 97 151 18 97 151 18 97 151
52128 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
52129 +18 97 151 22 40 52 2 5 5 2 2 1 22 40 52 26 108 161
52130 +90 154 193 37 112 160 22 40 52 3 4 3 13 20 25 22 30 35
52131 +3 6 7 1 1 1 2 2 2 6 9 11 5 5 5 4 3 3
52132 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
52133 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
52134 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52135 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52136 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52137 +4 4 4 4 4 4
52138 +1 1 1 4 0 0 60 73 81 177 184 187 193 200 203 174 174 174
52139 +177 184 187 193 200 203 163 162 163 30 32 34 4 0 0 2 2 2
52140 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
52141 +10 87 144 10 87 144 19 95 150 19 95 150 19 95 150 18 97 151
52142 +26 108 161 26 108 161 26 108 161 90 154 193 26 108 161 28 67 93
52143 +6 10 14 2 5 5 13 20 25 24 86 132 37 112 160 90 154 193
52144 +10 87 144 7 12 15 2 5 5 28 67 93 37 112 160 28 67 93
52145 +2 2 1 7 12 15 35 83 115 28 67 93 3 6 7 1 0 0
52146 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
52147 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
52148 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52149 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52150 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52151 +4 4 4 4 4 4
52152 +4 0 0 4 0 0 60 73 81 174 174 174 190 197 201 174 174 174
52153 +177 184 187 193 200 203 163 162 163 30 32 34 0 0 0 2 2 2
52154 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
52155 +10 87 144 16 89 141 19 95 150 10 87 144 26 108 161 26 108 161
52156 +26 108 161 26 108 161 26 108 161 28 67 93 6 10 14 1 1 2
52157 +7 12 15 28 67 93 26 108 161 16 89 141 24 86 132 21 29 34
52158 +3 4 3 21 29 34 37 112 160 37 112 160 27 99 146 21 29 34
52159 +21 29 34 26 108 161 90 154 193 35 83 115 1 1 2 2 0 0
52160 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
52161 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
52162 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52163 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52164 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52165 +4 4 4 4 4 4
52166 +3 1 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
52167 +190 197 201 193 200 203 165 164 165 37 38 37 4 0 0 2 2 2
52168 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
52169 +10 87 144 10 87 144 16 89 141 18 97 151 18 97 151 10 87 144
52170 +24 86 132 24 86 132 13 20 25 4 5 7 4 5 7 22 40 52
52171 +18 97 151 37 112 160 26 108 161 7 12 15 1 1 1 0 0 0
52172 +28 67 93 37 112 160 26 108 161 28 67 93 22 40 52 28 67 93
52173 +26 108 161 90 154 193 26 108 161 10 87 144 0 0 0 2 0 0
52174 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
52175 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
52176 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52177 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52178 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52179 +4 4 4 4 4 4
52180 +4 0 0 6 6 6 60 73 81 174 174 174 193 200 203 174 174 174
52181 +190 197 201 193 200 203 165 164 165 30 32 34 0 0 0 2 2 2
52182 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
52183 +10 87 144 10 87 144 10 87 144 18 97 151 28 67 93 6 10 14
52184 +0 0 0 1 1 2 4 5 7 13 20 25 16 89 141 26 108 161
52185 +26 108 161 26 108 161 24 86 132 6 9 11 2 3 3 22 40 52
52186 +37 112 160 16 89 141 22 40 52 28 67 93 26 108 161 26 108 161
52187 +90 154 193 26 108 161 26 108 161 28 67 93 1 1 1 4 0 0
52188 +4 4 4 5 5 5 3 3 3 4 0 0 26 28 28 124 126 130
52189 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
52190 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52191 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52192 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52193 +4 4 4 4 4 4
52194 +4 0 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
52195 +193 200 203 193 200 203 167 166 167 37 38 37 4 0 0 2 2 2
52196 +5 5 5 4 4 4 4 0 0 6 10 14 28 67 93 10 87 144
52197 +10 87 144 10 87 144 18 97 151 10 87 144 13 20 25 4 5 7
52198 +1 1 2 1 1 1 22 40 52 26 108 161 26 108 161 26 108 161
52199 +26 108 161 26 108 161 26 108 161 24 86 132 22 40 52 22 40 52
52200 +22 40 52 22 40 52 10 87 144 26 108 161 26 108 161 26 108 161
52201 +26 108 161 26 108 161 90 154 193 10 87 144 0 0 0 4 0 0
52202 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
52203 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
52204 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52205 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52206 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52207 +4 4 4 4 4 4
52208 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
52209 +190 197 201 205 212 215 167 166 167 30 32 34 0 0 0 2 2 2
52210 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
52211 +10 87 144 10 87 144 10 87 144 10 87 144 22 40 52 1 1 2
52212 +2 0 0 1 1 2 24 86 132 26 108 161 26 108 161 26 108 161
52213 +26 108 161 19 95 150 16 89 141 10 87 144 22 40 52 22 40 52
52214 +10 87 144 26 108 161 37 112 160 26 108 161 26 108 161 26 108 161
52215 +26 108 161 26 108 161 26 108 161 28 67 93 2 0 0 3 1 0
52216 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
52217 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
52218 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52219 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52220 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52221 +4 4 4 4 4 4
52222 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
52223 +193 200 203 193 200 203 174 174 174 37 38 37 4 0 0 2 2 2
52224 +5 5 5 4 4 4 3 2 2 1 1 2 13 20 25 10 87 144
52225 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 13 20 25
52226 +13 20 25 22 40 52 10 87 144 18 97 151 18 97 151 26 108 161
52227 +10 87 144 13 20 25 6 10 14 21 29 34 24 86 132 18 97 151
52228 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
52229 +26 108 161 90 154 193 18 97 151 13 20 25 0 0 0 4 3 3
52230 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
52231 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
52232 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52233 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52234 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52235 +4 4 4 4 4 4
52236 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
52237 +190 197 201 220 221 221 167 166 167 30 32 34 1 0 0 2 2 2
52238 +5 5 5 4 4 4 4 4 5 2 5 5 4 5 7 13 20 25
52239 +28 67 93 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
52240 +10 87 144 10 87 144 18 97 151 10 87 144 18 97 151 18 97 151
52241 +28 67 93 2 3 3 0 0 0 28 67 93 26 108 161 26 108 161
52242 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
52243 +26 108 161 10 87 144 13 20 25 1 1 2 3 2 2 4 4 4
52244 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
52245 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
52246 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52247 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52248 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52249 +4 4 4 4 4 4
52250 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
52251 +193 200 203 193 200 203 174 174 174 26 28 28 4 0 0 4 3 3
52252 +5 5 5 4 4 4 4 4 4 4 4 5 1 1 2 2 5 5
52253 +4 5 7 22 40 52 10 87 144 10 87 144 18 97 151 10 87 144
52254 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 18 97 151
52255 +10 87 144 28 67 93 22 40 52 10 87 144 26 108 161 18 97 151
52256 +18 97 151 18 97 151 26 108 161 26 108 161 26 108 161 26 108 161
52257 +22 40 52 1 1 2 0 0 0 2 3 3 4 4 4 4 4 4
52258 +4 4 4 5 5 5 4 4 4 0 0 0 26 28 28 131 129 131
52259 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
52260 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52261 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52262 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52263 +4 4 4 4 4 4
52264 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
52265 +190 197 201 220 221 221 190 197 201 41 54 63 4 0 0 2 2 2
52266 +6 6 6 4 4 4 4 4 4 4 4 5 4 4 5 3 3 3
52267 +1 1 2 1 1 2 6 10 14 22 40 52 10 87 144 18 97 151
52268 +18 97 151 10 87 144 10 87 144 10 87 144 18 97 151 10 87 144
52269 +10 87 144 18 97 151 26 108 161 18 97 151 18 97 151 10 87 144
52270 +26 108 161 26 108 161 26 108 161 10 87 144 28 67 93 6 10 14
52271 +1 1 2 1 1 2 4 3 3 4 4 5 4 4 4 4 4 4
52272 +5 5 5 5 5 5 1 1 1 4 0 0 37 51 59 137 136 137
52273 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
52274 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52275 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52276 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52277 +4 4 4 4 4 4
52278 +4 0 0 4 0 0 60 73 81 220 221 221 193 200 203 174 174 174
52279 +193 200 203 193 200 203 220 221 221 137 136 137 13 16 17 4 0 0
52280 +2 2 2 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5
52281 +4 4 5 4 3 3 1 1 2 4 5 7 13 20 25 28 67 93
52282 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
52283 +10 87 144 18 97 151 18 97 151 10 87 144 18 97 151 26 108 161
52284 +26 108 161 18 97 151 28 67 93 6 10 14 0 0 0 0 0 0
52285 +2 3 3 4 5 5 4 4 5 4 4 4 4 4 4 5 5 5
52286 +3 3 3 1 1 1 0 0 0 16 19 21 125 124 125 137 136 137
52287 +131 129 131 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
52288 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52289 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52290 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52291 +4 4 4 4 4 4
52292 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
52293 +193 200 203 190 197 201 220 221 221 220 221 221 153 152 153 30 32 34
52294 +0 0 0 0 0 0 2 2 2 4 4 4 4 4 4 4 4 4
52295 +4 4 4 4 5 5 4 5 7 1 1 2 1 1 2 4 5 7
52296 +13 20 25 28 67 93 10 87 144 18 97 151 10 87 144 10 87 144
52297 +10 87 144 10 87 144 10 87 144 18 97 151 26 108 161 18 97 151
52298 +28 67 93 7 12 15 0 0 0 0 0 0 2 2 1 4 4 4
52299 +4 5 5 4 5 5 4 4 4 4 4 4 3 3 3 0 0 0
52300 +0 0 0 0 0 0 37 38 37 125 124 125 158 157 158 131 129 131
52301 +125 124 125 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
52302 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52303 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52304 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52305 +4 4 4 4 4 4
52306 +4 3 3 4 0 0 41 54 63 193 200 203 220 221 221 174 174 174
52307 +193 200 203 193 200 203 193 200 203 220 221 221 244 246 246 193 200 203
52308 +120 125 127 5 5 5 1 0 0 0 0 0 1 1 1 4 4 4
52309 +4 4 4 4 4 4 4 5 5 4 5 5 4 4 5 1 1 2
52310 +4 5 7 4 5 7 22 40 52 10 87 144 10 87 144 10 87 144
52311 +10 87 144 10 87 144 18 97 151 10 87 144 10 87 144 13 20 25
52312 +4 5 7 2 3 3 1 1 2 4 4 4 4 5 5 4 4 4
52313 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 1 2
52314 +24 26 27 60 74 84 153 152 153 163 162 163 137 136 137 125 124 125
52315 +125 124 125 125 124 125 125 124 125 137 136 137 125 124 125 26 28 28
52316 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52317 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52318 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52319 +4 4 4 4 4 4
52320 +4 0 0 6 6 6 26 28 28 156 155 156 220 221 221 220 221 221
52321 +174 174 174 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
52322 +220 221 221 167 166 167 60 73 81 7 11 13 0 0 0 0 0 0
52323 +3 3 3 4 4 4 4 4 4 4 4 4 4 4 5 4 4 5
52324 +4 4 5 1 1 2 1 1 2 4 5 7 22 40 52 10 87 144
52325 +10 87 144 10 87 144 10 87 144 22 40 52 4 5 7 1 1 2
52326 +1 1 2 4 4 5 4 4 4 4 4 4 4 4 4 4 4 4
52327 +5 5 5 2 2 2 0 0 0 4 0 0 16 19 21 60 73 81
52328 +137 136 137 167 166 167 158 157 158 137 136 137 131 129 131 131 129 131
52329 +125 124 125 125 124 125 131 129 131 155 154 155 60 74 84 5 7 8
52330 +0 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52331 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52332 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52333 +4 4 4 4 4 4
52334 +5 5 5 4 0 0 4 0 0 60 73 81 193 200 203 220 221 221
52335 +193 200 203 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
52336 +220 221 221 220 221 221 220 221 221 137 136 137 43 57 68 6 6 6
52337 +4 0 0 1 1 1 4 4 4 4 4 4 4 4 4 4 4 4
52338 +4 4 5 4 4 5 3 2 2 1 1 2 2 5 5 13 20 25
52339 +22 40 52 22 40 52 13 20 25 2 3 3 1 1 2 3 3 3
52340 +4 5 7 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52341 +1 1 1 0 0 0 2 3 3 41 54 63 131 129 131 166 165 166
52342 +166 165 166 155 154 155 153 152 153 137 136 137 137 136 137 125 124 125
52343 +125 124 125 137 136 137 137 136 137 125 124 125 37 38 37 4 3 3
52344 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
52345 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52346 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52347 +4 4 4 4 4 4
52348 +4 3 3 6 6 6 6 6 6 13 16 17 60 73 81 167 166 167
52349 +220 221 221 220 221 221 220 221 221 193 200 203 193 200 203 193 200 203
52350 +205 212 215 220 221 221 220 221 221 244 246 246 205 212 215 125 124 125
52351 +24 26 27 0 0 0 0 0 0 2 2 2 5 5 5 5 5 5
52352 +4 4 4 4 4 4 4 4 4 4 4 5 1 1 2 4 5 7
52353 +4 5 7 4 5 7 1 1 2 3 2 2 4 4 5 4 4 4
52354 +4 4 4 4 4 4 5 5 5 4 4 4 0 0 0 0 0 0
52355 +2 0 0 26 28 28 125 124 125 174 174 174 174 174 174 166 165 166
52356 +156 155 156 153 152 153 137 136 137 137 136 137 131 129 131 137 136 137
52357 +137 136 137 137 136 137 60 74 84 30 32 34 4 0 0 4 0 0
52358 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52359 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52360 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52361 +4 4 4 4 4 4
52362 +5 5 5 6 6 6 4 0 0 4 0 0 6 6 6 26 28 28
52363 +125 124 125 174 174 174 220 221 221 220 221 221 220 221 221 193 200 203
52364 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
52365 +193 200 203 60 74 84 13 16 17 4 0 0 0 0 0 3 3 3
52366 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 5 3 3 3
52367 +1 1 2 3 3 3 4 4 5 4 4 5 4 4 4 4 4 4
52368 +5 5 5 5 5 5 2 2 2 0 0 0 0 0 0 13 16 17
52369 +60 74 84 174 174 174 193 200 203 174 174 174 167 166 167 163 162 163
52370 +153 152 153 153 152 153 137 136 137 137 136 137 153 152 153 137 136 137
52371 +125 124 125 41 54 63 24 26 27 4 0 0 4 0 0 5 5 5
52372 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52373 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52374 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52375 +4 4 4 4 4 4
52376 +4 3 3 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
52377 +6 6 6 37 38 37 131 129 131 220 221 221 220 221 221 220 221 221
52378 +193 200 203 193 200 203 220 221 221 205 212 215 220 221 221 244 246 246
52379 +244 246 246 244 246 246 174 174 174 41 54 63 0 0 0 0 0 0
52380 +0 0 0 4 4 4 5 5 5 5 5 5 4 4 4 4 4 5
52381 +4 4 5 4 4 5 4 4 4 4 4 4 6 6 6 6 6 6
52382 +3 3 3 0 0 0 2 0 0 13 16 17 60 73 81 156 155 156
52383 +220 221 221 193 200 203 174 174 174 165 164 165 163 162 163 154 153 154
52384 +153 152 153 153 152 153 158 157 158 163 162 163 137 136 137 60 73 81
52385 +13 16 17 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
52386 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52387 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52388 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52389 +4 4 4 4 4 4
52390 +5 5 5 4 3 3 4 3 3 6 6 6 6 6 6 6 6 6
52391 +6 6 6 6 6 6 6 6 6 37 38 37 167 166 167 244 246 246
52392 +244 246 246 220 221 221 205 212 215 205 212 215 220 221 221 193 200 203
52393 +220 221 221 244 246 246 244 246 246 244 246 246 137 136 137 37 38 37
52394 +3 2 2 0 0 0 1 1 1 5 5 5 5 5 5 4 4 4
52395 +4 4 4 4 4 4 4 4 4 5 5 5 4 4 4 1 1 1
52396 +0 0 0 5 5 5 43 57 68 153 152 153 193 200 203 220 221 221
52397 +177 184 187 174 174 174 167 166 167 166 165 166 158 157 158 157 156 157
52398 +158 157 158 166 165 166 156 155 156 85 115 134 13 16 17 4 0 0
52399 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
52400 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52401 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52402 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52403 +4 4 4 4 4 4
52404 +5 5 5 4 3 3 6 6 6 6 6 6 4 0 0 6 6 6
52405 +6 6 6 6 6 6 6 6 6 6 6 6 13 16 17 60 73 81
52406 +177 184 187 220 221 221 220 221 221 220 221 221 205 212 215 220 221 221
52407 +220 221 221 205 212 215 220 221 221 244 246 246 244 246 246 205 212 215
52408 +125 124 125 30 32 34 0 0 0 0 0 0 2 2 2 5 5 5
52409 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 0 0
52410 +37 38 37 131 129 131 205 212 215 220 221 221 193 200 203 174 174 174
52411 +174 174 174 174 174 174 167 166 167 165 164 165 166 165 166 167 166 167
52412 +158 157 158 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
52413 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
52414 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52415 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52416 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52417 +4 4 4 4 4 4
52418 +4 4 4 5 5 5 4 3 3 4 3 3 6 6 6 6 6 6
52419 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
52420 +26 28 28 125 124 125 205 212 215 220 221 221 220 221 221 220 221 221
52421 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
52422 +244 246 246 190 197 201 60 74 84 16 19 21 4 0 0 0 0 0
52423 +0 0 0 0 0 0 0 0 0 0 0 0 16 19 21 120 125 127
52424 +177 184 187 220 221 221 205 212 215 177 184 187 174 174 174 177 184 187
52425 +174 174 174 174 174 174 167 166 167 174 174 174 166 165 166 137 136 137
52426 +60 73 81 13 16 17 4 0 0 4 0 0 4 3 3 6 6 6
52427 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52428 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52429 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52430 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52431 +4 4 4 4 4 4
52432 +5 5 5 4 3 3 5 5 5 4 3 3 6 6 6 4 0 0
52433 +6 6 6 6 6 6 4 0 0 6 6 6 4 0 0 6 6 6
52434 +6 6 6 6 6 6 37 38 37 137 136 137 193 200 203 220 221 221
52435 +220 221 221 205 212 215 220 221 221 205 212 215 205 212 215 220 221 221
52436 +220 221 221 220 221 221 244 246 246 166 165 166 43 57 68 2 2 2
52437 +0 0 0 4 0 0 16 19 21 60 73 81 157 156 157 202 210 214
52438 +220 221 221 193 200 203 177 184 187 177 184 187 177 184 187 174 174 174
52439 +174 174 174 174 174 174 174 174 174 157 156 157 60 74 84 24 26 27
52440 +4 0 0 4 0 0 4 0 0 6 6 6 4 4 4 4 4 4
52441 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52442 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52443 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52444 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52445 +4 4 4 4 4 4
52446 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
52447 +6 6 6 4 0 0 6 6 6 6 6 6 6 6 6 4 0 0
52448 +4 0 0 4 0 0 6 6 6 24 26 27 60 73 81 167 166 167
52449 +220 221 221 220 221 221 220 221 221 205 212 215 205 212 215 205 212 215
52450 +205 212 215 220 221 221 220 221 221 220 221 221 205 212 215 137 136 137
52451 +60 74 84 125 124 125 137 136 137 190 197 201 220 221 221 193 200 203
52452 +177 184 187 177 184 187 177 184 187 174 174 174 174 174 174 177 184 187
52453 +190 197 201 174 174 174 125 124 125 37 38 37 6 6 6 4 0 0
52454 +4 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52455 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52456 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52457 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52458 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52459 +4 4 4 4 4 4
52460 +4 4 4 4 4 4 5 5 5 5 5 5 4 3 3 6 6 6
52461 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 6 6 6
52462 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
52463 +125 124 125 193 200 203 244 246 246 220 221 221 205 212 215 205 212 215
52464 +205 212 215 193 200 203 205 212 215 205 212 215 220 221 221 220 221 221
52465 +193 200 203 193 200 203 205 212 215 193 200 203 193 200 203 177 184 187
52466 +190 197 201 190 197 201 174 174 174 190 197 201 193 200 203 190 197 201
52467 +153 152 153 60 73 81 4 0 0 4 0 0 4 0 0 3 2 2
52468 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52469 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52470 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52471 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52472 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52473 +4 4 4 4 4 4
52474 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
52475 +6 6 6 4 3 3 4 3 3 4 3 3 6 6 6 6 6 6
52476 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 4 0 0
52477 +4 0 0 26 28 28 131 129 131 220 221 221 244 246 246 220 221 221
52478 +205 212 215 193 200 203 205 212 215 193 200 203 193 200 203 205 212 215
52479 +220 221 221 193 200 203 193 200 203 193 200 203 190 197 201 174 174 174
52480 +174 174 174 190 197 201 193 200 203 193 200 203 167 166 167 125 124 125
52481 +6 6 6 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
52482 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52483 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52484 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52485 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52486 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52487 +4 4 4 4 4 4
52488 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
52489 +5 5 5 4 3 3 5 5 5 6 6 6 4 3 3 5 5 5
52490 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
52491 +4 0 0 4 0 0 6 6 6 41 54 63 158 157 158 220 221 221
52492 +220 221 221 220 221 221 193 200 203 193 200 203 193 200 203 190 197 201
52493 +190 197 201 190 197 201 190 197 201 190 197 201 174 174 174 193 200 203
52494 +193 200 203 220 221 221 174 174 174 125 124 125 37 38 37 4 0 0
52495 +4 0 0 4 3 3 6 6 6 4 4 4 4 4 4 4 4 4
52496 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52497 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52498 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52499 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52500 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52501 +4 4 4 4 4 4
52502 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52503 +4 4 4 5 5 5 4 3 3 4 3 3 4 3 3 5 5 5
52504 +4 3 3 6 6 6 5 5 5 4 3 3 6 6 6 6 6 6
52505 +6 6 6 6 6 6 4 0 0 4 0 0 13 16 17 60 73 81
52506 +174 174 174 220 221 221 220 221 221 205 212 215 190 197 201 174 174 174
52507 +193 200 203 174 174 174 190 197 201 174 174 174 193 200 203 220 221 221
52508 +193 200 203 131 129 131 37 38 37 6 6 6 4 0 0 4 0 0
52509 +6 6 6 6 6 6 4 3 3 5 5 5 4 4 4 4 4 4
52510 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52511 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52512 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52513 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52514 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52515 +4 4 4 4 4 4
52516 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52517 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
52518 +5 5 5 4 3 3 4 3 3 5 5 5 4 3 3 4 3 3
52519 +5 5 5 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
52520 +6 6 6 125 124 125 174 174 174 220 221 221 220 221 221 193 200 203
52521 +193 200 203 193 200 203 193 200 203 193 200 203 220 221 221 158 157 158
52522 +60 73 81 6 6 6 4 0 0 4 0 0 5 5 5 6 6 6
52523 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
52524 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52525 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52526 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52527 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52528 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52529 +4 4 4 4 4 4
52530 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52531 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52532 +4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
52533 +5 5 5 5 5 5 6 6 6 6 6 6 4 0 0 4 0 0
52534 +4 0 0 4 0 0 26 28 28 125 124 125 174 174 174 193 200 203
52535 +193 200 203 174 174 174 193 200 203 167 166 167 125 124 125 6 6 6
52536 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 5 5 5
52537 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
52538 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52539 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52540 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52541 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52542 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52543 +4 4 4 4 4 4
52544 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52545 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52546 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
52547 +4 3 3 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
52548 +6 6 6 4 0 0 4 0 0 6 6 6 37 38 37 125 124 125
52549 +153 152 153 131 129 131 125 124 125 37 38 37 6 6 6 6 6 6
52550 +6 6 6 4 0 0 6 6 6 6 6 6 4 3 3 5 5 5
52551 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52552 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52553 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52554 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52555 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52556 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52557 +4 4 4 4 4 4
52558 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52559 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52560 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52561 +4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
52562 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
52563 +24 26 27 24 26 27 6 6 6 6 6 6 6 6 6 4 0 0
52564 +6 6 6 6 6 6 4 0 0 6 6 6 5 5 5 4 3 3
52565 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52566 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52567 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52568 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52569 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52570 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52571 +4 4 4 4 4 4
52572 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52573 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52574 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52575 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
52576 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
52577 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
52578 +4 0 0 6 6 6 6 6 6 4 3 3 5 5 5 4 4 4
52579 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52580 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52581 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52582 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52583 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52584 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52585 +4 4 4 4 4 4
52586 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52587 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52588 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52589 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 5 5 5
52590 +5 5 5 5 5 5 4 0 0 6 6 6 4 0 0 6 6 6
52591 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 4 0 0
52592 +6 6 6 4 3 3 5 5 5 4 3 3 5 5 5 4 4 4
52593 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52594 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52595 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52596 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52597 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52598 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52599 +4 4 4 4 4 4
52600 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52601 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52602 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52603 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
52604 +4 3 3 6 6 6 4 3 3 6 6 6 6 6 6 6 6 6
52605 +4 0 0 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
52606 +6 6 6 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52607 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52608 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52609 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52610 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52611 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52612 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52613 +4 4 4 4 4 4
52614 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52615 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52616 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52617 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52618 +4 4 4 5 5 5 4 3 3 5 5 5 4 0 0 6 6 6
52619 +6 6 6 4 0 0 6 6 6 6 6 6 4 0 0 6 6 6
52620 +4 3 3 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
52621 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52622 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52623 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52624 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52625 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52626 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52627 +4 4 4 4 4 4
52628 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52629 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52630 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52631 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52632 +4 4 4 5 5 5 4 3 3 5 5 5 6 6 6 4 3 3
52633 +4 3 3 6 6 6 6 6 6 4 3 3 6 6 6 4 3 3
52634 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52635 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52636 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52637 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52638 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52639 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52640 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52641 +4 4 4 4 4 4
52642 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52643 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52644 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52645 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52646 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 6 6 6
52647 +5 5 5 4 3 3 4 3 3 4 3 3 5 5 5 5 5 5
52648 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52649 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52650 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52651 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52652 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52653 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52654 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52655 +4 4 4 4 4 4
52656 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52657 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52658 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52659 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52660 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
52661 +5 5 5 4 3 3 5 5 5 5 5 5 4 4 4 4 4 4
52662 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52663 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52664 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52665 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52666 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52667 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52668 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52669 +4 4 4 4 4 4
52670 diff --git a/drivers/video/mb862xx/mb862xxfb_accel.c b/drivers/video/mb862xx/mb862xxfb_accel.c
52671 index fe92eed..106e085 100644
52672 --- a/drivers/video/mb862xx/mb862xxfb_accel.c
52673 +++ b/drivers/video/mb862xx/mb862xxfb_accel.c
52674 @@ -312,14 +312,18 @@ void mb862xxfb_init_accel(struct fb_info *info, int xres)
52675 struct mb862xxfb_par *par = info->par;
52676
52677 if (info->var.bits_per_pixel == 32) {
52678 - info->fbops->fb_fillrect = cfb_fillrect;
52679 - info->fbops->fb_copyarea = cfb_copyarea;
52680 - info->fbops->fb_imageblit = cfb_imageblit;
52681 + pax_open_kernel();
52682 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
52683 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
52684 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
52685 + pax_close_kernel();
52686 } else {
52687 outreg(disp, GC_L0EM, 3);
52688 - info->fbops->fb_fillrect = mb86290fb_fillrect;
52689 - info->fbops->fb_copyarea = mb86290fb_copyarea;
52690 - info->fbops->fb_imageblit = mb86290fb_imageblit;
52691 + pax_open_kernel();
52692 + *(void **)&info->fbops->fb_fillrect = mb86290fb_fillrect;
52693 + *(void **)&info->fbops->fb_copyarea = mb86290fb_copyarea;
52694 + *(void **)&info->fbops->fb_imageblit = mb86290fb_imageblit;
52695 + pax_close_kernel();
52696 }
52697 outreg(draw, GDC_REG_DRAW_BASE, 0);
52698 outreg(draw, GDC_REG_MODE_MISC, 0x8000);
52699 diff --git a/drivers/video/nvidia/nvidia.c b/drivers/video/nvidia/nvidia.c
52700 index ff22871..b129bed 100644
52701 --- a/drivers/video/nvidia/nvidia.c
52702 +++ b/drivers/video/nvidia/nvidia.c
52703 @@ -669,19 +669,23 @@ static int nvidiafb_set_par(struct fb_info *info)
52704 info->fix.line_length = (info->var.xres_virtual *
52705 info->var.bits_per_pixel) >> 3;
52706 if (info->var.accel_flags) {
52707 - info->fbops->fb_imageblit = nvidiafb_imageblit;
52708 - info->fbops->fb_fillrect = nvidiafb_fillrect;
52709 - info->fbops->fb_copyarea = nvidiafb_copyarea;
52710 - info->fbops->fb_sync = nvidiafb_sync;
52711 + pax_open_kernel();
52712 + *(void **)&info->fbops->fb_imageblit = nvidiafb_imageblit;
52713 + *(void **)&info->fbops->fb_fillrect = nvidiafb_fillrect;
52714 + *(void **)&info->fbops->fb_copyarea = nvidiafb_copyarea;
52715 + *(void **)&info->fbops->fb_sync = nvidiafb_sync;
52716 + pax_close_kernel();
52717 info->pixmap.scan_align = 4;
52718 info->flags &= ~FBINFO_HWACCEL_DISABLED;
52719 info->flags |= FBINFO_READS_FAST;
52720 NVResetGraphics(info);
52721 } else {
52722 - info->fbops->fb_imageblit = cfb_imageblit;
52723 - info->fbops->fb_fillrect = cfb_fillrect;
52724 - info->fbops->fb_copyarea = cfb_copyarea;
52725 - info->fbops->fb_sync = NULL;
52726 + pax_open_kernel();
52727 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
52728 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
52729 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
52730 + *(void **)&info->fbops->fb_sync = NULL;
52731 + pax_close_kernel();
52732 info->pixmap.scan_align = 1;
52733 info->flags |= FBINFO_HWACCEL_DISABLED;
52734 info->flags &= ~FBINFO_READS_FAST;
52735 @@ -1173,8 +1177,11 @@ static int nvidia_set_fbinfo(struct fb_info *info)
52736 info->pixmap.size = 8 * 1024;
52737 info->pixmap.flags = FB_PIXMAP_SYSTEM;
52738
52739 - if (!hwcur)
52740 - info->fbops->fb_cursor = NULL;
52741 + if (!hwcur) {
52742 + pax_open_kernel();
52743 + *(void **)&info->fbops->fb_cursor = NULL;
52744 + pax_close_kernel();
52745 + }
52746
52747 info->var.accel_flags = (!noaccel);
52748
52749 diff --git a/drivers/video/omap2/dss/display.c b/drivers/video/omap2/dss/display.c
52750 index fafe7c9..93197b9 100644
52751 --- a/drivers/video/omap2/dss/display.c
52752 +++ b/drivers/video/omap2/dss/display.c
52753 @@ -137,12 +137,14 @@ int omapdss_register_display(struct omap_dss_device *dssdev)
52754 snprintf(dssdev->alias, sizeof(dssdev->alias),
52755 "display%d", disp_num_counter++);
52756
52757 + pax_open_kernel();
52758 if (drv && drv->get_resolution == NULL)
52759 - drv->get_resolution = omapdss_default_get_resolution;
52760 + *(void **)&drv->get_resolution = omapdss_default_get_resolution;
52761 if (drv && drv->get_recommended_bpp == NULL)
52762 - drv->get_recommended_bpp = omapdss_default_get_recommended_bpp;
52763 + *(void **)&drv->get_recommended_bpp = omapdss_default_get_recommended_bpp;
52764 if (drv && drv->get_timings == NULL)
52765 - drv->get_timings = omapdss_default_get_timings;
52766 + *(void **)&drv->get_timings = omapdss_default_get_timings;
52767 + pax_close_kernel();
52768
52769 mutex_lock(&panel_list_mutex);
52770 list_add_tail(&dssdev->panel_list, &panel_list);
52771 diff --git a/drivers/video/s1d13xxxfb.c b/drivers/video/s1d13xxxfb.c
52772 index 05c2dc3..ea1f391 100644
52773 --- a/drivers/video/s1d13xxxfb.c
52774 +++ b/drivers/video/s1d13xxxfb.c
52775 @@ -881,8 +881,10 @@ static int s1d13xxxfb_probe(struct platform_device *pdev)
52776
52777 switch(prod_id) {
52778 case S1D13506_PROD_ID: /* activate acceleration */
52779 - s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
52780 - s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
52781 + pax_open_kernel();
52782 + *(void **)&s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
52783 + *(void **)&s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
52784 + pax_close_kernel();
52785 info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN |
52786 FBINFO_HWACCEL_FILLRECT | FBINFO_HWACCEL_COPYAREA;
52787 break;
52788 diff --git a/drivers/video/smscufx.c b/drivers/video/smscufx.c
52789 index e188ada..aac63c8 100644
52790 --- a/drivers/video/smscufx.c
52791 +++ b/drivers/video/smscufx.c
52792 @@ -1175,7 +1175,9 @@ static int ufx_ops_release(struct fb_info *info, int user)
52793 fb_deferred_io_cleanup(info);
52794 kfree(info->fbdefio);
52795 info->fbdefio = NULL;
52796 - info->fbops->fb_mmap = ufx_ops_mmap;
52797 + pax_open_kernel();
52798 + *(void **)&info->fbops->fb_mmap = ufx_ops_mmap;
52799 + pax_close_kernel();
52800 }
52801
52802 pr_debug("released /dev/fb%d user=%d count=%d",
52803 diff --git a/drivers/video/udlfb.c b/drivers/video/udlfb.c
52804 index d2e5bc3..4cb05d1 100644
52805 --- a/drivers/video/udlfb.c
52806 +++ b/drivers/video/udlfb.c
52807 @@ -623,11 +623,11 @@ static int dlfb_handle_damage(struct dlfb_data *dev, int x, int y,
52808 dlfb_urb_completion(urb);
52809
52810 error:
52811 - atomic_add(bytes_sent, &dev->bytes_sent);
52812 - atomic_add(bytes_identical, &dev->bytes_identical);
52813 - atomic_add(width*height*2, &dev->bytes_rendered);
52814 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
52815 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
52816 + atomic_add_unchecked(width*height*2, &dev->bytes_rendered);
52817 end_cycles = get_cycles();
52818 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
52819 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
52820 >> 10)), /* Kcycles */
52821 &dev->cpu_kcycles_used);
52822
52823 @@ -748,11 +748,11 @@ static void dlfb_dpy_deferred_io(struct fb_info *info,
52824 dlfb_urb_completion(urb);
52825
52826 error:
52827 - atomic_add(bytes_sent, &dev->bytes_sent);
52828 - atomic_add(bytes_identical, &dev->bytes_identical);
52829 - atomic_add(bytes_rendered, &dev->bytes_rendered);
52830 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
52831 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
52832 + atomic_add_unchecked(bytes_rendered, &dev->bytes_rendered);
52833 end_cycles = get_cycles();
52834 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
52835 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
52836 >> 10)), /* Kcycles */
52837 &dev->cpu_kcycles_used);
52838 }
52839 @@ -993,7 +993,9 @@ static int dlfb_ops_release(struct fb_info *info, int user)
52840 fb_deferred_io_cleanup(info);
52841 kfree(info->fbdefio);
52842 info->fbdefio = NULL;
52843 - info->fbops->fb_mmap = dlfb_ops_mmap;
52844 + pax_open_kernel();
52845 + *(void **)&info->fbops->fb_mmap = dlfb_ops_mmap;
52846 + pax_close_kernel();
52847 }
52848
52849 pr_warn("released /dev/fb%d user=%d count=%d\n",
52850 @@ -1376,7 +1378,7 @@ static ssize_t metrics_bytes_rendered_show(struct device *fbdev,
52851 struct fb_info *fb_info = dev_get_drvdata(fbdev);
52852 struct dlfb_data *dev = fb_info->par;
52853 return snprintf(buf, PAGE_SIZE, "%u\n",
52854 - atomic_read(&dev->bytes_rendered));
52855 + atomic_read_unchecked(&dev->bytes_rendered));
52856 }
52857
52858 static ssize_t metrics_bytes_identical_show(struct device *fbdev,
52859 @@ -1384,7 +1386,7 @@ static ssize_t metrics_bytes_identical_show(struct device *fbdev,
52860 struct fb_info *fb_info = dev_get_drvdata(fbdev);
52861 struct dlfb_data *dev = fb_info->par;
52862 return snprintf(buf, PAGE_SIZE, "%u\n",
52863 - atomic_read(&dev->bytes_identical));
52864 + atomic_read_unchecked(&dev->bytes_identical));
52865 }
52866
52867 static ssize_t metrics_bytes_sent_show(struct device *fbdev,
52868 @@ -1392,7 +1394,7 @@ static ssize_t metrics_bytes_sent_show(struct device *fbdev,
52869 struct fb_info *fb_info = dev_get_drvdata(fbdev);
52870 struct dlfb_data *dev = fb_info->par;
52871 return snprintf(buf, PAGE_SIZE, "%u\n",
52872 - atomic_read(&dev->bytes_sent));
52873 + atomic_read_unchecked(&dev->bytes_sent));
52874 }
52875
52876 static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
52877 @@ -1400,7 +1402,7 @@ static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
52878 struct fb_info *fb_info = dev_get_drvdata(fbdev);
52879 struct dlfb_data *dev = fb_info->par;
52880 return snprintf(buf, PAGE_SIZE, "%u\n",
52881 - atomic_read(&dev->cpu_kcycles_used));
52882 + atomic_read_unchecked(&dev->cpu_kcycles_used));
52883 }
52884
52885 static ssize_t edid_show(
52886 @@ -1460,10 +1462,10 @@ static ssize_t metrics_reset_store(struct device *fbdev,
52887 struct fb_info *fb_info = dev_get_drvdata(fbdev);
52888 struct dlfb_data *dev = fb_info->par;
52889
52890 - atomic_set(&dev->bytes_rendered, 0);
52891 - atomic_set(&dev->bytes_identical, 0);
52892 - atomic_set(&dev->bytes_sent, 0);
52893 - atomic_set(&dev->cpu_kcycles_used, 0);
52894 + atomic_set_unchecked(&dev->bytes_rendered, 0);
52895 + atomic_set_unchecked(&dev->bytes_identical, 0);
52896 + atomic_set_unchecked(&dev->bytes_sent, 0);
52897 + atomic_set_unchecked(&dev->cpu_kcycles_used, 0);
52898
52899 return count;
52900 }
52901 diff --git a/drivers/video/uvesafb.c b/drivers/video/uvesafb.c
52902 index 7aec6f3..e3b2d55 100644
52903 --- a/drivers/video/uvesafb.c
52904 +++ b/drivers/video/uvesafb.c
52905 @@ -19,6 +19,7 @@
52906 #include <linux/io.h>
52907 #include <linux/mutex.h>
52908 #include <linux/slab.h>
52909 +#include <linux/moduleloader.h>
52910 #include <video/edid.h>
52911 #include <video/uvesafb.h>
52912 #ifdef CONFIG_X86
52913 @@ -566,10 +567,32 @@ static int uvesafb_vbe_getpmi(struct uvesafb_ktask *task,
52914 if ((task->t.regs.eax & 0xffff) != 0x4f || task->t.regs.es < 0xc000) {
52915 par->pmi_setpal = par->ypan = 0;
52916 } else {
52917 +
52918 +#ifdef CONFIG_PAX_KERNEXEC
52919 +#ifdef CONFIG_MODULES
52920 + par->pmi_code = module_alloc_exec((u16)task->t.regs.ecx);
52921 +#endif
52922 + if (!par->pmi_code) {
52923 + par->pmi_setpal = par->ypan = 0;
52924 + return 0;
52925 + }
52926 +#endif
52927 +
52928 par->pmi_base = (u16 *)phys_to_virt(((u32)task->t.regs.es << 4)
52929 + task->t.regs.edi);
52930 +
52931 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
52932 + pax_open_kernel();
52933 + memcpy(par->pmi_code, par->pmi_base, (u16)task->t.regs.ecx);
52934 + pax_close_kernel();
52935 +
52936 + par->pmi_start = ktva_ktla(par->pmi_code + par->pmi_base[1]);
52937 + par->pmi_pal = ktva_ktla(par->pmi_code + par->pmi_base[2]);
52938 +#else
52939 par->pmi_start = (u8 *)par->pmi_base + par->pmi_base[1];
52940 par->pmi_pal = (u8 *)par->pmi_base + par->pmi_base[2];
52941 +#endif
52942 +
52943 printk(KERN_INFO "uvesafb: protected mode interface info at "
52944 "%04x:%04x\n",
52945 (u16)task->t.regs.es, (u16)task->t.regs.edi);
52946 @@ -814,13 +837,14 @@ static int uvesafb_vbe_init(struct fb_info *info)
52947 par->ypan = ypan;
52948
52949 if (par->pmi_setpal || par->ypan) {
52950 +#if !defined(CONFIG_MODULES) || !defined(CONFIG_PAX_KERNEXEC)
52951 if (__supported_pte_mask & _PAGE_NX) {
52952 par->pmi_setpal = par->ypan = 0;
52953 printk(KERN_WARNING "uvesafb: NX protection is active, "
52954 "better not use the PMI.\n");
52955 - } else {
52956 + } else
52957 +#endif
52958 uvesafb_vbe_getpmi(task, par);
52959 - }
52960 }
52961 #else
52962 /* The protected mode interface is not available on non-x86. */
52963 @@ -1454,8 +1478,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
52964 info->fix.ywrapstep = (par->ypan > 1) ? 1 : 0;
52965
52966 /* Disable blanking if the user requested so. */
52967 - if (!blank)
52968 - info->fbops->fb_blank = NULL;
52969 + if (!blank) {
52970 + pax_open_kernel();
52971 + *(void **)&info->fbops->fb_blank = NULL;
52972 + pax_close_kernel();
52973 + }
52974
52975 /*
52976 * Find out how much IO memory is required for the mode with
52977 @@ -1531,8 +1558,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
52978 info->flags = FBINFO_FLAG_DEFAULT |
52979 (par->ypan ? FBINFO_HWACCEL_YPAN : 0);
52980
52981 - if (!par->ypan)
52982 - info->fbops->fb_pan_display = NULL;
52983 + if (!par->ypan) {
52984 + pax_open_kernel();
52985 + *(void **)&info->fbops->fb_pan_display = NULL;
52986 + pax_close_kernel();
52987 + }
52988 }
52989
52990 static void uvesafb_init_mtrr(struct fb_info *info)
52991 @@ -1796,6 +1826,11 @@ out:
52992 if (par->vbe_modes)
52993 kfree(par->vbe_modes);
52994
52995 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
52996 + if (par->pmi_code)
52997 + module_free_exec(NULL, par->pmi_code);
52998 +#endif
52999 +
53000 framebuffer_release(info);
53001 return err;
53002 }
53003 @@ -1823,6 +1858,12 @@ static int uvesafb_remove(struct platform_device *dev)
53004 kfree(par->vbe_state_orig);
53005 if (par->vbe_state_saved)
53006 kfree(par->vbe_state_saved);
53007 +
53008 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
53009 + if (par->pmi_code)
53010 + module_free_exec(NULL, par->pmi_code);
53011 +#endif
53012 +
53013 }
53014
53015 framebuffer_release(info);
53016 diff --git a/drivers/video/vesafb.c b/drivers/video/vesafb.c
53017 index bd83233..7d8a5aa 100644
53018 --- a/drivers/video/vesafb.c
53019 +++ b/drivers/video/vesafb.c
53020 @@ -9,6 +9,7 @@
53021 */
53022
53023 #include <linux/module.h>
53024 +#include <linux/moduleloader.h>
53025 #include <linux/kernel.h>
53026 #include <linux/errno.h>
53027 #include <linux/string.h>
53028 @@ -52,8 +53,8 @@ static int vram_remap; /* Set amount of memory to be used */
53029 static int vram_total; /* Set total amount of memory */
53030 static int pmi_setpal __read_mostly = 1; /* pmi for palette changes ??? */
53031 static int ypan __read_mostly; /* 0..nothing, 1..ypan, 2..ywrap */
53032 -static void (*pmi_start)(void) __read_mostly;
53033 -static void (*pmi_pal) (void) __read_mostly;
53034 +static void (*pmi_start)(void) __read_only;
53035 +static void (*pmi_pal) (void) __read_only;
53036 static int depth __read_mostly;
53037 static int vga_compat __read_mostly;
53038 /* --------------------------------------------------------------------- */
53039 @@ -234,6 +235,7 @@ static int vesafb_probe(struct platform_device *dev)
53040 unsigned int size_remap;
53041 unsigned int size_total;
53042 char *option = NULL;
53043 + void *pmi_code = NULL;
53044
53045 /* ignore error return of fb_get_options */
53046 fb_get_options("vesafb", &option);
53047 @@ -280,10 +282,6 @@ static int vesafb_probe(struct platform_device *dev)
53048 size_remap = size_total;
53049 vesafb_fix.smem_len = size_remap;
53050
53051 -#ifndef __i386__
53052 - screen_info.vesapm_seg = 0;
53053 -#endif
53054 -
53055 if (!request_mem_region(vesafb_fix.smem_start, size_total, "vesafb")) {
53056 printk(KERN_WARNING
53057 "vesafb: cannot reserve video memory at 0x%lx\n",
53058 @@ -312,9 +310,21 @@ static int vesafb_probe(struct platform_device *dev)
53059 printk(KERN_INFO "vesafb: mode is %dx%dx%d, linelength=%d, pages=%d\n",
53060 vesafb_defined.xres, vesafb_defined.yres, vesafb_defined.bits_per_pixel, vesafb_fix.line_length, screen_info.pages);
53061
53062 +#ifdef __i386__
53063 +
53064 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
53065 + pmi_code = module_alloc_exec(screen_info.vesapm_size);
53066 + if (!pmi_code)
53067 +#elif !defined(CONFIG_PAX_KERNEXEC)
53068 + if (0)
53069 +#endif
53070 +
53071 +#endif
53072 + screen_info.vesapm_seg = 0;
53073 +
53074 if (screen_info.vesapm_seg) {
53075 - printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x\n",
53076 - screen_info.vesapm_seg,screen_info.vesapm_off);
53077 + printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x %04x bytes\n",
53078 + screen_info.vesapm_seg,screen_info.vesapm_off,screen_info.vesapm_size);
53079 }
53080
53081 if (screen_info.vesapm_seg < 0xc000)
53082 @@ -322,9 +332,25 @@ static int vesafb_probe(struct platform_device *dev)
53083
53084 if (ypan || pmi_setpal) {
53085 unsigned short *pmi_base;
53086 +
53087 pmi_base = (unsigned short*)phys_to_virt(((unsigned long)screen_info.vesapm_seg << 4) + screen_info.vesapm_off);
53088 - pmi_start = (void*)((char*)pmi_base + pmi_base[1]);
53089 - pmi_pal = (void*)((char*)pmi_base + pmi_base[2]);
53090 +
53091 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
53092 + pax_open_kernel();
53093 + memcpy(pmi_code, pmi_base, screen_info.vesapm_size);
53094 +#else
53095 + pmi_code = pmi_base;
53096 +#endif
53097 +
53098 + pmi_start = (void*)((char*)pmi_code + pmi_base[1]);
53099 + pmi_pal = (void*)((char*)pmi_code + pmi_base[2]);
53100 +
53101 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
53102 + pmi_start = ktva_ktla(pmi_start);
53103 + pmi_pal = ktva_ktla(pmi_pal);
53104 + pax_close_kernel();
53105 +#endif
53106 +
53107 printk(KERN_INFO "vesafb: pmi: set display start = %p, set palette = %p\n",pmi_start,pmi_pal);
53108 if (pmi_base[3]) {
53109 printk(KERN_INFO "vesafb: pmi: ports = ");
53110 @@ -477,8 +503,11 @@ static int vesafb_probe(struct platform_device *dev)
53111 info->flags = FBINFO_FLAG_DEFAULT | FBINFO_MISC_FIRMWARE |
53112 (ypan ? FBINFO_HWACCEL_YPAN : 0);
53113
53114 - if (!ypan)
53115 - info->fbops->fb_pan_display = NULL;
53116 + if (!ypan) {
53117 + pax_open_kernel();
53118 + *(void **)&info->fbops->fb_pan_display = NULL;
53119 + pax_close_kernel();
53120 + }
53121
53122 if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) {
53123 err = -ENOMEM;
53124 @@ -493,6 +522,11 @@ static int vesafb_probe(struct platform_device *dev)
53125 info->node, info->fix.id);
53126 return 0;
53127 err:
53128 +
53129 +#if defined(__i386__) && defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
53130 + module_free_exec(NULL, pmi_code);
53131 +#endif
53132 +
53133 if (info->screen_base)
53134 iounmap(info->screen_base);
53135 framebuffer_release(info);
53136 diff --git a/drivers/video/via/via_clock.h b/drivers/video/via/via_clock.h
53137 index 88714ae..16c2e11 100644
53138 --- a/drivers/video/via/via_clock.h
53139 +++ b/drivers/video/via/via_clock.h
53140 @@ -56,7 +56,7 @@ struct via_clock {
53141
53142 void (*set_engine_pll_state)(u8 state);
53143 void (*set_engine_pll)(struct via_pll_config config);
53144 -};
53145 +} __no_const;
53146
53147
53148 static inline u32 get_pll_internal_frequency(u32 ref_freq,
53149 diff --git a/drivers/xen/xenfs/xenstored.c b/drivers/xen/xenfs/xenstored.c
53150 index fef20db..d28b1ab 100644
53151 --- a/drivers/xen/xenfs/xenstored.c
53152 +++ b/drivers/xen/xenfs/xenstored.c
53153 @@ -24,7 +24,12 @@ static int xsd_release(struct inode *inode, struct file *file)
53154 static int xsd_kva_open(struct inode *inode, struct file *file)
53155 {
53156 file->private_data = (void *)kasprintf(GFP_KERNEL, "0x%p",
53157 +#ifdef CONFIG_GRKERNSEC_HIDESYM
53158 + NULL);
53159 +#else
53160 xen_store_interface);
53161 +#endif
53162 +
53163 if (!file->private_data)
53164 return -ENOMEM;
53165 return 0;
53166 diff --git a/fs/9p/vfs_addr.c b/fs/9p/vfs_addr.c
53167 index 9ff073f..05cef23 100644
53168 --- a/fs/9p/vfs_addr.c
53169 +++ b/fs/9p/vfs_addr.c
53170 @@ -187,7 +187,7 @@ static int v9fs_vfs_writepage_locked(struct page *page)
53171
53172 retval = v9fs_file_write_internal(inode,
53173 v9inode->writeback_fid,
53174 - (__force const char __user *)buffer,
53175 + (const char __force_user *)buffer,
53176 len, &offset, 0);
53177 if (retval > 0)
53178 retval = 0;
53179 diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
53180 index 94de6d1..8d81256 100644
53181 --- a/fs/9p/vfs_inode.c
53182 +++ b/fs/9p/vfs_inode.c
53183 @@ -1312,7 +1312,7 @@ static void *v9fs_vfs_follow_link(struct dentry *dentry, struct nameidata *nd)
53184 void
53185 v9fs_vfs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
53186 {
53187 - char *s = nd_get_link(nd);
53188 + const char *s = nd_get_link(nd);
53189
53190 p9_debug(P9_DEBUG_VFS, " %s %s\n",
53191 dentry->d_name.name, IS_ERR(s) ? "<error>" : s);
53192 diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt
53193 index 370b24c..ff0be7b 100644
53194 --- a/fs/Kconfig.binfmt
53195 +++ b/fs/Kconfig.binfmt
53196 @@ -103,7 +103,7 @@ config HAVE_AOUT
53197
53198 config BINFMT_AOUT
53199 tristate "Kernel support for a.out and ECOFF binaries"
53200 - depends on HAVE_AOUT
53201 + depends on HAVE_AOUT && BROKEN
53202 ---help---
53203 A.out (Assembler.OUTput) is a set of formats for libraries and
53204 executables used in the earliest versions of UNIX. Linux used
53205 diff --git a/fs/afs/inode.c b/fs/afs/inode.c
53206 index 789bc25..fafaeea 100644
53207 --- a/fs/afs/inode.c
53208 +++ b/fs/afs/inode.c
53209 @@ -141,7 +141,7 @@ struct inode *afs_iget_autocell(struct inode *dir, const char *dev_name,
53210 struct afs_vnode *vnode;
53211 struct super_block *sb;
53212 struct inode *inode;
53213 - static atomic_t afs_autocell_ino;
53214 + static atomic_unchecked_t afs_autocell_ino;
53215
53216 _enter("{%x:%u},%*.*s,",
53217 AFS_FS_I(dir)->fid.vid, AFS_FS_I(dir)->fid.vnode,
53218 @@ -154,7 +154,7 @@ struct inode *afs_iget_autocell(struct inode *dir, const char *dev_name,
53219 data.fid.unique = 0;
53220 data.fid.vnode = 0;
53221
53222 - inode = iget5_locked(sb, atomic_inc_return(&afs_autocell_ino),
53223 + inode = iget5_locked(sb, atomic_inc_return_unchecked(&afs_autocell_ino),
53224 afs_iget5_autocell_test, afs_iget5_set,
53225 &data);
53226 if (!inode) {
53227 diff --git a/fs/aio.c b/fs/aio.c
53228 index 6efb7f6..37da952 100644
53229 --- a/fs/aio.c
53230 +++ b/fs/aio.c
53231 @@ -338,7 +338,7 @@ static int aio_setup_ring(struct kioctx *ctx)
53232 size += sizeof(struct io_event) * nr_events;
53233
53234 nr_pages = PFN_UP(size);
53235 - if (nr_pages < 0)
53236 + if (nr_pages <= 0)
53237 return -EINVAL;
53238
53239 file = aio_private_file(ctx, nr_pages);
53240 diff --git a/fs/attr.c b/fs/attr.c
53241 index 1449adb..a2038c2 100644
53242 --- a/fs/attr.c
53243 +++ b/fs/attr.c
53244 @@ -102,6 +102,7 @@ int inode_newsize_ok(const struct inode *inode, loff_t offset)
53245 unsigned long limit;
53246
53247 limit = rlimit(RLIMIT_FSIZE);
53248 + gr_learn_resource(current, RLIMIT_FSIZE, (unsigned long)offset, 1);
53249 if (limit != RLIM_INFINITY && offset > limit)
53250 goto out_sig;
53251 if (offset > inode->i_sb->s_maxbytes)
53252 diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c
53253 index 689e40d..515cac5 100644
53254 --- a/fs/autofs4/waitq.c
53255 +++ b/fs/autofs4/waitq.c
53256 @@ -59,7 +59,7 @@ static int autofs4_write(struct autofs_sb_info *sbi,
53257 {
53258 unsigned long sigpipe, flags;
53259 mm_segment_t fs;
53260 - const char *data = (const char *)addr;
53261 + const char __user *data = (const char __force_user *)addr;
53262 ssize_t wr = 0;
53263
53264 sigpipe = sigismember(&current->pending.signal, SIGPIPE);
53265 @@ -340,6 +340,10 @@ static int validate_request(struct autofs_wait_queue **wait,
53266 return 1;
53267 }
53268
53269 +#ifdef CONFIG_GRKERNSEC_HIDESYM
53270 +static atomic_unchecked_t autofs_dummy_name_id = ATOMIC_INIT(0);
53271 +#endif
53272 +
53273 int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
53274 enum autofs_notify notify)
53275 {
53276 @@ -373,7 +377,12 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
53277
53278 /* If this is a direct mount request create a dummy name */
53279 if (IS_ROOT(dentry) && autofs_type_trigger(sbi->type))
53280 +#ifdef CONFIG_GRKERNSEC_HIDESYM
53281 + /* this name does get written to userland via autofs4_write() */
53282 + qstr.len = sprintf(name, "%08x", atomic_inc_return_unchecked(&autofs_dummy_name_id));
53283 +#else
53284 qstr.len = sprintf(name, "%p", dentry);
53285 +#endif
53286 else {
53287 qstr.len = autofs4_getpath(sbi, dentry, &name);
53288 if (!qstr.len) {
53289 diff --git a/fs/befs/endian.h b/fs/befs/endian.h
53290 index 2722387..56059b5 100644
53291 --- a/fs/befs/endian.h
53292 +++ b/fs/befs/endian.h
53293 @@ -11,7 +11,7 @@
53294
53295 #include <asm/byteorder.h>
53296
53297 -static inline u64
53298 +static inline u64 __intentional_overflow(-1)
53299 fs64_to_cpu(const struct super_block *sb, fs64 n)
53300 {
53301 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
53302 @@ -29,7 +29,7 @@ cpu_to_fs64(const struct super_block *sb, u64 n)
53303 return (__force fs64)cpu_to_be64(n);
53304 }
53305
53306 -static inline u32
53307 +static inline u32 __intentional_overflow(-1)
53308 fs32_to_cpu(const struct super_block *sb, fs32 n)
53309 {
53310 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
53311 @@ -47,7 +47,7 @@ cpu_to_fs32(const struct super_block *sb, u32 n)
53312 return (__force fs32)cpu_to_be32(n);
53313 }
53314
53315 -static inline u16
53316 +static inline u16 __intentional_overflow(-1)
53317 fs16_to_cpu(const struct super_block *sb, fs16 n)
53318 {
53319 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
53320 diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
53321 index e9c75e2..1baece1 100644
53322 --- a/fs/befs/linuxvfs.c
53323 +++ b/fs/befs/linuxvfs.c
53324 @@ -514,7 +514,7 @@ static void befs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
53325 {
53326 befs_inode_info *befs_ino = BEFS_I(dentry->d_inode);
53327 if (befs_ino->i_flags & BEFS_LONG_SYMLINK) {
53328 - char *link = nd_get_link(nd);
53329 + const char *link = nd_get_link(nd);
53330 if (!IS_ERR(link))
53331 kfree(link);
53332 }
53333 diff --git a/fs/binfmt_aout.c b/fs/binfmt_aout.c
53334 index 89dec7f..361b0d75 100644
53335 --- a/fs/binfmt_aout.c
53336 +++ b/fs/binfmt_aout.c
53337 @@ -16,6 +16,7 @@
53338 #include <linux/string.h>
53339 #include <linux/fs.h>
53340 #include <linux/file.h>
53341 +#include <linux/security.h>
53342 #include <linux/stat.h>
53343 #include <linux/fcntl.h>
53344 #include <linux/ptrace.h>
53345 @@ -59,6 +60,8 @@ static int aout_core_dump(struct coredump_params *cprm)
53346 #endif
53347 # define START_STACK(u) ((void __user *)u.start_stack)
53348
53349 + memset(&dump, 0, sizeof(dump));
53350 +
53351 fs = get_fs();
53352 set_fs(KERNEL_DS);
53353 has_dumped = 1;
53354 @@ -69,10 +72,12 @@ static int aout_core_dump(struct coredump_params *cprm)
53355
53356 /* If the size of the dump file exceeds the rlimit, then see what would happen
53357 if we wrote the stack, but not the data area. */
53358 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE, 1);
53359 if ((dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE > cprm->limit)
53360 dump.u_dsize = 0;
53361
53362 /* Make sure we have enough room to write the stack and data areas. */
53363 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_ssize + 1) * PAGE_SIZE, 1);
53364 if ((dump.u_ssize + 1) * PAGE_SIZE > cprm->limit)
53365 dump.u_ssize = 0;
53366
53367 @@ -233,6 +238,8 @@ static int load_aout_binary(struct linux_binprm * bprm)
53368 rlim = rlimit(RLIMIT_DATA);
53369 if (rlim >= RLIM_INFINITY)
53370 rlim = ~0;
53371 +
53372 + gr_learn_resource(current, RLIMIT_DATA, ex.a_data + ex.a_bss, 1);
53373 if (ex.a_data + ex.a_bss > rlim)
53374 return -ENOMEM;
53375
53376 @@ -265,6 +272,27 @@ static int load_aout_binary(struct linux_binprm * bprm)
53377
53378 install_exec_creds(bprm);
53379
53380 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
53381 + current->mm->pax_flags = 0UL;
53382 +#endif
53383 +
53384 +#ifdef CONFIG_PAX_PAGEEXEC
53385 + if (!(N_FLAGS(ex) & F_PAX_PAGEEXEC)) {
53386 + current->mm->pax_flags |= MF_PAX_PAGEEXEC;
53387 +
53388 +#ifdef CONFIG_PAX_EMUTRAMP
53389 + if (N_FLAGS(ex) & F_PAX_EMUTRAMP)
53390 + current->mm->pax_flags |= MF_PAX_EMUTRAMP;
53391 +#endif
53392 +
53393 +#ifdef CONFIG_PAX_MPROTECT
53394 + if (!(N_FLAGS(ex) & F_PAX_MPROTECT))
53395 + current->mm->pax_flags |= MF_PAX_MPROTECT;
53396 +#endif
53397 +
53398 + }
53399 +#endif
53400 +
53401 if (N_MAGIC(ex) == OMAGIC) {
53402 unsigned long text_addr, map_size;
53403 loff_t pos;
53404 @@ -322,7 +350,7 @@ static int load_aout_binary(struct linux_binprm * bprm)
53405 }
53406
53407 error = vm_mmap(bprm->file, N_DATADDR(ex), ex.a_data,
53408 - PROT_READ | PROT_WRITE | PROT_EXEC,
53409 + PROT_READ | PROT_WRITE,
53410 MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE | MAP_EXECUTABLE,
53411 fd_offset + ex.a_text);
53412 if (error != N_DATADDR(ex)) {
53413 diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
53414 index 4c94a79..228e9da 100644
53415 --- a/fs/binfmt_elf.c
53416 +++ b/fs/binfmt_elf.c
53417 @@ -34,6 +34,7 @@
53418 #include <linux/utsname.h>
53419 #include <linux/coredump.h>
53420 #include <linux/sched.h>
53421 +#include <linux/xattr.h>
53422 #include <asm/uaccess.h>
53423 #include <asm/param.h>
53424 #include <asm/page.h>
53425 @@ -60,6 +61,14 @@ static int elf_core_dump(struct coredump_params *cprm);
53426 #define elf_core_dump NULL
53427 #endif
53428
53429 +#ifdef CONFIG_PAX_MPROTECT
53430 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags);
53431 +#endif
53432 +
53433 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
53434 +static void elf_handle_mmap(struct file *file);
53435 +#endif
53436 +
53437 #if ELF_EXEC_PAGESIZE > PAGE_SIZE
53438 #define ELF_MIN_ALIGN ELF_EXEC_PAGESIZE
53439 #else
53440 @@ -79,6 +88,15 @@ static struct linux_binfmt elf_format = {
53441 .load_binary = load_elf_binary,
53442 .load_shlib = load_elf_library,
53443 .core_dump = elf_core_dump,
53444 +
53445 +#ifdef CONFIG_PAX_MPROTECT
53446 + .handle_mprotect= elf_handle_mprotect,
53447 +#endif
53448 +
53449 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
53450 + .handle_mmap = elf_handle_mmap,
53451 +#endif
53452 +
53453 .min_coredump = ELF_EXEC_PAGESIZE,
53454 };
53455
53456 @@ -86,6 +104,8 @@ static struct linux_binfmt elf_format = {
53457
53458 static int set_brk(unsigned long start, unsigned long end)
53459 {
53460 + unsigned long e = end;
53461 +
53462 start = ELF_PAGEALIGN(start);
53463 end = ELF_PAGEALIGN(end);
53464 if (end > start) {
53465 @@ -94,7 +114,7 @@ static int set_brk(unsigned long start, unsigned long end)
53466 if (BAD_ADDR(addr))
53467 return addr;
53468 }
53469 - current->mm->start_brk = current->mm->brk = end;
53470 + current->mm->start_brk = current->mm->brk = e;
53471 return 0;
53472 }
53473
53474 @@ -155,12 +175,13 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
53475 elf_addr_t __user *u_rand_bytes;
53476 const char *k_platform = ELF_PLATFORM;
53477 const char *k_base_platform = ELF_BASE_PLATFORM;
53478 - unsigned char k_rand_bytes[16];
53479 + u32 k_rand_bytes[4];
53480 int items;
53481 elf_addr_t *elf_info;
53482 int ei_index = 0;
53483 const struct cred *cred = current_cred();
53484 struct vm_area_struct *vma;
53485 + unsigned long saved_auxv[AT_VECTOR_SIZE];
53486
53487 /*
53488 * In some cases (e.g. Hyper-Threading), we want to avoid L1
53489 @@ -202,8 +223,12 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
53490 * Generate 16 random bytes for userspace PRNG seeding.
53491 */
53492 get_random_bytes(k_rand_bytes, sizeof(k_rand_bytes));
53493 - u_rand_bytes = (elf_addr_t __user *)
53494 - STACK_ALLOC(p, sizeof(k_rand_bytes));
53495 + prandom_seed(k_rand_bytes[0] ^ prandom_u32());
53496 + prandom_seed(k_rand_bytes[1] ^ prandom_u32());
53497 + prandom_seed(k_rand_bytes[2] ^ prandom_u32());
53498 + prandom_seed(k_rand_bytes[3] ^ prandom_u32());
53499 + p = STACK_ROUND(p, sizeof(k_rand_bytes));
53500 + u_rand_bytes = (elf_addr_t __user *) p;
53501 if (__copy_to_user(u_rand_bytes, k_rand_bytes, sizeof(k_rand_bytes)))
53502 return -EFAULT;
53503
53504 @@ -318,9 +343,11 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
53505 return -EFAULT;
53506 current->mm->env_end = p;
53507
53508 + memcpy(saved_auxv, elf_info, ei_index * sizeof(elf_addr_t));
53509 +
53510 /* Put the elf_info on the stack in the right place. */
53511 sp = (elf_addr_t __user *)envp + 1;
53512 - if (copy_to_user(sp, elf_info, ei_index * sizeof(elf_addr_t)))
53513 + if (copy_to_user(sp, saved_auxv, ei_index * sizeof(elf_addr_t)))
53514 return -EFAULT;
53515 return 0;
53516 }
53517 @@ -388,15 +415,14 @@ static unsigned long total_mapping_size(struct elf_phdr *cmds, int nr)
53518 an ELF header */
53519
53520 static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
53521 - struct file *interpreter, unsigned long *interp_map_addr,
53522 - unsigned long no_base)
53523 + struct file *interpreter, unsigned long no_base)
53524 {
53525 struct elf_phdr *elf_phdata;
53526 struct elf_phdr *eppnt;
53527 - unsigned long load_addr = 0;
53528 + unsigned long load_addr = 0, pax_task_size = TASK_SIZE;
53529 int load_addr_set = 0;
53530 unsigned long last_bss = 0, elf_bss = 0;
53531 - unsigned long error = ~0UL;
53532 + unsigned long error = -EINVAL;
53533 unsigned long total_size;
53534 int retval, i, size;
53535
53536 @@ -442,6 +468,11 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
53537 goto out_close;
53538 }
53539
53540 +#ifdef CONFIG_PAX_SEGMEXEC
53541 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
53542 + pax_task_size = SEGMEXEC_TASK_SIZE;
53543 +#endif
53544 +
53545 eppnt = elf_phdata;
53546 for (i = 0; i < interp_elf_ex->e_phnum; i++, eppnt++) {
53547 if (eppnt->p_type == PT_LOAD) {
53548 @@ -465,8 +496,6 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
53549 map_addr = elf_map(interpreter, load_addr + vaddr,
53550 eppnt, elf_prot, elf_type, total_size);
53551 total_size = 0;
53552 - if (!*interp_map_addr)
53553 - *interp_map_addr = map_addr;
53554 error = map_addr;
53555 if (BAD_ADDR(map_addr))
53556 goto out_close;
53557 @@ -485,8 +514,8 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
53558 k = load_addr + eppnt->p_vaddr;
53559 if (BAD_ADDR(k) ||
53560 eppnt->p_filesz > eppnt->p_memsz ||
53561 - eppnt->p_memsz > TASK_SIZE ||
53562 - TASK_SIZE - eppnt->p_memsz < k) {
53563 + eppnt->p_memsz > pax_task_size ||
53564 + pax_task_size - eppnt->p_memsz < k) {
53565 error = -ENOMEM;
53566 goto out_close;
53567 }
53568 @@ -525,9 +554,11 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
53569 elf_bss = ELF_PAGESTART(elf_bss + ELF_MIN_ALIGN - 1);
53570
53571 /* Map the last of the bss segment */
53572 - error = vm_brk(elf_bss, last_bss - elf_bss);
53573 - if (BAD_ADDR(error))
53574 - goto out_close;
53575 + if (last_bss > elf_bss) {
53576 + error = vm_brk(elf_bss, last_bss - elf_bss);
53577 + if (BAD_ADDR(error))
53578 + goto out_close;
53579 + }
53580 }
53581
53582 error = load_addr;
53583 @@ -538,6 +569,322 @@ out:
53584 return error;
53585 }
53586
53587 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
53588 +#ifdef CONFIG_PAX_SOFTMODE
53589 +static unsigned long pax_parse_pt_pax_softmode(const struct elf_phdr * const elf_phdata)
53590 +{
53591 + unsigned long pax_flags = 0UL;
53592 +
53593 +#ifdef CONFIG_PAX_PAGEEXEC
53594 + if (elf_phdata->p_flags & PF_PAGEEXEC)
53595 + pax_flags |= MF_PAX_PAGEEXEC;
53596 +#endif
53597 +
53598 +#ifdef CONFIG_PAX_SEGMEXEC
53599 + if (elf_phdata->p_flags & PF_SEGMEXEC)
53600 + pax_flags |= MF_PAX_SEGMEXEC;
53601 +#endif
53602 +
53603 +#ifdef CONFIG_PAX_EMUTRAMP
53604 + if ((elf_phdata->p_flags & PF_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
53605 + pax_flags |= MF_PAX_EMUTRAMP;
53606 +#endif
53607 +
53608 +#ifdef CONFIG_PAX_MPROTECT
53609 + if (elf_phdata->p_flags & PF_MPROTECT)
53610 + pax_flags |= MF_PAX_MPROTECT;
53611 +#endif
53612 +
53613 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
53614 + if (randomize_va_space && (elf_phdata->p_flags & PF_RANDMMAP))
53615 + pax_flags |= MF_PAX_RANDMMAP;
53616 +#endif
53617 +
53618 + return pax_flags;
53619 +}
53620 +#endif
53621 +
53622 +static unsigned long pax_parse_pt_pax_hardmode(const struct elf_phdr * const elf_phdata)
53623 +{
53624 + unsigned long pax_flags = 0UL;
53625 +
53626 +#ifdef CONFIG_PAX_PAGEEXEC
53627 + if (!(elf_phdata->p_flags & PF_NOPAGEEXEC))
53628 + pax_flags |= MF_PAX_PAGEEXEC;
53629 +#endif
53630 +
53631 +#ifdef CONFIG_PAX_SEGMEXEC
53632 + if (!(elf_phdata->p_flags & PF_NOSEGMEXEC))
53633 + pax_flags |= MF_PAX_SEGMEXEC;
53634 +#endif
53635 +
53636 +#ifdef CONFIG_PAX_EMUTRAMP
53637 + if (!(elf_phdata->p_flags & PF_NOEMUTRAMP))
53638 + pax_flags |= MF_PAX_EMUTRAMP;
53639 +#endif
53640 +
53641 +#ifdef CONFIG_PAX_MPROTECT
53642 + if (!(elf_phdata->p_flags & PF_NOMPROTECT))
53643 + pax_flags |= MF_PAX_MPROTECT;
53644 +#endif
53645 +
53646 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
53647 + if (randomize_va_space && !(elf_phdata->p_flags & PF_NORANDMMAP))
53648 + pax_flags |= MF_PAX_RANDMMAP;
53649 +#endif
53650 +
53651 + return pax_flags;
53652 +}
53653 +#endif
53654 +
53655 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
53656 +#ifdef CONFIG_PAX_SOFTMODE
53657 +static unsigned long pax_parse_xattr_pax_softmode(unsigned long pax_flags_softmode)
53658 +{
53659 + unsigned long pax_flags = 0UL;
53660 +
53661 +#ifdef CONFIG_PAX_PAGEEXEC
53662 + if (pax_flags_softmode & MF_PAX_PAGEEXEC)
53663 + pax_flags |= MF_PAX_PAGEEXEC;
53664 +#endif
53665 +
53666 +#ifdef CONFIG_PAX_SEGMEXEC
53667 + if (pax_flags_softmode & MF_PAX_SEGMEXEC)
53668 + pax_flags |= MF_PAX_SEGMEXEC;
53669 +#endif
53670 +
53671 +#ifdef CONFIG_PAX_EMUTRAMP
53672 + if ((pax_flags_softmode & MF_PAX_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
53673 + pax_flags |= MF_PAX_EMUTRAMP;
53674 +#endif
53675 +
53676 +#ifdef CONFIG_PAX_MPROTECT
53677 + if (pax_flags_softmode & MF_PAX_MPROTECT)
53678 + pax_flags |= MF_PAX_MPROTECT;
53679 +#endif
53680 +
53681 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
53682 + if (randomize_va_space && (pax_flags_softmode & MF_PAX_RANDMMAP))
53683 + pax_flags |= MF_PAX_RANDMMAP;
53684 +#endif
53685 +
53686 + return pax_flags;
53687 +}
53688 +#endif
53689 +
53690 +static unsigned long pax_parse_xattr_pax_hardmode(unsigned long pax_flags_hardmode)
53691 +{
53692 + unsigned long pax_flags = 0UL;
53693 +
53694 +#ifdef CONFIG_PAX_PAGEEXEC
53695 + if (!(pax_flags_hardmode & MF_PAX_PAGEEXEC))
53696 + pax_flags |= MF_PAX_PAGEEXEC;
53697 +#endif
53698 +
53699 +#ifdef CONFIG_PAX_SEGMEXEC
53700 + if (!(pax_flags_hardmode & MF_PAX_SEGMEXEC))
53701 + pax_flags |= MF_PAX_SEGMEXEC;
53702 +#endif
53703 +
53704 +#ifdef CONFIG_PAX_EMUTRAMP
53705 + if (!(pax_flags_hardmode & MF_PAX_EMUTRAMP))
53706 + pax_flags |= MF_PAX_EMUTRAMP;
53707 +#endif
53708 +
53709 +#ifdef CONFIG_PAX_MPROTECT
53710 + if (!(pax_flags_hardmode & MF_PAX_MPROTECT))
53711 + pax_flags |= MF_PAX_MPROTECT;
53712 +#endif
53713 +
53714 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
53715 + if (randomize_va_space && !(pax_flags_hardmode & MF_PAX_RANDMMAP))
53716 + pax_flags |= MF_PAX_RANDMMAP;
53717 +#endif
53718 +
53719 + return pax_flags;
53720 +}
53721 +#endif
53722 +
53723 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
53724 +static unsigned long pax_parse_ei_pax(const struct elfhdr * const elf_ex)
53725 +{
53726 + unsigned long pax_flags = 0UL;
53727 +
53728 +#ifdef CONFIG_PAX_EI_PAX
53729 +
53730 +#ifdef CONFIG_PAX_PAGEEXEC
53731 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_PAGEEXEC))
53732 + pax_flags |= MF_PAX_PAGEEXEC;
53733 +#endif
53734 +
53735 +#ifdef CONFIG_PAX_SEGMEXEC
53736 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_SEGMEXEC))
53737 + pax_flags |= MF_PAX_SEGMEXEC;
53738 +#endif
53739 +
53740 +#ifdef CONFIG_PAX_EMUTRAMP
53741 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && (elf_ex->e_ident[EI_PAX] & EF_PAX_EMUTRAMP))
53742 + pax_flags |= MF_PAX_EMUTRAMP;
53743 +#endif
53744 +
53745 +#ifdef CONFIG_PAX_MPROTECT
53746 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && !(elf_ex->e_ident[EI_PAX] & EF_PAX_MPROTECT))
53747 + pax_flags |= MF_PAX_MPROTECT;
53748 +#endif
53749 +
53750 +#ifdef CONFIG_PAX_ASLR
53751 + if (randomize_va_space && !(elf_ex->e_ident[EI_PAX] & EF_PAX_RANDMMAP))
53752 + pax_flags |= MF_PAX_RANDMMAP;
53753 +#endif
53754 +
53755 +#else
53756 +
53757 +#ifdef CONFIG_PAX_PAGEEXEC
53758 + pax_flags |= MF_PAX_PAGEEXEC;
53759 +#endif
53760 +
53761 +#ifdef CONFIG_PAX_SEGMEXEC
53762 + pax_flags |= MF_PAX_SEGMEXEC;
53763 +#endif
53764 +
53765 +#ifdef CONFIG_PAX_MPROTECT
53766 + pax_flags |= MF_PAX_MPROTECT;
53767 +#endif
53768 +
53769 +#ifdef CONFIG_PAX_RANDMMAP
53770 + if (randomize_va_space)
53771 + pax_flags |= MF_PAX_RANDMMAP;
53772 +#endif
53773 +
53774 +#endif
53775 +
53776 + return pax_flags;
53777 +}
53778 +
53779 +static unsigned long pax_parse_pt_pax(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata)
53780 +{
53781 +
53782 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
53783 + unsigned long i;
53784 +
53785 + for (i = 0UL; i < elf_ex->e_phnum; i++)
53786 + if (elf_phdata[i].p_type == PT_PAX_FLAGS) {
53787 + if (((elf_phdata[i].p_flags & PF_PAGEEXEC) && (elf_phdata[i].p_flags & PF_NOPAGEEXEC)) ||
53788 + ((elf_phdata[i].p_flags & PF_SEGMEXEC) && (elf_phdata[i].p_flags & PF_NOSEGMEXEC)) ||
53789 + ((elf_phdata[i].p_flags & PF_EMUTRAMP) && (elf_phdata[i].p_flags & PF_NOEMUTRAMP)) ||
53790 + ((elf_phdata[i].p_flags & PF_MPROTECT) && (elf_phdata[i].p_flags & PF_NOMPROTECT)) ||
53791 + ((elf_phdata[i].p_flags & PF_RANDMMAP) && (elf_phdata[i].p_flags & PF_NORANDMMAP)))
53792 + return ~0UL;
53793 +
53794 +#ifdef CONFIG_PAX_SOFTMODE
53795 + if (pax_softmode)
53796 + return pax_parse_pt_pax_softmode(&elf_phdata[i]);
53797 + else
53798 +#endif
53799 +
53800 + return pax_parse_pt_pax_hardmode(&elf_phdata[i]);
53801 + break;
53802 + }
53803 +#endif
53804 +
53805 + return ~0UL;
53806 +}
53807 +
53808 +static unsigned long pax_parse_xattr_pax(struct file * const file)
53809 +{
53810 +
53811 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
53812 + ssize_t xattr_size, i;
53813 + unsigned char xattr_value[sizeof("pemrs") - 1];
53814 + unsigned long pax_flags_hardmode = 0UL, pax_flags_softmode = 0UL;
53815 +
53816 + xattr_size = pax_getxattr(file->f_path.dentry, xattr_value, sizeof xattr_value);
53817 + switch (xattr_size) {
53818 + default:
53819 + return ~0UL;
53820 +
53821 + case -ENODATA:
53822 + break;
53823 +
53824 + case 0 ... sizeof xattr_value:
53825 + for (i = 0; i < xattr_size; i++)
53826 + switch (xattr_value[i]) {
53827 + default:
53828 + return ~0UL;
53829 +
53830 +#define parse_flag(option1, option2, flag) \
53831 + case option1: \
53832 + if (pax_flags_hardmode & MF_PAX_##flag) \
53833 + return ~0UL; \
53834 + pax_flags_hardmode |= MF_PAX_##flag; \
53835 + break; \
53836 + case option2: \
53837 + if (pax_flags_softmode & MF_PAX_##flag) \
53838 + return ~0UL; \
53839 + pax_flags_softmode |= MF_PAX_##flag; \
53840 + break;
53841 +
53842 + parse_flag('p', 'P', PAGEEXEC);
53843 + parse_flag('e', 'E', EMUTRAMP);
53844 + parse_flag('m', 'M', MPROTECT);
53845 + parse_flag('r', 'R', RANDMMAP);
53846 + parse_flag('s', 'S', SEGMEXEC);
53847 +
53848 +#undef parse_flag
53849 + }
53850 + break;
53851 + }
53852 +
53853 + if (pax_flags_hardmode & pax_flags_softmode)
53854 + return ~0UL;
53855 +
53856 +#ifdef CONFIG_PAX_SOFTMODE
53857 + if (pax_softmode)
53858 + return pax_parse_xattr_pax_softmode(pax_flags_softmode);
53859 + else
53860 +#endif
53861 +
53862 + return pax_parse_xattr_pax_hardmode(pax_flags_hardmode);
53863 +#else
53864 + return ~0UL;
53865 +#endif
53866 +
53867 +}
53868 +
53869 +static long pax_parse_pax_flags(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata, struct file * const file)
53870 +{
53871 + unsigned long pax_flags, pt_pax_flags, xattr_pax_flags;
53872 +
53873 + pax_flags = pax_parse_ei_pax(elf_ex);
53874 + pt_pax_flags = pax_parse_pt_pax(elf_ex, elf_phdata);
53875 + xattr_pax_flags = pax_parse_xattr_pax(file);
53876 +
53877 + if (pt_pax_flags == ~0UL)
53878 + pt_pax_flags = xattr_pax_flags;
53879 + else if (xattr_pax_flags == ~0UL)
53880 + xattr_pax_flags = pt_pax_flags;
53881 + if (pt_pax_flags != xattr_pax_flags)
53882 + return -EINVAL;
53883 + if (pt_pax_flags != ~0UL)
53884 + pax_flags = pt_pax_flags;
53885 +
53886 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_PAX_SEGMEXEC)
53887 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) == (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
53888 + if ((__supported_pte_mask & _PAGE_NX))
53889 + pax_flags &= ~MF_PAX_SEGMEXEC;
53890 + else
53891 + pax_flags &= ~MF_PAX_PAGEEXEC;
53892 + }
53893 +#endif
53894 +
53895 + if (0 > pax_check_flags(&pax_flags))
53896 + return -EINVAL;
53897 +
53898 + current->mm->pax_flags = pax_flags;
53899 + return 0;
53900 +}
53901 +#endif
53902 +
53903 /*
53904 * These are the functions used to load ELF style executables and shared
53905 * libraries. There is no binary dependent code anywhere else.
53906 @@ -554,6 +901,11 @@ static unsigned long randomize_stack_top(unsigned long stack_top)
53907 {
53908 unsigned int random_variable = 0;
53909
53910 +#ifdef CONFIG_PAX_RANDUSTACK
53911 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
53912 + return stack_top - current->mm->delta_stack;
53913 +#endif
53914 +
53915 if ((current->flags & PF_RANDOMIZE) &&
53916 !(current->personality & ADDR_NO_RANDOMIZE)) {
53917 random_variable = get_random_int() & STACK_RND_MASK;
53918 @@ -572,7 +924,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
53919 unsigned long load_addr = 0, load_bias = 0;
53920 int load_addr_set = 0;
53921 char * elf_interpreter = NULL;
53922 - unsigned long error;
53923 + unsigned long error = 0;
53924 struct elf_phdr *elf_ppnt, *elf_phdata;
53925 unsigned long elf_bss, elf_brk;
53926 int retval, i;
53927 @@ -582,12 +934,12 @@ static int load_elf_binary(struct linux_binprm *bprm)
53928 unsigned long start_code, end_code, start_data, end_data;
53929 unsigned long reloc_func_desc __maybe_unused = 0;
53930 int executable_stack = EXSTACK_DEFAULT;
53931 - unsigned long def_flags = 0;
53932 struct pt_regs *regs = current_pt_regs();
53933 struct {
53934 struct elfhdr elf_ex;
53935 struct elfhdr interp_elf_ex;
53936 } *loc;
53937 + unsigned long pax_task_size;
53938
53939 loc = kmalloc(sizeof(*loc), GFP_KERNEL);
53940 if (!loc) {
53941 @@ -723,11 +1075,82 @@ static int load_elf_binary(struct linux_binprm *bprm)
53942 goto out_free_dentry;
53943
53944 /* OK, This is the point of no return */
53945 - current->mm->def_flags = def_flags;
53946 + current->mm->def_flags = 0;
53947
53948 /* Do this immediately, since STACK_TOP as used in setup_arg_pages
53949 may depend on the personality. */
53950 SET_PERSONALITY(loc->elf_ex);
53951 +
53952 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
53953 + current->mm->pax_flags = 0UL;
53954 +#endif
53955 +
53956 +#ifdef CONFIG_PAX_DLRESOLVE
53957 + current->mm->call_dl_resolve = 0UL;
53958 +#endif
53959 +
53960 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
53961 + current->mm->call_syscall = 0UL;
53962 +#endif
53963 +
53964 +#ifdef CONFIG_PAX_ASLR
53965 + current->mm->delta_mmap = 0UL;
53966 + current->mm->delta_stack = 0UL;
53967 +#endif
53968 +
53969 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
53970 + if (0 > pax_parse_pax_flags(&loc->elf_ex, elf_phdata, bprm->file)) {
53971 + send_sig(SIGKILL, current, 0);
53972 + goto out_free_dentry;
53973 + }
53974 +#endif
53975 +
53976 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
53977 + pax_set_initial_flags(bprm);
53978 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
53979 + if (pax_set_initial_flags_func)
53980 + (pax_set_initial_flags_func)(bprm);
53981 +#endif
53982 +
53983 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
53984 + if ((current->mm->pax_flags & MF_PAX_PAGEEXEC) && !(__supported_pte_mask & _PAGE_NX)) {
53985 + current->mm->context.user_cs_limit = PAGE_SIZE;
53986 + current->mm->def_flags |= VM_PAGEEXEC | VM_NOHUGEPAGE;
53987 + }
53988 +#endif
53989 +
53990 +#ifdef CONFIG_PAX_SEGMEXEC
53991 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
53992 + current->mm->context.user_cs_base = SEGMEXEC_TASK_SIZE;
53993 + current->mm->context.user_cs_limit = TASK_SIZE-SEGMEXEC_TASK_SIZE;
53994 + pax_task_size = SEGMEXEC_TASK_SIZE;
53995 + current->mm->def_flags |= VM_NOHUGEPAGE;
53996 + } else
53997 +#endif
53998 +
53999 + pax_task_size = TASK_SIZE;
54000 +
54001 +#if defined(CONFIG_ARCH_TRACK_EXEC_LIMIT) || defined(CONFIG_PAX_SEGMEXEC)
54002 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
54003 + set_user_cs(current->mm->context.user_cs_base, current->mm->context.user_cs_limit, get_cpu());
54004 + put_cpu();
54005 + }
54006 +#endif
54007 +
54008 +#ifdef CONFIG_PAX_ASLR
54009 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
54010 + current->mm->delta_mmap = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN)-1)) << PAGE_SHIFT;
54011 + current->mm->delta_stack = (pax_get_random_long() & ((1UL << PAX_DELTA_STACK_LEN)-1)) << PAGE_SHIFT;
54012 + }
54013 +#endif
54014 +
54015 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
54016 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
54017 + executable_stack = EXSTACK_DISABLE_X;
54018 + current->personality &= ~READ_IMPLIES_EXEC;
54019 + } else
54020 +#endif
54021 +
54022 if (elf_read_implies_exec(loc->elf_ex, executable_stack))
54023 current->personality |= READ_IMPLIES_EXEC;
54024
54025 @@ -817,6 +1240,20 @@ static int load_elf_binary(struct linux_binprm *bprm)
54026 #else
54027 load_bias = ELF_PAGESTART(ELF_ET_DYN_BASE - vaddr);
54028 #endif
54029 +
54030 +#ifdef CONFIG_PAX_RANDMMAP
54031 + /* PaX: randomize base address at the default exe base if requested */
54032 + if ((current->mm->pax_flags & MF_PAX_RANDMMAP) && elf_interpreter) {
54033 +#ifdef CONFIG_SPARC64
54034 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << (PAGE_SHIFT+1);
54035 +#else
54036 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << PAGE_SHIFT;
54037 +#endif
54038 + load_bias = ELF_PAGESTART(PAX_ELF_ET_DYN_BASE - vaddr + load_bias);
54039 + elf_flags |= MAP_FIXED;
54040 + }
54041 +#endif
54042 +
54043 }
54044
54045 error = elf_map(bprm->file, load_bias + vaddr, elf_ppnt,
54046 @@ -849,9 +1286,9 @@ static int load_elf_binary(struct linux_binprm *bprm)
54047 * allowed task size. Note that p_filesz must always be
54048 * <= p_memsz so it is only necessary to check p_memsz.
54049 */
54050 - if (BAD_ADDR(k) || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
54051 - elf_ppnt->p_memsz > TASK_SIZE ||
54052 - TASK_SIZE - elf_ppnt->p_memsz < k) {
54053 + if (k >= pax_task_size || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
54054 + elf_ppnt->p_memsz > pax_task_size ||
54055 + pax_task_size - elf_ppnt->p_memsz < k) {
54056 /* set_brk can never work. Avoid overflows. */
54057 send_sig(SIGKILL, current, 0);
54058 retval = -EINVAL;
54059 @@ -890,17 +1327,45 @@ static int load_elf_binary(struct linux_binprm *bprm)
54060 goto out_free_dentry;
54061 }
54062 if (likely(elf_bss != elf_brk) && unlikely(padzero(elf_bss))) {
54063 - send_sig(SIGSEGV, current, 0);
54064 - retval = -EFAULT; /* Nobody gets to see this, but.. */
54065 - goto out_free_dentry;
54066 + /*
54067 + * This bss-zeroing can fail if the ELF
54068 + * file specifies odd protections. So
54069 + * we don't check the return value
54070 + */
54071 }
54072
54073 +#ifdef CONFIG_PAX_RANDMMAP
54074 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
54075 + unsigned long start, size, flags;
54076 + vm_flags_t vm_flags;
54077 +
54078 + start = ELF_PAGEALIGN(elf_brk);
54079 + size = PAGE_SIZE + ((pax_get_random_long() & ((1UL << 22) - 1UL)) << 4);
54080 + flags = MAP_FIXED | MAP_PRIVATE;
54081 + vm_flags = VM_DONTEXPAND | VM_DONTDUMP;
54082 +
54083 + down_write(&current->mm->mmap_sem);
54084 + start = get_unmapped_area(NULL, start, PAGE_ALIGN(size), 0, flags);
54085 + retval = -ENOMEM;
54086 + if (!IS_ERR_VALUE(start) && !find_vma_intersection(current->mm, start, start + size + PAGE_SIZE)) {
54087 +// if (current->personality & ADDR_NO_RANDOMIZE)
54088 +// vm_flags |= VM_READ | VM_MAYREAD;
54089 + start = mmap_region(NULL, start, PAGE_ALIGN(size), vm_flags, 0);
54090 + retval = IS_ERR_VALUE(start) ? start : 0;
54091 + }
54092 + up_write(&current->mm->mmap_sem);
54093 + if (retval == 0)
54094 + retval = set_brk(start + size, start + size + PAGE_SIZE);
54095 + if (retval < 0) {
54096 + send_sig(SIGKILL, current, 0);
54097 + goto out_free_dentry;
54098 + }
54099 + }
54100 +#endif
54101 +
54102 if (elf_interpreter) {
54103 - unsigned long interp_map_addr = 0;
54104 -
54105 elf_entry = load_elf_interp(&loc->interp_elf_ex,
54106 interpreter,
54107 - &interp_map_addr,
54108 load_bias);
54109 if (!IS_ERR((void *)elf_entry)) {
54110 /*
54111 @@ -1122,7 +1587,7 @@ static bool always_dump_vma(struct vm_area_struct *vma)
54112 * Decide what to dump of a segment, part, all or none.
54113 */
54114 static unsigned long vma_dump_size(struct vm_area_struct *vma,
54115 - unsigned long mm_flags)
54116 + unsigned long mm_flags, long signr)
54117 {
54118 #define FILTER(type) (mm_flags & (1UL << MMF_DUMP_##type))
54119
54120 @@ -1160,7 +1625,7 @@ static unsigned long vma_dump_size(struct vm_area_struct *vma,
54121 if (vma->vm_file == NULL)
54122 return 0;
54123
54124 - if (FILTER(MAPPED_PRIVATE))
54125 + if (signr == SIGKILL || FILTER(MAPPED_PRIVATE))
54126 goto whole;
54127
54128 /*
54129 @@ -1385,9 +1850,9 @@ static void fill_auxv_note(struct memelfnote *note, struct mm_struct *mm)
54130 {
54131 elf_addr_t *auxv = (elf_addr_t *) mm->saved_auxv;
54132 int i = 0;
54133 - do
54134 + do {
54135 i += 2;
54136 - while (auxv[i - 2] != AT_NULL);
54137 + } while (auxv[i - 2] != AT_NULL);
54138 fill_note(note, "CORE", NT_AUXV, i * sizeof(elf_addr_t), auxv);
54139 }
54140
54141 @@ -1396,7 +1861,7 @@ static void fill_siginfo_note(struct memelfnote *note, user_siginfo_t *csigdata,
54142 {
54143 mm_segment_t old_fs = get_fs();
54144 set_fs(KERNEL_DS);
54145 - copy_siginfo_to_user((user_siginfo_t __user *) csigdata, siginfo);
54146 + copy_siginfo_to_user((user_siginfo_t __force_user *) csigdata, siginfo);
54147 set_fs(old_fs);
54148 fill_note(note, "CORE", NT_SIGINFO, sizeof(*csigdata), csigdata);
54149 }
54150 @@ -2023,14 +2488,14 @@ static void fill_extnum_info(struct elfhdr *elf, struct elf_shdr *shdr4extnum,
54151 }
54152
54153 static size_t elf_core_vma_data_size(struct vm_area_struct *gate_vma,
54154 - unsigned long mm_flags)
54155 + struct coredump_params *cprm)
54156 {
54157 struct vm_area_struct *vma;
54158 size_t size = 0;
54159
54160 for (vma = first_vma(current, gate_vma); vma != NULL;
54161 vma = next_vma(vma, gate_vma))
54162 - size += vma_dump_size(vma, mm_flags);
54163 + size += vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
54164 return size;
54165 }
54166
54167 @@ -2123,7 +2588,7 @@ static int elf_core_dump(struct coredump_params *cprm)
54168
54169 dataoff = offset = roundup(offset, ELF_EXEC_PAGESIZE);
54170
54171 - offset += elf_core_vma_data_size(gate_vma, cprm->mm_flags);
54172 + offset += elf_core_vma_data_size(gate_vma, cprm);
54173 offset += elf_core_extra_data_size();
54174 e_shoff = offset;
54175
54176 @@ -2137,10 +2602,12 @@ static int elf_core_dump(struct coredump_params *cprm)
54177 offset = dataoff;
54178
54179 size += sizeof(*elf);
54180 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
54181 if (size > cprm->limit || !dump_write(cprm->file, elf, sizeof(*elf)))
54182 goto end_coredump;
54183
54184 size += sizeof(*phdr4note);
54185 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
54186 if (size > cprm->limit
54187 || !dump_write(cprm->file, phdr4note, sizeof(*phdr4note)))
54188 goto end_coredump;
54189 @@ -2154,7 +2621,7 @@ static int elf_core_dump(struct coredump_params *cprm)
54190 phdr.p_offset = offset;
54191 phdr.p_vaddr = vma->vm_start;
54192 phdr.p_paddr = 0;
54193 - phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags);
54194 + phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
54195 phdr.p_memsz = vma->vm_end - vma->vm_start;
54196 offset += phdr.p_filesz;
54197 phdr.p_flags = vma->vm_flags & VM_READ ? PF_R : 0;
54198 @@ -2165,6 +2632,7 @@ static int elf_core_dump(struct coredump_params *cprm)
54199 phdr.p_align = ELF_EXEC_PAGESIZE;
54200
54201 size += sizeof(phdr);
54202 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
54203 if (size > cprm->limit
54204 || !dump_write(cprm->file, &phdr, sizeof(phdr)))
54205 goto end_coredump;
54206 @@ -2189,7 +2657,7 @@ static int elf_core_dump(struct coredump_params *cprm)
54207 unsigned long addr;
54208 unsigned long end;
54209
54210 - end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags);
54211 + end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
54212
54213 for (addr = vma->vm_start; addr < end; addr += PAGE_SIZE) {
54214 struct page *page;
54215 @@ -2198,6 +2666,7 @@ static int elf_core_dump(struct coredump_params *cprm)
54216 page = get_dump_page(addr);
54217 if (page) {
54218 void *kaddr = kmap(page);
54219 + gr_learn_resource(current, RLIMIT_CORE, size + PAGE_SIZE, 1);
54220 stop = ((size += PAGE_SIZE) > cprm->limit) ||
54221 !dump_write(cprm->file, kaddr,
54222 PAGE_SIZE);
54223 @@ -2215,6 +2684,7 @@ static int elf_core_dump(struct coredump_params *cprm)
54224
54225 if (e_phnum == PN_XNUM) {
54226 size += sizeof(*shdr4extnum);
54227 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
54228 if (size > cprm->limit
54229 || !dump_write(cprm->file, shdr4extnum,
54230 sizeof(*shdr4extnum)))
54231 @@ -2235,6 +2705,167 @@ out:
54232
54233 #endif /* CONFIG_ELF_CORE */
54234
54235 +#ifdef CONFIG_PAX_MPROTECT
54236 +/* PaX: non-PIC ELF libraries need relocations on their executable segments
54237 + * therefore we'll grant them VM_MAYWRITE once during their life. Similarly
54238 + * we'll remove VM_MAYWRITE for good on RELRO segments.
54239 + *
54240 + * The checks favour ld-linux.so behaviour which operates on a per ELF segment
54241 + * basis because we want to allow the common case and not the special ones.
54242 + */
54243 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags)
54244 +{
54245 + struct elfhdr elf_h;
54246 + struct elf_phdr elf_p;
54247 + unsigned long i;
54248 + unsigned long oldflags;
54249 + bool is_textrel_rw, is_textrel_rx, is_relro;
54250 +
54251 + if (!(vma->vm_mm->pax_flags & MF_PAX_MPROTECT) || !vma->vm_file)
54252 + return;
54253 +
54254 + oldflags = vma->vm_flags & (VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ);
54255 + newflags &= VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ;
54256 +
54257 +#ifdef CONFIG_PAX_ELFRELOCS
54258 + /* possible TEXTREL */
54259 + is_textrel_rw = !vma->anon_vma && oldflags == (VM_MAYEXEC | VM_MAYREAD | VM_EXEC | VM_READ) && newflags == (VM_WRITE | VM_READ);
54260 + is_textrel_rx = vma->anon_vma && oldflags == (VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_WRITE | VM_READ) && newflags == (VM_EXEC | VM_READ);
54261 +#else
54262 + is_textrel_rw = false;
54263 + is_textrel_rx = false;
54264 +#endif
54265 +
54266 + /* possible RELRO */
54267 + is_relro = vma->anon_vma && oldflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ) && newflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ);
54268 +
54269 + if (!is_textrel_rw && !is_textrel_rx && !is_relro)
54270 + return;
54271 +
54272 + if (sizeof(elf_h) != kernel_read(vma->vm_file, 0UL, (char *)&elf_h, sizeof(elf_h)) ||
54273 + memcmp(elf_h.e_ident, ELFMAG, SELFMAG) ||
54274 +
54275 +#ifdef CONFIG_PAX_ETEXECRELOCS
54276 + ((is_textrel_rw || is_textrel_rx) && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
54277 +#else
54278 + ((is_textrel_rw || is_textrel_rx) && elf_h.e_type != ET_DYN) ||
54279 +#endif
54280 +
54281 + (is_relro && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
54282 + !elf_check_arch(&elf_h) ||
54283 + elf_h.e_phentsize != sizeof(struct elf_phdr) ||
54284 + elf_h.e_phnum > 65536UL / sizeof(struct elf_phdr))
54285 + return;
54286 +
54287 + for (i = 0UL; i < elf_h.e_phnum; i++) {
54288 + if (sizeof(elf_p) != kernel_read(vma->vm_file, elf_h.e_phoff + i*sizeof(elf_p), (char *)&elf_p, sizeof(elf_p)))
54289 + return;
54290 + switch (elf_p.p_type) {
54291 + case PT_DYNAMIC:
54292 + if (!is_textrel_rw && !is_textrel_rx)
54293 + continue;
54294 + i = 0UL;
54295 + while ((i+1) * sizeof(elf_dyn) <= elf_p.p_filesz) {
54296 + elf_dyn dyn;
54297 +
54298 + if (sizeof(dyn) != kernel_read(vma->vm_file, elf_p.p_offset + i*sizeof(dyn), (char *)&dyn, sizeof(dyn)))
54299 + break;
54300 + if (dyn.d_tag == DT_NULL)
54301 + break;
54302 + if (dyn.d_tag == DT_TEXTREL || (dyn.d_tag == DT_FLAGS && (dyn.d_un.d_val & DF_TEXTREL))) {
54303 + gr_log_textrel(vma);
54304 + if (is_textrel_rw)
54305 + vma->vm_flags |= VM_MAYWRITE;
54306 + else
54307 + /* PaX: disallow write access after relocs are done, hopefully noone else needs it... */
54308 + vma->vm_flags &= ~VM_MAYWRITE;
54309 + break;
54310 + }
54311 + i++;
54312 + }
54313 + is_textrel_rw = false;
54314 + is_textrel_rx = false;
54315 + continue;
54316 +
54317 + case PT_GNU_RELRO:
54318 + if (!is_relro)
54319 + continue;
54320 + if ((elf_p.p_offset >> PAGE_SHIFT) == vma->vm_pgoff && ELF_PAGEALIGN(elf_p.p_memsz) == vma->vm_end - vma->vm_start)
54321 + vma->vm_flags &= ~VM_MAYWRITE;
54322 + is_relro = false;
54323 + continue;
54324 +
54325 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
54326 + case PT_PAX_FLAGS: {
54327 + const char *msg_mprotect = "", *msg_emutramp = "";
54328 + char *buffer_lib, *buffer_exe;
54329 +
54330 + if (elf_p.p_flags & PF_NOMPROTECT)
54331 + msg_mprotect = "MPROTECT disabled";
54332 +
54333 +#ifdef CONFIG_PAX_EMUTRAMP
54334 + if (!(vma->vm_mm->pax_flags & MF_PAX_EMUTRAMP) && !(elf_p.p_flags & PF_NOEMUTRAMP))
54335 + msg_emutramp = "EMUTRAMP enabled";
54336 +#endif
54337 +
54338 + if (!msg_mprotect[0] && !msg_emutramp[0])
54339 + continue;
54340 +
54341 + if (!printk_ratelimit())
54342 + continue;
54343 +
54344 + buffer_lib = (char *)__get_free_page(GFP_KERNEL);
54345 + buffer_exe = (char *)__get_free_page(GFP_KERNEL);
54346 + if (buffer_lib && buffer_exe) {
54347 + char *path_lib, *path_exe;
54348 +
54349 + path_lib = pax_get_path(&vma->vm_file->f_path, buffer_lib, PAGE_SIZE);
54350 + path_exe = pax_get_path(&vma->vm_mm->exe_file->f_path, buffer_exe, PAGE_SIZE);
54351 +
54352 + pr_info("PAX: %s wants %s%s%s on %s\n", path_lib, msg_mprotect,
54353 + (msg_mprotect[0] && msg_emutramp[0] ? " and " : ""), msg_emutramp, path_exe);
54354 +
54355 + }
54356 + free_page((unsigned long)buffer_exe);
54357 + free_page((unsigned long)buffer_lib);
54358 + continue;
54359 + }
54360 +#endif
54361 +
54362 + }
54363 + }
54364 +}
54365 +#endif
54366 +
54367 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
54368 +
54369 +extern int grsec_enable_log_rwxmaps;
54370 +
54371 +static void elf_handle_mmap(struct file *file)
54372 +{
54373 + struct elfhdr elf_h;
54374 + struct elf_phdr elf_p;
54375 + unsigned long i;
54376 +
54377 + if (!grsec_enable_log_rwxmaps)
54378 + return;
54379 +
54380 + if (sizeof(elf_h) != kernel_read(file, 0UL, (char *)&elf_h, sizeof(elf_h)) ||
54381 + memcmp(elf_h.e_ident, ELFMAG, SELFMAG) ||
54382 + (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC) || !elf_check_arch(&elf_h) ||
54383 + elf_h.e_phentsize != sizeof(struct elf_phdr) ||
54384 + elf_h.e_phnum > 65536UL / sizeof(struct elf_phdr))
54385 + return;
54386 +
54387 + for (i = 0UL; i < elf_h.e_phnum; i++) {
54388 + if (sizeof(elf_p) != kernel_read(file, elf_h.e_phoff + i*sizeof(elf_p), (char *)&elf_p, sizeof(elf_p)))
54389 + return;
54390 + if (elf_p.p_type == PT_GNU_STACK && (elf_p.p_flags & PF_X))
54391 + gr_log_ptgnustack(file);
54392 + }
54393 +}
54394 +#endif
54395 +
54396 static int __init init_elf_binfmt(void)
54397 {
54398 register_binfmt(&elf_format);
54399 diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c
54400 index d50bbe5..af3b649 100644
54401 --- a/fs/binfmt_flat.c
54402 +++ b/fs/binfmt_flat.c
54403 @@ -566,7 +566,9 @@ static int load_flat_file(struct linux_binprm * bprm,
54404 realdatastart = (unsigned long) -ENOMEM;
54405 printk("Unable to allocate RAM for process data, errno %d\n",
54406 (int)-realdatastart);
54407 + down_write(&current->mm->mmap_sem);
54408 vm_munmap(textpos, text_len);
54409 + up_write(&current->mm->mmap_sem);
54410 ret = realdatastart;
54411 goto err;
54412 }
54413 @@ -590,8 +592,10 @@ static int load_flat_file(struct linux_binprm * bprm,
54414 }
54415 if (IS_ERR_VALUE(result)) {
54416 printk("Unable to read data+bss, errno %d\n", (int)-result);
54417 + down_write(&current->mm->mmap_sem);
54418 vm_munmap(textpos, text_len);
54419 vm_munmap(realdatastart, len);
54420 + up_write(&current->mm->mmap_sem);
54421 ret = result;
54422 goto err;
54423 }
54424 @@ -653,8 +657,10 @@ static int load_flat_file(struct linux_binprm * bprm,
54425 }
54426 if (IS_ERR_VALUE(result)) {
54427 printk("Unable to read code+data+bss, errno %d\n",(int)-result);
54428 + down_write(&current->mm->mmap_sem);
54429 vm_munmap(textpos, text_len + data_len + extra +
54430 MAX_SHARED_LIBS * sizeof(unsigned long));
54431 + up_write(&current->mm->mmap_sem);
54432 ret = result;
54433 goto err;
54434 }
54435 diff --git a/fs/bio.c b/fs/bio.c
54436 index ea5035d..a2932eb 100644
54437 --- a/fs/bio.c
54438 +++ b/fs/bio.c
54439 @@ -1106,7 +1106,7 @@ struct bio *bio_copy_user_iov(struct request_queue *q,
54440 /*
54441 * Overflow, abort
54442 */
54443 - if (end < start)
54444 + if (end < start || end - start > INT_MAX - nr_pages)
54445 return ERR_PTR(-EINVAL);
54446
54447 nr_pages += end - start;
54448 @@ -1240,7 +1240,7 @@ static struct bio *__bio_map_user_iov(struct request_queue *q,
54449 /*
54450 * Overflow, abort
54451 */
54452 - if (end < start)
54453 + if (end < start || end - start > INT_MAX - nr_pages)
54454 return ERR_PTR(-EINVAL);
54455
54456 nr_pages += end - start;
54457 @@ -1502,7 +1502,7 @@ static void bio_copy_kern_endio(struct bio *bio, int err)
54458 const int read = bio_data_dir(bio) == READ;
54459 struct bio_map_data *bmd = bio->bi_private;
54460 int i;
54461 - char *p = bmd->sgvecs[0].iov_base;
54462 + char *p = (char __force_kernel *)bmd->sgvecs[0].iov_base;
54463
54464 bio_for_each_segment_all(bvec, bio, i) {
54465 char *addr = page_address(bvec->bv_page);
54466 diff --git a/fs/block_dev.c b/fs/block_dev.c
54467 index 1e86823..8e34695 100644
54468 --- a/fs/block_dev.c
54469 +++ b/fs/block_dev.c
54470 @@ -637,7 +637,7 @@ static bool bd_may_claim(struct block_device *bdev, struct block_device *whole,
54471 else if (bdev->bd_contains == bdev)
54472 return true; /* is a whole device which isn't held */
54473
54474 - else if (whole->bd_holder == bd_may_claim)
54475 + else if (whole->bd_holder == (void *)bd_may_claim)
54476 return true; /* is a partition of a device that is being partitioned */
54477 else if (whole->bd_holder != NULL)
54478 return false; /* is a partition of a held device */
54479 diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
54480 index b544a44..f3fb987 100644
54481 --- a/fs/btrfs/ctree.c
54482 +++ b/fs/btrfs/ctree.c
54483 @@ -1028,9 +1028,12 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
54484 free_extent_buffer(buf);
54485 add_root_to_dirty_list(root);
54486 } else {
54487 - if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID)
54488 - parent_start = parent->start;
54489 - else
54490 + if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID) {
54491 + if (parent)
54492 + parent_start = parent->start;
54493 + else
54494 + parent_start = 0;
54495 + } else
54496 parent_start = 0;
54497
54498 WARN_ON(trans->transid != btrfs_header_generation(parent));
54499 diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
54500 index cbd9523..5cca781 100644
54501 --- a/fs/btrfs/delayed-inode.c
54502 +++ b/fs/btrfs/delayed-inode.c
54503 @@ -459,7 +459,7 @@ static int __btrfs_add_delayed_deletion_item(struct btrfs_delayed_node *node,
54504
54505 static void finish_one_item(struct btrfs_delayed_root *delayed_root)
54506 {
54507 - int seq = atomic_inc_return(&delayed_root->items_seq);
54508 + int seq = atomic_inc_return_unchecked(&delayed_root->items_seq);
54509 if ((atomic_dec_return(&delayed_root->items) <
54510 BTRFS_DELAYED_BACKGROUND || seq % BTRFS_DELAYED_BATCH == 0) &&
54511 waitqueue_active(&delayed_root->wait))
54512 @@ -1378,7 +1378,7 @@ void btrfs_assert_delayed_root_empty(struct btrfs_root *root)
54513 static int refs_newer(struct btrfs_delayed_root *delayed_root,
54514 int seq, int count)
54515 {
54516 - int val = atomic_read(&delayed_root->items_seq);
54517 + int val = atomic_read_unchecked(&delayed_root->items_seq);
54518
54519 if (val < seq || val >= seq + count)
54520 return 1;
54521 @@ -1395,7 +1395,7 @@ void btrfs_balance_delayed_items(struct btrfs_root *root)
54522 if (atomic_read(&delayed_root->items) < BTRFS_DELAYED_BACKGROUND)
54523 return;
54524
54525 - seq = atomic_read(&delayed_root->items_seq);
54526 + seq = atomic_read_unchecked(&delayed_root->items_seq);
54527
54528 if (atomic_read(&delayed_root->items) >= BTRFS_DELAYED_WRITEBACK) {
54529 int ret;
54530 diff --git a/fs/btrfs/delayed-inode.h b/fs/btrfs/delayed-inode.h
54531 index a4b38f9..f86a509 100644
54532 --- a/fs/btrfs/delayed-inode.h
54533 +++ b/fs/btrfs/delayed-inode.h
54534 @@ -43,7 +43,7 @@ struct btrfs_delayed_root {
54535 */
54536 struct list_head prepare_list;
54537 atomic_t items; /* for delayed items */
54538 - atomic_t items_seq; /* for delayed items */
54539 + atomic_unchecked_t items_seq; /* for delayed items */
54540 int nodes; /* for delayed nodes */
54541 wait_queue_head_t wait;
54542 };
54543 @@ -87,7 +87,7 @@ static inline void btrfs_init_delayed_root(
54544 struct btrfs_delayed_root *delayed_root)
54545 {
54546 atomic_set(&delayed_root->items, 0);
54547 - atomic_set(&delayed_root->items_seq, 0);
54548 + atomic_set_unchecked(&delayed_root->items_seq, 0);
54549 delayed_root->nodes = 0;
54550 spin_lock_init(&delayed_root->lock);
54551 init_waitqueue_head(&delayed_root->wait);
54552 diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
54553 index 8747feb..ad1655c 100644
54554 --- a/fs/btrfs/ioctl.c
54555 +++ b/fs/btrfs/ioctl.c
54556 @@ -3465,9 +3465,12 @@ static long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
54557 for (i = 0; i < num_types; i++) {
54558 struct btrfs_space_info *tmp;
54559
54560 + /* Don't copy in more than we allocated */
54561 if (!slot_count)
54562 break;
54563
54564 + slot_count--;
54565 +
54566 info = NULL;
54567 rcu_read_lock();
54568 list_for_each_entry_rcu(tmp, &root->fs_info->space_info,
54569 @@ -3489,10 +3492,7 @@ static long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
54570 memcpy(dest, &space, sizeof(space));
54571 dest++;
54572 space_args.total_spaces++;
54573 - slot_count--;
54574 }
54575 - if (!slot_count)
54576 - break;
54577 }
54578 up_read(&info->groups_sem);
54579 }
54580 diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
54581 index e913328..a34fb36 100644
54582 --- a/fs/btrfs/super.c
54583 +++ b/fs/btrfs/super.c
54584 @@ -266,7 +266,7 @@ void __btrfs_abort_transaction(struct btrfs_trans_handle *trans,
54585 function, line, errstr);
54586 return;
54587 }
54588 - ACCESS_ONCE(trans->transaction->aborted) = errno;
54589 + ACCESS_ONCE_RW(trans->transaction->aborted) = errno;
54590 /* Wake up anybody who may be waiting on this transaction */
54591 wake_up(&root->fs_info->transaction_wait);
54592 wake_up(&root->fs_info->transaction_blocked_wait);
54593 diff --git a/fs/buffer.c b/fs/buffer.c
54594 index 6024877..7bd000a 100644
54595 --- a/fs/buffer.c
54596 +++ b/fs/buffer.c
54597 @@ -3426,7 +3426,7 @@ void __init buffer_init(void)
54598 bh_cachep = kmem_cache_create("buffer_head",
54599 sizeof(struct buffer_head), 0,
54600 (SLAB_RECLAIM_ACCOUNT|SLAB_PANIC|
54601 - SLAB_MEM_SPREAD),
54602 + SLAB_MEM_SPREAD|SLAB_NO_SANITIZE),
54603 NULL);
54604
54605 /*
54606 diff --git a/fs/cachefiles/bind.c b/fs/cachefiles/bind.c
54607 index 622f469..e8d2d55 100644
54608 --- a/fs/cachefiles/bind.c
54609 +++ b/fs/cachefiles/bind.c
54610 @@ -39,13 +39,11 @@ int cachefiles_daemon_bind(struct cachefiles_cache *cache, char *args)
54611 args);
54612
54613 /* start by checking things over */
54614 - ASSERT(cache->fstop_percent >= 0 &&
54615 - cache->fstop_percent < cache->fcull_percent &&
54616 + ASSERT(cache->fstop_percent < cache->fcull_percent &&
54617 cache->fcull_percent < cache->frun_percent &&
54618 cache->frun_percent < 100);
54619
54620 - ASSERT(cache->bstop_percent >= 0 &&
54621 - cache->bstop_percent < cache->bcull_percent &&
54622 + ASSERT(cache->bstop_percent < cache->bcull_percent &&
54623 cache->bcull_percent < cache->brun_percent &&
54624 cache->brun_percent < 100);
54625
54626 diff --git a/fs/cachefiles/daemon.c b/fs/cachefiles/daemon.c
54627 index 0a1467b..6a53245 100644
54628 --- a/fs/cachefiles/daemon.c
54629 +++ b/fs/cachefiles/daemon.c
54630 @@ -196,7 +196,7 @@ static ssize_t cachefiles_daemon_read(struct file *file, char __user *_buffer,
54631 if (n > buflen)
54632 return -EMSGSIZE;
54633
54634 - if (copy_to_user(_buffer, buffer, n) != 0)
54635 + if (n > sizeof(buffer) || copy_to_user(_buffer, buffer, n) != 0)
54636 return -EFAULT;
54637
54638 return n;
54639 @@ -222,7 +222,7 @@ static ssize_t cachefiles_daemon_write(struct file *file,
54640 if (test_bit(CACHEFILES_DEAD, &cache->flags))
54641 return -EIO;
54642
54643 - if (datalen < 0 || datalen > PAGE_SIZE - 1)
54644 + if (datalen > PAGE_SIZE - 1)
54645 return -EOPNOTSUPP;
54646
54647 /* drag the command string into the kernel so we can parse it */
54648 @@ -386,7 +386,7 @@ static int cachefiles_daemon_fstop(struct cachefiles_cache *cache, char *args)
54649 if (args[0] != '%' || args[1] != '\0')
54650 return -EINVAL;
54651
54652 - if (fstop < 0 || fstop >= cache->fcull_percent)
54653 + if (fstop >= cache->fcull_percent)
54654 return cachefiles_daemon_range_error(cache, args);
54655
54656 cache->fstop_percent = fstop;
54657 @@ -458,7 +458,7 @@ static int cachefiles_daemon_bstop(struct cachefiles_cache *cache, char *args)
54658 if (args[0] != '%' || args[1] != '\0')
54659 return -EINVAL;
54660
54661 - if (bstop < 0 || bstop >= cache->bcull_percent)
54662 + if (bstop >= cache->bcull_percent)
54663 return cachefiles_daemon_range_error(cache, args);
54664
54665 cache->bstop_percent = bstop;
54666 diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h
54667 index 5349473..d6c0b93 100644
54668 --- a/fs/cachefiles/internal.h
54669 +++ b/fs/cachefiles/internal.h
54670 @@ -59,7 +59,7 @@ struct cachefiles_cache {
54671 wait_queue_head_t daemon_pollwq; /* poll waitqueue for daemon */
54672 struct rb_root active_nodes; /* active nodes (can't be culled) */
54673 rwlock_t active_lock; /* lock for active_nodes */
54674 - atomic_t gravecounter; /* graveyard uniquifier */
54675 + atomic_unchecked_t gravecounter; /* graveyard uniquifier */
54676 unsigned frun_percent; /* when to stop culling (% files) */
54677 unsigned fcull_percent; /* when to start culling (% files) */
54678 unsigned fstop_percent; /* when to stop allocating (% files) */
54679 @@ -171,19 +171,19 @@ extern int cachefiles_check_in_use(struct cachefiles_cache *cache,
54680 * proc.c
54681 */
54682 #ifdef CONFIG_CACHEFILES_HISTOGRAM
54683 -extern atomic_t cachefiles_lookup_histogram[HZ];
54684 -extern atomic_t cachefiles_mkdir_histogram[HZ];
54685 -extern atomic_t cachefiles_create_histogram[HZ];
54686 +extern atomic_unchecked_t cachefiles_lookup_histogram[HZ];
54687 +extern atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
54688 +extern atomic_unchecked_t cachefiles_create_histogram[HZ];
54689
54690 extern int __init cachefiles_proc_init(void);
54691 extern void cachefiles_proc_cleanup(void);
54692 static inline
54693 -void cachefiles_hist(atomic_t histogram[], unsigned long start_jif)
54694 +void cachefiles_hist(atomic_unchecked_t histogram[], unsigned long start_jif)
54695 {
54696 unsigned long jif = jiffies - start_jif;
54697 if (jif >= HZ)
54698 jif = HZ - 1;
54699 - atomic_inc(&histogram[jif]);
54700 + atomic_inc_unchecked(&histogram[jif]);
54701 }
54702
54703 #else
54704 diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c
54705 index f4a08d7..5aa4599 100644
54706 --- a/fs/cachefiles/namei.c
54707 +++ b/fs/cachefiles/namei.c
54708 @@ -317,7 +317,7 @@ try_again:
54709 /* first step is to make up a grave dentry in the graveyard */
54710 sprintf(nbuffer, "%08x%08x",
54711 (uint32_t) get_seconds(),
54712 - (uint32_t) atomic_inc_return(&cache->gravecounter));
54713 + (uint32_t) atomic_inc_return_unchecked(&cache->gravecounter));
54714
54715 /* do the multiway lock magic */
54716 trap = lock_rename(cache->graveyard, dir);
54717 diff --git a/fs/cachefiles/proc.c b/fs/cachefiles/proc.c
54718 index eccd339..4c1d995 100644
54719 --- a/fs/cachefiles/proc.c
54720 +++ b/fs/cachefiles/proc.c
54721 @@ -14,9 +14,9 @@
54722 #include <linux/seq_file.h>
54723 #include "internal.h"
54724
54725 -atomic_t cachefiles_lookup_histogram[HZ];
54726 -atomic_t cachefiles_mkdir_histogram[HZ];
54727 -atomic_t cachefiles_create_histogram[HZ];
54728 +atomic_unchecked_t cachefiles_lookup_histogram[HZ];
54729 +atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
54730 +atomic_unchecked_t cachefiles_create_histogram[HZ];
54731
54732 /*
54733 * display the latency histogram
54734 @@ -35,9 +35,9 @@ static int cachefiles_histogram_show(struct seq_file *m, void *v)
54735 return 0;
54736 default:
54737 index = (unsigned long) v - 3;
54738 - x = atomic_read(&cachefiles_lookup_histogram[index]);
54739 - y = atomic_read(&cachefiles_mkdir_histogram[index]);
54740 - z = atomic_read(&cachefiles_create_histogram[index]);
54741 + x = atomic_read_unchecked(&cachefiles_lookup_histogram[index]);
54742 + y = atomic_read_unchecked(&cachefiles_mkdir_histogram[index]);
54743 + z = atomic_read_unchecked(&cachefiles_create_histogram[index]);
54744 if (x == 0 && y == 0 && z == 0)
54745 return 0;
54746
54747 diff --git a/fs/cachefiles/rdwr.c b/fs/cachefiles/rdwr.c
54748 index ebaff36..7e3ea26 100644
54749 --- a/fs/cachefiles/rdwr.c
54750 +++ b/fs/cachefiles/rdwr.c
54751 @@ -950,7 +950,7 @@ int cachefiles_write_page(struct fscache_storage *op, struct page *page)
54752 old_fs = get_fs();
54753 set_fs(KERNEL_DS);
54754 ret = file->f_op->write(
54755 - file, (const void __user *) data, len, &pos);
54756 + file, (const void __force_user *) data, len, &pos);
54757 set_fs(old_fs);
54758 kunmap(page);
54759 file_end_write(file);
54760 diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
54761 index 868b61d..58835a5 100644
54762 --- a/fs/ceph/dir.c
54763 +++ b/fs/ceph/dir.c
54764 @@ -240,7 +240,7 @@ static int ceph_readdir(struct file *file, struct dir_context *ctx)
54765 struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
54766 struct ceph_mds_client *mdsc = fsc->mdsc;
54767 unsigned frag = fpos_frag(ctx->pos);
54768 - int off = fpos_off(ctx->pos);
54769 + unsigned int off = fpos_off(ctx->pos);
54770 int err;
54771 u32 ftype;
54772 struct ceph_mds_reply_info_parsed *rinfo;
54773 diff --git a/fs/ceph/super.c b/fs/ceph/super.c
54774 index 6a0951e..03fac6d 100644
54775 --- a/fs/ceph/super.c
54776 +++ b/fs/ceph/super.c
54777 @@ -870,7 +870,7 @@ static int ceph_compare_super(struct super_block *sb, void *data)
54778 /*
54779 * construct our own bdi so we can control readahead, etc.
54780 */
54781 -static atomic_long_t bdi_seq = ATOMIC_LONG_INIT(0);
54782 +static atomic_long_unchecked_t bdi_seq = ATOMIC_LONG_INIT(0);
54783
54784 static int ceph_register_bdi(struct super_block *sb,
54785 struct ceph_fs_client *fsc)
54786 @@ -887,7 +887,7 @@ static int ceph_register_bdi(struct super_block *sb,
54787 default_backing_dev_info.ra_pages;
54788
54789 err = bdi_register(&fsc->backing_dev_info, NULL, "ceph-%ld",
54790 - atomic_long_inc_return(&bdi_seq));
54791 + atomic_long_inc_return_unchecked(&bdi_seq));
54792 if (!err)
54793 sb->s_bdi = &fsc->backing_dev_info;
54794 return err;
54795 diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c
54796 index f3ac415..3d2420c 100644
54797 --- a/fs/cifs/cifs_debug.c
54798 +++ b/fs/cifs/cifs_debug.c
54799 @@ -286,8 +286,8 @@ static ssize_t cifs_stats_proc_write(struct file *file,
54800
54801 if (c == '1' || c == 'y' || c == 'Y' || c == '0') {
54802 #ifdef CONFIG_CIFS_STATS2
54803 - atomic_set(&totBufAllocCount, 0);
54804 - atomic_set(&totSmBufAllocCount, 0);
54805 + atomic_set_unchecked(&totBufAllocCount, 0);
54806 + atomic_set_unchecked(&totSmBufAllocCount, 0);
54807 #endif /* CONFIG_CIFS_STATS2 */
54808 spin_lock(&cifs_tcp_ses_lock);
54809 list_for_each(tmp1, &cifs_tcp_ses_list) {
54810 @@ -300,7 +300,7 @@ static ssize_t cifs_stats_proc_write(struct file *file,
54811 tcon = list_entry(tmp3,
54812 struct cifs_tcon,
54813 tcon_list);
54814 - atomic_set(&tcon->num_smbs_sent, 0);
54815 + atomic_set_unchecked(&tcon->num_smbs_sent, 0);
54816 if (server->ops->clear_stats)
54817 server->ops->clear_stats(tcon);
54818 }
54819 @@ -332,8 +332,8 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
54820 smBufAllocCount.counter, cifs_min_small);
54821 #ifdef CONFIG_CIFS_STATS2
54822 seq_printf(m, "Total Large %d Small %d Allocations\n",
54823 - atomic_read(&totBufAllocCount),
54824 - atomic_read(&totSmBufAllocCount));
54825 + atomic_read_unchecked(&totBufAllocCount),
54826 + atomic_read_unchecked(&totSmBufAllocCount));
54827 #endif /* CONFIG_CIFS_STATS2 */
54828
54829 seq_printf(m, "Operations (MIDs): %d\n", atomic_read(&midCount));
54830 @@ -362,7 +362,7 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
54831 if (tcon->need_reconnect)
54832 seq_puts(m, "\tDISCONNECTED ");
54833 seq_printf(m, "\nSMBs: %d",
54834 - atomic_read(&tcon->num_smbs_sent));
54835 + atomic_read_unchecked(&tcon->num_smbs_sent));
54836 if (server->ops->print_stats)
54837 server->ops->print_stats(m, tcon);
54838 }
54839 diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
54840 index 77fc5e1..e3d13e6 100644
54841 --- a/fs/cifs/cifsfs.c
54842 +++ b/fs/cifs/cifsfs.c
54843 @@ -1056,7 +1056,7 @@ cifs_init_request_bufs(void)
54844 */
54845 cifs_req_cachep = kmem_cache_create("cifs_request",
54846 CIFSMaxBufSize + max_hdr_size, 0,
54847 - SLAB_HWCACHE_ALIGN, NULL);
54848 + SLAB_HWCACHE_ALIGN | SLAB_USERCOPY, NULL);
54849 if (cifs_req_cachep == NULL)
54850 return -ENOMEM;
54851
54852 @@ -1083,7 +1083,7 @@ cifs_init_request_bufs(void)
54853 efficient to alloc 1 per page off the slab compared to 17K (5page)
54854 alloc of large cifs buffers even when page debugging is on */
54855 cifs_sm_req_cachep = kmem_cache_create("cifs_small_rq",
54856 - MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN,
54857 + MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN | SLAB_USERCOPY,
54858 NULL);
54859 if (cifs_sm_req_cachep == NULL) {
54860 mempool_destroy(cifs_req_poolp);
54861 @@ -1168,8 +1168,8 @@ init_cifs(void)
54862 atomic_set(&bufAllocCount, 0);
54863 atomic_set(&smBufAllocCount, 0);
54864 #ifdef CONFIG_CIFS_STATS2
54865 - atomic_set(&totBufAllocCount, 0);
54866 - atomic_set(&totSmBufAllocCount, 0);
54867 + atomic_set_unchecked(&totBufAllocCount, 0);
54868 + atomic_set_unchecked(&totSmBufAllocCount, 0);
54869 #endif /* CONFIG_CIFS_STATS2 */
54870
54871 atomic_set(&midCount, 0);
54872 diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
54873 index c8e03f8..75362f6 100644
54874 --- a/fs/cifs/cifsglob.h
54875 +++ b/fs/cifs/cifsglob.h
54876 @@ -758,35 +758,35 @@ struct cifs_tcon {
54877 __u16 Flags; /* optional support bits */
54878 enum statusEnum tidStatus;
54879 #ifdef CONFIG_CIFS_STATS
54880 - atomic_t num_smbs_sent;
54881 + atomic_unchecked_t num_smbs_sent;
54882 union {
54883 struct {
54884 - atomic_t num_writes;
54885 - atomic_t num_reads;
54886 - atomic_t num_flushes;
54887 - atomic_t num_oplock_brks;
54888 - atomic_t num_opens;
54889 - atomic_t num_closes;
54890 - atomic_t num_deletes;
54891 - atomic_t num_mkdirs;
54892 - atomic_t num_posixopens;
54893 - atomic_t num_posixmkdirs;
54894 - atomic_t num_rmdirs;
54895 - atomic_t num_renames;
54896 - atomic_t num_t2renames;
54897 - atomic_t num_ffirst;
54898 - atomic_t num_fnext;
54899 - atomic_t num_fclose;
54900 - atomic_t num_hardlinks;
54901 - atomic_t num_symlinks;
54902 - atomic_t num_locks;
54903 - atomic_t num_acl_get;
54904 - atomic_t num_acl_set;
54905 + atomic_unchecked_t num_writes;
54906 + atomic_unchecked_t num_reads;
54907 + atomic_unchecked_t num_flushes;
54908 + atomic_unchecked_t num_oplock_brks;
54909 + atomic_unchecked_t num_opens;
54910 + atomic_unchecked_t num_closes;
54911 + atomic_unchecked_t num_deletes;
54912 + atomic_unchecked_t num_mkdirs;
54913 + atomic_unchecked_t num_posixopens;
54914 + atomic_unchecked_t num_posixmkdirs;
54915 + atomic_unchecked_t num_rmdirs;
54916 + atomic_unchecked_t num_renames;
54917 + atomic_unchecked_t num_t2renames;
54918 + atomic_unchecked_t num_ffirst;
54919 + atomic_unchecked_t num_fnext;
54920 + atomic_unchecked_t num_fclose;
54921 + atomic_unchecked_t num_hardlinks;
54922 + atomic_unchecked_t num_symlinks;
54923 + atomic_unchecked_t num_locks;
54924 + atomic_unchecked_t num_acl_get;
54925 + atomic_unchecked_t num_acl_set;
54926 } cifs_stats;
54927 #ifdef CONFIG_CIFS_SMB2
54928 struct {
54929 - atomic_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
54930 - atomic_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
54931 + atomic_unchecked_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
54932 + atomic_unchecked_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
54933 } smb2_stats;
54934 #endif /* CONFIG_CIFS_SMB2 */
54935 } stats;
54936 @@ -1111,7 +1111,7 @@ convert_delimiter(char *path, char delim)
54937 }
54938
54939 #ifdef CONFIG_CIFS_STATS
54940 -#define cifs_stats_inc atomic_inc
54941 +#define cifs_stats_inc atomic_inc_unchecked
54942
54943 static inline void cifs_stats_bytes_written(struct cifs_tcon *tcon,
54944 unsigned int bytes)
54945 @@ -1477,8 +1477,8 @@ GLOBAL_EXTERN atomic_t tconInfoReconnectCount;
54946 /* Various Debug counters */
54947 GLOBAL_EXTERN atomic_t bufAllocCount; /* current number allocated */
54948 #ifdef CONFIG_CIFS_STATS2
54949 -GLOBAL_EXTERN atomic_t totBufAllocCount; /* total allocated over all time */
54950 -GLOBAL_EXTERN atomic_t totSmBufAllocCount;
54951 +GLOBAL_EXTERN atomic_unchecked_t totBufAllocCount; /* total allocated over all time */
54952 +GLOBAL_EXTERN atomic_unchecked_t totSmBufAllocCount;
54953 #endif
54954 GLOBAL_EXTERN atomic_t smBufAllocCount;
54955 GLOBAL_EXTERN atomic_t midCount;
54956 diff --git a/fs/cifs/file.c b/fs/cifs/file.c
54957 index 7ddddf2..2e12dbc 100644
54958 --- a/fs/cifs/file.c
54959 +++ b/fs/cifs/file.c
54960 @@ -1900,10 +1900,14 @@ static int cifs_writepages(struct address_space *mapping,
54961 index = mapping->writeback_index; /* Start from prev offset */
54962 end = -1;
54963 } else {
54964 - index = wbc->range_start >> PAGE_CACHE_SHIFT;
54965 - end = wbc->range_end >> PAGE_CACHE_SHIFT;
54966 - if (wbc->range_start == 0 && wbc->range_end == LLONG_MAX)
54967 + if (wbc->range_start == 0 && wbc->range_end == LLONG_MAX) {
54968 range_whole = true;
54969 + index = 0;
54970 + end = ULONG_MAX;
54971 + } else {
54972 + index = wbc->range_start >> PAGE_CACHE_SHIFT;
54973 + end = wbc->range_end >> PAGE_CACHE_SHIFT;
54974 + }
54975 scanned = true;
54976 }
54977 retry:
54978 diff --git a/fs/cifs/link.c b/fs/cifs/link.c
54979 index 7e36ceb..109252f 100644
54980 --- a/fs/cifs/link.c
54981 +++ b/fs/cifs/link.c
54982 @@ -624,7 +624,7 @@ symlink_exit:
54983
54984 void cifs_put_link(struct dentry *direntry, struct nameidata *nd, void *cookie)
54985 {
54986 - char *p = nd_get_link(nd);
54987 + const char *p = nd_get_link(nd);
54988 if (!IS_ERR(p))
54989 kfree(p);
54990 }
54991 diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
54992 index 138a011..cf9e13a 100644
54993 --- a/fs/cifs/misc.c
54994 +++ b/fs/cifs/misc.c
54995 @@ -170,7 +170,7 @@ cifs_buf_get(void)
54996 memset(ret_buf, 0, buf_size + 3);
54997 atomic_inc(&bufAllocCount);
54998 #ifdef CONFIG_CIFS_STATS2
54999 - atomic_inc(&totBufAllocCount);
55000 + atomic_inc_unchecked(&totBufAllocCount);
55001 #endif /* CONFIG_CIFS_STATS2 */
55002 }
55003
55004 @@ -205,7 +205,7 @@ cifs_small_buf_get(void)
55005 /* memset(ret_buf, 0, sizeof(struct smb_hdr) + 27);*/
55006 atomic_inc(&smBufAllocCount);
55007 #ifdef CONFIG_CIFS_STATS2
55008 - atomic_inc(&totSmBufAllocCount);
55009 + atomic_inc_unchecked(&totSmBufAllocCount);
55010 #endif /* CONFIG_CIFS_STATS2 */
55011
55012 }
55013 diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c
55014 index e50554b..c011413 100644
55015 --- a/fs/cifs/smb1ops.c
55016 +++ b/fs/cifs/smb1ops.c
55017 @@ -609,27 +609,27 @@ static void
55018 cifs_clear_stats(struct cifs_tcon *tcon)
55019 {
55020 #ifdef CONFIG_CIFS_STATS
55021 - atomic_set(&tcon->stats.cifs_stats.num_writes, 0);
55022 - atomic_set(&tcon->stats.cifs_stats.num_reads, 0);
55023 - atomic_set(&tcon->stats.cifs_stats.num_flushes, 0);
55024 - atomic_set(&tcon->stats.cifs_stats.num_oplock_brks, 0);
55025 - atomic_set(&tcon->stats.cifs_stats.num_opens, 0);
55026 - atomic_set(&tcon->stats.cifs_stats.num_posixopens, 0);
55027 - atomic_set(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
55028 - atomic_set(&tcon->stats.cifs_stats.num_closes, 0);
55029 - atomic_set(&tcon->stats.cifs_stats.num_deletes, 0);
55030 - atomic_set(&tcon->stats.cifs_stats.num_mkdirs, 0);
55031 - atomic_set(&tcon->stats.cifs_stats.num_rmdirs, 0);
55032 - atomic_set(&tcon->stats.cifs_stats.num_renames, 0);
55033 - atomic_set(&tcon->stats.cifs_stats.num_t2renames, 0);
55034 - atomic_set(&tcon->stats.cifs_stats.num_ffirst, 0);
55035 - atomic_set(&tcon->stats.cifs_stats.num_fnext, 0);
55036 - atomic_set(&tcon->stats.cifs_stats.num_fclose, 0);
55037 - atomic_set(&tcon->stats.cifs_stats.num_hardlinks, 0);
55038 - atomic_set(&tcon->stats.cifs_stats.num_symlinks, 0);
55039 - atomic_set(&tcon->stats.cifs_stats.num_locks, 0);
55040 - atomic_set(&tcon->stats.cifs_stats.num_acl_get, 0);
55041 - atomic_set(&tcon->stats.cifs_stats.num_acl_set, 0);
55042 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_writes, 0);
55043 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_reads, 0);
55044 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_flushes, 0);
55045 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_oplock_brks, 0);
55046 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_opens, 0);
55047 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixopens, 0);
55048 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
55049 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_closes, 0);
55050 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_deletes, 0);
55051 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_mkdirs, 0);
55052 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_rmdirs, 0);
55053 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_renames, 0);
55054 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_t2renames, 0);
55055 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_ffirst, 0);
55056 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fnext, 0);
55057 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fclose, 0);
55058 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_hardlinks, 0);
55059 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_symlinks, 0);
55060 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_locks, 0);
55061 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_get, 0);
55062 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_set, 0);
55063 #endif
55064 }
55065
55066 @@ -638,36 +638,36 @@ cifs_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
55067 {
55068 #ifdef CONFIG_CIFS_STATS
55069 seq_printf(m, " Oplocks breaks: %d",
55070 - atomic_read(&tcon->stats.cifs_stats.num_oplock_brks));
55071 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_oplock_brks));
55072 seq_printf(m, "\nReads: %d Bytes: %llu",
55073 - atomic_read(&tcon->stats.cifs_stats.num_reads),
55074 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_reads),
55075 (long long)(tcon->bytes_read));
55076 seq_printf(m, "\nWrites: %d Bytes: %llu",
55077 - atomic_read(&tcon->stats.cifs_stats.num_writes),
55078 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_writes),
55079 (long long)(tcon->bytes_written));
55080 seq_printf(m, "\nFlushes: %d",
55081 - atomic_read(&tcon->stats.cifs_stats.num_flushes));
55082 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_flushes));
55083 seq_printf(m, "\nLocks: %d HardLinks: %d Symlinks: %d",
55084 - atomic_read(&tcon->stats.cifs_stats.num_locks),
55085 - atomic_read(&tcon->stats.cifs_stats.num_hardlinks),
55086 - atomic_read(&tcon->stats.cifs_stats.num_symlinks));
55087 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_locks),
55088 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_hardlinks),
55089 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_symlinks));
55090 seq_printf(m, "\nOpens: %d Closes: %d Deletes: %d",
55091 - atomic_read(&tcon->stats.cifs_stats.num_opens),
55092 - atomic_read(&tcon->stats.cifs_stats.num_closes),
55093 - atomic_read(&tcon->stats.cifs_stats.num_deletes));
55094 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_opens),
55095 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_closes),
55096 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_deletes));
55097 seq_printf(m, "\nPosix Opens: %d Posix Mkdirs: %d",
55098 - atomic_read(&tcon->stats.cifs_stats.num_posixopens),
55099 - atomic_read(&tcon->stats.cifs_stats.num_posixmkdirs));
55100 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixopens),
55101 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs));
55102 seq_printf(m, "\nMkdirs: %d Rmdirs: %d",
55103 - atomic_read(&tcon->stats.cifs_stats.num_mkdirs),
55104 - atomic_read(&tcon->stats.cifs_stats.num_rmdirs));
55105 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_mkdirs),
55106 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_rmdirs));
55107 seq_printf(m, "\nRenames: %d T2 Renames %d",
55108 - atomic_read(&tcon->stats.cifs_stats.num_renames),
55109 - atomic_read(&tcon->stats.cifs_stats.num_t2renames));
55110 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_renames),
55111 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_t2renames));
55112 seq_printf(m, "\nFindFirst: %d FNext %d FClose %d",
55113 - atomic_read(&tcon->stats.cifs_stats.num_ffirst),
55114 - atomic_read(&tcon->stats.cifs_stats.num_fnext),
55115 - atomic_read(&tcon->stats.cifs_stats.num_fclose));
55116 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_ffirst),
55117 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fnext),
55118 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fclose));
55119 #endif
55120 }
55121
55122 diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
55123 index 861b332..5506392 100644
55124 --- a/fs/cifs/smb2ops.c
55125 +++ b/fs/cifs/smb2ops.c
55126 @@ -282,8 +282,8 @@ smb2_clear_stats(struct cifs_tcon *tcon)
55127 #ifdef CONFIG_CIFS_STATS
55128 int i;
55129 for (i = 0; i < NUMBER_OF_SMB2_COMMANDS; i++) {
55130 - atomic_set(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
55131 - atomic_set(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
55132 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
55133 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
55134 }
55135 #endif
55136 }
55137 @@ -311,65 +311,65 @@ static void
55138 smb2_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
55139 {
55140 #ifdef CONFIG_CIFS_STATS
55141 - atomic_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
55142 - atomic_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
55143 + atomic_unchecked_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
55144 + atomic_unchecked_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
55145 seq_printf(m, "\nNegotiates: %d sent %d failed",
55146 - atomic_read(&sent[SMB2_NEGOTIATE_HE]),
55147 - atomic_read(&failed[SMB2_NEGOTIATE_HE]));
55148 + atomic_read_unchecked(&sent[SMB2_NEGOTIATE_HE]),
55149 + atomic_read_unchecked(&failed[SMB2_NEGOTIATE_HE]));
55150 seq_printf(m, "\nSessionSetups: %d sent %d failed",
55151 - atomic_read(&sent[SMB2_SESSION_SETUP_HE]),
55152 - atomic_read(&failed[SMB2_SESSION_SETUP_HE]));
55153 + atomic_read_unchecked(&sent[SMB2_SESSION_SETUP_HE]),
55154 + atomic_read_unchecked(&failed[SMB2_SESSION_SETUP_HE]));
55155 seq_printf(m, "\nLogoffs: %d sent %d failed",
55156 - atomic_read(&sent[SMB2_LOGOFF_HE]),
55157 - atomic_read(&failed[SMB2_LOGOFF_HE]));
55158 + atomic_read_unchecked(&sent[SMB2_LOGOFF_HE]),
55159 + atomic_read_unchecked(&failed[SMB2_LOGOFF_HE]));
55160 seq_printf(m, "\nTreeConnects: %d sent %d failed",
55161 - atomic_read(&sent[SMB2_TREE_CONNECT_HE]),
55162 - atomic_read(&failed[SMB2_TREE_CONNECT_HE]));
55163 + atomic_read_unchecked(&sent[SMB2_TREE_CONNECT_HE]),
55164 + atomic_read_unchecked(&failed[SMB2_TREE_CONNECT_HE]));
55165 seq_printf(m, "\nTreeDisconnects: %d sent %d failed",
55166 - atomic_read(&sent[SMB2_TREE_DISCONNECT_HE]),
55167 - atomic_read(&failed[SMB2_TREE_DISCONNECT_HE]));
55168 + atomic_read_unchecked(&sent[SMB2_TREE_DISCONNECT_HE]),
55169 + atomic_read_unchecked(&failed[SMB2_TREE_DISCONNECT_HE]));
55170 seq_printf(m, "\nCreates: %d sent %d failed",
55171 - atomic_read(&sent[SMB2_CREATE_HE]),
55172 - atomic_read(&failed[SMB2_CREATE_HE]));
55173 + atomic_read_unchecked(&sent[SMB2_CREATE_HE]),
55174 + atomic_read_unchecked(&failed[SMB2_CREATE_HE]));
55175 seq_printf(m, "\nCloses: %d sent %d failed",
55176 - atomic_read(&sent[SMB2_CLOSE_HE]),
55177 - atomic_read(&failed[SMB2_CLOSE_HE]));
55178 + atomic_read_unchecked(&sent[SMB2_CLOSE_HE]),
55179 + atomic_read_unchecked(&failed[SMB2_CLOSE_HE]));
55180 seq_printf(m, "\nFlushes: %d sent %d failed",
55181 - atomic_read(&sent[SMB2_FLUSH_HE]),
55182 - atomic_read(&failed[SMB2_FLUSH_HE]));
55183 + atomic_read_unchecked(&sent[SMB2_FLUSH_HE]),
55184 + atomic_read_unchecked(&failed[SMB2_FLUSH_HE]));
55185 seq_printf(m, "\nReads: %d sent %d failed",
55186 - atomic_read(&sent[SMB2_READ_HE]),
55187 - atomic_read(&failed[SMB2_READ_HE]));
55188 + atomic_read_unchecked(&sent[SMB2_READ_HE]),
55189 + atomic_read_unchecked(&failed[SMB2_READ_HE]));
55190 seq_printf(m, "\nWrites: %d sent %d failed",
55191 - atomic_read(&sent[SMB2_WRITE_HE]),
55192 - atomic_read(&failed[SMB2_WRITE_HE]));
55193 + atomic_read_unchecked(&sent[SMB2_WRITE_HE]),
55194 + atomic_read_unchecked(&failed[SMB2_WRITE_HE]));
55195 seq_printf(m, "\nLocks: %d sent %d failed",
55196 - atomic_read(&sent[SMB2_LOCK_HE]),
55197 - atomic_read(&failed[SMB2_LOCK_HE]));
55198 + atomic_read_unchecked(&sent[SMB2_LOCK_HE]),
55199 + atomic_read_unchecked(&failed[SMB2_LOCK_HE]));
55200 seq_printf(m, "\nIOCTLs: %d sent %d failed",
55201 - atomic_read(&sent[SMB2_IOCTL_HE]),
55202 - atomic_read(&failed[SMB2_IOCTL_HE]));
55203 + atomic_read_unchecked(&sent[SMB2_IOCTL_HE]),
55204 + atomic_read_unchecked(&failed[SMB2_IOCTL_HE]));
55205 seq_printf(m, "\nCancels: %d sent %d failed",
55206 - atomic_read(&sent[SMB2_CANCEL_HE]),
55207 - atomic_read(&failed[SMB2_CANCEL_HE]));
55208 + atomic_read_unchecked(&sent[SMB2_CANCEL_HE]),
55209 + atomic_read_unchecked(&failed[SMB2_CANCEL_HE]));
55210 seq_printf(m, "\nEchos: %d sent %d failed",
55211 - atomic_read(&sent[SMB2_ECHO_HE]),
55212 - atomic_read(&failed[SMB2_ECHO_HE]));
55213 + atomic_read_unchecked(&sent[SMB2_ECHO_HE]),
55214 + atomic_read_unchecked(&failed[SMB2_ECHO_HE]));
55215 seq_printf(m, "\nQueryDirectories: %d sent %d failed",
55216 - atomic_read(&sent[SMB2_QUERY_DIRECTORY_HE]),
55217 - atomic_read(&failed[SMB2_QUERY_DIRECTORY_HE]));
55218 + atomic_read_unchecked(&sent[SMB2_QUERY_DIRECTORY_HE]),
55219 + atomic_read_unchecked(&failed[SMB2_QUERY_DIRECTORY_HE]));
55220 seq_printf(m, "\nChangeNotifies: %d sent %d failed",
55221 - atomic_read(&sent[SMB2_CHANGE_NOTIFY_HE]),
55222 - atomic_read(&failed[SMB2_CHANGE_NOTIFY_HE]));
55223 + atomic_read_unchecked(&sent[SMB2_CHANGE_NOTIFY_HE]),
55224 + atomic_read_unchecked(&failed[SMB2_CHANGE_NOTIFY_HE]));
55225 seq_printf(m, "\nQueryInfos: %d sent %d failed",
55226 - atomic_read(&sent[SMB2_QUERY_INFO_HE]),
55227 - atomic_read(&failed[SMB2_QUERY_INFO_HE]));
55228 + atomic_read_unchecked(&sent[SMB2_QUERY_INFO_HE]),
55229 + atomic_read_unchecked(&failed[SMB2_QUERY_INFO_HE]));
55230 seq_printf(m, "\nSetInfos: %d sent %d failed",
55231 - atomic_read(&sent[SMB2_SET_INFO_HE]),
55232 - atomic_read(&failed[SMB2_SET_INFO_HE]));
55233 + atomic_read_unchecked(&sent[SMB2_SET_INFO_HE]),
55234 + atomic_read_unchecked(&failed[SMB2_SET_INFO_HE]));
55235 seq_printf(m, "\nOplockBreaks: %d sent %d failed",
55236 - atomic_read(&sent[SMB2_OPLOCK_BREAK_HE]),
55237 - atomic_read(&failed[SMB2_OPLOCK_BREAK_HE]));
55238 + atomic_read_unchecked(&sent[SMB2_OPLOCK_BREAK_HE]),
55239 + atomic_read_unchecked(&failed[SMB2_OPLOCK_BREAK_HE]));
55240 #endif
55241 }
55242
55243 diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
55244 index edccb52..16bc6db 100644
55245 --- a/fs/cifs/smb2pdu.c
55246 +++ b/fs/cifs/smb2pdu.c
55247 @@ -1957,8 +1957,7 @@ SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon,
55248 default:
55249 cifs_dbg(VFS, "info level %u isn't supported\n",
55250 srch_inf->info_level);
55251 - rc = -EINVAL;
55252 - goto qdir_exit;
55253 + return -EINVAL;
55254 }
55255
55256 req->FileIndex = cpu_to_le32(index);
55257 diff --git a/fs/coda/cache.c b/fs/coda/cache.c
55258 index 1da168c..8bc7ff6 100644
55259 --- a/fs/coda/cache.c
55260 +++ b/fs/coda/cache.c
55261 @@ -24,7 +24,7 @@
55262 #include "coda_linux.h"
55263 #include "coda_cache.h"
55264
55265 -static atomic_t permission_epoch = ATOMIC_INIT(0);
55266 +static atomic_unchecked_t permission_epoch = ATOMIC_INIT(0);
55267
55268 /* replace or extend an acl cache hit */
55269 void coda_cache_enter(struct inode *inode, int mask)
55270 @@ -32,7 +32,7 @@ void coda_cache_enter(struct inode *inode, int mask)
55271 struct coda_inode_info *cii = ITOC(inode);
55272
55273 spin_lock(&cii->c_lock);
55274 - cii->c_cached_epoch = atomic_read(&permission_epoch);
55275 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch);
55276 if (!uid_eq(cii->c_uid, current_fsuid())) {
55277 cii->c_uid = current_fsuid();
55278 cii->c_cached_perm = mask;
55279 @@ -46,14 +46,14 @@ void coda_cache_clear_inode(struct inode *inode)
55280 {
55281 struct coda_inode_info *cii = ITOC(inode);
55282 spin_lock(&cii->c_lock);
55283 - cii->c_cached_epoch = atomic_read(&permission_epoch) - 1;
55284 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch) - 1;
55285 spin_unlock(&cii->c_lock);
55286 }
55287
55288 /* remove all acl caches */
55289 void coda_cache_clear_all(struct super_block *sb)
55290 {
55291 - atomic_inc(&permission_epoch);
55292 + atomic_inc_unchecked(&permission_epoch);
55293 }
55294
55295
55296 @@ -66,7 +66,7 @@ int coda_cache_check(struct inode *inode, int mask)
55297 spin_lock(&cii->c_lock);
55298 hit = (mask & cii->c_cached_perm) == mask &&
55299 uid_eq(cii->c_uid, current_fsuid()) &&
55300 - cii->c_cached_epoch == atomic_read(&permission_epoch);
55301 + cii->c_cached_epoch == atomic_read_unchecked(&permission_epoch);
55302 spin_unlock(&cii->c_lock);
55303
55304 return hit;
55305 diff --git a/fs/compat.c b/fs/compat.c
55306 index 6af20de..fec3fbb 100644
55307 --- a/fs/compat.c
55308 +++ b/fs/compat.c
55309 @@ -54,7 +54,7 @@
55310 #include <asm/ioctls.h>
55311 #include "internal.h"
55312
55313 -int compat_log = 1;
55314 +int compat_log = 0;
55315
55316 int compat_printk(const char *fmt, ...)
55317 {
55318 @@ -488,7 +488,7 @@ compat_sys_io_setup(unsigned nr_reqs, u32 __user *ctx32p)
55319
55320 set_fs(KERNEL_DS);
55321 /* The __user pointer cast is valid because of the set_fs() */
55322 - ret = sys_io_setup(nr_reqs, (aio_context_t __user *) &ctx64);
55323 + ret = sys_io_setup(nr_reqs, (aio_context_t __force_user *) &ctx64);
55324 set_fs(oldfs);
55325 /* truncating is ok because it's a user address */
55326 if (!ret)
55327 @@ -546,7 +546,7 @@ ssize_t compat_rw_copy_check_uvector(int type,
55328 goto out;
55329
55330 ret = -EINVAL;
55331 - if (nr_segs > UIO_MAXIOV || nr_segs < 0)
55332 + if (nr_segs > UIO_MAXIOV)
55333 goto out;
55334 if (nr_segs > fast_segs) {
55335 ret = -ENOMEM;
55336 @@ -834,6 +834,7 @@ struct compat_old_linux_dirent {
55337 struct compat_readdir_callback {
55338 struct dir_context ctx;
55339 struct compat_old_linux_dirent __user *dirent;
55340 + struct file * file;
55341 int result;
55342 };
55343
55344 @@ -851,6 +852,10 @@ static int compat_fillonedir(void *__buf, const char *name, int namlen,
55345 buf->result = -EOVERFLOW;
55346 return -EOVERFLOW;
55347 }
55348 +
55349 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
55350 + return 0;
55351 +
55352 buf->result++;
55353 dirent = buf->dirent;
55354 if (!access_ok(VERIFY_WRITE, dirent,
55355 @@ -882,6 +887,7 @@ asmlinkage long compat_sys_old_readdir(unsigned int fd,
55356 if (!f.file)
55357 return -EBADF;
55358
55359 + buf.file = f.file;
55360 error = iterate_dir(f.file, &buf.ctx);
55361 if (buf.result)
55362 error = buf.result;
55363 @@ -901,6 +907,7 @@ struct compat_getdents_callback {
55364 struct dir_context ctx;
55365 struct compat_linux_dirent __user *current_dir;
55366 struct compat_linux_dirent __user *previous;
55367 + struct file * file;
55368 int count;
55369 int error;
55370 };
55371 @@ -922,6 +929,10 @@ static int compat_filldir(void *__buf, const char *name, int namlen,
55372 buf->error = -EOVERFLOW;
55373 return -EOVERFLOW;
55374 }
55375 +
55376 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
55377 + return 0;
55378 +
55379 dirent = buf->previous;
55380 if (dirent) {
55381 if (__put_user(offset, &dirent->d_off))
55382 @@ -967,6 +978,7 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
55383 if (!f.file)
55384 return -EBADF;
55385
55386 + buf.file = f.file;
55387 error = iterate_dir(f.file, &buf.ctx);
55388 if (error >= 0)
55389 error = buf.error;
55390 @@ -987,6 +999,7 @@ struct compat_getdents_callback64 {
55391 struct dir_context ctx;
55392 struct linux_dirent64 __user *current_dir;
55393 struct linux_dirent64 __user *previous;
55394 + struct file * file;
55395 int count;
55396 int error;
55397 };
55398 @@ -1003,6 +1016,10 @@ static int compat_filldir64(void * __buf, const char * name, int namlen, loff_t
55399 buf->error = -EINVAL; /* only used if we fail.. */
55400 if (reclen > buf->count)
55401 return -EINVAL;
55402 +
55403 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
55404 + return 0;
55405 +
55406 dirent = buf->previous;
55407
55408 if (dirent) {
55409 @@ -1052,6 +1069,7 @@ asmlinkage long compat_sys_getdents64(unsigned int fd,
55410 if (!f.file)
55411 return -EBADF;
55412
55413 + buf.file = f.file;
55414 error = iterate_dir(f.file, &buf.ctx);
55415 if (error >= 0)
55416 error = buf.error;
55417 diff --git a/fs/compat_binfmt_elf.c b/fs/compat_binfmt_elf.c
55418 index a81147e..20bf2b5 100644
55419 --- a/fs/compat_binfmt_elf.c
55420 +++ b/fs/compat_binfmt_elf.c
55421 @@ -30,11 +30,13 @@
55422 #undef elf_phdr
55423 #undef elf_shdr
55424 #undef elf_note
55425 +#undef elf_dyn
55426 #undef elf_addr_t
55427 #define elfhdr elf32_hdr
55428 #define elf_phdr elf32_phdr
55429 #define elf_shdr elf32_shdr
55430 #define elf_note elf32_note
55431 +#define elf_dyn Elf32_Dyn
55432 #define elf_addr_t Elf32_Addr
55433
55434 /*
55435 diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
55436 index 5d19acf..9ab093b 100644
55437 --- a/fs/compat_ioctl.c
55438 +++ b/fs/compat_ioctl.c
55439 @@ -621,7 +621,7 @@ static int serial_struct_ioctl(unsigned fd, unsigned cmd,
55440 return -EFAULT;
55441 if (__get_user(udata, &ss32->iomem_base))
55442 return -EFAULT;
55443 - ss.iomem_base = compat_ptr(udata);
55444 + ss.iomem_base = (unsigned char __force_kernel *)compat_ptr(udata);
55445 if (__get_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift) ||
55446 __get_user(ss.port_high, &ss32->port_high))
55447 return -EFAULT;
55448 @@ -702,8 +702,8 @@ static int do_i2c_rdwr_ioctl(unsigned int fd, unsigned int cmd,
55449 for (i = 0; i < nmsgs; i++) {
55450 if (copy_in_user(&tmsgs[i].addr, &umsgs[i].addr, 3*sizeof(u16)))
55451 return -EFAULT;
55452 - if (get_user(datap, &umsgs[i].buf) ||
55453 - put_user(compat_ptr(datap), &tmsgs[i].buf))
55454 + if (get_user(datap, (u8 __user * __user *)&umsgs[i].buf) ||
55455 + put_user(compat_ptr(datap), (u8 __user * __user *)&tmsgs[i].buf))
55456 return -EFAULT;
55457 }
55458 return sys_ioctl(fd, cmd, (unsigned long)tdata);
55459 @@ -796,7 +796,7 @@ static int compat_ioctl_preallocate(struct file *file,
55460 copy_in_user(&p->l_len, &p32->l_len, sizeof(s64)) ||
55461 copy_in_user(&p->l_sysid, &p32->l_sysid, sizeof(s32)) ||
55462 copy_in_user(&p->l_pid, &p32->l_pid, sizeof(u32)) ||
55463 - copy_in_user(&p->l_pad, &p32->l_pad, 4*sizeof(u32)))
55464 + copy_in_user(p->l_pad, &p32->l_pad, 4*sizeof(u32)))
55465 return -EFAULT;
55466
55467 return ioctl_preallocate(file, p);
55468 @@ -1616,8 +1616,8 @@ asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
55469 static int __init init_sys32_ioctl_cmp(const void *p, const void *q)
55470 {
55471 unsigned int a, b;
55472 - a = *(unsigned int *)p;
55473 - b = *(unsigned int *)q;
55474 + a = *(const unsigned int *)p;
55475 + b = *(const unsigned int *)q;
55476 if (a > b)
55477 return 1;
55478 if (a < b)
55479 diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
55480 index 511d415..319d0e5 100644
55481 --- a/fs/configfs/dir.c
55482 +++ b/fs/configfs/dir.c
55483 @@ -1558,7 +1558,8 @@ static int configfs_readdir(struct file *file, struct dir_context *ctx)
55484 }
55485 for (p = q->next; p != &parent_sd->s_children; p = p->next) {
55486 struct configfs_dirent *next;
55487 - const char *name;
55488 + const unsigned char * name;
55489 + char d_name[sizeof(next->s_dentry->d_iname)];
55490 int len;
55491 struct inode *inode = NULL;
55492
55493 @@ -1567,7 +1568,12 @@ static int configfs_readdir(struct file *file, struct dir_context *ctx)
55494 continue;
55495
55496 name = configfs_get_name(next);
55497 - len = strlen(name);
55498 + if (next->s_dentry && name == next->s_dentry->d_iname) {
55499 + len = next->s_dentry->d_name.len;
55500 + memcpy(d_name, name, len);
55501 + name = d_name;
55502 + } else
55503 + len = strlen(name);
55504
55505 /*
55506 * We'll have a dentry and an inode for
55507 diff --git a/fs/coredump.c b/fs/coredump.c
55508 index 9bdeca1..2a9b08d 100644
55509 --- a/fs/coredump.c
55510 +++ b/fs/coredump.c
55511 @@ -438,8 +438,8 @@ static void wait_for_dump_helpers(struct file *file)
55512 struct pipe_inode_info *pipe = file->private_data;
55513
55514 pipe_lock(pipe);
55515 - pipe->readers++;
55516 - pipe->writers--;
55517 + atomic_inc(&pipe->readers);
55518 + atomic_dec(&pipe->writers);
55519 wake_up_interruptible_sync(&pipe->wait);
55520 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
55521 pipe_unlock(pipe);
55522 @@ -448,11 +448,11 @@ static void wait_for_dump_helpers(struct file *file)
55523 * We actually want wait_event_freezable() but then we need
55524 * to clear TIF_SIGPENDING and improve dump_interrupted().
55525 */
55526 - wait_event_interruptible(pipe->wait, pipe->readers == 1);
55527 + wait_event_interruptible(pipe->wait, atomic_read(&pipe->readers) == 1);
55528
55529 pipe_lock(pipe);
55530 - pipe->readers--;
55531 - pipe->writers++;
55532 + atomic_dec(&pipe->readers);
55533 + atomic_inc(&pipe->writers);
55534 pipe_unlock(pipe);
55535 }
55536
55537 @@ -499,7 +499,9 @@ void do_coredump(siginfo_t *siginfo)
55538 struct files_struct *displaced;
55539 bool need_nonrelative = false;
55540 bool core_dumped = false;
55541 - static atomic_t core_dump_count = ATOMIC_INIT(0);
55542 + static atomic_unchecked_t core_dump_count = ATOMIC_INIT(0);
55543 + long signr = siginfo->si_signo;
55544 + int dumpable;
55545 struct coredump_params cprm = {
55546 .siginfo = siginfo,
55547 .regs = signal_pt_regs(),
55548 @@ -512,12 +514,17 @@ void do_coredump(siginfo_t *siginfo)
55549 .mm_flags = mm->flags,
55550 };
55551
55552 - audit_core_dumps(siginfo->si_signo);
55553 + audit_core_dumps(signr);
55554 +
55555 + dumpable = __get_dumpable(cprm.mm_flags);
55556 +
55557 + if (signr == SIGSEGV || signr == SIGBUS || signr == SIGKILL || signr == SIGILL)
55558 + gr_handle_brute_attach(dumpable);
55559
55560 binfmt = mm->binfmt;
55561 if (!binfmt || !binfmt->core_dump)
55562 goto fail;
55563 - if (!__get_dumpable(cprm.mm_flags))
55564 + if (!dumpable)
55565 goto fail;
55566
55567 cred = prepare_creds();
55568 @@ -536,7 +543,7 @@ void do_coredump(siginfo_t *siginfo)
55569 need_nonrelative = true;
55570 }
55571
55572 - retval = coredump_wait(siginfo->si_signo, &core_state);
55573 + retval = coredump_wait(signr, &core_state);
55574 if (retval < 0)
55575 goto fail_creds;
55576
55577 @@ -579,7 +586,7 @@ void do_coredump(siginfo_t *siginfo)
55578 }
55579 cprm.limit = RLIM_INFINITY;
55580
55581 - dump_count = atomic_inc_return(&core_dump_count);
55582 + dump_count = atomic_inc_return_unchecked(&core_dump_count);
55583 if (core_pipe_limit && (core_pipe_limit < dump_count)) {
55584 printk(KERN_WARNING "Pid %d(%s) over core_pipe_limit\n",
55585 task_tgid_vnr(current), current->comm);
55586 @@ -611,6 +618,8 @@ void do_coredump(siginfo_t *siginfo)
55587 } else {
55588 struct inode *inode;
55589
55590 + gr_learn_resource(current, RLIMIT_CORE, binfmt->min_coredump, 1);
55591 +
55592 if (cprm.limit < binfmt->min_coredump)
55593 goto fail_unlock;
55594
55595 @@ -669,7 +678,7 @@ close_fail:
55596 filp_close(cprm.file, NULL);
55597 fail_dropcount:
55598 if (ispipe)
55599 - atomic_dec(&core_dump_count);
55600 + atomic_dec_unchecked(&core_dump_count);
55601 fail_unlock:
55602 kfree(cn.corename);
55603 coredump_finish(mm, core_dumped);
55604 @@ -689,7 +698,7 @@ int dump_write(struct file *file, const void *addr, int nr)
55605 {
55606 return !dump_interrupted() &&
55607 access_ok(VERIFY_READ, addr, nr) &&
55608 - file->f_op->write(file, addr, nr, &file->f_pos) == nr;
55609 + file->f_op->write(file, (const char __force_user *)addr, nr, &file->f_pos) == nr;
55610 }
55611 EXPORT_SYMBOL(dump_write);
55612
55613 diff --git a/fs/dcache.c b/fs/dcache.c
55614 index 89f9671..d2dce57 100644
55615 --- a/fs/dcache.c
55616 +++ b/fs/dcache.c
55617 @@ -1570,7 +1570,7 @@ struct dentry *__d_alloc(struct super_block *sb, const struct qstr *name)
55618 */
55619 dentry->d_iname[DNAME_INLINE_LEN-1] = 0;
55620 if (name->len > DNAME_INLINE_LEN-1) {
55621 - dname = kmalloc(name->len + 1, GFP_KERNEL);
55622 + dname = kmalloc(round_up(name->len + 1, sizeof(unsigned long)), GFP_KERNEL);
55623 if (!dname) {
55624 kmem_cache_free(dentry_cache, dentry);
55625 return NULL;
55626 @@ -2893,6 +2893,7 @@ static int prepend_path(const struct path *path,
55627 restart:
55628 bptr = *buffer;
55629 blen = *buflen;
55630 + error = 0;
55631 dentry = path->dentry;
55632 vfsmnt = path->mnt;
55633 mnt = real_mount(vfsmnt);
55634 @@ -3432,7 +3433,8 @@ void __init vfs_caches_init(unsigned long mempages)
55635 mempages -= reserve;
55636
55637 names_cachep = kmem_cache_create("names_cache", PATH_MAX, 0,
55638 - SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
55639 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_USERCOPY|
55640 + SLAB_NO_SANITIZE, NULL);
55641
55642 dcache_init();
55643 inode_init();
55644 diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
55645 index c7c83ff..bda9461 100644
55646 --- a/fs/debugfs/inode.c
55647 +++ b/fs/debugfs/inode.c
55648 @@ -415,7 +415,11 @@ EXPORT_SYMBOL_GPL(debugfs_create_file);
55649 */
55650 struct dentry *debugfs_create_dir(const char *name, struct dentry *parent)
55651 {
55652 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
55653 + return __create_file(name, S_IFDIR | S_IRWXU,
55654 +#else
55655 return __create_file(name, S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO,
55656 +#endif
55657 parent, NULL, NULL);
55658 }
55659 EXPORT_SYMBOL_GPL(debugfs_create_dir);
55660 diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
55661 index 67e9b63..a9adb68 100644
55662 --- a/fs/ecryptfs/inode.c
55663 +++ b/fs/ecryptfs/inode.c
55664 @@ -674,7 +674,7 @@ static int ecryptfs_readlink_lower(struct dentry *dentry, char **buf,
55665 old_fs = get_fs();
55666 set_fs(get_ds());
55667 rc = lower_dentry->d_inode->i_op->readlink(lower_dentry,
55668 - (char __user *)lower_buf,
55669 + (char __force_user *)lower_buf,
55670 PATH_MAX);
55671 set_fs(old_fs);
55672 if (rc < 0)
55673 @@ -706,7 +706,7 @@ out:
55674 static void
55675 ecryptfs_put_link(struct dentry *dentry, struct nameidata *nd, void *ptr)
55676 {
55677 - char *buf = nd_get_link(nd);
55678 + const char *buf = nd_get_link(nd);
55679 if (!IS_ERR(buf)) {
55680 /* Free the char* */
55681 kfree(buf);
55682 diff --git a/fs/ecryptfs/miscdev.c b/fs/ecryptfs/miscdev.c
55683 index e4141f2..d8263e8 100644
55684 --- a/fs/ecryptfs/miscdev.c
55685 +++ b/fs/ecryptfs/miscdev.c
55686 @@ -304,7 +304,7 @@ check_list:
55687 goto out_unlock_msg_ctx;
55688 i = PKT_TYPE_SIZE + PKT_CTR_SIZE;
55689 if (msg_ctx->msg) {
55690 - if (copy_to_user(&buf[i], packet_length, packet_length_size))
55691 + if (packet_length_size > sizeof(packet_length) || copy_to_user(&buf[i], packet_length, packet_length_size))
55692 goto out_unlock_msg_ctx;
55693 i += packet_length_size;
55694 if (copy_to_user(&buf[i], msg_ctx->msg, msg_ctx->msg_size))
55695 diff --git a/fs/exec.c b/fs/exec.c
55696 index bb8afc1..2f5087e 100644
55697 --- a/fs/exec.c
55698 +++ b/fs/exec.c
55699 @@ -55,8 +55,20 @@
55700 #include <linux/pipe_fs_i.h>
55701 #include <linux/oom.h>
55702 #include <linux/compat.h>
55703 +#include <linux/random.h>
55704 +#include <linux/seq_file.h>
55705 +#include <linux/coredump.h>
55706 +#include <linux/mman.h>
55707 +
55708 +#ifdef CONFIG_PAX_REFCOUNT
55709 +#include <linux/kallsyms.h>
55710 +#include <linux/kdebug.h>
55711 +#endif
55712 +
55713 +#include <trace/events/fs.h>
55714
55715 #include <asm/uaccess.h>
55716 +#include <asm/sections.h>
55717 #include <asm/mmu_context.h>
55718 #include <asm/tlb.h>
55719
55720 @@ -66,19 +78,34 @@
55721
55722 #include <trace/events/sched.h>
55723
55724 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
55725 +void __weak pax_set_initial_flags(struct linux_binprm *bprm)
55726 +{
55727 + 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");
55728 +}
55729 +#endif
55730 +
55731 +#ifdef CONFIG_PAX_HOOK_ACL_FLAGS
55732 +void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
55733 +EXPORT_SYMBOL(pax_set_initial_flags_func);
55734 +#endif
55735 +
55736 int suid_dumpable = 0;
55737
55738 static LIST_HEAD(formats);
55739 static DEFINE_RWLOCK(binfmt_lock);
55740
55741 +extern int gr_process_kernel_exec_ban(void);
55742 +extern int gr_process_suid_exec_ban(const struct linux_binprm *bprm);
55743 +
55744 void __register_binfmt(struct linux_binfmt * fmt, int insert)
55745 {
55746 BUG_ON(!fmt);
55747 if (WARN_ON(!fmt->load_binary))
55748 return;
55749 write_lock(&binfmt_lock);
55750 - insert ? list_add(&fmt->lh, &formats) :
55751 - list_add_tail(&fmt->lh, &formats);
55752 + insert ? pax_list_add((struct list_head *)&fmt->lh, &formats) :
55753 + pax_list_add_tail((struct list_head *)&fmt->lh, &formats);
55754 write_unlock(&binfmt_lock);
55755 }
55756
55757 @@ -87,7 +114,7 @@ EXPORT_SYMBOL(__register_binfmt);
55758 void unregister_binfmt(struct linux_binfmt * fmt)
55759 {
55760 write_lock(&binfmt_lock);
55761 - list_del(&fmt->lh);
55762 + pax_list_del((struct list_head *)&fmt->lh);
55763 write_unlock(&binfmt_lock);
55764 }
55765
55766 @@ -183,18 +210,10 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
55767 int write)
55768 {
55769 struct page *page;
55770 - int ret;
55771
55772 -#ifdef CONFIG_STACK_GROWSUP
55773 - if (write) {
55774 - ret = expand_downwards(bprm->vma, pos);
55775 - if (ret < 0)
55776 - return NULL;
55777 - }
55778 -#endif
55779 - ret = get_user_pages(current, bprm->mm, pos,
55780 - 1, write, 1, &page, NULL);
55781 - if (ret <= 0)
55782 + if (0 > expand_downwards(bprm->vma, pos))
55783 + return NULL;
55784 + if (0 >= get_user_pages(current, bprm->mm, pos, 1, write, 1, &page, NULL))
55785 return NULL;
55786
55787 if (write) {
55788 @@ -210,6 +229,17 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
55789 if (size <= ARG_MAX)
55790 return page;
55791
55792 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55793 + // only allow 512KB for argv+env on suid/sgid binaries
55794 + // to prevent easy ASLR exhaustion
55795 + if (((!uid_eq(bprm->cred->euid, current_euid())) ||
55796 + (!gid_eq(bprm->cred->egid, current_egid()))) &&
55797 + (size > (512 * 1024))) {
55798 + put_page(page);
55799 + return NULL;
55800 + }
55801 +#endif
55802 +
55803 /*
55804 * Limit to 1/4-th the stack size for the argv+env strings.
55805 * This ensures that:
55806 @@ -269,6 +299,11 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
55807 vma->vm_end = STACK_TOP_MAX;
55808 vma->vm_start = vma->vm_end - PAGE_SIZE;
55809 vma->vm_flags = VM_SOFTDIRTY | VM_STACK_FLAGS | VM_STACK_INCOMPLETE_SETUP;
55810 +
55811 +#ifdef CONFIG_PAX_SEGMEXEC
55812 + vma->vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
55813 +#endif
55814 +
55815 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
55816 INIT_LIST_HEAD(&vma->anon_vma_chain);
55817
55818 @@ -279,6 +314,12 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
55819 mm->stack_vm = mm->total_vm = 1;
55820 up_write(&mm->mmap_sem);
55821 bprm->p = vma->vm_end - sizeof(void *);
55822 +
55823 +#ifdef CONFIG_PAX_RANDUSTACK
55824 + if (randomize_va_space)
55825 + bprm->p ^= prandom_u32() & ~PAGE_MASK;
55826 +#endif
55827 +
55828 return 0;
55829 err:
55830 up_write(&mm->mmap_sem);
55831 @@ -399,7 +440,7 @@ struct user_arg_ptr {
55832 } ptr;
55833 };
55834
55835 -static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
55836 +const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
55837 {
55838 const char __user *native;
55839
55840 @@ -408,14 +449,14 @@ static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
55841 compat_uptr_t compat;
55842
55843 if (get_user(compat, argv.ptr.compat + nr))
55844 - return ERR_PTR(-EFAULT);
55845 + return (const char __force_user *)ERR_PTR(-EFAULT);
55846
55847 return compat_ptr(compat);
55848 }
55849 #endif
55850
55851 if (get_user(native, argv.ptr.native + nr))
55852 - return ERR_PTR(-EFAULT);
55853 + return (const char __force_user *)ERR_PTR(-EFAULT);
55854
55855 return native;
55856 }
55857 @@ -434,7 +475,7 @@ static int count(struct user_arg_ptr argv, int max)
55858 if (!p)
55859 break;
55860
55861 - if (IS_ERR(p))
55862 + if (IS_ERR((const char __force_kernel *)p))
55863 return -EFAULT;
55864
55865 if (i >= max)
55866 @@ -469,7 +510,7 @@ static int copy_strings(int argc, struct user_arg_ptr argv,
55867
55868 ret = -EFAULT;
55869 str = get_user_arg_ptr(argv, argc);
55870 - if (IS_ERR(str))
55871 + if (IS_ERR((const char __force_kernel *)str))
55872 goto out;
55873
55874 len = strnlen_user(str, MAX_ARG_STRLEN);
55875 @@ -551,7 +592,7 @@ int copy_strings_kernel(int argc, const char *const *__argv,
55876 int r;
55877 mm_segment_t oldfs = get_fs();
55878 struct user_arg_ptr argv = {
55879 - .ptr.native = (const char __user *const __user *)__argv,
55880 + .ptr.native = (const char __force_user * const __force_user *)__argv,
55881 };
55882
55883 set_fs(KERNEL_DS);
55884 @@ -586,7 +627,8 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
55885 unsigned long new_end = old_end - shift;
55886 struct mmu_gather tlb;
55887
55888 - BUG_ON(new_start > new_end);
55889 + if (new_start >= new_end || new_start < mmap_min_addr)
55890 + return -ENOMEM;
55891
55892 /*
55893 * ensure there are no vmas between where we want to go
55894 @@ -595,6 +637,10 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
55895 if (vma != find_vma(mm, new_start))
55896 return -EFAULT;
55897
55898 +#ifdef CONFIG_PAX_SEGMEXEC
55899 + BUG_ON(pax_find_mirror_vma(vma));
55900 +#endif
55901 +
55902 /*
55903 * cover the whole range: [new_start, old_end)
55904 */
55905 @@ -675,10 +721,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
55906 stack_top = arch_align_stack(stack_top);
55907 stack_top = PAGE_ALIGN(stack_top);
55908
55909 - if (unlikely(stack_top < mmap_min_addr) ||
55910 - unlikely(vma->vm_end - vma->vm_start >= stack_top - mmap_min_addr))
55911 - return -ENOMEM;
55912 -
55913 stack_shift = vma->vm_end - stack_top;
55914
55915 bprm->p -= stack_shift;
55916 @@ -690,8 +732,28 @@ int setup_arg_pages(struct linux_binprm *bprm,
55917 bprm->exec -= stack_shift;
55918
55919 down_write(&mm->mmap_sem);
55920 +
55921 + /* Move stack pages down in memory. */
55922 + if (stack_shift) {
55923 + ret = shift_arg_pages(vma, stack_shift);
55924 + if (ret)
55925 + goto out_unlock;
55926 + }
55927 +
55928 vm_flags = VM_STACK_FLAGS;
55929
55930 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
55931 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
55932 + vm_flags &= ~VM_EXEC;
55933 +
55934 +#ifdef CONFIG_PAX_MPROTECT
55935 + if (mm->pax_flags & MF_PAX_MPROTECT)
55936 + vm_flags &= ~VM_MAYEXEC;
55937 +#endif
55938 +
55939 + }
55940 +#endif
55941 +
55942 /*
55943 * Adjust stack execute permissions; explicitly enable for
55944 * EXSTACK_ENABLE_X, disable for EXSTACK_DISABLE_X and leave alone
55945 @@ -710,13 +772,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
55946 goto out_unlock;
55947 BUG_ON(prev != vma);
55948
55949 - /* Move stack pages down in memory. */
55950 - if (stack_shift) {
55951 - ret = shift_arg_pages(vma, stack_shift);
55952 - if (ret)
55953 - goto out_unlock;
55954 - }
55955 -
55956 /* mprotect_fixup is overkill to remove the temporary stack flags */
55957 vma->vm_flags &= ~VM_STACK_INCOMPLETE_SETUP;
55958
55959 @@ -740,6 +795,27 @@ int setup_arg_pages(struct linux_binprm *bprm,
55960 #endif
55961 current->mm->start_stack = bprm->p;
55962 ret = expand_stack(vma, stack_base);
55963 +
55964 +#if !defined(CONFIG_STACK_GROWSUP) && defined(CONFIG_PAX_RANDMMAP)
55965 + if (!ret && (mm->pax_flags & MF_PAX_RANDMMAP) && STACK_TOP <= 0xFFFFFFFFU && STACK_TOP > vma->vm_end) {
55966 + unsigned long size;
55967 + vm_flags_t vm_flags;
55968 +
55969 + size = STACK_TOP - vma->vm_end;
55970 + vm_flags = VM_NONE | VM_DONTEXPAND | VM_DONTDUMP;
55971 +
55972 + ret = vma->vm_end != mmap_region(NULL, vma->vm_end, size, vm_flags, 0);
55973 +
55974 +#ifdef CONFIG_X86
55975 + if (!ret) {
55976 + size = PAGE_SIZE + mmap_min_addr + ((mm->delta_mmap ^ mm->delta_stack) & (0xFFUL << PAGE_SHIFT));
55977 + ret = 0 != mmap_region(NULL, 0, PAGE_ALIGN(size), vm_flags, 0);
55978 + }
55979 +#endif
55980 +
55981 + }
55982 +#endif
55983 +
55984 if (ret)
55985 ret = -EFAULT;
55986
55987 @@ -776,6 +852,8 @@ struct file *open_exec(const char *name)
55988
55989 fsnotify_open(file);
55990
55991 + trace_open_exec(name);
55992 +
55993 err = deny_write_access(file);
55994 if (err)
55995 goto exit;
55996 @@ -799,7 +877,7 @@ int kernel_read(struct file *file, loff_t offset,
55997 old_fs = get_fs();
55998 set_fs(get_ds());
55999 /* The cast to a user pointer is valid due to the set_fs() */
56000 - result = vfs_read(file, (void __user *)addr, count, &pos);
56001 + result = vfs_read(file, (void __force_user *)addr, count, &pos);
56002 set_fs(old_fs);
56003 return result;
56004 }
56005 @@ -1255,7 +1333,7 @@ static int check_unsafe_exec(struct linux_binprm *bprm)
56006 }
56007 rcu_read_unlock();
56008
56009 - if (p->fs->users > n_fs) {
56010 + if (atomic_read(&p->fs->users) > n_fs) {
56011 bprm->unsafe |= LSM_UNSAFE_SHARE;
56012 } else {
56013 res = -EAGAIN;
56014 @@ -1451,6 +1529,31 @@ static int exec_binprm(struct linux_binprm *bprm)
56015 return ret;
56016 }
56017
56018 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56019 +static DEFINE_PER_CPU(u64, exec_counter);
56020 +static int __init init_exec_counters(void)
56021 +{
56022 + unsigned int cpu;
56023 +
56024 + for_each_possible_cpu(cpu) {
56025 + per_cpu(exec_counter, cpu) = (u64)cpu;
56026 + }
56027 +
56028 + return 0;
56029 +}
56030 +early_initcall(init_exec_counters);
56031 +static inline void increment_exec_counter(void)
56032 +{
56033 + BUILD_BUG_ON(NR_CPUS > (1 << 16));
56034 + current->exec_id = this_cpu_add_return(exec_counter, 1 << 16);
56035 +}
56036 +#else
56037 +static inline void increment_exec_counter(void) {}
56038 +#endif
56039 +
56040 +extern void gr_handle_exec_args(struct linux_binprm *bprm,
56041 + struct user_arg_ptr argv);
56042 +
56043 /*
56044 * sys_execve() executes a new program.
56045 */
56046 @@ -1458,12 +1561,19 @@ static int do_execve_common(const char *filename,
56047 struct user_arg_ptr argv,
56048 struct user_arg_ptr envp)
56049 {
56050 +#ifdef CONFIG_GRKERNSEC
56051 + struct file *old_exec_file;
56052 + struct acl_subject_label *old_acl;
56053 + struct rlimit old_rlim[RLIM_NLIMITS];
56054 +#endif
56055 struct linux_binprm *bprm;
56056 struct file *file;
56057 struct files_struct *displaced;
56058 bool clear_in_exec;
56059 int retval;
56060
56061 + gr_learn_resource(current, RLIMIT_NPROC, atomic_read(&current_user()->processes), 1);
56062 +
56063 /*
56064 * We move the actual failure in case of RLIMIT_NPROC excess from
56065 * set*uid() to execve() because too many poorly written programs
56066 @@ -1504,12 +1614,22 @@ static int do_execve_common(const char *filename,
56067 if (IS_ERR(file))
56068 goto out_unmark;
56069
56070 + if (gr_ptrace_readexec(file, bprm->unsafe)) {
56071 + retval = -EPERM;
56072 + goto out_file;
56073 + }
56074 +
56075 sched_exec();
56076
56077 bprm->file = file;
56078 bprm->filename = filename;
56079 bprm->interp = filename;
56080
56081 + if (!gr_acl_handle_execve(file->f_path.dentry, file->f_path.mnt)) {
56082 + retval = -EACCES;
56083 + goto out_file;
56084 + }
56085 +
56086 retval = bprm_mm_init(bprm);
56087 if (retval)
56088 goto out_file;
56089 @@ -1526,24 +1646,70 @@ static int do_execve_common(const char *filename,
56090 if (retval < 0)
56091 goto out;
56092
56093 +#ifdef CONFIG_GRKERNSEC
56094 + old_acl = current->acl;
56095 + memcpy(old_rlim, current->signal->rlim, sizeof(old_rlim));
56096 + old_exec_file = current->exec_file;
56097 + get_file(file);
56098 + current->exec_file = file;
56099 +#endif
56100 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56101 + /* limit suid stack to 8MB
56102 + * we saved the old limits above and will restore them if this exec fails
56103 + */
56104 + if (((!uid_eq(bprm->cred->euid, current_euid())) || (!gid_eq(bprm->cred->egid, current_egid()))) &&
56105 + (old_rlim[RLIMIT_STACK].rlim_cur > (8 * 1024 * 1024)))
56106 + current->signal->rlim[RLIMIT_STACK].rlim_cur = 8 * 1024 * 1024;
56107 +#endif
56108 +
56109 + if (gr_process_kernel_exec_ban() || gr_process_suid_exec_ban(bprm)) {
56110 + retval = -EPERM;
56111 + goto out_fail;
56112 + }
56113 +
56114 + if (!gr_tpe_allow(file)) {
56115 + retval = -EACCES;
56116 + goto out_fail;
56117 + }
56118 +
56119 + if (gr_check_crash_exec(file)) {
56120 + retval = -EACCES;
56121 + goto out_fail;
56122 + }
56123 +
56124 + retval = gr_set_proc_label(file->f_path.dentry, file->f_path.mnt,
56125 + bprm->unsafe);
56126 + if (retval < 0)
56127 + goto out_fail;
56128 +
56129 retval = copy_strings_kernel(1, &bprm->filename, bprm);
56130 if (retval < 0)
56131 - goto out;
56132 + goto out_fail;
56133
56134 bprm->exec = bprm->p;
56135 retval = copy_strings(bprm->envc, envp, bprm);
56136 if (retval < 0)
56137 - goto out;
56138 + goto out_fail;
56139
56140 retval = copy_strings(bprm->argc, argv, bprm);
56141 if (retval < 0)
56142 - goto out;
56143 + goto out_fail;
56144 +
56145 + gr_log_chroot_exec(file->f_path.dentry, file->f_path.mnt);
56146 +
56147 + gr_handle_exec_args(bprm, argv);
56148
56149 retval = exec_binprm(bprm);
56150 if (retval < 0)
56151 - goto out;
56152 + goto out_fail;
56153 +#ifdef CONFIG_GRKERNSEC
56154 + if (old_exec_file)
56155 + fput(old_exec_file);
56156 +#endif
56157
56158 /* execve succeeded */
56159 +
56160 + increment_exec_counter();
56161 current->fs->in_exec = 0;
56162 current->in_execve = 0;
56163 acct_update_integrals(current);
56164 @@ -1552,6 +1718,14 @@ static int do_execve_common(const char *filename,
56165 put_files_struct(displaced);
56166 return retval;
56167
56168 +out_fail:
56169 +#ifdef CONFIG_GRKERNSEC
56170 + current->acl = old_acl;
56171 + memcpy(current->signal->rlim, old_rlim, sizeof(old_rlim));
56172 + fput(current->exec_file);
56173 + current->exec_file = old_exec_file;
56174 +#endif
56175 +
56176 out:
56177 if (bprm->mm) {
56178 acct_arg_size(bprm, 0);
56179 @@ -1706,3 +1880,295 @@ asmlinkage long compat_sys_execve(const char __user * filename,
56180 return error;
56181 }
56182 #endif
56183 +
56184 +int pax_check_flags(unsigned long *flags)
56185 +{
56186 + int retval = 0;
56187 +
56188 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_SEGMEXEC)
56189 + if (*flags & MF_PAX_SEGMEXEC)
56190 + {
56191 + *flags &= ~MF_PAX_SEGMEXEC;
56192 + retval = -EINVAL;
56193 + }
56194 +#endif
56195 +
56196 + if ((*flags & MF_PAX_PAGEEXEC)
56197 +
56198 +#ifdef CONFIG_PAX_PAGEEXEC
56199 + && (*flags & MF_PAX_SEGMEXEC)
56200 +#endif
56201 +
56202 + )
56203 + {
56204 + *flags &= ~MF_PAX_PAGEEXEC;
56205 + retval = -EINVAL;
56206 + }
56207 +
56208 + if ((*flags & MF_PAX_MPROTECT)
56209 +
56210 +#ifdef CONFIG_PAX_MPROTECT
56211 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
56212 +#endif
56213 +
56214 + )
56215 + {
56216 + *flags &= ~MF_PAX_MPROTECT;
56217 + retval = -EINVAL;
56218 + }
56219 +
56220 + if ((*flags & MF_PAX_EMUTRAMP)
56221 +
56222 +#ifdef CONFIG_PAX_EMUTRAMP
56223 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
56224 +#endif
56225 +
56226 + )
56227 + {
56228 + *flags &= ~MF_PAX_EMUTRAMP;
56229 + retval = -EINVAL;
56230 + }
56231 +
56232 + return retval;
56233 +}
56234 +
56235 +EXPORT_SYMBOL(pax_check_flags);
56236 +
56237 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
56238 +char *pax_get_path(const struct path *path, char *buf, int buflen)
56239 +{
56240 + char *pathname = d_path(path, buf, buflen);
56241 +
56242 + if (IS_ERR(pathname))
56243 + goto toolong;
56244 +
56245 + pathname = mangle_path(buf, pathname, "\t\n\\");
56246 + if (!pathname)
56247 + goto toolong;
56248 +
56249 + *pathname = 0;
56250 + return buf;
56251 +
56252 +toolong:
56253 + return "<path too long>";
56254 +}
56255 +EXPORT_SYMBOL(pax_get_path);
56256 +
56257 +void pax_report_fault(struct pt_regs *regs, void *pc, void *sp)
56258 +{
56259 + struct task_struct *tsk = current;
56260 + struct mm_struct *mm = current->mm;
56261 + char *buffer_exec = (char *)__get_free_page(GFP_KERNEL);
56262 + char *buffer_fault = (char *)__get_free_page(GFP_KERNEL);
56263 + char *path_exec = NULL;
56264 + char *path_fault = NULL;
56265 + unsigned long start = 0UL, end = 0UL, offset = 0UL;
56266 + siginfo_t info = { };
56267 +
56268 + if (buffer_exec && buffer_fault) {
56269 + struct vm_area_struct *vma, *vma_exec = NULL, *vma_fault = NULL;
56270 +
56271 + down_read(&mm->mmap_sem);
56272 + vma = mm->mmap;
56273 + while (vma && (!vma_exec || !vma_fault)) {
56274 + if (vma->vm_file && mm->exe_file == vma->vm_file && (vma->vm_flags & VM_EXEC))
56275 + vma_exec = vma;
56276 + if (vma->vm_start <= (unsigned long)pc && (unsigned long)pc < vma->vm_end)
56277 + vma_fault = vma;
56278 + vma = vma->vm_next;
56279 + }
56280 + if (vma_exec)
56281 + path_exec = pax_get_path(&vma_exec->vm_file->f_path, buffer_exec, PAGE_SIZE);
56282 + if (vma_fault) {
56283 + start = vma_fault->vm_start;
56284 + end = vma_fault->vm_end;
56285 + offset = vma_fault->vm_pgoff << PAGE_SHIFT;
56286 + if (vma_fault->vm_file)
56287 + path_fault = pax_get_path(&vma_fault->vm_file->f_path, buffer_fault, PAGE_SIZE);
56288 + else if ((unsigned long)pc >= mm->start_brk && (unsigned long)pc < mm->brk)
56289 + path_fault = "<heap>";
56290 + else if (vma_fault->vm_flags & (VM_GROWSDOWN | VM_GROWSUP))
56291 + path_fault = "<stack>";
56292 + else
56293 + path_fault = "<anonymous mapping>";
56294 + }
56295 + up_read(&mm->mmap_sem);
56296 + }
56297 + if (tsk->signal->curr_ip)
56298 + printk(KERN_ERR "PAX: From %pI4: execution attempt in: %s, %08lx-%08lx %08lx\n", &tsk->signal->curr_ip, path_fault, start, end, offset);
56299 + else
56300 + printk(KERN_ERR "PAX: execution attempt in: %s, %08lx-%08lx %08lx\n", path_fault, start, end, offset);
56301 + 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),
56302 + from_kuid_munged(&init_user_ns, task_uid(tsk)), from_kuid_munged(&init_user_ns, task_euid(tsk)), pc, sp);
56303 + free_page((unsigned long)buffer_exec);
56304 + free_page((unsigned long)buffer_fault);
56305 + pax_report_insns(regs, pc, sp);
56306 + info.si_signo = SIGKILL;
56307 + info.si_errno = 0;
56308 + info.si_code = SI_KERNEL;
56309 + info.si_pid = 0;
56310 + info.si_uid = 0;
56311 + do_coredump(&info);
56312 +}
56313 +#endif
56314 +
56315 +#ifdef CONFIG_PAX_REFCOUNT
56316 +void pax_report_refcount_overflow(struct pt_regs *regs)
56317 +{
56318 + if (current->signal->curr_ip)
56319 + printk(KERN_ERR "PAX: From %pI4: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n",
56320 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
56321 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
56322 + else
56323 + printk(KERN_ERR "PAX: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n", current->comm, task_pid_nr(current),
56324 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
56325 + print_symbol(KERN_ERR "PAX: refcount overflow occured at: %s\n", instruction_pointer(regs));
56326 + preempt_disable();
56327 + show_regs(regs);
56328 + preempt_enable();
56329 + force_sig_info(SIGKILL, SEND_SIG_FORCED, current);
56330 +}
56331 +#endif
56332 +
56333 +#ifdef CONFIG_PAX_USERCOPY
56334 +/* 0: not at all, 1: fully, 2: fully inside frame, -1: partially (implies an error) */
56335 +static noinline int check_stack_object(const void *obj, unsigned long len)
56336 +{
56337 + const void * const stack = task_stack_page(current);
56338 + const void * const stackend = stack + THREAD_SIZE;
56339 +
56340 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
56341 + const void *frame = NULL;
56342 + const void *oldframe;
56343 +#endif
56344 +
56345 + if (obj + len < obj)
56346 + return -1;
56347 +
56348 + if (obj + len <= stack || stackend <= obj)
56349 + return 0;
56350 +
56351 + if (obj < stack || stackend < obj + len)
56352 + return -1;
56353 +
56354 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
56355 + oldframe = __builtin_frame_address(1);
56356 + if (oldframe)
56357 + frame = __builtin_frame_address(2);
56358 + /*
56359 + low ----------------------------------------------> high
56360 + [saved bp][saved ip][args][local vars][saved bp][saved ip]
56361 + ^----------------^
56362 + allow copies only within here
56363 + */
56364 + while (stack <= frame && frame < stackend) {
56365 + /* if obj + len extends past the last frame, this
56366 + check won't pass and the next frame will be 0,
56367 + causing us to bail out and correctly report
56368 + the copy as invalid
56369 + */
56370 + if (obj + len <= frame)
56371 + return obj >= oldframe + 2 * sizeof(void *) ? 2 : -1;
56372 + oldframe = frame;
56373 + frame = *(const void * const *)frame;
56374 + }
56375 + return -1;
56376 +#else
56377 + return 1;
56378 +#endif
56379 +}
56380 +
56381 +static __noreturn void pax_report_usercopy(const void *ptr, unsigned long len, bool to_user, const char *type)
56382 +{
56383 + if (current->signal->curr_ip)
56384 + printk(KERN_ERR "PAX: From %pI4: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
56385 + &current->signal->curr_ip, to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
56386 + else
56387 + printk(KERN_ERR "PAX: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
56388 + to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
56389 + dump_stack();
56390 + gr_handle_kernel_exploit();
56391 + do_group_exit(SIGKILL);
56392 +}
56393 +#endif
56394 +
56395 +#ifdef CONFIG_PAX_USERCOPY
56396 +static inline bool check_kernel_text_object(unsigned long low, unsigned long high)
56397 +{
56398 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
56399 + unsigned long textlow = ktla_ktva((unsigned long)_stext);
56400 +#ifdef CONFIG_MODULES
56401 + unsigned long texthigh = (unsigned long)MODULES_EXEC_VADDR;
56402 +#else
56403 + unsigned long texthigh = ktla_ktva((unsigned long)_etext);
56404 +#endif
56405 +
56406 +#else
56407 + unsigned long textlow = (unsigned long)_stext;
56408 + unsigned long texthigh = (unsigned long)_etext;
56409 +
56410 +#ifdef CONFIG_X86_64
56411 + /* check against linear mapping as well */
56412 + if (high > (unsigned long)__va(__pa(textlow)) &&
56413 + low <= (unsigned long)__va(__pa(texthigh)))
56414 + return true;
56415 +#endif
56416 +
56417 +#endif
56418 +
56419 + if (high <= textlow || low > texthigh)
56420 + return false;
56421 + else
56422 + return true;
56423 +}
56424 +#endif
56425 +
56426 +void __check_object_size(const void *ptr, unsigned long n, bool to_user)
56427 +{
56428 +
56429 +#ifdef CONFIG_PAX_USERCOPY
56430 + const char *type;
56431 +
56432 + if (!n)
56433 + return;
56434 +
56435 + type = check_heap_object(ptr, n);
56436 + if (!type) {
56437 + int ret = check_stack_object(ptr, n);
56438 + if (ret == 1 || ret == 2)
56439 + return;
56440 + if (ret == 0) {
56441 + if (check_kernel_text_object((unsigned long)ptr, (unsigned long)ptr + n))
56442 + type = "<kernel text>";
56443 + else
56444 + return;
56445 + } else
56446 + type = "<process stack>";
56447 + }
56448 +
56449 + pax_report_usercopy(ptr, n, to_user, type);
56450 +#endif
56451 +
56452 +}
56453 +EXPORT_SYMBOL(__check_object_size);
56454 +
56455 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
56456 +void pax_track_stack(void)
56457 +{
56458 + unsigned long sp = (unsigned long)&sp;
56459 + if (sp < current_thread_info()->lowest_stack &&
56460 + sp > (unsigned long)task_stack_page(current))
56461 + current_thread_info()->lowest_stack = sp;
56462 +}
56463 +EXPORT_SYMBOL(pax_track_stack);
56464 +#endif
56465 +
56466 +#ifdef CONFIG_PAX_SIZE_OVERFLOW
56467 +void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
56468 +{
56469 + printk(KERN_ERR "PAX: size overflow detected in function %s %s:%u %s", func, file, line, ssa_name);
56470 + dump_stack();
56471 + do_group_exit(SIGKILL);
56472 +}
56473 +EXPORT_SYMBOL(report_size_overflow);
56474 +#endif
56475 diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c
56476 index 9f9992b..8b59411 100644
56477 --- a/fs/ext2/balloc.c
56478 +++ b/fs/ext2/balloc.c
56479 @@ -1184,10 +1184,10 @@ static int ext2_has_free_blocks(struct ext2_sb_info *sbi)
56480
56481 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
56482 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
56483 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
56484 + if (free_blocks < root_blocks + 1 &&
56485 !uid_eq(sbi->s_resuid, current_fsuid()) &&
56486 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
56487 - !in_group_p (sbi->s_resgid))) {
56488 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
56489 return 0;
56490 }
56491 return 1;
56492 diff --git a/fs/ext2/xattr.c b/fs/ext2/xattr.c
56493 index 2d7557d..14e38f94 100644
56494 --- a/fs/ext2/xattr.c
56495 +++ b/fs/ext2/xattr.c
56496 @@ -247,7 +247,7 @@ ext2_xattr_list(struct dentry *dentry, char *buffer, size_t buffer_size)
56497 struct buffer_head *bh = NULL;
56498 struct ext2_xattr_entry *entry;
56499 char *end;
56500 - size_t rest = buffer_size;
56501 + size_t rest = buffer_size, total_size = 0;
56502 int error;
56503
56504 ea_idebug(inode, "buffer=%p, buffer_size=%ld",
56505 @@ -305,9 +305,10 @@ bad_block: ext2_error(inode->i_sb, "ext2_xattr_list",
56506 buffer += size;
56507 }
56508 rest -= size;
56509 + total_size += size;
56510 }
56511 }
56512 - error = buffer_size - rest; /* total size */
56513 + error = total_size;
56514
56515 cleanup:
56516 brelse(bh);
56517 diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c
56518 index 22548f5..41521d8 100644
56519 --- a/fs/ext3/balloc.c
56520 +++ b/fs/ext3/balloc.c
56521 @@ -1438,10 +1438,10 @@ static int ext3_has_free_blocks(struct ext3_sb_info *sbi, int use_reservation)
56522
56523 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
56524 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
56525 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
56526 + if (free_blocks < root_blocks + 1 &&
56527 !use_reservation && !uid_eq(sbi->s_resuid, current_fsuid()) &&
56528 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
56529 - !in_group_p (sbi->s_resgid))) {
56530 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
56531 return 0;
56532 }
56533 return 1;
56534 diff --git a/fs/ext3/xattr.c b/fs/ext3/xattr.c
56535 index b1fc963..881228c 100644
56536 --- a/fs/ext3/xattr.c
56537 +++ b/fs/ext3/xattr.c
56538 @@ -330,7 +330,7 @@ static int
56539 ext3_xattr_list_entries(struct dentry *dentry, struct ext3_xattr_entry *entry,
56540 char *buffer, size_t buffer_size)
56541 {
56542 - size_t rest = buffer_size;
56543 + size_t rest = buffer_size, total_size = 0;
56544
56545 for (; !IS_LAST_ENTRY(entry); entry = EXT3_XATTR_NEXT(entry)) {
56546 const struct xattr_handler *handler =
56547 @@ -347,9 +347,10 @@ ext3_xattr_list_entries(struct dentry *dentry, struct ext3_xattr_entry *entry,
56548 buffer += size;
56549 }
56550 rest -= size;
56551 + total_size += size;
56552 }
56553 }
56554 - return buffer_size - rest;
56555 + return total_size;
56556 }
56557
56558 static int
56559 diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
56560 index dc5d572..4c21f8e 100644
56561 --- a/fs/ext4/balloc.c
56562 +++ b/fs/ext4/balloc.c
56563 @@ -534,8 +534,8 @@ static int ext4_has_free_clusters(struct ext4_sb_info *sbi,
56564 /* Hm, nope. Are (enough) root reserved clusters available? */
56565 if (uid_eq(sbi->s_resuid, current_fsuid()) ||
56566 (!gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) && in_group_p(sbi->s_resgid)) ||
56567 - capable(CAP_SYS_RESOURCE) ||
56568 - (flags & EXT4_MB_USE_ROOT_BLOCKS)) {
56569 + (flags & EXT4_MB_USE_ROOT_BLOCKS) ||
56570 + capable_nolog(CAP_SYS_RESOURCE)) {
56571
56572 if (free_clusters >= (nclusters + dirty_clusters +
56573 resv_clusters))
56574 diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
56575 index af815ea..99294a6 100644
56576 --- a/fs/ext4/ext4.h
56577 +++ b/fs/ext4/ext4.h
56578 @@ -1256,19 +1256,19 @@ struct ext4_sb_info {
56579 unsigned long s_mb_last_start;
56580
56581 /* stats for buddy allocator */
56582 - atomic_t s_bal_reqs; /* number of reqs with len > 1 */
56583 - atomic_t s_bal_success; /* we found long enough chunks */
56584 - atomic_t s_bal_allocated; /* in blocks */
56585 - atomic_t s_bal_ex_scanned; /* total extents scanned */
56586 - atomic_t s_bal_goals; /* goal hits */
56587 - atomic_t s_bal_breaks; /* too long searches */
56588 - atomic_t s_bal_2orders; /* 2^order hits */
56589 + atomic_unchecked_t s_bal_reqs; /* number of reqs with len > 1 */
56590 + atomic_unchecked_t s_bal_success; /* we found long enough chunks */
56591 + atomic_unchecked_t s_bal_allocated; /* in blocks */
56592 + atomic_unchecked_t s_bal_ex_scanned; /* total extents scanned */
56593 + atomic_unchecked_t s_bal_goals; /* goal hits */
56594 + atomic_unchecked_t s_bal_breaks; /* too long searches */
56595 + atomic_unchecked_t s_bal_2orders; /* 2^order hits */
56596 spinlock_t s_bal_lock;
56597 unsigned long s_mb_buddies_generated;
56598 unsigned long long s_mb_generation_time;
56599 - atomic_t s_mb_lost_chunks;
56600 - atomic_t s_mb_preallocated;
56601 - atomic_t s_mb_discarded;
56602 + atomic_unchecked_t s_mb_lost_chunks;
56603 + atomic_unchecked_t s_mb_preallocated;
56604 + atomic_unchecked_t s_mb_discarded;
56605 atomic_t s_lock_busy;
56606
56607 /* locality groups */
56608 diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
56609 index a41e3ba..e574a00 100644
56610 --- a/fs/ext4/mballoc.c
56611 +++ b/fs/ext4/mballoc.c
56612 @@ -1880,7 +1880,7 @@ void ext4_mb_simple_scan_group(struct ext4_allocation_context *ac,
56613 BUG_ON(ac->ac_b_ex.fe_len != ac->ac_g_ex.fe_len);
56614
56615 if (EXT4_SB(sb)->s_mb_stats)
56616 - atomic_inc(&EXT4_SB(sb)->s_bal_2orders);
56617 + atomic_inc_unchecked(&EXT4_SB(sb)->s_bal_2orders);
56618
56619 break;
56620 }
56621 @@ -2189,7 +2189,7 @@ repeat:
56622 ac->ac_status = AC_STATUS_CONTINUE;
56623 ac->ac_flags |= EXT4_MB_HINT_FIRST;
56624 cr = 3;
56625 - atomic_inc(&sbi->s_mb_lost_chunks);
56626 + atomic_inc_unchecked(&sbi->s_mb_lost_chunks);
56627 goto repeat;
56628 }
56629 }
56630 @@ -2697,25 +2697,25 @@ int ext4_mb_release(struct super_block *sb)
56631 if (sbi->s_mb_stats) {
56632 ext4_msg(sb, KERN_INFO,
56633 "mballoc: %u blocks %u reqs (%u success)",
56634 - atomic_read(&sbi->s_bal_allocated),
56635 - atomic_read(&sbi->s_bal_reqs),
56636 - atomic_read(&sbi->s_bal_success));
56637 + atomic_read_unchecked(&sbi->s_bal_allocated),
56638 + atomic_read_unchecked(&sbi->s_bal_reqs),
56639 + atomic_read_unchecked(&sbi->s_bal_success));
56640 ext4_msg(sb, KERN_INFO,
56641 "mballoc: %u extents scanned, %u goal hits, "
56642 "%u 2^N hits, %u breaks, %u lost",
56643 - atomic_read(&sbi->s_bal_ex_scanned),
56644 - atomic_read(&sbi->s_bal_goals),
56645 - atomic_read(&sbi->s_bal_2orders),
56646 - atomic_read(&sbi->s_bal_breaks),
56647 - atomic_read(&sbi->s_mb_lost_chunks));
56648 + atomic_read_unchecked(&sbi->s_bal_ex_scanned),
56649 + atomic_read_unchecked(&sbi->s_bal_goals),
56650 + atomic_read_unchecked(&sbi->s_bal_2orders),
56651 + atomic_read_unchecked(&sbi->s_bal_breaks),
56652 + atomic_read_unchecked(&sbi->s_mb_lost_chunks));
56653 ext4_msg(sb, KERN_INFO,
56654 "mballoc: %lu generated and it took %Lu",
56655 sbi->s_mb_buddies_generated,
56656 sbi->s_mb_generation_time);
56657 ext4_msg(sb, KERN_INFO,
56658 "mballoc: %u preallocated, %u discarded",
56659 - atomic_read(&sbi->s_mb_preallocated),
56660 - atomic_read(&sbi->s_mb_discarded));
56661 + atomic_read_unchecked(&sbi->s_mb_preallocated),
56662 + atomic_read_unchecked(&sbi->s_mb_discarded));
56663 }
56664
56665 free_percpu(sbi->s_locality_groups);
56666 @@ -3169,16 +3169,16 @@ static void ext4_mb_collect_stats(struct ext4_allocation_context *ac)
56667 struct ext4_sb_info *sbi = EXT4_SB(ac->ac_sb);
56668
56669 if (sbi->s_mb_stats && ac->ac_g_ex.fe_len > 1) {
56670 - atomic_inc(&sbi->s_bal_reqs);
56671 - atomic_add(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
56672 + atomic_inc_unchecked(&sbi->s_bal_reqs);
56673 + atomic_add_unchecked(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
56674 if (ac->ac_b_ex.fe_len >= ac->ac_o_ex.fe_len)
56675 - atomic_inc(&sbi->s_bal_success);
56676 - atomic_add(ac->ac_found, &sbi->s_bal_ex_scanned);
56677 + atomic_inc_unchecked(&sbi->s_bal_success);
56678 + atomic_add_unchecked(ac->ac_found, &sbi->s_bal_ex_scanned);
56679 if (ac->ac_g_ex.fe_start == ac->ac_b_ex.fe_start &&
56680 ac->ac_g_ex.fe_group == ac->ac_b_ex.fe_group)
56681 - atomic_inc(&sbi->s_bal_goals);
56682 + atomic_inc_unchecked(&sbi->s_bal_goals);
56683 if (ac->ac_found > sbi->s_mb_max_to_scan)
56684 - atomic_inc(&sbi->s_bal_breaks);
56685 + atomic_inc_unchecked(&sbi->s_bal_breaks);
56686 }
56687
56688 if (ac->ac_op == EXT4_MB_HISTORY_ALLOC)
56689 @@ -3578,7 +3578,7 @@ ext4_mb_new_inode_pa(struct ext4_allocation_context *ac)
56690 trace_ext4_mb_new_inode_pa(ac, pa);
56691
56692 ext4_mb_use_inode_pa(ac, pa);
56693 - atomic_add(pa->pa_free, &sbi->s_mb_preallocated);
56694 + atomic_add_unchecked(pa->pa_free, &sbi->s_mb_preallocated);
56695
56696 ei = EXT4_I(ac->ac_inode);
56697 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
56698 @@ -3638,7 +3638,7 @@ ext4_mb_new_group_pa(struct ext4_allocation_context *ac)
56699 trace_ext4_mb_new_group_pa(ac, pa);
56700
56701 ext4_mb_use_group_pa(ac, pa);
56702 - atomic_add(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
56703 + atomic_add_unchecked(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
56704
56705 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
56706 lg = ac->ac_lg;
56707 @@ -3727,7 +3727,7 @@ ext4_mb_release_inode_pa(struct ext4_buddy *e4b, struct buffer_head *bitmap_bh,
56708 * from the bitmap and continue.
56709 */
56710 }
56711 - atomic_add(free, &sbi->s_mb_discarded);
56712 + atomic_add_unchecked(free, &sbi->s_mb_discarded);
56713
56714 return err;
56715 }
56716 @@ -3745,7 +3745,7 @@ ext4_mb_release_group_pa(struct ext4_buddy *e4b,
56717 ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, &bit);
56718 BUG_ON(group != e4b->bd_group && pa->pa_len != 0);
56719 mb_free_blocks(pa->pa_inode, e4b, bit, pa->pa_len);
56720 - atomic_add(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
56721 + atomic_add_unchecked(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
56722 trace_ext4_mballoc_discard(sb, NULL, group, bit, pa->pa_len);
56723
56724 return 0;
56725 diff --git a/fs/ext4/mmp.c b/fs/ext4/mmp.c
56726 index 214461e..3614c89 100644
56727 --- a/fs/ext4/mmp.c
56728 +++ b/fs/ext4/mmp.c
56729 @@ -113,7 +113,7 @@ static int read_mmp_block(struct super_block *sb, struct buffer_head **bh,
56730 void __dump_mmp_msg(struct super_block *sb, struct mmp_struct *mmp,
56731 const char *function, unsigned int line, const char *msg)
56732 {
56733 - __ext4_warning(sb, function, line, msg);
56734 + __ext4_warning(sb, function, line, "%s", msg);
56735 __ext4_warning(sb, function, line,
56736 "MMP failure info: last update time: %llu, last update "
56737 "node: %s, last update device: %s\n",
56738 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
56739 index 2c2e6cb..7c3ee62 100644
56740 --- a/fs/ext4/super.c
56741 +++ b/fs/ext4/super.c
56742 @@ -1251,7 +1251,7 @@ static ext4_fsblk_t get_sb_block(void **data)
56743 }
56744
56745 #define DEFAULT_JOURNAL_IOPRIO (IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, 3))
56746 -static char deprecated_msg[] = "Mount option \"%s\" will be removed by %s\n"
56747 +static const char deprecated_msg[] = "Mount option \"%s\" will be removed by %s\n"
56748 "Contact linux-ext4@vger.kernel.org if you think we should keep it.\n";
56749
56750 #ifdef CONFIG_QUOTA
56751 @@ -2431,7 +2431,7 @@ struct ext4_attr {
56752 int offset;
56753 int deprecated_val;
56754 } u;
56755 -};
56756 +} __do_const;
56757
56758 static int parse_strtoull(const char *buf,
56759 unsigned long long max, unsigned long long *value)
56760 diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
56761 index 1423c48..9c0c6dc 100644
56762 --- a/fs/ext4/xattr.c
56763 +++ b/fs/ext4/xattr.c
56764 @@ -381,7 +381,7 @@ static int
56765 ext4_xattr_list_entries(struct dentry *dentry, struct ext4_xattr_entry *entry,
56766 char *buffer, size_t buffer_size)
56767 {
56768 - size_t rest = buffer_size;
56769 + size_t rest = buffer_size, total_size = 0;
56770
56771 for (; !IS_LAST_ENTRY(entry); entry = EXT4_XATTR_NEXT(entry)) {
56772 const struct xattr_handler *handler =
56773 @@ -398,9 +398,10 @@ ext4_xattr_list_entries(struct dentry *dentry, struct ext4_xattr_entry *entry,
56774 buffer += size;
56775 }
56776 rest -= size;
56777 + total_size += size;
56778 }
56779 }
56780 - return buffer_size - rest;
56781 + return total_size;
56782 }
56783
56784 static int
56785 diff --git a/fs/fcntl.c b/fs/fcntl.c
56786 index 65343c3..9969dcf 100644
56787 --- a/fs/fcntl.c
56788 +++ b/fs/fcntl.c
56789 @@ -107,6 +107,11 @@ int __f_setown(struct file *filp, struct pid *pid, enum pid_type type,
56790 if (err)
56791 return err;
56792
56793 + if (gr_handle_chroot_fowner(pid, type))
56794 + return -ENOENT;
56795 + if (gr_check_protected_task_fowner(pid, type))
56796 + return -EACCES;
56797 +
56798 f_modown(filp, pid, type, force);
56799 return 0;
56800 }
56801 diff --git a/fs/fhandle.c b/fs/fhandle.c
56802 index 999ff5c..41f4109 100644
56803 --- a/fs/fhandle.c
56804 +++ b/fs/fhandle.c
56805 @@ -67,8 +67,7 @@ static long do_sys_name_to_handle(struct path *path,
56806 } else
56807 retval = 0;
56808 /* copy the mount id */
56809 - if (copy_to_user(mnt_id, &real_mount(path->mnt)->mnt_id,
56810 - sizeof(*mnt_id)) ||
56811 + if (put_user(real_mount(path->mnt)->mnt_id, mnt_id) ||
56812 copy_to_user(ufh, handle,
56813 sizeof(struct file_handle) + handle_bytes))
56814 retval = -EFAULT;
56815 diff --git a/fs/file.c b/fs/file.c
56816 index 4a78f98..f9a6d25 100644
56817 --- a/fs/file.c
56818 +++ b/fs/file.c
56819 @@ -16,6 +16,7 @@
56820 #include <linux/slab.h>
56821 #include <linux/vmalloc.h>
56822 #include <linux/file.h>
56823 +#include <linux/security.h>
56824 #include <linux/fdtable.h>
56825 #include <linux/bitops.h>
56826 #include <linux/interrupt.h>
56827 @@ -141,7 +142,7 @@ out:
56828 * Return <0 error code on error; 1 on successful completion.
56829 * The files->file_lock should be held on entry, and will be held on exit.
56830 */
56831 -static int expand_fdtable(struct files_struct *files, int nr)
56832 +static int expand_fdtable(struct files_struct *files, unsigned int nr)
56833 __releases(files->file_lock)
56834 __acquires(files->file_lock)
56835 {
56836 @@ -186,7 +187,7 @@ static int expand_fdtable(struct files_struct *files, int nr)
56837 * expanded and execution may have blocked.
56838 * The files->file_lock should be held on entry, and will be held on exit.
56839 */
56840 -static int expand_files(struct files_struct *files, int nr)
56841 +static int expand_files(struct files_struct *files, unsigned int nr)
56842 {
56843 struct fdtable *fdt;
56844
56845 @@ -828,6 +829,7 @@ int replace_fd(unsigned fd, struct file *file, unsigned flags)
56846 if (!file)
56847 return __close_fd(files, fd);
56848
56849 + gr_learn_resource(current, RLIMIT_NOFILE, fd, 0);
56850 if (fd >= rlimit(RLIMIT_NOFILE))
56851 return -EBADF;
56852
56853 @@ -854,6 +856,7 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldfd, unsigned int, newfd, int, flags)
56854 if (unlikely(oldfd == newfd))
56855 return -EINVAL;
56856
56857 + gr_learn_resource(current, RLIMIT_NOFILE, newfd, 0);
56858 if (newfd >= rlimit(RLIMIT_NOFILE))
56859 return -EBADF;
56860
56861 @@ -909,6 +912,7 @@ SYSCALL_DEFINE1(dup, unsigned int, fildes)
56862 int f_dupfd(unsigned int from, struct file *file, unsigned flags)
56863 {
56864 int err;
56865 + gr_learn_resource(current, RLIMIT_NOFILE, from, 0);
56866 if (from >= rlimit(RLIMIT_NOFILE))
56867 return -EINVAL;
56868 err = alloc_fd(from, flags);
56869 diff --git a/fs/filesystems.c b/fs/filesystems.c
56870 index 92567d9..fcd8cbf 100644
56871 --- a/fs/filesystems.c
56872 +++ b/fs/filesystems.c
56873 @@ -273,7 +273,11 @@ struct file_system_type *get_fs_type(const char *name)
56874 int len = dot ? dot - name : strlen(name);
56875
56876 fs = __get_fs_type(name, len);
56877 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
56878 + if (!fs && (___request_module(true, "grsec_modharden_fs", "fs-%.*s", len, name) == 0))
56879 +#else
56880 if (!fs && (request_module("fs-%.*s", len, name) == 0))
56881 +#endif
56882 fs = __get_fs_type(name, len);
56883
56884 if (dot && fs && !(fs->fs_flags & FS_HAS_SUBTYPE)) {
56885 diff --git a/fs/fs_struct.c b/fs/fs_struct.c
56886 index d8ac61d..79a36f0 100644
56887 --- a/fs/fs_struct.c
56888 +++ b/fs/fs_struct.c
56889 @@ -4,6 +4,7 @@
56890 #include <linux/path.h>
56891 #include <linux/slab.h>
56892 #include <linux/fs_struct.h>
56893 +#include <linux/grsecurity.h>
56894 #include "internal.h"
56895
56896 /*
56897 @@ -19,6 +20,7 @@ void set_fs_root(struct fs_struct *fs, const struct path *path)
56898 write_seqcount_begin(&fs->seq);
56899 old_root = fs->root;
56900 fs->root = *path;
56901 + gr_set_chroot_entries(current, path);
56902 write_seqcount_end(&fs->seq);
56903 spin_unlock(&fs->lock);
56904 if (old_root.dentry)
56905 @@ -67,6 +69,10 @@ void chroot_fs_refs(const struct path *old_root, const struct path *new_root)
56906 int hits = 0;
56907 spin_lock(&fs->lock);
56908 write_seqcount_begin(&fs->seq);
56909 + /* this root replacement is only done by pivot_root,
56910 + leave grsec's chroot tagging alone for this task
56911 + so that a pivoted root isn't treated as a chroot
56912 + */
56913 hits += replace_path(&fs->root, old_root, new_root);
56914 hits += replace_path(&fs->pwd, old_root, new_root);
56915 write_seqcount_end(&fs->seq);
56916 @@ -99,7 +105,8 @@ void exit_fs(struct task_struct *tsk)
56917 task_lock(tsk);
56918 spin_lock(&fs->lock);
56919 tsk->fs = NULL;
56920 - kill = !--fs->users;
56921 + gr_clear_chroot_entries(tsk);
56922 + kill = !atomic_dec_return(&fs->users);
56923 spin_unlock(&fs->lock);
56924 task_unlock(tsk);
56925 if (kill)
56926 @@ -112,7 +119,7 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
56927 struct fs_struct *fs = kmem_cache_alloc(fs_cachep, GFP_KERNEL);
56928 /* We don't need to lock fs - think why ;-) */
56929 if (fs) {
56930 - fs->users = 1;
56931 + atomic_set(&fs->users, 1);
56932 fs->in_exec = 0;
56933 spin_lock_init(&fs->lock);
56934 seqcount_init(&fs->seq);
56935 @@ -121,6 +128,9 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
56936 spin_lock(&old->lock);
56937 fs->root = old->root;
56938 path_get(&fs->root);
56939 + /* instead of calling gr_set_chroot_entries here,
56940 + we call it from every caller of this function
56941 + */
56942 fs->pwd = old->pwd;
56943 path_get(&fs->pwd);
56944 spin_unlock(&old->lock);
56945 @@ -139,8 +149,9 @@ int unshare_fs_struct(void)
56946
56947 task_lock(current);
56948 spin_lock(&fs->lock);
56949 - kill = !--fs->users;
56950 + kill = !atomic_dec_return(&fs->users);
56951 current->fs = new_fs;
56952 + gr_set_chroot_entries(current, &new_fs->root);
56953 spin_unlock(&fs->lock);
56954 task_unlock(current);
56955
56956 @@ -153,13 +164,13 @@ EXPORT_SYMBOL_GPL(unshare_fs_struct);
56957
56958 int current_umask(void)
56959 {
56960 - return current->fs->umask;
56961 + return current->fs->umask | gr_acl_umask();
56962 }
56963 EXPORT_SYMBOL(current_umask);
56964
56965 /* to be mentioned only in INIT_TASK */
56966 struct fs_struct init_fs = {
56967 - .users = 1,
56968 + .users = ATOMIC_INIT(1),
56969 .lock = __SPIN_LOCK_UNLOCKED(init_fs.lock),
56970 .seq = SEQCNT_ZERO,
56971 .umask = 0022,
56972 diff --git a/fs/fscache/cookie.c b/fs/fscache/cookie.c
56973 index b2a86e3..37f425a 100644
56974 --- a/fs/fscache/cookie.c
56975 +++ b/fs/fscache/cookie.c
56976 @@ -19,7 +19,7 @@
56977
56978 struct kmem_cache *fscache_cookie_jar;
56979
56980 -static atomic_t fscache_object_debug_id = ATOMIC_INIT(0);
56981 +static atomic_unchecked_t fscache_object_debug_id = ATOMIC_INIT(0);
56982
56983 static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie);
56984 static int fscache_alloc_object(struct fscache_cache *cache,
56985 @@ -68,11 +68,11 @@ struct fscache_cookie *__fscache_acquire_cookie(
56986 parent ? (char *) parent->def->name : "<no-parent>",
56987 def->name, netfs_data);
56988
56989 - fscache_stat(&fscache_n_acquires);
56990 + fscache_stat_unchecked(&fscache_n_acquires);
56991
56992 /* if there's no parent cookie, then we don't create one here either */
56993 if (!parent) {
56994 - fscache_stat(&fscache_n_acquires_null);
56995 + fscache_stat_unchecked(&fscache_n_acquires_null);
56996 _leave(" [no parent]");
56997 return NULL;
56998 }
56999 @@ -87,7 +87,7 @@ struct fscache_cookie *__fscache_acquire_cookie(
57000 /* allocate and initialise a cookie */
57001 cookie = kmem_cache_alloc(fscache_cookie_jar, GFP_KERNEL);
57002 if (!cookie) {
57003 - fscache_stat(&fscache_n_acquires_oom);
57004 + fscache_stat_unchecked(&fscache_n_acquires_oom);
57005 _leave(" [ENOMEM]");
57006 return NULL;
57007 }
57008 @@ -114,13 +114,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
57009
57010 switch (cookie->def->type) {
57011 case FSCACHE_COOKIE_TYPE_INDEX:
57012 - fscache_stat(&fscache_n_cookie_index);
57013 + fscache_stat_unchecked(&fscache_n_cookie_index);
57014 break;
57015 case FSCACHE_COOKIE_TYPE_DATAFILE:
57016 - fscache_stat(&fscache_n_cookie_data);
57017 + fscache_stat_unchecked(&fscache_n_cookie_data);
57018 break;
57019 default:
57020 - fscache_stat(&fscache_n_cookie_special);
57021 + fscache_stat_unchecked(&fscache_n_cookie_special);
57022 break;
57023 }
57024
57025 @@ -131,13 +131,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
57026 if (fscache_acquire_non_index_cookie(cookie) < 0) {
57027 atomic_dec(&parent->n_children);
57028 __fscache_cookie_put(cookie);
57029 - fscache_stat(&fscache_n_acquires_nobufs);
57030 + fscache_stat_unchecked(&fscache_n_acquires_nobufs);
57031 _leave(" = NULL");
57032 return NULL;
57033 }
57034 }
57035
57036 - fscache_stat(&fscache_n_acquires_ok);
57037 + fscache_stat_unchecked(&fscache_n_acquires_ok);
57038 _leave(" = %p", cookie);
57039 return cookie;
57040 }
57041 @@ -173,7 +173,7 @@ static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie)
57042 cache = fscache_select_cache_for_object(cookie->parent);
57043 if (!cache) {
57044 up_read(&fscache_addremove_sem);
57045 - fscache_stat(&fscache_n_acquires_no_cache);
57046 + fscache_stat_unchecked(&fscache_n_acquires_no_cache);
57047 _leave(" = -ENOMEDIUM [no cache]");
57048 return -ENOMEDIUM;
57049 }
57050 @@ -259,14 +259,14 @@ static int fscache_alloc_object(struct fscache_cache *cache,
57051 object = cache->ops->alloc_object(cache, cookie);
57052 fscache_stat_d(&fscache_n_cop_alloc_object);
57053 if (IS_ERR(object)) {
57054 - fscache_stat(&fscache_n_object_no_alloc);
57055 + fscache_stat_unchecked(&fscache_n_object_no_alloc);
57056 ret = PTR_ERR(object);
57057 goto error;
57058 }
57059
57060 - fscache_stat(&fscache_n_object_alloc);
57061 + fscache_stat_unchecked(&fscache_n_object_alloc);
57062
57063 - object->debug_id = atomic_inc_return(&fscache_object_debug_id);
57064 + object->debug_id = atomic_inc_return_unchecked(&fscache_object_debug_id);
57065
57066 _debug("ALLOC OBJ%x: %s {%lx}",
57067 object->debug_id, cookie->def->name, object->events);
57068 @@ -380,7 +380,7 @@ void __fscache_invalidate(struct fscache_cookie *cookie)
57069
57070 _enter("{%s}", cookie->def->name);
57071
57072 - fscache_stat(&fscache_n_invalidates);
57073 + fscache_stat_unchecked(&fscache_n_invalidates);
57074
57075 /* Only permit invalidation of data files. Invalidating an index will
57076 * require the caller to release all its attachments to the tree rooted
57077 @@ -438,10 +438,10 @@ void __fscache_update_cookie(struct fscache_cookie *cookie)
57078 {
57079 struct fscache_object *object;
57080
57081 - fscache_stat(&fscache_n_updates);
57082 + fscache_stat_unchecked(&fscache_n_updates);
57083
57084 if (!cookie) {
57085 - fscache_stat(&fscache_n_updates_null);
57086 + fscache_stat_unchecked(&fscache_n_updates_null);
57087 _leave(" [no cookie]");
57088 return;
57089 }
57090 @@ -473,12 +473,12 @@ void __fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)
57091 {
57092 struct fscache_object *object;
57093
57094 - fscache_stat(&fscache_n_relinquishes);
57095 + fscache_stat_unchecked(&fscache_n_relinquishes);
57096 if (retire)
57097 - fscache_stat(&fscache_n_relinquishes_retire);
57098 + fscache_stat_unchecked(&fscache_n_relinquishes_retire);
57099
57100 if (!cookie) {
57101 - fscache_stat(&fscache_n_relinquishes_null);
57102 + fscache_stat_unchecked(&fscache_n_relinquishes_null);
57103 _leave(" [no cookie]");
57104 return;
57105 }
57106 @@ -598,7 +598,7 @@ int __fscache_check_consistency(struct fscache_cookie *cookie)
57107 if (test_bit(FSCACHE_IOERROR, &object->cache->flags))
57108 goto inconsistent;
57109
57110 - op->debug_id = atomic_inc_return(&fscache_op_debug_id);
57111 + op->debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
57112
57113 atomic_inc(&cookie->n_active);
57114 if (fscache_submit_op(object, op) < 0)
57115 diff --git a/fs/fscache/internal.h b/fs/fscache/internal.h
57116 index 4226f66..0fb3f45 100644
57117 --- a/fs/fscache/internal.h
57118 +++ b/fs/fscache/internal.h
57119 @@ -133,8 +133,8 @@ extern void fscache_operation_gc(struct work_struct *);
57120 extern int fscache_wait_for_deferred_lookup(struct fscache_cookie *);
57121 extern int fscache_wait_for_operation_activation(struct fscache_object *,
57122 struct fscache_operation *,
57123 - atomic_t *,
57124 - atomic_t *,
57125 + atomic_unchecked_t *,
57126 + atomic_unchecked_t *,
57127 void (*)(struct fscache_operation *));
57128 extern void fscache_invalidate_writes(struct fscache_cookie *);
57129
57130 @@ -153,101 +153,101 @@ extern void fscache_proc_cleanup(void);
57131 * stats.c
57132 */
57133 #ifdef CONFIG_FSCACHE_STATS
57134 -extern atomic_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
57135 -extern atomic_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
57136 +extern atomic_unchecked_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
57137 +extern atomic_unchecked_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
57138
57139 -extern atomic_t fscache_n_op_pend;
57140 -extern atomic_t fscache_n_op_run;
57141 -extern atomic_t fscache_n_op_enqueue;
57142 -extern atomic_t fscache_n_op_deferred_release;
57143 -extern atomic_t fscache_n_op_release;
57144 -extern atomic_t fscache_n_op_gc;
57145 -extern atomic_t fscache_n_op_cancelled;
57146 -extern atomic_t fscache_n_op_rejected;
57147 +extern atomic_unchecked_t fscache_n_op_pend;
57148 +extern atomic_unchecked_t fscache_n_op_run;
57149 +extern atomic_unchecked_t fscache_n_op_enqueue;
57150 +extern atomic_unchecked_t fscache_n_op_deferred_release;
57151 +extern atomic_unchecked_t fscache_n_op_release;
57152 +extern atomic_unchecked_t fscache_n_op_gc;
57153 +extern atomic_unchecked_t fscache_n_op_cancelled;
57154 +extern atomic_unchecked_t fscache_n_op_rejected;
57155
57156 -extern atomic_t fscache_n_attr_changed;
57157 -extern atomic_t fscache_n_attr_changed_ok;
57158 -extern atomic_t fscache_n_attr_changed_nobufs;
57159 -extern atomic_t fscache_n_attr_changed_nomem;
57160 -extern atomic_t fscache_n_attr_changed_calls;
57161 +extern atomic_unchecked_t fscache_n_attr_changed;
57162 +extern atomic_unchecked_t fscache_n_attr_changed_ok;
57163 +extern atomic_unchecked_t fscache_n_attr_changed_nobufs;
57164 +extern atomic_unchecked_t fscache_n_attr_changed_nomem;
57165 +extern atomic_unchecked_t fscache_n_attr_changed_calls;
57166
57167 -extern atomic_t fscache_n_allocs;
57168 -extern atomic_t fscache_n_allocs_ok;
57169 -extern atomic_t fscache_n_allocs_wait;
57170 -extern atomic_t fscache_n_allocs_nobufs;
57171 -extern atomic_t fscache_n_allocs_intr;
57172 -extern atomic_t fscache_n_allocs_object_dead;
57173 -extern atomic_t fscache_n_alloc_ops;
57174 -extern atomic_t fscache_n_alloc_op_waits;
57175 +extern atomic_unchecked_t fscache_n_allocs;
57176 +extern atomic_unchecked_t fscache_n_allocs_ok;
57177 +extern atomic_unchecked_t fscache_n_allocs_wait;
57178 +extern atomic_unchecked_t fscache_n_allocs_nobufs;
57179 +extern atomic_unchecked_t fscache_n_allocs_intr;
57180 +extern atomic_unchecked_t fscache_n_allocs_object_dead;
57181 +extern atomic_unchecked_t fscache_n_alloc_ops;
57182 +extern atomic_unchecked_t fscache_n_alloc_op_waits;
57183
57184 -extern atomic_t fscache_n_retrievals;
57185 -extern atomic_t fscache_n_retrievals_ok;
57186 -extern atomic_t fscache_n_retrievals_wait;
57187 -extern atomic_t fscache_n_retrievals_nodata;
57188 -extern atomic_t fscache_n_retrievals_nobufs;
57189 -extern atomic_t fscache_n_retrievals_intr;
57190 -extern atomic_t fscache_n_retrievals_nomem;
57191 -extern atomic_t fscache_n_retrievals_object_dead;
57192 -extern atomic_t fscache_n_retrieval_ops;
57193 -extern atomic_t fscache_n_retrieval_op_waits;
57194 +extern atomic_unchecked_t fscache_n_retrievals;
57195 +extern atomic_unchecked_t fscache_n_retrievals_ok;
57196 +extern atomic_unchecked_t fscache_n_retrievals_wait;
57197 +extern atomic_unchecked_t fscache_n_retrievals_nodata;
57198 +extern atomic_unchecked_t fscache_n_retrievals_nobufs;
57199 +extern atomic_unchecked_t fscache_n_retrievals_intr;
57200 +extern atomic_unchecked_t fscache_n_retrievals_nomem;
57201 +extern atomic_unchecked_t fscache_n_retrievals_object_dead;
57202 +extern atomic_unchecked_t fscache_n_retrieval_ops;
57203 +extern atomic_unchecked_t fscache_n_retrieval_op_waits;
57204
57205 -extern atomic_t fscache_n_stores;
57206 -extern atomic_t fscache_n_stores_ok;
57207 -extern atomic_t fscache_n_stores_again;
57208 -extern atomic_t fscache_n_stores_nobufs;
57209 -extern atomic_t fscache_n_stores_oom;
57210 -extern atomic_t fscache_n_store_ops;
57211 -extern atomic_t fscache_n_store_calls;
57212 -extern atomic_t fscache_n_store_pages;
57213 -extern atomic_t fscache_n_store_radix_deletes;
57214 -extern atomic_t fscache_n_store_pages_over_limit;
57215 +extern atomic_unchecked_t fscache_n_stores;
57216 +extern atomic_unchecked_t fscache_n_stores_ok;
57217 +extern atomic_unchecked_t fscache_n_stores_again;
57218 +extern atomic_unchecked_t fscache_n_stores_nobufs;
57219 +extern atomic_unchecked_t fscache_n_stores_oom;
57220 +extern atomic_unchecked_t fscache_n_store_ops;
57221 +extern atomic_unchecked_t fscache_n_store_calls;
57222 +extern atomic_unchecked_t fscache_n_store_pages;
57223 +extern atomic_unchecked_t fscache_n_store_radix_deletes;
57224 +extern atomic_unchecked_t fscache_n_store_pages_over_limit;
57225
57226 -extern atomic_t fscache_n_store_vmscan_not_storing;
57227 -extern atomic_t fscache_n_store_vmscan_gone;
57228 -extern atomic_t fscache_n_store_vmscan_busy;
57229 -extern atomic_t fscache_n_store_vmscan_cancelled;
57230 -extern atomic_t fscache_n_store_vmscan_wait;
57231 +extern atomic_unchecked_t fscache_n_store_vmscan_not_storing;
57232 +extern atomic_unchecked_t fscache_n_store_vmscan_gone;
57233 +extern atomic_unchecked_t fscache_n_store_vmscan_busy;
57234 +extern atomic_unchecked_t fscache_n_store_vmscan_cancelled;
57235 +extern atomic_unchecked_t fscache_n_store_vmscan_wait;
57236
57237 -extern atomic_t fscache_n_marks;
57238 -extern atomic_t fscache_n_uncaches;
57239 +extern atomic_unchecked_t fscache_n_marks;
57240 +extern atomic_unchecked_t fscache_n_uncaches;
57241
57242 -extern atomic_t fscache_n_acquires;
57243 -extern atomic_t fscache_n_acquires_null;
57244 -extern atomic_t fscache_n_acquires_no_cache;
57245 -extern atomic_t fscache_n_acquires_ok;
57246 -extern atomic_t fscache_n_acquires_nobufs;
57247 -extern atomic_t fscache_n_acquires_oom;
57248 +extern atomic_unchecked_t fscache_n_acquires;
57249 +extern atomic_unchecked_t fscache_n_acquires_null;
57250 +extern atomic_unchecked_t fscache_n_acquires_no_cache;
57251 +extern atomic_unchecked_t fscache_n_acquires_ok;
57252 +extern atomic_unchecked_t fscache_n_acquires_nobufs;
57253 +extern atomic_unchecked_t fscache_n_acquires_oom;
57254
57255 -extern atomic_t fscache_n_invalidates;
57256 -extern atomic_t fscache_n_invalidates_run;
57257 +extern atomic_unchecked_t fscache_n_invalidates;
57258 +extern atomic_unchecked_t fscache_n_invalidates_run;
57259
57260 -extern atomic_t fscache_n_updates;
57261 -extern atomic_t fscache_n_updates_null;
57262 -extern atomic_t fscache_n_updates_run;
57263 +extern atomic_unchecked_t fscache_n_updates;
57264 +extern atomic_unchecked_t fscache_n_updates_null;
57265 +extern atomic_unchecked_t fscache_n_updates_run;
57266
57267 -extern atomic_t fscache_n_relinquishes;
57268 -extern atomic_t fscache_n_relinquishes_null;
57269 -extern atomic_t fscache_n_relinquishes_waitcrt;
57270 -extern atomic_t fscache_n_relinquishes_retire;
57271 +extern atomic_unchecked_t fscache_n_relinquishes;
57272 +extern atomic_unchecked_t fscache_n_relinquishes_null;
57273 +extern atomic_unchecked_t fscache_n_relinquishes_waitcrt;
57274 +extern atomic_unchecked_t fscache_n_relinquishes_retire;
57275
57276 -extern atomic_t fscache_n_cookie_index;
57277 -extern atomic_t fscache_n_cookie_data;
57278 -extern atomic_t fscache_n_cookie_special;
57279 +extern atomic_unchecked_t fscache_n_cookie_index;
57280 +extern atomic_unchecked_t fscache_n_cookie_data;
57281 +extern atomic_unchecked_t fscache_n_cookie_special;
57282
57283 -extern atomic_t fscache_n_object_alloc;
57284 -extern atomic_t fscache_n_object_no_alloc;
57285 -extern atomic_t fscache_n_object_lookups;
57286 -extern atomic_t fscache_n_object_lookups_negative;
57287 -extern atomic_t fscache_n_object_lookups_positive;
57288 -extern atomic_t fscache_n_object_lookups_timed_out;
57289 -extern atomic_t fscache_n_object_created;
57290 -extern atomic_t fscache_n_object_avail;
57291 -extern atomic_t fscache_n_object_dead;
57292 +extern atomic_unchecked_t fscache_n_object_alloc;
57293 +extern atomic_unchecked_t fscache_n_object_no_alloc;
57294 +extern atomic_unchecked_t fscache_n_object_lookups;
57295 +extern atomic_unchecked_t fscache_n_object_lookups_negative;
57296 +extern atomic_unchecked_t fscache_n_object_lookups_positive;
57297 +extern atomic_unchecked_t fscache_n_object_lookups_timed_out;
57298 +extern atomic_unchecked_t fscache_n_object_created;
57299 +extern atomic_unchecked_t fscache_n_object_avail;
57300 +extern atomic_unchecked_t fscache_n_object_dead;
57301
57302 -extern atomic_t fscache_n_checkaux_none;
57303 -extern atomic_t fscache_n_checkaux_okay;
57304 -extern atomic_t fscache_n_checkaux_update;
57305 -extern atomic_t fscache_n_checkaux_obsolete;
57306 +extern atomic_unchecked_t fscache_n_checkaux_none;
57307 +extern atomic_unchecked_t fscache_n_checkaux_okay;
57308 +extern atomic_unchecked_t fscache_n_checkaux_update;
57309 +extern atomic_unchecked_t fscache_n_checkaux_obsolete;
57310
57311 extern atomic_t fscache_n_cop_alloc_object;
57312 extern atomic_t fscache_n_cop_lookup_object;
57313 @@ -272,6 +272,11 @@ static inline void fscache_stat(atomic_t *stat)
57314 atomic_inc(stat);
57315 }
57316
57317 +static inline void fscache_stat_unchecked(atomic_unchecked_t *stat)
57318 +{
57319 + atomic_inc_unchecked(stat);
57320 +}
57321 +
57322 static inline void fscache_stat_d(atomic_t *stat)
57323 {
57324 atomic_dec(stat);
57325 @@ -284,6 +289,7 @@ extern const struct file_operations fscache_stats_fops;
57326
57327 #define __fscache_stat(stat) (NULL)
57328 #define fscache_stat(stat) do {} while (0)
57329 +#define fscache_stat_unchecked(stat) do {} while (0)
57330 #define fscache_stat_d(stat) do {} while (0)
57331 #endif
57332
57333 diff --git a/fs/fscache/object.c b/fs/fscache/object.c
57334 index 86d75a6..5f3d7a0 100644
57335 --- a/fs/fscache/object.c
57336 +++ b/fs/fscache/object.c
57337 @@ -451,7 +451,7 @@ static const struct fscache_state *fscache_look_up_object(struct fscache_object
57338 _debug("LOOKUP \"%s\" in \"%s\"",
57339 cookie->def->name, object->cache->tag->name);
57340
57341 - fscache_stat(&fscache_n_object_lookups);
57342 + fscache_stat_unchecked(&fscache_n_object_lookups);
57343 fscache_stat(&fscache_n_cop_lookup_object);
57344 ret = object->cache->ops->lookup_object(object);
57345 fscache_stat_d(&fscache_n_cop_lookup_object);
57346 @@ -461,7 +461,7 @@ static const struct fscache_state *fscache_look_up_object(struct fscache_object
57347 if (ret == -ETIMEDOUT) {
57348 /* probably stuck behind another object, so move this one to
57349 * the back of the queue */
57350 - fscache_stat(&fscache_n_object_lookups_timed_out);
57351 + fscache_stat_unchecked(&fscache_n_object_lookups_timed_out);
57352 _leave(" [timeout]");
57353 return NO_TRANSIT;
57354 }
57355 @@ -489,7 +489,7 @@ void fscache_object_lookup_negative(struct fscache_object *object)
57356 _enter("{OBJ%x,%s}", object->debug_id, object->state->name);
57357
57358 if (!test_and_set_bit(FSCACHE_OBJECT_IS_LOOKED_UP, &object->flags)) {
57359 - fscache_stat(&fscache_n_object_lookups_negative);
57360 + fscache_stat_unchecked(&fscache_n_object_lookups_negative);
57361
57362 /* Allow write requests to begin stacking up and read requests to begin
57363 * returning ENODATA.
57364 @@ -523,7 +523,7 @@ void fscache_obtained_object(struct fscache_object *object)
57365 /* if we were still looking up, then we must have a positive lookup
57366 * result, in which case there may be data available */
57367 if (!test_and_set_bit(FSCACHE_OBJECT_IS_LOOKED_UP, &object->flags)) {
57368 - fscache_stat(&fscache_n_object_lookups_positive);
57369 + fscache_stat_unchecked(&fscache_n_object_lookups_positive);
57370
57371 /* We do (presumably) have data */
57372 clear_bit_unlock(FSCACHE_COOKIE_NO_DATA_YET, &cookie->flags);
57373 @@ -534,7 +534,7 @@ void fscache_obtained_object(struct fscache_object *object)
57374 clear_bit_unlock(FSCACHE_COOKIE_LOOKING_UP, &cookie->flags);
57375 wake_up_bit(&cookie->flags, FSCACHE_COOKIE_LOOKING_UP);
57376 } else {
57377 - fscache_stat(&fscache_n_object_created);
57378 + fscache_stat_unchecked(&fscache_n_object_created);
57379 }
57380
57381 set_bit(FSCACHE_OBJECT_IS_AVAILABLE, &object->flags);
57382 @@ -570,7 +570,7 @@ static const struct fscache_state *fscache_object_available(struct fscache_objec
57383 fscache_stat_d(&fscache_n_cop_lookup_complete);
57384
57385 fscache_hist(fscache_obj_instantiate_histogram, object->lookup_jif);
57386 - fscache_stat(&fscache_n_object_avail);
57387 + fscache_stat_unchecked(&fscache_n_object_avail);
57388
57389 _leave("");
57390 return transit_to(JUMPSTART_DEPS);
57391 @@ -716,7 +716,7 @@ static const struct fscache_state *fscache_drop_object(struct fscache_object *ob
57392
57393 /* this just shifts the object release to the work processor */
57394 fscache_put_object(object);
57395 - fscache_stat(&fscache_n_object_dead);
57396 + fscache_stat_unchecked(&fscache_n_object_dead);
57397
57398 _leave("");
57399 return transit_to(OBJECT_DEAD);
57400 @@ -881,7 +881,7 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
57401 enum fscache_checkaux result;
57402
57403 if (!object->cookie->def->check_aux) {
57404 - fscache_stat(&fscache_n_checkaux_none);
57405 + fscache_stat_unchecked(&fscache_n_checkaux_none);
57406 return FSCACHE_CHECKAUX_OKAY;
57407 }
57408
57409 @@ -890,17 +890,17 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
57410 switch (result) {
57411 /* entry okay as is */
57412 case FSCACHE_CHECKAUX_OKAY:
57413 - fscache_stat(&fscache_n_checkaux_okay);
57414 + fscache_stat_unchecked(&fscache_n_checkaux_okay);
57415 break;
57416
57417 /* entry requires update */
57418 case FSCACHE_CHECKAUX_NEEDS_UPDATE:
57419 - fscache_stat(&fscache_n_checkaux_update);
57420 + fscache_stat_unchecked(&fscache_n_checkaux_update);
57421 break;
57422
57423 /* entry requires deletion */
57424 case FSCACHE_CHECKAUX_OBSOLETE:
57425 - fscache_stat(&fscache_n_checkaux_obsolete);
57426 + fscache_stat_unchecked(&fscache_n_checkaux_obsolete);
57427 break;
57428
57429 default:
57430 @@ -986,7 +986,7 @@ static const struct fscache_state *fscache_invalidate_object(struct fscache_obje
57431 {
57432 const struct fscache_state *s;
57433
57434 - fscache_stat(&fscache_n_invalidates_run);
57435 + fscache_stat_unchecked(&fscache_n_invalidates_run);
57436 fscache_stat(&fscache_n_cop_invalidate_object);
57437 s = _fscache_invalidate_object(object, event);
57438 fscache_stat_d(&fscache_n_cop_invalidate_object);
57439 @@ -1001,7 +1001,7 @@ static const struct fscache_state *fscache_update_object(struct fscache_object *
57440 {
57441 _enter("{OBJ%x},%d", object->debug_id, event);
57442
57443 - fscache_stat(&fscache_n_updates_run);
57444 + fscache_stat_unchecked(&fscache_n_updates_run);
57445 fscache_stat(&fscache_n_cop_update_object);
57446 object->cache->ops->update_object(object);
57447 fscache_stat_d(&fscache_n_cop_update_object);
57448 diff --git a/fs/fscache/operation.c b/fs/fscache/operation.c
57449 index 318071a..379938b 100644
57450 --- a/fs/fscache/operation.c
57451 +++ b/fs/fscache/operation.c
57452 @@ -17,7 +17,7 @@
57453 #include <linux/slab.h>
57454 #include "internal.h"
57455
57456 -atomic_t fscache_op_debug_id;
57457 +atomic_unchecked_t fscache_op_debug_id;
57458 EXPORT_SYMBOL(fscache_op_debug_id);
57459
57460 /**
57461 @@ -39,7 +39,7 @@ void fscache_enqueue_operation(struct fscache_operation *op)
57462 ASSERTCMP(atomic_read(&op->usage), >, 0);
57463 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_IN_PROGRESS);
57464
57465 - fscache_stat(&fscache_n_op_enqueue);
57466 + fscache_stat_unchecked(&fscache_n_op_enqueue);
57467 switch (op->flags & FSCACHE_OP_TYPE) {
57468 case FSCACHE_OP_ASYNC:
57469 _debug("queue async");
57470 @@ -73,7 +73,7 @@ static void fscache_run_op(struct fscache_object *object,
57471 wake_up_bit(&op->flags, FSCACHE_OP_WAITING);
57472 if (op->processor)
57473 fscache_enqueue_operation(op);
57474 - fscache_stat(&fscache_n_op_run);
57475 + fscache_stat_unchecked(&fscache_n_op_run);
57476 }
57477
57478 /*
57479 @@ -105,11 +105,11 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
57480 if (object->n_in_progress > 0) {
57481 atomic_inc(&op->usage);
57482 list_add_tail(&op->pend_link, &object->pending_ops);
57483 - fscache_stat(&fscache_n_op_pend);
57484 + fscache_stat_unchecked(&fscache_n_op_pend);
57485 } else if (!list_empty(&object->pending_ops)) {
57486 atomic_inc(&op->usage);
57487 list_add_tail(&op->pend_link, &object->pending_ops);
57488 - fscache_stat(&fscache_n_op_pend);
57489 + fscache_stat_unchecked(&fscache_n_op_pend);
57490 fscache_start_operations(object);
57491 } else {
57492 ASSERTCMP(object->n_in_progress, ==, 0);
57493 @@ -125,7 +125,7 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
57494 object->n_exclusive++; /* reads and writes must wait */
57495 atomic_inc(&op->usage);
57496 list_add_tail(&op->pend_link, &object->pending_ops);
57497 - fscache_stat(&fscache_n_op_pend);
57498 + fscache_stat_unchecked(&fscache_n_op_pend);
57499 ret = 0;
57500 } else {
57501 /* If we're in any other state, there must have been an I/O
57502 @@ -212,11 +212,11 @@ int fscache_submit_op(struct fscache_object *object,
57503 if (object->n_exclusive > 0) {
57504 atomic_inc(&op->usage);
57505 list_add_tail(&op->pend_link, &object->pending_ops);
57506 - fscache_stat(&fscache_n_op_pend);
57507 + fscache_stat_unchecked(&fscache_n_op_pend);
57508 } else if (!list_empty(&object->pending_ops)) {
57509 atomic_inc(&op->usage);
57510 list_add_tail(&op->pend_link, &object->pending_ops);
57511 - fscache_stat(&fscache_n_op_pend);
57512 + fscache_stat_unchecked(&fscache_n_op_pend);
57513 fscache_start_operations(object);
57514 } else {
57515 ASSERTCMP(object->n_exclusive, ==, 0);
57516 @@ -228,10 +228,10 @@ int fscache_submit_op(struct fscache_object *object,
57517 object->n_ops++;
57518 atomic_inc(&op->usage);
57519 list_add_tail(&op->pend_link, &object->pending_ops);
57520 - fscache_stat(&fscache_n_op_pend);
57521 + fscache_stat_unchecked(&fscache_n_op_pend);
57522 ret = 0;
57523 } else if (fscache_object_is_dying(object)) {
57524 - fscache_stat(&fscache_n_op_rejected);
57525 + fscache_stat_unchecked(&fscache_n_op_rejected);
57526 op->state = FSCACHE_OP_ST_CANCELLED;
57527 ret = -ENOBUFS;
57528 } else if (!test_bit(FSCACHE_IOERROR, &object->cache->flags)) {
57529 @@ -310,7 +310,7 @@ int fscache_cancel_op(struct fscache_operation *op,
57530 ret = -EBUSY;
57531 if (op->state == FSCACHE_OP_ST_PENDING) {
57532 ASSERT(!list_empty(&op->pend_link));
57533 - fscache_stat(&fscache_n_op_cancelled);
57534 + fscache_stat_unchecked(&fscache_n_op_cancelled);
57535 list_del_init(&op->pend_link);
57536 if (do_cancel)
57537 do_cancel(op);
57538 @@ -342,7 +342,7 @@ void fscache_cancel_all_ops(struct fscache_object *object)
57539 while (!list_empty(&object->pending_ops)) {
57540 op = list_entry(object->pending_ops.next,
57541 struct fscache_operation, pend_link);
57542 - fscache_stat(&fscache_n_op_cancelled);
57543 + fscache_stat_unchecked(&fscache_n_op_cancelled);
57544 list_del_init(&op->pend_link);
57545
57546 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_PENDING);
57547 @@ -414,7 +414,7 @@ void fscache_put_operation(struct fscache_operation *op)
57548 op->state, ==, FSCACHE_OP_ST_CANCELLED);
57549 op->state = FSCACHE_OP_ST_DEAD;
57550
57551 - fscache_stat(&fscache_n_op_release);
57552 + fscache_stat_unchecked(&fscache_n_op_release);
57553
57554 if (op->release) {
57555 op->release(op);
57556 @@ -433,7 +433,7 @@ void fscache_put_operation(struct fscache_operation *op)
57557 * lock, and defer it otherwise */
57558 if (!spin_trylock(&object->lock)) {
57559 _debug("defer put");
57560 - fscache_stat(&fscache_n_op_deferred_release);
57561 + fscache_stat_unchecked(&fscache_n_op_deferred_release);
57562
57563 cache = object->cache;
57564 spin_lock(&cache->op_gc_list_lock);
57565 @@ -486,7 +486,7 @@ void fscache_operation_gc(struct work_struct *work)
57566
57567 _debug("GC DEFERRED REL OBJ%x OP%x",
57568 object->debug_id, op->debug_id);
57569 - fscache_stat(&fscache_n_op_gc);
57570 + fscache_stat_unchecked(&fscache_n_op_gc);
57571
57572 ASSERTCMP(atomic_read(&op->usage), ==, 0);
57573 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_DEAD);
57574 diff --git a/fs/fscache/page.c b/fs/fscache/page.c
57575 index 73899c1..ae40c58 100644
57576 --- a/fs/fscache/page.c
57577 +++ b/fs/fscache/page.c
57578 @@ -61,7 +61,7 @@ try_again:
57579 val = radix_tree_lookup(&cookie->stores, page->index);
57580 if (!val) {
57581 rcu_read_unlock();
57582 - fscache_stat(&fscache_n_store_vmscan_not_storing);
57583 + fscache_stat_unchecked(&fscache_n_store_vmscan_not_storing);
57584 __fscache_uncache_page(cookie, page);
57585 return true;
57586 }
57587 @@ -91,11 +91,11 @@ try_again:
57588 spin_unlock(&cookie->stores_lock);
57589
57590 if (xpage) {
57591 - fscache_stat(&fscache_n_store_vmscan_cancelled);
57592 - fscache_stat(&fscache_n_store_radix_deletes);
57593 + fscache_stat_unchecked(&fscache_n_store_vmscan_cancelled);
57594 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
57595 ASSERTCMP(xpage, ==, page);
57596 } else {
57597 - fscache_stat(&fscache_n_store_vmscan_gone);
57598 + fscache_stat_unchecked(&fscache_n_store_vmscan_gone);
57599 }
57600
57601 wake_up_bit(&cookie->flags, 0);
57602 @@ -110,11 +110,11 @@ page_busy:
57603 * sleeping on memory allocation, so we may need to impose a timeout
57604 * too. */
57605 if (!(gfp & __GFP_WAIT) || !(gfp & __GFP_FS)) {
57606 - fscache_stat(&fscache_n_store_vmscan_busy);
57607 + fscache_stat_unchecked(&fscache_n_store_vmscan_busy);
57608 return false;
57609 }
57610
57611 - fscache_stat(&fscache_n_store_vmscan_wait);
57612 + fscache_stat_unchecked(&fscache_n_store_vmscan_wait);
57613 __fscache_wait_on_page_write(cookie, page);
57614 gfp &= ~__GFP_WAIT;
57615 goto try_again;
57616 @@ -140,7 +140,7 @@ static void fscache_end_page_write(struct fscache_object *object,
57617 FSCACHE_COOKIE_STORING_TAG);
57618 if (!radix_tree_tag_get(&cookie->stores, page->index,
57619 FSCACHE_COOKIE_PENDING_TAG)) {
57620 - fscache_stat(&fscache_n_store_radix_deletes);
57621 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
57622 xpage = radix_tree_delete(&cookie->stores, page->index);
57623 }
57624 spin_unlock(&cookie->stores_lock);
57625 @@ -161,7 +161,7 @@ static void fscache_attr_changed_op(struct fscache_operation *op)
57626
57627 _enter("{OBJ%x OP%x}", object->debug_id, op->debug_id);
57628
57629 - fscache_stat(&fscache_n_attr_changed_calls);
57630 + fscache_stat_unchecked(&fscache_n_attr_changed_calls);
57631
57632 if (fscache_object_is_active(object) &&
57633 fscache_use_cookie(object)) {
57634 @@ -189,11 +189,11 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
57635
57636 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
57637
57638 - fscache_stat(&fscache_n_attr_changed);
57639 + fscache_stat_unchecked(&fscache_n_attr_changed);
57640
57641 op = kzalloc(sizeof(*op), GFP_KERNEL);
57642 if (!op) {
57643 - fscache_stat(&fscache_n_attr_changed_nomem);
57644 + fscache_stat_unchecked(&fscache_n_attr_changed_nomem);
57645 _leave(" = -ENOMEM");
57646 return -ENOMEM;
57647 }
57648 @@ -211,7 +211,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
57649 if (fscache_submit_exclusive_op(object, op) < 0)
57650 goto nobufs;
57651 spin_unlock(&cookie->lock);
57652 - fscache_stat(&fscache_n_attr_changed_ok);
57653 + fscache_stat_unchecked(&fscache_n_attr_changed_ok);
57654 fscache_put_operation(op);
57655 _leave(" = 0");
57656 return 0;
57657 @@ -219,7 +219,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
57658 nobufs:
57659 spin_unlock(&cookie->lock);
57660 kfree(op);
57661 - fscache_stat(&fscache_n_attr_changed_nobufs);
57662 + fscache_stat_unchecked(&fscache_n_attr_changed_nobufs);
57663 _leave(" = %d", -ENOBUFS);
57664 return -ENOBUFS;
57665 }
57666 @@ -258,7 +258,7 @@ static struct fscache_retrieval *fscache_alloc_retrieval(
57667 /* allocate a retrieval operation and attempt to submit it */
57668 op = kzalloc(sizeof(*op), GFP_NOIO);
57669 if (!op) {
57670 - fscache_stat(&fscache_n_retrievals_nomem);
57671 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
57672 return NULL;
57673 }
57674
57675 @@ -289,13 +289,13 @@ int fscache_wait_for_deferred_lookup(struct fscache_cookie *cookie)
57676 return 0;
57677 }
57678
57679 - fscache_stat(&fscache_n_retrievals_wait);
57680 + fscache_stat_unchecked(&fscache_n_retrievals_wait);
57681
57682 jif = jiffies;
57683 if (wait_on_bit(&cookie->flags, FSCACHE_COOKIE_LOOKING_UP,
57684 fscache_wait_bit_interruptible,
57685 TASK_INTERRUPTIBLE) != 0) {
57686 - fscache_stat(&fscache_n_retrievals_intr);
57687 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
57688 _leave(" = -ERESTARTSYS");
57689 return -ERESTARTSYS;
57690 }
57691 @@ -324,8 +324,8 @@ static void fscache_do_cancel_retrieval(struct fscache_operation *_op)
57692 */
57693 int fscache_wait_for_operation_activation(struct fscache_object *object,
57694 struct fscache_operation *op,
57695 - atomic_t *stat_op_waits,
57696 - atomic_t *stat_object_dead,
57697 + atomic_unchecked_t *stat_op_waits,
57698 + atomic_unchecked_t *stat_object_dead,
57699 void (*do_cancel)(struct fscache_operation *))
57700 {
57701 int ret;
57702 @@ -335,7 +335,7 @@ int fscache_wait_for_operation_activation(struct fscache_object *object,
57703
57704 _debug(">>> WT");
57705 if (stat_op_waits)
57706 - fscache_stat(stat_op_waits);
57707 + fscache_stat_unchecked(stat_op_waits);
57708 if (wait_on_bit(&op->flags, FSCACHE_OP_WAITING,
57709 fscache_wait_bit_interruptible,
57710 TASK_INTERRUPTIBLE) != 0) {
57711 @@ -353,7 +353,7 @@ int fscache_wait_for_operation_activation(struct fscache_object *object,
57712 check_if_dead:
57713 if (op->state == FSCACHE_OP_ST_CANCELLED) {
57714 if (stat_object_dead)
57715 - fscache_stat(stat_object_dead);
57716 + fscache_stat_unchecked(stat_object_dead);
57717 _leave(" = -ENOBUFS [cancelled]");
57718 return -ENOBUFS;
57719 }
57720 @@ -361,7 +361,7 @@ check_if_dead:
57721 pr_err("%s() = -ENOBUFS [obj dead %d]\n", __func__, op->state);
57722 fscache_cancel_op(op, do_cancel);
57723 if (stat_object_dead)
57724 - fscache_stat(stat_object_dead);
57725 + fscache_stat_unchecked(stat_object_dead);
57726 return -ENOBUFS;
57727 }
57728 return 0;
57729 @@ -388,7 +388,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
57730
57731 _enter("%p,%p,,,", cookie, page);
57732
57733 - fscache_stat(&fscache_n_retrievals);
57734 + fscache_stat_unchecked(&fscache_n_retrievals);
57735
57736 if (hlist_empty(&cookie->backing_objects))
57737 goto nobufs;
57738 @@ -428,7 +428,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
57739 goto nobufs_unlock_dec;
57740 spin_unlock(&cookie->lock);
57741
57742 - fscache_stat(&fscache_n_retrieval_ops);
57743 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
57744
57745 /* pin the netfs read context in case we need to do the actual netfs
57746 * read because we've encountered a cache read failure */
57747 @@ -459,15 +459,15 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
57748
57749 error:
57750 if (ret == -ENOMEM)
57751 - fscache_stat(&fscache_n_retrievals_nomem);
57752 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
57753 else if (ret == -ERESTARTSYS)
57754 - fscache_stat(&fscache_n_retrievals_intr);
57755 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
57756 else if (ret == -ENODATA)
57757 - fscache_stat(&fscache_n_retrievals_nodata);
57758 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
57759 else if (ret < 0)
57760 - fscache_stat(&fscache_n_retrievals_nobufs);
57761 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
57762 else
57763 - fscache_stat(&fscache_n_retrievals_ok);
57764 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
57765
57766 fscache_put_retrieval(op);
57767 _leave(" = %d", ret);
57768 @@ -480,7 +480,7 @@ nobufs_unlock:
57769 atomic_dec(&cookie->n_active);
57770 kfree(op);
57771 nobufs:
57772 - fscache_stat(&fscache_n_retrievals_nobufs);
57773 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
57774 _leave(" = -ENOBUFS");
57775 return -ENOBUFS;
57776 }
57777 @@ -518,7 +518,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
57778
57779 _enter("%p,,%d,,,", cookie, *nr_pages);
57780
57781 - fscache_stat(&fscache_n_retrievals);
57782 + fscache_stat_unchecked(&fscache_n_retrievals);
57783
57784 if (hlist_empty(&cookie->backing_objects))
57785 goto nobufs;
57786 @@ -554,7 +554,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
57787 goto nobufs_unlock_dec;
57788 spin_unlock(&cookie->lock);
57789
57790 - fscache_stat(&fscache_n_retrieval_ops);
57791 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
57792
57793 /* pin the netfs read context in case we need to do the actual netfs
57794 * read because we've encountered a cache read failure */
57795 @@ -585,15 +585,15 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
57796
57797 error:
57798 if (ret == -ENOMEM)
57799 - fscache_stat(&fscache_n_retrievals_nomem);
57800 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
57801 else if (ret == -ERESTARTSYS)
57802 - fscache_stat(&fscache_n_retrievals_intr);
57803 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
57804 else if (ret == -ENODATA)
57805 - fscache_stat(&fscache_n_retrievals_nodata);
57806 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
57807 else if (ret < 0)
57808 - fscache_stat(&fscache_n_retrievals_nobufs);
57809 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
57810 else
57811 - fscache_stat(&fscache_n_retrievals_ok);
57812 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
57813
57814 fscache_put_retrieval(op);
57815 _leave(" = %d", ret);
57816 @@ -606,7 +606,7 @@ nobufs_unlock:
57817 atomic_dec(&cookie->n_active);
57818 kfree(op);
57819 nobufs:
57820 - fscache_stat(&fscache_n_retrievals_nobufs);
57821 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
57822 _leave(" = -ENOBUFS");
57823 return -ENOBUFS;
57824 }
57825 @@ -630,7 +630,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
57826
57827 _enter("%p,%p,,,", cookie, page);
57828
57829 - fscache_stat(&fscache_n_allocs);
57830 + fscache_stat_unchecked(&fscache_n_allocs);
57831
57832 if (hlist_empty(&cookie->backing_objects))
57833 goto nobufs;
57834 @@ -662,7 +662,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
57835 goto nobufs_unlock;
57836 spin_unlock(&cookie->lock);
57837
57838 - fscache_stat(&fscache_n_alloc_ops);
57839 + fscache_stat_unchecked(&fscache_n_alloc_ops);
57840
57841 ret = fscache_wait_for_operation_activation(
57842 object, &op->op,
57843 @@ -679,11 +679,11 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
57844
57845 error:
57846 if (ret == -ERESTARTSYS)
57847 - fscache_stat(&fscache_n_allocs_intr);
57848 + fscache_stat_unchecked(&fscache_n_allocs_intr);
57849 else if (ret < 0)
57850 - fscache_stat(&fscache_n_allocs_nobufs);
57851 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
57852 else
57853 - fscache_stat(&fscache_n_allocs_ok);
57854 + fscache_stat_unchecked(&fscache_n_allocs_ok);
57855
57856 fscache_put_retrieval(op);
57857 _leave(" = %d", ret);
57858 @@ -694,7 +694,7 @@ nobufs_unlock:
57859 atomic_dec(&cookie->n_active);
57860 kfree(op);
57861 nobufs:
57862 - fscache_stat(&fscache_n_allocs_nobufs);
57863 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
57864 _leave(" = -ENOBUFS");
57865 return -ENOBUFS;
57866 }
57867 @@ -770,7 +770,7 @@ static void fscache_write_op(struct fscache_operation *_op)
57868
57869 spin_lock(&cookie->stores_lock);
57870
57871 - fscache_stat(&fscache_n_store_calls);
57872 + fscache_stat_unchecked(&fscache_n_store_calls);
57873
57874 /* find a page to store */
57875 page = NULL;
57876 @@ -781,7 +781,7 @@ static void fscache_write_op(struct fscache_operation *_op)
57877 page = results[0];
57878 _debug("gang %d [%lx]", n, page->index);
57879 if (page->index > op->store_limit) {
57880 - fscache_stat(&fscache_n_store_pages_over_limit);
57881 + fscache_stat_unchecked(&fscache_n_store_pages_over_limit);
57882 goto superseded;
57883 }
57884
57885 @@ -793,7 +793,7 @@ static void fscache_write_op(struct fscache_operation *_op)
57886 spin_unlock(&cookie->stores_lock);
57887 spin_unlock(&object->lock);
57888
57889 - fscache_stat(&fscache_n_store_pages);
57890 + fscache_stat_unchecked(&fscache_n_store_pages);
57891 fscache_stat(&fscache_n_cop_write_page);
57892 ret = object->cache->ops->write_page(op, page);
57893 fscache_stat_d(&fscache_n_cop_write_page);
57894 @@ -896,7 +896,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
57895 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
57896 ASSERT(PageFsCache(page));
57897
57898 - fscache_stat(&fscache_n_stores);
57899 + fscache_stat_unchecked(&fscache_n_stores);
57900
57901 if (test_bit(FSCACHE_COOKIE_INVALIDATING, &cookie->flags)) {
57902 _leave(" = -ENOBUFS [invalidating]");
57903 @@ -954,7 +954,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
57904 spin_unlock(&cookie->stores_lock);
57905 spin_unlock(&object->lock);
57906
57907 - op->op.debug_id = atomic_inc_return(&fscache_op_debug_id);
57908 + op->op.debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
57909 op->store_limit = object->store_limit;
57910
57911 atomic_inc(&cookie->n_active);
57912 @@ -963,8 +963,8 @@ int __fscache_write_page(struct fscache_cookie *cookie,
57913
57914 spin_unlock(&cookie->lock);
57915 radix_tree_preload_end();
57916 - fscache_stat(&fscache_n_store_ops);
57917 - fscache_stat(&fscache_n_stores_ok);
57918 + fscache_stat_unchecked(&fscache_n_store_ops);
57919 + fscache_stat_unchecked(&fscache_n_stores_ok);
57920
57921 /* the work queue now carries its own ref on the object */
57922 fscache_put_operation(&op->op);
57923 @@ -972,14 +972,14 @@ int __fscache_write_page(struct fscache_cookie *cookie,
57924 return 0;
57925
57926 already_queued:
57927 - fscache_stat(&fscache_n_stores_again);
57928 + fscache_stat_unchecked(&fscache_n_stores_again);
57929 already_pending:
57930 spin_unlock(&cookie->stores_lock);
57931 spin_unlock(&object->lock);
57932 spin_unlock(&cookie->lock);
57933 radix_tree_preload_end();
57934 kfree(op);
57935 - fscache_stat(&fscache_n_stores_ok);
57936 + fscache_stat_unchecked(&fscache_n_stores_ok);
57937 _leave(" = 0");
57938 return 0;
57939
57940 @@ -999,14 +999,14 @@ nobufs:
57941 spin_unlock(&cookie->lock);
57942 radix_tree_preload_end();
57943 kfree(op);
57944 - fscache_stat(&fscache_n_stores_nobufs);
57945 + fscache_stat_unchecked(&fscache_n_stores_nobufs);
57946 _leave(" = -ENOBUFS");
57947 return -ENOBUFS;
57948
57949 nomem_free:
57950 kfree(op);
57951 nomem:
57952 - fscache_stat(&fscache_n_stores_oom);
57953 + fscache_stat_unchecked(&fscache_n_stores_oom);
57954 _leave(" = -ENOMEM");
57955 return -ENOMEM;
57956 }
57957 @@ -1024,7 +1024,7 @@ void __fscache_uncache_page(struct fscache_cookie *cookie, struct page *page)
57958 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
57959 ASSERTCMP(page, !=, NULL);
57960
57961 - fscache_stat(&fscache_n_uncaches);
57962 + fscache_stat_unchecked(&fscache_n_uncaches);
57963
57964 /* cache withdrawal may beat us to it */
57965 if (!PageFsCache(page))
57966 @@ -1075,7 +1075,7 @@ void fscache_mark_page_cached(struct fscache_retrieval *op, struct page *page)
57967 struct fscache_cookie *cookie = op->op.object->cookie;
57968
57969 #ifdef CONFIG_FSCACHE_STATS
57970 - atomic_inc(&fscache_n_marks);
57971 + atomic_inc_unchecked(&fscache_n_marks);
57972 #endif
57973
57974 _debug("- mark %p{%lx}", page, page->index);
57975 diff --git a/fs/fscache/stats.c b/fs/fscache/stats.c
57976 index 40d13c7..ddf52b9 100644
57977 --- a/fs/fscache/stats.c
57978 +++ b/fs/fscache/stats.c
57979 @@ -18,99 +18,99 @@
57980 /*
57981 * operation counters
57982 */
57983 -atomic_t fscache_n_op_pend;
57984 -atomic_t fscache_n_op_run;
57985 -atomic_t fscache_n_op_enqueue;
57986 -atomic_t fscache_n_op_requeue;
57987 -atomic_t fscache_n_op_deferred_release;
57988 -atomic_t fscache_n_op_release;
57989 -atomic_t fscache_n_op_gc;
57990 -atomic_t fscache_n_op_cancelled;
57991 -atomic_t fscache_n_op_rejected;
57992 +atomic_unchecked_t fscache_n_op_pend;
57993 +atomic_unchecked_t fscache_n_op_run;
57994 +atomic_unchecked_t fscache_n_op_enqueue;
57995 +atomic_unchecked_t fscache_n_op_requeue;
57996 +atomic_unchecked_t fscache_n_op_deferred_release;
57997 +atomic_unchecked_t fscache_n_op_release;
57998 +atomic_unchecked_t fscache_n_op_gc;
57999 +atomic_unchecked_t fscache_n_op_cancelled;
58000 +atomic_unchecked_t fscache_n_op_rejected;
58001
58002 -atomic_t fscache_n_attr_changed;
58003 -atomic_t fscache_n_attr_changed_ok;
58004 -atomic_t fscache_n_attr_changed_nobufs;
58005 -atomic_t fscache_n_attr_changed_nomem;
58006 -atomic_t fscache_n_attr_changed_calls;
58007 +atomic_unchecked_t fscache_n_attr_changed;
58008 +atomic_unchecked_t fscache_n_attr_changed_ok;
58009 +atomic_unchecked_t fscache_n_attr_changed_nobufs;
58010 +atomic_unchecked_t fscache_n_attr_changed_nomem;
58011 +atomic_unchecked_t fscache_n_attr_changed_calls;
58012
58013 -atomic_t fscache_n_allocs;
58014 -atomic_t fscache_n_allocs_ok;
58015 -atomic_t fscache_n_allocs_wait;
58016 -atomic_t fscache_n_allocs_nobufs;
58017 -atomic_t fscache_n_allocs_intr;
58018 -atomic_t fscache_n_allocs_object_dead;
58019 -atomic_t fscache_n_alloc_ops;
58020 -atomic_t fscache_n_alloc_op_waits;
58021 +atomic_unchecked_t fscache_n_allocs;
58022 +atomic_unchecked_t fscache_n_allocs_ok;
58023 +atomic_unchecked_t fscache_n_allocs_wait;
58024 +atomic_unchecked_t fscache_n_allocs_nobufs;
58025 +atomic_unchecked_t fscache_n_allocs_intr;
58026 +atomic_unchecked_t fscache_n_allocs_object_dead;
58027 +atomic_unchecked_t fscache_n_alloc_ops;
58028 +atomic_unchecked_t fscache_n_alloc_op_waits;
58029
58030 -atomic_t fscache_n_retrievals;
58031 -atomic_t fscache_n_retrievals_ok;
58032 -atomic_t fscache_n_retrievals_wait;
58033 -atomic_t fscache_n_retrievals_nodata;
58034 -atomic_t fscache_n_retrievals_nobufs;
58035 -atomic_t fscache_n_retrievals_intr;
58036 -atomic_t fscache_n_retrievals_nomem;
58037 -atomic_t fscache_n_retrievals_object_dead;
58038 -atomic_t fscache_n_retrieval_ops;
58039 -atomic_t fscache_n_retrieval_op_waits;
58040 +atomic_unchecked_t fscache_n_retrievals;
58041 +atomic_unchecked_t fscache_n_retrievals_ok;
58042 +atomic_unchecked_t fscache_n_retrievals_wait;
58043 +atomic_unchecked_t fscache_n_retrievals_nodata;
58044 +atomic_unchecked_t fscache_n_retrievals_nobufs;
58045 +atomic_unchecked_t fscache_n_retrievals_intr;
58046 +atomic_unchecked_t fscache_n_retrievals_nomem;
58047 +atomic_unchecked_t fscache_n_retrievals_object_dead;
58048 +atomic_unchecked_t fscache_n_retrieval_ops;
58049 +atomic_unchecked_t fscache_n_retrieval_op_waits;
58050
58051 -atomic_t fscache_n_stores;
58052 -atomic_t fscache_n_stores_ok;
58053 -atomic_t fscache_n_stores_again;
58054 -atomic_t fscache_n_stores_nobufs;
58055 -atomic_t fscache_n_stores_oom;
58056 -atomic_t fscache_n_store_ops;
58057 -atomic_t fscache_n_store_calls;
58058 -atomic_t fscache_n_store_pages;
58059 -atomic_t fscache_n_store_radix_deletes;
58060 -atomic_t fscache_n_store_pages_over_limit;
58061 +atomic_unchecked_t fscache_n_stores;
58062 +atomic_unchecked_t fscache_n_stores_ok;
58063 +atomic_unchecked_t fscache_n_stores_again;
58064 +atomic_unchecked_t fscache_n_stores_nobufs;
58065 +atomic_unchecked_t fscache_n_stores_oom;
58066 +atomic_unchecked_t fscache_n_store_ops;
58067 +atomic_unchecked_t fscache_n_store_calls;
58068 +atomic_unchecked_t fscache_n_store_pages;
58069 +atomic_unchecked_t fscache_n_store_radix_deletes;
58070 +atomic_unchecked_t fscache_n_store_pages_over_limit;
58071
58072 -atomic_t fscache_n_store_vmscan_not_storing;
58073 -atomic_t fscache_n_store_vmscan_gone;
58074 -atomic_t fscache_n_store_vmscan_busy;
58075 -atomic_t fscache_n_store_vmscan_cancelled;
58076 -atomic_t fscache_n_store_vmscan_wait;
58077 +atomic_unchecked_t fscache_n_store_vmscan_not_storing;
58078 +atomic_unchecked_t fscache_n_store_vmscan_gone;
58079 +atomic_unchecked_t fscache_n_store_vmscan_busy;
58080 +atomic_unchecked_t fscache_n_store_vmscan_cancelled;
58081 +atomic_unchecked_t fscache_n_store_vmscan_wait;
58082
58083 -atomic_t fscache_n_marks;
58084 -atomic_t fscache_n_uncaches;
58085 +atomic_unchecked_t fscache_n_marks;
58086 +atomic_unchecked_t fscache_n_uncaches;
58087
58088 -atomic_t fscache_n_acquires;
58089 -atomic_t fscache_n_acquires_null;
58090 -atomic_t fscache_n_acquires_no_cache;
58091 -atomic_t fscache_n_acquires_ok;
58092 -atomic_t fscache_n_acquires_nobufs;
58093 -atomic_t fscache_n_acquires_oom;
58094 +atomic_unchecked_t fscache_n_acquires;
58095 +atomic_unchecked_t fscache_n_acquires_null;
58096 +atomic_unchecked_t fscache_n_acquires_no_cache;
58097 +atomic_unchecked_t fscache_n_acquires_ok;
58098 +atomic_unchecked_t fscache_n_acquires_nobufs;
58099 +atomic_unchecked_t fscache_n_acquires_oom;
58100
58101 -atomic_t fscache_n_invalidates;
58102 -atomic_t fscache_n_invalidates_run;
58103 +atomic_unchecked_t fscache_n_invalidates;
58104 +atomic_unchecked_t fscache_n_invalidates_run;
58105
58106 -atomic_t fscache_n_updates;
58107 -atomic_t fscache_n_updates_null;
58108 -atomic_t fscache_n_updates_run;
58109 +atomic_unchecked_t fscache_n_updates;
58110 +atomic_unchecked_t fscache_n_updates_null;
58111 +atomic_unchecked_t fscache_n_updates_run;
58112
58113 -atomic_t fscache_n_relinquishes;
58114 -atomic_t fscache_n_relinquishes_null;
58115 -atomic_t fscache_n_relinquishes_waitcrt;
58116 -atomic_t fscache_n_relinquishes_retire;
58117 +atomic_unchecked_t fscache_n_relinquishes;
58118 +atomic_unchecked_t fscache_n_relinquishes_null;
58119 +atomic_unchecked_t fscache_n_relinquishes_waitcrt;
58120 +atomic_unchecked_t fscache_n_relinquishes_retire;
58121
58122 -atomic_t fscache_n_cookie_index;
58123 -atomic_t fscache_n_cookie_data;
58124 -atomic_t fscache_n_cookie_special;
58125 +atomic_unchecked_t fscache_n_cookie_index;
58126 +atomic_unchecked_t fscache_n_cookie_data;
58127 +atomic_unchecked_t fscache_n_cookie_special;
58128
58129 -atomic_t fscache_n_object_alloc;
58130 -atomic_t fscache_n_object_no_alloc;
58131 -atomic_t fscache_n_object_lookups;
58132 -atomic_t fscache_n_object_lookups_negative;
58133 -atomic_t fscache_n_object_lookups_positive;
58134 -atomic_t fscache_n_object_lookups_timed_out;
58135 -atomic_t fscache_n_object_created;
58136 -atomic_t fscache_n_object_avail;
58137 -atomic_t fscache_n_object_dead;
58138 +atomic_unchecked_t fscache_n_object_alloc;
58139 +atomic_unchecked_t fscache_n_object_no_alloc;
58140 +atomic_unchecked_t fscache_n_object_lookups;
58141 +atomic_unchecked_t fscache_n_object_lookups_negative;
58142 +atomic_unchecked_t fscache_n_object_lookups_positive;
58143 +atomic_unchecked_t fscache_n_object_lookups_timed_out;
58144 +atomic_unchecked_t fscache_n_object_created;
58145 +atomic_unchecked_t fscache_n_object_avail;
58146 +atomic_unchecked_t fscache_n_object_dead;
58147
58148 -atomic_t fscache_n_checkaux_none;
58149 -atomic_t fscache_n_checkaux_okay;
58150 -atomic_t fscache_n_checkaux_update;
58151 -atomic_t fscache_n_checkaux_obsolete;
58152 +atomic_unchecked_t fscache_n_checkaux_none;
58153 +atomic_unchecked_t fscache_n_checkaux_okay;
58154 +atomic_unchecked_t fscache_n_checkaux_update;
58155 +atomic_unchecked_t fscache_n_checkaux_obsolete;
58156
58157 atomic_t fscache_n_cop_alloc_object;
58158 atomic_t fscache_n_cop_lookup_object;
58159 @@ -138,118 +138,118 @@ static int fscache_stats_show(struct seq_file *m, void *v)
58160 seq_puts(m, "FS-Cache statistics\n");
58161
58162 seq_printf(m, "Cookies: idx=%u dat=%u spc=%u\n",
58163 - atomic_read(&fscache_n_cookie_index),
58164 - atomic_read(&fscache_n_cookie_data),
58165 - atomic_read(&fscache_n_cookie_special));
58166 + atomic_read_unchecked(&fscache_n_cookie_index),
58167 + atomic_read_unchecked(&fscache_n_cookie_data),
58168 + atomic_read_unchecked(&fscache_n_cookie_special));
58169
58170 seq_printf(m, "Objects: alc=%u nal=%u avl=%u ded=%u\n",
58171 - atomic_read(&fscache_n_object_alloc),
58172 - atomic_read(&fscache_n_object_no_alloc),
58173 - atomic_read(&fscache_n_object_avail),
58174 - atomic_read(&fscache_n_object_dead));
58175 + atomic_read_unchecked(&fscache_n_object_alloc),
58176 + atomic_read_unchecked(&fscache_n_object_no_alloc),
58177 + atomic_read_unchecked(&fscache_n_object_avail),
58178 + atomic_read_unchecked(&fscache_n_object_dead));
58179 seq_printf(m, "ChkAux : non=%u ok=%u upd=%u obs=%u\n",
58180 - atomic_read(&fscache_n_checkaux_none),
58181 - atomic_read(&fscache_n_checkaux_okay),
58182 - atomic_read(&fscache_n_checkaux_update),
58183 - atomic_read(&fscache_n_checkaux_obsolete));
58184 + atomic_read_unchecked(&fscache_n_checkaux_none),
58185 + atomic_read_unchecked(&fscache_n_checkaux_okay),
58186 + atomic_read_unchecked(&fscache_n_checkaux_update),
58187 + atomic_read_unchecked(&fscache_n_checkaux_obsolete));
58188
58189 seq_printf(m, "Pages : mrk=%u unc=%u\n",
58190 - atomic_read(&fscache_n_marks),
58191 - atomic_read(&fscache_n_uncaches));
58192 + atomic_read_unchecked(&fscache_n_marks),
58193 + atomic_read_unchecked(&fscache_n_uncaches));
58194
58195 seq_printf(m, "Acquire: n=%u nul=%u noc=%u ok=%u nbf=%u"
58196 " oom=%u\n",
58197 - atomic_read(&fscache_n_acquires),
58198 - atomic_read(&fscache_n_acquires_null),
58199 - atomic_read(&fscache_n_acquires_no_cache),
58200 - atomic_read(&fscache_n_acquires_ok),
58201 - atomic_read(&fscache_n_acquires_nobufs),
58202 - atomic_read(&fscache_n_acquires_oom));
58203 + atomic_read_unchecked(&fscache_n_acquires),
58204 + atomic_read_unchecked(&fscache_n_acquires_null),
58205 + atomic_read_unchecked(&fscache_n_acquires_no_cache),
58206 + atomic_read_unchecked(&fscache_n_acquires_ok),
58207 + atomic_read_unchecked(&fscache_n_acquires_nobufs),
58208 + atomic_read_unchecked(&fscache_n_acquires_oom));
58209
58210 seq_printf(m, "Lookups: n=%u neg=%u pos=%u crt=%u tmo=%u\n",
58211 - atomic_read(&fscache_n_object_lookups),
58212 - atomic_read(&fscache_n_object_lookups_negative),
58213 - atomic_read(&fscache_n_object_lookups_positive),
58214 - atomic_read(&fscache_n_object_created),
58215 - atomic_read(&fscache_n_object_lookups_timed_out));
58216 + atomic_read_unchecked(&fscache_n_object_lookups),
58217 + atomic_read_unchecked(&fscache_n_object_lookups_negative),
58218 + atomic_read_unchecked(&fscache_n_object_lookups_positive),
58219 + atomic_read_unchecked(&fscache_n_object_created),
58220 + atomic_read_unchecked(&fscache_n_object_lookups_timed_out));
58221
58222 seq_printf(m, "Invals : n=%u run=%u\n",
58223 - atomic_read(&fscache_n_invalidates),
58224 - atomic_read(&fscache_n_invalidates_run));
58225 + atomic_read_unchecked(&fscache_n_invalidates),
58226 + atomic_read_unchecked(&fscache_n_invalidates_run));
58227
58228 seq_printf(m, "Updates: n=%u nul=%u run=%u\n",
58229 - atomic_read(&fscache_n_updates),
58230 - atomic_read(&fscache_n_updates_null),
58231 - atomic_read(&fscache_n_updates_run));
58232 + atomic_read_unchecked(&fscache_n_updates),
58233 + atomic_read_unchecked(&fscache_n_updates_null),
58234 + atomic_read_unchecked(&fscache_n_updates_run));
58235
58236 seq_printf(m, "Relinqs: n=%u nul=%u wcr=%u rtr=%u\n",
58237 - atomic_read(&fscache_n_relinquishes),
58238 - atomic_read(&fscache_n_relinquishes_null),
58239 - atomic_read(&fscache_n_relinquishes_waitcrt),
58240 - atomic_read(&fscache_n_relinquishes_retire));
58241 + atomic_read_unchecked(&fscache_n_relinquishes),
58242 + atomic_read_unchecked(&fscache_n_relinquishes_null),
58243 + atomic_read_unchecked(&fscache_n_relinquishes_waitcrt),
58244 + atomic_read_unchecked(&fscache_n_relinquishes_retire));
58245
58246 seq_printf(m, "AttrChg: n=%u ok=%u nbf=%u oom=%u run=%u\n",
58247 - atomic_read(&fscache_n_attr_changed),
58248 - atomic_read(&fscache_n_attr_changed_ok),
58249 - atomic_read(&fscache_n_attr_changed_nobufs),
58250 - atomic_read(&fscache_n_attr_changed_nomem),
58251 - atomic_read(&fscache_n_attr_changed_calls));
58252 + atomic_read_unchecked(&fscache_n_attr_changed),
58253 + atomic_read_unchecked(&fscache_n_attr_changed_ok),
58254 + atomic_read_unchecked(&fscache_n_attr_changed_nobufs),
58255 + atomic_read_unchecked(&fscache_n_attr_changed_nomem),
58256 + atomic_read_unchecked(&fscache_n_attr_changed_calls));
58257
58258 seq_printf(m, "Allocs : n=%u ok=%u wt=%u nbf=%u int=%u\n",
58259 - atomic_read(&fscache_n_allocs),
58260 - atomic_read(&fscache_n_allocs_ok),
58261 - atomic_read(&fscache_n_allocs_wait),
58262 - atomic_read(&fscache_n_allocs_nobufs),
58263 - atomic_read(&fscache_n_allocs_intr));
58264 + atomic_read_unchecked(&fscache_n_allocs),
58265 + atomic_read_unchecked(&fscache_n_allocs_ok),
58266 + atomic_read_unchecked(&fscache_n_allocs_wait),
58267 + atomic_read_unchecked(&fscache_n_allocs_nobufs),
58268 + atomic_read_unchecked(&fscache_n_allocs_intr));
58269 seq_printf(m, "Allocs : ops=%u owt=%u abt=%u\n",
58270 - atomic_read(&fscache_n_alloc_ops),
58271 - atomic_read(&fscache_n_alloc_op_waits),
58272 - atomic_read(&fscache_n_allocs_object_dead));
58273 + atomic_read_unchecked(&fscache_n_alloc_ops),
58274 + atomic_read_unchecked(&fscache_n_alloc_op_waits),
58275 + atomic_read_unchecked(&fscache_n_allocs_object_dead));
58276
58277 seq_printf(m, "Retrvls: n=%u ok=%u wt=%u nod=%u nbf=%u"
58278 " int=%u oom=%u\n",
58279 - atomic_read(&fscache_n_retrievals),
58280 - atomic_read(&fscache_n_retrievals_ok),
58281 - atomic_read(&fscache_n_retrievals_wait),
58282 - atomic_read(&fscache_n_retrievals_nodata),
58283 - atomic_read(&fscache_n_retrievals_nobufs),
58284 - atomic_read(&fscache_n_retrievals_intr),
58285 - atomic_read(&fscache_n_retrievals_nomem));
58286 + atomic_read_unchecked(&fscache_n_retrievals),
58287 + atomic_read_unchecked(&fscache_n_retrievals_ok),
58288 + atomic_read_unchecked(&fscache_n_retrievals_wait),
58289 + atomic_read_unchecked(&fscache_n_retrievals_nodata),
58290 + atomic_read_unchecked(&fscache_n_retrievals_nobufs),
58291 + atomic_read_unchecked(&fscache_n_retrievals_intr),
58292 + atomic_read_unchecked(&fscache_n_retrievals_nomem));
58293 seq_printf(m, "Retrvls: ops=%u owt=%u abt=%u\n",
58294 - atomic_read(&fscache_n_retrieval_ops),
58295 - atomic_read(&fscache_n_retrieval_op_waits),
58296 - atomic_read(&fscache_n_retrievals_object_dead));
58297 + atomic_read_unchecked(&fscache_n_retrieval_ops),
58298 + atomic_read_unchecked(&fscache_n_retrieval_op_waits),
58299 + atomic_read_unchecked(&fscache_n_retrievals_object_dead));
58300
58301 seq_printf(m, "Stores : n=%u ok=%u agn=%u nbf=%u oom=%u\n",
58302 - atomic_read(&fscache_n_stores),
58303 - atomic_read(&fscache_n_stores_ok),
58304 - atomic_read(&fscache_n_stores_again),
58305 - atomic_read(&fscache_n_stores_nobufs),
58306 - atomic_read(&fscache_n_stores_oom));
58307 + atomic_read_unchecked(&fscache_n_stores),
58308 + atomic_read_unchecked(&fscache_n_stores_ok),
58309 + atomic_read_unchecked(&fscache_n_stores_again),
58310 + atomic_read_unchecked(&fscache_n_stores_nobufs),
58311 + atomic_read_unchecked(&fscache_n_stores_oom));
58312 seq_printf(m, "Stores : ops=%u run=%u pgs=%u rxd=%u olm=%u\n",
58313 - atomic_read(&fscache_n_store_ops),
58314 - atomic_read(&fscache_n_store_calls),
58315 - atomic_read(&fscache_n_store_pages),
58316 - atomic_read(&fscache_n_store_radix_deletes),
58317 - atomic_read(&fscache_n_store_pages_over_limit));
58318 + atomic_read_unchecked(&fscache_n_store_ops),
58319 + atomic_read_unchecked(&fscache_n_store_calls),
58320 + atomic_read_unchecked(&fscache_n_store_pages),
58321 + atomic_read_unchecked(&fscache_n_store_radix_deletes),
58322 + atomic_read_unchecked(&fscache_n_store_pages_over_limit));
58323
58324 seq_printf(m, "VmScan : nos=%u gon=%u bsy=%u can=%u wt=%u\n",
58325 - atomic_read(&fscache_n_store_vmscan_not_storing),
58326 - atomic_read(&fscache_n_store_vmscan_gone),
58327 - atomic_read(&fscache_n_store_vmscan_busy),
58328 - atomic_read(&fscache_n_store_vmscan_cancelled),
58329 - atomic_read(&fscache_n_store_vmscan_wait));
58330 + atomic_read_unchecked(&fscache_n_store_vmscan_not_storing),
58331 + atomic_read_unchecked(&fscache_n_store_vmscan_gone),
58332 + atomic_read_unchecked(&fscache_n_store_vmscan_busy),
58333 + atomic_read_unchecked(&fscache_n_store_vmscan_cancelled),
58334 + atomic_read_unchecked(&fscache_n_store_vmscan_wait));
58335
58336 seq_printf(m, "Ops : pend=%u run=%u enq=%u can=%u rej=%u\n",
58337 - atomic_read(&fscache_n_op_pend),
58338 - atomic_read(&fscache_n_op_run),
58339 - atomic_read(&fscache_n_op_enqueue),
58340 - atomic_read(&fscache_n_op_cancelled),
58341 - atomic_read(&fscache_n_op_rejected));
58342 + atomic_read_unchecked(&fscache_n_op_pend),
58343 + atomic_read_unchecked(&fscache_n_op_run),
58344 + atomic_read_unchecked(&fscache_n_op_enqueue),
58345 + atomic_read_unchecked(&fscache_n_op_cancelled),
58346 + atomic_read_unchecked(&fscache_n_op_rejected));
58347 seq_printf(m, "Ops : dfr=%u rel=%u gc=%u\n",
58348 - atomic_read(&fscache_n_op_deferred_release),
58349 - atomic_read(&fscache_n_op_release),
58350 - atomic_read(&fscache_n_op_gc));
58351 + atomic_read_unchecked(&fscache_n_op_deferred_release),
58352 + atomic_read_unchecked(&fscache_n_op_release),
58353 + atomic_read_unchecked(&fscache_n_op_gc));
58354
58355 seq_printf(m, "CacheOp: alo=%d luo=%d luc=%d gro=%d\n",
58356 atomic_read(&fscache_n_cop_alloc_object),
58357 diff --git a/fs/fuse/cuse.c b/fs/fuse/cuse.c
58358 index adbfd66..4b25822 100644
58359 --- a/fs/fuse/cuse.c
58360 +++ b/fs/fuse/cuse.c
58361 @@ -603,10 +603,12 @@ static int __init cuse_init(void)
58362 INIT_LIST_HEAD(&cuse_conntbl[i]);
58363
58364 /* inherit and extend fuse_dev_operations */
58365 - cuse_channel_fops = fuse_dev_operations;
58366 - cuse_channel_fops.owner = THIS_MODULE;
58367 - cuse_channel_fops.open = cuse_channel_open;
58368 - cuse_channel_fops.release = cuse_channel_release;
58369 + pax_open_kernel();
58370 + memcpy((void *)&cuse_channel_fops, &fuse_dev_operations, sizeof(fuse_dev_operations));
58371 + *(void **)&cuse_channel_fops.owner = THIS_MODULE;
58372 + *(void **)&cuse_channel_fops.open = cuse_channel_open;
58373 + *(void **)&cuse_channel_fops.release = cuse_channel_release;
58374 + pax_close_kernel();
58375
58376 cuse_class = class_create(THIS_MODULE, "cuse");
58377 if (IS_ERR(cuse_class))
58378 diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
58379 index ef74ad5..c9ac759e 100644
58380 --- a/fs/fuse/dev.c
58381 +++ b/fs/fuse/dev.c
58382 @@ -1339,7 +1339,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
58383 ret = 0;
58384 pipe_lock(pipe);
58385
58386 - if (!pipe->readers) {
58387 + if (!atomic_read(&pipe->readers)) {
58388 send_sig(SIGPIPE, current, 0);
58389 if (!ret)
58390 ret = -EPIPE;
58391 @@ -1364,7 +1364,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
58392 page_nr++;
58393 ret += buf->len;
58394
58395 - if (pipe->files)
58396 + if (atomic_read(&pipe->files))
58397 do_wakeup = 1;
58398 }
58399
58400 diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
58401 index b7989f2..1f72ec4 100644
58402 --- a/fs/fuse/dir.c
58403 +++ b/fs/fuse/dir.c
58404 @@ -1438,7 +1438,7 @@ static char *read_link(struct dentry *dentry)
58405 return link;
58406 }
58407
58408 -static void free_link(char *link)
58409 +static void free_link(const char *link)
58410 {
58411 if (!IS_ERR(link))
58412 free_page((unsigned long) link);
58413 diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
58414 index 1298766..c964c60 100644
58415 --- a/fs/gfs2/inode.c
58416 +++ b/fs/gfs2/inode.c
58417 @@ -1515,7 +1515,7 @@ out:
58418
58419 static void gfs2_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
58420 {
58421 - char *s = nd_get_link(nd);
58422 + const char *s = nd_get_link(nd);
58423 if (!IS_ERR(s))
58424 kfree(s);
58425 }
58426 diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c
58427 index 2543728..14d7bd4 100644
58428 --- a/fs/hostfs/hostfs_kern.c
58429 +++ b/fs/hostfs/hostfs_kern.c
58430 @@ -904,7 +904,7 @@ static void *hostfs_follow_link(struct dentry *dentry, struct nameidata *nd)
58431
58432 static void hostfs_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie)
58433 {
58434 - char *s = nd_get_link(nd);
58435 + const char *s = nd_get_link(nd);
58436 if (!IS_ERR(s))
58437 __putname(s);
58438 }
58439 diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
58440 index d19b30a..ef89c36 100644
58441 --- a/fs/hugetlbfs/inode.c
58442 +++ b/fs/hugetlbfs/inode.c
58443 @@ -152,6 +152,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
58444 struct mm_struct *mm = current->mm;
58445 struct vm_area_struct *vma;
58446 struct hstate *h = hstate_file(file);
58447 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
58448 struct vm_unmapped_area_info info;
58449
58450 if (len & ~huge_page_mask(h))
58451 @@ -165,17 +166,26 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
58452 return addr;
58453 }
58454
58455 +#ifdef CONFIG_PAX_RANDMMAP
58456 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
58457 +#endif
58458 +
58459 if (addr) {
58460 addr = ALIGN(addr, huge_page_size(h));
58461 vma = find_vma(mm, addr);
58462 - if (TASK_SIZE - len >= addr &&
58463 - (!vma || addr + len <= vma->vm_start))
58464 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
58465 return addr;
58466 }
58467
58468 info.flags = 0;
58469 info.length = len;
58470 info.low_limit = TASK_UNMAPPED_BASE;
58471 +
58472 +#ifdef CONFIG_PAX_RANDMMAP
58473 + if (mm->pax_flags & MF_PAX_RANDMMAP)
58474 + info.low_limit += mm->delta_mmap;
58475 +#endif
58476 +
58477 info.high_limit = TASK_SIZE;
58478 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
58479 info.align_offset = 0;
58480 @@ -908,7 +918,7 @@ static struct file_system_type hugetlbfs_fs_type = {
58481 };
58482 MODULE_ALIAS_FS("hugetlbfs");
58483
58484 -static struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
58485 +struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
58486
58487 static int can_do_hugetlb_shm(void)
58488 {
58489 diff --git a/fs/inode.c b/fs/inode.c
58490 index b33ba8e..3c79a47 100644
58491 --- a/fs/inode.c
58492 +++ b/fs/inode.c
58493 @@ -849,8 +849,8 @@ unsigned int get_next_ino(void)
58494
58495 #ifdef CONFIG_SMP
58496 if (unlikely((res & (LAST_INO_BATCH-1)) == 0)) {
58497 - static atomic_t shared_last_ino;
58498 - int next = atomic_add_return(LAST_INO_BATCH, &shared_last_ino);
58499 + static atomic_unchecked_t shared_last_ino;
58500 + int next = atomic_add_return_unchecked(LAST_INO_BATCH, &shared_last_ino);
58501
58502 res = next - LAST_INO_BATCH;
58503 }
58504 diff --git a/fs/jffs2/erase.c b/fs/jffs2/erase.c
58505 index 4a6cf28..d3a29d3 100644
58506 --- a/fs/jffs2/erase.c
58507 +++ b/fs/jffs2/erase.c
58508 @@ -452,7 +452,8 @@ static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseb
58509 struct jffs2_unknown_node marker = {
58510 .magic = cpu_to_je16(JFFS2_MAGIC_BITMASK),
58511 .nodetype = cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
58512 - .totlen = cpu_to_je32(c->cleanmarker_size)
58513 + .totlen = cpu_to_je32(c->cleanmarker_size),
58514 + .hdr_crc = cpu_to_je32(0)
58515 };
58516
58517 jffs2_prealloc_raw_node_refs(c, jeb, 1);
58518 diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c
58519 index a6597d6..41b30ec 100644
58520 --- a/fs/jffs2/wbuf.c
58521 +++ b/fs/jffs2/wbuf.c
58522 @@ -1023,7 +1023,8 @@ static const struct jffs2_unknown_node oob_cleanmarker =
58523 {
58524 .magic = constant_cpu_to_je16(JFFS2_MAGIC_BITMASK),
58525 .nodetype = constant_cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
58526 - .totlen = constant_cpu_to_je32(8)
58527 + .totlen = constant_cpu_to_je32(8),
58528 + .hdr_crc = constant_cpu_to_je32(0)
58529 };
58530
58531 /*
58532 diff --git a/fs/jfs/super.c b/fs/jfs/super.c
58533 index 6669aa2..36b033d 100644
58534 --- a/fs/jfs/super.c
58535 +++ b/fs/jfs/super.c
58536 @@ -882,7 +882,7 @@ static int __init init_jfs_fs(void)
58537
58538 jfs_inode_cachep =
58539 kmem_cache_create("jfs_ip", sizeof(struct jfs_inode_info), 0,
58540 - SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD,
58541 + SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD|SLAB_USERCOPY,
58542 init_once);
58543 if (jfs_inode_cachep == NULL)
58544 return -ENOMEM;
58545 diff --git a/fs/libfs.c b/fs/libfs.c
58546 index 193e0c2..7404665 100644
58547 --- a/fs/libfs.c
58548 +++ b/fs/libfs.c
58549 @@ -150,6 +150,9 @@ int dcache_readdir(struct file *file, struct dir_context *ctx)
58550
58551 for (p = q->next; p != &dentry->d_subdirs; p = p->next) {
58552 struct dentry *next = list_entry(p, struct dentry, d_u.d_child);
58553 + char d_name[sizeof(next->d_iname)];
58554 + const unsigned char *name;
58555 +
58556 spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED);
58557 if (!simple_positive(next)) {
58558 spin_unlock(&next->d_lock);
58559 @@ -158,7 +161,12 @@ int dcache_readdir(struct file *file, struct dir_context *ctx)
58560
58561 spin_unlock(&next->d_lock);
58562 spin_unlock(&dentry->d_lock);
58563 - if (!dir_emit(ctx, next->d_name.name, next->d_name.len,
58564 + name = next->d_name.name;
58565 + if (name == next->d_iname) {
58566 + memcpy(d_name, name, next->d_name.len);
58567 + name = d_name;
58568 + }
58569 + if (!dir_emit(ctx, name, next->d_name.len,
58570 next->d_inode->i_ino, dt_type(next->d_inode)))
58571 return 0;
58572 spin_lock(&dentry->d_lock);
58573 diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c
58574 index acd3947..1f896e2 100644
58575 --- a/fs/lockd/clntproc.c
58576 +++ b/fs/lockd/clntproc.c
58577 @@ -36,11 +36,11 @@ static const struct rpc_call_ops nlmclnt_cancel_ops;
58578 /*
58579 * Cookie counter for NLM requests
58580 */
58581 -static atomic_t nlm_cookie = ATOMIC_INIT(0x1234);
58582 +static atomic_unchecked_t nlm_cookie = ATOMIC_INIT(0x1234);
58583
58584 void nlmclnt_next_cookie(struct nlm_cookie *c)
58585 {
58586 - u32 cookie = atomic_inc_return(&nlm_cookie);
58587 + u32 cookie = atomic_inc_return_unchecked(&nlm_cookie);
58588
58589 memcpy(c->data, &cookie, 4);
58590 c->len=4;
58591 diff --git a/fs/locks.c b/fs/locks.c
58592 index b27a300..4156d0b 100644
58593 --- a/fs/locks.c
58594 +++ b/fs/locks.c
58595 @@ -2183,16 +2183,16 @@ void locks_remove_flock(struct file *filp)
58596 return;
58597
58598 if (filp->f_op && filp->f_op->flock) {
58599 - struct file_lock fl = {
58600 + struct file_lock flock = {
58601 .fl_pid = current->tgid,
58602 .fl_file = filp,
58603 .fl_flags = FL_FLOCK,
58604 .fl_type = F_UNLCK,
58605 .fl_end = OFFSET_MAX,
58606 };
58607 - filp->f_op->flock(filp, F_SETLKW, &fl);
58608 - if (fl.fl_ops && fl.fl_ops->fl_release_private)
58609 - fl.fl_ops->fl_release_private(&fl);
58610 + filp->f_op->flock(filp, F_SETLKW, &flock);
58611 + if (flock.fl_ops && flock.fl_ops->fl_release_private)
58612 + flock.fl_ops->fl_release_private(&flock);
58613 }
58614
58615 spin_lock(&inode->i_lock);
58616 diff --git a/fs/namei.c b/fs/namei.c
58617 index 23ac50f..c6757a5 100644
58618 --- a/fs/namei.c
58619 +++ b/fs/namei.c
58620 @@ -319,16 +319,32 @@ int generic_permission(struct inode *inode, int mask)
58621 if (ret != -EACCES)
58622 return ret;
58623
58624 +#ifdef CONFIG_GRKERNSEC
58625 + /* we'll block if we have to log due to a denied capability use */
58626 + if (mask & MAY_NOT_BLOCK)
58627 + return -ECHILD;
58628 +#endif
58629 +
58630 if (S_ISDIR(inode->i_mode)) {
58631 /* DACs are overridable for directories */
58632 - if (inode_capable(inode, CAP_DAC_OVERRIDE))
58633 - return 0;
58634 if (!(mask & MAY_WRITE))
58635 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
58636 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
58637 + inode_capable(inode, CAP_DAC_READ_SEARCH))
58638 return 0;
58639 + if (inode_capable(inode, CAP_DAC_OVERRIDE))
58640 + return 0;
58641 return -EACCES;
58642 }
58643 /*
58644 + * Searching includes executable on directories, else just read.
58645 + */
58646 + mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
58647 + if (mask == MAY_READ)
58648 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
58649 + inode_capable(inode, CAP_DAC_READ_SEARCH))
58650 + return 0;
58651 +
58652 + /*
58653 * Read/write DACs are always overridable.
58654 * Executable DACs are overridable when there is
58655 * at least one exec bit set.
58656 @@ -337,14 +353,6 @@ int generic_permission(struct inode *inode, int mask)
58657 if (inode_capable(inode, CAP_DAC_OVERRIDE))
58658 return 0;
58659
58660 - /*
58661 - * Searching includes executable on directories, else just read.
58662 - */
58663 - mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
58664 - if (mask == MAY_READ)
58665 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
58666 - return 0;
58667 -
58668 return -EACCES;
58669 }
58670
58671 @@ -821,7 +829,7 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
58672 {
58673 struct dentry *dentry = link->dentry;
58674 int error;
58675 - char *s;
58676 + const char *s;
58677
58678 BUG_ON(nd->flags & LOOKUP_RCU);
58679
58680 @@ -842,6 +850,12 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
58681 if (error)
58682 goto out_put_nd_path;
58683
58684 + if (gr_handle_follow_link(dentry->d_parent->d_inode,
58685 + dentry->d_inode, dentry, nd->path.mnt)) {
58686 + error = -EACCES;
58687 + goto out_put_nd_path;
58688 + }
58689 +
58690 nd->last_type = LAST_BIND;
58691 *p = dentry->d_inode->i_op->follow_link(dentry, nd);
58692 error = PTR_ERR(*p);
58693 @@ -1602,6 +1616,8 @@ static inline int nested_symlink(struct path *path, struct nameidata *nd)
58694 if (res)
58695 break;
58696 res = walk_component(nd, path, LOOKUP_FOLLOW);
58697 + if (res >= 0 && gr_handle_symlink_owner(&link, nd->inode))
58698 + res = -EACCES;
58699 put_link(nd, &link, cookie);
58700 } while (res > 0);
58701
58702 @@ -1700,7 +1716,7 @@ EXPORT_SYMBOL(full_name_hash);
58703 static inline unsigned long hash_name(const char *name, unsigned int *hashp)
58704 {
58705 unsigned long a, b, adata, bdata, mask, hash, len;
58706 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
58707 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
58708
58709 hash = a = 0;
58710 len = -sizeof(unsigned long);
58711 @@ -1981,6 +1997,8 @@ static int path_lookupat(int dfd, const char *name,
58712 if (err)
58713 break;
58714 err = lookup_last(nd, &path);
58715 + if (!err && gr_handle_symlink_owner(&link, nd->inode))
58716 + err = -EACCES;
58717 put_link(nd, &link, cookie);
58718 }
58719 }
58720 @@ -1988,6 +2006,13 @@ static int path_lookupat(int dfd, const char *name,
58721 if (!err)
58722 err = complete_walk(nd);
58723
58724 + if (!err && !(nd->flags & LOOKUP_PARENT)) {
58725 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
58726 + path_put(&nd->path);
58727 + err = -ENOENT;
58728 + }
58729 + }
58730 +
58731 if (!err && nd->flags & LOOKUP_DIRECTORY) {
58732 if (!can_lookup(nd->inode)) {
58733 path_put(&nd->path);
58734 @@ -2015,8 +2040,15 @@ static int filename_lookup(int dfd, struct filename *name,
58735 retval = path_lookupat(dfd, name->name,
58736 flags | LOOKUP_REVAL, nd);
58737
58738 - if (likely(!retval))
58739 + if (likely(!retval)) {
58740 audit_inode(name, nd->path.dentry, flags & LOOKUP_PARENT);
58741 + if (name->name[0] != '/' && nd->path.dentry && nd->inode) {
58742 + if (!gr_chroot_fchdir(nd->path.dentry, nd->path.mnt)) {
58743 + path_put(&nd->path);
58744 + return -ENOENT;
58745 + }
58746 + }
58747 + }
58748 return retval;
58749 }
58750
58751 @@ -2587,6 +2619,13 @@ static int may_open(struct path *path, int acc_mode, int flag)
58752 if (flag & O_NOATIME && !inode_owner_or_capable(inode))
58753 return -EPERM;
58754
58755 + if (gr_handle_rofs_blockwrite(dentry, path->mnt, acc_mode))
58756 + return -EPERM;
58757 + if (gr_handle_rawio(inode))
58758 + return -EPERM;
58759 + if (!gr_acl_handle_open(dentry, path->mnt, acc_mode))
58760 + return -EACCES;
58761 +
58762 return 0;
58763 }
58764
58765 @@ -2818,7 +2857,7 @@ looked_up:
58766 * cleared otherwise prior to returning.
58767 */
58768 static int lookup_open(struct nameidata *nd, struct path *path,
58769 - struct file *file,
58770 + struct path *link, struct file *file,
58771 const struct open_flags *op,
58772 bool got_write, int *opened)
58773 {
58774 @@ -2853,6 +2892,17 @@ static int lookup_open(struct nameidata *nd, struct path *path,
58775 /* Negative dentry, just create the file */
58776 if (!dentry->d_inode && (op->open_flag & O_CREAT)) {
58777 umode_t mode = op->mode;
58778 +
58779 + if (link && gr_handle_symlink_owner(link, dir->d_inode)) {
58780 + error = -EACCES;
58781 + goto out_dput;
58782 + }
58783 +
58784 + if (!gr_acl_handle_creat(dentry, dir, nd->path.mnt, op->open_flag, op->acc_mode, mode)) {
58785 + error = -EACCES;
58786 + goto out_dput;
58787 + }
58788 +
58789 if (!IS_POSIXACL(dir->d_inode))
58790 mode &= ~current_umask();
58791 /*
58792 @@ -2874,6 +2924,8 @@ static int lookup_open(struct nameidata *nd, struct path *path,
58793 nd->flags & LOOKUP_EXCL);
58794 if (error)
58795 goto out_dput;
58796 + else
58797 + gr_handle_create(dentry, nd->path.mnt);
58798 }
58799 out_no_open:
58800 path->dentry = dentry;
58801 @@ -2888,7 +2940,7 @@ out_dput:
58802 /*
58803 * Handle the last step of open()
58804 */
58805 -static int do_last(struct nameidata *nd, struct path *path,
58806 +static int do_last(struct nameidata *nd, struct path *path, struct path *link,
58807 struct file *file, const struct open_flags *op,
58808 int *opened, struct filename *name)
58809 {
58810 @@ -2938,6 +2990,15 @@ static int do_last(struct nameidata *nd, struct path *path,
58811 if (error)
58812 return error;
58813
58814 + if (!gr_acl_handle_hidden_file(dir, nd->path.mnt)) {
58815 + error = -ENOENT;
58816 + goto out;
58817 + }
58818 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
58819 + error = -EACCES;
58820 + goto out;
58821 + }
58822 +
58823 audit_inode(name, dir, LOOKUP_PARENT);
58824 error = -EISDIR;
58825 /* trailing slashes? */
58826 @@ -2957,7 +3018,7 @@ retry_lookup:
58827 */
58828 }
58829 mutex_lock(&dir->d_inode->i_mutex);
58830 - error = lookup_open(nd, path, file, op, got_write, opened);
58831 + error = lookup_open(nd, path, link, file, op, got_write, opened);
58832 mutex_unlock(&dir->d_inode->i_mutex);
58833
58834 if (error <= 0) {
58835 @@ -2981,11 +3042,28 @@ retry_lookup:
58836 goto finish_open_created;
58837 }
58838
58839 + if (!gr_acl_handle_hidden_file(path->dentry, nd->path.mnt)) {
58840 + error = -ENOENT;
58841 + goto exit_dput;
58842 + }
58843 + if (link && gr_handle_symlink_owner(link, path->dentry->d_inode)) {
58844 + error = -EACCES;
58845 + goto exit_dput;
58846 + }
58847 +
58848 /*
58849 * create/update audit record if it already exists.
58850 */
58851 - if (path->dentry->d_inode)
58852 + if (path->dentry->d_inode) {
58853 + /* only check if O_CREAT is specified, all other checks need to go
58854 + into may_open */
58855 + if (gr_handle_fifo(path->dentry, path->mnt, dir, open_flag, acc_mode)) {
58856 + error = -EACCES;
58857 + goto exit_dput;
58858 + }
58859 +
58860 audit_inode(name, path->dentry, 0);
58861 + }
58862
58863 /*
58864 * If atomic_open() acquired write access it is dropped now due to
58865 @@ -3026,6 +3104,11 @@ finish_lookup:
58866 }
58867 }
58868 BUG_ON(inode != path->dentry->d_inode);
58869 + /* if we're resolving a symlink to another symlink */
58870 + if (link && gr_handle_symlink_owner(link, inode)) {
58871 + error = -EACCES;
58872 + goto out;
58873 + }
58874 return 1;
58875 }
58876
58877 @@ -3035,7 +3118,6 @@ finish_lookup:
58878 save_parent.dentry = nd->path.dentry;
58879 save_parent.mnt = mntget(path->mnt);
58880 nd->path.dentry = path->dentry;
58881 -
58882 }
58883 nd->inode = inode;
58884 /* Why this, you ask? _Now_ we might have grown LOOKUP_JUMPED... */
58885 @@ -3045,7 +3127,18 @@ finish_open:
58886 path_put(&save_parent);
58887 return error;
58888 }
58889 +
58890 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
58891 + error = -ENOENT;
58892 + goto out;
58893 + }
58894 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
58895 + error = -EACCES;
58896 + goto out;
58897 + }
58898 +
58899 audit_inode(name, nd->path.dentry, 0);
58900 +
58901 error = -EISDIR;
58902 if ((open_flag & O_CREAT) && S_ISDIR(nd->inode->i_mode))
58903 goto out;
58904 @@ -3208,7 +3301,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
58905 if (unlikely(error))
58906 goto out;
58907
58908 - error = do_last(nd, &path, file, op, &opened, pathname);
58909 + error = do_last(nd, &path, NULL, file, op, &opened, pathname);
58910 while (unlikely(error > 0)) { /* trailing symlink */
58911 struct path link = path;
58912 void *cookie;
58913 @@ -3226,7 +3319,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
58914 error = follow_link(&link, nd, &cookie);
58915 if (unlikely(error))
58916 break;
58917 - error = do_last(nd, &path, file, op, &opened, pathname);
58918 + error = do_last(nd, &path, &link, file, op, &opened, pathname);
58919 put_link(nd, &link, cookie);
58920 }
58921 out:
58922 @@ -3326,8 +3419,12 @@ struct dentry *kern_path_create(int dfd, const char *pathname,
58923 goto unlock;
58924
58925 error = -EEXIST;
58926 - if (dentry->d_inode)
58927 + if (dentry->d_inode) {
58928 + if (!gr_acl_handle_hidden_file(dentry, nd.path.mnt)) {
58929 + error = -ENOENT;
58930 + }
58931 goto fail;
58932 + }
58933 /*
58934 * Special case - lookup gave negative, but... we had foo/bar/
58935 * From the vfs_mknod() POV we just have a negative dentry -
58936 @@ -3379,6 +3476,20 @@ struct dentry *user_path_create(int dfd, const char __user *pathname,
58937 }
58938 EXPORT_SYMBOL(user_path_create);
58939
58940 +static struct dentry *user_path_create_with_name(int dfd, const char __user *pathname, struct path *path, struct filename **to, unsigned int lookup_flags)
58941 +{
58942 + struct filename *tmp = getname(pathname);
58943 + struct dentry *res;
58944 + if (IS_ERR(tmp))
58945 + return ERR_CAST(tmp);
58946 + res = kern_path_create(dfd, tmp->name, path, lookup_flags);
58947 + if (IS_ERR(res))
58948 + putname(tmp);
58949 + else
58950 + *to = tmp;
58951 + return res;
58952 +}
58953 +
58954 int vfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev)
58955 {
58956 int error = may_create(dir, dentry);
58957 @@ -3441,6 +3552,17 @@ retry:
58958
58959 if (!IS_POSIXACL(path.dentry->d_inode))
58960 mode &= ~current_umask();
58961 +
58962 + if (gr_handle_chroot_mknod(dentry, path.mnt, mode)) {
58963 + error = -EPERM;
58964 + goto out;
58965 + }
58966 +
58967 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
58968 + error = -EACCES;
58969 + goto out;
58970 + }
58971 +
58972 error = security_path_mknod(&path, dentry, mode, dev);
58973 if (error)
58974 goto out;
58975 @@ -3457,6 +3579,8 @@ retry:
58976 break;
58977 }
58978 out:
58979 + if (!error)
58980 + gr_handle_create(dentry, path.mnt);
58981 done_path_create(&path, dentry);
58982 if (retry_estale(error, lookup_flags)) {
58983 lookup_flags |= LOOKUP_REVAL;
58984 @@ -3509,9 +3633,16 @@ retry:
58985
58986 if (!IS_POSIXACL(path.dentry->d_inode))
58987 mode &= ~current_umask();
58988 + if (!gr_acl_handle_mkdir(dentry, path.dentry, path.mnt)) {
58989 + error = -EACCES;
58990 + goto out;
58991 + }
58992 error = security_path_mkdir(&path, dentry, mode);
58993 if (!error)
58994 error = vfs_mkdir(path.dentry->d_inode, dentry, mode);
58995 + if (!error)
58996 + gr_handle_create(dentry, path.mnt);
58997 +out:
58998 done_path_create(&path, dentry);
58999 if (retry_estale(error, lookup_flags)) {
59000 lookup_flags |= LOOKUP_REVAL;
59001 @@ -3592,6 +3723,8 @@ static long do_rmdir(int dfd, const char __user *pathname)
59002 struct filename *name;
59003 struct dentry *dentry;
59004 struct nameidata nd;
59005 + ino_t saved_ino = 0;
59006 + dev_t saved_dev = 0;
59007 unsigned int lookup_flags = 0;
59008 retry:
59009 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
59010 @@ -3624,10 +3757,21 @@ retry:
59011 error = -ENOENT;
59012 goto exit3;
59013 }
59014 +
59015 + saved_ino = dentry->d_inode->i_ino;
59016 + saved_dev = gr_get_dev_from_dentry(dentry);
59017 +
59018 + if (!gr_acl_handle_rmdir(dentry, nd.path.mnt)) {
59019 + error = -EACCES;
59020 + goto exit3;
59021 + }
59022 +
59023 error = security_path_rmdir(&nd.path, dentry);
59024 if (error)
59025 goto exit3;
59026 error = vfs_rmdir(nd.path.dentry->d_inode, dentry);
59027 + if (!error && (saved_dev || saved_ino))
59028 + gr_handle_delete(saved_ino, saved_dev);
59029 exit3:
59030 dput(dentry);
59031 exit2:
59032 @@ -3693,6 +3837,8 @@ static long do_unlinkat(int dfd, const char __user *pathname)
59033 struct dentry *dentry;
59034 struct nameidata nd;
59035 struct inode *inode = NULL;
59036 + ino_t saved_ino = 0;
59037 + dev_t saved_dev = 0;
59038 unsigned int lookup_flags = 0;
59039 retry:
59040 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
59041 @@ -3719,10 +3865,22 @@ retry:
59042 if (!inode)
59043 goto slashes;
59044 ihold(inode);
59045 +
59046 + if (inode->i_nlink <= 1) {
59047 + saved_ino = inode->i_ino;
59048 + saved_dev = gr_get_dev_from_dentry(dentry);
59049 + }
59050 + if (!gr_acl_handle_unlink(dentry, nd.path.mnt)) {
59051 + error = -EACCES;
59052 + goto exit2;
59053 + }
59054 +
59055 error = security_path_unlink(&nd.path, dentry);
59056 if (error)
59057 goto exit2;
59058 error = vfs_unlink(nd.path.dentry->d_inode, dentry);
59059 + if (!error && (saved_ino || saved_dev))
59060 + gr_handle_delete(saved_ino, saved_dev);
59061 exit2:
59062 dput(dentry);
59063 }
59064 @@ -3800,9 +3958,17 @@ retry:
59065 if (IS_ERR(dentry))
59066 goto out_putname;
59067
59068 + if (!gr_acl_handle_symlink(dentry, path.dentry, path.mnt, from)) {
59069 + error = -EACCES;
59070 + goto out;
59071 + }
59072 +
59073 error = security_path_symlink(&path, dentry, from->name);
59074 if (!error)
59075 error = vfs_symlink(path.dentry->d_inode, dentry, from->name);
59076 + if (!error)
59077 + gr_handle_create(dentry, path.mnt);
59078 +out:
59079 done_path_create(&path, dentry);
59080 if (retry_estale(error, lookup_flags)) {
59081 lookup_flags |= LOOKUP_REVAL;
59082 @@ -3882,6 +4048,7 @@ SYSCALL_DEFINE5(linkat, int, olddfd, const char __user *, oldname,
59083 {
59084 struct dentry *new_dentry;
59085 struct path old_path, new_path;
59086 + struct filename *to = NULL;
59087 int how = 0;
59088 int error;
59089
59090 @@ -3905,7 +4072,7 @@ retry:
59091 if (error)
59092 return error;
59093
59094 - new_dentry = user_path_create(newdfd, newname, &new_path,
59095 + new_dentry = user_path_create_with_name(newdfd, newname, &new_path, &to,
59096 (how & LOOKUP_REVAL));
59097 error = PTR_ERR(new_dentry);
59098 if (IS_ERR(new_dentry))
59099 @@ -3917,11 +4084,28 @@ retry:
59100 error = may_linkat(&old_path);
59101 if (unlikely(error))
59102 goto out_dput;
59103 +
59104 + if (gr_handle_hardlink(old_path.dentry, old_path.mnt,
59105 + old_path.dentry->d_inode,
59106 + old_path.dentry->d_inode->i_mode, to)) {
59107 + error = -EACCES;
59108 + goto out_dput;
59109 + }
59110 +
59111 + if (!gr_acl_handle_link(new_dentry, new_path.dentry, new_path.mnt,
59112 + old_path.dentry, old_path.mnt, to)) {
59113 + error = -EACCES;
59114 + goto out_dput;
59115 + }
59116 +
59117 error = security_path_link(old_path.dentry, &new_path, new_dentry);
59118 if (error)
59119 goto out_dput;
59120 error = vfs_link(old_path.dentry, new_path.dentry->d_inode, new_dentry);
59121 + if (!error)
59122 + gr_handle_create(new_dentry, new_path.mnt);
59123 out_dput:
59124 + putname(to);
59125 done_path_create(&new_path, new_dentry);
59126 if (retry_estale(error, how)) {
59127 how |= LOOKUP_REVAL;
59128 @@ -4167,12 +4351,21 @@ retry:
59129 if (new_dentry == trap)
59130 goto exit5;
59131
59132 + error = gr_acl_handle_rename(new_dentry, new_dir, newnd.path.mnt,
59133 + old_dentry, old_dir->d_inode, oldnd.path.mnt,
59134 + to);
59135 + if (error)
59136 + goto exit5;
59137 +
59138 error = security_path_rename(&oldnd.path, old_dentry,
59139 &newnd.path, new_dentry);
59140 if (error)
59141 goto exit5;
59142 error = vfs_rename(old_dir->d_inode, old_dentry,
59143 new_dir->d_inode, new_dentry);
59144 + if (!error)
59145 + gr_handle_rename(old_dir->d_inode, new_dir->d_inode, old_dentry,
59146 + new_dentry, oldnd.path.mnt, new_dentry->d_inode ? 1 : 0);
59147 exit5:
59148 dput(new_dentry);
59149 exit4:
59150 @@ -4204,6 +4397,8 @@ SYSCALL_DEFINE2(rename, const char __user *, oldname, const char __user *, newna
59151
59152 int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const char *link)
59153 {
59154 + char tmpbuf[64];
59155 + const char *newlink;
59156 int len;
59157
59158 len = PTR_ERR(link);
59159 @@ -4213,7 +4408,14 @@ int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const c
59160 len = strlen(link);
59161 if (len > (unsigned) buflen)
59162 len = buflen;
59163 - if (copy_to_user(buffer, link, len))
59164 +
59165 + if (len < sizeof(tmpbuf)) {
59166 + memcpy(tmpbuf, link, len);
59167 + newlink = tmpbuf;
59168 + } else
59169 + newlink = link;
59170 +
59171 + if (copy_to_user(buffer, newlink, len))
59172 len = -EFAULT;
59173 out:
59174 return len;
59175 diff --git a/fs/namespace.c b/fs/namespace.c
59176 index da5c494..a755a54 100644
59177 --- a/fs/namespace.c
59178 +++ b/fs/namespace.c
59179 @@ -1268,6 +1268,9 @@ static int do_umount(struct mount *mnt, int flags)
59180 if (!(sb->s_flags & MS_RDONLY))
59181 retval = do_remount_sb(sb, MS_RDONLY, NULL, 0);
59182 up_write(&sb->s_umount);
59183 +
59184 + gr_log_remount(mnt->mnt_devname, retval);
59185 +
59186 return retval;
59187 }
59188
59189 @@ -1286,6 +1289,9 @@ static int do_umount(struct mount *mnt, int flags)
59190 }
59191 br_write_unlock(&vfsmount_lock);
59192 namespace_unlock();
59193 +
59194 + gr_log_unmount(mnt->mnt_devname, retval);
59195 +
59196 return retval;
59197 }
59198
59199 @@ -1305,7 +1311,7 @@ static inline bool may_mount(void)
59200 * unixes. Our API is identical to OSF/1 to avoid making a mess of AMD
59201 */
59202
59203 -SYSCALL_DEFINE2(umount, char __user *, name, int, flags)
59204 +SYSCALL_DEFINE2(umount, const char __user *, name, int, flags)
59205 {
59206 struct path path;
59207 struct mount *mnt;
59208 @@ -1347,7 +1353,7 @@ out:
59209 /*
59210 * The 2.0 compatible umount. No flags.
59211 */
59212 -SYSCALL_DEFINE1(oldumount, char __user *, name)
59213 +SYSCALL_DEFINE1(oldumount, const char __user *, name)
59214 {
59215 return sys_umount(name, 0);
59216 }
59217 @@ -2358,6 +2364,16 @@ long do_mount(const char *dev_name, const char *dir_name,
59218 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
59219 MS_STRICTATIME);
59220
59221 + if (gr_handle_rofs_mount(path.dentry, path.mnt, mnt_flags)) {
59222 + retval = -EPERM;
59223 + goto dput_out;
59224 + }
59225 +
59226 + if (gr_handle_chroot_mount(path.dentry, path.mnt, dev_name)) {
59227 + retval = -EPERM;
59228 + goto dput_out;
59229 + }
59230 +
59231 if (flags & MS_REMOUNT)
59232 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
59233 data_page);
59234 @@ -2372,6 +2388,9 @@ long do_mount(const char *dev_name, const char *dir_name,
59235 dev_name, data_page);
59236 dput_out:
59237 path_put(&path);
59238 +
59239 + gr_log_mount(dev_name, dir_name, retval);
59240 +
59241 return retval;
59242 }
59243
59244 @@ -2389,7 +2408,7 @@ static void free_mnt_ns(struct mnt_namespace *ns)
59245 * number incrementing at 10Ghz will take 12,427 years to wrap which
59246 * is effectively never, so we can ignore the possibility.
59247 */
59248 -static atomic64_t mnt_ns_seq = ATOMIC64_INIT(1);
59249 +static atomic64_unchecked_t mnt_ns_seq = ATOMIC64_INIT(1);
59250
59251 static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns)
59252 {
59253 @@ -2404,7 +2423,7 @@ static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns)
59254 kfree(new_ns);
59255 return ERR_PTR(ret);
59256 }
59257 - new_ns->seq = atomic64_add_return(1, &mnt_ns_seq);
59258 + new_ns->seq = atomic64_inc_return_unchecked(&mnt_ns_seq);
59259 atomic_set(&new_ns->count, 1);
59260 new_ns->root = NULL;
59261 INIT_LIST_HEAD(&new_ns->list);
59262 @@ -2418,7 +2437,7 @@ static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns)
59263 * Allocate a new namespace structure and populate it with contents
59264 * copied from the namespace of the passed in task structure.
59265 */
59266 -static struct mnt_namespace *dup_mnt_ns(struct mnt_namespace *mnt_ns,
59267 +static __latent_entropy struct mnt_namespace *dup_mnt_ns(struct mnt_namespace *mnt_ns,
59268 struct user_namespace *user_ns, struct fs_struct *fs)
59269 {
59270 struct mnt_namespace *new_ns;
59271 @@ -2549,8 +2568,8 @@ struct dentry *mount_subtree(struct vfsmount *mnt, const char *name)
59272 }
59273 EXPORT_SYMBOL(mount_subtree);
59274
59275 -SYSCALL_DEFINE5(mount, char __user *, dev_name, char __user *, dir_name,
59276 - char __user *, type, unsigned long, flags, void __user *, data)
59277 +SYSCALL_DEFINE5(mount, const char __user *, dev_name, const char __user *, dir_name,
59278 + const char __user *, type, unsigned long, flags, void __user *, data)
59279 {
59280 int ret;
59281 char *kernel_type;
59282 @@ -2663,6 +2682,11 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root,
59283 if (error)
59284 goto out2;
59285
59286 + if (gr_handle_chroot_pivot()) {
59287 + error = -EPERM;
59288 + goto out2;
59289 + }
59290 +
59291 get_fs_root(current->fs, &root);
59292 old_mp = lock_mount(&old);
59293 error = PTR_ERR(old_mp);
59294 @@ -2932,7 +2956,7 @@ static int mntns_install(struct nsproxy *nsproxy, void *ns)
59295 !ns_capable(current_user_ns(), CAP_SYS_ADMIN))
59296 return -EPERM;
59297
59298 - if (fs->users != 1)
59299 + if (atomic_read(&fs->users) != 1)
59300 return -EINVAL;
59301
59302 get_mnt_ns(mnt_ns);
59303 diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c
59304 index f4ccfe6..a5cf064 100644
59305 --- a/fs/nfs/callback_xdr.c
59306 +++ b/fs/nfs/callback_xdr.c
59307 @@ -51,7 +51,7 @@ struct callback_op {
59308 callback_decode_arg_t decode_args;
59309 callback_encode_res_t encode_res;
59310 long res_maxsize;
59311 -};
59312 +} __do_const;
59313
59314 static struct callback_op callback_ops[];
59315
59316 diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
59317 index eda8879..bfc6837 100644
59318 --- a/fs/nfs/inode.c
59319 +++ b/fs/nfs/inode.c
59320 @@ -1150,16 +1150,16 @@ static int nfs_size_need_update(const struct inode *inode, const struct nfs_fatt
59321 return nfs_size_to_loff_t(fattr->size) > i_size_read(inode);
59322 }
59323
59324 -static atomic_long_t nfs_attr_generation_counter;
59325 +static atomic_long_unchecked_t nfs_attr_generation_counter;
59326
59327 static unsigned long nfs_read_attr_generation_counter(void)
59328 {
59329 - return atomic_long_read(&nfs_attr_generation_counter);
59330 + return atomic_long_read_unchecked(&nfs_attr_generation_counter);
59331 }
59332
59333 unsigned long nfs_inc_attr_generation_counter(void)
59334 {
59335 - return atomic_long_inc_return(&nfs_attr_generation_counter);
59336 + return atomic_long_inc_return_unchecked(&nfs_attr_generation_counter);
59337 }
59338
59339 void nfs_fattr_init(struct nfs_fattr *fattr)
59340 diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
59341 index 419572f..5414a23 100644
59342 --- a/fs/nfsd/nfs4proc.c
59343 +++ b/fs/nfsd/nfs4proc.c
59344 @@ -1168,7 +1168,7 @@ struct nfsd4_operation {
59345 nfsd4op_rsize op_rsize_bop;
59346 stateid_getter op_get_currentstateid;
59347 stateid_setter op_set_currentstateid;
59348 -};
59349 +} __do_const;
59350
59351 static struct nfsd4_operation nfsd4_ops[];
59352
59353 diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
59354 index ecc735e..79b2d31 100644
59355 --- a/fs/nfsd/nfs4xdr.c
59356 +++ b/fs/nfsd/nfs4xdr.c
59357 @@ -1500,7 +1500,7 @@ nfsd4_decode_notsupp(struct nfsd4_compoundargs *argp, void *p)
59358
59359 typedef __be32(*nfsd4_dec)(struct nfsd4_compoundargs *argp, void *);
59360
59361 -static nfsd4_dec nfsd4_dec_ops[] = {
59362 +static const nfsd4_dec nfsd4_dec_ops[] = {
59363 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
59364 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
59365 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
59366 @@ -1540,7 +1540,7 @@ static nfsd4_dec nfsd4_dec_ops[] = {
59367 [OP_RELEASE_LOCKOWNER] = (nfsd4_dec)nfsd4_decode_release_lockowner,
59368 };
59369
59370 -static nfsd4_dec nfsd41_dec_ops[] = {
59371 +static const nfsd4_dec nfsd41_dec_ops[] = {
59372 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
59373 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
59374 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
59375 @@ -1602,7 +1602,7 @@ static nfsd4_dec nfsd41_dec_ops[] = {
59376 };
59377
59378 struct nfsd4_minorversion_ops {
59379 - nfsd4_dec *decoders;
59380 + const nfsd4_dec *decoders;
59381 int nops;
59382 };
59383
59384 diff --git a/fs/nfsd/nfscache.c b/fs/nfsd/nfscache.c
59385 index b6af150..f6ec5e3 100644
59386 --- a/fs/nfsd/nfscache.c
59387 +++ b/fs/nfsd/nfscache.c
59388 @@ -547,14 +547,17 @@ nfsd_cache_update(struct svc_rqst *rqstp, int cachetype, __be32 *statp)
59389 {
59390 struct svc_cacherep *rp = rqstp->rq_cacherep;
59391 struct kvec *resv = &rqstp->rq_res.head[0], *cachv;
59392 - int len;
59393 + long len;
59394 size_t bufsize = 0;
59395
59396 if (!rp)
59397 return;
59398
59399 - len = resv->iov_len - ((char*)statp - (char*)resv->iov_base);
59400 - len >>= 2;
59401 + if (statp) {
59402 + len = (char*)statp - (char*)resv->iov_base;
59403 + len = resv->iov_len - len;
59404 + len >>= 2;
59405 + }
59406
59407 /* Don't cache excessive amounts of data and XDR failures */
59408 if (!statp || len > (256 >> 2)) {
59409 diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
59410 index 72cb28e..5b5f87d 100644
59411 --- a/fs/nfsd/vfs.c
59412 +++ b/fs/nfsd/vfs.c
59413 @@ -993,7 +993,7 @@ nfsd_vfs_read(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
59414 } else {
59415 oldfs = get_fs();
59416 set_fs(KERNEL_DS);
59417 - host_err = vfs_readv(file, (struct iovec __user *)vec, vlen, &offset);
59418 + host_err = vfs_readv(file, (struct iovec __force_user *)vec, vlen, &offset);
59419 set_fs(oldfs);
59420 }
59421
59422 @@ -1080,7 +1080,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
59423
59424 /* Write the data. */
59425 oldfs = get_fs(); set_fs(KERNEL_DS);
59426 - host_err = vfs_writev(file, (struct iovec __user *)vec, vlen, &pos);
59427 + host_err = vfs_writev(file, (struct iovec __force_user *)vec, vlen, &pos);
59428 set_fs(oldfs);
59429 if (host_err < 0)
59430 goto out_nfserr;
59431 @@ -1626,7 +1626,7 @@ nfsd_readlink(struct svc_rqst *rqstp, struct svc_fh *fhp, char *buf, int *lenp)
59432 */
59433
59434 oldfs = get_fs(); set_fs(KERNEL_DS);
59435 - host_err = inode->i_op->readlink(path.dentry, (char __user *)buf, *lenp);
59436 + host_err = inode->i_op->readlink(path.dentry, (char __force_user *)buf, *lenp);
59437 set_fs(oldfs);
59438
59439 if (host_err < 0)
59440 diff --git a/fs/nls/nls_base.c b/fs/nls/nls_base.c
59441 index fea6bd5..8ee9d81 100644
59442 --- a/fs/nls/nls_base.c
59443 +++ b/fs/nls/nls_base.c
59444 @@ -234,20 +234,22 @@ EXPORT_SYMBOL(utf16s_to_utf8s);
59445
59446 int register_nls(struct nls_table * nls)
59447 {
59448 - struct nls_table ** tmp = &tables;
59449 + struct nls_table *tmp = tables;
59450
59451 if (nls->next)
59452 return -EBUSY;
59453
59454 spin_lock(&nls_lock);
59455 - while (*tmp) {
59456 - if (nls == *tmp) {
59457 + while (tmp) {
59458 + if (nls == tmp) {
59459 spin_unlock(&nls_lock);
59460 return -EBUSY;
59461 }
59462 - tmp = &(*tmp)->next;
59463 + tmp = tmp->next;
59464 }
59465 - nls->next = tables;
59466 + pax_open_kernel();
59467 + *(struct nls_table **)&nls->next = tables;
59468 + pax_close_kernel();
59469 tables = nls;
59470 spin_unlock(&nls_lock);
59471 return 0;
59472 @@ -255,12 +257,14 @@ int register_nls(struct nls_table * nls)
59473
59474 int unregister_nls(struct nls_table * nls)
59475 {
59476 - struct nls_table ** tmp = &tables;
59477 + struct nls_table * const * tmp = &tables;
59478
59479 spin_lock(&nls_lock);
59480 while (*tmp) {
59481 if (nls == *tmp) {
59482 - *tmp = nls->next;
59483 + pax_open_kernel();
59484 + *(struct nls_table **)tmp = nls->next;
59485 + pax_close_kernel();
59486 spin_unlock(&nls_lock);
59487 return 0;
59488 }
59489 diff --git a/fs/nls/nls_euc-jp.c b/fs/nls/nls_euc-jp.c
59490 index 7424929..35f6be5 100644
59491 --- a/fs/nls/nls_euc-jp.c
59492 +++ b/fs/nls/nls_euc-jp.c
59493 @@ -561,8 +561,10 @@ static int __init init_nls_euc_jp(void)
59494 p_nls = load_nls("cp932");
59495
59496 if (p_nls) {
59497 - table.charset2upper = p_nls->charset2upper;
59498 - table.charset2lower = p_nls->charset2lower;
59499 + pax_open_kernel();
59500 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
59501 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
59502 + pax_close_kernel();
59503 return register_nls(&table);
59504 }
59505
59506 diff --git a/fs/nls/nls_koi8-ru.c b/fs/nls/nls_koi8-ru.c
59507 index e7bc1d7..06bd4bb 100644
59508 --- a/fs/nls/nls_koi8-ru.c
59509 +++ b/fs/nls/nls_koi8-ru.c
59510 @@ -63,8 +63,10 @@ static int __init init_nls_koi8_ru(void)
59511 p_nls = load_nls("koi8-u");
59512
59513 if (p_nls) {
59514 - table.charset2upper = p_nls->charset2upper;
59515 - table.charset2lower = p_nls->charset2lower;
59516 + pax_open_kernel();
59517 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
59518 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
59519 + pax_close_kernel();
59520 return register_nls(&table);
59521 }
59522
59523 diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
59524 index e44cb64..4807084 100644
59525 --- a/fs/notify/fanotify/fanotify_user.c
59526 +++ b/fs/notify/fanotify/fanotify_user.c
59527 @@ -253,8 +253,8 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group,
59528
59529 fd = fanotify_event_metadata.fd;
59530 ret = -EFAULT;
59531 - if (copy_to_user(buf, &fanotify_event_metadata,
59532 - fanotify_event_metadata.event_len))
59533 + if (fanotify_event_metadata.event_len > sizeof fanotify_event_metadata ||
59534 + copy_to_user(buf, &fanotify_event_metadata, fanotify_event_metadata.event_len))
59535 goto out_close_fd;
59536
59537 ret = prepare_for_access_response(group, event, fd);
59538 diff --git a/fs/notify/notification.c b/fs/notify/notification.c
59539 index 7b51b05..5ea5ef6 100644
59540 --- a/fs/notify/notification.c
59541 +++ b/fs/notify/notification.c
59542 @@ -57,7 +57,7 @@ static struct kmem_cache *fsnotify_event_holder_cachep;
59543 * get set to 0 so it will never get 'freed'
59544 */
59545 static struct fsnotify_event *q_overflow_event;
59546 -static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
59547 +static atomic_unchecked_t fsnotify_sync_cookie = ATOMIC_INIT(0);
59548
59549 /**
59550 * fsnotify_get_cookie - return a unique cookie for use in synchronizing events.
59551 @@ -65,7 +65,7 @@ static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
59552 */
59553 u32 fsnotify_get_cookie(void)
59554 {
59555 - return atomic_inc_return(&fsnotify_sync_cookie);
59556 + return atomic_inc_return_unchecked(&fsnotify_sync_cookie);
59557 }
59558 EXPORT_SYMBOL_GPL(fsnotify_get_cookie);
59559
59560 diff --git a/fs/ntfs/dir.c b/fs/ntfs/dir.c
59561 index 9e38daf..5727cae 100644
59562 --- a/fs/ntfs/dir.c
59563 +++ b/fs/ntfs/dir.c
59564 @@ -1310,7 +1310,7 @@ find_next_index_buffer:
59565 ia = (INDEX_ALLOCATION*)(kaddr + (ia_pos & ~PAGE_CACHE_MASK &
59566 ~(s64)(ndir->itype.index.block_size - 1)));
59567 /* Bounds checks. */
59568 - if (unlikely((u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
59569 + if (unlikely(!kaddr || (u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
59570 ntfs_error(sb, "Out of bounds check failed. Corrupt directory "
59571 "inode 0x%lx or driver bug.", vdir->i_ino);
59572 goto err_out;
59573 diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
59574 index ea4ba9d..1e13d34 100644
59575 --- a/fs/ntfs/file.c
59576 +++ b/fs/ntfs/file.c
59577 @@ -1282,7 +1282,7 @@ static inline size_t ntfs_copy_from_user(struct page **pages,
59578 char *addr;
59579 size_t total = 0;
59580 unsigned len;
59581 - int left;
59582 + unsigned left;
59583
59584 do {
59585 len = PAGE_CACHE_SIZE - ofs;
59586 diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c
59587 index 82650d5..db37dcf 100644
59588 --- a/fs/ntfs/super.c
59589 +++ b/fs/ntfs/super.c
59590 @@ -685,7 +685,7 @@ static struct buffer_head *read_ntfs_boot_sector(struct super_block *sb,
59591 if (!silent)
59592 ntfs_error(sb, "Primary boot sector is invalid.");
59593 } else if (!silent)
59594 - ntfs_error(sb, read_err_str, "primary");
59595 + ntfs_error(sb, read_err_str, "%s", "primary");
59596 if (!(NTFS_SB(sb)->on_errors & ON_ERRORS_RECOVER)) {
59597 if (bh_primary)
59598 brelse(bh_primary);
59599 @@ -701,7 +701,7 @@ static struct buffer_head *read_ntfs_boot_sector(struct super_block *sb,
59600 goto hotfix_primary_boot_sector;
59601 brelse(bh_backup);
59602 } else if (!silent)
59603 - ntfs_error(sb, read_err_str, "backup");
59604 + ntfs_error(sb, read_err_str, "%s", "backup");
59605 /* Try to read NT3.51- backup boot sector. */
59606 if ((bh_backup = sb_bread(sb, nr_blocks >> 1))) {
59607 if (is_boot_sector_ntfs(sb, (NTFS_BOOT_SECTOR*)
59608 @@ -712,7 +712,7 @@ static struct buffer_head *read_ntfs_boot_sector(struct super_block *sb,
59609 "sector.");
59610 brelse(bh_backup);
59611 } else if (!silent)
59612 - ntfs_error(sb, read_err_str, "backup");
59613 + ntfs_error(sb, read_err_str, "%s", "backup");
59614 /* We failed. Cleanup and return. */
59615 if (bh_primary)
59616 brelse(bh_primary);
59617 diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
59618 index cd5496b..26a1055 100644
59619 --- a/fs/ocfs2/localalloc.c
59620 +++ b/fs/ocfs2/localalloc.c
59621 @@ -1278,7 +1278,7 @@ static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb,
59622 goto bail;
59623 }
59624
59625 - atomic_inc(&osb->alloc_stats.moves);
59626 + atomic_inc_unchecked(&osb->alloc_stats.moves);
59627
59628 bail:
59629 if (handle)
59630 diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h
59631 index 3a90347..c40bef8 100644
59632 --- a/fs/ocfs2/ocfs2.h
59633 +++ b/fs/ocfs2/ocfs2.h
59634 @@ -235,11 +235,11 @@ enum ocfs2_vol_state
59635
59636 struct ocfs2_alloc_stats
59637 {
59638 - atomic_t moves;
59639 - atomic_t local_data;
59640 - atomic_t bitmap_data;
59641 - atomic_t bg_allocs;
59642 - atomic_t bg_extends;
59643 + atomic_unchecked_t moves;
59644 + atomic_unchecked_t local_data;
59645 + atomic_unchecked_t bitmap_data;
59646 + atomic_unchecked_t bg_allocs;
59647 + atomic_unchecked_t bg_extends;
59648 };
59649
59650 enum ocfs2_local_alloc_state
59651 diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
59652 index 5397c07..54afc55 100644
59653 --- a/fs/ocfs2/suballoc.c
59654 +++ b/fs/ocfs2/suballoc.c
59655 @@ -872,7 +872,7 @@ static int ocfs2_reserve_suballoc_bits(struct ocfs2_super *osb,
59656 mlog_errno(status);
59657 goto bail;
59658 }
59659 - atomic_inc(&osb->alloc_stats.bg_extends);
59660 + atomic_inc_unchecked(&osb->alloc_stats.bg_extends);
59661
59662 /* You should never ask for this much metadata */
59663 BUG_ON(bits_wanted >
59664 @@ -2000,7 +2000,7 @@ int ocfs2_claim_metadata(handle_t *handle,
59665 mlog_errno(status);
59666 goto bail;
59667 }
59668 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
59669 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
59670
59671 *suballoc_loc = res.sr_bg_blkno;
59672 *suballoc_bit_start = res.sr_bit_offset;
59673 @@ -2164,7 +2164,7 @@ int ocfs2_claim_new_inode_at_loc(handle_t *handle,
59674 trace_ocfs2_claim_new_inode_at_loc((unsigned long long)di_blkno,
59675 res->sr_bits);
59676
59677 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
59678 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
59679
59680 BUG_ON(res->sr_bits != 1);
59681
59682 @@ -2206,7 +2206,7 @@ int ocfs2_claim_new_inode(handle_t *handle,
59683 mlog_errno(status);
59684 goto bail;
59685 }
59686 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
59687 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
59688
59689 BUG_ON(res.sr_bits != 1);
59690
59691 @@ -2310,7 +2310,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
59692 cluster_start,
59693 num_clusters);
59694 if (!status)
59695 - atomic_inc(&osb->alloc_stats.local_data);
59696 + atomic_inc_unchecked(&osb->alloc_stats.local_data);
59697 } else {
59698 if (min_clusters > (osb->bitmap_cpg - 1)) {
59699 /* The only paths asking for contiguousness
59700 @@ -2336,7 +2336,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
59701 ocfs2_desc_bitmap_to_cluster_off(ac->ac_inode,
59702 res.sr_bg_blkno,
59703 res.sr_bit_offset);
59704 - atomic_inc(&osb->alloc_stats.bitmap_data);
59705 + atomic_inc_unchecked(&osb->alloc_stats.bitmap_data);
59706 *num_clusters = res.sr_bits;
59707 }
59708 }
59709 diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
59710 index d4e81e4..ad89f5f 100644
59711 --- a/fs/ocfs2/super.c
59712 +++ b/fs/ocfs2/super.c
59713 @@ -300,11 +300,11 @@ static int ocfs2_osb_dump(struct ocfs2_super *osb, char *buf, int len)
59714 "%10s => GlobalAllocs: %d LocalAllocs: %d "
59715 "SubAllocs: %d LAWinMoves: %d SAExtends: %d\n",
59716 "Stats",
59717 - atomic_read(&osb->alloc_stats.bitmap_data),
59718 - atomic_read(&osb->alloc_stats.local_data),
59719 - atomic_read(&osb->alloc_stats.bg_allocs),
59720 - atomic_read(&osb->alloc_stats.moves),
59721 - atomic_read(&osb->alloc_stats.bg_extends));
59722 + atomic_read_unchecked(&osb->alloc_stats.bitmap_data),
59723 + atomic_read_unchecked(&osb->alloc_stats.local_data),
59724 + atomic_read_unchecked(&osb->alloc_stats.bg_allocs),
59725 + atomic_read_unchecked(&osb->alloc_stats.moves),
59726 + atomic_read_unchecked(&osb->alloc_stats.bg_extends));
59727
59728 out += snprintf(buf + out, len - out,
59729 "%10s => State: %u Descriptor: %llu Size: %u bits "
59730 @@ -2121,11 +2121,11 @@ static int ocfs2_initialize_super(struct super_block *sb,
59731 spin_lock_init(&osb->osb_xattr_lock);
59732 ocfs2_init_steal_slots(osb);
59733
59734 - atomic_set(&osb->alloc_stats.moves, 0);
59735 - atomic_set(&osb->alloc_stats.local_data, 0);
59736 - atomic_set(&osb->alloc_stats.bitmap_data, 0);
59737 - atomic_set(&osb->alloc_stats.bg_allocs, 0);
59738 - atomic_set(&osb->alloc_stats.bg_extends, 0);
59739 + atomic_set_unchecked(&osb->alloc_stats.moves, 0);
59740 + atomic_set_unchecked(&osb->alloc_stats.local_data, 0);
59741 + atomic_set_unchecked(&osb->alloc_stats.bitmap_data, 0);
59742 + atomic_set_unchecked(&osb->alloc_stats.bg_allocs, 0);
59743 + atomic_set_unchecked(&osb->alloc_stats.bg_extends, 0);
59744
59745 /* Copy the blockcheck stats from the superblock probe */
59746 osb->osb_ecc_stats = *stats;
59747 diff --git a/fs/open.c b/fs/open.c
59748 index d420331..2dbb3fd 100644
59749 --- a/fs/open.c
59750 +++ b/fs/open.c
59751 @@ -32,6 +32,8 @@
59752 #include <linux/dnotify.h>
59753 #include <linux/compat.h>
59754
59755 +#define CREATE_TRACE_POINTS
59756 +#include <trace/events/fs.h>
59757 #include "internal.h"
59758
59759 int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,
59760 @@ -102,6 +104,8 @@ long vfs_truncate(struct path *path, loff_t length)
59761 error = locks_verify_truncate(inode, NULL, length);
59762 if (!error)
59763 error = security_path_truncate(path);
59764 + if (!error && !gr_acl_handle_truncate(path->dentry, path->mnt))
59765 + error = -EACCES;
59766 if (!error)
59767 error = do_truncate(path->dentry, length, 0, NULL);
59768
59769 @@ -186,6 +190,8 @@ static long do_sys_ftruncate(unsigned int fd, loff_t length, int small)
59770 error = locks_verify_truncate(inode, f.file, length);
59771 if (!error)
59772 error = security_path_truncate(&f.file->f_path);
59773 + if (!error && !gr_acl_handle_truncate(f.file->f_path.dentry, f.file->f_path.mnt))
59774 + error = -EACCES;
59775 if (!error)
59776 error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, f.file);
59777 sb_end_write(inode->i_sb);
59778 @@ -360,6 +366,9 @@ retry:
59779 if (__mnt_is_readonly(path.mnt))
59780 res = -EROFS;
59781
59782 + if (!res && !gr_acl_handle_access(path.dentry, path.mnt, mode))
59783 + res = -EACCES;
59784 +
59785 out_path_release:
59786 path_put(&path);
59787 if (retry_estale(res, lookup_flags)) {
59788 @@ -391,6 +400,8 @@ retry:
59789 if (error)
59790 goto dput_and_out;
59791
59792 + gr_log_chdir(path.dentry, path.mnt);
59793 +
59794 set_fs_pwd(current->fs, &path);
59795
59796 dput_and_out:
59797 @@ -420,6 +431,13 @@ SYSCALL_DEFINE1(fchdir, unsigned int, fd)
59798 goto out_putf;
59799
59800 error = inode_permission(inode, MAY_EXEC | MAY_CHDIR);
59801 +
59802 + if (!error && !gr_chroot_fchdir(f.file->f_path.dentry, f.file->f_path.mnt))
59803 + error = -EPERM;
59804 +
59805 + if (!error)
59806 + gr_log_chdir(f.file->f_path.dentry, f.file->f_path.mnt);
59807 +
59808 if (!error)
59809 set_fs_pwd(current->fs, &f.file->f_path);
59810 out_putf:
59811 @@ -449,7 +467,13 @@ retry:
59812 if (error)
59813 goto dput_and_out;
59814
59815 + if (gr_handle_chroot_chroot(path.dentry, path.mnt))
59816 + goto dput_and_out;
59817 +
59818 set_fs_root(current->fs, &path);
59819 +
59820 + gr_handle_chroot_chdir(&path);
59821 +
59822 error = 0;
59823 dput_and_out:
59824 path_put(&path);
59825 @@ -471,6 +495,16 @@ static int chmod_common(struct path *path, umode_t mode)
59826 if (error)
59827 return error;
59828 mutex_lock(&inode->i_mutex);
59829 +
59830 + if (!gr_acl_handle_chmod(path->dentry, path->mnt, &mode)) {
59831 + error = -EACCES;
59832 + goto out_unlock;
59833 + }
59834 + if (gr_handle_chroot_chmod(path->dentry, path->mnt, mode)) {
59835 + error = -EACCES;
59836 + goto out_unlock;
59837 + }
59838 +
59839 error = security_path_chmod(path, mode);
59840 if (error)
59841 goto out_unlock;
59842 @@ -530,6 +564,9 @@ static int chown_common(struct path *path, uid_t user, gid_t group)
59843 uid = make_kuid(current_user_ns(), user);
59844 gid = make_kgid(current_user_ns(), group);
59845
59846 + if (!gr_acl_handle_chown(path->dentry, path->mnt))
59847 + return -EACCES;
59848 +
59849 newattrs.ia_valid = ATTR_CTIME;
59850 if (user != (uid_t) -1) {
59851 if (!uid_valid(uid))
59852 @@ -974,6 +1011,7 @@ long do_sys_open(int dfd, const char __user *filename, int flags, umode_t mode)
59853 } else {
59854 fsnotify_open(f);
59855 fd_install(fd, f);
59856 + trace_do_sys_open(tmp->name, flags, mode);
59857 }
59858 }
59859 putname(tmp);
59860 diff --git a/fs/pipe.c b/fs/pipe.c
59861 index 0e0752e..7cfdd50 100644
59862 --- a/fs/pipe.c
59863 +++ b/fs/pipe.c
59864 @@ -56,7 +56,7 @@ unsigned int pipe_min_size = PAGE_SIZE;
59865
59866 static void pipe_lock_nested(struct pipe_inode_info *pipe, int subclass)
59867 {
59868 - if (pipe->files)
59869 + if (atomic_read(&pipe->files))
59870 mutex_lock_nested(&pipe->mutex, subclass);
59871 }
59872
59873 @@ -71,7 +71,7 @@ EXPORT_SYMBOL(pipe_lock);
59874
59875 void pipe_unlock(struct pipe_inode_info *pipe)
59876 {
59877 - if (pipe->files)
59878 + if (atomic_read(&pipe->files))
59879 mutex_unlock(&pipe->mutex);
59880 }
59881 EXPORT_SYMBOL(pipe_unlock);
59882 @@ -449,9 +449,9 @@ redo:
59883 }
59884 if (bufs) /* More to do? */
59885 continue;
59886 - if (!pipe->writers)
59887 + if (!atomic_read(&pipe->writers))
59888 break;
59889 - if (!pipe->waiting_writers) {
59890 + if (!atomic_read(&pipe->waiting_writers)) {
59891 /* syscall merging: Usually we must not sleep
59892 * if O_NONBLOCK is set, or if we got some data.
59893 * But if a writer sleeps in kernel space, then
59894 @@ -513,7 +513,7 @@ pipe_write(struct kiocb *iocb, const struct iovec *_iov,
59895 ret = 0;
59896 __pipe_lock(pipe);
59897
59898 - if (!pipe->readers) {
59899 + if (!atomic_read(&pipe->readers)) {
59900 send_sig(SIGPIPE, current, 0);
59901 ret = -EPIPE;
59902 goto out;
59903 @@ -562,7 +562,7 @@ redo1:
59904 for (;;) {
59905 int bufs;
59906
59907 - if (!pipe->readers) {
59908 + if (!atomic_read(&pipe->readers)) {
59909 send_sig(SIGPIPE, current, 0);
59910 if (!ret)
59911 ret = -EPIPE;
59912 @@ -653,9 +653,9 @@ redo2:
59913 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
59914 do_wakeup = 0;
59915 }
59916 - pipe->waiting_writers++;
59917 + atomic_inc(&pipe->waiting_writers);
59918 pipe_wait(pipe);
59919 - pipe->waiting_writers--;
59920 + atomic_dec(&pipe->waiting_writers);
59921 }
59922 out:
59923 __pipe_unlock(pipe);
59924 @@ -709,7 +709,7 @@ pipe_poll(struct file *filp, poll_table *wait)
59925 mask = 0;
59926 if (filp->f_mode & FMODE_READ) {
59927 mask = (nrbufs > 0) ? POLLIN | POLLRDNORM : 0;
59928 - if (!pipe->writers && filp->f_version != pipe->w_counter)
59929 + if (!atomic_read(&pipe->writers) && filp->f_version != pipe->w_counter)
59930 mask |= POLLHUP;
59931 }
59932
59933 @@ -719,7 +719,7 @@ pipe_poll(struct file *filp, poll_table *wait)
59934 * Most Unices do not set POLLERR for FIFOs but on Linux they
59935 * behave exactly like pipes for poll().
59936 */
59937 - if (!pipe->readers)
59938 + if (!atomic_read(&pipe->readers))
59939 mask |= POLLERR;
59940 }
59941
59942 @@ -731,7 +731,7 @@ static void put_pipe_info(struct inode *inode, struct pipe_inode_info *pipe)
59943 int kill = 0;
59944
59945 spin_lock(&inode->i_lock);
59946 - if (!--pipe->files) {
59947 + if (atomic_dec_and_test(&pipe->files)) {
59948 inode->i_pipe = NULL;
59949 kill = 1;
59950 }
59951 @@ -748,11 +748,11 @@ pipe_release(struct inode *inode, struct file *file)
59952
59953 __pipe_lock(pipe);
59954 if (file->f_mode & FMODE_READ)
59955 - pipe->readers--;
59956 + atomic_dec(&pipe->readers);
59957 if (file->f_mode & FMODE_WRITE)
59958 - pipe->writers--;
59959 + atomic_dec(&pipe->writers);
59960
59961 - if (pipe->readers || pipe->writers) {
59962 + if (atomic_read(&pipe->readers) || atomic_read(&pipe->writers)) {
59963 wake_up_interruptible_sync_poll(&pipe->wait, POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM | POLLERR | POLLHUP);
59964 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
59965 kill_fasync(&pipe->fasync_writers, SIGIO, POLL_OUT);
59966 @@ -817,7 +817,7 @@ void free_pipe_info(struct pipe_inode_info *pipe)
59967 kfree(pipe);
59968 }
59969
59970 -static struct vfsmount *pipe_mnt __read_mostly;
59971 +struct vfsmount *pipe_mnt __read_mostly;
59972
59973 /*
59974 * pipefs_dname() is called from d_path().
59975 @@ -847,8 +847,9 @@ static struct inode * get_pipe_inode(void)
59976 goto fail_iput;
59977
59978 inode->i_pipe = pipe;
59979 - pipe->files = 2;
59980 - pipe->readers = pipe->writers = 1;
59981 + atomic_set(&pipe->files, 2);
59982 + atomic_set(&pipe->readers, 1);
59983 + atomic_set(&pipe->writers, 1);
59984 inode->i_fop = &pipefifo_fops;
59985
59986 /*
59987 @@ -1027,17 +1028,17 @@ static int fifo_open(struct inode *inode, struct file *filp)
59988 spin_lock(&inode->i_lock);
59989 if (inode->i_pipe) {
59990 pipe = inode->i_pipe;
59991 - pipe->files++;
59992 + atomic_inc(&pipe->files);
59993 spin_unlock(&inode->i_lock);
59994 } else {
59995 spin_unlock(&inode->i_lock);
59996 pipe = alloc_pipe_info();
59997 if (!pipe)
59998 return -ENOMEM;
59999 - pipe->files = 1;
60000 + atomic_set(&pipe->files, 1);
60001 spin_lock(&inode->i_lock);
60002 if (unlikely(inode->i_pipe)) {
60003 - inode->i_pipe->files++;
60004 + atomic_inc(&inode->i_pipe->files);
60005 spin_unlock(&inode->i_lock);
60006 free_pipe_info(pipe);
60007 pipe = inode->i_pipe;
60008 @@ -1062,10 +1063,10 @@ static int fifo_open(struct inode *inode, struct file *filp)
60009 * opened, even when there is no process writing the FIFO.
60010 */
60011 pipe->r_counter++;
60012 - if (pipe->readers++ == 0)
60013 + if (atomic_inc_return(&pipe->readers) == 1)
60014 wake_up_partner(pipe);
60015
60016 - if (!is_pipe && !pipe->writers) {
60017 + if (!is_pipe && !atomic_read(&pipe->writers)) {
60018 if ((filp->f_flags & O_NONBLOCK)) {
60019 /* suppress POLLHUP until we have
60020 * seen a writer */
60021 @@ -1084,14 +1085,14 @@ static int fifo_open(struct inode *inode, struct file *filp)
60022 * errno=ENXIO when there is no process reading the FIFO.
60023 */
60024 ret = -ENXIO;
60025 - if (!is_pipe && (filp->f_flags & O_NONBLOCK) && !pipe->readers)
60026 + if (!is_pipe && (filp->f_flags & O_NONBLOCK) && !atomic_read(&pipe->readers))
60027 goto err;
60028
60029 pipe->w_counter++;
60030 - if (!pipe->writers++)
60031 + if (atomic_inc_return(&pipe->writers) == 1)
60032 wake_up_partner(pipe);
60033
60034 - if (!is_pipe && !pipe->readers) {
60035 + if (!is_pipe && !atomic_read(&pipe->readers)) {
60036 if (wait_for_partner(pipe, &pipe->r_counter))
60037 goto err_wr;
60038 }
60039 @@ -1105,11 +1106,11 @@ static int fifo_open(struct inode *inode, struct file *filp)
60040 * the process can at least talk to itself.
60041 */
60042
60043 - pipe->readers++;
60044 - pipe->writers++;
60045 + atomic_inc(&pipe->readers);
60046 + atomic_inc(&pipe->writers);
60047 pipe->r_counter++;
60048 pipe->w_counter++;
60049 - if (pipe->readers == 1 || pipe->writers == 1)
60050 + if (atomic_read(&pipe->readers) == 1 || atomic_read(&pipe->writers) == 1)
60051 wake_up_partner(pipe);
60052 break;
60053
60054 @@ -1123,13 +1124,13 @@ static int fifo_open(struct inode *inode, struct file *filp)
60055 return 0;
60056
60057 err_rd:
60058 - if (!--pipe->readers)
60059 + if (atomic_dec_and_test(&pipe->readers))
60060 wake_up_interruptible(&pipe->wait);
60061 ret = -ERESTARTSYS;
60062 goto err;
60063
60064 err_wr:
60065 - if (!--pipe->writers)
60066 + if (atomic_dec_and_test(&pipe->writers))
60067 wake_up_interruptible(&pipe->wait);
60068 ret = -ERESTARTSYS;
60069 goto err;
60070 diff --git a/fs/proc/Kconfig b/fs/proc/Kconfig
60071 index 15af622..0e9f4467 100644
60072 --- a/fs/proc/Kconfig
60073 +++ b/fs/proc/Kconfig
60074 @@ -30,12 +30,12 @@ config PROC_FS
60075
60076 config PROC_KCORE
60077 bool "/proc/kcore support" if !ARM
60078 - depends on PROC_FS && MMU
60079 + depends on PROC_FS && MMU && !GRKERNSEC_PROC_ADD
60080
60081 config PROC_VMCORE
60082 bool "/proc/vmcore support"
60083 - depends on PROC_FS && CRASH_DUMP
60084 - default y
60085 + depends on PROC_FS && CRASH_DUMP && !GRKERNSEC
60086 + default n
60087 help
60088 Exports the dump image of crashed kernel in ELF format.
60089
60090 @@ -59,8 +59,8 @@ config PROC_SYSCTL
60091 limited in memory.
60092
60093 config PROC_PAGE_MONITOR
60094 - default y
60095 - depends on PROC_FS && MMU
60096 + default n
60097 + depends on PROC_FS && MMU && !GRKERNSEC
60098 bool "Enable /proc page monitoring" if EXPERT
60099 help
60100 Various /proc files exist to monitor process memory utilization:
60101 diff --git a/fs/proc/array.c b/fs/proc/array.c
60102 index cbd0f1b..adec3f0 100644
60103 --- a/fs/proc/array.c
60104 +++ b/fs/proc/array.c
60105 @@ -60,6 +60,7 @@
60106 #include <linux/tty.h>
60107 #include <linux/string.h>
60108 #include <linux/mman.h>
60109 +#include <linux/grsecurity.h>
60110 #include <linux/proc_fs.h>
60111 #include <linux/ioport.h>
60112 #include <linux/uaccess.h>
60113 @@ -363,6 +364,21 @@ static void task_cpus_allowed(struct seq_file *m, struct task_struct *task)
60114 seq_putc(m, '\n');
60115 }
60116
60117 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
60118 +static inline void task_pax(struct seq_file *m, struct task_struct *p)
60119 +{
60120 + if (p->mm)
60121 + seq_printf(m, "PaX:\t%c%c%c%c%c\n",
60122 + p->mm->pax_flags & MF_PAX_PAGEEXEC ? 'P' : 'p',
60123 + p->mm->pax_flags & MF_PAX_EMUTRAMP ? 'E' : 'e',
60124 + p->mm->pax_flags & MF_PAX_MPROTECT ? 'M' : 'm',
60125 + p->mm->pax_flags & MF_PAX_RANDMMAP ? 'R' : 'r',
60126 + p->mm->pax_flags & MF_PAX_SEGMEXEC ? 'S' : 's');
60127 + else
60128 + seq_printf(m, "PaX:\t-----\n");
60129 +}
60130 +#endif
60131 +
60132 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
60133 struct pid *pid, struct task_struct *task)
60134 {
60135 @@ -381,9 +397,24 @@ int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
60136 task_cpus_allowed(m, task);
60137 cpuset_task_status_allowed(m, task);
60138 task_context_switch_counts(m, task);
60139 +
60140 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
60141 + task_pax(m, task);
60142 +#endif
60143 +
60144 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
60145 + task_grsec_rbac(m, task);
60146 +#endif
60147 +
60148 return 0;
60149 }
60150
60151 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60152 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
60153 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
60154 + _mm->pax_flags & MF_PAX_SEGMEXEC))
60155 +#endif
60156 +
60157 static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
60158 struct pid *pid, struct task_struct *task, int whole)
60159 {
60160 @@ -405,6 +436,13 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
60161 char tcomm[sizeof(task->comm)];
60162 unsigned long flags;
60163
60164 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60165 + if (current->exec_id != m->exec_id) {
60166 + gr_log_badprocpid("stat");
60167 + return 0;
60168 + }
60169 +#endif
60170 +
60171 state = *get_task_state(task);
60172 vsize = eip = esp = 0;
60173 permitted = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
60174 @@ -476,6 +514,19 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
60175 gtime = task_gtime(task);
60176 }
60177
60178 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60179 + if (PAX_RAND_FLAGS(mm)) {
60180 + eip = 0;
60181 + esp = 0;
60182 + wchan = 0;
60183 + }
60184 +#endif
60185 +#ifdef CONFIG_GRKERNSEC_HIDESYM
60186 + wchan = 0;
60187 + eip =0;
60188 + esp =0;
60189 +#endif
60190 +
60191 /* scale priority and nice values from timeslices to -20..20 */
60192 /* to make it look like a "normal" Unix priority/nice value */
60193 priority = task_prio(task);
60194 @@ -512,9 +563,15 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
60195 seq_put_decimal_ull(m, ' ', vsize);
60196 seq_put_decimal_ull(m, ' ', mm ? get_mm_rss(mm) : 0);
60197 seq_put_decimal_ull(m, ' ', rsslim);
60198 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60199 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->start_code : 1) : 0));
60200 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->end_code : 1) : 0));
60201 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 0 : ((permitted && mm) ? mm->start_stack : 0));
60202 +#else
60203 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->start_code : 1) : 0);
60204 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->end_code : 1) : 0);
60205 seq_put_decimal_ull(m, ' ', (permitted && mm) ? mm->start_stack : 0);
60206 +#endif
60207 seq_put_decimal_ull(m, ' ', esp);
60208 seq_put_decimal_ull(m, ' ', eip);
60209 /* The signal information here is obsolete.
60210 @@ -536,7 +593,11 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
60211 seq_put_decimal_ull(m, ' ', cputime_to_clock_t(gtime));
60212 seq_put_decimal_ll(m, ' ', cputime_to_clock_t(cgtime));
60213
60214 - if (mm && permitted) {
60215 + if (mm && permitted
60216 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60217 + && !PAX_RAND_FLAGS(mm)
60218 +#endif
60219 + ) {
60220 seq_put_decimal_ull(m, ' ', mm->start_data);
60221 seq_put_decimal_ull(m, ' ', mm->end_data);
60222 seq_put_decimal_ull(m, ' ', mm->start_brk);
60223 @@ -574,8 +635,15 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
60224 struct pid *pid, struct task_struct *task)
60225 {
60226 unsigned long size = 0, resident = 0, shared = 0, text = 0, data = 0;
60227 - struct mm_struct *mm = get_task_mm(task);
60228 + struct mm_struct *mm;
60229
60230 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60231 + if (current->exec_id != m->exec_id) {
60232 + gr_log_badprocpid("statm");
60233 + return 0;
60234 + }
60235 +#endif
60236 + mm = get_task_mm(task);
60237 if (mm) {
60238 size = task_statm(mm, &shared, &text, &data, &resident);
60239 mmput(mm);
60240 @@ -598,6 +666,13 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
60241 return 0;
60242 }
60243
60244 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
60245 +int proc_pid_ipaddr(struct task_struct *task, char *buffer)
60246 +{
60247 + return sprintf(buffer, "%pI4\n", &task->signal->curr_ip);
60248 +}
60249 +#endif
60250 +
60251 #ifdef CONFIG_CHECKPOINT_RESTORE
60252 static struct pid *
60253 get_children_pid(struct inode *inode, struct pid *pid_prev, loff_t pos)
60254 diff --git a/fs/proc/base.c b/fs/proc/base.c
60255 index 1485e38..8ad4236 100644
60256 --- a/fs/proc/base.c
60257 +++ b/fs/proc/base.c
60258 @@ -113,6 +113,14 @@ struct pid_entry {
60259 union proc_op op;
60260 };
60261
60262 +struct getdents_callback {
60263 + struct linux_dirent __user * current_dir;
60264 + struct linux_dirent __user * previous;
60265 + struct file * file;
60266 + int count;
60267 + int error;
60268 +};
60269 +
60270 #define NOD(NAME, MODE, IOP, FOP, OP) { \
60271 .name = (NAME), \
60272 .len = sizeof(NAME) - 1, \
60273 @@ -210,6 +218,9 @@ static int proc_pid_cmdline(struct task_struct *task, char * buffer)
60274 if (!mm->arg_end)
60275 goto out_mm; /* Shh! No looking before we're done */
60276
60277 + if (gr_acl_handle_procpidmem(task))
60278 + goto out_mm;
60279 +
60280 len = mm->arg_end - mm->arg_start;
60281
60282 if (len > PAGE_SIZE)
60283 @@ -237,12 +248,28 @@ out:
60284 return res;
60285 }
60286
60287 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60288 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
60289 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
60290 + _mm->pax_flags & MF_PAX_SEGMEXEC))
60291 +#endif
60292 +
60293 static int proc_pid_auxv(struct task_struct *task, char *buffer)
60294 {
60295 struct mm_struct *mm = mm_access(task, PTRACE_MODE_READ);
60296 int res = PTR_ERR(mm);
60297 if (mm && !IS_ERR(mm)) {
60298 unsigned int nwords = 0;
60299 +
60300 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60301 + /* allow if we're currently ptracing this task */
60302 + if (PAX_RAND_FLAGS(mm) &&
60303 + (!(task->ptrace & PT_PTRACED) || (task->parent != current))) {
60304 + mmput(mm);
60305 + return 0;
60306 + }
60307 +#endif
60308 +
60309 do {
60310 nwords += 2;
60311 } while (mm->saved_auxv[nwords - 2] != 0); /* AT_NULL */
60312 @@ -256,7 +283,7 @@ static int proc_pid_auxv(struct task_struct *task, char *buffer)
60313 }
60314
60315
60316 -#ifdef CONFIG_KALLSYMS
60317 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
60318 /*
60319 * Provides a wchan file via kallsyms in a proper one-value-per-file format.
60320 * Returns the resolved symbol. If that fails, simply return the address.
60321 @@ -295,7 +322,7 @@ static void unlock_trace(struct task_struct *task)
60322 mutex_unlock(&task->signal->cred_guard_mutex);
60323 }
60324
60325 -#ifdef CONFIG_STACKTRACE
60326 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
60327
60328 #define MAX_STACK_TRACE_DEPTH 64
60329
60330 @@ -518,7 +545,7 @@ static int proc_pid_limits(struct task_struct *task, char *buffer)
60331 return count;
60332 }
60333
60334 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
60335 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
60336 static int proc_pid_syscall(struct task_struct *task, char *buffer)
60337 {
60338 long nr;
60339 @@ -547,7 +574,7 @@ static int proc_pid_syscall(struct task_struct *task, char *buffer)
60340 /************************************************************************/
60341
60342 /* permission checks */
60343 -static int proc_fd_access_allowed(struct inode *inode)
60344 +static int proc_fd_access_allowed(struct inode *inode, unsigned int log)
60345 {
60346 struct task_struct *task;
60347 int allowed = 0;
60348 @@ -557,7 +584,10 @@ static int proc_fd_access_allowed(struct inode *inode)
60349 */
60350 task = get_proc_task(inode);
60351 if (task) {
60352 - allowed = ptrace_may_access(task, PTRACE_MODE_READ);
60353 + if (log)
60354 + allowed = ptrace_may_access(task, PTRACE_MODE_READ);
60355 + else
60356 + allowed = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
60357 put_task_struct(task);
60358 }
60359 return allowed;
60360 @@ -588,10 +618,35 @@ static bool has_pid_permissions(struct pid_namespace *pid,
60361 struct task_struct *task,
60362 int hide_pid_min)
60363 {
60364 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
60365 + return false;
60366 +
60367 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
60368 + rcu_read_lock();
60369 + {
60370 + const struct cred *tmpcred = current_cred();
60371 + const struct cred *cred = __task_cred(task);
60372 +
60373 + if (uid_eq(tmpcred->uid, GLOBAL_ROOT_UID) || uid_eq(tmpcred->uid, cred->uid)
60374 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
60375 + || in_group_p(grsec_proc_gid)
60376 +#endif
60377 + ) {
60378 + rcu_read_unlock();
60379 + return true;
60380 + }
60381 + }
60382 + rcu_read_unlock();
60383 +
60384 + if (!pid->hide_pid)
60385 + return false;
60386 +#endif
60387 +
60388 if (pid->hide_pid < hide_pid_min)
60389 return true;
60390 if (in_group_p(pid->pid_gid))
60391 return true;
60392 +
60393 return ptrace_may_access(task, PTRACE_MODE_READ);
60394 }
60395
60396 @@ -609,7 +664,11 @@ static int proc_pid_permission(struct inode *inode, int mask)
60397 put_task_struct(task);
60398
60399 if (!has_perms) {
60400 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
60401 + {
60402 +#else
60403 if (pid->hide_pid == 2) {
60404 +#endif
60405 /*
60406 * Let's make getdents(), stat(), and open()
60407 * consistent with each other. If a process
60408 @@ -707,6 +766,11 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
60409 if (!task)
60410 return -ESRCH;
60411
60412 + if (gr_acl_handle_procpidmem(task)) {
60413 + put_task_struct(task);
60414 + return -EPERM;
60415 + }
60416 +
60417 mm = mm_access(task, mode);
60418 put_task_struct(task);
60419
60420 @@ -722,6 +786,10 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
60421
60422 file->private_data = mm;
60423
60424 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60425 + file->f_version = current->exec_id;
60426 +#endif
60427 +
60428 return 0;
60429 }
60430
60431 @@ -743,6 +811,17 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
60432 ssize_t copied;
60433 char *page;
60434
60435 +#ifdef CONFIG_GRKERNSEC
60436 + if (write)
60437 + return -EPERM;
60438 +#endif
60439 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60440 + if (file->f_version != current->exec_id) {
60441 + gr_log_badprocpid("mem");
60442 + return 0;
60443 + }
60444 +#endif
60445 +
60446 if (!mm)
60447 return 0;
60448
60449 @@ -755,7 +834,7 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
60450 goto free;
60451
60452 while (count > 0) {
60453 - int this_len = min_t(int, count, PAGE_SIZE);
60454 + ssize_t this_len = min_t(ssize_t, count, PAGE_SIZE);
60455
60456 if (write && copy_from_user(page, buf, this_len)) {
60457 copied = -EFAULT;
60458 @@ -847,6 +926,13 @@ static ssize_t environ_read(struct file *file, char __user *buf,
60459 if (!mm)
60460 return 0;
60461
60462 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60463 + if (file->f_version != current->exec_id) {
60464 + gr_log_badprocpid("environ");
60465 + return 0;
60466 + }
60467 +#endif
60468 +
60469 page = (char *)__get_free_page(GFP_TEMPORARY);
60470 if (!page)
60471 return -ENOMEM;
60472 @@ -856,7 +942,7 @@ static ssize_t environ_read(struct file *file, char __user *buf,
60473 goto free;
60474 while (count > 0) {
60475 size_t this_len, max_len;
60476 - int retval;
60477 + ssize_t retval;
60478
60479 if (src >= (mm->env_end - mm->env_start))
60480 break;
60481 @@ -1461,7 +1547,7 @@ static void *proc_pid_follow_link(struct dentry *dentry, struct nameidata *nd)
60482 int error = -EACCES;
60483
60484 /* Are we allowed to snoop on the tasks file descriptors? */
60485 - if (!proc_fd_access_allowed(inode))
60486 + if (!proc_fd_access_allowed(inode, 0))
60487 goto out;
60488
60489 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
60490 @@ -1505,8 +1591,18 @@ static int proc_pid_readlink(struct dentry * dentry, char __user * buffer, int b
60491 struct path path;
60492
60493 /* Are we allowed to snoop on the tasks file descriptors? */
60494 - if (!proc_fd_access_allowed(inode))
60495 - goto out;
60496 + /* logging this is needed for learning on chromium to work properly,
60497 + but we don't want to flood the logs from 'ps' which does a readlink
60498 + on /proc/fd/2 of tasks in the listing, nor do we want 'ps' to learn
60499 + CAP_SYS_PTRACE as it's not necessary for its basic functionality
60500 + */
60501 + if (dentry->d_name.name[0] == '2' && dentry->d_name.name[1] == '\0') {
60502 + if (!proc_fd_access_allowed(inode,0))
60503 + goto out;
60504 + } else {
60505 + if (!proc_fd_access_allowed(inode,1))
60506 + goto out;
60507 + }
60508
60509 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
60510 if (error)
60511 @@ -1556,7 +1652,11 @@ struct inode *proc_pid_make_inode(struct super_block * sb, struct task_struct *t
60512 rcu_read_lock();
60513 cred = __task_cred(task);
60514 inode->i_uid = cred->euid;
60515 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
60516 + inode->i_gid = grsec_proc_gid;
60517 +#else
60518 inode->i_gid = cred->egid;
60519 +#endif
60520 rcu_read_unlock();
60521 }
60522 security_task_to_inode(task, inode);
60523 @@ -1592,10 +1692,19 @@ int pid_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
60524 return -ENOENT;
60525 }
60526 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
60527 +#ifdef CONFIG_GRKERNSEC_PROC_USER
60528 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
60529 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
60530 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
60531 +#endif
60532 task_dumpable(task)) {
60533 cred = __task_cred(task);
60534 stat->uid = cred->euid;
60535 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
60536 + stat->gid = grsec_proc_gid;
60537 +#else
60538 stat->gid = cred->egid;
60539 +#endif
60540 }
60541 }
60542 rcu_read_unlock();
60543 @@ -1633,11 +1742,20 @@ int pid_revalidate(struct dentry *dentry, unsigned int flags)
60544
60545 if (task) {
60546 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
60547 +#ifdef CONFIG_GRKERNSEC_PROC_USER
60548 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
60549 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
60550 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
60551 +#endif
60552 task_dumpable(task)) {
60553 rcu_read_lock();
60554 cred = __task_cred(task);
60555 inode->i_uid = cred->euid;
60556 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
60557 + inode->i_gid = grsec_proc_gid;
60558 +#else
60559 inode->i_gid = cred->egid;
60560 +#endif
60561 rcu_read_unlock();
60562 } else {
60563 inode->i_uid = GLOBAL_ROOT_UID;
60564 @@ -2166,6 +2284,9 @@ static struct dentry *proc_pident_lookup(struct inode *dir,
60565 if (!task)
60566 goto out_no_task;
60567
60568 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
60569 + goto out;
60570 +
60571 /*
60572 * Yes, it does not scale. And it should not. Don't add
60573 * new entries into /proc/<tgid>/ without very good reasons.
60574 @@ -2196,6 +2317,9 @@ static int proc_pident_readdir(struct file *file, struct dir_context *ctx,
60575 if (!task)
60576 return -ENOENT;
60577
60578 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
60579 + goto out;
60580 +
60581 if (!dir_emit_dots(file, ctx))
60582 goto out;
60583
60584 @@ -2585,7 +2709,7 @@ static const struct pid_entry tgid_base_stuff[] = {
60585 REG("autogroup", S_IRUGO|S_IWUSR, proc_pid_sched_autogroup_operations),
60586 #endif
60587 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
60588 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
60589 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
60590 INF("syscall", S_IRUGO, proc_pid_syscall),
60591 #endif
60592 INF("cmdline", S_IRUGO, proc_pid_cmdline),
60593 @@ -2610,10 +2734,10 @@ static const struct pid_entry tgid_base_stuff[] = {
60594 #ifdef CONFIG_SECURITY
60595 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
60596 #endif
60597 -#ifdef CONFIG_KALLSYMS
60598 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
60599 INF("wchan", S_IRUGO, proc_pid_wchan),
60600 #endif
60601 -#ifdef CONFIG_STACKTRACE
60602 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
60603 ONE("stack", S_IRUGO, proc_pid_stack),
60604 #endif
60605 #ifdef CONFIG_SCHEDSTATS
60606 @@ -2647,6 +2771,9 @@ static const struct pid_entry tgid_base_stuff[] = {
60607 #ifdef CONFIG_HARDWALL
60608 INF("hardwall", S_IRUGO, proc_pid_hardwall),
60609 #endif
60610 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
60611 + INF("ipaddr", S_IRUSR, proc_pid_ipaddr),
60612 +#endif
60613 #ifdef CONFIG_USER_NS
60614 REG("uid_map", S_IRUGO|S_IWUSR, proc_uid_map_operations),
60615 REG("gid_map", S_IRUGO|S_IWUSR, proc_gid_map_operations),
60616 @@ -2777,7 +2904,14 @@ static int proc_pid_instantiate(struct inode *dir,
60617 if (!inode)
60618 goto out;
60619
60620 +#ifdef CONFIG_GRKERNSEC_PROC_USER
60621 + inode->i_mode = S_IFDIR|S_IRUSR|S_IXUSR;
60622 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
60623 + inode->i_gid = grsec_proc_gid;
60624 + inode->i_mode = S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP;
60625 +#else
60626 inode->i_mode = S_IFDIR|S_IRUGO|S_IXUGO;
60627 +#endif
60628 inode->i_op = &proc_tgid_base_inode_operations;
60629 inode->i_fop = &proc_tgid_base_operations;
60630 inode->i_flags|=S_IMMUTABLE;
60631 @@ -2815,7 +2949,11 @@ struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry, unsign
60632 if (!task)
60633 goto out;
60634
60635 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
60636 + goto out_put_task;
60637 +
60638 result = proc_pid_instantiate(dir, dentry, task, NULL);
60639 +out_put_task:
60640 put_task_struct(task);
60641 out:
60642 return ERR_PTR(result);
60643 @@ -2921,7 +3059,7 @@ static const struct pid_entry tid_base_stuff[] = {
60644 REG("sched", S_IRUGO|S_IWUSR, proc_pid_sched_operations),
60645 #endif
60646 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
60647 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
60648 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
60649 INF("syscall", S_IRUGO, proc_pid_syscall),
60650 #endif
60651 INF("cmdline", S_IRUGO, proc_pid_cmdline),
60652 @@ -2948,10 +3086,10 @@ static const struct pid_entry tid_base_stuff[] = {
60653 #ifdef CONFIG_SECURITY
60654 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
60655 #endif
60656 -#ifdef CONFIG_KALLSYMS
60657 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
60658 INF("wchan", S_IRUGO, proc_pid_wchan),
60659 #endif
60660 -#ifdef CONFIG_STACKTRACE
60661 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
60662 ONE("stack", S_IRUGO, proc_pid_stack),
60663 #endif
60664 #ifdef CONFIG_SCHEDSTATS
60665 diff --git a/fs/proc/cmdline.c b/fs/proc/cmdline.c
60666 index 82676e3..5f8518a 100644
60667 --- a/fs/proc/cmdline.c
60668 +++ b/fs/proc/cmdline.c
60669 @@ -23,7 +23,11 @@ static const struct file_operations cmdline_proc_fops = {
60670
60671 static int __init proc_cmdline_init(void)
60672 {
60673 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
60674 + proc_create_grsec("cmdline", 0, NULL, &cmdline_proc_fops);
60675 +#else
60676 proc_create("cmdline", 0, NULL, &cmdline_proc_fops);
60677 +#endif
60678 return 0;
60679 }
60680 module_init(proc_cmdline_init);
60681 diff --git a/fs/proc/devices.c b/fs/proc/devices.c
60682 index b143471..bb105e5 100644
60683 --- a/fs/proc/devices.c
60684 +++ b/fs/proc/devices.c
60685 @@ -64,7 +64,11 @@ static const struct file_operations proc_devinfo_operations = {
60686
60687 static int __init proc_devices_init(void)
60688 {
60689 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
60690 + proc_create_grsec("devices", 0, NULL, &proc_devinfo_operations);
60691 +#else
60692 proc_create("devices", 0, NULL, &proc_devinfo_operations);
60693 +#endif
60694 return 0;
60695 }
60696 module_init(proc_devices_init);
60697 diff --git a/fs/proc/fd.c b/fs/proc/fd.c
60698 index 985ea88..d118a0a 100644
60699 --- a/fs/proc/fd.c
60700 +++ b/fs/proc/fd.c
60701 @@ -25,7 +25,8 @@ static int seq_show(struct seq_file *m, void *v)
60702 if (!task)
60703 return -ENOENT;
60704
60705 - files = get_files_struct(task);
60706 + if (!gr_acl_handle_procpidmem(task))
60707 + files = get_files_struct(task);
60708 put_task_struct(task);
60709
60710 if (files) {
60711 @@ -283,11 +284,21 @@ static struct dentry *proc_lookupfd(struct inode *dir, struct dentry *dentry,
60712 */
60713 int proc_fd_permission(struct inode *inode, int mask)
60714 {
60715 + struct task_struct *task;
60716 int rv = generic_permission(inode, mask);
60717 - if (rv == 0)
60718 - return 0;
60719 +
60720 if (task_tgid(current) == proc_pid(inode))
60721 rv = 0;
60722 +
60723 + task = get_proc_task(inode);
60724 + if (task == NULL)
60725 + return rv;
60726 +
60727 + if (gr_acl_handle_procpidmem(task))
60728 + rv = -EACCES;
60729 +
60730 + put_task_struct(task);
60731 +
60732 return rv;
60733 }
60734
60735 diff --git a/fs/proc/inode.c b/fs/proc/inode.c
60736 index 8eaa1ba..cc6ff42 100644
60737 --- a/fs/proc/inode.c
60738 +++ b/fs/proc/inode.c
60739 @@ -23,11 +23,17 @@
60740 #include <linux/slab.h>
60741 #include <linux/mount.h>
60742 #include <linux/magic.h>
60743 +#include <linux/grsecurity.h>
60744
60745 #include <asm/uaccess.h>
60746
60747 #include "internal.h"
60748
60749 +#ifdef CONFIG_PROC_SYSCTL
60750 +extern const struct inode_operations proc_sys_inode_operations;
60751 +extern const struct inode_operations proc_sys_dir_operations;
60752 +#endif
60753 +
60754 static void proc_evict_inode(struct inode *inode)
60755 {
60756 struct proc_dir_entry *de;
60757 @@ -55,6 +61,13 @@ static void proc_evict_inode(struct inode *inode)
60758 ns = PROC_I(inode)->ns.ns;
60759 if (ns_ops && ns)
60760 ns_ops->put(ns);
60761 +
60762 +#ifdef CONFIG_PROC_SYSCTL
60763 + if (inode->i_op == &proc_sys_inode_operations ||
60764 + inode->i_op == &proc_sys_dir_operations)
60765 + gr_handle_delete(inode->i_ino, inode->i_sb->s_dev);
60766 +#endif
60767 +
60768 }
60769
60770 static struct kmem_cache * proc_inode_cachep;
60771 @@ -405,7 +418,11 @@ struct inode *proc_get_inode(struct super_block *sb, struct proc_dir_entry *de)
60772 if (de->mode) {
60773 inode->i_mode = de->mode;
60774 inode->i_uid = de->uid;
60775 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
60776 + inode->i_gid = grsec_proc_gid;
60777 +#else
60778 inode->i_gid = de->gid;
60779 +#endif
60780 }
60781 if (de->size)
60782 inode->i_size = de->size;
60783 diff --git a/fs/proc/internal.h b/fs/proc/internal.h
60784 index 651d09a..60c73ae 100644
60785 --- a/fs/proc/internal.h
60786 +++ b/fs/proc/internal.h
60787 @@ -155,6 +155,9 @@ extern int proc_pid_status(struct seq_file *, struct pid_namespace *,
60788 struct pid *, struct task_struct *);
60789 extern int proc_pid_statm(struct seq_file *, struct pid_namespace *,
60790 struct pid *, struct task_struct *);
60791 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
60792 +extern int proc_pid_ipaddr(struct task_struct *task, char *buffer);
60793 +#endif
60794
60795 /*
60796 * base.c
60797 diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c
60798 index 06ea155..9a798c7 100644
60799 --- a/fs/proc/kcore.c
60800 +++ b/fs/proc/kcore.c
60801 @@ -484,9 +484,10 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
60802 * the addresses in the elf_phdr on our list.
60803 */
60804 start = kc_offset_to_vaddr(*fpos - elf_buflen);
60805 - if ((tsz = (PAGE_SIZE - (start & ~PAGE_MASK))) > buflen)
60806 + tsz = PAGE_SIZE - (start & ~PAGE_MASK);
60807 + if (tsz > buflen)
60808 tsz = buflen;
60809 -
60810 +
60811 while (buflen) {
60812 struct kcore_list *m;
60813
60814 @@ -515,20 +516,23 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
60815 kfree(elf_buf);
60816 } else {
60817 if (kern_addr_valid(start)) {
60818 - unsigned long n;
60819 + char *elf_buf;
60820 + mm_segment_t oldfs;
60821
60822 - n = copy_to_user(buffer, (char *)start, tsz);
60823 - /*
60824 - * We cannot distinguish between fault on source
60825 - * and fault on destination. When this happens
60826 - * we clear too and hope it will trigger the
60827 - * EFAULT again.
60828 - */
60829 - if (n) {
60830 - if (clear_user(buffer + tsz - n,
60831 - n))
60832 + elf_buf = kmalloc(tsz, GFP_KERNEL);
60833 + if (!elf_buf)
60834 + return -ENOMEM;
60835 + oldfs = get_fs();
60836 + set_fs(KERNEL_DS);
60837 + if (!__copy_from_user(elf_buf, (const void __user *)start, tsz)) {
60838 + set_fs(oldfs);
60839 + if (copy_to_user(buffer, elf_buf, tsz)) {
60840 + kfree(elf_buf);
60841 return -EFAULT;
60842 + }
60843 }
60844 + set_fs(oldfs);
60845 + kfree(elf_buf);
60846 } else {
60847 if (clear_user(buffer, tsz))
60848 return -EFAULT;
60849 @@ -548,6 +552,9 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
60850
60851 static int open_kcore(struct inode *inode, struct file *filp)
60852 {
60853 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
60854 + return -EPERM;
60855 +#endif
60856 if (!capable(CAP_SYS_RAWIO))
60857 return -EPERM;
60858 if (kcore_need_update)
60859 diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c
60860 index 59d85d6..ac6fc05 100644
60861 --- a/fs/proc/meminfo.c
60862 +++ b/fs/proc/meminfo.c
60863 @@ -153,7 +153,7 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
60864 vmi.used >> 10,
60865 vmi.largest_chunk >> 10
60866 #ifdef CONFIG_MEMORY_FAILURE
60867 - ,atomic_long_read(&num_poisoned_pages) << (PAGE_SHIFT - 10)
60868 + ,atomic_long_read_unchecked(&num_poisoned_pages) << (PAGE_SHIFT - 10)
60869 #endif
60870 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
60871 ,K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) *
60872 diff --git a/fs/proc/nommu.c b/fs/proc/nommu.c
60873 index ccfd99b..1b7e255 100644
60874 --- a/fs/proc/nommu.c
60875 +++ b/fs/proc/nommu.c
60876 @@ -66,7 +66,7 @@ static int nommu_region_show(struct seq_file *m, struct vm_region *region)
60877 if (len < 1)
60878 len = 1;
60879 seq_printf(m, "%*c", len, ' ');
60880 - seq_path(m, &file->f_path, "");
60881 + seq_path(m, &file->f_path, "\n\\");
60882 }
60883
60884 seq_putc(m, '\n');
60885 diff --git a/fs/proc/proc_net.c b/fs/proc/proc_net.c
60886 index 4677bb7..408e936 100644
60887 --- a/fs/proc/proc_net.c
60888 +++ b/fs/proc/proc_net.c
60889 @@ -23,6 +23,7 @@
60890 #include <linux/nsproxy.h>
60891 #include <net/net_namespace.h>
60892 #include <linux/seq_file.h>
60893 +#include <linux/grsecurity.h>
60894
60895 #include "internal.h"
60896
60897 @@ -109,6 +110,17 @@ static struct net *get_proc_task_net(struct inode *dir)
60898 struct task_struct *task;
60899 struct nsproxy *ns;
60900 struct net *net = NULL;
60901 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
60902 + const struct cred *cred = current_cred();
60903 +#endif
60904 +
60905 +#ifdef CONFIG_GRKERNSEC_PROC_USER
60906 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID))
60907 + return net;
60908 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
60909 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID) && !in_group_p(grsec_proc_gid))
60910 + return net;
60911 +#endif
60912
60913 rcu_read_lock();
60914 task = pid_task(proc_pid(dir), PIDTYPE_PID);
60915 diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
60916 index 7129046..6914844 100644
60917 --- a/fs/proc/proc_sysctl.c
60918 +++ b/fs/proc/proc_sysctl.c
60919 @@ -11,13 +11,21 @@
60920 #include <linux/namei.h>
60921 #include <linux/mm.h>
60922 #include <linux/module.h>
60923 +#include <linux/nsproxy.h>
60924 +#ifdef CONFIG_GRKERNSEC
60925 +#include <net/net_namespace.h>
60926 +#endif
60927 #include "internal.h"
60928
60929 +extern int gr_handle_chroot_sysctl(const int op);
60930 +extern int gr_handle_sysctl_mod(const char *dirname, const char *name,
60931 + const int op);
60932 +
60933 static const struct dentry_operations proc_sys_dentry_operations;
60934 static const struct file_operations proc_sys_file_operations;
60935 -static const struct inode_operations proc_sys_inode_operations;
60936 +const struct inode_operations proc_sys_inode_operations;
60937 static const struct file_operations proc_sys_dir_file_operations;
60938 -static const struct inode_operations proc_sys_dir_operations;
60939 +const struct inode_operations proc_sys_dir_operations;
60940
60941 void proc_sys_poll_notify(struct ctl_table_poll *poll)
60942 {
60943 @@ -467,6 +475,9 @@ static struct dentry *proc_sys_lookup(struct inode *dir, struct dentry *dentry,
60944
60945 err = NULL;
60946 d_set_d_op(dentry, &proc_sys_dentry_operations);
60947 +
60948 + gr_handle_proc_create(dentry, inode);
60949 +
60950 d_add(dentry, inode);
60951
60952 out:
60953 @@ -482,6 +493,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
60954 struct inode *inode = file_inode(filp);
60955 struct ctl_table_header *head = grab_header(inode);
60956 struct ctl_table *table = PROC_I(inode)->sysctl_entry;
60957 + int op = write ? MAY_WRITE : MAY_READ;
60958 ssize_t error;
60959 size_t res;
60960
60961 @@ -493,7 +505,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
60962 * and won't be until we finish.
60963 */
60964 error = -EPERM;
60965 - if (sysctl_perm(head, table, write ? MAY_WRITE : MAY_READ))
60966 + if (sysctl_perm(head, table, op))
60967 goto out;
60968
60969 /* if that can happen at all, it should be -EINVAL, not -EISDIR */
60970 @@ -501,6 +513,27 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
60971 if (!table->proc_handler)
60972 goto out;
60973
60974 +#ifdef CONFIG_GRKERNSEC
60975 + error = -EPERM;
60976 + if (gr_handle_chroot_sysctl(op))
60977 + goto out;
60978 + dget(filp->f_path.dentry);
60979 + if (gr_handle_sysctl_mod(filp->f_path.dentry->d_parent->d_name.name, table->procname, op)) {
60980 + dput(filp->f_path.dentry);
60981 + goto out;
60982 + }
60983 + dput(filp->f_path.dentry);
60984 + if (!gr_acl_handle_open(filp->f_path.dentry, filp->f_path.mnt, op))
60985 + goto out;
60986 + if (write) {
60987 + if (current->nsproxy->net_ns != table->extra2) {
60988 + if (!capable(CAP_SYS_ADMIN))
60989 + goto out;
60990 + } else if (!ns_capable(current->nsproxy->net_ns->user_ns, CAP_NET_ADMIN))
60991 + goto out;
60992 + }
60993 +#endif
60994 +
60995 /* careful: calling conventions are nasty here */
60996 res = count;
60997 error = table->proc_handler(table, write, buf, &res, ppos);
60998 @@ -598,6 +631,9 @@ static bool proc_sys_fill_cache(struct file *file,
60999 return false;
61000 } else {
61001 d_set_d_op(child, &proc_sys_dentry_operations);
61002 +
61003 + gr_handle_proc_create(child, inode);
61004 +
61005 d_add(child, inode);
61006 }
61007 } else {
61008 @@ -641,6 +677,9 @@ static int scan(struct ctl_table_header *head, ctl_table *table,
61009 if ((*pos)++ < ctx->pos)
61010 return true;
61011
61012 + if (!gr_acl_handle_hidden_file(file->f_path.dentry, file->f_path.mnt))
61013 + return 0;
61014 +
61015 if (unlikely(S_ISLNK(table->mode)))
61016 res = proc_sys_link_fill_cache(file, ctx, head, table);
61017 else
61018 @@ -734,6 +773,9 @@ static int proc_sys_getattr(struct vfsmount *mnt, struct dentry *dentry, struct
61019 if (IS_ERR(head))
61020 return PTR_ERR(head);
61021
61022 + if (table && !gr_acl_handle_hidden_file(dentry, mnt))
61023 + return -ENOENT;
61024 +
61025 generic_fillattr(inode, stat);
61026 if (table)
61027 stat->mode = (stat->mode & S_IFMT) | table->mode;
61028 @@ -756,13 +798,13 @@ static const struct file_operations proc_sys_dir_file_operations = {
61029 .llseek = generic_file_llseek,
61030 };
61031
61032 -static const struct inode_operations proc_sys_inode_operations = {
61033 +const struct inode_operations proc_sys_inode_operations = {
61034 .permission = proc_sys_permission,
61035 .setattr = proc_sys_setattr,
61036 .getattr = proc_sys_getattr,
61037 };
61038
61039 -static const struct inode_operations proc_sys_dir_operations = {
61040 +const struct inode_operations proc_sys_dir_operations = {
61041 .lookup = proc_sys_lookup,
61042 .permission = proc_sys_permission,
61043 .setattr = proc_sys_setattr,
61044 @@ -839,7 +881,7 @@ static struct ctl_dir *find_subdir(struct ctl_dir *dir,
61045 static struct ctl_dir *new_dir(struct ctl_table_set *set,
61046 const char *name, int namelen)
61047 {
61048 - struct ctl_table *table;
61049 + ctl_table_no_const *table;
61050 struct ctl_dir *new;
61051 struct ctl_node *node;
61052 char *new_name;
61053 @@ -851,7 +893,7 @@ static struct ctl_dir *new_dir(struct ctl_table_set *set,
61054 return NULL;
61055
61056 node = (struct ctl_node *)(new + 1);
61057 - table = (struct ctl_table *)(node + 1);
61058 + table = (ctl_table_no_const *)(node + 1);
61059 new_name = (char *)(table + 2);
61060 memcpy(new_name, name, namelen);
61061 new_name[namelen] = '\0';
61062 @@ -1020,7 +1062,8 @@ static int sysctl_check_table(const char *path, struct ctl_table *table)
61063 static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table *table,
61064 struct ctl_table_root *link_root)
61065 {
61066 - struct ctl_table *link_table, *entry, *link;
61067 + ctl_table_no_const *link_table, *link;
61068 + struct ctl_table *entry;
61069 struct ctl_table_header *links;
61070 struct ctl_node *node;
61071 char *link_name;
61072 @@ -1043,7 +1086,7 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table
61073 return NULL;
61074
61075 node = (struct ctl_node *)(links + 1);
61076 - link_table = (struct ctl_table *)(node + nr_entries);
61077 + link_table = (ctl_table_no_const *)(node + nr_entries);
61078 link_name = (char *)&link_table[nr_entries + 1];
61079
61080 for (link = link_table, entry = table; entry->procname; link++, entry++) {
61081 @@ -1291,8 +1334,8 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
61082 struct ctl_table_header ***subheader, struct ctl_table_set *set,
61083 struct ctl_table *table)
61084 {
61085 - struct ctl_table *ctl_table_arg = NULL;
61086 - struct ctl_table *entry, *files;
61087 + ctl_table_no_const *ctl_table_arg = NULL, *files = NULL;
61088 + struct ctl_table *entry;
61089 int nr_files = 0;
61090 int nr_dirs = 0;
61091 int err = -ENOMEM;
61092 @@ -1304,10 +1347,9 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
61093 nr_files++;
61094 }
61095
61096 - files = table;
61097 /* If there are mixed files and directories we need a new table */
61098 if (nr_dirs && nr_files) {
61099 - struct ctl_table *new;
61100 + ctl_table_no_const *new;
61101 files = kzalloc(sizeof(struct ctl_table) * (nr_files + 1),
61102 GFP_KERNEL);
61103 if (!files)
61104 @@ -1325,7 +1367,7 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
61105 /* Register everything except a directory full of subdirectories */
61106 if (nr_files || !nr_dirs) {
61107 struct ctl_table_header *header;
61108 - header = __register_sysctl_table(set, path, files);
61109 + header = __register_sysctl_table(set, path, files ? files : table);
61110 if (!header) {
61111 kfree(ctl_table_arg);
61112 goto out;
61113 diff --git a/fs/proc/root.c b/fs/proc/root.c
61114 index 87dbcbe..55e1b4d 100644
61115 --- a/fs/proc/root.c
61116 +++ b/fs/proc/root.c
61117 @@ -186,7 +186,15 @@ void __init proc_root_init(void)
61118 #ifdef CONFIG_PROC_DEVICETREE
61119 proc_device_tree_init();
61120 #endif
61121 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
61122 +#ifdef CONFIG_GRKERNSEC_PROC_USER
61123 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR, NULL);
61124 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
61125 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
61126 +#endif
61127 +#else
61128 proc_mkdir("bus", NULL);
61129 +#endif
61130 proc_sys_init();
61131 }
61132
61133 diff --git a/fs/proc/self.c b/fs/proc/self.c
61134 index 6b6a993..807cccc 100644
61135 --- a/fs/proc/self.c
61136 +++ b/fs/proc/self.c
61137 @@ -39,7 +39,7 @@ static void *proc_self_follow_link(struct dentry *dentry, struct nameidata *nd)
61138 static void proc_self_put_link(struct dentry *dentry, struct nameidata *nd,
61139 void *cookie)
61140 {
61141 - char *s = nd_get_link(nd);
61142 + const char *s = nd_get_link(nd);
61143 if (!IS_ERR(s))
61144 kfree(s);
61145 }
61146 diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
61147 index 390bdab..83c1e8a 100644
61148 --- a/fs/proc/task_mmu.c
61149 +++ b/fs/proc/task_mmu.c
61150 @@ -12,12 +12,19 @@
61151 #include <linux/swap.h>
61152 #include <linux/swapops.h>
61153 #include <linux/mmu_notifier.h>
61154 +#include <linux/grsecurity.h>
61155
61156 #include <asm/elf.h>
61157 #include <asm/uaccess.h>
61158 #include <asm/tlbflush.h>
61159 #include "internal.h"
61160
61161 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
61162 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
61163 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
61164 + _mm->pax_flags & MF_PAX_SEGMEXEC))
61165 +#endif
61166 +
61167 void task_mem(struct seq_file *m, struct mm_struct *mm)
61168 {
61169 unsigned long data, text, lib, swap;
61170 @@ -53,8 +60,13 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
61171 "VmExe:\t%8lu kB\n"
61172 "VmLib:\t%8lu kB\n"
61173 "VmPTE:\t%8lu kB\n"
61174 - "VmSwap:\t%8lu kB\n",
61175 - hiwater_vm << (PAGE_SHIFT-10),
61176 + "VmSwap:\t%8lu kB\n"
61177 +
61178 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
61179 + "CsBase:\t%8lx\nCsLim:\t%8lx\n"
61180 +#endif
61181 +
61182 + ,hiwater_vm << (PAGE_SHIFT-10),
61183 total_vm << (PAGE_SHIFT-10),
61184 mm->locked_vm << (PAGE_SHIFT-10),
61185 mm->pinned_vm << (PAGE_SHIFT-10),
61186 @@ -63,7 +75,19 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
61187 data << (PAGE_SHIFT-10),
61188 mm->stack_vm << (PAGE_SHIFT-10), text, lib,
61189 (PTRS_PER_PTE*sizeof(pte_t)*mm->nr_ptes) >> 10,
61190 - swap << (PAGE_SHIFT-10));
61191 + swap << (PAGE_SHIFT-10)
61192 +
61193 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
61194 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
61195 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_base
61196 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_limit
61197 +#else
61198 + , mm->context.user_cs_base
61199 + , mm->context.user_cs_limit
61200 +#endif
61201 +#endif
61202 +
61203 + );
61204 }
61205
61206 unsigned long task_vsize(struct mm_struct *mm)
61207 @@ -278,13 +302,13 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
61208 pgoff = ((loff_t)vma->vm_pgoff) << PAGE_SHIFT;
61209 }
61210
61211 - /* We don't show the stack guard page in /proc/maps */
61212 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
61213 + start = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_start;
61214 + end = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_end;
61215 +#else
61216 start = vma->vm_start;
61217 - if (stack_guard_page_start(vma, start))
61218 - start += PAGE_SIZE;
61219 end = vma->vm_end;
61220 - if (stack_guard_page_end(vma, end))
61221 - end -= PAGE_SIZE;
61222 +#endif
61223
61224 seq_printf(m, "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu %n",
61225 start,
61226 @@ -293,7 +317,11 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
61227 flags & VM_WRITE ? 'w' : '-',
61228 flags & VM_EXEC ? 'x' : '-',
61229 flags & VM_MAYSHARE ? 's' : 'p',
61230 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
61231 + PAX_RAND_FLAGS(mm) ? 0UL : pgoff,
61232 +#else
61233 pgoff,
61234 +#endif
61235 MAJOR(dev), MINOR(dev), ino, &len);
61236
61237 /*
61238 @@ -302,7 +330,7 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
61239 */
61240 if (file) {
61241 pad_len_spaces(m, len);
61242 - seq_path(m, &file->f_path, "\n");
61243 + seq_path(m, &file->f_path, "\n\\");
61244 goto done;
61245 }
61246
61247 @@ -328,8 +356,9 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
61248 * Thread stack in /proc/PID/task/TID/maps or
61249 * the main process stack.
61250 */
61251 - if (!is_pid || (vma->vm_start <= mm->start_stack &&
61252 - vma->vm_end >= mm->start_stack)) {
61253 + if (!is_pid || (vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP)) ||
61254 + (vma->vm_start <= mm->start_stack &&
61255 + vma->vm_end >= mm->start_stack)) {
61256 name = "[stack]";
61257 } else {
61258 /* Thread stack in /proc/PID/maps */
61259 @@ -353,6 +382,13 @@ static int show_map(struct seq_file *m, void *v, int is_pid)
61260 struct proc_maps_private *priv = m->private;
61261 struct task_struct *task = priv->task;
61262
61263 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
61264 + if (current->exec_id != m->exec_id) {
61265 + gr_log_badprocpid("maps");
61266 + return 0;
61267 + }
61268 +#endif
61269 +
61270 show_map_vma(m, vma, is_pid);
61271
61272 if (m->count < m->size) /* vma is copied successfully */
61273 @@ -590,12 +626,23 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
61274 .private = &mss,
61275 };
61276
61277 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
61278 + if (current->exec_id != m->exec_id) {
61279 + gr_log_badprocpid("smaps");
61280 + return 0;
61281 + }
61282 +#endif
61283 memset(&mss, 0, sizeof mss);
61284 - mss.vma = vma;
61285 - /* mmap_sem is held in m_start */
61286 - if (vma->vm_mm && !is_vm_hugetlb_page(vma))
61287 - walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
61288 -
61289 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
61290 + if (!PAX_RAND_FLAGS(vma->vm_mm)) {
61291 +#endif
61292 + mss.vma = vma;
61293 + /* mmap_sem is held in m_start */
61294 + if (vma->vm_mm && !is_vm_hugetlb_page(vma))
61295 + walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
61296 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
61297 + }
61298 +#endif
61299 show_map_vma(m, vma, is_pid);
61300
61301 seq_printf(m,
61302 @@ -613,7 +660,11 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
61303 "KernelPageSize: %8lu kB\n"
61304 "MMUPageSize: %8lu kB\n"
61305 "Locked: %8lu kB\n",
61306 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
61307 + PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : (vma->vm_end - vma->vm_start) >> 10,
61308 +#else
61309 (vma->vm_end - vma->vm_start) >> 10,
61310 +#endif
61311 mss.resident >> 10,
61312 (unsigned long)(mss.pss >> (10 + PSS_SHIFT)),
61313 mss.shared_clean >> 10,
61314 @@ -1390,6 +1441,13 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
61315 int n;
61316 char buffer[50];
61317
61318 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
61319 + if (current->exec_id != m->exec_id) {
61320 + gr_log_badprocpid("numa_maps");
61321 + return 0;
61322 + }
61323 +#endif
61324 +
61325 if (!mm)
61326 return 0;
61327
61328 @@ -1409,11 +1467,15 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
61329 if (n < 0)
61330 return n;
61331
61332 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
61333 + seq_printf(m, "%08lx %s", PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : vma->vm_start, buffer);
61334 +#else
61335 seq_printf(m, "%08lx %s", vma->vm_start, buffer);
61336 +#endif
61337
61338 if (file) {
61339 seq_printf(m, " file=");
61340 - seq_path(m, &file->f_path, "\n\t= ");
61341 + seq_path(m, &file->f_path, "\n\t\\= ");
61342 } else if (vma->vm_start <= mm->brk && vma->vm_end >= mm->start_brk) {
61343 seq_printf(m, " heap");
61344 } else {
61345 diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
61346 index 56123a6..5a2f6ec 100644
61347 --- a/fs/proc/task_nommu.c
61348 +++ b/fs/proc/task_nommu.c
61349 @@ -51,7 +51,7 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
61350 else
61351 bytes += kobjsize(mm);
61352
61353 - if (current->fs && current->fs->users > 1)
61354 + if (current->fs && atomic_read(&current->fs->users) > 1)
61355 sbytes += kobjsize(current->fs);
61356 else
61357 bytes += kobjsize(current->fs);
61358 @@ -168,7 +168,7 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
61359
61360 if (file) {
61361 pad_len_spaces(m, len);
61362 - seq_path(m, &file->f_path, "");
61363 + seq_path(m, &file->f_path, "\n\\");
61364 } else if (mm) {
61365 pid_t tid = vm_is_stack(priv->task, vma, is_pid);
61366
61367 diff --git a/fs/proc/vmcore.c b/fs/proc/vmcore.c
61368 index 9100d69..f1f9fc9 100644
61369 --- a/fs/proc/vmcore.c
61370 +++ b/fs/proc/vmcore.c
61371 @@ -105,9 +105,13 @@ static ssize_t read_from_oldmem(char *buf, size_t count,
61372 nr_bytes = count;
61373
61374 /* If pfn is not ram, return zeros for sparse dump files */
61375 - if (pfn_is_ram(pfn) == 0)
61376 - memset(buf, 0, nr_bytes);
61377 - else {
61378 + if (pfn_is_ram(pfn) == 0) {
61379 + if (userbuf) {
61380 + if (clear_user((char __force_user *)buf, nr_bytes))
61381 + return -EFAULT;
61382 + } else
61383 + memset(buf, 0, nr_bytes);
61384 + } else {
61385 tmp = copy_oldmem_page(pfn, buf, nr_bytes,
61386 offset, userbuf);
61387 if (tmp < 0)
61388 @@ -233,7 +237,7 @@ static ssize_t __read_vmcore(char *buffer, size_t buflen, loff_t *fpos,
61389 if (*fpos < m->offset + m->size) {
61390 tsz = min_t(size_t, m->offset + m->size - *fpos, buflen);
61391 start = m->paddr + *fpos - m->offset;
61392 - tmp = read_from_oldmem(buffer, tsz, &start, userbuf);
61393 + tmp = read_from_oldmem((char __force_kernel *)buffer, tsz, &start, userbuf);
61394 if (tmp < 0)
61395 return tmp;
61396 buflen -= tsz;
61397 diff --git a/fs/qnx6/qnx6.h b/fs/qnx6/qnx6.h
61398 index b00fcc9..e0c6381 100644
61399 --- a/fs/qnx6/qnx6.h
61400 +++ b/fs/qnx6/qnx6.h
61401 @@ -74,7 +74,7 @@ enum {
61402 BYTESEX_BE,
61403 };
61404
61405 -static inline __u64 fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
61406 +static inline __u64 __intentional_overflow(-1) fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
61407 {
61408 if (sbi->s_bytesex == BYTESEX_LE)
61409 return le64_to_cpu((__force __le64)n);
61410 @@ -90,7 +90,7 @@ static inline __fs64 cpu_to_fs64(struct qnx6_sb_info *sbi, __u64 n)
61411 return (__force __fs64)cpu_to_be64(n);
61412 }
61413
61414 -static inline __u32 fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
61415 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
61416 {
61417 if (sbi->s_bytesex == BYTESEX_LE)
61418 return le32_to_cpu((__force __le32)n);
61419 diff --git a/fs/quota/netlink.c b/fs/quota/netlink.c
61420 index 16e8abb..2dcf914 100644
61421 --- a/fs/quota/netlink.c
61422 +++ b/fs/quota/netlink.c
61423 @@ -33,7 +33,7 @@ static struct genl_family quota_genl_family = {
61424 void quota_send_warning(struct kqid qid, dev_t dev,
61425 const char warntype)
61426 {
61427 - static atomic_t seq;
61428 + static atomic_unchecked_t seq;
61429 struct sk_buff *skb;
61430 void *msg_head;
61431 int ret;
61432 @@ -49,7 +49,7 @@ void quota_send_warning(struct kqid qid, dev_t dev,
61433 "VFS: Not enough memory to send quota warning.\n");
61434 return;
61435 }
61436 - msg_head = genlmsg_put(skb, 0, atomic_add_return(1, &seq),
61437 + msg_head = genlmsg_put(skb, 0, atomic_add_return_unchecked(1, &seq),
61438 &quota_genl_family, 0, QUOTA_NL_C_WARNING);
61439 if (!msg_head) {
61440 printk(KERN_ERR
61441 diff --git a/fs/read_write.c b/fs/read_write.c
61442 index e3cd280..a378473 100644
61443 --- a/fs/read_write.c
61444 +++ b/fs/read_write.c
61445 @@ -438,7 +438,7 @@ ssize_t __kernel_write(struct file *file, const char *buf, size_t count, loff_t
61446
61447 old_fs = get_fs();
61448 set_fs(get_ds());
61449 - p = (__force const char __user *)buf;
61450 + p = (const char __force_user *)buf;
61451 if (count > MAX_RW_COUNT)
61452 count = MAX_RW_COUNT;
61453 if (file->f_op->write)
61454 diff --git a/fs/readdir.c b/fs/readdir.c
61455 index 93d71e5..6a14be8 100644
61456 --- a/fs/readdir.c
61457 +++ b/fs/readdir.c
61458 @@ -17,6 +17,7 @@
61459 #include <linux/security.h>
61460 #include <linux/syscalls.h>
61461 #include <linux/unistd.h>
61462 +#include <linux/namei.h>
61463
61464 #include <asm/uaccess.h>
61465
61466 @@ -69,6 +70,7 @@ struct old_linux_dirent {
61467 struct readdir_callback {
61468 struct dir_context ctx;
61469 struct old_linux_dirent __user * dirent;
61470 + struct file * file;
61471 int result;
61472 };
61473
61474 @@ -86,6 +88,10 @@ static int fillonedir(void * __buf, const char * name, int namlen, loff_t offset
61475 buf->result = -EOVERFLOW;
61476 return -EOVERFLOW;
61477 }
61478 +
61479 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
61480 + return 0;
61481 +
61482 buf->result++;
61483 dirent = buf->dirent;
61484 if (!access_ok(VERIFY_WRITE, dirent,
61485 @@ -117,6 +123,7 @@ SYSCALL_DEFINE3(old_readdir, unsigned int, fd,
61486 if (!f.file)
61487 return -EBADF;
61488
61489 + buf.file = f.file;
61490 error = iterate_dir(f.file, &buf.ctx);
61491 if (buf.result)
61492 error = buf.result;
61493 @@ -142,6 +149,7 @@ struct getdents_callback {
61494 struct dir_context ctx;
61495 struct linux_dirent __user * current_dir;
61496 struct linux_dirent __user * previous;
61497 + struct file * file;
61498 int count;
61499 int error;
61500 };
61501 @@ -163,6 +171,10 @@ static int filldir(void * __buf, const char * name, int namlen, loff_t offset,
61502 buf->error = -EOVERFLOW;
61503 return -EOVERFLOW;
61504 }
61505 +
61506 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
61507 + return 0;
61508 +
61509 dirent = buf->previous;
61510 if (dirent) {
61511 if (__put_user(offset, &dirent->d_off))
61512 @@ -208,6 +220,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
61513 if (!f.file)
61514 return -EBADF;
61515
61516 + buf.file = f.file;
61517 error = iterate_dir(f.file, &buf.ctx);
61518 if (error >= 0)
61519 error = buf.error;
61520 @@ -226,6 +239,7 @@ struct getdents_callback64 {
61521 struct dir_context ctx;
61522 struct linux_dirent64 __user * current_dir;
61523 struct linux_dirent64 __user * previous;
61524 + struct file *file;
61525 int count;
61526 int error;
61527 };
61528 @@ -241,6 +255,10 @@ static int filldir64(void * __buf, const char * name, int namlen, loff_t offset,
61529 buf->error = -EINVAL; /* only used if we fail.. */
61530 if (reclen > buf->count)
61531 return -EINVAL;
61532 +
61533 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
61534 + return 0;
61535 +
61536 dirent = buf->previous;
61537 if (dirent) {
61538 if (__put_user(offset, &dirent->d_off))
61539 @@ -288,6 +306,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
61540 if (!f.file)
61541 return -EBADF;
61542
61543 + buf.file = f.file;
61544 error = iterate_dir(f.file, &buf.ctx);
61545 if (error >= 0)
61546 error = buf.error;
61547 diff --git a/fs/reiserfs/do_balan.c b/fs/reiserfs/do_balan.c
61548 index 2b7882b..1c5ef48 100644
61549 --- a/fs/reiserfs/do_balan.c
61550 +++ b/fs/reiserfs/do_balan.c
61551 @@ -2051,7 +2051,7 @@ void do_balance(struct tree_balance *tb, /* tree_balance structure */
61552 return;
61553 }
61554
61555 - atomic_inc(&(fs_generation(tb->tb_sb)));
61556 + atomic_inc_unchecked(&(fs_generation(tb->tb_sb)));
61557 do_balance_starts(tb);
61558
61559 /* balance leaf returns 0 except if combining L R and S into
61560 diff --git a/fs/reiserfs/procfs.c b/fs/reiserfs/procfs.c
61561 index a958444..42b2323 100644
61562 --- a/fs/reiserfs/procfs.c
61563 +++ b/fs/reiserfs/procfs.c
61564 @@ -114,7 +114,7 @@ static int show_super(struct seq_file *m, void *unused)
61565 "SMALL_TAILS " : "NO_TAILS ",
61566 replay_only(sb) ? "REPLAY_ONLY " : "",
61567 convert_reiserfs(sb) ? "CONV " : "",
61568 - atomic_read(&r->s_generation_counter),
61569 + atomic_read_unchecked(&r->s_generation_counter),
61570 SF(s_disk_reads), SF(s_disk_writes), SF(s_fix_nodes),
61571 SF(s_do_balance), SF(s_unneeded_left_neighbor),
61572 SF(s_good_search_by_key_reada), SF(s_bmaps),
61573 diff --git a/fs/reiserfs/reiserfs.h b/fs/reiserfs/reiserfs.h
61574 index f8adaee..0eeeeca 100644
61575 --- a/fs/reiserfs/reiserfs.h
61576 +++ b/fs/reiserfs/reiserfs.h
61577 @@ -453,7 +453,7 @@ struct reiserfs_sb_info {
61578 /* Comment? -Hans */
61579 wait_queue_head_t s_wait;
61580 /* To be obsoleted soon by per buffer seals.. -Hans */
61581 - atomic_t s_generation_counter; // increased by one every time the
61582 + atomic_unchecked_t s_generation_counter; // increased by one every time the
61583 // tree gets re-balanced
61584 unsigned long s_properties; /* File system properties. Currently holds
61585 on-disk FS format */
61586 @@ -1982,7 +1982,7 @@ static inline loff_t max_reiserfs_offset(struct inode *inode)
61587 #define REISERFS_USER_MEM 1 /* reiserfs user memory mode */
61588
61589 #define fs_generation(s) (REISERFS_SB(s)->s_generation_counter)
61590 -#define get_generation(s) atomic_read (&fs_generation(s))
61591 +#define get_generation(s) atomic_read_unchecked (&fs_generation(s))
61592 #define FILESYSTEM_CHANGED_TB(tb) (get_generation((tb)->tb_sb) != (tb)->fs_gen)
61593 #define __fs_changed(gen,s) (gen != get_generation (s))
61594 #define fs_changed(gen,s) \
61595 diff --git a/fs/select.c b/fs/select.c
61596 index dfd5cb1..1754d57 100644
61597 --- a/fs/select.c
61598 +++ b/fs/select.c
61599 @@ -20,6 +20,7 @@
61600 #include <linux/export.h>
61601 #include <linux/slab.h>
61602 #include <linux/poll.h>
61603 +#include <linux/security.h>
61604 #include <linux/personality.h> /* for STICKY_TIMEOUTS */
61605 #include <linux/file.h>
61606 #include <linux/fdtable.h>
61607 @@ -880,6 +881,7 @@ int do_sys_poll(struct pollfd __user *ufds, unsigned int nfds,
61608 struct poll_list *walk = head;
61609 unsigned long todo = nfds;
61610
61611 + gr_learn_resource(current, RLIMIT_NOFILE, nfds, 1);
61612 if (nfds > rlimit(RLIMIT_NOFILE))
61613 return -EINVAL;
61614
61615 diff --git a/fs/seq_file.c b/fs/seq_file.c
61616 index a290157..ec3211a 100644
61617 --- a/fs/seq_file.c
61618 +++ b/fs/seq_file.c
61619 @@ -10,6 +10,7 @@
61620 #include <linux/seq_file.h>
61621 #include <linux/slab.h>
61622 #include <linux/cred.h>
61623 +#include <linux/sched.h>
61624
61625 #include <asm/uaccess.h>
61626 #include <asm/page.h>
61627 @@ -60,6 +61,9 @@ int seq_open(struct file *file, const struct seq_operations *op)
61628 #ifdef CONFIG_USER_NS
61629 p->user_ns = file->f_cred->user_ns;
61630 #endif
61631 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
61632 + p->exec_id = current->exec_id;
61633 +#endif
61634
61635 /*
61636 * Wrappers around seq_open(e.g. swaps_open) need to be
61637 @@ -96,7 +100,7 @@ static int traverse(struct seq_file *m, loff_t offset)
61638 return 0;
61639 }
61640 if (!m->buf) {
61641 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
61642 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
61643 if (!m->buf)
61644 return -ENOMEM;
61645 }
61646 @@ -136,7 +140,7 @@ static int traverse(struct seq_file *m, loff_t offset)
61647 Eoverflow:
61648 m->op->stop(m, p);
61649 kfree(m->buf);
61650 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
61651 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
61652 return !m->buf ? -ENOMEM : -EAGAIN;
61653 }
61654
61655 @@ -152,7 +156,7 @@ Eoverflow:
61656 ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
61657 {
61658 struct seq_file *m = file->private_data;
61659 - size_t copied = 0;
61660 + ssize_t copied = 0;
61661 loff_t pos;
61662 size_t n;
61663 void *p;
61664 @@ -191,7 +195,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
61665
61666 /* grab buffer if we didn't have one */
61667 if (!m->buf) {
61668 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
61669 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
61670 if (!m->buf)
61671 goto Enomem;
61672 }
61673 @@ -232,7 +236,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
61674 goto Fill;
61675 m->op->stop(m, p);
61676 kfree(m->buf);
61677 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
61678 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
61679 if (!m->buf)
61680 goto Enomem;
61681 m->count = 0;
61682 @@ -583,7 +587,7 @@ static void single_stop(struct seq_file *p, void *v)
61683 int single_open(struct file *file, int (*show)(struct seq_file *, void *),
61684 void *data)
61685 {
61686 - struct seq_operations *op = kmalloc(sizeof(*op), GFP_KERNEL);
61687 + seq_operations_no_const *op = kzalloc(sizeof(*op), GFP_KERNEL);
61688 int res = -ENOMEM;
61689
61690 if (op) {
61691 diff --git a/fs/splice.c b/fs/splice.c
61692 index 3b7ee65..87fc2e4 100644
61693 --- a/fs/splice.c
61694 +++ b/fs/splice.c
61695 @@ -196,7 +196,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
61696 pipe_lock(pipe);
61697
61698 for (;;) {
61699 - if (!pipe->readers) {
61700 + if (!atomic_read(&pipe->readers)) {
61701 send_sig(SIGPIPE, current, 0);
61702 if (!ret)
61703 ret = -EPIPE;
61704 @@ -219,7 +219,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
61705 page_nr++;
61706 ret += buf->len;
61707
61708 - if (pipe->files)
61709 + if (atomic_read(&pipe->files))
61710 do_wakeup = 1;
61711
61712 if (!--spd->nr_pages)
61713 @@ -250,9 +250,9 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
61714 do_wakeup = 0;
61715 }
61716
61717 - pipe->waiting_writers++;
61718 + atomic_inc(&pipe->waiting_writers);
61719 pipe_wait(pipe);
61720 - pipe->waiting_writers--;
61721 + atomic_dec(&pipe->waiting_writers);
61722 }
61723
61724 pipe_unlock(pipe);
61725 @@ -565,7 +565,7 @@ static ssize_t kernel_readv(struct file *file, const struct iovec *vec,
61726 old_fs = get_fs();
61727 set_fs(get_ds());
61728 /* The cast to a user pointer is valid due to the set_fs() */
61729 - res = vfs_readv(file, (const struct iovec __user *)vec, vlen, &pos);
61730 + res = vfs_readv(file, (const struct iovec __force_user *)vec, vlen, &pos);
61731 set_fs(old_fs);
61732
61733 return res;
61734 @@ -580,7 +580,7 @@ ssize_t kernel_write(struct file *file, const char *buf, size_t count,
61735 old_fs = get_fs();
61736 set_fs(get_ds());
61737 /* The cast to a user pointer is valid due to the set_fs() */
61738 - res = vfs_write(file, (__force const char __user *)buf, count, &pos);
61739 + res = vfs_write(file, (const char __force_user *)buf, count, &pos);
61740 set_fs(old_fs);
61741
61742 return res;
61743 @@ -633,7 +633,7 @@ ssize_t default_file_splice_read(struct file *in, loff_t *ppos,
61744 goto err;
61745
61746 this_len = min_t(size_t, len, PAGE_CACHE_SIZE - offset);
61747 - vec[i].iov_base = (void __user *) page_address(page);
61748 + vec[i].iov_base = (void __force_user *) page_address(page);
61749 vec[i].iov_len = this_len;
61750 spd.pages[i] = page;
61751 spd.nr_pages++;
61752 @@ -829,7 +829,7 @@ int splice_from_pipe_feed(struct pipe_inode_info *pipe, struct splice_desc *sd,
61753 ops->release(pipe, buf);
61754 pipe->curbuf = (pipe->curbuf + 1) & (pipe->buffers - 1);
61755 pipe->nrbufs--;
61756 - if (pipe->files)
61757 + if (atomic_read(&pipe->files))
61758 sd->need_wakeup = true;
61759 }
61760
61761 @@ -854,10 +854,10 @@ EXPORT_SYMBOL(splice_from_pipe_feed);
61762 int splice_from_pipe_next(struct pipe_inode_info *pipe, struct splice_desc *sd)
61763 {
61764 while (!pipe->nrbufs) {
61765 - if (!pipe->writers)
61766 + if (!atomic_read(&pipe->writers))
61767 return 0;
61768
61769 - if (!pipe->waiting_writers && sd->num_spliced)
61770 + if (!atomic_read(&pipe->waiting_writers) && sd->num_spliced)
61771 return 0;
61772
61773 if (sd->flags & SPLICE_F_NONBLOCK)
61774 @@ -1179,7 +1179,7 @@ ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd,
61775 * out of the pipe right after the splice_to_pipe(). So set
61776 * PIPE_READERS appropriately.
61777 */
61778 - pipe->readers = 1;
61779 + atomic_set(&pipe->readers, 1);
61780
61781 current->splice_pipe = pipe;
61782 }
61783 @@ -1475,6 +1475,7 @@ static int get_iovec_page_array(const struct iovec __user *iov,
61784
61785 partial[buffers].offset = off;
61786 partial[buffers].len = plen;
61787 + partial[buffers].private = 0;
61788
61789 off = 0;
61790 len -= plen;
61791 @@ -1777,9 +1778,9 @@ static int ipipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
61792 ret = -ERESTARTSYS;
61793 break;
61794 }
61795 - if (!pipe->writers)
61796 + if (!atomic_read(&pipe->writers))
61797 break;
61798 - if (!pipe->waiting_writers) {
61799 + if (!atomic_read(&pipe->waiting_writers)) {
61800 if (flags & SPLICE_F_NONBLOCK) {
61801 ret = -EAGAIN;
61802 break;
61803 @@ -1811,7 +1812,7 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
61804 pipe_lock(pipe);
61805
61806 while (pipe->nrbufs >= pipe->buffers) {
61807 - if (!pipe->readers) {
61808 + if (!atomic_read(&pipe->readers)) {
61809 send_sig(SIGPIPE, current, 0);
61810 ret = -EPIPE;
61811 break;
61812 @@ -1824,9 +1825,9 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
61813 ret = -ERESTARTSYS;
61814 break;
61815 }
61816 - pipe->waiting_writers++;
61817 + atomic_inc(&pipe->waiting_writers);
61818 pipe_wait(pipe);
61819 - pipe->waiting_writers--;
61820 + atomic_dec(&pipe->waiting_writers);
61821 }
61822
61823 pipe_unlock(pipe);
61824 @@ -1862,14 +1863,14 @@ retry:
61825 pipe_double_lock(ipipe, opipe);
61826
61827 do {
61828 - if (!opipe->readers) {
61829 + if (!atomic_read(&opipe->readers)) {
61830 send_sig(SIGPIPE, current, 0);
61831 if (!ret)
61832 ret = -EPIPE;
61833 break;
61834 }
61835
61836 - if (!ipipe->nrbufs && !ipipe->writers)
61837 + if (!ipipe->nrbufs && !atomic_read(&ipipe->writers))
61838 break;
61839
61840 /*
61841 @@ -1966,7 +1967,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
61842 pipe_double_lock(ipipe, opipe);
61843
61844 do {
61845 - if (!opipe->readers) {
61846 + if (!atomic_read(&opipe->readers)) {
61847 send_sig(SIGPIPE, current, 0);
61848 if (!ret)
61849 ret = -EPIPE;
61850 @@ -2011,7 +2012,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
61851 * return EAGAIN if we have the potential of some data in the
61852 * future, otherwise just return 0
61853 */
61854 - if (!ret && ipipe->waiting_writers && (flags & SPLICE_F_NONBLOCK))
61855 + if (!ret && atomic_read(&ipipe->waiting_writers) && (flags & SPLICE_F_NONBLOCK))
61856 ret = -EAGAIN;
61857
61858 pipe_unlock(ipipe);
61859 diff --git a/fs/stat.c b/fs/stat.c
61860 index ae0c3ce..9ee641c 100644
61861 --- a/fs/stat.c
61862 +++ b/fs/stat.c
61863 @@ -28,8 +28,13 @@ void generic_fillattr(struct inode *inode, struct kstat *stat)
61864 stat->gid = inode->i_gid;
61865 stat->rdev = inode->i_rdev;
61866 stat->size = i_size_read(inode);
61867 - stat->atime = inode->i_atime;
61868 - stat->mtime = inode->i_mtime;
61869 + if (is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
61870 + stat->atime = inode->i_ctime;
61871 + stat->mtime = inode->i_ctime;
61872 + } else {
61873 + stat->atime = inode->i_atime;
61874 + stat->mtime = inode->i_mtime;
61875 + }
61876 stat->ctime = inode->i_ctime;
61877 stat->blksize = (1 << inode->i_blkbits);
61878 stat->blocks = inode->i_blocks;
61879 @@ -52,9 +57,16 @@ EXPORT_SYMBOL(generic_fillattr);
61880 int vfs_getattr_nosec(struct path *path, struct kstat *stat)
61881 {
61882 struct inode *inode = path->dentry->d_inode;
61883 + int retval;
61884
61885 - if (inode->i_op->getattr)
61886 - return inode->i_op->getattr(path->mnt, path->dentry, stat);
61887 + if (inode->i_op->getattr) {
61888 + retval = inode->i_op->getattr(path->mnt, path->dentry, stat);
61889 + if (!retval && is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
61890 + stat->atime = stat->ctime;
61891 + stat->mtime = stat->ctime;
61892 + }
61893 + return retval;
61894 + }
61895
61896 generic_fillattr(inode, stat);
61897 return 0;
61898 diff --git a/fs/sysfs/bin.c b/fs/sysfs/bin.c
61899 index c590cab..6dfd6fc 100644
61900 --- a/fs/sysfs/bin.c
61901 +++ b/fs/sysfs/bin.c
61902 @@ -234,13 +234,13 @@ static int bin_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
61903 return ret;
61904 }
61905
61906 -static int bin_access(struct vm_area_struct *vma, unsigned long addr,
61907 - void *buf, int len, int write)
61908 +static ssize_t bin_access(struct vm_area_struct *vma, unsigned long addr,
61909 + void *buf, size_t len, int write)
61910 {
61911 struct file *file = vma->vm_file;
61912 struct bin_buffer *bb = file->private_data;
61913 struct sysfs_dirent *attr_sd = file->f_path.dentry->d_fsdata;
61914 - int ret;
61915 + ssize_t ret;
61916
61917 if (!bb->vm_ops)
61918 return -EINVAL;
61919 diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
61920 index 4d83ced..049dc45 100644
61921 --- a/fs/sysfs/dir.c
61922 +++ b/fs/sysfs/dir.c
61923 @@ -40,7 +40,7 @@ static DEFINE_IDA(sysfs_ino_ida);
61924 *
61925 * Returns 31 bit hash of ns + name (so it fits in an off_t )
61926 */
61927 -static unsigned int sysfs_name_hash(const void *ns, const char *name)
61928 +static unsigned int sysfs_name_hash(const void *ns, const unsigned char *name)
61929 {
61930 unsigned long hash = init_name_hash();
61931 unsigned int len = strlen(name);
61932 @@ -675,6 +675,18 @@ static int create_dir(struct kobject *kobj, struct sysfs_dirent *parent_sd,
61933 struct sysfs_dirent *sd;
61934 int rc;
61935
61936 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
61937 + const char *parent_name = parent_sd->s_name;
61938 +
61939 + mode = S_IFDIR | S_IRWXU;
61940 +
61941 + if ((!strcmp(parent_name, "") && (!strcmp(name, "devices") || !strcmp(name, "fs"))) ||
61942 + (!strcmp(parent_name, "devices") && !strcmp(name, "system")) ||
61943 + (!strcmp(parent_name, "fs") && (!strcmp(name, "selinux") || !strcmp(name, "fuse") || !strcmp(name, "ecryptfs"))) ||
61944 + (!strcmp(parent_name, "system") && !strcmp(name, "cpu")))
61945 + mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO;
61946 +#endif
61947 +
61948 /* allocate */
61949 sd = sysfs_new_dirent(name, mode, SYSFS_DIR);
61950 if (!sd)
61951 diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
61952 index 15ef5eb..e474372 100644
61953 --- a/fs/sysfs/file.c
61954 +++ b/fs/sysfs/file.c
61955 @@ -37,7 +37,7 @@ static DEFINE_SPINLOCK(sysfs_open_dirent_lock);
61956
61957 struct sysfs_open_dirent {
61958 atomic_t refcnt;
61959 - atomic_t event;
61960 + atomic_unchecked_t event;
61961 wait_queue_head_t poll;
61962 struct list_head buffers; /* goes through sysfs_buffer.list */
61963 };
61964 @@ -81,7 +81,7 @@ static int fill_read_buffer(struct dentry *dentry, struct sysfs_buffer *buffer)
61965 if (!sysfs_get_active(attr_sd))
61966 return -ENODEV;
61967
61968 - buffer->event = atomic_read(&attr_sd->s_attr.open->event);
61969 + buffer->event = atomic_read_unchecked(&attr_sd->s_attr.open->event);
61970 count = ops->show(kobj, attr_sd->s_attr.attr, buffer->page);
61971
61972 sysfs_put_active(attr_sd);
61973 @@ -284,7 +284,7 @@ static int sysfs_get_open_dirent(struct sysfs_dirent *sd,
61974 return -ENOMEM;
61975
61976 atomic_set(&new_od->refcnt, 0);
61977 - atomic_set(&new_od->event, 1);
61978 + atomic_set_unchecked(&new_od->event, 1);
61979 init_waitqueue_head(&new_od->poll);
61980 INIT_LIST_HEAD(&new_od->buffers);
61981 goto retry;
61982 @@ -430,7 +430,7 @@ static unsigned int sysfs_poll(struct file *filp, poll_table *wait)
61983
61984 sysfs_put_active(attr_sd);
61985
61986 - if (buffer->event != atomic_read(&od->event))
61987 + if (buffer->event != atomic_read_unchecked(&od->event))
61988 goto trigger;
61989
61990 return DEFAULT_POLLMASK;
61991 @@ -450,7 +450,7 @@ void sysfs_notify_dirent(struct sysfs_dirent *sd)
61992 if (!WARN_ON(sysfs_type(sd) != SYSFS_KOBJ_ATTR)) {
61993 od = sd->s_attr.open;
61994 if (od) {
61995 - atomic_inc(&od->event);
61996 + atomic_inc_unchecked(&od->event);
61997 wake_up_interruptible(&od->poll);
61998 }
61999 }
62000 diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c
62001 index 2dd4507..62a215a 100644
62002 --- a/fs/sysfs/symlink.c
62003 +++ b/fs/sysfs/symlink.c
62004 @@ -308,7 +308,7 @@ static void *sysfs_follow_link(struct dentry *dentry, struct nameidata *nd)
62005 static void sysfs_put_link(struct dentry *dentry, struct nameidata *nd,
62006 void *cookie)
62007 {
62008 - char *page = nd_get_link(nd);
62009 + const char *page = nd_get_link(nd);
62010 if (!IS_ERR(page))
62011 free_page((unsigned long)page);
62012 }
62013 diff --git a/fs/sysv/sysv.h b/fs/sysv/sysv.h
62014 index 69d4889..a810bd4 100644
62015 --- a/fs/sysv/sysv.h
62016 +++ b/fs/sysv/sysv.h
62017 @@ -188,7 +188,7 @@ static inline u32 PDP_swab(u32 x)
62018 #endif
62019 }
62020
62021 -static inline __u32 fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
62022 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
62023 {
62024 if (sbi->s_bytesex == BYTESEX_PDP)
62025 return PDP_swab((__force __u32)n);
62026 diff --git a/fs/ubifs/io.c b/fs/ubifs/io.c
62027 index e18b988..f1d4ad0f 100644
62028 --- a/fs/ubifs/io.c
62029 +++ b/fs/ubifs/io.c
62030 @@ -155,7 +155,7 @@ int ubifs_leb_change(struct ubifs_info *c, int lnum, const void *buf, int len)
62031 return err;
62032 }
62033
62034 -int ubifs_leb_unmap(struct ubifs_info *c, int lnum)
62035 +int __intentional_overflow(-1) ubifs_leb_unmap(struct ubifs_info *c, int lnum)
62036 {
62037 int err;
62038
62039 diff --git a/fs/udf/misc.c b/fs/udf/misc.c
62040 index c175b4d..8f36a16 100644
62041 --- a/fs/udf/misc.c
62042 +++ b/fs/udf/misc.c
62043 @@ -289,7 +289,7 @@ void udf_new_tag(char *data, uint16_t ident, uint16_t version, uint16_t snum,
62044
62045 u8 udf_tag_checksum(const struct tag *t)
62046 {
62047 - u8 *data = (u8 *)t;
62048 + const u8 *data = (const u8 *)t;
62049 u8 checksum = 0;
62050 int i;
62051 for (i = 0; i < sizeof(struct tag); ++i)
62052 diff --git a/fs/ufs/swab.h b/fs/ufs/swab.h
62053 index 8d974c4..b82f6ec 100644
62054 --- a/fs/ufs/swab.h
62055 +++ b/fs/ufs/swab.h
62056 @@ -22,7 +22,7 @@ enum {
62057 BYTESEX_BE
62058 };
62059
62060 -static inline u64
62061 +static inline u64 __intentional_overflow(-1)
62062 fs64_to_cpu(struct super_block *sbp, __fs64 n)
62063 {
62064 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
62065 @@ -40,7 +40,7 @@ cpu_to_fs64(struct super_block *sbp, u64 n)
62066 return (__force __fs64)cpu_to_be64(n);
62067 }
62068
62069 -static inline u32
62070 +static inline u32 __intentional_overflow(-1)
62071 fs32_to_cpu(struct super_block *sbp, __fs32 n)
62072 {
62073 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
62074 diff --git a/fs/utimes.c b/fs/utimes.c
62075 index f4fb7ec..3fe03c0 100644
62076 --- a/fs/utimes.c
62077 +++ b/fs/utimes.c
62078 @@ -1,6 +1,7 @@
62079 #include <linux/compiler.h>
62080 #include <linux/file.h>
62081 #include <linux/fs.h>
62082 +#include <linux/security.h>
62083 #include <linux/linkage.h>
62084 #include <linux/mount.h>
62085 #include <linux/namei.h>
62086 @@ -101,6 +102,12 @@ static int utimes_common(struct path *path, struct timespec *times)
62087 goto mnt_drop_write_and_out;
62088 }
62089 }
62090 +
62091 + if (!gr_acl_handle_utime(path->dentry, path->mnt)) {
62092 + error = -EACCES;
62093 + goto mnt_drop_write_and_out;
62094 + }
62095 +
62096 mutex_lock(&inode->i_mutex);
62097 error = notify_change(path->dentry, &newattrs);
62098 mutex_unlock(&inode->i_mutex);
62099 diff --git a/fs/xattr.c b/fs/xattr.c
62100 index 3377dff..4d074d9 100644
62101 --- a/fs/xattr.c
62102 +++ b/fs/xattr.c
62103 @@ -227,6 +227,27 @@ int vfs_xattr_cmp(struct dentry *dentry, const char *xattr_name,
62104 return rc;
62105 }
62106
62107 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
62108 +ssize_t
62109 +pax_getxattr(struct dentry *dentry, void *value, size_t size)
62110 +{
62111 + struct inode *inode = dentry->d_inode;
62112 + ssize_t error;
62113 +
62114 + error = inode_permission(inode, MAY_EXEC);
62115 + if (error)
62116 + return error;
62117 +
62118 + if (inode->i_op->getxattr)
62119 + error = inode->i_op->getxattr(dentry, XATTR_NAME_PAX_FLAGS, value, size);
62120 + else
62121 + error = -EOPNOTSUPP;
62122 +
62123 + return error;
62124 +}
62125 +EXPORT_SYMBOL(pax_getxattr);
62126 +#endif
62127 +
62128 ssize_t
62129 vfs_getxattr(struct dentry *dentry, const char *name, void *value, size_t size)
62130 {
62131 @@ -319,7 +340,7 @@ EXPORT_SYMBOL_GPL(vfs_removexattr);
62132 * Extended attribute SET operations
62133 */
62134 static long
62135 -setxattr(struct dentry *d, const char __user *name, const void __user *value,
62136 +setxattr(struct path *path, const char __user *name, const void __user *value,
62137 size_t size, int flags)
62138 {
62139 int error;
62140 @@ -355,7 +376,12 @@ setxattr(struct dentry *d, const char __user *name, const void __user *value,
62141 posix_acl_fix_xattr_from_user(kvalue, size);
62142 }
62143
62144 - error = vfs_setxattr(d, kname, kvalue, size, flags);
62145 + if (!gr_acl_handle_setxattr(path->dentry, path->mnt)) {
62146 + error = -EACCES;
62147 + goto out;
62148 + }
62149 +
62150 + error = vfs_setxattr(path->dentry, kname, kvalue, size, flags);
62151 out:
62152 if (vvalue)
62153 vfree(vvalue);
62154 @@ -377,7 +403,7 @@ retry:
62155 return error;
62156 error = mnt_want_write(path.mnt);
62157 if (!error) {
62158 - error = setxattr(path.dentry, name, value, size, flags);
62159 + error = setxattr(&path, name, value, size, flags);
62160 mnt_drop_write(path.mnt);
62161 }
62162 path_put(&path);
62163 @@ -401,7 +427,7 @@ retry:
62164 return error;
62165 error = mnt_want_write(path.mnt);
62166 if (!error) {
62167 - error = setxattr(path.dentry, name, value, size, flags);
62168 + error = setxattr(&path, name, value, size, flags);
62169 mnt_drop_write(path.mnt);
62170 }
62171 path_put(&path);
62172 @@ -416,16 +442,14 @@ SYSCALL_DEFINE5(fsetxattr, int, fd, const char __user *, name,
62173 const void __user *,value, size_t, size, int, flags)
62174 {
62175 struct fd f = fdget(fd);
62176 - struct dentry *dentry;
62177 int error = -EBADF;
62178
62179 if (!f.file)
62180 return error;
62181 - dentry = f.file->f_path.dentry;
62182 - audit_inode(NULL, dentry, 0);
62183 + audit_inode(NULL, f.file->f_path.dentry, 0);
62184 error = mnt_want_write_file(f.file);
62185 if (!error) {
62186 - error = setxattr(dentry, name, value, size, flags);
62187 + error = setxattr(&f.file->f_path, name, value, size, flags);
62188 mnt_drop_write_file(f.file);
62189 }
62190 fdput(f);
62191 diff --git a/fs/xattr_acl.c b/fs/xattr_acl.c
62192 index 9fbea87..6b19972 100644
62193 --- a/fs/xattr_acl.c
62194 +++ b/fs/xattr_acl.c
62195 @@ -76,8 +76,8 @@ struct posix_acl *
62196 posix_acl_from_xattr(struct user_namespace *user_ns,
62197 const void *value, size_t size)
62198 {
62199 - posix_acl_xattr_header *header = (posix_acl_xattr_header *)value;
62200 - posix_acl_xattr_entry *entry = (posix_acl_xattr_entry *)(header+1), *end;
62201 + const posix_acl_xattr_header *header = (const posix_acl_xattr_header *)value;
62202 + const posix_acl_xattr_entry *entry = (const posix_acl_xattr_entry *)(header+1), *end;
62203 int count;
62204 struct posix_acl *acl;
62205 struct posix_acl_entry *acl_e;
62206 diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c
62207 index f47e65c..e7125d9 100644
62208 --- a/fs/xfs/xfs_bmap.c
62209 +++ b/fs/xfs/xfs_bmap.c
62210 @@ -586,7 +586,7 @@ xfs_bmap_validate_ret(
62211
62212 #else
62213 #define xfs_bmap_check_leaf_extents(cur, ip, whichfork) do { } while (0)
62214 -#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap)
62215 +#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap) do { } while (0)
62216 #endif /* DEBUG */
62217
62218 /*
62219 diff --git a/fs/xfs/xfs_dir2_readdir.c b/fs/xfs/xfs_dir2_readdir.c
62220 index 8f84153..7ce60d0 100644
62221 --- a/fs/xfs/xfs_dir2_readdir.c
62222 +++ b/fs/xfs/xfs_dir2_readdir.c
62223 @@ -160,7 +160,12 @@ xfs_dir2_sf_getdents(
62224 ino = xfs_dir3_sfe_get_ino(mp, sfp, sfep);
62225 filetype = xfs_dir3_sfe_get_ftype(mp, sfp, sfep);
62226 ctx->pos = off & 0x7fffffff;
62227 - if (!dir_emit(ctx, (char *)sfep->name, sfep->namelen, ino,
62228 + if (dp->i_df.if_u1.if_data == dp->i_df.if_u2.if_inline_data) {
62229 + char name[sfep->namelen];
62230 + memcpy(name, sfep->name, sfep->namelen);
62231 + if (!dir_emit(ctx, name, sfep->namelen, ino, xfs_dir3_get_dtype(mp, filetype)))
62232 + return 0;
62233 + } else if (!dir_emit(ctx, (char *)sfep->name, sfep->namelen, ino,
62234 xfs_dir3_get_dtype(mp, filetype)))
62235 return 0;
62236 sfep = xfs_dir3_sf_nextentry(mp, sfp, sfep);
62237 diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
62238 index 8c8ef24..689f742 100644
62239 --- a/fs/xfs/xfs_ioctl.c
62240 +++ b/fs/xfs/xfs_ioctl.c
62241 @@ -127,7 +127,7 @@ xfs_find_handle(
62242 }
62243
62244 error = -EFAULT;
62245 - if (copy_to_user(hreq->ohandle, &handle, hsize) ||
62246 + if (hsize > sizeof handle || copy_to_user(hreq->ohandle, &handle, hsize) ||
62247 copy_to_user(hreq->ohandlen, &hsize, sizeof(__s32)))
62248 goto out_put;
62249
62250 diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
62251 index 2b8952d..a60c6be 100644
62252 --- a/fs/xfs/xfs_iops.c
62253 +++ b/fs/xfs/xfs_iops.c
62254 @@ -401,7 +401,7 @@ xfs_vn_put_link(
62255 struct nameidata *nd,
62256 void *p)
62257 {
62258 - char *s = nd_get_link(nd);
62259 + const char *s = nd_get_link(nd);
62260
62261 if (!IS_ERR(s))
62262 kfree(s);
62263 diff --git a/grsecurity/Kconfig b/grsecurity/Kconfig
62264 new file mode 100644
62265 index 0000000..a78d810
62266 --- /dev/null
62267 +++ b/grsecurity/Kconfig
62268 @@ -0,0 +1,1107 @@
62269 +#
62270 +# grecurity configuration
62271 +#
62272 +menu "Memory Protections"
62273 +depends on GRKERNSEC
62274 +
62275 +config GRKERNSEC_KMEM
62276 + bool "Deny reading/writing to /dev/kmem, /dev/mem, and /dev/port"
62277 + default y if GRKERNSEC_CONFIG_AUTO
62278 + select STRICT_DEVMEM if (X86 || ARM || TILE || S390)
62279 + help
62280 + If you say Y here, /dev/kmem and /dev/mem won't be allowed to
62281 + be written to or read from to modify or leak the contents of the running
62282 + kernel. /dev/port will also not be allowed to be opened, and support
62283 + for /dev/cpu/*/msr and kexec will be removed. If you have module
62284 + support disabled, enabling this will close up six ways that are
62285 + currently used to insert malicious code into the running kernel.
62286 +
62287 + Even with this feature enabled, we still highly recommend that
62288 + you use the RBAC system, as it is still possible for an attacker to
62289 + modify the running kernel through other more obscure methods.
62290 +
62291 + Enabling this feature will prevent the "cpupower" and "powertop" tools
62292 + from working.
62293 +
62294 + It is highly recommended that you say Y here if you meet all the
62295 + conditions above.
62296 +
62297 +config GRKERNSEC_VM86
62298 + bool "Restrict VM86 mode"
62299 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
62300 + depends on X86_32
62301 +
62302 + help
62303 + If you say Y here, only processes with CAP_SYS_RAWIO will be able to
62304 + make use of a special execution mode on 32bit x86 processors called
62305 + Virtual 8086 (VM86) mode. XFree86 may need vm86 mode for certain
62306 + video cards and will still work with this option enabled. The purpose
62307 + of the option is to prevent exploitation of emulation errors in
62308 + virtualization of vm86 mode like the one discovered in VMWare in 2009.
62309 + Nearly all users should be able to enable this option.
62310 +
62311 +config GRKERNSEC_IO
62312 + bool "Disable privileged I/O"
62313 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
62314 + depends on X86
62315 + select RTC_CLASS
62316 + select RTC_INTF_DEV
62317 + select RTC_DRV_CMOS
62318 +
62319 + help
62320 + If you say Y here, all ioperm and iopl calls will return an error.
62321 + Ioperm and iopl can be used to modify the running kernel.
62322 + Unfortunately, some programs need this access to operate properly,
62323 + the most notable of which are XFree86 and hwclock. hwclock can be
62324 + remedied by having RTC support in the kernel, so real-time
62325 + clock support is enabled if this option is enabled, to ensure
62326 + that hwclock operates correctly.
62327 +
62328 + If you're using XFree86 or a version of Xorg from 2012 or earlier,
62329 + you may not be able to boot into a graphical environment with this
62330 + option enabled. In this case, you should use the RBAC system instead.
62331 +
62332 +config GRKERNSEC_JIT_HARDEN
62333 + bool "Harden BPF JIT against spray attacks"
62334 + default y if GRKERNSEC_CONFIG_AUTO
62335 + depends on BPF_JIT
62336 + help
62337 + If you say Y here, the native code generated by the kernel's Berkeley
62338 + Packet Filter (BPF) JIT engine will be hardened against JIT-spraying
62339 + attacks that attempt to fit attacker-beneficial instructions in
62340 + 32bit immediate fields of JIT-generated native instructions. The
62341 + attacker will generally aim to cause an unintended instruction sequence
62342 + of JIT-generated native code to execute by jumping into the middle of
62343 + a generated instruction. This feature effectively randomizes the 32bit
62344 + immediate constants present in the generated code to thwart such attacks.
62345 +
62346 + If you're using KERNEXEC, it's recommended that you enable this option
62347 + to supplement the hardening of the kernel.
62348 +
62349 +config GRKERNSEC_PERF_HARDEN
62350 + bool "Disable unprivileged PERF_EVENTS usage by default"
62351 + default y if GRKERNSEC_CONFIG_AUTO
62352 + depends on PERF_EVENTS
62353 + help
62354 + If you say Y here, the range of acceptable values for the
62355 + /proc/sys/kernel/perf_event_paranoid sysctl will be expanded to allow and
62356 + default to a new value: 3. When the sysctl is set to this value, no
62357 + unprivileged use of the PERF_EVENTS syscall interface will be permitted.
62358 +
62359 + Though PERF_EVENTS can be used legitimately for performance monitoring
62360 + and low-level application profiling, it is forced on regardless of
62361 + configuration, has been at fault for several vulnerabilities, and
62362 + creates new opportunities for side channels and other information leaks.
62363 +
62364 + This feature puts PERF_EVENTS into a secure default state and permits
62365 + the administrator to change out of it temporarily if unprivileged
62366 + application profiling is needed.
62367 +
62368 +config GRKERNSEC_RAND_THREADSTACK
62369 + bool "Insert random gaps between thread stacks"
62370 + default y if GRKERNSEC_CONFIG_AUTO
62371 + depends on PAX_RANDMMAP && !PPC
62372 + help
62373 + If you say Y here, a random-sized gap will be enforced between allocated
62374 + thread stacks. Glibc's NPTL and other threading libraries that
62375 + pass MAP_STACK to the kernel for thread stack allocation are supported.
62376 + The implementation currently provides 8 bits of entropy for the gap.
62377 +
62378 + Many distributions do not compile threaded remote services with the
62379 + -fstack-check argument to GCC, causing the variable-sized stack-based
62380 + allocator, alloca(), to not probe the stack on allocation. This
62381 + permits an unbounded alloca() to skip over any guard page and potentially
62382 + modify another thread's stack reliably. An enforced random gap
62383 + reduces the reliability of such an attack and increases the chance
62384 + that such a read/write to another thread's stack instead lands in
62385 + an unmapped area, causing a crash and triggering grsecurity's
62386 + anti-bruteforcing logic.
62387 +
62388 +config GRKERNSEC_PROC_MEMMAP
62389 + bool "Harden ASLR against information leaks and entropy reduction"
62390 + default y if (GRKERNSEC_CONFIG_AUTO || PAX_NOEXEC || PAX_ASLR)
62391 + depends on PAX_NOEXEC || PAX_ASLR
62392 + help
62393 + If you say Y here, the /proc/<pid>/maps and /proc/<pid>/stat files will
62394 + give no information about the addresses of its mappings if
62395 + PaX features that rely on random addresses are enabled on the task.
62396 + In addition to sanitizing this information and disabling other
62397 + dangerous sources of information, this option causes reads of sensitive
62398 + /proc/<pid> entries where the file descriptor was opened in a different
62399 + task than the one performing the read. Such attempts are logged.
62400 + This option also limits argv/env strings for suid/sgid binaries
62401 + to 512KB to prevent a complete exhaustion of the stack entropy provided
62402 + by ASLR. Finally, it places an 8MB stack resource limit on suid/sgid
62403 + binaries to prevent alternative mmap layouts from being abused.
62404 +
62405 + If you use PaX it is essential that you say Y here as it closes up
62406 + several holes that make full ASLR useless locally.
62407 +
62408 +config GRKERNSEC_BRUTE
62409 + bool "Deter exploit bruteforcing"
62410 + default y if GRKERNSEC_CONFIG_AUTO
62411 + help
62412 + If you say Y here, attempts to bruteforce exploits against forking
62413 + daemons such as apache or sshd, as well as against suid/sgid binaries
62414 + will be deterred. When a child of a forking daemon is killed by PaX
62415 + or crashes due to an illegal instruction or other suspicious signal,
62416 + the parent process will be delayed 30 seconds upon every subsequent
62417 + fork until the administrator is able to assess the situation and
62418 + restart the daemon.
62419 + In the suid/sgid case, the attempt is logged, the user has all their
62420 + existing instances of the suid/sgid binary terminated and will
62421 + be unable to execute any suid/sgid binaries for 15 minutes.
62422 +
62423 + It is recommended that you also enable signal logging in the auditing
62424 + section so that logs are generated when a process triggers a suspicious
62425 + signal.
62426 + If the sysctl option is enabled, a sysctl option with name
62427 + "deter_bruteforce" is created.
62428 +
62429 +
62430 +config GRKERNSEC_MODHARDEN
62431 + bool "Harden module auto-loading"
62432 + default y if GRKERNSEC_CONFIG_AUTO
62433 + depends on MODULES
62434 + help
62435 + If you say Y here, module auto-loading in response to use of some
62436 + feature implemented by an unloaded module will be restricted to
62437 + root users. Enabling this option helps defend against attacks
62438 + by unprivileged users who abuse the auto-loading behavior to
62439 + cause a vulnerable module to load that is then exploited.
62440 +
62441 + If this option prevents a legitimate use of auto-loading for a
62442 + non-root user, the administrator can execute modprobe manually
62443 + with the exact name of the module mentioned in the alert log.
62444 + Alternatively, the administrator can add the module to the list
62445 + of modules loaded at boot by modifying init scripts.
62446 +
62447 + Modification of init scripts will most likely be needed on
62448 + Ubuntu servers with encrypted home directory support enabled,
62449 + as the first non-root user logging in will cause the ecb(aes),
62450 + ecb(aes)-all, cbc(aes), and cbc(aes)-all modules to be loaded.
62451 +
62452 +config GRKERNSEC_HIDESYM
62453 + bool "Hide kernel symbols"
62454 + default y if GRKERNSEC_CONFIG_AUTO
62455 + select PAX_USERCOPY_SLABS
62456 + help
62457 + If you say Y here, getting information on loaded modules, and
62458 + displaying all kernel symbols through a syscall will be restricted
62459 + to users with CAP_SYS_MODULE. For software compatibility reasons,
62460 + /proc/kallsyms will be restricted to the root user. The RBAC
62461 + system can hide that entry even from root.
62462 +
62463 + This option also prevents leaking of kernel addresses through
62464 + several /proc entries.
62465 +
62466 + Note that this option is only effective provided the following
62467 + conditions are met:
62468 + 1) The kernel using grsecurity is not precompiled by some distribution
62469 + 2) You have also enabled GRKERNSEC_DMESG
62470 + 3) You are using the RBAC system and hiding other files such as your
62471 + kernel image and System.map. Alternatively, enabling this option
62472 + causes the permissions on /boot, /lib/modules, and the kernel
62473 + source directory to change at compile time to prevent
62474 + reading by non-root users.
62475 + If the above conditions are met, this option will aid in providing a
62476 + useful protection against local kernel exploitation of overflows
62477 + and arbitrary read/write vulnerabilities.
62478 +
62479 + It is highly recommended that you enable GRKERNSEC_PERF_HARDEN
62480 + in addition to this feature.
62481 +
62482 +config GRKERNSEC_KERN_LOCKOUT
62483 + bool "Active kernel exploit response"
62484 + default y if GRKERNSEC_CONFIG_AUTO
62485 + depends on X86 || ARM || PPC || SPARC
62486 + help
62487 + If you say Y here, when a PaX alert is triggered due to suspicious
62488 + activity in the kernel (from KERNEXEC/UDEREF/USERCOPY)
62489 + or an OOPS occurs due to bad memory accesses, instead of just
62490 + terminating the offending process (and potentially allowing
62491 + a subsequent exploit from the same user), we will take one of two
62492 + actions:
62493 + If the user was root, we will panic the system
62494 + If the user was non-root, we will log the attempt, terminate
62495 + all processes owned by the user, then prevent them from creating
62496 + any new processes until the system is restarted
62497 + This deters repeated kernel exploitation/bruteforcing attempts
62498 + and is useful for later forensics.
62499 +
62500 +config GRKERNSEC_OLD_ARM_USERLAND
62501 + bool "Old ARM userland compatibility"
62502 + depends on ARM && (CPU_V6 || CPU_V6K || CPU_V7)
62503 + help
62504 + If you say Y here, stubs of executable code to perform such operations
62505 + as "compare-exchange" will be placed at fixed locations in the ARM vector
62506 + table. This is unfortunately needed for old ARM userland meant to run
62507 + across a wide range of processors. Without this option enabled,
62508 + the get_tls and data memory barrier stubs will be emulated by the kernel,
62509 + which is enough for Linaro userlands or other userlands designed for v6
62510 + and newer ARM CPUs. It's recommended that you try without this option enabled
62511 + first, and only enable it if your userland does not boot (it will likely fail
62512 + at init time).
62513 +
62514 +endmenu
62515 +menu "Role Based Access Control Options"
62516 +depends on GRKERNSEC
62517 +
62518 +config GRKERNSEC_RBAC_DEBUG
62519 + bool
62520 +
62521 +config GRKERNSEC_NO_RBAC
62522 + bool "Disable RBAC system"
62523 + help
62524 + If you say Y here, the /dev/grsec device will be removed from the kernel,
62525 + preventing the RBAC system from being enabled. You should only say Y
62526 + here if you have no intention of using the RBAC system, so as to prevent
62527 + an attacker with root access from misusing the RBAC system to hide files
62528 + and processes when loadable module support and /dev/[k]mem have been
62529 + locked down.
62530 +
62531 +config GRKERNSEC_ACL_HIDEKERN
62532 + bool "Hide kernel processes"
62533 + help
62534 + If you say Y here, all kernel threads will be hidden to all
62535 + processes but those whose subject has the "view hidden processes"
62536 + flag.
62537 +
62538 +config GRKERNSEC_ACL_MAXTRIES
62539 + int "Maximum tries before password lockout"
62540 + default 3
62541 + help
62542 + This option enforces the maximum number of times a user can attempt
62543 + to authorize themselves with the grsecurity RBAC system before being
62544 + denied the ability to attempt authorization again for a specified time.
62545 + The lower the number, the harder it will be to brute-force a password.
62546 +
62547 +config GRKERNSEC_ACL_TIMEOUT
62548 + int "Time to wait after max password tries, in seconds"
62549 + default 30
62550 + help
62551 + This option specifies the time the user must wait after attempting to
62552 + authorize to the RBAC system with the maximum number of invalid
62553 + passwords. The higher the number, the harder it will be to brute-force
62554 + a password.
62555 +
62556 +endmenu
62557 +menu "Filesystem Protections"
62558 +depends on GRKERNSEC
62559 +
62560 +config GRKERNSEC_PROC
62561 + bool "Proc restrictions"
62562 + default y if GRKERNSEC_CONFIG_AUTO
62563 + help
62564 + If you say Y here, the permissions of the /proc filesystem
62565 + will be altered to enhance system security and privacy. You MUST
62566 + choose either a user only restriction or a user and group restriction.
62567 + Depending upon the option you choose, you can either restrict users to
62568 + see only the processes they themselves run, or choose a group that can
62569 + view all processes and files normally restricted to root if you choose
62570 + the "restrict to user only" option. NOTE: If you're running identd or
62571 + ntpd as a non-root user, you will have to run it as the group you
62572 + specify here.
62573 +
62574 +config GRKERNSEC_PROC_USER
62575 + bool "Restrict /proc to user only"
62576 + depends on GRKERNSEC_PROC
62577 + help
62578 + If you say Y here, non-root users will only be able to view their own
62579 + processes, and restricts them from viewing network-related information,
62580 + and viewing kernel symbol and module information.
62581 +
62582 +config GRKERNSEC_PROC_USERGROUP
62583 + bool "Allow special group"
62584 + default y if GRKERNSEC_CONFIG_AUTO
62585 + depends on GRKERNSEC_PROC && !GRKERNSEC_PROC_USER
62586 + help
62587 + If you say Y here, you will be able to select a group that will be
62588 + able to view all processes and network-related information. If you've
62589 + enabled GRKERNSEC_HIDESYM, kernel and symbol information may still
62590 + remain hidden. This option is useful if you want to run identd as
62591 + a non-root user. The group you select may also be chosen at boot time
62592 + via "grsec_proc_gid=" on the kernel commandline.
62593 +
62594 +config GRKERNSEC_PROC_GID
62595 + int "GID for special group"
62596 + depends on GRKERNSEC_PROC_USERGROUP
62597 + default 1001
62598 +
62599 +config GRKERNSEC_PROC_ADD
62600 + bool "Additional restrictions"
62601 + default y if GRKERNSEC_CONFIG_AUTO
62602 + depends on GRKERNSEC_PROC_USER || GRKERNSEC_PROC_USERGROUP
62603 + help
62604 + If you say Y here, additional restrictions will be placed on
62605 + /proc that keep normal users from viewing device information and
62606 + slabinfo information that could be useful for exploits.
62607 +
62608 +config GRKERNSEC_LINK
62609 + bool "Linking restrictions"
62610 + default y if GRKERNSEC_CONFIG_AUTO
62611 + help
62612 + If you say Y here, /tmp race exploits will be prevented, since users
62613 + will no longer be able to follow symlinks owned by other users in
62614 + world-writable +t directories (e.g. /tmp), unless the owner of the
62615 + symlink is the owner of the directory. users will also not be
62616 + able to hardlink to files they do not own. If the sysctl option is
62617 + enabled, a sysctl option with name "linking_restrictions" is created.
62618 +
62619 +config GRKERNSEC_SYMLINKOWN
62620 + bool "Kernel-enforced SymlinksIfOwnerMatch"
62621 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
62622 + help
62623 + Apache's SymlinksIfOwnerMatch option has an inherent race condition
62624 + that prevents it from being used as a security feature. As Apache
62625 + verifies the symlink by performing a stat() against the target of
62626 + the symlink before it is followed, an attacker can setup a symlink
62627 + to point to a same-owned file, then replace the symlink with one
62628 + that targets another user's file just after Apache "validates" the
62629 + symlink -- a classic TOCTOU race. If you say Y here, a complete,
62630 + race-free replacement for Apache's "SymlinksIfOwnerMatch" option
62631 + will be in place for the group you specify. If the sysctl option
62632 + is enabled, a sysctl option with name "enforce_symlinksifowner" is
62633 + created.
62634 +
62635 +config GRKERNSEC_SYMLINKOWN_GID
62636 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
62637 + depends on GRKERNSEC_SYMLINKOWN
62638 + default 1006
62639 + help
62640 + Setting this GID determines what group kernel-enforced
62641 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
62642 + is enabled, a sysctl option with name "symlinkown_gid" is created.
62643 +
62644 +config GRKERNSEC_FIFO
62645 + bool "FIFO restrictions"
62646 + default y if GRKERNSEC_CONFIG_AUTO
62647 + help
62648 + If you say Y here, users will not be able to write to FIFOs they don't
62649 + own in world-writable +t directories (e.g. /tmp), unless the owner of
62650 + the FIFO is the same owner of the directory it's held in. If the sysctl
62651 + option is enabled, a sysctl option with name "fifo_restrictions" is
62652 + created.
62653 +
62654 +config GRKERNSEC_SYSFS_RESTRICT
62655 + bool "Sysfs/debugfs restriction"
62656 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
62657 + depends on SYSFS
62658 + help
62659 + If you say Y here, sysfs (the pseudo-filesystem mounted at /sys) and
62660 + any filesystem normally mounted under it (e.g. debugfs) will be
62661 + mostly accessible only by root. These filesystems generally provide access
62662 + to hardware and debug information that isn't appropriate for unprivileged
62663 + users of the system. Sysfs and debugfs have also become a large source
62664 + of new vulnerabilities, ranging from infoleaks to local compromise.
62665 + There has been very little oversight with an eye toward security involved
62666 + in adding new exporters of information to these filesystems, so their
62667 + use is discouraged.
62668 + For reasons of compatibility, a few directories have been whitelisted
62669 + for access by non-root users:
62670 + /sys/fs/selinux
62671 + /sys/fs/fuse
62672 + /sys/devices/system/cpu
62673 +
62674 +config GRKERNSEC_ROFS
62675 + bool "Runtime read-only mount protection"
62676 + depends on SYSCTL
62677 + help
62678 + If you say Y here, a sysctl option with name "romount_protect" will
62679 + be created. By setting this option to 1 at runtime, filesystems
62680 + will be protected in the following ways:
62681 + * No new writable mounts will be allowed
62682 + * Existing read-only mounts won't be able to be remounted read/write
62683 + * Write operations will be denied on all block devices
62684 + This option acts independently of grsec_lock: once it is set to 1,
62685 + it cannot be turned off. Therefore, please be mindful of the resulting
62686 + behavior if this option is enabled in an init script on a read-only
62687 + filesystem. This feature is mainly intended for secure embedded systems.
62688 +
62689 +config GRKERNSEC_DEVICE_SIDECHANNEL
62690 + bool "Eliminate stat/notify-based device sidechannels"
62691 + default y if GRKERNSEC_CONFIG_AUTO
62692 + help
62693 + If you say Y here, timing analyses on block or character
62694 + devices like /dev/ptmx using stat or inotify/dnotify/fanotify
62695 + will be thwarted for unprivileged users. If a process without
62696 + CAP_MKNOD stats such a device, the last access and last modify times
62697 + will match the device's create time. No access or modify events
62698 + will be triggered through inotify/dnotify/fanotify for such devices.
62699 + This feature will prevent attacks that may at a minimum
62700 + allow an attacker to determine the administrator's password length.
62701 +
62702 +config GRKERNSEC_CHROOT
62703 + bool "Chroot jail restrictions"
62704 + default y if GRKERNSEC_CONFIG_AUTO
62705 + help
62706 + If you say Y here, you will be able to choose several options that will
62707 + make breaking out of a chrooted jail much more difficult. If you
62708 + encounter no software incompatibilities with the following options, it
62709 + is recommended that you enable each one.
62710 +
62711 +config GRKERNSEC_CHROOT_MOUNT
62712 + bool "Deny mounts"
62713 + default y if GRKERNSEC_CONFIG_AUTO
62714 + depends on GRKERNSEC_CHROOT
62715 + help
62716 + If you say Y here, processes inside a chroot will not be able to
62717 + mount or remount filesystems. If the sysctl option is enabled, a
62718 + sysctl option with name "chroot_deny_mount" is created.
62719 +
62720 +config GRKERNSEC_CHROOT_DOUBLE
62721 + bool "Deny double-chroots"
62722 + default y if GRKERNSEC_CONFIG_AUTO
62723 + depends on GRKERNSEC_CHROOT
62724 + help
62725 + If you say Y here, processes inside a chroot will not be able to chroot
62726 + again outside the chroot. This is a widely used method of breaking
62727 + out of a chroot jail and should not be allowed. If the sysctl
62728 + option is enabled, a sysctl option with name
62729 + "chroot_deny_chroot" is created.
62730 +
62731 +config GRKERNSEC_CHROOT_PIVOT
62732 + bool "Deny pivot_root in chroot"
62733 + default y if GRKERNSEC_CONFIG_AUTO
62734 + depends on GRKERNSEC_CHROOT
62735 + help
62736 + If you say Y here, processes inside a chroot will not be able to use
62737 + a function called pivot_root() that was introduced in Linux 2.3.41. It
62738 + works similar to chroot in that it changes the root filesystem. This
62739 + function could be misused in a chrooted process to attempt to break out
62740 + of the chroot, and therefore should not be allowed. If the sysctl
62741 + option is enabled, a sysctl option with name "chroot_deny_pivot" is
62742 + created.
62743 +
62744 +config GRKERNSEC_CHROOT_CHDIR
62745 + bool "Enforce chdir(\"/\") on all chroots"
62746 + default y if GRKERNSEC_CONFIG_AUTO
62747 + depends on GRKERNSEC_CHROOT
62748 + help
62749 + If you say Y here, the current working directory of all newly-chrooted
62750 + applications will be set to the the root directory of the chroot.
62751 + The man page on chroot(2) states:
62752 + Note that this call does not change the current working
62753 + directory, so that `.' can be outside the tree rooted at
62754 + `/'. In particular, the super-user can escape from a
62755 + `chroot jail' by doing `mkdir foo; chroot foo; cd ..'.
62756 +
62757 + It is recommended that you say Y here, since it's not known to break
62758 + any software. If the sysctl option is enabled, a sysctl option with
62759 + name "chroot_enforce_chdir" is created.
62760 +
62761 +config GRKERNSEC_CHROOT_CHMOD
62762 + bool "Deny (f)chmod +s"
62763 + default y if GRKERNSEC_CONFIG_AUTO
62764 + depends on GRKERNSEC_CHROOT
62765 + help
62766 + If you say Y here, processes inside a chroot will not be able to chmod
62767 + or fchmod files to make them have suid or sgid bits. This protects
62768 + against another published method of breaking a chroot. If the sysctl
62769 + option is enabled, a sysctl option with name "chroot_deny_chmod" is
62770 + created.
62771 +
62772 +config GRKERNSEC_CHROOT_FCHDIR
62773 + bool "Deny fchdir out of chroot"
62774 + default y if GRKERNSEC_CONFIG_AUTO
62775 + depends on GRKERNSEC_CHROOT
62776 + help
62777 + If you say Y here, a well-known method of breaking chroots by fchdir'ing
62778 + to a file descriptor of the chrooting process that points to a directory
62779 + outside the filesystem will be stopped. If the sysctl option
62780 + is enabled, a sysctl option with name "chroot_deny_fchdir" is created.
62781 +
62782 +config GRKERNSEC_CHROOT_MKNOD
62783 + bool "Deny mknod"
62784 + default y if GRKERNSEC_CONFIG_AUTO
62785 + depends on GRKERNSEC_CHROOT
62786 + help
62787 + If you say Y here, processes inside a chroot will not be allowed to
62788 + mknod. The problem with using mknod inside a chroot is that it
62789 + would allow an attacker to create a device entry that is the same
62790 + as one on the physical root of your system, which could range from
62791 + anything from the console device to a device for your harddrive (which
62792 + they could then use to wipe the drive or steal data). It is recommended
62793 + that you say Y here, unless you run into software incompatibilities.
62794 + If the sysctl option is enabled, a sysctl option with name
62795 + "chroot_deny_mknod" is created.
62796 +
62797 +config GRKERNSEC_CHROOT_SHMAT
62798 + bool "Deny shmat() out of chroot"
62799 + default y if GRKERNSEC_CONFIG_AUTO
62800 + depends on GRKERNSEC_CHROOT
62801 + help
62802 + If you say Y here, processes inside a chroot will not be able to attach
62803 + to shared memory segments that were created outside of the chroot jail.
62804 + It is recommended that you say Y here. If the sysctl option is enabled,
62805 + a sysctl option with name "chroot_deny_shmat" is created.
62806 +
62807 +config GRKERNSEC_CHROOT_UNIX
62808 + bool "Deny access to abstract AF_UNIX sockets out of chroot"
62809 + default y if GRKERNSEC_CONFIG_AUTO
62810 + depends on GRKERNSEC_CHROOT
62811 + help
62812 + If you say Y here, processes inside a chroot will not be able to
62813 + connect to abstract (meaning not belonging to a filesystem) Unix
62814 + domain sockets that were bound outside of a chroot. It is recommended
62815 + that you say Y here. If the sysctl option is enabled, a sysctl option
62816 + with name "chroot_deny_unix" is created.
62817 +
62818 +config GRKERNSEC_CHROOT_FINDTASK
62819 + bool "Protect outside processes"
62820 + default y if GRKERNSEC_CONFIG_AUTO
62821 + depends on GRKERNSEC_CHROOT
62822 + help
62823 + If you say Y here, processes inside a chroot will not be able to
62824 + kill, send signals with fcntl, ptrace, capget, getpgid, setpgid,
62825 + getsid, or view any process outside of the chroot. If the sysctl
62826 + option is enabled, a sysctl option with name "chroot_findtask" is
62827 + created.
62828 +
62829 +config GRKERNSEC_CHROOT_NICE
62830 + bool "Restrict priority changes"
62831 + default y if GRKERNSEC_CONFIG_AUTO
62832 + depends on GRKERNSEC_CHROOT
62833 + help
62834 + If you say Y here, processes inside a chroot will not be able to raise
62835 + the priority of processes in the chroot, or alter the priority of
62836 + processes outside the chroot. This provides more security than simply
62837 + removing CAP_SYS_NICE from the process' capability set. If the
62838 + sysctl option is enabled, a sysctl option with name "chroot_restrict_nice"
62839 + is created.
62840 +
62841 +config GRKERNSEC_CHROOT_SYSCTL
62842 + bool "Deny sysctl writes"
62843 + default y if GRKERNSEC_CONFIG_AUTO
62844 + depends on GRKERNSEC_CHROOT
62845 + help
62846 + If you say Y here, an attacker in a chroot will not be able to
62847 + write to sysctl entries, either by sysctl(2) or through a /proc
62848 + interface. It is strongly recommended that you say Y here. If the
62849 + sysctl option is enabled, a sysctl option with name
62850 + "chroot_deny_sysctl" is created.
62851 +
62852 +config GRKERNSEC_CHROOT_CAPS
62853 + bool "Capability restrictions"
62854 + default y if GRKERNSEC_CONFIG_AUTO
62855 + depends on GRKERNSEC_CHROOT
62856 + help
62857 + If you say Y here, the capabilities on all processes within a
62858 + chroot jail will be lowered to stop module insertion, raw i/o,
62859 + system and net admin tasks, rebooting the system, modifying immutable
62860 + files, modifying IPC owned by another, and changing the system time.
62861 + This is left an option because it can break some apps. Disable this
62862 + if your chrooted apps are having problems performing those kinds of
62863 + tasks. If the sysctl option is enabled, a sysctl option with
62864 + name "chroot_caps" is created.
62865 +
62866 +config GRKERNSEC_CHROOT_INITRD
62867 + bool "Exempt initrd tasks from restrictions"
62868 + default y if GRKERNSEC_CONFIG_AUTO
62869 + depends on GRKERNSEC_CHROOT && BLK_DEV_INITRD
62870 + help
62871 + If you say Y here, tasks started prior to init will be exempted from
62872 + grsecurity's chroot restrictions. This option is mainly meant to
62873 + resolve Plymouth's performing privileged operations unnecessarily
62874 + in a chroot.
62875 +
62876 +endmenu
62877 +menu "Kernel Auditing"
62878 +depends on GRKERNSEC
62879 +
62880 +config GRKERNSEC_AUDIT_GROUP
62881 + bool "Single group for auditing"
62882 + help
62883 + If you say Y here, the exec and chdir logging features will only operate
62884 + on a group you specify. This option is recommended if you only want to
62885 + watch certain users instead of having a large amount of logs from the
62886 + entire system. If the sysctl option is enabled, a sysctl option with
62887 + name "audit_group" is created.
62888 +
62889 +config GRKERNSEC_AUDIT_GID
62890 + int "GID for auditing"
62891 + depends on GRKERNSEC_AUDIT_GROUP
62892 + default 1007
62893 +
62894 +config GRKERNSEC_EXECLOG
62895 + bool "Exec logging"
62896 + help
62897 + If you say Y here, all execve() calls will be logged (since the
62898 + other exec*() calls are frontends to execve(), all execution
62899 + will be logged). Useful for shell-servers that like to keep track
62900 + of their users. If the sysctl option is enabled, a sysctl option with
62901 + name "exec_logging" is created.
62902 + WARNING: This option when enabled will produce a LOT of logs, especially
62903 + on an active system.
62904 +
62905 +config GRKERNSEC_RESLOG
62906 + bool "Resource logging"
62907 + default y if GRKERNSEC_CONFIG_AUTO
62908 + help
62909 + If you say Y here, all attempts to overstep resource limits will
62910 + be logged with the resource name, the requested size, and the current
62911 + limit. It is highly recommended that you say Y here. If the sysctl
62912 + option is enabled, a sysctl option with name "resource_logging" is
62913 + created. If the RBAC system is enabled, the sysctl value is ignored.
62914 +
62915 +config GRKERNSEC_CHROOT_EXECLOG
62916 + bool "Log execs within chroot"
62917 + help
62918 + If you say Y here, all executions inside a chroot jail will be logged
62919 + to syslog. This can cause a large amount of logs if certain
62920 + applications (eg. djb's daemontools) are installed on the system, and
62921 + is therefore left as an option. If the sysctl option is enabled, a
62922 + sysctl option with name "chroot_execlog" is created.
62923 +
62924 +config GRKERNSEC_AUDIT_PTRACE
62925 + bool "Ptrace logging"
62926 + help
62927 + If you say Y here, all attempts to attach to a process via ptrace
62928 + will be logged. If the sysctl option is enabled, a sysctl option
62929 + with name "audit_ptrace" is created.
62930 +
62931 +config GRKERNSEC_AUDIT_CHDIR
62932 + bool "Chdir logging"
62933 + help
62934 + If you say Y here, all chdir() calls will be logged. If the sysctl
62935 + option is enabled, a sysctl option with name "audit_chdir" is created.
62936 +
62937 +config GRKERNSEC_AUDIT_MOUNT
62938 + bool "(Un)Mount logging"
62939 + help
62940 + If you say Y here, all mounts and unmounts will be logged. If the
62941 + sysctl option is enabled, a sysctl option with name "audit_mount" is
62942 + created.
62943 +
62944 +config GRKERNSEC_SIGNAL
62945 + bool "Signal logging"
62946 + default y if GRKERNSEC_CONFIG_AUTO
62947 + help
62948 + If you say Y here, certain important signals will be logged, such as
62949 + SIGSEGV, which will as a result inform you of when a error in a program
62950 + occurred, which in some cases could mean a possible exploit attempt.
62951 + If the sysctl option is enabled, a sysctl option with name
62952 + "signal_logging" is created.
62953 +
62954 +config GRKERNSEC_FORKFAIL
62955 + bool "Fork failure logging"
62956 + help
62957 + If you say Y here, all failed fork() attempts will be logged.
62958 + This could suggest a fork bomb, or someone attempting to overstep
62959 + their process limit. If the sysctl option is enabled, a sysctl option
62960 + with name "forkfail_logging" is created.
62961 +
62962 +config GRKERNSEC_TIME
62963 + bool "Time change logging"
62964 + default y if GRKERNSEC_CONFIG_AUTO
62965 + help
62966 + If you say Y here, any changes of the system clock will be logged.
62967 + If the sysctl option is enabled, a sysctl option with name
62968 + "timechange_logging" is created.
62969 +
62970 +config GRKERNSEC_PROC_IPADDR
62971 + bool "/proc/<pid>/ipaddr support"
62972 + default y if GRKERNSEC_CONFIG_AUTO
62973 + help
62974 + If you say Y here, a new entry will be added to each /proc/<pid>
62975 + directory that contains the IP address of the person using the task.
62976 + The IP is carried across local TCP and AF_UNIX stream sockets.
62977 + This information can be useful for IDS/IPSes to perform remote response
62978 + to a local attack. The entry is readable by only the owner of the
62979 + process (and root if he has CAP_DAC_OVERRIDE, which can be removed via
62980 + the RBAC system), and thus does not create privacy concerns.
62981 +
62982 +config GRKERNSEC_RWXMAP_LOG
62983 + bool 'Denied RWX mmap/mprotect logging'
62984 + default y if GRKERNSEC_CONFIG_AUTO
62985 + depends on PAX_MPROTECT && !PAX_EMUPLT && !PAX_EMUSIGRT
62986 + help
62987 + If you say Y here, calls to mmap() and mprotect() with explicit
62988 + usage of PROT_WRITE and PROT_EXEC together will be logged when
62989 + denied by the PAX_MPROTECT feature. This feature will also
62990 + log other problematic scenarios that can occur when PAX_MPROTECT
62991 + is enabled on a binary, like textrels and PT_GNU_STACK. If the
62992 + sysctl option is enabled, a sysctl option with name "rwxmap_logging"
62993 + is created.
62994 +
62995 +endmenu
62996 +
62997 +menu "Executable Protections"
62998 +depends on GRKERNSEC
62999 +
63000 +config GRKERNSEC_DMESG
63001 + bool "Dmesg(8) restriction"
63002 + default y if GRKERNSEC_CONFIG_AUTO
63003 + help
63004 + If you say Y here, non-root users will not be able to use dmesg(8)
63005 + to view the contents of the kernel's circular log buffer.
63006 + The kernel's log buffer often contains kernel addresses and other
63007 + identifying information useful to an attacker in fingerprinting a
63008 + system for a targeted exploit.
63009 + If the sysctl option is enabled, a sysctl option with name "dmesg" is
63010 + created.
63011 +
63012 +config GRKERNSEC_HARDEN_PTRACE
63013 + bool "Deter ptrace-based process snooping"
63014 + default y if GRKERNSEC_CONFIG_AUTO
63015 + help
63016 + If you say Y here, TTY sniffers and other malicious monitoring
63017 + programs implemented through ptrace will be defeated. If you
63018 + have been using the RBAC system, this option has already been
63019 + enabled for several years for all users, with the ability to make
63020 + fine-grained exceptions.
63021 +
63022 + This option only affects the ability of non-root users to ptrace
63023 + processes that are not a descendent of the ptracing process.
63024 + This means that strace ./binary and gdb ./binary will still work,
63025 + but attaching to arbitrary processes will not. If the sysctl
63026 + option is enabled, a sysctl option with name "harden_ptrace" is
63027 + created.
63028 +
63029 +config GRKERNSEC_PTRACE_READEXEC
63030 + bool "Require read access to ptrace sensitive binaries"
63031 + default y if GRKERNSEC_CONFIG_AUTO
63032 + help
63033 + If you say Y here, unprivileged users will not be able to ptrace unreadable
63034 + binaries. This option is useful in environments that
63035 + remove the read bits (e.g. file mode 4711) from suid binaries to
63036 + prevent infoleaking of their contents. This option adds
63037 + consistency to the use of that file mode, as the binary could normally
63038 + be read out when run without privileges while ptracing.
63039 +
63040 + If the sysctl option is enabled, a sysctl option with name "ptrace_readexec"
63041 + is created.
63042 +
63043 +config GRKERNSEC_SETXID
63044 + bool "Enforce consistent multithreaded privileges"
63045 + default y if GRKERNSEC_CONFIG_AUTO
63046 + depends on (X86 || SPARC64 || PPC || ARM || MIPS)
63047 + help
63048 + If you say Y here, a change from a root uid to a non-root uid
63049 + in a multithreaded application will cause the resulting uids,
63050 + gids, supplementary groups, and capabilities in that thread
63051 + to be propagated to the other threads of the process. In most
63052 + cases this is unnecessary, as glibc will emulate this behavior
63053 + on behalf of the application. Other libcs do not act in the
63054 + same way, allowing the other threads of the process to continue
63055 + running with root privileges. If the sysctl option is enabled,
63056 + a sysctl option with name "consistent_setxid" is created.
63057 +
63058 +config GRKERNSEC_HARDEN_IPC
63059 + bool "Disallow access to world-accessible IPC objects"
63060 + default y if GRKERNSEC_CONFIG_AUTO
63061 + depends on SYSVIPC
63062 + help
63063 + If you say Y here, access to overly-permissive IPC (shared memory,
63064 + message queues, and semaphores) will be denied for processes whose
63065 + effective user or group would not grant them permission. It's a
63066 + common error to grant too much permission to these objects, with
63067 + impact ranging from denial of service and information leaking to
63068 + privilege escalation. This feature was developed in response to
63069 + research by Tim Brown:
63070 + http://labs.portcullis.co.uk/whitepapers/memory-squatting-attacks-on-system-v-shared-memory/
63071 + who found hundreds of such insecure usages. Processes with
63072 + CAP_IPC_OWNER are still permitted to access these IPC objects.
63073 + If the sysctl option is enabled, a sysctl option with name
63074 + "harden_ipc" is created.
63075 +
63076 +config GRKERNSEC_TPE
63077 + bool "Trusted Path Execution (TPE)"
63078 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
63079 + help
63080 + If you say Y here, you will be able to choose a gid to add to the
63081 + supplementary groups of users you want to mark as "untrusted."
63082 + These users will not be able to execute any files that are not in
63083 + root-owned directories writable only by root. If the sysctl option
63084 + is enabled, a sysctl option with name "tpe" is created.
63085 +
63086 +config GRKERNSEC_TPE_ALL
63087 + bool "Partially restrict all non-root users"
63088 + depends on GRKERNSEC_TPE
63089 + help
63090 + If you say Y here, all non-root users will be covered under
63091 + a weaker TPE restriction. This is separate from, and in addition to,
63092 + the main TPE options that you have selected elsewhere. Thus, if a
63093 + "trusted" GID is chosen, this restriction applies to even that GID.
63094 + Under this restriction, all non-root users will only be allowed to
63095 + execute files in directories they own that are not group or
63096 + world-writable, or in directories owned by root and writable only by
63097 + root. If the sysctl option is enabled, a sysctl option with name
63098 + "tpe_restrict_all" is created.
63099 +
63100 +config GRKERNSEC_TPE_INVERT
63101 + bool "Invert GID option"
63102 + depends on GRKERNSEC_TPE
63103 + help
63104 + If you say Y here, the group you specify in the TPE configuration will
63105 + decide what group TPE restrictions will be *disabled* for. This
63106 + option is useful if you want TPE restrictions to be applied to most
63107 + users on the system. If the sysctl option is enabled, a sysctl option
63108 + with name "tpe_invert" is created. Unlike other sysctl options, this
63109 + entry will default to on for backward-compatibility.
63110 +
63111 +config GRKERNSEC_TPE_GID
63112 + int
63113 + default GRKERNSEC_TPE_UNTRUSTED_GID if (GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT)
63114 + default GRKERNSEC_TPE_TRUSTED_GID if (GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT)
63115 +
63116 +config GRKERNSEC_TPE_UNTRUSTED_GID
63117 + int "GID for TPE-untrusted users"
63118 + depends on GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
63119 + default 1005
63120 + help
63121 + Setting this GID determines what group TPE restrictions will be
63122 + *enabled* for. If the sysctl option is enabled, a sysctl option
63123 + with name "tpe_gid" is created.
63124 +
63125 +config GRKERNSEC_TPE_TRUSTED_GID
63126 + int "GID for TPE-trusted users"
63127 + depends on GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
63128 + default 1005
63129 + help
63130 + Setting this GID determines what group TPE restrictions will be
63131 + *disabled* for. If the sysctl option is enabled, a sysctl option
63132 + with name "tpe_gid" is created.
63133 +
63134 +endmenu
63135 +menu "Network Protections"
63136 +depends on GRKERNSEC
63137 +
63138 +config GRKERNSEC_RANDNET
63139 + bool "Larger entropy pools"
63140 + default y if GRKERNSEC_CONFIG_AUTO
63141 + help
63142 + If you say Y here, the entropy pools used for many features of Linux
63143 + and grsecurity will be doubled in size. Since several grsecurity
63144 + features use additional randomness, it is recommended that you say Y
63145 + here. Saying Y here has a similar effect as modifying
63146 + /proc/sys/kernel/random/poolsize.
63147 +
63148 +config GRKERNSEC_BLACKHOLE
63149 + bool "TCP/UDP blackhole and LAST_ACK DoS prevention"
63150 + default y if GRKERNSEC_CONFIG_AUTO
63151 + depends on NET
63152 + help
63153 + If you say Y here, neither TCP resets nor ICMP
63154 + destination-unreachable packets will be sent in response to packets
63155 + sent to ports for which no associated listening process exists.
63156 + This feature supports both IPV4 and IPV6 and exempts the
63157 + loopback interface from blackholing. Enabling this feature
63158 + makes a host more resilient to DoS attacks and reduces network
63159 + visibility against scanners.
63160 +
63161 + The blackhole feature as-implemented is equivalent to the FreeBSD
63162 + blackhole feature, as it prevents RST responses to all packets, not
63163 + just SYNs. Under most application behavior this causes no
63164 + problems, but applications (like haproxy) may not close certain
63165 + connections in a way that cleanly terminates them on the remote
63166 + end, leaving the remote host in LAST_ACK state. Because of this
63167 + side-effect and to prevent intentional LAST_ACK DoSes, this
63168 + feature also adds automatic mitigation against such attacks.
63169 + The mitigation drastically reduces the amount of time a socket
63170 + can spend in LAST_ACK state. If you're using haproxy and not
63171 + all servers it connects to have this option enabled, consider
63172 + disabling this feature on the haproxy host.
63173 +
63174 + If the sysctl option is enabled, two sysctl options with names
63175 + "ip_blackhole" and "lastack_retries" will be created.
63176 + While "ip_blackhole" takes the standard zero/non-zero on/off
63177 + toggle, "lastack_retries" uses the same kinds of values as
63178 + "tcp_retries1" and "tcp_retries2". The default value of 4
63179 + prevents a socket from lasting more than 45 seconds in LAST_ACK
63180 + state.
63181 +
63182 +config GRKERNSEC_NO_SIMULT_CONNECT
63183 + bool "Disable TCP Simultaneous Connect"
63184 + default y if GRKERNSEC_CONFIG_AUTO
63185 + depends on NET
63186 + help
63187 + If you say Y here, a feature by Willy Tarreau will be enabled that
63188 + removes a weakness in Linux's strict implementation of TCP that
63189 + allows two clients to connect to each other without either entering
63190 + a listening state. The weakness allows an attacker to easily prevent
63191 + a client from connecting to a known server provided the source port
63192 + for the connection is guessed correctly.
63193 +
63194 + As the weakness could be used to prevent an antivirus or IPS from
63195 + fetching updates, or prevent an SSL gateway from fetching a CRL,
63196 + it should be eliminated by enabling this option. Though Linux is
63197 + one of few operating systems supporting simultaneous connect, it
63198 + has no legitimate use in practice and is rarely supported by firewalls.
63199 +
63200 +config GRKERNSEC_SOCKET
63201 + bool "Socket restrictions"
63202 + depends on NET
63203 + help
63204 + If you say Y here, you will be able to choose from several options.
63205 + If you assign a GID on your system and add it to the supplementary
63206 + groups of users you want to restrict socket access to, this patch
63207 + will perform up to three things, based on the option(s) you choose.
63208 +
63209 +config GRKERNSEC_SOCKET_ALL
63210 + bool "Deny any sockets to group"
63211 + depends on GRKERNSEC_SOCKET
63212 + help
63213 + If you say Y here, you will be able to choose a GID of whose users will
63214 + be unable to connect to other hosts from your machine or run server
63215 + applications from your machine. If the sysctl option is enabled, a
63216 + sysctl option with name "socket_all" is created.
63217 +
63218 +config GRKERNSEC_SOCKET_ALL_GID
63219 + int "GID to deny all sockets for"
63220 + depends on GRKERNSEC_SOCKET_ALL
63221 + default 1004
63222 + help
63223 + Here you can choose the GID to disable socket access for. Remember to
63224 + add the users you want socket access disabled for to the GID
63225 + specified here. If the sysctl option is enabled, a sysctl option
63226 + with name "socket_all_gid" is created.
63227 +
63228 +config GRKERNSEC_SOCKET_CLIENT
63229 + bool "Deny client sockets to group"
63230 + depends on GRKERNSEC_SOCKET
63231 + help
63232 + If you say Y here, you will be able to choose a GID of whose users will
63233 + be unable to connect to other hosts from your machine, but will be
63234 + able to run servers. If this option is enabled, all users in the group
63235 + you specify will have to use passive mode when initiating ftp transfers
63236 + from the shell on your machine. If the sysctl option is enabled, a
63237 + sysctl option with name "socket_client" is created.
63238 +
63239 +config GRKERNSEC_SOCKET_CLIENT_GID
63240 + int "GID to deny client sockets for"
63241 + depends on GRKERNSEC_SOCKET_CLIENT
63242 + default 1003
63243 + help
63244 + Here you can choose the GID to disable client socket access for.
63245 + Remember to add the users you want client socket access disabled for to
63246 + the GID specified here. If the sysctl option is enabled, a sysctl
63247 + option with name "socket_client_gid" is created.
63248 +
63249 +config GRKERNSEC_SOCKET_SERVER
63250 + bool "Deny server sockets to group"
63251 + depends on GRKERNSEC_SOCKET
63252 + help
63253 + If you say Y here, you will be able to choose a GID of whose users will
63254 + be unable to run server applications from your machine. If the sysctl
63255 + option is enabled, a sysctl option with name "socket_server" is created.
63256 +
63257 +config GRKERNSEC_SOCKET_SERVER_GID
63258 + int "GID to deny server sockets for"
63259 + depends on GRKERNSEC_SOCKET_SERVER
63260 + default 1002
63261 + help
63262 + Here you can choose the GID to disable server socket access for.
63263 + Remember to add the users you want server socket access disabled for to
63264 + the GID specified here. If the sysctl option is enabled, a sysctl
63265 + option with name "socket_server_gid" is created.
63266 +
63267 +endmenu
63268 +
63269 +menu "Physical Protections"
63270 +depends on GRKERNSEC
63271 +
63272 +config GRKERNSEC_DENYUSB
63273 + bool "Deny new USB connections after toggle"
63274 + default y if GRKERNSEC_CONFIG_AUTO
63275 + depends on SYSCTL && USB_SUPPORT
63276 + help
63277 + If you say Y here, a new sysctl option with name "deny_new_usb"
63278 + will be created. Setting its value to 1 will prevent any new
63279 + USB devices from being recognized by the OS. Any attempted USB
63280 + device insertion will be logged. This option is intended to be
63281 + used against custom USB devices designed to exploit vulnerabilities
63282 + in various USB device drivers.
63283 +
63284 + For greatest effectiveness, this sysctl should be set after any
63285 + relevant init scripts. This option is safe to enable in distros
63286 + as each user can choose whether or not to toggle the sysctl.
63287 +
63288 +config GRKERNSEC_DENYUSB_FORCE
63289 + bool "Reject all USB devices not connected at boot"
63290 + select USB
63291 + depends on GRKERNSEC_DENYUSB
63292 + help
63293 + If you say Y here, a variant of GRKERNSEC_DENYUSB will be enabled
63294 + that doesn't involve a sysctl entry. This option should only be
63295 + enabled if you're sure you want to deny all new USB connections
63296 + at runtime and don't want to modify init scripts. This should not
63297 + be enabled by distros. It forces the core USB code to be built
63298 + into the kernel image so that all devices connected at boot time
63299 + can be recognized and new USB device connections can be prevented
63300 + prior to init running.
63301 +
63302 +endmenu
63303 +
63304 +menu "Sysctl Support"
63305 +depends on GRKERNSEC && SYSCTL
63306 +
63307 +config GRKERNSEC_SYSCTL
63308 + bool "Sysctl support"
63309 + default y if GRKERNSEC_CONFIG_AUTO
63310 + help
63311 + If you say Y here, you will be able to change the options that
63312 + grsecurity runs with at bootup, without having to recompile your
63313 + kernel. You can echo values to files in /proc/sys/kernel/grsecurity
63314 + to enable (1) or disable (0) various features. All the sysctl entries
63315 + are mutable until the "grsec_lock" entry is set to a non-zero value.
63316 + All features enabled in the kernel configuration are disabled at boot
63317 + if you do not say Y to the "Turn on features by default" option.
63318 + All options should be set at startup, and the grsec_lock entry should
63319 + be set to a non-zero value after all the options are set.
63320 + *THIS IS EXTREMELY IMPORTANT*
63321 +
63322 +config GRKERNSEC_SYSCTL_DISTRO
63323 + bool "Extra sysctl support for distro makers (READ HELP)"
63324 + depends on GRKERNSEC_SYSCTL && GRKERNSEC_IO
63325 + help
63326 + If you say Y here, additional sysctl options will be created
63327 + for features that affect processes running as root. Therefore,
63328 + it is critical when using this option that the grsec_lock entry be
63329 + enabled after boot. Only distros with prebuilt kernel packages
63330 + with this option enabled that can ensure grsec_lock is enabled
63331 + after boot should use this option.
63332 + *Failure to set grsec_lock after boot makes all grsec features
63333 + this option covers useless*
63334 +
63335 + Currently this option creates the following sysctl entries:
63336 + "Disable Privileged I/O": "disable_priv_io"
63337 +
63338 +config GRKERNSEC_SYSCTL_ON
63339 + bool "Turn on features by default"
63340 + default y if GRKERNSEC_CONFIG_AUTO
63341 + depends on GRKERNSEC_SYSCTL
63342 + help
63343 + If you say Y here, instead of having all features enabled in the
63344 + kernel configuration disabled at boot time, the features will be
63345 + enabled at boot time. It is recommended you say Y here unless
63346 + there is some reason you would want all sysctl-tunable features to
63347 + be disabled by default. As mentioned elsewhere, it is important
63348 + to enable the grsec_lock entry once you have finished modifying
63349 + the sysctl entries.
63350 +
63351 +endmenu
63352 +menu "Logging Options"
63353 +depends on GRKERNSEC
63354 +
63355 +config GRKERNSEC_FLOODTIME
63356 + int "Seconds in between log messages (minimum)"
63357 + default 10
63358 + help
63359 + This option allows you to enforce the number of seconds between
63360 + grsecurity log messages. The default should be suitable for most
63361 + people, however, if you choose to change it, choose a value small enough
63362 + to allow informative logs to be produced, but large enough to
63363 + prevent flooding.
63364 +
63365 +config GRKERNSEC_FLOODBURST
63366 + int "Number of messages in a burst (maximum)"
63367 + default 6
63368 + help
63369 + This option allows you to choose the maximum number of messages allowed
63370 + within the flood time interval you chose in a separate option. The
63371 + default should be suitable for most people, however if you find that
63372 + many of your logs are being interpreted as flooding, you may want to
63373 + raise this value.
63374 +
63375 +endmenu
63376 diff --git a/grsecurity/Makefile b/grsecurity/Makefile
63377 new file mode 100644
63378 index 0000000..85beb79
63379 --- /dev/null
63380 +++ b/grsecurity/Makefile
63381 @@ -0,0 +1,43 @@
63382 +# grsecurity's ACL system was originally written in 2001 by Michael Dalton
63383 +# during 2001-2009 it has been completely redesigned by Brad Spengler
63384 +# into an RBAC system
63385 +#
63386 +# All code in this directory and various hooks inserted throughout the kernel
63387 +# are copyright Brad Spengler - Open Source Security, Inc., and released
63388 +# under the GPL v2 or higher
63389 +
63390 +KBUILD_CFLAGS += -Werror
63391 +
63392 +obj-y = grsec_chdir.o grsec_chroot.o grsec_exec.o grsec_fifo.o grsec_fork.o \
63393 + grsec_mount.o grsec_sig.o grsec_sysctl.o \
63394 + grsec_time.o grsec_tpe.o grsec_link.o grsec_pax.o grsec_ptrace.o \
63395 + grsec_usb.o grsec_ipc.o
63396 +
63397 +obj-$(CONFIG_GRKERNSEC) += grsec_init.o grsum.o gracl.o gracl_segv.o \
63398 + gracl_cap.o gracl_alloc.o gracl_shm.o grsec_mem.o gracl_fs.o \
63399 + gracl_learn.o grsec_log.o gracl_policy.o
63400 +ifdef CONFIG_COMPAT
63401 +obj-$(CONFIG_GRKERNSEC) += gracl_compat.o
63402 +endif
63403 +
63404 +obj-$(CONFIG_GRKERNSEC_RESLOG) += gracl_res.o
63405 +
63406 +ifdef CONFIG_NET
63407 +obj-y += grsec_sock.o
63408 +obj-$(CONFIG_GRKERNSEC) += gracl_ip.o
63409 +endif
63410 +
63411 +ifndef CONFIG_GRKERNSEC
63412 +obj-y += grsec_disabled.o
63413 +endif
63414 +
63415 +ifdef CONFIG_GRKERNSEC_HIDESYM
63416 +extra-y := grsec_hidesym.o
63417 +$(obj)/grsec_hidesym.o:
63418 + @-chmod -f 500 /boot
63419 + @-chmod -f 500 /lib/modules
63420 + @-chmod -f 500 /lib64/modules
63421 + @-chmod -f 500 /lib32/modules
63422 + @-chmod -f 700 .
63423 + @echo ' grsec: protected kernel image paths'
63424 +endif
63425 diff --git a/grsecurity/gracl.c b/grsecurity/gracl.c
63426 new file mode 100644
63427 index 0000000..6affeea
63428 --- /dev/null
63429 +++ b/grsecurity/gracl.c
63430 @@ -0,0 +1,2679 @@
63431 +#include <linux/kernel.h>
63432 +#include <linux/module.h>
63433 +#include <linux/sched.h>
63434 +#include <linux/mm.h>
63435 +#include <linux/file.h>
63436 +#include <linux/fs.h>
63437 +#include <linux/namei.h>
63438 +#include <linux/mount.h>
63439 +#include <linux/tty.h>
63440 +#include <linux/proc_fs.h>
63441 +#include <linux/lglock.h>
63442 +#include <linux/slab.h>
63443 +#include <linux/vmalloc.h>
63444 +#include <linux/types.h>
63445 +#include <linux/sysctl.h>
63446 +#include <linux/netdevice.h>
63447 +#include <linux/ptrace.h>
63448 +#include <linux/gracl.h>
63449 +#include <linux/gralloc.h>
63450 +#include <linux/security.h>
63451 +#include <linux/grinternal.h>
63452 +#include <linux/pid_namespace.h>
63453 +#include <linux/stop_machine.h>
63454 +#include <linux/fdtable.h>
63455 +#include <linux/percpu.h>
63456 +#include <linux/lglock.h>
63457 +#include <linux/hugetlb.h>
63458 +#include <linux/posix-timers.h>
63459 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
63460 +#include <linux/magic.h>
63461 +#include <linux/pagemap.h>
63462 +#include "../fs/btrfs/async-thread.h"
63463 +#include "../fs/btrfs/ctree.h"
63464 +#include "../fs/btrfs/btrfs_inode.h"
63465 +#endif
63466 +#include "../fs/mount.h"
63467 +
63468 +#include <asm/uaccess.h>
63469 +#include <asm/errno.h>
63470 +#include <asm/mman.h>
63471 +
63472 +#define FOR_EACH_ROLE_START(role) \
63473 + role = running_polstate.role_list; \
63474 + while (role) {
63475 +
63476 +#define FOR_EACH_ROLE_END(role) \
63477 + role = role->prev; \
63478 + }
63479 +
63480 +extern struct lglock vfsmount_lock;
63481 +
63482 +extern struct path gr_real_root;
63483 +
63484 +static struct gr_policy_state running_polstate;
63485 +struct gr_policy_state *polstate = &running_polstate;
63486 +extern struct gr_alloc_state *current_alloc_state;
63487 +
63488 +extern char *gr_shared_page[4];
63489 +DEFINE_RWLOCK(gr_inode_lock);
63490 +
63491 +static unsigned int gr_status __read_only = GR_STATUS_INIT;
63492 +
63493 +#ifdef CONFIG_NET
63494 +extern struct vfsmount *sock_mnt;
63495 +#endif
63496 +
63497 +extern struct vfsmount *pipe_mnt;
63498 +extern struct vfsmount *shm_mnt;
63499 +
63500 +#ifdef CONFIG_HUGETLBFS
63501 +extern struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
63502 +#endif
63503 +
63504 +extern u16 acl_sp_role_value;
63505 +extern struct acl_object_label *fakefs_obj_rw;
63506 +extern struct acl_object_label *fakefs_obj_rwx;
63507 +
63508 +int gr_acl_is_enabled(void)
63509 +{
63510 + return (gr_status & GR_READY);
63511 +}
63512 +
63513 +void gr_enable_rbac_system(void)
63514 +{
63515 + pax_open_kernel();
63516 + gr_status |= GR_READY;
63517 + pax_close_kernel();
63518 +}
63519 +
63520 +int gr_rbac_disable(void *unused)
63521 +{
63522 + pax_open_kernel();
63523 + gr_status &= ~GR_READY;
63524 + pax_close_kernel();
63525 +
63526 + return 0;
63527 +}
63528 +
63529 +static inline dev_t __get_dev(const struct dentry *dentry)
63530 +{
63531 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
63532 + if (dentry->d_sb->s_magic == BTRFS_SUPER_MAGIC)
63533 + return BTRFS_I(dentry->d_inode)->root->anon_dev;
63534 + else
63535 +#endif
63536 + return dentry->d_sb->s_dev;
63537 +}
63538 +
63539 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
63540 +{
63541 + return __get_dev(dentry);
63542 +}
63543 +
63544 +static char gr_task_roletype_to_char(struct task_struct *task)
63545 +{
63546 + switch (task->role->roletype &
63547 + (GR_ROLE_DEFAULT | GR_ROLE_USER | GR_ROLE_GROUP |
63548 + GR_ROLE_SPECIAL)) {
63549 + case GR_ROLE_DEFAULT:
63550 + return 'D';
63551 + case GR_ROLE_USER:
63552 + return 'U';
63553 + case GR_ROLE_GROUP:
63554 + return 'G';
63555 + case GR_ROLE_SPECIAL:
63556 + return 'S';
63557 + }
63558 +
63559 + return 'X';
63560 +}
63561 +
63562 +char gr_roletype_to_char(void)
63563 +{
63564 + return gr_task_roletype_to_char(current);
63565 +}
63566 +
63567 +__inline__ int
63568 +gr_acl_tpe_check(void)
63569 +{
63570 + if (unlikely(!(gr_status & GR_READY)))
63571 + return 0;
63572 + if (current->role->roletype & GR_ROLE_TPE)
63573 + return 1;
63574 + else
63575 + return 0;
63576 +}
63577 +
63578 +int
63579 +gr_handle_rawio(const struct inode *inode)
63580 +{
63581 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
63582 + if (inode && S_ISBLK(inode->i_mode) &&
63583 + grsec_enable_chroot_caps && proc_is_chrooted(current) &&
63584 + !capable(CAP_SYS_RAWIO))
63585 + return 1;
63586 +#endif
63587 + return 0;
63588 +}
63589 +
63590 +int
63591 +gr_streq(const char *a, const char *b, const unsigned int lena, const unsigned int lenb)
63592 +{
63593 + if (likely(lena != lenb))
63594 + return 0;
63595 +
63596 + return !memcmp(a, b, lena);
63597 +}
63598 +
63599 +static int prepend(char **buffer, int *buflen, const char *str, int namelen)
63600 +{
63601 + *buflen -= namelen;
63602 + if (*buflen < 0)
63603 + return -ENAMETOOLONG;
63604 + *buffer -= namelen;
63605 + memcpy(*buffer, str, namelen);
63606 + return 0;
63607 +}
63608 +
63609 +static int prepend_name(char **buffer, int *buflen, struct qstr *name)
63610 +{
63611 + return prepend(buffer, buflen, name->name, name->len);
63612 +}
63613 +
63614 +static int prepend_path(const struct path *path, struct path *root,
63615 + char **buffer, int *buflen)
63616 +{
63617 + struct dentry *dentry = path->dentry;
63618 + struct vfsmount *vfsmnt = path->mnt;
63619 + struct mount *mnt = real_mount(vfsmnt);
63620 + bool slash = false;
63621 + int error = 0;
63622 +
63623 + while (dentry != root->dentry || vfsmnt != root->mnt) {
63624 + struct dentry * parent;
63625 +
63626 + if (dentry == vfsmnt->mnt_root || IS_ROOT(dentry)) {
63627 + /* Global root? */
63628 + if (!mnt_has_parent(mnt)) {
63629 + goto out;
63630 + }
63631 + dentry = mnt->mnt_mountpoint;
63632 + mnt = mnt->mnt_parent;
63633 + vfsmnt = &mnt->mnt;
63634 + continue;
63635 + }
63636 + parent = dentry->d_parent;
63637 + prefetch(parent);
63638 + spin_lock(&dentry->d_lock);
63639 + error = prepend_name(buffer, buflen, &dentry->d_name);
63640 + spin_unlock(&dentry->d_lock);
63641 + if (!error)
63642 + error = prepend(buffer, buflen, "/", 1);
63643 + if (error)
63644 + break;
63645 +
63646 + slash = true;
63647 + dentry = parent;
63648 + }
63649 +
63650 +out:
63651 + if (!error && !slash)
63652 + error = prepend(buffer, buflen, "/", 1);
63653 +
63654 + return error;
63655 +}
63656 +
63657 +/* this must be called with vfsmount_lock and rename_lock held */
63658 +
63659 +static char *__our_d_path(const struct path *path, struct path *root,
63660 + char *buf, int buflen)
63661 +{
63662 + char *res = buf + buflen;
63663 + int error;
63664 +
63665 + prepend(&res, &buflen, "\0", 1);
63666 + error = prepend_path(path, root, &res, &buflen);
63667 + if (error)
63668 + return ERR_PTR(error);
63669 +
63670 + return res;
63671 +}
63672 +
63673 +static char *
63674 +gen_full_path(struct path *path, struct path *root, char *buf, int buflen)
63675 +{
63676 + char *retval;
63677 +
63678 + retval = __our_d_path(path, root, buf, buflen);
63679 + if (unlikely(IS_ERR(retval)))
63680 + retval = strcpy(buf, "<path too long>");
63681 + else if (unlikely(retval[1] == '/' && retval[2] == '\0'))
63682 + retval[1] = '\0';
63683 +
63684 + return retval;
63685 +}
63686 +
63687 +static char *
63688 +__d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
63689 + char *buf, int buflen)
63690 +{
63691 + struct path path;
63692 + char *res;
63693 +
63694 + path.dentry = (struct dentry *)dentry;
63695 + path.mnt = (struct vfsmount *)vfsmnt;
63696 +
63697 + /* we can use gr_real_root.dentry, gr_real_root.mnt, because this is only called
63698 + by the RBAC system */
63699 + res = gen_full_path(&path, &gr_real_root, buf, buflen);
63700 +
63701 + return res;
63702 +}
63703 +
63704 +static char *
63705 +d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
63706 + char *buf, int buflen)
63707 +{
63708 + char *res;
63709 + struct path path;
63710 + struct path root;
63711 + struct task_struct *reaper = init_pid_ns.child_reaper;
63712 +
63713 + path.dentry = (struct dentry *)dentry;
63714 + path.mnt = (struct vfsmount *)vfsmnt;
63715 +
63716 + /* we can't use gr_real_root.dentry, gr_real_root.mnt, because they belong only to the RBAC system */
63717 + get_fs_root(reaper->fs, &root);
63718 +
63719 + br_read_lock(&vfsmount_lock);
63720 + write_seqlock(&rename_lock);
63721 + res = gen_full_path(&path, &root, buf, buflen);
63722 + write_sequnlock(&rename_lock);
63723 + br_read_unlock(&vfsmount_lock);
63724 +
63725 + path_put(&root);
63726 + return res;
63727 +}
63728 +
63729 +char *
63730 +gr_to_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
63731 +{
63732 + char *ret;
63733 + br_read_lock(&vfsmount_lock);
63734 + write_seqlock(&rename_lock);
63735 + ret = __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
63736 + PAGE_SIZE);
63737 + write_sequnlock(&rename_lock);
63738 + br_read_unlock(&vfsmount_lock);
63739 + return ret;
63740 +}
63741 +
63742 +static char *
63743 +gr_to_proc_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
63744 +{
63745 + char *ret;
63746 + char *buf;
63747 + int buflen;
63748 +
63749 + br_read_lock(&vfsmount_lock);
63750 + write_seqlock(&rename_lock);
63751 + buf = per_cpu_ptr(gr_shared_page[0], smp_processor_id());
63752 + ret = __d_real_path(dentry, mnt, buf, PAGE_SIZE - 6);
63753 + buflen = (int)(ret - buf);
63754 + if (buflen >= 5)
63755 + prepend(&ret, &buflen, "/proc", 5);
63756 + else
63757 + ret = strcpy(buf, "<path too long>");
63758 + write_sequnlock(&rename_lock);
63759 + br_read_unlock(&vfsmount_lock);
63760 + return ret;
63761 +}
63762 +
63763 +char *
63764 +gr_to_filename_nolock(const struct dentry *dentry, const struct vfsmount *mnt)
63765 +{
63766 + return __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
63767 + PAGE_SIZE);
63768 +}
63769 +
63770 +char *
63771 +gr_to_filename(const struct dentry *dentry, const struct vfsmount *mnt)
63772 +{
63773 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
63774 + PAGE_SIZE);
63775 +}
63776 +
63777 +char *
63778 +gr_to_filename1(const struct dentry *dentry, const struct vfsmount *mnt)
63779 +{
63780 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[1], smp_processor_id()),
63781 + PAGE_SIZE);
63782 +}
63783 +
63784 +char *
63785 +gr_to_filename2(const struct dentry *dentry, const struct vfsmount *mnt)
63786 +{
63787 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[2], smp_processor_id()),
63788 + PAGE_SIZE);
63789 +}
63790 +
63791 +char *
63792 +gr_to_filename3(const struct dentry *dentry, const struct vfsmount *mnt)
63793 +{
63794 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[3], smp_processor_id()),
63795 + PAGE_SIZE);
63796 +}
63797 +
63798 +__inline__ __u32
63799 +to_gr_audit(const __u32 reqmode)
63800 +{
63801 + /* masks off auditable permission flags, then shifts them to create
63802 + auditing flags, and adds the special case of append auditing if
63803 + we're requesting write */
63804 + return (((reqmode & ~GR_AUDITS) << 10) | ((reqmode & GR_WRITE) ? GR_AUDIT_APPEND : 0));
63805 +}
63806 +
63807 +struct acl_role_label *
63808 +__lookup_acl_role_label(const struct gr_policy_state *state, const struct task_struct *task, const uid_t uid,
63809 + const gid_t gid)
63810 +{
63811 + unsigned int index = gr_rhash(uid, GR_ROLE_USER, state->acl_role_set.r_size);
63812 + struct acl_role_label *match;
63813 + struct role_allowed_ip *ipp;
63814 + unsigned int x;
63815 + u32 curr_ip = task->signal->saved_ip;
63816 +
63817 + match = state->acl_role_set.r_hash[index];
63818 +
63819 + while (match) {
63820 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_USER)) == (GR_ROLE_DOMAIN | GR_ROLE_USER)) {
63821 + for (x = 0; x < match->domain_child_num; x++) {
63822 + if (match->domain_children[x] == uid)
63823 + goto found;
63824 + }
63825 + } else if (match->uidgid == uid && match->roletype & GR_ROLE_USER)
63826 + break;
63827 + match = match->next;
63828 + }
63829 +found:
63830 + if (match == NULL) {
63831 + try_group:
63832 + index = gr_rhash(gid, GR_ROLE_GROUP, state->acl_role_set.r_size);
63833 + match = state->acl_role_set.r_hash[index];
63834 +
63835 + while (match) {
63836 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) == (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) {
63837 + for (x = 0; x < match->domain_child_num; x++) {
63838 + if (match->domain_children[x] == gid)
63839 + goto found2;
63840 + }
63841 + } else if (match->uidgid == gid && match->roletype & GR_ROLE_GROUP)
63842 + break;
63843 + match = match->next;
63844 + }
63845 +found2:
63846 + if (match == NULL)
63847 + match = state->default_role;
63848 + if (match->allowed_ips == NULL)
63849 + return match;
63850 + else {
63851 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
63852 + if (likely
63853 + ((ntohl(curr_ip) & ipp->netmask) ==
63854 + (ntohl(ipp->addr) & ipp->netmask)))
63855 + return match;
63856 + }
63857 + match = state->default_role;
63858 + }
63859 + } else if (match->allowed_ips == NULL) {
63860 + return match;
63861 + } else {
63862 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
63863 + if (likely
63864 + ((ntohl(curr_ip) & ipp->netmask) ==
63865 + (ntohl(ipp->addr) & ipp->netmask)))
63866 + return match;
63867 + }
63868 + goto try_group;
63869 + }
63870 +
63871 + return match;
63872 +}
63873 +
63874 +static struct acl_role_label *
63875 +lookup_acl_role_label(const struct task_struct *task, const uid_t uid,
63876 + const gid_t gid)
63877 +{
63878 + return __lookup_acl_role_label(&running_polstate, task, uid, gid);
63879 +}
63880 +
63881 +struct acl_subject_label *
63882 +lookup_acl_subj_label(const ino_t ino, const dev_t dev,
63883 + const struct acl_role_label *role)
63884 +{
63885 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
63886 + struct acl_subject_label *match;
63887 +
63888 + match = role->subj_hash[index];
63889 +
63890 + while (match && (match->inode != ino || match->device != dev ||
63891 + (match->mode & GR_DELETED))) {
63892 + match = match->next;
63893 + }
63894 +
63895 + if (match && !(match->mode & GR_DELETED))
63896 + return match;
63897 + else
63898 + return NULL;
63899 +}
63900 +
63901 +struct acl_subject_label *
63902 +lookup_acl_subj_label_deleted(const ino_t ino, const dev_t dev,
63903 + const struct acl_role_label *role)
63904 +{
63905 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
63906 + struct acl_subject_label *match;
63907 +
63908 + match = role->subj_hash[index];
63909 +
63910 + while (match && (match->inode != ino || match->device != dev ||
63911 + !(match->mode & GR_DELETED))) {
63912 + match = match->next;
63913 + }
63914 +
63915 + if (match && (match->mode & GR_DELETED))
63916 + return match;
63917 + else
63918 + return NULL;
63919 +}
63920 +
63921 +static struct acl_object_label *
63922 +lookup_acl_obj_label(const ino_t ino, const dev_t dev,
63923 + const struct acl_subject_label *subj)
63924 +{
63925 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
63926 + struct acl_object_label *match;
63927 +
63928 + match = subj->obj_hash[index];
63929 +
63930 + while (match && (match->inode != ino || match->device != dev ||
63931 + (match->mode & GR_DELETED))) {
63932 + match = match->next;
63933 + }
63934 +
63935 + if (match && !(match->mode & GR_DELETED))
63936 + return match;
63937 + else
63938 + return NULL;
63939 +}
63940 +
63941 +static struct acl_object_label *
63942 +lookup_acl_obj_label_create(const ino_t ino, const dev_t dev,
63943 + const struct acl_subject_label *subj)
63944 +{
63945 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
63946 + struct acl_object_label *match;
63947 +
63948 + match = subj->obj_hash[index];
63949 +
63950 + while (match && (match->inode != ino || match->device != dev ||
63951 + !(match->mode & GR_DELETED))) {
63952 + match = match->next;
63953 + }
63954 +
63955 + if (match && (match->mode & GR_DELETED))
63956 + return match;
63957 +
63958 + match = subj->obj_hash[index];
63959 +
63960 + while (match && (match->inode != ino || match->device != dev ||
63961 + (match->mode & GR_DELETED))) {
63962 + match = match->next;
63963 + }
63964 +
63965 + if (match && !(match->mode & GR_DELETED))
63966 + return match;
63967 + else
63968 + return NULL;
63969 +}
63970 +
63971 +struct name_entry *
63972 +__lookup_name_entry(const struct gr_policy_state *state, const char *name)
63973 +{
63974 + unsigned int len = strlen(name);
63975 + unsigned int key = full_name_hash(name, len);
63976 + unsigned int index = key % state->name_set.n_size;
63977 + struct name_entry *match;
63978 +
63979 + match = state->name_set.n_hash[index];
63980 +
63981 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len)))
63982 + match = match->next;
63983 +
63984 + return match;
63985 +}
63986 +
63987 +static struct name_entry *
63988 +lookup_name_entry(const char *name)
63989 +{
63990 + return __lookup_name_entry(&running_polstate, name);
63991 +}
63992 +
63993 +static struct name_entry *
63994 +lookup_name_entry_create(const char *name)
63995 +{
63996 + unsigned int len = strlen(name);
63997 + unsigned int key = full_name_hash(name, len);
63998 + unsigned int index = key % running_polstate.name_set.n_size;
63999 + struct name_entry *match;
64000 +
64001 + match = running_polstate.name_set.n_hash[index];
64002 +
64003 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
64004 + !match->deleted))
64005 + match = match->next;
64006 +
64007 + if (match && match->deleted)
64008 + return match;
64009 +
64010 + match = running_polstate.name_set.n_hash[index];
64011 +
64012 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
64013 + match->deleted))
64014 + match = match->next;
64015 +
64016 + if (match && !match->deleted)
64017 + return match;
64018 + else
64019 + return NULL;
64020 +}
64021 +
64022 +static struct inodev_entry *
64023 +lookup_inodev_entry(const ino_t ino, const dev_t dev)
64024 +{
64025 + unsigned int index = gr_fhash(ino, dev, running_polstate.inodev_set.i_size);
64026 + struct inodev_entry *match;
64027 +
64028 + match = running_polstate.inodev_set.i_hash[index];
64029 +
64030 + while (match && (match->nentry->inode != ino || match->nentry->device != dev))
64031 + match = match->next;
64032 +
64033 + return match;
64034 +}
64035 +
64036 +void
64037 +__insert_inodev_entry(const struct gr_policy_state *state, struct inodev_entry *entry)
64038 +{
64039 + unsigned int index = gr_fhash(entry->nentry->inode, entry->nentry->device,
64040 + state->inodev_set.i_size);
64041 + struct inodev_entry **curr;
64042 +
64043 + entry->prev = NULL;
64044 +
64045 + curr = &state->inodev_set.i_hash[index];
64046 + if (*curr != NULL)
64047 + (*curr)->prev = entry;
64048 +
64049 + entry->next = *curr;
64050 + *curr = entry;
64051 +
64052 + return;
64053 +}
64054 +
64055 +static void
64056 +insert_inodev_entry(struct inodev_entry *entry)
64057 +{
64058 + __insert_inodev_entry(&running_polstate, entry);
64059 +}
64060 +
64061 +void
64062 +insert_acl_obj_label(struct acl_object_label *obj,
64063 + struct acl_subject_label *subj)
64064 +{
64065 + unsigned int index =
64066 + gr_fhash(obj->inode, obj->device, subj->obj_hash_size);
64067 + struct acl_object_label **curr;
64068 +
64069 + obj->prev = NULL;
64070 +
64071 + curr = &subj->obj_hash[index];
64072 + if (*curr != NULL)
64073 + (*curr)->prev = obj;
64074 +
64075 + obj->next = *curr;
64076 + *curr = obj;
64077 +
64078 + return;
64079 +}
64080 +
64081 +void
64082 +insert_acl_subj_label(struct acl_subject_label *obj,
64083 + struct acl_role_label *role)
64084 +{
64085 + unsigned int index = gr_fhash(obj->inode, obj->device, role->subj_hash_size);
64086 + struct acl_subject_label **curr;
64087 +
64088 + obj->prev = NULL;
64089 +
64090 + curr = &role->subj_hash[index];
64091 + if (*curr != NULL)
64092 + (*curr)->prev = obj;
64093 +
64094 + obj->next = *curr;
64095 + *curr = obj;
64096 +
64097 + return;
64098 +}
64099 +
64100 +/* derived from glibc fnmatch() 0: match, 1: no match*/
64101 +
64102 +static int
64103 +glob_match(const char *p, const char *n)
64104 +{
64105 + char c;
64106 +
64107 + while ((c = *p++) != '\0') {
64108 + switch (c) {
64109 + case '?':
64110 + if (*n == '\0')
64111 + return 1;
64112 + else if (*n == '/')
64113 + return 1;
64114 + break;
64115 + case '\\':
64116 + if (*n != c)
64117 + return 1;
64118 + break;
64119 + case '*':
64120 + for (c = *p++; c == '?' || c == '*'; c = *p++) {
64121 + if (*n == '/')
64122 + return 1;
64123 + else if (c == '?') {
64124 + if (*n == '\0')
64125 + return 1;
64126 + else
64127 + ++n;
64128 + }
64129 + }
64130 + if (c == '\0') {
64131 + return 0;
64132 + } else {
64133 + const char *endp;
64134 +
64135 + if ((endp = strchr(n, '/')) == NULL)
64136 + endp = n + strlen(n);
64137 +
64138 + if (c == '[') {
64139 + for (--p; n < endp; ++n)
64140 + if (!glob_match(p, n))
64141 + return 0;
64142 + } else if (c == '/') {
64143 + while (*n != '\0' && *n != '/')
64144 + ++n;
64145 + if (*n == '/' && !glob_match(p, n + 1))
64146 + return 0;
64147 + } else {
64148 + for (--p; n < endp; ++n)
64149 + if (*n == c && !glob_match(p, n))
64150 + return 0;
64151 + }
64152 +
64153 + return 1;
64154 + }
64155 + case '[':
64156 + {
64157 + int not;
64158 + char cold;
64159 +
64160 + if (*n == '\0' || *n == '/')
64161 + return 1;
64162 +
64163 + not = (*p == '!' || *p == '^');
64164 + if (not)
64165 + ++p;
64166 +
64167 + c = *p++;
64168 + for (;;) {
64169 + unsigned char fn = (unsigned char)*n;
64170 +
64171 + if (c == '\0')
64172 + return 1;
64173 + else {
64174 + if (c == fn)
64175 + goto matched;
64176 + cold = c;
64177 + c = *p++;
64178 +
64179 + if (c == '-' && *p != ']') {
64180 + unsigned char cend = *p++;
64181 +
64182 + if (cend == '\0')
64183 + return 1;
64184 +
64185 + if (cold <= fn && fn <= cend)
64186 + goto matched;
64187 +
64188 + c = *p++;
64189 + }
64190 + }
64191 +
64192 + if (c == ']')
64193 + break;
64194 + }
64195 + if (!not)
64196 + return 1;
64197 + break;
64198 + matched:
64199 + while (c != ']') {
64200 + if (c == '\0')
64201 + return 1;
64202 +
64203 + c = *p++;
64204 + }
64205 + if (not)
64206 + return 1;
64207 + }
64208 + break;
64209 + default:
64210 + if (c != *n)
64211 + return 1;
64212 + }
64213 +
64214 + ++n;
64215 + }
64216 +
64217 + if (*n == '\0')
64218 + return 0;
64219 +
64220 + if (*n == '/')
64221 + return 0;
64222 +
64223 + return 1;
64224 +}
64225 +
64226 +static struct acl_object_label *
64227 +chk_glob_label(struct acl_object_label *globbed,
64228 + const struct dentry *dentry, const struct vfsmount *mnt, char **path)
64229 +{
64230 + struct acl_object_label *tmp;
64231 +
64232 + if (*path == NULL)
64233 + *path = gr_to_filename_nolock(dentry, mnt);
64234 +
64235 + tmp = globbed;
64236 +
64237 + while (tmp) {
64238 + if (!glob_match(tmp->filename, *path))
64239 + return tmp;
64240 + tmp = tmp->next;
64241 + }
64242 +
64243 + return NULL;
64244 +}
64245 +
64246 +static struct acl_object_label *
64247 +__full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
64248 + const ino_t curr_ino, const dev_t curr_dev,
64249 + const struct acl_subject_label *subj, char **path, const int checkglob)
64250 +{
64251 + struct acl_subject_label *tmpsubj;
64252 + struct acl_object_label *retval;
64253 + struct acl_object_label *retval2;
64254 +
64255 + tmpsubj = (struct acl_subject_label *) subj;
64256 + read_lock(&gr_inode_lock);
64257 + do {
64258 + retval = lookup_acl_obj_label(curr_ino, curr_dev, tmpsubj);
64259 + if (retval) {
64260 + if (checkglob && retval->globbed) {
64261 + retval2 = chk_glob_label(retval->globbed, orig_dentry, orig_mnt, path);
64262 + if (retval2)
64263 + retval = retval2;
64264 + }
64265 + break;
64266 + }
64267 + } while ((tmpsubj = tmpsubj->parent_subject));
64268 + read_unlock(&gr_inode_lock);
64269 +
64270 + return retval;
64271 +}
64272 +
64273 +static __inline__ struct acl_object_label *
64274 +full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
64275 + struct dentry *curr_dentry,
64276 + const struct acl_subject_label *subj, char **path, const int checkglob)
64277 +{
64278 + int newglob = checkglob;
64279 + ino_t inode;
64280 + dev_t device;
64281 +
64282 + /* if we aren't checking a subdirectory of the original path yet, don't do glob checking
64283 + as we don't want a / * rule to match instead of the / object
64284 + don't do this for create lookups that call this function though, since they're looking up
64285 + on the parent and thus need globbing checks on all paths
64286 + */
64287 + if (orig_dentry == curr_dentry && newglob != GR_CREATE_GLOB)
64288 + newglob = GR_NO_GLOB;
64289 +
64290 + spin_lock(&curr_dentry->d_lock);
64291 + inode = curr_dentry->d_inode->i_ino;
64292 + device = __get_dev(curr_dentry);
64293 + spin_unlock(&curr_dentry->d_lock);
64294 +
64295 + return __full_lookup(orig_dentry, orig_mnt, inode, device, subj, path, newglob);
64296 +}
64297 +
64298 +#ifdef CONFIG_HUGETLBFS
64299 +static inline bool
64300 +is_hugetlbfs_mnt(const struct vfsmount *mnt)
64301 +{
64302 + int i;
64303 + for (i = 0; i < HUGE_MAX_HSTATE; i++) {
64304 + if (unlikely(hugetlbfs_vfsmount[i] == mnt))
64305 + return true;
64306 + }
64307 +
64308 + return false;
64309 +}
64310 +#endif
64311 +
64312 +static struct acl_object_label *
64313 +__chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
64314 + const struct acl_subject_label *subj, char *path, const int checkglob)
64315 +{
64316 + struct dentry *dentry = (struct dentry *) l_dentry;
64317 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
64318 + struct mount *real_mnt = real_mount(mnt);
64319 + struct acl_object_label *retval;
64320 + struct dentry *parent;
64321 +
64322 + br_read_lock(&vfsmount_lock);
64323 + write_seqlock(&rename_lock);
64324 +
64325 + if (unlikely((mnt == shm_mnt && dentry->d_inode->i_nlink == 0) || mnt == pipe_mnt ||
64326 +#ifdef CONFIG_NET
64327 + mnt == sock_mnt ||
64328 +#endif
64329 +#ifdef CONFIG_HUGETLBFS
64330 + (is_hugetlbfs_mnt(mnt) && dentry->d_inode->i_nlink == 0) ||
64331 +#endif
64332 + /* ignore Eric Biederman */
64333 + IS_PRIVATE(l_dentry->d_inode))) {
64334 + retval = (subj->mode & GR_SHMEXEC) ? fakefs_obj_rwx : fakefs_obj_rw;
64335 + goto out;
64336 + }
64337 +
64338 + for (;;) {
64339 + if (dentry == gr_real_root.dentry && mnt == gr_real_root.mnt)
64340 + break;
64341 +
64342 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
64343 + if (!mnt_has_parent(real_mnt))
64344 + break;
64345 +
64346 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
64347 + if (retval != NULL)
64348 + goto out;
64349 +
64350 + dentry = real_mnt->mnt_mountpoint;
64351 + real_mnt = real_mnt->mnt_parent;
64352 + mnt = &real_mnt->mnt;
64353 + continue;
64354 + }
64355 +
64356 + parent = dentry->d_parent;
64357 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
64358 + if (retval != NULL)
64359 + goto out;
64360 +
64361 + dentry = parent;
64362 + }
64363 +
64364 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
64365 +
64366 + /* gr_real_root is pinned so we don't have to hold a reference */
64367 + if (retval == NULL)
64368 + retval = full_lookup(l_dentry, l_mnt, gr_real_root.dentry, subj, &path, checkglob);
64369 +out:
64370 + write_sequnlock(&rename_lock);
64371 + br_read_unlock(&vfsmount_lock);
64372 +
64373 + BUG_ON(retval == NULL);
64374 +
64375 + return retval;
64376 +}
64377 +
64378 +static __inline__ struct acl_object_label *
64379 +chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
64380 + const struct acl_subject_label *subj)
64381 +{
64382 + char *path = NULL;
64383 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_REG_GLOB);
64384 +}
64385 +
64386 +static __inline__ struct acl_object_label *
64387 +chk_obj_label_noglob(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
64388 + const struct acl_subject_label *subj)
64389 +{
64390 + char *path = NULL;
64391 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_NO_GLOB);
64392 +}
64393 +
64394 +static __inline__ struct acl_object_label *
64395 +chk_obj_create_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
64396 + const struct acl_subject_label *subj, char *path)
64397 +{
64398 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_CREATE_GLOB);
64399 +}
64400 +
64401 +struct acl_subject_label *
64402 +chk_subj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
64403 + const struct acl_role_label *role)
64404 +{
64405 + struct dentry *dentry = (struct dentry *) l_dentry;
64406 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
64407 + struct mount *real_mnt = real_mount(mnt);
64408 + struct acl_subject_label *retval;
64409 + struct dentry *parent;
64410 +
64411 + br_read_lock(&vfsmount_lock);
64412 + write_seqlock(&rename_lock);
64413 +
64414 + for (;;) {
64415 + if (dentry == gr_real_root.dentry && mnt == gr_real_root.mnt)
64416 + break;
64417 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
64418 + if (!mnt_has_parent(real_mnt))
64419 + break;
64420 +
64421 + spin_lock(&dentry->d_lock);
64422 + read_lock(&gr_inode_lock);
64423 + retval =
64424 + lookup_acl_subj_label(dentry->d_inode->i_ino,
64425 + __get_dev(dentry), role);
64426 + read_unlock(&gr_inode_lock);
64427 + spin_unlock(&dentry->d_lock);
64428 + if (retval != NULL)
64429 + goto out;
64430 +
64431 + dentry = real_mnt->mnt_mountpoint;
64432 + real_mnt = real_mnt->mnt_parent;
64433 + mnt = &real_mnt->mnt;
64434 + continue;
64435 + }
64436 +
64437 + spin_lock(&dentry->d_lock);
64438 + read_lock(&gr_inode_lock);
64439 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
64440 + __get_dev(dentry), role);
64441 + read_unlock(&gr_inode_lock);
64442 + parent = dentry->d_parent;
64443 + spin_unlock(&dentry->d_lock);
64444 +
64445 + if (retval != NULL)
64446 + goto out;
64447 +
64448 + dentry = parent;
64449 + }
64450 +
64451 + spin_lock(&dentry->d_lock);
64452 + read_lock(&gr_inode_lock);
64453 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
64454 + __get_dev(dentry), role);
64455 + read_unlock(&gr_inode_lock);
64456 + spin_unlock(&dentry->d_lock);
64457 +
64458 + if (unlikely(retval == NULL)) {
64459 + /* gr_real_root is pinned, we don't need to hold a reference */
64460 + read_lock(&gr_inode_lock);
64461 + retval = lookup_acl_subj_label(gr_real_root.dentry->d_inode->i_ino,
64462 + __get_dev(gr_real_root.dentry), role);
64463 + read_unlock(&gr_inode_lock);
64464 + }
64465 +out:
64466 + write_sequnlock(&rename_lock);
64467 + br_read_unlock(&vfsmount_lock);
64468 +
64469 + BUG_ON(retval == NULL);
64470 +
64471 + return retval;
64472 +}
64473 +
64474 +void
64475 +assign_special_role(const char *rolename)
64476 +{
64477 + struct acl_object_label *obj;
64478 + struct acl_role_label *r;
64479 + struct acl_role_label *assigned = NULL;
64480 + struct task_struct *tsk;
64481 + struct file *filp;
64482 +
64483 + FOR_EACH_ROLE_START(r)
64484 + if (!strcmp(rolename, r->rolename) &&
64485 + (r->roletype & GR_ROLE_SPECIAL)) {
64486 + assigned = r;
64487 + break;
64488 + }
64489 + FOR_EACH_ROLE_END(r)
64490 +
64491 + if (!assigned)
64492 + return;
64493 +
64494 + read_lock(&tasklist_lock);
64495 + read_lock(&grsec_exec_file_lock);
64496 +
64497 + tsk = current->real_parent;
64498 + if (tsk == NULL)
64499 + goto out_unlock;
64500 +
64501 + filp = tsk->exec_file;
64502 + if (filp == NULL)
64503 + goto out_unlock;
64504 +
64505 + tsk->is_writable = 0;
64506 + tsk->inherited = 0;
64507 +
64508 + tsk->acl_sp_role = 1;
64509 + tsk->acl_role_id = ++acl_sp_role_value;
64510 + tsk->role = assigned;
64511 + tsk->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role);
64512 +
64513 + /* ignore additional mmap checks for processes that are writable
64514 + by the default ACL */
64515 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, running_polstate.default_role->root_label);
64516 + if (unlikely(obj->mode & GR_WRITE))
64517 + tsk->is_writable = 1;
64518 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role->root_label);
64519 + if (unlikely(obj->mode & GR_WRITE))
64520 + tsk->is_writable = 1;
64521 +
64522 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
64523 + printk(KERN_ALERT "Assigning special role:%s subject:%s to process (%s:%d)\n", tsk->role->rolename,
64524 + tsk->acl->filename, tsk->comm, task_pid_nr(tsk));
64525 +#endif
64526 +
64527 +out_unlock:
64528 + read_unlock(&grsec_exec_file_lock);
64529 + read_unlock(&tasklist_lock);
64530 + return;
64531 +}
64532 +
64533 +
64534 +static void
64535 +gr_log_learn(const struct dentry *dentry, const struct vfsmount *mnt, const __u32 mode)
64536 +{
64537 + struct task_struct *task = current;
64538 + const struct cred *cred = current_cred();
64539 +
64540 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename, task->role->roletype,
64541 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
64542 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
64543 + 1UL, 1UL, gr_to_filename(dentry, mnt), (unsigned long) mode, &task->signal->saved_ip);
64544 +
64545 + return;
64546 +}
64547 +
64548 +static void
64549 +gr_log_learn_uid_change(const kuid_t real, const kuid_t effective, const kuid_t fs)
64550 +{
64551 + struct task_struct *task = current;
64552 + const struct cred *cred = current_cred();
64553 +
64554 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
64555 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
64556 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
64557 + 'u', GR_GLOBAL_UID(real), GR_GLOBAL_UID(effective), GR_GLOBAL_UID(fs), &task->signal->saved_ip);
64558 +
64559 + return;
64560 +}
64561 +
64562 +static void
64563 +gr_log_learn_gid_change(const kgid_t real, const kgid_t effective, const kgid_t fs)
64564 +{
64565 + struct task_struct *task = current;
64566 + const struct cred *cred = current_cred();
64567 +
64568 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
64569 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
64570 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
64571 + 'g', GR_GLOBAL_GID(real), GR_GLOBAL_GID(effective), GR_GLOBAL_GID(fs), &task->signal->saved_ip);
64572 +
64573 + return;
64574 +}
64575 +
64576 +static void
64577 +gr_set_proc_res(struct task_struct *task)
64578 +{
64579 + struct acl_subject_label *proc;
64580 + unsigned short i;
64581 +
64582 + proc = task->acl;
64583 +
64584 + if (proc->mode & (GR_LEARN | GR_INHERITLEARN))
64585 + return;
64586 +
64587 + for (i = 0; i < RLIM_NLIMITS; i++) {
64588 + if (!(proc->resmask & (1U << i)))
64589 + continue;
64590 +
64591 + task->signal->rlim[i].rlim_cur = proc->res[i].rlim_cur;
64592 + task->signal->rlim[i].rlim_max = proc->res[i].rlim_max;
64593 +
64594 + if (i == RLIMIT_CPU)
64595 + update_rlimit_cpu(task, proc->res[i].rlim_cur);
64596 + }
64597 +
64598 + return;
64599 +}
64600 +
64601 +/* both of the below must be called with
64602 + rcu_read_lock();
64603 + read_lock(&tasklist_lock);
64604 + read_lock(&grsec_exec_file_lock);
64605 +*/
64606 +
64607 +struct acl_subject_label *__gr_get_subject_for_task(const struct gr_policy_state *state, struct task_struct *task, const char *filename)
64608 +{
64609 + char *tmpname;
64610 + struct acl_subject_label *tmpsubj;
64611 + struct file *filp;
64612 + struct name_entry *nmatch;
64613 +
64614 + filp = task->exec_file;
64615 + if (filp == NULL)
64616 + return NULL;
64617 +
64618 + /* the following is to apply the correct subject
64619 + on binaries running when the RBAC system
64620 + is enabled, when the binaries have been
64621 + replaced or deleted since their execution
64622 + -----
64623 + when the RBAC system starts, the inode/dev
64624 + from exec_file will be one the RBAC system
64625 + is unaware of. It only knows the inode/dev
64626 + of the present file on disk, or the absence
64627 + of it.
64628 + */
64629 +
64630 + if (filename)
64631 + nmatch = __lookup_name_entry(state, filename);
64632 + else {
64633 + preempt_disable();
64634 + tmpname = gr_to_filename_rbac(filp->f_path.dentry, filp->f_path.mnt);
64635 +
64636 + nmatch = __lookup_name_entry(state, tmpname);
64637 + preempt_enable();
64638 + }
64639 + tmpsubj = NULL;
64640 + if (nmatch) {
64641 + if (nmatch->deleted)
64642 + tmpsubj = lookup_acl_subj_label_deleted(nmatch->inode, nmatch->device, task->role);
64643 + else
64644 + tmpsubj = lookup_acl_subj_label(nmatch->inode, nmatch->device, task->role);
64645 + }
64646 + /* this also works for the reload case -- if we don't match a potentially inherited subject
64647 + then we fall back to a normal lookup based on the binary's ino/dev
64648 + */
64649 + if (tmpsubj == NULL)
64650 + tmpsubj = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, task->role);
64651 +
64652 + return tmpsubj;
64653 +}
64654 +
64655 +static struct acl_subject_label *gr_get_subject_for_task(struct task_struct *task, const char *filename)
64656 +{
64657 + return __gr_get_subject_for_task(&running_polstate, task, filename);
64658 +}
64659 +
64660 +void __gr_apply_subject_to_task(const struct gr_policy_state *state, struct task_struct *task, struct acl_subject_label *subj)
64661 +{
64662 + struct acl_object_label *obj;
64663 + struct file *filp;
64664 +
64665 + filp = task->exec_file;
64666 +
64667 + task->acl = subj;
64668 + task->is_writable = 0;
64669 + /* ignore additional mmap checks for processes that are writable
64670 + by the default ACL */
64671 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, state->default_role->root_label);
64672 + if (unlikely(obj->mode & GR_WRITE))
64673 + task->is_writable = 1;
64674 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
64675 + if (unlikely(obj->mode & GR_WRITE))
64676 + task->is_writable = 1;
64677 +
64678 + gr_set_proc_res(task);
64679 +
64680 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
64681 + 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);
64682 +#endif
64683 +}
64684 +
64685 +static void gr_apply_subject_to_task(struct task_struct *task, struct acl_subject_label *subj)
64686 +{
64687 + __gr_apply_subject_to_task(&running_polstate, task, subj);
64688 +}
64689 +
64690 +__u32
64691 +gr_search_file(const struct dentry * dentry, const __u32 mode,
64692 + const struct vfsmount * mnt)
64693 +{
64694 + __u32 retval = mode;
64695 + struct acl_subject_label *curracl;
64696 + struct acl_object_label *currobj;
64697 +
64698 + if (unlikely(!(gr_status & GR_READY)))
64699 + return (mode & ~GR_AUDITS);
64700 +
64701 + curracl = current->acl;
64702 +
64703 + currobj = chk_obj_label(dentry, mnt, curracl);
64704 + retval = currobj->mode & mode;
64705 +
64706 + /* if we're opening a specified transfer file for writing
64707 + (e.g. /dev/initctl), then transfer our role to init
64708 + */
64709 + if (unlikely(currobj->mode & GR_INIT_TRANSFER && retval & GR_WRITE &&
64710 + current->role->roletype & GR_ROLE_PERSIST)) {
64711 + struct task_struct *task = init_pid_ns.child_reaper;
64712 +
64713 + if (task->role != current->role) {
64714 + struct acl_subject_label *subj;
64715 +
64716 + task->acl_sp_role = 0;
64717 + task->acl_role_id = current->acl_role_id;
64718 + task->role = current->role;
64719 + rcu_read_lock();
64720 + read_lock(&grsec_exec_file_lock);
64721 + subj = gr_get_subject_for_task(task, NULL);
64722 + gr_apply_subject_to_task(task, subj);
64723 + read_unlock(&grsec_exec_file_lock);
64724 + rcu_read_unlock();
64725 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_INIT_TRANSFER_MSG);
64726 + }
64727 + }
64728 +
64729 + if (unlikely
64730 + ((curracl->mode & (GR_LEARN | GR_INHERITLEARN)) && !(mode & GR_NOPTRACE)
64731 + && (retval != (mode & ~(GR_AUDITS | GR_SUPPRESS))))) {
64732 + __u32 new_mode = mode;
64733 +
64734 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
64735 +
64736 + retval = new_mode;
64737 +
64738 + if (new_mode & GR_EXEC && curracl->mode & GR_INHERITLEARN)
64739 + new_mode |= GR_INHERIT;
64740 +
64741 + if (!(mode & GR_NOLEARN))
64742 + gr_log_learn(dentry, mnt, new_mode);
64743 + }
64744 +
64745 + return retval;
64746 +}
64747 +
64748 +struct acl_object_label *gr_get_create_object(const struct dentry *new_dentry,
64749 + const struct dentry *parent,
64750 + const struct vfsmount *mnt)
64751 +{
64752 + struct name_entry *match;
64753 + struct acl_object_label *matchpo;
64754 + struct acl_subject_label *curracl;
64755 + char *path;
64756 +
64757 + if (unlikely(!(gr_status & GR_READY)))
64758 + return NULL;
64759 +
64760 + preempt_disable();
64761 + path = gr_to_filename_rbac(new_dentry, mnt);
64762 + match = lookup_name_entry_create(path);
64763 +
64764 + curracl = current->acl;
64765 +
64766 + if (match) {
64767 + read_lock(&gr_inode_lock);
64768 + matchpo = lookup_acl_obj_label_create(match->inode, match->device, curracl);
64769 + read_unlock(&gr_inode_lock);
64770 +
64771 + if (matchpo) {
64772 + preempt_enable();
64773 + return matchpo;
64774 + }
64775 + }
64776 +
64777 + // lookup parent
64778 +
64779 + matchpo = chk_obj_create_label(parent, mnt, curracl, path);
64780 +
64781 + preempt_enable();
64782 + return matchpo;
64783 +}
64784 +
64785 +__u32
64786 +gr_check_create(const struct dentry * new_dentry, const struct dentry * parent,
64787 + const struct vfsmount * mnt, const __u32 mode)
64788 +{
64789 + struct acl_object_label *matchpo;
64790 + __u32 retval;
64791 +
64792 + if (unlikely(!(gr_status & GR_READY)))
64793 + return (mode & ~GR_AUDITS);
64794 +
64795 + matchpo = gr_get_create_object(new_dentry, parent, mnt);
64796 +
64797 + retval = matchpo->mode & mode;
64798 +
64799 + if ((retval != (mode & ~(GR_AUDITS | GR_SUPPRESS)))
64800 + && (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
64801 + __u32 new_mode = mode;
64802 +
64803 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
64804 +
64805 + gr_log_learn(new_dentry, mnt, new_mode);
64806 + return new_mode;
64807 + }
64808 +
64809 + return retval;
64810 +}
64811 +
64812 +__u32
64813 +gr_check_link(const struct dentry * new_dentry,
64814 + const struct dentry * parent_dentry,
64815 + const struct vfsmount * parent_mnt,
64816 + const struct dentry * old_dentry, const struct vfsmount * old_mnt)
64817 +{
64818 + struct acl_object_label *obj;
64819 + __u32 oldmode, newmode;
64820 + __u32 needmode;
64821 + __u32 checkmodes = GR_FIND | GR_APPEND | GR_WRITE | GR_EXEC | GR_SETID | GR_READ |
64822 + GR_DELETE | GR_INHERIT;
64823 +
64824 + if (unlikely(!(gr_status & GR_READY)))
64825 + return (GR_CREATE | GR_LINK);
64826 +
64827 + obj = chk_obj_label(old_dentry, old_mnt, current->acl);
64828 + oldmode = obj->mode;
64829 +
64830 + obj = gr_get_create_object(new_dentry, parent_dentry, parent_mnt);
64831 + newmode = obj->mode;
64832 +
64833 + needmode = newmode & checkmodes;
64834 +
64835 + // old name for hardlink must have at least the permissions of the new name
64836 + if ((oldmode & needmode) != needmode)
64837 + goto bad;
64838 +
64839 + // if old name had restrictions/auditing, make sure the new name does as well
64840 + needmode = oldmode & (GR_NOPTRACE | GR_PTRACERD | GR_INHERIT | GR_AUDITS);
64841 +
64842 + // don't allow hardlinking of suid/sgid/fcapped files without permission
64843 + if (is_privileged_binary(old_dentry))
64844 + needmode |= GR_SETID;
64845 +
64846 + if ((newmode & needmode) != needmode)
64847 + goto bad;
64848 +
64849 + // enforce minimum permissions
64850 + if ((newmode & (GR_CREATE | GR_LINK)) == (GR_CREATE | GR_LINK))
64851 + return newmode;
64852 +bad:
64853 + needmode = oldmode;
64854 + if (is_privileged_binary(old_dentry))
64855 + needmode |= GR_SETID;
64856 +
64857 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN)) {
64858 + gr_log_learn(old_dentry, old_mnt, needmode | GR_CREATE | GR_LINK);
64859 + return (GR_CREATE | GR_LINK);
64860 + } else if (newmode & GR_SUPPRESS)
64861 + return GR_SUPPRESS;
64862 + else
64863 + return 0;
64864 +}
64865 +
64866 +int
64867 +gr_check_hidden_task(const struct task_struct *task)
64868 +{
64869 + if (unlikely(!(gr_status & GR_READY)))
64870 + return 0;
64871 +
64872 + if (!(task->acl->mode & GR_PROCFIND) && !(current->acl->mode & GR_VIEW))
64873 + return 1;
64874 +
64875 + return 0;
64876 +}
64877 +
64878 +int
64879 +gr_check_protected_task(const struct task_struct *task)
64880 +{
64881 + if (unlikely(!(gr_status & GR_READY) || !task))
64882 + return 0;
64883 +
64884 + if ((task->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
64885 + task->acl != current->acl)
64886 + return 1;
64887 +
64888 + return 0;
64889 +}
64890 +
64891 +int
64892 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
64893 +{
64894 + struct task_struct *p;
64895 + int ret = 0;
64896 +
64897 + if (unlikely(!(gr_status & GR_READY) || !pid))
64898 + return ret;
64899 +
64900 + read_lock(&tasklist_lock);
64901 + do_each_pid_task(pid, type, p) {
64902 + if ((p->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
64903 + p->acl != current->acl) {
64904 + ret = 1;
64905 + goto out;
64906 + }
64907 + } while_each_pid_task(pid, type, p);
64908 +out:
64909 + read_unlock(&tasklist_lock);
64910 +
64911 + return ret;
64912 +}
64913 +
64914 +void
64915 +gr_copy_label(struct task_struct *tsk)
64916 +{
64917 + struct task_struct *p = current;
64918 +
64919 + tsk->inherited = p->inherited;
64920 + tsk->acl_sp_role = 0;
64921 + tsk->acl_role_id = p->acl_role_id;
64922 + tsk->acl = p->acl;
64923 + tsk->role = p->role;
64924 + tsk->signal->used_accept = 0;
64925 + tsk->signal->curr_ip = p->signal->curr_ip;
64926 + tsk->signal->saved_ip = p->signal->saved_ip;
64927 + if (p->exec_file)
64928 + get_file(p->exec_file);
64929 + tsk->exec_file = p->exec_file;
64930 + tsk->is_writable = p->is_writable;
64931 + if (unlikely(p->signal->used_accept)) {
64932 + p->signal->curr_ip = 0;
64933 + p->signal->saved_ip = 0;
64934 + }
64935 +
64936 + return;
64937 +}
64938 +
64939 +extern int gr_process_kernel_setuid_ban(struct user_struct *user);
64940 +
64941 +int
64942 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
64943 +{
64944 + unsigned int i;
64945 + __u16 num;
64946 + uid_t *uidlist;
64947 + uid_t curuid;
64948 + int realok = 0;
64949 + int effectiveok = 0;
64950 + int fsok = 0;
64951 + uid_t globalreal, globaleffective, globalfs;
64952 +
64953 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT)
64954 + struct user_struct *user;
64955 +
64956 + if (!uid_valid(real))
64957 + goto skipit;
64958 +
64959 + /* find user based on global namespace */
64960 +
64961 + globalreal = GR_GLOBAL_UID(real);
64962 +
64963 + user = find_user(make_kuid(&init_user_ns, globalreal));
64964 + if (user == NULL)
64965 + goto skipit;
64966 +
64967 + if (gr_process_kernel_setuid_ban(user)) {
64968 + /* for find_user */
64969 + free_uid(user);
64970 + return 1;
64971 + }
64972 +
64973 + /* for find_user */
64974 + free_uid(user);
64975 +
64976 +skipit:
64977 +#endif
64978 +
64979 + if (unlikely(!(gr_status & GR_READY)))
64980 + return 0;
64981 +
64982 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
64983 + gr_log_learn_uid_change(real, effective, fs);
64984 +
64985 + num = current->acl->user_trans_num;
64986 + uidlist = current->acl->user_transitions;
64987 +
64988 + if (uidlist == NULL)
64989 + return 0;
64990 +
64991 + if (!uid_valid(real)) {
64992 + realok = 1;
64993 + globalreal = (uid_t)-1;
64994 + } else {
64995 + globalreal = GR_GLOBAL_UID(real);
64996 + }
64997 + if (!uid_valid(effective)) {
64998 + effectiveok = 1;
64999 + globaleffective = (uid_t)-1;
65000 + } else {
65001 + globaleffective = GR_GLOBAL_UID(effective);
65002 + }
65003 + if (!uid_valid(fs)) {
65004 + fsok = 1;
65005 + globalfs = (uid_t)-1;
65006 + } else {
65007 + globalfs = GR_GLOBAL_UID(fs);
65008 + }
65009 +
65010 + if (current->acl->user_trans_type & GR_ID_ALLOW) {
65011 + for (i = 0; i < num; i++) {
65012 + curuid = uidlist[i];
65013 + if (globalreal == curuid)
65014 + realok = 1;
65015 + if (globaleffective == curuid)
65016 + effectiveok = 1;
65017 + if (globalfs == curuid)
65018 + fsok = 1;
65019 + }
65020 + } else if (current->acl->user_trans_type & GR_ID_DENY) {
65021 + for (i = 0; i < num; i++) {
65022 + curuid = uidlist[i];
65023 + if (globalreal == curuid)
65024 + break;
65025 + if (globaleffective == curuid)
65026 + break;
65027 + if (globalfs == curuid)
65028 + break;
65029 + }
65030 + /* not in deny list */
65031 + if (i == num) {
65032 + realok = 1;
65033 + effectiveok = 1;
65034 + fsok = 1;
65035 + }
65036 + }
65037 +
65038 + if (realok && effectiveok && fsok)
65039 + return 0;
65040 + else {
65041 + gr_log_int(GR_DONT_AUDIT, GR_USRCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
65042 + return 1;
65043 + }
65044 +}
65045 +
65046 +int
65047 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
65048 +{
65049 + unsigned int i;
65050 + __u16 num;
65051 + gid_t *gidlist;
65052 + gid_t curgid;
65053 + int realok = 0;
65054 + int effectiveok = 0;
65055 + int fsok = 0;
65056 + gid_t globalreal, globaleffective, globalfs;
65057 +
65058 + if (unlikely(!(gr_status & GR_READY)))
65059 + return 0;
65060 +
65061 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
65062 + gr_log_learn_gid_change(real, effective, fs);
65063 +
65064 + num = current->acl->group_trans_num;
65065 + gidlist = current->acl->group_transitions;
65066 +
65067 + if (gidlist == NULL)
65068 + return 0;
65069 +
65070 + if (!gid_valid(real)) {
65071 + realok = 1;
65072 + globalreal = (gid_t)-1;
65073 + } else {
65074 + globalreal = GR_GLOBAL_GID(real);
65075 + }
65076 + if (!gid_valid(effective)) {
65077 + effectiveok = 1;
65078 + globaleffective = (gid_t)-1;
65079 + } else {
65080 + globaleffective = GR_GLOBAL_GID(effective);
65081 + }
65082 + if (!gid_valid(fs)) {
65083 + fsok = 1;
65084 + globalfs = (gid_t)-1;
65085 + } else {
65086 + globalfs = GR_GLOBAL_GID(fs);
65087 + }
65088 +
65089 + if (current->acl->group_trans_type & GR_ID_ALLOW) {
65090 + for (i = 0; i < num; i++) {
65091 + curgid = gidlist[i];
65092 + if (globalreal == curgid)
65093 + realok = 1;
65094 + if (globaleffective == curgid)
65095 + effectiveok = 1;
65096 + if (globalfs == curgid)
65097 + fsok = 1;
65098 + }
65099 + } else if (current->acl->group_trans_type & GR_ID_DENY) {
65100 + for (i = 0; i < num; i++) {
65101 + curgid = gidlist[i];
65102 + if (globalreal == curgid)
65103 + break;
65104 + if (globaleffective == curgid)
65105 + break;
65106 + if (globalfs == curgid)
65107 + break;
65108 + }
65109 + /* not in deny list */
65110 + if (i == num) {
65111 + realok = 1;
65112 + effectiveok = 1;
65113 + fsok = 1;
65114 + }
65115 + }
65116 +
65117 + if (realok && effectiveok && fsok)
65118 + return 0;
65119 + else {
65120 + gr_log_int(GR_DONT_AUDIT, GR_GRPCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
65121 + return 1;
65122 + }
65123 +}
65124 +
65125 +extern int gr_acl_is_capable(const int cap);
65126 +
65127 +void
65128 +gr_set_role_label(struct task_struct *task, const kuid_t kuid, const kgid_t kgid)
65129 +{
65130 + struct acl_role_label *role = task->role;
65131 + struct acl_subject_label *subj = NULL;
65132 + struct acl_object_label *obj;
65133 + struct file *filp;
65134 + uid_t uid;
65135 + gid_t gid;
65136 +
65137 + if (unlikely(!(gr_status & GR_READY)))
65138 + return;
65139 +
65140 + uid = GR_GLOBAL_UID(kuid);
65141 + gid = GR_GLOBAL_GID(kgid);
65142 +
65143 + filp = task->exec_file;
65144 +
65145 + /* kernel process, we'll give them the kernel role */
65146 + if (unlikely(!filp)) {
65147 + task->role = running_polstate.kernel_role;
65148 + task->acl = running_polstate.kernel_role->root_label;
65149 + return;
65150 + } else if (!task->role || !(task->role->roletype & GR_ROLE_SPECIAL)) {
65151 + /* save the current ip at time of role lookup so that the proper
65152 + IP will be learned for role_allowed_ip */
65153 + task->signal->saved_ip = task->signal->curr_ip;
65154 + role = lookup_acl_role_label(task, uid, gid);
65155 + }
65156 +
65157 + /* don't change the role if we're not a privileged process */
65158 + if (role && task->role != role &&
65159 + (((role->roletype & GR_ROLE_USER) && !gr_acl_is_capable(CAP_SETUID)) ||
65160 + ((role->roletype & GR_ROLE_GROUP) && !gr_acl_is_capable(CAP_SETGID))))
65161 + return;
65162 +
65163 + /* perform subject lookup in possibly new role
65164 + we can use this result below in the case where role == task->role
65165 + */
65166 + subj = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, role);
65167 +
65168 + /* if we changed uid/gid, but result in the same role
65169 + and are using inheritance, don't lose the inherited subject
65170 + if current subject is other than what normal lookup
65171 + would result in, we arrived via inheritance, don't
65172 + lose subject
65173 + */
65174 + if (role != task->role || (!(task->acl->mode & GR_INHERITLEARN) &&
65175 + (subj == task->acl)))
65176 + task->acl = subj;
65177 +
65178 + /* leave task->inherited unaffected */
65179 +
65180 + task->role = role;
65181 +
65182 + task->is_writable = 0;
65183 +
65184 + /* ignore additional mmap checks for processes that are writable
65185 + by the default ACL */
65186 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, running_polstate.default_role->root_label);
65187 + if (unlikely(obj->mode & GR_WRITE))
65188 + task->is_writable = 1;
65189 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
65190 + if (unlikely(obj->mode & GR_WRITE))
65191 + task->is_writable = 1;
65192 +
65193 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
65194 + 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);
65195 +#endif
65196 +
65197 + gr_set_proc_res(task);
65198 +
65199 + return;
65200 +}
65201 +
65202 +int
65203 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
65204 + const int unsafe_flags)
65205 +{
65206 + struct task_struct *task = current;
65207 + struct acl_subject_label *newacl;
65208 + struct acl_object_label *obj;
65209 + __u32 retmode;
65210 +
65211 + if (unlikely(!(gr_status & GR_READY)))
65212 + return 0;
65213 +
65214 + newacl = chk_subj_label(dentry, mnt, task->role);
65215 +
65216 + /* special handling for if we did an strace -f -p <pid> from an admin role, where pid then
65217 + did an exec
65218 + */
65219 + rcu_read_lock();
65220 + read_lock(&tasklist_lock);
65221 + if (task->ptrace && task->parent && ((task->parent->role->roletype & GR_ROLE_GOD) ||
65222 + (task->parent->acl->mode & GR_POVERRIDE))) {
65223 + read_unlock(&tasklist_lock);
65224 + rcu_read_unlock();
65225 + goto skip_check;
65226 + }
65227 + read_unlock(&tasklist_lock);
65228 + rcu_read_unlock();
65229 +
65230 + if (unsafe_flags && !(task->acl->mode & GR_POVERRIDE) && (task->acl != newacl) &&
65231 + !(task->role->roletype & GR_ROLE_GOD) &&
65232 + !gr_search_file(dentry, GR_PTRACERD, mnt) &&
65233 + !(task->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
65234 + if (unsafe_flags & LSM_UNSAFE_SHARE)
65235 + gr_log_fs_generic(GR_DONT_AUDIT, GR_UNSAFESHARE_EXEC_ACL_MSG, dentry, mnt);
65236 + else
65237 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_EXEC_ACL_MSG, dentry, mnt);
65238 + return -EACCES;
65239 + }
65240 +
65241 +skip_check:
65242 +
65243 + obj = chk_obj_label(dentry, mnt, task->acl);
65244 + retmode = obj->mode & (GR_INHERIT | GR_AUDIT_INHERIT);
65245 +
65246 + if (!(task->acl->mode & GR_INHERITLEARN) &&
65247 + ((newacl->mode & GR_LEARN) || !(retmode & GR_INHERIT))) {
65248 + if (obj->nested)
65249 + task->acl = obj->nested;
65250 + else
65251 + task->acl = newacl;
65252 + task->inherited = 0;
65253 + } else {
65254 + task->inherited = 1;
65255 + if (retmode & GR_INHERIT && retmode & GR_AUDIT_INHERIT)
65256 + gr_log_str_fs(GR_DO_AUDIT, GR_INHERIT_ACL_MSG, task->acl->filename, dentry, mnt);
65257 + }
65258 +
65259 + task->is_writable = 0;
65260 +
65261 + /* ignore additional mmap checks for processes that are writable
65262 + by the default ACL */
65263 + obj = chk_obj_label(dentry, mnt, running_polstate.default_role->root_label);
65264 + if (unlikely(obj->mode & GR_WRITE))
65265 + task->is_writable = 1;
65266 + obj = chk_obj_label(dentry, mnt, task->role->root_label);
65267 + if (unlikely(obj->mode & GR_WRITE))
65268 + task->is_writable = 1;
65269 +
65270 + gr_set_proc_res(task);
65271 +
65272 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
65273 + 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);
65274 +#endif
65275 + return 0;
65276 +}
65277 +
65278 +/* always called with valid inodev ptr */
65279 +static void
65280 +do_handle_delete(struct inodev_entry *inodev, const ino_t ino, const dev_t dev)
65281 +{
65282 + struct acl_object_label *matchpo;
65283 + struct acl_subject_label *matchps;
65284 + struct acl_subject_label *subj;
65285 + struct acl_role_label *role;
65286 + unsigned int x;
65287 +
65288 + FOR_EACH_ROLE_START(role)
65289 + FOR_EACH_SUBJECT_START(role, subj, x)
65290 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
65291 + matchpo->mode |= GR_DELETED;
65292 + FOR_EACH_SUBJECT_END(subj,x)
65293 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
65294 + /* nested subjects aren't in the role's subj_hash table */
65295 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
65296 + matchpo->mode |= GR_DELETED;
65297 + FOR_EACH_NESTED_SUBJECT_END(subj)
65298 + if ((matchps = lookup_acl_subj_label(ino, dev, role)) != NULL)
65299 + matchps->mode |= GR_DELETED;
65300 + FOR_EACH_ROLE_END(role)
65301 +
65302 + inodev->nentry->deleted = 1;
65303 +
65304 + return;
65305 +}
65306 +
65307 +void
65308 +gr_handle_delete(const ino_t ino, const dev_t dev)
65309 +{
65310 + struct inodev_entry *inodev;
65311 +
65312 + if (unlikely(!(gr_status & GR_READY)))
65313 + return;
65314 +
65315 + write_lock(&gr_inode_lock);
65316 + inodev = lookup_inodev_entry(ino, dev);
65317 + if (inodev != NULL)
65318 + do_handle_delete(inodev, ino, dev);
65319 + write_unlock(&gr_inode_lock);
65320 +
65321 + return;
65322 +}
65323 +
65324 +static void
65325 +update_acl_obj_label(const ino_t oldinode, const dev_t olddevice,
65326 + const ino_t newinode, const dev_t newdevice,
65327 + struct acl_subject_label *subj)
65328 +{
65329 + unsigned int index = gr_fhash(oldinode, olddevice, subj->obj_hash_size);
65330 + struct acl_object_label *match;
65331 +
65332 + match = subj->obj_hash[index];
65333 +
65334 + while (match && (match->inode != oldinode ||
65335 + match->device != olddevice ||
65336 + !(match->mode & GR_DELETED)))
65337 + match = match->next;
65338 +
65339 + if (match && (match->inode == oldinode)
65340 + && (match->device == olddevice)
65341 + && (match->mode & GR_DELETED)) {
65342 + if (match->prev == NULL) {
65343 + subj->obj_hash[index] = match->next;
65344 + if (match->next != NULL)
65345 + match->next->prev = NULL;
65346 + } else {
65347 + match->prev->next = match->next;
65348 + if (match->next != NULL)
65349 + match->next->prev = match->prev;
65350 + }
65351 + match->prev = NULL;
65352 + match->next = NULL;
65353 + match->inode = newinode;
65354 + match->device = newdevice;
65355 + match->mode &= ~GR_DELETED;
65356 +
65357 + insert_acl_obj_label(match, subj);
65358 + }
65359 +
65360 + return;
65361 +}
65362 +
65363 +static void
65364 +update_acl_subj_label(const ino_t oldinode, const dev_t olddevice,
65365 + const ino_t newinode, const dev_t newdevice,
65366 + struct acl_role_label *role)
65367 +{
65368 + unsigned int index = gr_fhash(oldinode, olddevice, role->subj_hash_size);
65369 + struct acl_subject_label *match;
65370 +
65371 + match = role->subj_hash[index];
65372 +
65373 + while (match && (match->inode != oldinode ||
65374 + match->device != olddevice ||
65375 + !(match->mode & GR_DELETED)))
65376 + match = match->next;
65377 +
65378 + if (match && (match->inode == oldinode)
65379 + && (match->device == olddevice)
65380 + && (match->mode & GR_DELETED)) {
65381 + if (match->prev == NULL) {
65382 + role->subj_hash[index] = match->next;
65383 + if (match->next != NULL)
65384 + match->next->prev = NULL;
65385 + } else {
65386 + match->prev->next = match->next;
65387 + if (match->next != NULL)
65388 + match->next->prev = match->prev;
65389 + }
65390 + match->prev = NULL;
65391 + match->next = NULL;
65392 + match->inode = newinode;
65393 + match->device = newdevice;
65394 + match->mode &= ~GR_DELETED;
65395 +
65396 + insert_acl_subj_label(match, role);
65397 + }
65398 +
65399 + return;
65400 +}
65401 +
65402 +static void
65403 +update_inodev_entry(const ino_t oldinode, const dev_t olddevice,
65404 + const ino_t newinode, const dev_t newdevice)
65405 +{
65406 + unsigned int index = gr_fhash(oldinode, olddevice, running_polstate.inodev_set.i_size);
65407 + struct inodev_entry *match;
65408 +
65409 + match = running_polstate.inodev_set.i_hash[index];
65410 +
65411 + while (match && (match->nentry->inode != oldinode ||
65412 + match->nentry->device != olddevice || !match->nentry->deleted))
65413 + match = match->next;
65414 +
65415 + if (match && (match->nentry->inode == oldinode)
65416 + && (match->nentry->device == olddevice) &&
65417 + match->nentry->deleted) {
65418 + if (match->prev == NULL) {
65419 + running_polstate.inodev_set.i_hash[index] = match->next;
65420 + if (match->next != NULL)
65421 + match->next->prev = NULL;
65422 + } else {
65423 + match->prev->next = match->next;
65424 + if (match->next != NULL)
65425 + match->next->prev = match->prev;
65426 + }
65427 + match->prev = NULL;
65428 + match->next = NULL;
65429 + match->nentry->inode = newinode;
65430 + match->nentry->device = newdevice;
65431 + match->nentry->deleted = 0;
65432 +
65433 + insert_inodev_entry(match);
65434 + }
65435 +
65436 + return;
65437 +}
65438 +
65439 +static void
65440 +__do_handle_create(const struct name_entry *matchn, ino_t ino, dev_t dev)
65441 +{
65442 + struct acl_subject_label *subj;
65443 + struct acl_role_label *role;
65444 + unsigned int x;
65445 +
65446 + FOR_EACH_ROLE_START(role)
65447 + update_acl_subj_label(matchn->inode, matchn->device, ino, dev, role);
65448 +
65449 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
65450 + if ((subj->inode == ino) && (subj->device == dev)) {
65451 + subj->inode = ino;
65452 + subj->device = dev;
65453 + }
65454 + /* nested subjects aren't in the role's subj_hash table */
65455 + update_acl_obj_label(matchn->inode, matchn->device,
65456 + ino, dev, subj);
65457 + FOR_EACH_NESTED_SUBJECT_END(subj)
65458 + FOR_EACH_SUBJECT_START(role, subj, x)
65459 + update_acl_obj_label(matchn->inode, matchn->device,
65460 + ino, dev, subj);
65461 + FOR_EACH_SUBJECT_END(subj,x)
65462 + FOR_EACH_ROLE_END(role)
65463 +
65464 + update_inodev_entry(matchn->inode, matchn->device, ino, dev);
65465 +
65466 + return;
65467 +}
65468 +
65469 +static void
65470 +do_handle_create(const struct name_entry *matchn, const struct dentry *dentry,
65471 + const struct vfsmount *mnt)
65472 +{
65473 + ino_t ino = dentry->d_inode->i_ino;
65474 + dev_t dev = __get_dev(dentry);
65475 +
65476 + __do_handle_create(matchn, ino, dev);
65477 +
65478 + return;
65479 +}
65480 +
65481 +void
65482 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
65483 +{
65484 + struct name_entry *matchn;
65485 +
65486 + if (unlikely(!(gr_status & GR_READY)))
65487 + return;
65488 +
65489 + preempt_disable();
65490 + matchn = lookup_name_entry(gr_to_filename_rbac(dentry, mnt));
65491 +
65492 + if (unlikely((unsigned long)matchn)) {
65493 + write_lock(&gr_inode_lock);
65494 + do_handle_create(matchn, dentry, mnt);
65495 + write_unlock(&gr_inode_lock);
65496 + }
65497 + preempt_enable();
65498 +
65499 + return;
65500 +}
65501 +
65502 +void
65503 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
65504 +{
65505 + struct name_entry *matchn;
65506 +
65507 + if (unlikely(!(gr_status & GR_READY)))
65508 + return;
65509 +
65510 + preempt_disable();
65511 + matchn = lookup_name_entry(gr_to_proc_filename_rbac(dentry, init_pid_ns.proc_mnt));
65512 +
65513 + if (unlikely((unsigned long)matchn)) {
65514 + write_lock(&gr_inode_lock);
65515 + __do_handle_create(matchn, inode->i_ino, inode->i_sb->s_dev);
65516 + write_unlock(&gr_inode_lock);
65517 + }
65518 + preempt_enable();
65519 +
65520 + return;
65521 +}
65522 +
65523 +void
65524 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
65525 + struct dentry *old_dentry,
65526 + struct dentry *new_dentry,
65527 + struct vfsmount *mnt, const __u8 replace)
65528 +{
65529 + struct name_entry *matchn;
65530 + struct inodev_entry *inodev;
65531 + struct inode *inode = new_dentry->d_inode;
65532 + ino_t old_ino = old_dentry->d_inode->i_ino;
65533 + dev_t old_dev = __get_dev(old_dentry);
65534 +
65535 + /* vfs_rename swaps the name and parent link for old_dentry and
65536 + new_dentry
65537 + at this point, old_dentry has the new name, parent link, and inode
65538 + for the renamed file
65539 + if a file is being replaced by a rename, new_dentry has the inode
65540 + and name for the replaced file
65541 + */
65542 +
65543 + if (unlikely(!(gr_status & GR_READY)))
65544 + return;
65545 +
65546 + preempt_disable();
65547 + matchn = lookup_name_entry(gr_to_filename_rbac(old_dentry, mnt));
65548 +
65549 + /* we wouldn't have to check d_inode if it weren't for
65550 + NFS silly-renaming
65551 + */
65552 +
65553 + write_lock(&gr_inode_lock);
65554 + if (unlikely(replace && inode)) {
65555 + ino_t new_ino = inode->i_ino;
65556 + dev_t new_dev = __get_dev(new_dentry);
65557 +
65558 + inodev = lookup_inodev_entry(new_ino, new_dev);
65559 + if (inodev != NULL && ((inode->i_nlink <= 1) || S_ISDIR(inode->i_mode)))
65560 + do_handle_delete(inodev, new_ino, new_dev);
65561 + }
65562 +
65563 + inodev = lookup_inodev_entry(old_ino, old_dev);
65564 + if (inodev != NULL && ((old_dentry->d_inode->i_nlink <= 1) || S_ISDIR(old_dentry->d_inode->i_mode)))
65565 + do_handle_delete(inodev, old_ino, old_dev);
65566 +
65567 + if (unlikely((unsigned long)matchn))
65568 + do_handle_create(matchn, old_dentry, mnt);
65569 +
65570 + write_unlock(&gr_inode_lock);
65571 + preempt_enable();
65572 +
65573 + return;
65574 +}
65575 +
65576 +#if defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC)
65577 +static const unsigned long res_learn_bumps[GR_NLIMITS] = {
65578 + [RLIMIT_CPU] = GR_RLIM_CPU_BUMP,
65579 + [RLIMIT_FSIZE] = GR_RLIM_FSIZE_BUMP,
65580 + [RLIMIT_DATA] = GR_RLIM_DATA_BUMP,
65581 + [RLIMIT_STACK] = GR_RLIM_STACK_BUMP,
65582 + [RLIMIT_CORE] = GR_RLIM_CORE_BUMP,
65583 + [RLIMIT_RSS] = GR_RLIM_RSS_BUMP,
65584 + [RLIMIT_NPROC] = GR_RLIM_NPROC_BUMP,
65585 + [RLIMIT_NOFILE] = GR_RLIM_NOFILE_BUMP,
65586 + [RLIMIT_MEMLOCK] = GR_RLIM_MEMLOCK_BUMP,
65587 + [RLIMIT_AS] = GR_RLIM_AS_BUMP,
65588 + [RLIMIT_LOCKS] = GR_RLIM_LOCKS_BUMP,
65589 + [RLIMIT_SIGPENDING] = GR_RLIM_SIGPENDING_BUMP,
65590 + [RLIMIT_MSGQUEUE] = GR_RLIM_MSGQUEUE_BUMP,
65591 + [RLIMIT_NICE] = GR_RLIM_NICE_BUMP,
65592 + [RLIMIT_RTPRIO] = GR_RLIM_RTPRIO_BUMP,
65593 + [RLIMIT_RTTIME] = GR_RLIM_RTTIME_BUMP
65594 +};
65595 +
65596 +void
65597 +gr_learn_resource(const struct task_struct *task,
65598 + const int res, const unsigned long wanted, const int gt)
65599 +{
65600 + struct acl_subject_label *acl;
65601 + const struct cred *cred;
65602 +
65603 + if (unlikely((gr_status & GR_READY) &&
65604 + task->acl && (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))))
65605 + goto skip_reslog;
65606 +
65607 + gr_log_resource(task, res, wanted, gt);
65608 +skip_reslog:
65609 +
65610 + if (unlikely(!(gr_status & GR_READY) || !wanted || res >= GR_NLIMITS))
65611 + return;
65612 +
65613 + acl = task->acl;
65614 +
65615 + if (likely(!acl || !(acl->mode & (GR_LEARN | GR_INHERITLEARN)) ||
65616 + !(acl->resmask & (1U << (unsigned short) res))))
65617 + return;
65618 +
65619 + if (wanted >= acl->res[res].rlim_cur) {
65620 + unsigned long res_add;
65621 +
65622 + res_add = wanted + res_learn_bumps[res];
65623 +
65624 + acl->res[res].rlim_cur = res_add;
65625 +
65626 + if (wanted > acl->res[res].rlim_max)
65627 + acl->res[res].rlim_max = res_add;
65628 +
65629 + /* only log the subject filename, since resource logging is supported for
65630 + single-subject learning only */
65631 + rcu_read_lock();
65632 + cred = __task_cred(task);
65633 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
65634 + task->role->roletype, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), acl->filename,
65635 + acl->filename, acl->res[res].rlim_cur, acl->res[res].rlim_max,
65636 + "", (unsigned long) res, &task->signal->saved_ip);
65637 + rcu_read_unlock();
65638 + }
65639 +
65640 + return;
65641 +}
65642 +EXPORT_SYMBOL(gr_learn_resource);
65643 +#endif
65644 +
65645 +#if defined(CONFIG_PAX_HAVE_ACL_FLAGS) && (defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR))
65646 +void
65647 +pax_set_initial_flags(struct linux_binprm *bprm)
65648 +{
65649 + struct task_struct *task = current;
65650 + struct acl_subject_label *proc;
65651 + unsigned long flags;
65652 +
65653 + if (unlikely(!(gr_status & GR_READY)))
65654 + return;
65655 +
65656 + flags = pax_get_flags(task);
65657 +
65658 + proc = task->acl;
65659 +
65660 + if (proc->pax_flags & GR_PAX_DISABLE_PAGEEXEC)
65661 + flags &= ~MF_PAX_PAGEEXEC;
65662 + if (proc->pax_flags & GR_PAX_DISABLE_SEGMEXEC)
65663 + flags &= ~MF_PAX_SEGMEXEC;
65664 + if (proc->pax_flags & GR_PAX_DISABLE_RANDMMAP)
65665 + flags &= ~MF_PAX_RANDMMAP;
65666 + if (proc->pax_flags & GR_PAX_DISABLE_EMUTRAMP)
65667 + flags &= ~MF_PAX_EMUTRAMP;
65668 + if (proc->pax_flags & GR_PAX_DISABLE_MPROTECT)
65669 + flags &= ~MF_PAX_MPROTECT;
65670 +
65671 + if (proc->pax_flags & GR_PAX_ENABLE_PAGEEXEC)
65672 + flags |= MF_PAX_PAGEEXEC;
65673 + if (proc->pax_flags & GR_PAX_ENABLE_SEGMEXEC)
65674 + flags |= MF_PAX_SEGMEXEC;
65675 + if (proc->pax_flags & GR_PAX_ENABLE_RANDMMAP)
65676 + flags |= MF_PAX_RANDMMAP;
65677 + if (proc->pax_flags & GR_PAX_ENABLE_EMUTRAMP)
65678 + flags |= MF_PAX_EMUTRAMP;
65679 + if (proc->pax_flags & GR_PAX_ENABLE_MPROTECT)
65680 + flags |= MF_PAX_MPROTECT;
65681 +
65682 + pax_set_flags(task, flags);
65683 +
65684 + return;
65685 +}
65686 +#endif
65687 +
65688 +int
65689 +gr_handle_proc_ptrace(struct task_struct *task)
65690 +{
65691 + struct file *filp;
65692 + struct task_struct *tmp = task;
65693 + struct task_struct *curtemp = current;
65694 + __u32 retmode;
65695 +
65696 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
65697 + if (unlikely(!(gr_status & GR_READY)))
65698 + return 0;
65699 +#endif
65700 +
65701 + read_lock(&tasklist_lock);
65702 + read_lock(&grsec_exec_file_lock);
65703 + filp = task->exec_file;
65704 +
65705 + while (task_pid_nr(tmp) > 0) {
65706 + if (tmp == curtemp)
65707 + break;
65708 + tmp = tmp->real_parent;
65709 + }
65710 +
65711 + if (!filp || (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
65712 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE))))) {
65713 + read_unlock(&grsec_exec_file_lock);
65714 + read_unlock(&tasklist_lock);
65715 + return 1;
65716 + }
65717 +
65718 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
65719 + if (!(gr_status & GR_READY)) {
65720 + read_unlock(&grsec_exec_file_lock);
65721 + read_unlock(&tasklist_lock);
65722 + return 0;
65723 + }
65724 +#endif
65725 +
65726 + retmode = gr_search_file(filp->f_path.dentry, GR_NOPTRACE, filp->f_path.mnt);
65727 + read_unlock(&grsec_exec_file_lock);
65728 + read_unlock(&tasklist_lock);
65729 +
65730 + if (retmode & GR_NOPTRACE)
65731 + return 1;
65732 +
65733 + if (!(current->acl->mode & GR_POVERRIDE) && !(current->role->roletype & GR_ROLE_GOD)
65734 + && (current->acl != task->acl || (current->acl != current->role->root_label
65735 + && task_pid_nr(current) != task_pid_nr(task))))
65736 + return 1;
65737 +
65738 + return 0;
65739 +}
65740 +
65741 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p)
65742 +{
65743 + if (unlikely(!(gr_status & GR_READY)))
65744 + return;
65745 +
65746 + if (!(current->role->roletype & GR_ROLE_GOD))
65747 + return;
65748 +
65749 + seq_printf(m, "RBAC:\t%.64s:%c:%.950s\n",
65750 + p->role->rolename, gr_task_roletype_to_char(p),
65751 + p->acl->filename);
65752 +}
65753 +
65754 +int
65755 +gr_handle_ptrace(struct task_struct *task, const long request)
65756 +{
65757 + struct task_struct *tmp = task;
65758 + struct task_struct *curtemp = current;
65759 + __u32 retmode;
65760 +
65761 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
65762 + if (unlikely(!(gr_status & GR_READY)))
65763 + return 0;
65764 +#endif
65765 + if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
65766 + read_lock(&tasklist_lock);
65767 + while (task_pid_nr(tmp) > 0) {
65768 + if (tmp == curtemp)
65769 + break;
65770 + tmp = tmp->real_parent;
65771 + }
65772 +
65773 + if (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
65774 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE)))) {
65775 + read_unlock(&tasklist_lock);
65776 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
65777 + return 1;
65778 + }
65779 + read_unlock(&tasklist_lock);
65780 + }
65781 +
65782 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
65783 + if (!(gr_status & GR_READY))
65784 + return 0;
65785 +#endif
65786 +
65787 + read_lock(&grsec_exec_file_lock);
65788 + if (unlikely(!task->exec_file)) {
65789 + read_unlock(&grsec_exec_file_lock);
65790 + return 0;
65791 + }
65792 +
65793 + retmode = gr_search_file(task->exec_file->f_path.dentry, GR_PTRACERD | GR_NOPTRACE, task->exec_file->f_path.mnt);
65794 + read_unlock(&grsec_exec_file_lock);
65795 +
65796 + if (retmode & GR_NOPTRACE) {
65797 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
65798 + return 1;
65799 + }
65800 +
65801 + if (retmode & GR_PTRACERD) {
65802 + switch (request) {
65803 + case PTRACE_SEIZE:
65804 + case PTRACE_POKETEXT:
65805 + case PTRACE_POKEDATA:
65806 + case PTRACE_POKEUSR:
65807 +#if !defined(CONFIG_PPC32) && !defined(CONFIG_PPC64) && !defined(CONFIG_PARISC) && !defined(CONFIG_ALPHA) && !defined(CONFIG_IA64)
65808 + case PTRACE_SETREGS:
65809 + case PTRACE_SETFPREGS:
65810 +#endif
65811 +#ifdef CONFIG_X86
65812 + case PTRACE_SETFPXREGS:
65813 +#endif
65814 +#ifdef CONFIG_ALTIVEC
65815 + case PTRACE_SETVRREGS:
65816 +#endif
65817 + return 1;
65818 + default:
65819 + return 0;
65820 + }
65821 + } else if (!(current->acl->mode & GR_POVERRIDE) &&
65822 + !(current->role->roletype & GR_ROLE_GOD) &&
65823 + (current->acl != task->acl)) {
65824 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
65825 + return 1;
65826 + }
65827 +
65828 + return 0;
65829 +}
65830 +
65831 +static int is_writable_mmap(const struct file *filp)
65832 +{
65833 + struct task_struct *task = current;
65834 + struct acl_object_label *obj, *obj2;
65835 +
65836 + if (gr_status & GR_READY && !(task->acl->mode & GR_OVERRIDE) &&
65837 + !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))) {
65838 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, running_polstate.default_role->root_label);
65839 + obj2 = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt,
65840 + task->role->root_label);
65841 + if (unlikely((obj->mode & GR_WRITE) || (obj2->mode & GR_WRITE))) {
65842 + gr_log_fs_generic(GR_DONT_AUDIT, GR_WRITLIB_ACL_MSG, filp->f_path.dentry, filp->f_path.mnt);
65843 + return 1;
65844 + }
65845 + }
65846 + return 0;
65847 +}
65848 +
65849 +int
65850 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot)
65851 +{
65852 + __u32 mode;
65853 +
65854 + if (unlikely(!file || !(prot & PROT_EXEC)))
65855 + return 1;
65856 +
65857 + if (is_writable_mmap(file))
65858 + return 0;
65859 +
65860 + mode =
65861 + gr_search_file(file->f_path.dentry,
65862 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
65863 + file->f_path.mnt);
65864 +
65865 + if (!gr_tpe_allow(file))
65866 + return 0;
65867 +
65868 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
65869 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
65870 + return 0;
65871 + } else if (unlikely(!(mode & GR_EXEC))) {
65872 + return 0;
65873 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
65874 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
65875 + return 1;
65876 + }
65877 +
65878 + return 1;
65879 +}
65880 +
65881 +int
65882 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
65883 +{
65884 + __u32 mode;
65885 +
65886 + if (unlikely(!file || !(prot & PROT_EXEC)))
65887 + return 1;
65888 +
65889 + if (is_writable_mmap(file))
65890 + return 0;
65891 +
65892 + mode =
65893 + gr_search_file(file->f_path.dentry,
65894 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
65895 + file->f_path.mnt);
65896 +
65897 + if (!gr_tpe_allow(file))
65898 + return 0;
65899 +
65900 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
65901 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
65902 + return 0;
65903 + } else if (unlikely(!(mode & GR_EXEC))) {
65904 + return 0;
65905 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
65906 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
65907 + return 1;
65908 + }
65909 +
65910 + return 1;
65911 +}
65912 +
65913 +void
65914 +gr_acl_handle_psacct(struct task_struct *task, const long code)
65915 +{
65916 + unsigned long runtime;
65917 + unsigned long cputime;
65918 + unsigned int wday, cday;
65919 + __u8 whr, chr;
65920 + __u8 wmin, cmin;
65921 + __u8 wsec, csec;
65922 + struct timespec timeval;
65923 +
65924 + if (unlikely(!(gr_status & GR_READY) || !task->acl ||
65925 + !(task->acl->mode & GR_PROCACCT)))
65926 + return;
65927 +
65928 + do_posix_clock_monotonic_gettime(&timeval);
65929 + runtime = timeval.tv_sec - task->start_time.tv_sec;
65930 + wday = runtime / (3600 * 24);
65931 + runtime -= wday * (3600 * 24);
65932 + whr = runtime / 3600;
65933 + runtime -= whr * 3600;
65934 + wmin = runtime / 60;
65935 + runtime -= wmin * 60;
65936 + wsec = runtime;
65937 +
65938 + cputime = (task->utime + task->stime) / HZ;
65939 + cday = cputime / (3600 * 24);
65940 + cputime -= cday * (3600 * 24);
65941 + chr = cputime / 3600;
65942 + cputime -= chr * 3600;
65943 + cmin = cputime / 60;
65944 + cputime -= cmin * 60;
65945 + csec = cputime;
65946 +
65947 + gr_log_procacct(GR_DO_AUDIT, GR_ACL_PROCACCT_MSG, task, wday, whr, wmin, wsec, cday, chr, cmin, csec, code);
65948 +
65949 + return;
65950 +}
65951 +
65952 +#ifdef CONFIG_TASKSTATS
65953 +int gr_is_taskstats_denied(int pid)
65954 +{
65955 + struct task_struct *task;
65956 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
65957 + const struct cred *cred;
65958 +#endif
65959 + int ret = 0;
65960 +
65961 + /* restrict taskstats viewing to un-chrooted root users
65962 + who have the 'view' subject flag if the RBAC system is enabled
65963 + */
65964 +
65965 + rcu_read_lock();
65966 + read_lock(&tasklist_lock);
65967 + task = find_task_by_vpid(pid);
65968 + if (task) {
65969 +#ifdef CONFIG_GRKERNSEC_CHROOT
65970 + if (proc_is_chrooted(task))
65971 + ret = -EACCES;
65972 +#endif
65973 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
65974 + cred = __task_cred(task);
65975 +#ifdef CONFIG_GRKERNSEC_PROC_USER
65976 + if (gr_is_global_nonroot(cred->uid))
65977 + ret = -EACCES;
65978 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
65979 + if (gr_is_global_nonroot(cred->uid) && !groups_search(cred->group_info, grsec_proc_gid))
65980 + ret = -EACCES;
65981 +#endif
65982 +#endif
65983 + if (gr_status & GR_READY) {
65984 + if (!(task->acl->mode & GR_VIEW))
65985 + ret = -EACCES;
65986 + }
65987 + } else
65988 + ret = -ENOENT;
65989 +
65990 + read_unlock(&tasklist_lock);
65991 + rcu_read_unlock();
65992 +
65993 + return ret;
65994 +}
65995 +#endif
65996 +
65997 +/* AUXV entries are filled via a descendant of search_binary_handler
65998 + after we've already applied the subject for the target
65999 +*/
66000 +int gr_acl_enable_at_secure(void)
66001 +{
66002 + if (unlikely(!(gr_status & GR_READY)))
66003 + return 0;
66004 +
66005 + if (current->acl->mode & GR_ATSECURE)
66006 + return 1;
66007 +
66008 + return 0;
66009 +}
66010 +
66011 +int gr_acl_handle_filldir(const struct file *file, const char *name, const unsigned int namelen, const ino_t ino)
66012 +{
66013 + struct task_struct *task = current;
66014 + struct dentry *dentry = file->f_path.dentry;
66015 + struct vfsmount *mnt = file->f_path.mnt;
66016 + struct acl_object_label *obj, *tmp;
66017 + struct acl_subject_label *subj;
66018 + unsigned int bufsize;
66019 + int is_not_root;
66020 + char *path;
66021 + dev_t dev = __get_dev(dentry);
66022 +
66023 + if (unlikely(!(gr_status & GR_READY)))
66024 + return 1;
66025 +
66026 + if (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))
66027 + return 1;
66028 +
66029 + /* ignore Eric Biederman */
66030 + if (IS_PRIVATE(dentry->d_inode))
66031 + return 1;
66032 +
66033 + subj = task->acl;
66034 + read_lock(&gr_inode_lock);
66035 + do {
66036 + obj = lookup_acl_obj_label(ino, dev, subj);
66037 + if (obj != NULL) {
66038 + read_unlock(&gr_inode_lock);
66039 + return (obj->mode & GR_FIND) ? 1 : 0;
66040 + }
66041 + } while ((subj = subj->parent_subject));
66042 + read_unlock(&gr_inode_lock);
66043 +
66044 + /* this is purely an optimization since we're looking for an object
66045 + for the directory we're doing a readdir on
66046 + if it's possible for any globbed object to match the entry we're
66047 + filling into the directory, then the object we find here will be
66048 + an anchor point with attached globbed objects
66049 + */
66050 + obj = chk_obj_label_noglob(dentry, mnt, task->acl);
66051 + if (obj->globbed == NULL)
66052 + return (obj->mode & GR_FIND) ? 1 : 0;
66053 +
66054 + is_not_root = ((obj->filename[0] == '/') &&
66055 + (obj->filename[1] == '\0')) ? 0 : 1;
66056 + bufsize = PAGE_SIZE - namelen - is_not_root;
66057 +
66058 + /* check bufsize > PAGE_SIZE || bufsize == 0 */
66059 + if (unlikely((bufsize - 1) > (PAGE_SIZE - 1)))
66060 + return 1;
66061 +
66062 + preempt_disable();
66063 + path = d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
66064 + bufsize);
66065 +
66066 + bufsize = strlen(path);
66067 +
66068 + /* if base is "/", don't append an additional slash */
66069 + if (is_not_root)
66070 + *(path + bufsize) = '/';
66071 + memcpy(path + bufsize + is_not_root, name, namelen);
66072 + *(path + bufsize + namelen + is_not_root) = '\0';
66073 +
66074 + tmp = obj->globbed;
66075 + while (tmp) {
66076 + if (!glob_match(tmp->filename, path)) {
66077 + preempt_enable();
66078 + return (tmp->mode & GR_FIND) ? 1 : 0;
66079 + }
66080 + tmp = tmp->next;
66081 + }
66082 + preempt_enable();
66083 + return (obj->mode & GR_FIND) ? 1 : 0;
66084 +}
66085 +
66086 +void gr_put_exec_file(struct task_struct *task)
66087 +{
66088 + struct file *filp;
66089 +
66090 + write_lock(&grsec_exec_file_lock);
66091 + filp = task->exec_file;
66092 + task->exec_file = NULL;
66093 + write_unlock(&grsec_exec_file_lock);
66094 +
66095 + if (filp)
66096 + fput(filp);
66097 +
66098 + return;
66099 +}
66100 +
66101 +
66102 +#ifdef CONFIG_NETFILTER_XT_MATCH_GRADM_MODULE
66103 +EXPORT_SYMBOL(gr_acl_is_enabled);
66104 +#endif
66105 +#ifdef CONFIG_SECURITY
66106 +EXPORT_SYMBOL(gr_check_user_change);
66107 +EXPORT_SYMBOL(gr_check_group_change);
66108 +#endif
66109 +
66110 diff --git a/grsecurity/gracl_alloc.c b/grsecurity/gracl_alloc.c
66111 new file mode 100644
66112 index 0000000..18ffbbd
66113 --- /dev/null
66114 +++ b/grsecurity/gracl_alloc.c
66115 @@ -0,0 +1,105 @@
66116 +#include <linux/kernel.h>
66117 +#include <linux/mm.h>
66118 +#include <linux/slab.h>
66119 +#include <linux/vmalloc.h>
66120 +#include <linux/gracl.h>
66121 +#include <linux/grsecurity.h>
66122 +
66123 +static struct gr_alloc_state __current_alloc_state = { 1, 1, NULL };
66124 +struct gr_alloc_state *current_alloc_state = &__current_alloc_state;
66125 +
66126 +static __inline__ int
66127 +alloc_pop(void)
66128 +{
66129 + if (current_alloc_state->alloc_stack_next == 1)
66130 + return 0;
66131 +
66132 + kfree(current_alloc_state->alloc_stack[current_alloc_state->alloc_stack_next - 2]);
66133 +
66134 + current_alloc_state->alloc_stack_next--;
66135 +
66136 + return 1;
66137 +}
66138 +
66139 +static __inline__ int
66140 +alloc_push(void *buf)
66141 +{
66142 + if (current_alloc_state->alloc_stack_next >= current_alloc_state->alloc_stack_size)
66143 + return 1;
66144 +
66145 + current_alloc_state->alloc_stack[current_alloc_state->alloc_stack_next - 1] = buf;
66146 +
66147 + current_alloc_state->alloc_stack_next++;
66148 +
66149 + return 0;
66150 +}
66151 +
66152 +void *
66153 +acl_alloc(unsigned long len)
66154 +{
66155 + void *ret = NULL;
66156 +
66157 + if (!len || len > PAGE_SIZE)
66158 + goto out;
66159 +
66160 + ret = kmalloc(len, GFP_KERNEL);
66161 +
66162 + if (ret) {
66163 + if (alloc_push(ret)) {
66164 + kfree(ret);
66165 + ret = NULL;
66166 + }
66167 + }
66168 +
66169 +out:
66170 + return ret;
66171 +}
66172 +
66173 +void *
66174 +acl_alloc_num(unsigned long num, unsigned long len)
66175 +{
66176 + if (!len || (num > (PAGE_SIZE / len)))
66177 + return NULL;
66178 +
66179 + return acl_alloc(num * len);
66180 +}
66181 +
66182 +void
66183 +acl_free_all(void)
66184 +{
66185 + if (!current_alloc_state->alloc_stack)
66186 + return;
66187 +
66188 + while (alloc_pop()) ;
66189 +
66190 + if (current_alloc_state->alloc_stack) {
66191 + if ((current_alloc_state->alloc_stack_size * sizeof (void *)) <= PAGE_SIZE)
66192 + kfree(current_alloc_state->alloc_stack);
66193 + else
66194 + vfree(current_alloc_state->alloc_stack);
66195 + }
66196 +
66197 + current_alloc_state->alloc_stack = NULL;
66198 + current_alloc_state->alloc_stack_size = 1;
66199 + current_alloc_state->alloc_stack_next = 1;
66200 +
66201 + return;
66202 +}
66203 +
66204 +int
66205 +acl_alloc_stack_init(unsigned long size)
66206 +{
66207 + if ((size * sizeof (void *)) <= PAGE_SIZE)
66208 + current_alloc_state->alloc_stack =
66209 + (void **) kmalloc(size * sizeof (void *), GFP_KERNEL);
66210 + else
66211 + current_alloc_state->alloc_stack = (void **) vmalloc(size * sizeof (void *));
66212 +
66213 + current_alloc_state->alloc_stack_size = size;
66214 + current_alloc_state->alloc_stack_next = 1;
66215 +
66216 + if (!current_alloc_state->alloc_stack)
66217 + return 0;
66218 + else
66219 + return 1;
66220 +}
66221 diff --git a/grsecurity/gracl_cap.c b/grsecurity/gracl_cap.c
66222 new file mode 100644
66223 index 0000000..bdd51ea
66224 --- /dev/null
66225 +++ b/grsecurity/gracl_cap.c
66226 @@ -0,0 +1,110 @@
66227 +#include <linux/kernel.h>
66228 +#include <linux/module.h>
66229 +#include <linux/sched.h>
66230 +#include <linux/gracl.h>
66231 +#include <linux/grsecurity.h>
66232 +#include <linux/grinternal.h>
66233 +
66234 +extern const char *captab_log[];
66235 +extern int captab_log_entries;
66236 +
66237 +int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
66238 +{
66239 + struct acl_subject_label *curracl;
66240 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
66241 + kernel_cap_t cap_audit = __cap_empty_set;
66242 +
66243 + if (!gr_acl_is_enabled())
66244 + return 1;
66245 +
66246 + curracl = task->acl;
66247 +
66248 + cap_drop = curracl->cap_lower;
66249 + cap_mask = curracl->cap_mask;
66250 + cap_audit = curracl->cap_invert_audit;
66251 +
66252 + while ((curracl = curracl->parent_subject)) {
66253 + /* if the cap isn't specified in the current computed mask but is specified in the
66254 + current level subject, and is lowered in the current level subject, then add
66255 + it to the set of dropped capabilities
66256 + otherwise, add the current level subject's mask to the current computed mask
66257 + */
66258 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
66259 + cap_raise(cap_mask, cap);
66260 + if (cap_raised(curracl->cap_lower, cap))
66261 + cap_raise(cap_drop, cap);
66262 + if (cap_raised(curracl->cap_invert_audit, cap))
66263 + cap_raise(cap_audit, cap);
66264 + }
66265 + }
66266 +
66267 + if (!cap_raised(cap_drop, cap)) {
66268 + if (cap_raised(cap_audit, cap))
66269 + gr_log_cap(GR_DO_AUDIT, GR_CAP_ACL_MSG2, task, captab_log[cap]);
66270 + return 1;
66271 + }
66272 +
66273 + curracl = task->acl;
66274 +
66275 + if ((curracl->mode & (GR_LEARN | GR_INHERITLEARN))
66276 + && cap_raised(cred->cap_effective, cap)) {
66277 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
66278 + task->role->roletype, GR_GLOBAL_UID(cred->uid),
66279 + GR_GLOBAL_GID(cred->gid), task->exec_file ?
66280 + gr_to_filename(task->exec_file->f_path.dentry,
66281 + task->exec_file->f_path.mnt) : curracl->filename,
66282 + curracl->filename, 0UL,
66283 + 0UL, "", (unsigned long) cap, &task->signal->saved_ip);
66284 + return 1;
66285 + }
66286 +
66287 + if ((cap >= 0) && (cap < captab_log_entries) && cap_raised(cred->cap_effective, cap) && !cap_raised(cap_audit, cap))
66288 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_ACL_MSG, task, captab_log[cap]);
66289 +
66290 + return 0;
66291 +}
66292 +
66293 +int
66294 +gr_acl_is_capable(const int cap)
66295 +{
66296 + return gr_task_acl_is_capable(current, current_cred(), cap);
66297 +}
66298 +
66299 +int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap)
66300 +{
66301 + struct acl_subject_label *curracl;
66302 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
66303 +
66304 + if (!gr_acl_is_enabled())
66305 + return 1;
66306 +
66307 + curracl = task->acl;
66308 +
66309 + cap_drop = curracl->cap_lower;
66310 + cap_mask = curracl->cap_mask;
66311 +
66312 + while ((curracl = curracl->parent_subject)) {
66313 + /* if the cap isn't specified in the current computed mask but is specified in the
66314 + current level subject, and is lowered in the current level subject, then add
66315 + it to the set of dropped capabilities
66316 + otherwise, add the current level subject's mask to the current computed mask
66317 + */
66318 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
66319 + cap_raise(cap_mask, cap);
66320 + if (cap_raised(curracl->cap_lower, cap))
66321 + cap_raise(cap_drop, cap);
66322 + }
66323 + }
66324 +
66325 + if (!cap_raised(cap_drop, cap))
66326 + return 1;
66327 +
66328 + return 0;
66329 +}
66330 +
66331 +int
66332 +gr_acl_is_capable_nolog(const int cap)
66333 +{
66334 + return gr_task_acl_is_capable_nolog(current, cap);
66335 +}
66336 +
66337 diff --git a/grsecurity/gracl_compat.c b/grsecurity/gracl_compat.c
66338 new file mode 100644
66339 index 0000000..ca25605
66340 --- /dev/null
66341 +++ b/grsecurity/gracl_compat.c
66342 @@ -0,0 +1,270 @@
66343 +#include <linux/kernel.h>
66344 +#include <linux/gracl.h>
66345 +#include <linux/compat.h>
66346 +#include <linux/gracl_compat.h>
66347 +
66348 +#include <asm/uaccess.h>
66349 +
66350 +int copy_gr_arg_wrapper_compat(const char *buf, struct gr_arg_wrapper *uwrap)
66351 +{
66352 + struct gr_arg_wrapper_compat uwrapcompat;
66353 +
66354 + if (copy_from_user(&uwrapcompat, buf, sizeof(uwrapcompat)))
66355 + return -EFAULT;
66356 +
66357 + if (((uwrapcompat.version != GRSECURITY_VERSION) &&
66358 + (uwrapcompat.version != 0x2901)) ||
66359 + (uwrapcompat.size != sizeof(struct gr_arg_compat)))
66360 + return -EINVAL;
66361 +
66362 + uwrap->arg = compat_ptr(uwrapcompat.arg);
66363 + uwrap->version = uwrapcompat.version;
66364 + uwrap->size = sizeof(struct gr_arg);
66365 +
66366 + return 0;
66367 +}
66368 +
66369 +int copy_gr_arg_compat(const struct gr_arg __user *buf, struct gr_arg *arg)
66370 +{
66371 + struct gr_arg_compat argcompat;
66372 +
66373 + if (copy_from_user(&argcompat, buf, sizeof(argcompat)))
66374 + return -EFAULT;
66375 +
66376 + arg->role_db.r_table = compat_ptr(argcompat.role_db.r_table);
66377 + arg->role_db.num_pointers = argcompat.role_db.num_pointers;
66378 + arg->role_db.num_roles = argcompat.role_db.num_roles;
66379 + arg->role_db.num_domain_children = argcompat.role_db.num_domain_children;
66380 + arg->role_db.num_subjects = argcompat.role_db.num_subjects;
66381 + arg->role_db.num_objects = argcompat.role_db.num_objects;
66382 +
66383 + memcpy(&arg->pw, &argcompat.pw, sizeof(arg->pw));
66384 + memcpy(&arg->salt, &argcompat.salt, sizeof(arg->salt));
66385 + memcpy(&arg->sum, &argcompat.sum, sizeof(arg->sum));
66386 + memcpy(&arg->sp_role, &argcompat.sp_role, sizeof(arg->sp_role));
66387 + arg->sprole_pws = compat_ptr(argcompat.sprole_pws);
66388 + arg->segv_device = argcompat.segv_device;
66389 + arg->segv_inode = argcompat.segv_inode;
66390 + arg->segv_uid = argcompat.segv_uid;
66391 + arg->num_sprole_pws = argcompat.num_sprole_pws;
66392 + arg->mode = argcompat.mode;
66393 +
66394 + return 0;
66395 +}
66396 +
66397 +int copy_acl_object_label_compat(struct acl_object_label *obj, const struct acl_object_label *userp)
66398 +{
66399 + struct acl_object_label_compat objcompat;
66400 +
66401 + if (copy_from_user(&objcompat, userp, sizeof(objcompat)))
66402 + return -EFAULT;
66403 +
66404 + obj->filename = compat_ptr(objcompat.filename);
66405 + obj->inode = objcompat.inode;
66406 + obj->device = objcompat.device;
66407 + obj->mode = objcompat.mode;
66408 +
66409 + obj->nested = compat_ptr(objcompat.nested);
66410 + obj->globbed = compat_ptr(objcompat.globbed);
66411 +
66412 + obj->prev = compat_ptr(objcompat.prev);
66413 + obj->next = compat_ptr(objcompat.next);
66414 +
66415 + return 0;
66416 +}
66417 +
66418 +int copy_acl_subject_label_compat(struct acl_subject_label *subj, const struct acl_subject_label *userp)
66419 +{
66420 + unsigned int i;
66421 + struct acl_subject_label_compat subjcompat;
66422 +
66423 + if (copy_from_user(&subjcompat, userp, sizeof(subjcompat)))
66424 + return -EFAULT;
66425 +
66426 + subj->filename = compat_ptr(subjcompat.filename);
66427 + subj->inode = subjcompat.inode;
66428 + subj->device = subjcompat.device;
66429 + subj->mode = subjcompat.mode;
66430 + subj->cap_mask = subjcompat.cap_mask;
66431 + subj->cap_lower = subjcompat.cap_lower;
66432 + subj->cap_invert_audit = subjcompat.cap_invert_audit;
66433 +
66434 + for (i = 0; i < GR_NLIMITS; i++) {
66435 + if (subjcompat.res[i].rlim_cur == COMPAT_RLIM_INFINITY)
66436 + subj->res[i].rlim_cur = RLIM_INFINITY;
66437 + else
66438 + subj->res[i].rlim_cur = subjcompat.res[i].rlim_cur;
66439 + if (subjcompat.res[i].rlim_max == COMPAT_RLIM_INFINITY)
66440 + subj->res[i].rlim_max = RLIM_INFINITY;
66441 + else
66442 + subj->res[i].rlim_max = subjcompat.res[i].rlim_max;
66443 + }
66444 + subj->resmask = subjcompat.resmask;
66445 +
66446 + subj->user_trans_type = subjcompat.user_trans_type;
66447 + subj->group_trans_type = subjcompat.group_trans_type;
66448 + subj->user_transitions = compat_ptr(subjcompat.user_transitions);
66449 + subj->group_transitions = compat_ptr(subjcompat.group_transitions);
66450 + subj->user_trans_num = subjcompat.user_trans_num;
66451 + subj->group_trans_num = subjcompat.group_trans_num;
66452 +
66453 + memcpy(&subj->sock_families, &subjcompat.sock_families, sizeof(subj->sock_families));
66454 + memcpy(&subj->ip_proto, &subjcompat.ip_proto, sizeof(subj->ip_proto));
66455 + subj->ip_type = subjcompat.ip_type;
66456 + subj->ips = compat_ptr(subjcompat.ips);
66457 + subj->ip_num = subjcompat.ip_num;
66458 + subj->inaddr_any_override = subjcompat.inaddr_any_override;
66459 +
66460 + subj->crashes = subjcompat.crashes;
66461 + subj->expires = subjcompat.expires;
66462 +
66463 + subj->parent_subject = compat_ptr(subjcompat.parent_subject);
66464 + subj->hash = compat_ptr(subjcompat.hash);
66465 + subj->prev = compat_ptr(subjcompat.prev);
66466 + subj->next = compat_ptr(subjcompat.next);
66467 +
66468 + subj->obj_hash = compat_ptr(subjcompat.obj_hash);
66469 + subj->obj_hash_size = subjcompat.obj_hash_size;
66470 + subj->pax_flags = subjcompat.pax_flags;
66471 +
66472 + return 0;
66473 +}
66474 +
66475 +int copy_acl_role_label_compat(struct acl_role_label *role, const struct acl_role_label *userp)
66476 +{
66477 + struct acl_role_label_compat rolecompat;
66478 +
66479 + if (copy_from_user(&rolecompat, userp, sizeof(rolecompat)))
66480 + return -EFAULT;
66481 +
66482 + role->rolename = compat_ptr(rolecompat.rolename);
66483 + role->uidgid = rolecompat.uidgid;
66484 + role->roletype = rolecompat.roletype;
66485 +
66486 + role->auth_attempts = rolecompat.auth_attempts;
66487 + role->expires = rolecompat.expires;
66488 +
66489 + role->root_label = compat_ptr(rolecompat.root_label);
66490 + role->hash = compat_ptr(rolecompat.hash);
66491 +
66492 + role->prev = compat_ptr(rolecompat.prev);
66493 + role->next = compat_ptr(rolecompat.next);
66494 +
66495 + role->transitions = compat_ptr(rolecompat.transitions);
66496 + role->allowed_ips = compat_ptr(rolecompat.allowed_ips);
66497 + role->domain_children = compat_ptr(rolecompat.domain_children);
66498 + role->domain_child_num = rolecompat.domain_child_num;
66499 +
66500 + role->umask = rolecompat.umask;
66501 +
66502 + role->subj_hash = compat_ptr(rolecompat.subj_hash);
66503 + role->subj_hash_size = rolecompat.subj_hash_size;
66504 +
66505 + return 0;
66506 +}
66507 +
66508 +int copy_role_allowed_ip_compat(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp)
66509 +{
66510 + struct role_allowed_ip_compat roleip_compat;
66511 +
66512 + if (copy_from_user(&roleip_compat, userp, sizeof(roleip_compat)))
66513 + return -EFAULT;
66514 +
66515 + roleip->addr = roleip_compat.addr;
66516 + roleip->netmask = roleip_compat.netmask;
66517 +
66518 + roleip->prev = compat_ptr(roleip_compat.prev);
66519 + roleip->next = compat_ptr(roleip_compat.next);
66520 +
66521 + return 0;
66522 +}
66523 +
66524 +int copy_role_transition_compat(struct role_transition *trans, const struct role_transition *userp)
66525 +{
66526 + struct role_transition_compat trans_compat;
66527 +
66528 + if (copy_from_user(&trans_compat, userp, sizeof(trans_compat)))
66529 + return -EFAULT;
66530 +
66531 + trans->rolename = compat_ptr(trans_compat.rolename);
66532 +
66533 + trans->prev = compat_ptr(trans_compat.prev);
66534 + trans->next = compat_ptr(trans_compat.next);
66535 +
66536 + return 0;
66537 +
66538 +}
66539 +
66540 +int copy_gr_hash_struct_compat(struct gr_hash_struct *hash, const struct gr_hash_struct *userp)
66541 +{
66542 + struct gr_hash_struct_compat hash_compat;
66543 +
66544 + if (copy_from_user(&hash_compat, userp, sizeof(hash_compat)))
66545 + return -EFAULT;
66546 +
66547 + hash->table = compat_ptr(hash_compat.table);
66548 + hash->nametable = compat_ptr(hash_compat.nametable);
66549 + hash->first = compat_ptr(hash_compat.first);
66550 +
66551 + hash->table_size = hash_compat.table_size;
66552 + hash->used_size = hash_compat.used_size;
66553 +
66554 + hash->type = hash_compat.type;
66555 +
66556 + return 0;
66557 +}
66558 +
66559 +int copy_pointer_from_array_compat(void *ptr, unsigned long idx, const void *userp)
66560 +{
66561 + compat_uptr_t ptrcompat;
66562 +
66563 + if (copy_from_user(&ptrcompat, userp + (idx * sizeof(ptrcompat)), sizeof(ptrcompat)))
66564 + return -EFAULT;
66565 +
66566 + *(void **)ptr = compat_ptr(ptrcompat);
66567 +
66568 + return 0;
66569 +}
66570 +
66571 +int copy_acl_ip_label_compat(struct acl_ip_label *ip, const struct acl_ip_label *userp)
66572 +{
66573 + struct acl_ip_label_compat ip_compat;
66574 +
66575 + if (copy_from_user(&ip_compat, userp, sizeof(ip_compat)))
66576 + return -EFAULT;
66577 +
66578 + ip->iface = compat_ptr(ip_compat.iface);
66579 + ip->addr = ip_compat.addr;
66580 + ip->netmask = ip_compat.netmask;
66581 + ip->low = ip_compat.low;
66582 + ip->high = ip_compat.high;
66583 + ip->mode = ip_compat.mode;
66584 + ip->type = ip_compat.type;
66585 +
66586 + memcpy(&ip->proto, &ip_compat.proto, sizeof(ip->proto));
66587 +
66588 + ip->prev = compat_ptr(ip_compat.prev);
66589 + ip->next = compat_ptr(ip_compat.next);
66590 +
66591 + return 0;
66592 +}
66593 +
66594 +int copy_sprole_pw_compat(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp)
66595 +{
66596 + struct sprole_pw_compat pw_compat;
66597 +
66598 + if (copy_from_user(&pw_compat, (const void *)userp + (sizeof(pw_compat) * idx), sizeof(pw_compat)))
66599 + return -EFAULT;
66600 +
66601 + pw->rolename = compat_ptr(pw_compat.rolename);
66602 + memcpy(&pw->salt, pw_compat.salt, sizeof(pw->salt));
66603 + memcpy(&pw->sum, pw_compat.sum, sizeof(pw->sum));
66604 +
66605 + return 0;
66606 +}
66607 +
66608 +size_t get_gr_arg_wrapper_size_compat(void)
66609 +{
66610 + return sizeof(struct gr_arg_wrapper_compat);
66611 +}
66612 +
66613 diff --git a/grsecurity/gracl_fs.c b/grsecurity/gracl_fs.c
66614 new file mode 100644
66615 index 0000000..a340c17
66616 --- /dev/null
66617 +++ b/grsecurity/gracl_fs.c
66618 @@ -0,0 +1,431 @@
66619 +#include <linux/kernel.h>
66620 +#include <linux/sched.h>
66621 +#include <linux/types.h>
66622 +#include <linux/fs.h>
66623 +#include <linux/file.h>
66624 +#include <linux/stat.h>
66625 +#include <linux/grsecurity.h>
66626 +#include <linux/grinternal.h>
66627 +#include <linux/gracl.h>
66628 +
66629 +umode_t
66630 +gr_acl_umask(void)
66631 +{
66632 + if (unlikely(!gr_acl_is_enabled()))
66633 + return 0;
66634 +
66635 + return current->role->umask;
66636 +}
66637 +
66638 +__u32
66639 +gr_acl_handle_hidden_file(const struct dentry * dentry,
66640 + const struct vfsmount * mnt)
66641 +{
66642 + __u32 mode;
66643 +
66644 + if (unlikely(!dentry->d_inode))
66645 + return GR_FIND;
66646 +
66647 + mode =
66648 + gr_search_file(dentry, GR_FIND | GR_AUDIT_FIND | GR_SUPPRESS, mnt);
66649 +
66650 + if (unlikely(mode & GR_FIND && mode & GR_AUDIT_FIND)) {
66651 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
66652 + return mode;
66653 + } else if (unlikely(!(mode & GR_FIND) && !(mode & GR_SUPPRESS))) {
66654 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
66655 + return 0;
66656 + } else if (unlikely(!(mode & GR_FIND)))
66657 + return 0;
66658 +
66659 + return GR_FIND;
66660 +}
66661 +
66662 +__u32
66663 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
66664 + int acc_mode)
66665 +{
66666 + __u32 reqmode = GR_FIND;
66667 + __u32 mode;
66668 +
66669 + if (unlikely(!dentry->d_inode))
66670 + return reqmode;
66671 +
66672 + if (acc_mode & MAY_APPEND)
66673 + reqmode |= GR_APPEND;
66674 + else if (acc_mode & MAY_WRITE)
66675 + reqmode |= GR_WRITE;
66676 + if ((acc_mode & MAY_READ) && !S_ISDIR(dentry->d_inode->i_mode))
66677 + reqmode |= GR_READ;
66678 +
66679 + mode =
66680 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
66681 + mnt);
66682 +
66683 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
66684 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
66685 + reqmode & GR_READ ? " reading" : "",
66686 + reqmode & GR_WRITE ? " writing" : reqmode &
66687 + GR_APPEND ? " appending" : "");
66688 + return reqmode;
66689 + } else
66690 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
66691 + {
66692 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
66693 + reqmode & GR_READ ? " reading" : "",
66694 + reqmode & GR_WRITE ? " writing" : reqmode &
66695 + GR_APPEND ? " appending" : "");
66696 + return 0;
66697 + } else if (unlikely((mode & reqmode) != reqmode))
66698 + return 0;
66699 +
66700 + return reqmode;
66701 +}
66702 +
66703 +__u32
66704 +gr_acl_handle_creat(const struct dentry * dentry,
66705 + const struct dentry * p_dentry,
66706 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
66707 + const int imode)
66708 +{
66709 + __u32 reqmode = GR_WRITE | GR_CREATE;
66710 + __u32 mode;
66711 +
66712 + if (acc_mode & MAY_APPEND)
66713 + reqmode |= GR_APPEND;
66714 + // if a directory was required or the directory already exists, then
66715 + // don't count this open as a read
66716 + if ((acc_mode & MAY_READ) &&
66717 + !((open_flags & O_DIRECTORY) || (dentry->d_inode && S_ISDIR(dentry->d_inode->i_mode))))
66718 + reqmode |= GR_READ;
66719 + if ((open_flags & O_CREAT) &&
66720 + ((imode & S_ISUID) || ((imode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
66721 + reqmode |= GR_SETID;
66722 +
66723 + mode =
66724 + gr_check_create(dentry, p_dentry, p_mnt,
66725 + reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
66726 +
66727 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
66728 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
66729 + reqmode & GR_READ ? " reading" : "",
66730 + reqmode & GR_WRITE ? " writing" : reqmode &
66731 + GR_APPEND ? " appending" : "");
66732 + return reqmode;
66733 + } else
66734 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
66735 + {
66736 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
66737 + reqmode & GR_READ ? " reading" : "",
66738 + reqmode & GR_WRITE ? " writing" : reqmode &
66739 + GR_APPEND ? " appending" : "");
66740 + return 0;
66741 + } else if (unlikely((mode & reqmode) != reqmode))
66742 + return 0;
66743 +
66744 + return reqmode;
66745 +}
66746 +
66747 +__u32
66748 +gr_acl_handle_access(const struct dentry * dentry, const struct vfsmount * mnt,
66749 + const int fmode)
66750 +{
66751 + __u32 mode, reqmode = GR_FIND;
66752 +
66753 + if ((fmode & S_IXOTH) && !S_ISDIR(dentry->d_inode->i_mode))
66754 + reqmode |= GR_EXEC;
66755 + if (fmode & S_IWOTH)
66756 + reqmode |= GR_WRITE;
66757 + if (fmode & S_IROTH)
66758 + reqmode |= GR_READ;
66759 +
66760 + mode =
66761 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
66762 + mnt);
66763 +
66764 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
66765 + gr_log_fs_rbac_mode3(GR_DO_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
66766 + reqmode & GR_READ ? " reading" : "",
66767 + reqmode & GR_WRITE ? " writing" : "",
66768 + reqmode & GR_EXEC ? " executing" : "");
66769 + return reqmode;
66770 + } else
66771 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
66772 + {
66773 + gr_log_fs_rbac_mode3(GR_DONT_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
66774 + reqmode & GR_READ ? " reading" : "",
66775 + reqmode & GR_WRITE ? " writing" : "",
66776 + reqmode & GR_EXEC ? " executing" : "");
66777 + return 0;
66778 + } else if (unlikely((mode & reqmode) != reqmode))
66779 + return 0;
66780 +
66781 + return reqmode;
66782 +}
66783 +
66784 +static __u32 generic_fs_handler(const struct dentry *dentry, const struct vfsmount *mnt, __u32 reqmode, const char *fmt)
66785 +{
66786 + __u32 mode;
66787 +
66788 + mode = gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS, mnt);
66789 +
66790 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
66791 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, dentry, mnt);
66792 + return mode;
66793 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
66794 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, dentry, mnt);
66795 + return 0;
66796 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
66797 + return 0;
66798 +
66799 + return (reqmode);
66800 +}
66801 +
66802 +__u32
66803 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
66804 +{
66805 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_RMDIR_ACL_MSG);
66806 +}
66807 +
66808 +__u32
66809 +gr_acl_handle_unlink(const struct dentry *dentry, const struct vfsmount *mnt)
66810 +{
66811 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_UNLINK_ACL_MSG);
66812 +}
66813 +
66814 +__u32
66815 +gr_acl_handle_truncate(const struct dentry *dentry, const struct vfsmount *mnt)
66816 +{
66817 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_TRUNCATE_ACL_MSG);
66818 +}
66819 +
66820 +__u32
66821 +gr_acl_handle_utime(const struct dentry *dentry, const struct vfsmount *mnt)
66822 +{
66823 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_ATIME_ACL_MSG);
66824 +}
66825 +
66826 +__u32
66827 +gr_acl_handle_chmod(const struct dentry *dentry, const struct vfsmount *mnt,
66828 + umode_t *modeptr)
66829 +{
66830 + umode_t mode;
66831 +
66832 + *modeptr &= ~gr_acl_umask();
66833 + mode = *modeptr;
66834 +
66835 + if (unlikely(dentry->d_inode && S_ISSOCK(dentry->d_inode->i_mode)))
66836 + return 1;
66837 +
66838 + if (unlikely(dentry->d_inode && !S_ISDIR(dentry->d_inode->i_mode) &&
66839 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))) {
66840 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_SETID,
66841 + GR_CHMOD_ACL_MSG);
66842 + } else {
66843 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHMOD_ACL_MSG);
66844 + }
66845 +}
66846 +
66847 +__u32
66848 +gr_acl_handle_chown(const struct dentry *dentry, const struct vfsmount *mnt)
66849 +{
66850 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHOWN_ACL_MSG);
66851 +}
66852 +
66853 +__u32
66854 +gr_acl_handle_setxattr(const struct dentry *dentry, const struct vfsmount *mnt)
66855 +{
66856 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_SETXATTR_ACL_MSG);
66857 +}
66858 +
66859 +__u32
66860 +gr_acl_handle_execve(const struct dentry *dentry, const struct vfsmount *mnt)
66861 +{
66862 + return generic_fs_handler(dentry, mnt, GR_EXEC, GR_EXEC_ACL_MSG);
66863 +}
66864 +
66865 +__u32
66866 +gr_acl_handle_unix(const struct dentry *dentry, const struct vfsmount *mnt)
66867 +{
66868 + return generic_fs_handler(dentry, mnt, GR_READ | GR_WRITE,
66869 + GR_UNIXCONNECT_ACL_MSG);
66870 +}
66871 +
66872 +/* hardlinks require at minimum create and link permission,
66873 + any additional privilege required is based on the
66874 + privilege of the file being linked to
66875 +*/
66876 +__u32
66877 +gr_acl_handle_link(const struct dentry * new_dentry,
66878 + const struct dentry * parent_dentry,
66879 + const struct vfsmount * parent_mnt,
66880 + const struct dentry * old_dentry,
66881 + const struct vfsmount * old_mnt, const struct filename *to)
66882 +{
66883 + __u32 mode;
66884 + __u32 needmode = GR_CREATE | GR_LINK;
66885 + __u32 needaudit = GR_AUDIT_CREATE | GR_AUDIT_LINK;
66886 +
66887 + mode =
66888 + gr_check_link(new_dentry, parent_dentry, parent_mnt, old_dentry,
66889 + old_mnt);
66890 +
66891 + if (unlikely(((mode & needmode) == needmode) && (mode & needaudit))) {
66892 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
66893 + return mode;
66894 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
66895 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
66896 + return 0;
66897 + } else if (unlikely((mode & needmode) != needmode))
66898 + return 0;
66899 +
66900 + return 1;
66901 +}
66902 +
66903 +__u32
66904 +gr_acl_handle_symlink(const struct dentry * new_dentry,
66905 + const struct dentry * parent_dentry,
66906 + const struct vfsmount * parent_mnt, const struct filename *from)
66907 +{
66908 + __u32 needmode = GR_WRITE | GR_CREATE;
66909 + __u32 mode;
66910 +
66911 + mode =
66912 + gr_check_create(new_dentry, parent_dentry, parent_mnt,
66913 + GR_CREATE | GR_AUDIT_CREATE |
66914 + GR_WRITE | GR_AUDIT_WRITE | GR_SUPPRESS);
66915 +
66916 + if (unlikely(mode & GR_WRITE && mode & GR_AUDITS)) {
66917 + gr_log_fs_str_rbac(GR_DO_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
66918 + return mode;
66919 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
66920 + gr_log_fs_str_rbac(GR_DONT_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
66921 + return 0;
66922 + } else if (unlikely((mode & needmode) != needmode))
66923 + return 0;
66924 +
66925 + return (GR_WRITE | GR_CREATE);
66926 +}
66927 +
66928 +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)
66929 +{
66930 + __u32 mode;
66931 +
66932 + mode = gr_check_create(new_dentry, parent_dentry, parent_mnt, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
66933 +
66934 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
66935 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, new_dentry, parent_mnt);
66936 + return mode;
66937 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
66938 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, new_dentry, parent_mnt);
66939 + return 0;
66940 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
66941 + return 0;
66942 +
66943 + return (reqmode);
66944 +}
66945 +
66946 +__u32
66947 +gr_acl_handle_mknod(const struct dentry * new_dentry,
66948 + const struct dentry * parent_dentry,
66949 + const struct vfsmount * parent_mnt,
66950 + const int mode)
66951 +{
66952 + __u32 reqmode = GR_WRITE | GR_CREATE;
66953 + if (unlikely((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
66954 + reqmode |= GR_SETID;
66955 +
66956 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
66957 + reqmode, GR_MKNOD_ACL_MSG);
66958 +}
66959 +
66960 +__u32
66961 +gr_acl_handle_mkdir(const struct dentry *new_dentry,
66962 + const struct dentry *parent_dentry,
66963 + const struct vfsmount *parent_mnt)
66964 +{
66965 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
66966 + GR_WRITE | GR_CREATE, GR_MKDIR_ACL_MSG);
66967 +}
66968 +
66969 +#define RENAME_CHECK_SUCCESS(old, new) \
66970 + (((old & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)) && \
66971 + ((new & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)))
66972 +
66973 +int
66974 +gr_acl_handle_rename(struct dentry *new_dentry,
66975 + struct dentry *parent_dentry,
66976 + const struct vfsmount *parent_mnt,
66977 + struct dentry *old_dentry,
66978 + struct inode *old_parent_inode,
66979 + struct vfsmount *old_mnt, const struct filename *newname)
66980 +{
66981 + __u32 comp1, comp2;
66982 + int error = 0;
66983 +
66984 + if (unlikely(!gr_acl_is_enabled()))
66985 + return 0;
66986 +
66987 + if (!new_dentry->d_inode) {
66988 + comp1 = gr_check_create(new_dentry, parent_dentry, parent_mnt,
66989 + GR_READ | GR_WRITE | GR_CREATE | GR_AUDIT_READ |
66990 + GR_AUDIT_WRITE | GR_AUDIT_CREATE | GR_SUPPRESS);
66991 + comp2 = gr_search_file(old_dentry, GR_READ | GR_WRITE |
66992 + GR_DELETE | GR_AUDIT_DELETE |
66993 + GR_AUDIT_READ | GR_AUDIT_WRITE |
66994 + GR_SUPPRESS, old_mnt);
66995 + } else {
66996 + comp1 = gr_search_file(new_dentry, GR_READ | GR_WRITE |
66997 + GR_CREATE | GR_DELETE |
66998 + GR_AUDIT_CREATE | GR_AUDIT_DELETE |
66999 + GR_AUDIT_READ | GR_AUDIT_WRITE |
67000 + GR_SUPPRESS, parent_mnt);
67001 + comp2 =
67002 + gr_search_file(old_dentry,
67003 + GR_READ | GR_WRITE | GR_AUDIT_READ |
67004 + GR_DELETE | GR_AUDIT_DELETE |
67005 + GR_AUDIT_WRITE | GR_SUPPRESS, old_mnt);
67006 + }
67007 +
67008 + if (RENAME_CHECK_SUCCESS(comp1, comp2) &&
67009 + ((comp1 & GR_AUDITS) || (comp2 & GR_AUDITS)))
67010 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
67011 + else if (!RENAME_CHECK_SUCCESS(comp1, comp2) && !(comp1 & GR_SUPPRESS)
67012 + && !(comp2 & GR_SUPPRESS)) {
67013 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
67014 + error = -EACCES;
67015 + } else if (unlikely(!RENAME_CHECK_SUCCESS(comp1, comp2)))
67016 + error = -EACCES;
67017 +
67018 + return error;
67019 +}
67020 +
67021 +void
67022 +gr_acl_handle_exit(void)
67023 +{
67024 + u16 id;
67025 + char *rolename;
67026 +
67027 + if (unlikely(current->acl_sp_role && gr_acl_is_enabled() &&
67028 + !(current->role->roletype & GR_ROLE_PERSIST))) {
67029 + id = current->acl_role_id;
67030 + rolename = current->role->rolename;
67031 + gr_set_acls(1);
67032 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLEL_ACL_MSG, rolename, id);
67033 + }
67034 +
67035 + gr_put_exec_file(current);
67036 + return;
67037 +}
67038 +
67039 +int
67040 +gr_acl_handle_procpidmem(const struct task_struct *task)
67041 +{
67042 + if (unlikely(!gr_acl_is_enabled()))
67043 + return 0;
67044 +
67045 + if (task != current && task->acl->mode & GR_PROTPROCFD)
67046 + return -EACCES;
67047 +
67048 + return 0;
67049 +}
67050 diff --git a/grsecurity/gracl_ip.c b/grsecurity/gracl_ip.c
67051 new file mode 100644
67052 index 0000000..f056b81
67053 --- /dev/null
67054 +++ b/grsecurity/gracl_ip.c
67055 @@ -0,0 +1,386 @@
67056 +#include <linux/kernel.h>
67057 +#include <asm/uaccess.h>
67058 +#include <asm/errno.h>
67059 +#include <net/sock.h>
67060 +#include <linux/file.h>
67061 +#include <linux/fs.h>
67062 +#include <linux/net.h>
67063 +#include <linux/in.h>
67064 +#include <linux/skbuff.h>
67065 +#include <linux/ip.h>
67066 +#include <linux/udp.h>
67067 +#include <linux/types.h>
67068 +#include <linux/sched.h>
67069 +#include <linux/netdevice.h>
67070 +#include <linux/inetdevice.h>
67071 +#include <linux/gracl.h>
67072 +#include <linux/grsecurity.h>
67073 +#include <linux/grinternal.h>
67074 +
67075 +#define GR_BIND 0x01
67076 +#define GR_CONNECT 0x02
67077 +#define GR_INVERT 0x04
67078 +#define GR_BINDOVERRIDE 0x08
67079 +#define GR_CONNECTOVERRIDE 0x10
67080 +#define GR_SOCK_FAMILY 0x20
67081 +
67082 +static const char * gr_protocols[IPPROTO_MAX] = {
67083 + "ip", "icmp", "igmp", "ggp", "ipencap", "st", "tcp", "cbt",
67084 + "egp", "igp", "bbn-rcc", "nvp", "pup", "argus", "emcon", "xnet",
67085 + "chaos", "udp", "mux", "dcn", "hmp", "prm", "xns-idp", "trunk-1",
67086 + "trunk-2", "leaf-1", "leaf-2", "rdp", "irtp", "iso-tp4", "netblt", "mfe-nsp",
67087 + "merit-inp", "sep", "3pc", "idpr", "xtp", "ddp", "idpr-cmtp", "tp++",
67088 + "il", "ipv6", "sdrp", "ipv6-route", "ipv6-frag", "idrp", "rsvp", "gre",
67089 + "mhrp", "bna", "ipv6-crypt", "ipv6-auth", "i-nlsp", "swipe", "narp", "mobile",
67090 + "tlsp", "skip", "ipv6-icmp", "ipv6-nonxt", "ipv6-opts", "unknown:61", "cftp", "unknown:63",
67091 + "sat-expak", "kryptolan", "rvd", "ippc", "unknown:68", "sat-mon", "visa", "ipcv",
67092 + "cpnx", "cphb", "wsn", "pvp", "br-sat-mon", "sun-nd", "wb-mon", "wb-expak",
67093 + "iso-ip", "vmtp", "secure-vmtp", "vines", "ttp", "nfsnet-igp", "dgp", "tcf",
67094 + "eigrp", "ospf", "sprite-rpc", "larp", "mtp", "ax.25", "ipip", "micp",
67095 + "scc-sp", "etherip", "encap", "unknown:99", "gmtp", "ifmp", "pnni", "pim",
67096 + "aris", "scps", "qnx", "a/n", "ipcomp", "snp", "compaq-peer", "ipx-in-ip",
67097 + "vrrp", "pgm", "unknown:114", "l2tp", "ddx", "iatp", "stp", "srp",
67098 + "uti", "smp", "sm", "ptp", "isis", "fire", "crtp", "crdup",
67099 + "sscopmce", "iplt", "sps", "pipe", "sctp", "fc", "unkown:134", "unknown:135",
67100 + "unknown:136", "unknown:137", "unknown:138", "unknown:139", "unknown:140", "unknown:141", "unknown:142", "unknown:143",
67101 + "unknown:144", "unknown:145", "unknown:146", "unknown:147", "unknown:148", "unknown:149", "unknown:150", "unknown:151",
67102 + "unknown:152", "unknown:153", "unknown:154", "unknown:155", "unknown:156", "unknown:157", "unknown:158", "unknown:159",
67103 + "unknown:160", "unknown:161", "unknown:162", "unknown:163", "unknown:164", "unknown:165", "unknown:166", "unknown:167",
67104 + "unknown:168", "unknown:169", "unknown:170", "unknown:171", "unknown:172", "unknown:173", "unknown:174", "unknown:175",
67105 + "unknown:176", "unknown:177", "unknown:178", "unknown:179", "unknown:180", "unknown:181", "unknown:182", "unknown:183",
67106 + "unknown:184", "unknown:185", "unknown:186", "unknown:187", "unknown:188", "unknown:189", "unknown:190", "unknown:191",
67107 + "unknown:192", "unknown:193", "unknown:194", "unknown:195", "unknown:196", "unknown:197", "unknown:198", "unknown:199",
67108 + "unknown:200", "unknown:201", "unknown:202", "unknown:203", "unknown:204", "unknown:205", "unknown:206", "unknown:207",
67109 + "unknown:208", "unknown:209", "unknown:210", "unknown:211", "unknown:212", "unknown:213", "unknown:214", "unknown:215",
67110 + "unknown:216", "unknown:217", "unknown:218", "unknown:219", "unknown:220", "unknown:221", "unknown:222", "unknown:223",
67111 + "unknown:224", "unknown:225", "unknown:226", "unknown:227", "unknown:228", "unknown:229", "unknown:230", "unknown:231",
67112 + "unknown:232", "unknown:233", "unknown:234", "unknown:235", "unknown:236", "unknown:237", "unknown:238", "unknown:239",
67113 + "unknown:240", "unknown:241", "unknown:242", "unknown:243", "unknown:244", "unknown:245", "unknown:246", "unknown:247",
67114 + "unknown:248", "unknown:249", "unknown:250", "unknown:251", "unknown:252", "unknown:253", "unknown:254", "unknown:255",
67115 + };
67116 +
67117 +static const char * gr_socktypes[SOCK_MAX] = {
67118 + "unknown:0", "stream", "dgram", "raw", "rdm", "seqpacket", "unknown:6",
67119 + "unknown:7", "unknown:8", "unknown:9", "packet"
67120 + };
67121 +
67122 +static const char * gr_sockfamilies[AF_MAX+1] = {
67123 + "unspec", "unix", "inet", "ax25", "ipx", "appletalk", "netrom", "bridge", "atmpvc", "x25",
67124 + "inet6", "rose", "decnet", "netbeui", "security", "key", "netlink", "packet", "ash",
67125 + "econet", "atmsvc", "rds", "sna", "irda", "ppox", "wanpipe", "llc", "fam_27", "fam_28",
67126 + "tipc", "bluetooth", "iucv", "rxrpc", "isdn", "phonet", "ieee802154", "ciaf"
67127 + };
67128 +
67129 +const char *
67130 +gr_proto_to_name(unsigned char proto)
67131 +{
67132 + return gr_protocols[proto];
67133 +}
67134 +
67135 +const char *
67136 +gr_socktype_to_name(unsigned char type)
67137 +{
67138 + return gr_socktypes[type];
67139 +}
67140 +
67141 +const char *
67142 +gr_sockfamily_to_name(unsigned char family)
67143 +{
67144 + return gr_sockfamilies[family];
67145 +}
67146 +
67147 +extern const struct net_proto_family __rcu *net_families[NPROTO] __read_mostly;
67148 +
67149 +int
67150 +gr_search_socket(const int domain, const int type, const int protocol)
67151 +{
67152 + struct acl_subject_label *curr;
67153 + const struct cred *cred = current_cred();
67154 +
67155 + if (unlikely(!gr_acl_is_enabled()))
67156 + goto exit;
67157 +
67158 + if ((domain < 0) || (type < 0) || (protocol < 0) ||
67159 + (domain >= AF_MAX) || (type >= SOCK_MAX) || (protocol >= IPPROTO_MAX))
67160 + goto exit; // let the kernel handle it
67161 +
67162 + curr = current->acl;
67163 +
67164 + if (curr->sock_families[domain / 32] & (1U << (domain % 32))) {
67165 + /* the family is allowed, if this is PF_INET allow it only if
67166 + the extra sock type/protocol checks pass */
67167 + if (domain == PF_INET)
67168 + goto inet_check;
67169 + goto exit;
67170 + } else {
67171 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
67172 + __u32 fakeip = 0;
67173 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
67174 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
67175 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
67176 + gr_to_filename(current->exec_file->f_path.dentry,
67177 + current->exec_file->f_path.mnt) :
67178 + curr->filename, curr->filename,
67179 + &fakeip, domain, 0, 0, GR_SOCK_FAMILY,
67180 + &current->signal->saved_ip);
67181 + goto exit;
67182 + }
67183 + goto exit_fail;
67184 + }
67185 +
67186 +inet_check:
67187 + /* the rest of this checking is for IPv4 only */
67188 + if (!curr->ips)
67189 + goto exit;
67190 +
67191 + if ((curr->ip_type & (1U << type)) &&
67192 + (curr->ip_proto[protocol / 32] & (1U << (protocol % 32))))
67193 + goto exit;
67194 +
67195 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
67196 + /* we don't place acls on raw sockets , and sometimes
67197 + dgram/ip sockets are opened for ioctl and not
67198 + bind/connect, so we'll fake a bind learn log */
67199 + if (type == SOCK_RAW || type == SOCK_PACKET) {
67200 + __u32 fakeip = 0;
67201 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
67202 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
67203 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
67204 + gr_to_filename(current->exec_file->f_path.dentry,
67205 + current->exec_file->f_path.mnt) :
67206 + curr->filename, curr->filename,
67207 + &fakeip, 0, type,
67208 + protocol, GR_CONNECT, &current->signal->saved_ip);
67209 + } else if ((type == SOCK_DGRAM) && (protocol == IPPROTO_IP)) {
67210 + __u32 fakeip = 0;
67211 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
67212 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
67213 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
67214 + gr_to_filename(current->exec_file->f_path.dentry,
67215 + current->exec_file->f_path.mnt) :
67216 + curr->filename, curr->filename,
67217 + &fakeip, 0, type,
67218 + protocol, GR_BIND, &current->signal->saved_ip);
67219 + }
67220 + /* we'll log when they use connect or bind */
67221 + goto exit;
67222 + }
67223 +
67224 +exit_fail:
67225 + if (domain == PF_INET)
67226 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(domain),
67227 + gr_socktype_to_name(type), gr_proto_to_name(protocol));
67228 + else if (rcu_access_pointer(net_families[domain]) != NULL)
67229 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(domain),
67230 + gr_socktype_to_name(type), protocol);
67231 +
67232 + return 0;
67233 +exit:
67234 + return 1;
67235 +}
67236 +
67237 +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)
67238 +{
67239 + if ((ip->mode & mode) &&
67240 + (ip_port >= ip->low) &&
67241 + (ip_port <= ip->high) &&
67242 + ((ntohl(ip_addr) & our_netmask) ==
67243 + (ntohl(our_addr) & our_netmask))
67244 + && (ip->proto[protocol / 32] & (1U << (protocol % 32)))
67245 + && (ip->type & (1U << type))) {
67246 + if (ip->mode & GR_INVERT)
67247 + return 2; // specifically denied
67248 + else
67249 + return 1; // allowed
67250 + }
67251 +
67252 + return 0; // not specifically allowed, may continue parsing
67253 +}
67254 +
67255 +static int
67256 +gr_search_connectbind(const int full_mode, struct sock *sk,
67257 + struct sockaddr_in *addr, const int type)
67258 +{
67259 + char iface[IFNAMSIZ] = {0};
67260 + struct acl_subject_label *curr;
67261 + struct acl_ip_label *ip;
67262 + struct inet_sock *isk;
67263 + struct net_device *dev;
67264 + struct in_device *idev;
67265 + unsigned long i;
67266 + int ret;
67267 + int mode = full_mode & (GR_BIND | GR_CONNECT);
67268 + __u32 ip_addr = 0;
67269 + __u32 our_addr;
67270 + __u32 our_netmask;
67271 + char *p;
67272 + __u16 ip_port = 0;
67273 + const struct cred *cred = current_cred();
67274 +
67275 + if (unlikely(!gr_acl_is_enabled() || sk->sk_family != PF_INET))
67276 + return 0;
67277 +
67278 + curr = current->acl;
67279 + isk = inet_sk(sk);
67280 +
67281 + /* INADDR_ANY overriding for binds, inaddr_any_override is already in network order */
67282 + if ((full_mode & GR_BINDOVERRIDE) && addr->sin_addr.s_addr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0)
67283 + addr->sin_addr.s_addr = curr->inaddr_any_override;
67284 + if ((full_mode & GR_CONNECT) && isk->inet_saddr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0) {
67285 + struct sockaddr_in saddr;
67286 + int err;
67287 +
67288 + saddr.sin_family = AF_INET;
67289 + saddr.sin_addr.s_addr = curr->inaddr_any_override;
67290 + saddr.sin_port = isk->inet_sport;
67291 +
67292 + err = security_socket_bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
67293 + if (err)
67294 + return err;
67295 +
67296 + err = sk->sk_socket->ops->bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
67297 + if (err)
67298 + return err;
67299 + }
67300 +
67301 + if (!curr->ips)
67302 + return 0;
67303 +
67304 + ip_addr = addr->sin_addr.s_addr;
67305 + ip_port = ntohs(addr->sin_port);
67306 +
67307 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
67308 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
67309 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
67310 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
67311 + gr_to_filename(current->exec_file->f_path.dentry,
67312 + current->exec_file->f_path.mnt) :
67313 + curr->filename, curr->filename,
67314 + &ip_addr, ip_port, type,
67315 + sk->sk_protocol, mode, &current->signal->saved_ip);
67316 + return 0;
67317 + }
67318 +
67319 + for (i = 0; i < curr->ip_num; i++) {
67320 + ip = *(curr->ips + i);
67321 + if (ip->iface != NULL) {
67322 + strncpy(iface, ip->iface, IFNAMSIZ - 1);
67323 + p = strchr(iface, ':');
67324 + if (p != NULL)
67325 + *p = '\0';
67326 + dev = dev_get_by_name(sock_net(sk), iface);
67327 + if (dev == NULL)
67328 + continue;
67329 + idev = in_dev_get(dev);
67330 + if (idev == NULL) {
67331 + dev_put(dev);
67332 + continue;
67333 + }
67334 + rcu_read_lock();
67335 + for_ifa(idev) {
67336 + if (!strcmp(ip->iface, ifa->ifa_label)) {
67337 + our_addr = ifa->ifa_address;
67338 + our_netmask = 0xffffffff;
67339 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
67340 + if (ret == 1) {
67341 + rcu_read_unlock();
67342 + in_dev_put(idev);
67343 + dev_put(dev);
67344 + return 0;
67345 + } else if (ret == 2) {
67346 + rcu_read_unlock();
67347 + in_dev_put(idev);
67348 + dev_put(dev);
67349 + goto denied;
67350 + }
67351 + }
67352 + } endfor_ifa(idev);
67353 + rcu_read_unlock();
67354 + in_dev_put(idev);
67355 + dev_put(dev);
67356 + } else {
67357 + our_addr = ip->addr;
67358 + our_netmask = ip->netmask;
67359 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
67360 + if (ret == 1)
67361 + return 0;
67362 + else if (ret == 2)
67363 + goto denied;
67364 + }
67365 + }
67366 +
67367 +denied:
67368 + if (mode == GR_BIND)
67369 + 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));
67370 + else if (mode == GR_CONNECT)
67371 + 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));
67372 +
67373 + return -EACCES;
67374 +}
67375 +
67376 +int
67377 +gr_search_connect(struct socket *sock, struct sockaddr_in *addr)
67378 +{
67379 + /* always allow disconnection of dgram sockets with connect */
67380 + if (addr->sin_family == AF_UNSPEC)
67381 + return 0;
67382 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sock->sk, addr, sock->type);
67383 +}
67384 +
67385 +int
67386 +gr_search_bind(struct socket *sock, struct sockaddr_in *addr)
67387 +{
67388 + return gr_search_connectbind(GR_BIND | GR_BINDOVERRIDE, sock->sk, addr, sock->type);
67389 +}
67390 +
67391 +int gr_search_listen(struct socket *sock)
67392 +{
67393 + struct sock *sk = sock->sk;
67394 + struct sockaddr_in addr;
67395 +
67396 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
67397 + addr.sin_port = inet_sk(sk)->inet_sport;
67398 +
67399 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
67400 +}
67401 +
67402 +int gr_search_accept(struct socket *sock)
67403 +{
67404 + struct sock *sk = sock->sk;
67405 + struct sockaddr_in addr;
67406 +
67407 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
67408 + addr.sin_port = inet_sk(sk)->inet_sport;
67409 +
67410 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
67411 +}
67412 +
67413 +int
67414 +gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr)
67415 +{
67416 + if (addr)
67417 + return gr_search_connectbind(GR_CONNECT, sk, addr, SOCK_DGRAM);
67418 + else {
67419 + struct sockaddr_in sin;
67420 + const struct inet_sock *inet = inet_sk(sk);
67421 +
67422 + sin.sin_addr.s_addr = inet->inet_daddr;
67423 + sin.sin_port = inet->inet_dport;
67424 +
67425 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
67426 + }
67427 +}
67428 +
67429 +int
67430 +gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb)
67431 +{
67432 + struct sockaddr_in sin;
67433 +
67434 + if (unlikely(skb->len < sizeof (struct udphdr)))
67435 + return 0; // skip this packet
67436 +
67437 + sin.sin_addr.s_addr = ip_hdr(skb)->saddr;
67438 + sin.sin_port = udp_hdr(skb)->source;
67439 +
67440 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
67441 +}
67442 diff --git a/grsecurity/gracl_learn.c b/grsecurity/gracl_learn.c
67443 new file mode 100644
67444 index 0000000..25f54ef
67445 --- /dev/null
67446 +++ b/grsecurity/gracl_learn.c
67447 @@ -0,0 +1,207 @@
67448 +#include <linux/kernel.h>
67449 +#include <linux/mm.h>
67450 +#include <linux/sched.h>
67451 +#include <linux/poll.h>
67452 +#include <linux/string.h>
67453 +#include <linux/file.h>
67454 +#include <linux/types.h>
67455 +#include <linux/vmalloc.h>
67456 +#include <linux/grinternal.h>
67457 +
67458 +extern ssize_t write_grsec_handler(struct file * file, const char __user * buf,
67459 + size_t count, loff_t *ppos);
67460 +extern int gr_acl_is_enabled(void);
67461 +
67462 +static DECLARE_WAIT_QUEUE_HEAD(learn_wait);
67463 +static int gr_learn_attached;
67464 +
67465 +/* use a 512k buffer */
67466 +#define LEARN_BUFFER_SIZE (512 * 1024)
67467 +
67468 +static DEFINE_SPINLOCK(gr_learn_lock);
67469 +static DEFINE_MUTEX(gr_learn_user_mutex);
67470 +
67471 +/* we need to maintain two buffers, so that the kernel context of grlearn
67472 + uses a semaphore around the userspace copying, and the other kernel contexts
67473 + use a spinlock when copying into the buffer, since they cannot sleep
67474 +*/
67475 +static char *learn_buffer;
67476 +static char *learn_buffer_user;
67477 +static int learn_buffer_len;
67478 +static int learn_buffer_user_len;
67479 +
67480 +static ssize_t
67481 +read_learn(struct file *file, char __user * buf, size_t count, loff_t * ppos)
67482 +{
67483 + DECLARE_WAITQUEUE(wait, current);
67484 + ssize_t retval = 0;
67485 +
67486 + add_wait_queue(&learn_wait, &wait);
67487 + set_current_state(TASK_INTERRUPTIBLE);
67488 + do {
67489 + mutex_lock(&gr_learn_user_mutex);
67490 + spin_lock(&gr_learn_lock);
67491 + if (learn_buffer_len)
67492 + break;
67493 + spin_unlock(&gr_learn_lock);
67494 + mutex_unlock(&gr_learn_user_mutex);
67495 + if (file->f_flags & O_NONBLOCK) {
67496 + retval = -EAGAIN;
67497 + goto out;
67498 + }
67499 + if (signal_pending(current)) {
67500 + retval = -ERESTARTSYS;
67501 + goto out;
67502 + }
67503 +
67504 + schedule();
67505 + } while (1);
67506 +
67507 + memcpy(learn_buffer_user, learn_buffer, learn_buffer_len);
67508 + learn_buffer_user_len = learn_buffer_len;
67509 + retval = learn_buffer_len;
67510 + learn_buffer_len = 0;
67511 +
67512 + spin_unlock(&gr_learn_lock);
67513 +
67514 + if (copy_to_user(buf, learn_buffer_user, learn_buffer_user_len))
67515 + retval = -EFAULT;
67516 +
67517 + mutex_unlock(&gr_learn_user_mutex);
67518 +out:
67519 + set_current_state(TASK_RUNNING);
67520 + remove_wait_queue(&learn_wait, &wait);
67521 + return retval;
67522 +}
67523 +
67524 +static unsigned int
67525 +poll_learn(struct file * file, poll_table * wait)
67526 +{
67527 + poll_wait(file, &learn_wait, wait);
67528 +
67529 + if (learn_buffer_len)
67530 + return (POLLIN | POLLRDNORM);
67531 +
67532 + return 0;
67533 +}
67534 +
67535 +void
67536 +gr_clear_learn_entries(void)
67537 +{
67538 + char *tmp;
67539 +
67540 + mutex_lock(&gr_learn_user_mutex);
67541 + spin_lock(&gr_learn_lock);
67542 + tmp = learn_buffer;
67543 + learn_buffer = NULL;
67544 + spin_unlock(&gr_learn_lock);
67545 + if (tmp)
67546 + vfree(tmp);
67547 + if (learn_buffer_user != NULL) {
67548 + vfree(learn_buffer_user);
67549 + learn_buffer_user = NULL;
67550 + }
67551 + learn_buffer_len = 0;
67552 + mutex_unlock(&gr_learn_user_mutex);
67553 +
67554 + return;
67555 +}
67556 +
67557 +void
67558 +gr_add_learn_entry(const char *fmt, ...)
67559 +{
67560 + va_list args;
67561 + unsigned int len;
67562 +
67563 + if (!gr_learn_attached)
67564 + return;
67565 +
67566 + spin_lock(&gr_learn_lock);
67567 +
67568 + /* leave a gap at the end so we know when it's "full" but don't have to
67569 + compute the exact length of the string we're trying to append
67570 + */
67571 + if (learn_buffer_len > LEARN_BUFFER_SIZE - 16384) {
67572 + spin_unlock(&gr_learn_lock);
67573 + wake_up_interruptible(&learn_wait);
67574 + return;
67575 + }
67576 + if (learn_buffer == NULL) {
67577 + spin_unlock(&gr_learn_lock);
67578 + return;
67579 + }
67580 +
67581 + va_start(args, fmt);
67582 + len = vsnprintf(learn_buffer + learn_buffer_len, LEARN_BUFFER_SIZE - learn_buffer_len, fmt, args);
67583 + va_end(args);
67584 +
67585 + learn_buffer_len += len + 1;
67586 +
67587 + spin_unlock(&gr_learn_lock);
67588 + wake_up_interruptible(&learn_wait);
67589 +
67590 + return;
67591 +}
67592 +
67593 +static int
67594 +open_learn(struct inode *inode, struct file *file)
67595 +{
67596 + if (file->f_mode & FMODE_READ && gr_learn_attached)
67597 + return -EBUSY;
67598 + if (file->f_mode & FMODE_READ) {
67599 + int retval = 0;
67600 + mutex_lock(&gr_learn_user_mutex);
67601 + if (learn_buffer == NULL)
67602 + learn_buffer = vmalloc(LEARN_BUFFER_SIZE);
67603 + if (learn_buffer_user == NULL)
67604 + learn_buffer_user = vmalloc(LEARN_BUFFER_SIZE);
67605 + if (learn_buffer == NULL) {
67606 + retval = -ENOMEM;
67607 + goto out_error;
67608 + }
67609 + if (learn_buffer_user == NULL) {
67610 + retval = -ENOMEM;
67611 + goto out_error;
67612 + }
67613 + learn_buffer_len = 0;
67614 + learn_buffer_user_len = 0;
67615 + gr_learn_attached = 1;
67616 +out_error:
67617 + mutex_unlock(&gr_learn_user_mutex);
67618 + return retval;
67619 + }
67620 + return 0;
67621 +}
67622 +
67623 +static int
67624 +close_learn(struct inode *inode, struct file *file)
67625 +{
67626 + if (file->f_mode & FMODE_READ) {
67627 + char *tmp = NULL;
67628 + mutex_lock(&gr_learn_user_mutex);
67629 + spin_lock(&gr_learn_lock);
67630 + tmp = learn_buffer;
67631 + learn_buffer = NULL;
67632 + spin_unlock(&gr_learn_lock);
67633 + if (tmp)
67634 + vfree(tmp);
67635 + if (learn_buffer_user != NULL) {
67636 + vfree(learn_buffer_user);
67637 + learn_buffer_user = NULL;
67638 + }
67639 + learn_buffer_len = 0;
67640 + learn_buffer_user_len = 0;
67641 + gr_learn_attached = 0;
67642 + mutex_unlock(&gr_learn_user_mutex);
67643 + }
67644 +
67645 + return 0;
67646 +}
67647 +
67648 +const struct file_operations grsec_fops = {
67649 + .read = read_learn,
67650 + .write = write_grsec_handler,
67651 + .open = open_learn,
67652 + .release = close_learn,
67653 + .poll = poll_learn,
67654 +};
67655 diff --git a/grsecurity/gracl_policy.c b/grsecurity/gracl_policy.c
67656 new file mode 100644
67657 index 0000000..361a099
67658 --- /dev/null
67659 +++ b/grsecurity/gracl_policy.c
67660 @@ -0,0 +1,1782 @@
67661 +#include <linux/kernel.h>
67662 +#include <linux/module.h>
67663 +#include <linux/sched.h>
67664 +#include <linux/mm.h>
67665 +#include <linux/file.h>
67666 +#include <linux/fs.h>
67667 +#include <linux/namei.h>
67668 +#include <linux/mount.h>
67669 +#include <linux/tty.h>
67670 +#include <linux/proc_fs.h>
67671 +#include <linux/lglock.h>
67672 +#include <linux/slab.h>
67673 +#include <linux/vmalloc.h>
67674 +#include <linux/types.h>
67675 +#include <linux/sysctl.h>
67676 +#include <linux/netdevice.h>
67677 +#include <linux/ptrace.h>
67678 +#include <linux/gracl.h>
67679 +#include <linux/gralloc.h>
67680 +#include <linux/security.h>
67681 +#include <linux/grinternal.h>
67682 +#include <linux/pid_namespace.h>
67683 +#include <linux/stop_machine.h>
67684 +#include <linux/fdtable.h>
67685 +#include <linux/percpu.h>
67686 +#include <linux/lglock.h>
67687 +#include <linux/hugetlb.h>
67688 +#include <linux/posix-timers.h>
67689 +#include "../fs/mount.h"
67690 +
67691 +#include <asm/uaccess.h>
67692 +#include <asm/errno.h>
67693 +#include <asm/mman.h>
67694 +
67695 +extern struct gr_policy_state *polstate;
67696 +
67697 +#define FOR_EACH_ROLE_START(role) \
67698 + role = polstate->role_list; \
67699 + while (role) {
67700 +
67701 +#define FOR_EACH_ROLE_END(role) \
67702 + role = role->prev; \
67703 + }
67704 +
67705 +struct path gr_real_root;
67706 +
67707 +extern struct gr_alloc_state *current_alloc_state;
67708 +
67709 +u16 acl_sp_role_value;
67710 +
67711 +static DEFINE_MUTEX(gr_dev_mutex);
67712 +
67713 +extern int chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum);
67714 +extern void gr_clear_learn_entries(void);
67715 +
67716 +static struct gr_arg gr_usermode;
67717 +static unsigned char gr_system_salt[GR_SALT_LEN];
67718 +static unsigned char gr_system_sum[GR_SHA_LEN];
67719 +
67720 +static unsigned int gr_auth_attempts = 0;
67721 +static unsigned long gr_auth_expires = 0UL;
67722 +
67723 +struct acl_object_label *fakefs_obj_rw;
67724 +struct acl_object_label *fakefs_obj_rwx;
67725 +
67726 +extern int gr_init_uidset(void);
67727 +extern void gr_free_uidset(void);
67728 +extern void gr_remove_uid(uid_t uid);
67729 +extern int gr_find_uid(uid_t uid);
67730 +
67731 +extern struct acl_subject_label *__gr_get_subject_for_task(const struct gr_policy_state *state, struct task_struct *task, const char *filename);
67732 +extern void __gr_apply_subject_to_task(struct gr_policy_state *state, struct task_struct *task, struct acl_subject_label *subj);
67733 +extern int gr_streq(const char *a, const char *b, const unsigned int lena, const unsigned int lenb);
67734 +extern void __insert_inodev_entry(const struct gr_policy_state *state, struct inodev_entry *entry);
67735 +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);
67736 +extern void insert_acl_obj_label(struct acl_object_label *obj, struct acl_subject_label *subj);
67737 +extern void insert_acl_subj_label(struct acl_subject_label *obj, struct acl_role_label *role);
67738 +extern struct name_entry * __lookup_name_entry(const struct gr_policy_state *state, const char *name);
67739 +extern char *gr_to_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt);
67740 +extern struct acl_subject_label *lookup_acl_subj_label(const ino_t ino, const dev_t dev, const struct acl_role_label *role);
67741 +extern struct acl_subject_label *lookup_acl_subj_label_deleted(const ino_t ino, const dev_t dev, const struct acl_role_label *role);
67742 +extern void assign_special_role(const char *rolename);
67743 +extern struct acl_subject_label *chk_subj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt, const struct acl_role_label *role);
67744 +extern int gr_rbac_disable(void *unused);
67745 +extern void gr_enable_rbac_system(void);
67746 +
67747 +static int copy_acl_object_label_normal(struct acl_object_label *obj, const struct acl_object_label *userp)
67748 +{
67749 + if (copy_from_user(obj, userp, sizeof(struct acl_object_label)))
67750 + return -EFAULT;
67751 +
67752 + return 0;
67753 +}
67754 +
67755 +static int copy_acl_ip_label_normal(struct acl_ip_label *ip, const struct acl_ip_label *userp)
67756 +{
67757 + if (copy_from_user(ip, userp, sizeof(struct acl_ip_label)))
67758 + return -EFAULT;
67759 +
67760 + return 0;
67761 +}
67762 +
67763 +static int copy_acl_subject_label_normal(struct acl_subject_label *subj, const struct acl_subject_label *userp)
67764 +{
67765 + if (copy_from_user(subj, userp, sizeof(struct acl_subject_label)))
67766 + return -EFAULT;
67767 +
67768 + return 0;
67769 +}
67770 +
67771 +static int copy_acl_role_label_normal(struct acl_role_label *role, const struct acl_role_label *userp)
67772 +{
67773 + if (copy_from_user(role, userp, sizeof(struct acl_role_label)))
67774 + return -EFAULT;
67775 +
67776 + return 0;
67777 +}
67778 +
67779 +static int copy_role_allowed_ip_normal(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp)
67780 +{
67781 + if (copy_from_user(roleip, userp, sizeof(struct role_allowed_ip)))
67782 + return -EFAULT;
67783 +
67784 + return 0;
67785 +}
67786 +
67787 +static int copy_sprole_pw_normal(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp)
67788 +{
67789 + if (copy_from_user(pw, userp + idx, sizeof(struct sprole_pw)))
67790 + return -EFAULT;
67791 +
67792 + return 0;
67793 +}
67794 +
67795 +static int copy_gr_hash_struct_normal(struct gr_hash_struct *hash, const struct gr_hash_struct *userp)
67796 +{
67797 + if (copy_from_user(hash, userp, sizeof(struct gr_hash_struct)))
67798 + return -EFAULT;
67799 +
67800 + return 0;
67801 +}
67802 +
67803 +static int copy_role_transition_normal(struct role_transition *trans, const struct role_transition *userp)
67804 +{
67805 + if (copy_from_user(trans, userp, sizeof(struct role_transition)))
67806 + return -EFAULT;
67807 +
67808 + return 0;
67809 +}
67810 +
67811 +int copy_pointer_from_array_normal(void *ptr, unsigned long idx, const void *userp)
67812 +{
67813 + if (copy_from_user(ptr, userp + (idx * sizeof(void *)), sizeof(void *)))
67814 + return -EFAULT;
67815 +
67816 + return 0;
67817 +}
67818 +
67819 +static int copy_gr_arg_wrapper_normal(const char __user *buf, struct gr_arg_wrapper *uwrap)
67820 +{
67821 + if (copy_from_user(uwrap, buf, sizeof (struct gr_arg_wrapper)))
67822 + return -EFAULT;
67823 +
67824 + if (((uwrap->version != GRSECURITY_VERSION) &&
67825 + (uwrap->version != 0x2901)) ||
67826 + (uwrap->size != sizeof(struct gr_arg)))
67827 + return -EINVAL;
67828 +
67829 + return 0;
67830 +}
67831 +
67832 +static int copy_gr_arg_normal(const struct gr_arg __user *buf, struct gr_arg *arg)
67833 +{
67834 + if (copy_from_user(arg, buf, sizeof (struct gr_arg)))
67835 + return -EFAULT;
67836 +
67837 + return 0;
67838 +}
67839 +
67840 +static size_t get_gr_arg_wrapper_size_normal(void)
67841 +{
67842 + return sizeof(struct gr_arg_wrapper);
67843 +}
67844 +
67845 +#ifdef CONFIG_COMPAT
67846 +extern int copy_gr_arg_wrapper_compat(const char *buf, struct gr_arg_wrapper *uwrap);
67847 +extern int copy_gr_arg_compat(const struct gr_arg __user *buf, struct gr_arg *arg);
67848 +extern int copy_acl_object_label_compat(struct acl_object_label *obj, const struct acl_object_label *userp);
67849 +extern int copy_acl_subject_label_compat(struct acl_subject_label *subj, const struct acl_subject_label *userp);
67850 +extern int copy_acl_role_label_compat(struct acl_role_label *role, const struct acl_role_label *userp);
67851 +extern int copy_role_allowed_ip_compat(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp);
67852 +extern int copy_role_transition_compat(struct role_transition *trans, const struct role_transition *userp);
67853 +extern int copy_gr_hash_struct_compat(struct gr_hash_struct *hash, const struct gr_hash_struct *userp);
67854 +extern int copy_pointer_from_array_compat(void *ptr, unsigned long idx, const void *userp);
67855 +extern int copy_acl_ip_label_compat(struct acl_ip_label *ip, const struct acl_ip_label *userp);
67856 +extern int copy_sprole_pw_compat(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp);
67857 +extern size_t get_gr_arg_wrapper_size_compat(void);
67858 +
67859 +int (* copy_gr_arg_wrapper)(const char *buf, struct gr_arg_wrapper *uwrap) __read_only;
67860 +int (* copy_gr_arg)(const struct gr_arg *buf, struct gr_arg *arg) __read_only;
67861 +int (* copy_acl_object_label)(struct acl_object_label *obj, const struct acl_object_label *userp) __read_only;
67862 +int (* copy_acl_subject_label)(struct acl_subject_label *subj, const struct acl_subject_label *userp) __read_only;
67863 +int (* copy_acl_role_label)(struct acl_role_label *role, const struct acl_role_label *userp) __read_only;
67864 +int (* copy_acl_ip_label)(struct acl_ip_label *ip, const struct acl_ip_label *userp) __read_only;
67865 +int (* copy_pointer_from_array)(void *ptr, unsigned long idx, const void *userp) __read_only;
67866 +int (* copy_sprole_pw)(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp) __read_only;
67867 +int (* copy_gr_hash_struct)(struct gr_hash_struct *hash, const struct gr_hash_struct *userp) __read_only;
67868 +int (* copy_role_transition)(struct role_transition *trans, const struct role_transition *userp) __read_only;
67869 +int (* copy_role_allowed_ip)(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp) __read_only;
67870 +size_t (* get_gr_arg_wrapper_size)(void) __read_only;
67871 +
67872 +#else
67873 +#define copy_gr_arg_wrapper copy_gr_arg_wrapper_normal
67874 +#define copy_gr_arg copy_gr_arg_normal
67875 +#define copy_gr_hash_struct copy_gr_hash_struct_normal
67876 +#define copy_acl_object_label copy_acl_object_label_normal
67877 +#define copy_acl_subject_label copy_acl_subject_label_normal
67878 +#define copy_acl_role_label copy_acl_role_label_normal
67879 +#define copy_acl_ip_label copy_acl_ip_label_normal
67880 +#define copy_pointer_from_array copy_pointer_from_array_normal
67881 +#define copy_sprole_pw copy_sprole_pw_normal
67882 +#define copy_role_transition copy_role_transition_normal
67883 +#define copy_role_allowed_ip copy_role_allowed_ip_normal
67884 +#define get_gr_arg_wrapper_size get_gr_arg_wrapper_size_normal
67885 +#endif
67886 +
67887 +static struct acl_subject_label *
67888 +lookup_subject_map(const struct acl_subject_label *userp)
67889 +{
67890 + unsigned int index = gr_shash(userp, polstate->subj_map_set.s_size);
67891 + struct subject_map *match;
67892 +
67893 + match = polstate->subj_map_set.s_hash[index];
67894 +
67895 + while (match && match->user != userp)
67896 + match = match->next;
67897 +
67898 + if (match != NULL)
67899 + return match->kernel;
67900 + else
67901 + return NULL;
67902 +}
67903 +
67904 +static void
67905 +insert_subj_map_entry(struct subject_map *subjmap)
67906 +{
67907 + unsigned int index = gr_shash(subjmap->user, polstate->subj_map_set.s_size);
67908 + struct subject_map **curr;
67909 +
67910 + subjmap->prev = NULL;
67911 +
67912 + curr = &polstate->subj_map_set.s_hash[index];
67913 + if (*curr != NULL)
67914 + (*curr)->prev = subjmap;
67915 +
67916 + subjmap->next = *curr;
67917 + *curr = subjmap;
67918 +
67919 + return;
67920 +}
67921 +
67922 +static void
67923 +__insert_acl_role_label(struct acl_role_label *role, uid_t uidgid)
67924 +{
67925 + unsigned int index =
67926 + gr_rhash(uidgid, role->roletype & (GR_ROLE_USER | GR_ROLE_GROUP), polstate->acl_role_set.r_size);
67927 + struct acl_role_label **curr;
67928 + struct acl_role_label *tmp, *tmp2;
67929 +
67930 + curr = &polstate->acl_role_set.r_hash[index];
67931 +
67932 + /* simple case, slot is empty, just set it to our role */
67933 + if (*curr == NULL) {
67934 + *curr = role;
67935 + } else {
67936 + /* example:
67937 + 1 -> 2 -> 3 (adding 2 -> 3 to here)
67938 + 2 -> 3
67939 + */
67940 + /* first check to see if we can already be reached via this slot */
67941 + tmp = *curr;
67942 + while (tmp && tmp != role)
67943 + tmp = tmp->next;
67944 + if (tmp == role) {
67945 + /* we don't need to add ourselves to this slot's chain */
67946 + return;
67947 + }
67948 + /* we need to add ourselves to this chain, two cases */
67949 + if (role->next == NULL) {
67950 + /* simple case, append the current chain to our role */
67951 + role->next = *curr;
67952 + *curr = role;
67953 + } else {
67954 + /* 1 -> 2 -> 3 -> 4
67955 + 2 -> 3 -> 4
67956 + 3 -> 4 (adding 1 -> 2 -> 3 -> 4 to here)
67957 + */
67958 + /* trickier case: walk our role's chain until we find
67959 + the role for the start of the current slot's chain */
67960 + tmp = role;
67961 + tmp2 = *curr;
67962 + while (tmp->next && tmp->next != tmp2)
67963 + tmp = tmp->next;
67964 + if (tmp->next == tmp2) {
67965 + /* from example above, we found 3, so just
67966 + replace this slot's chain with ours */
67967 + *curr = role;
67968 + } else {
67969 + /* we didn't find a subset of our role's chain
67970 + in the current slot's chain, so append their
67971 + chain to ours, and set us as the first role in
67972 + the slot's chain
67973 +
67974 + we could fold this case with the case above,
67975 + but making it explicit for clarity
67976 + */
67977 + tmp->next = tmp2;
67978 + *curr = role;
67979 + }
67980 + }
67981 + }
67982 +
67983 + return;
67984 +}
67985 +
67986 +static void
67987 +insert_acl_role_label(struct acl_role_label *role)
67988 +{
67989 + int i;
67990 +
67991 + if (polstate->role_list == NULL) {
67992 + polstate->role_list = role;
67993 + role->prev = NULL;
67994 + } else {
67995 + role->prev = polstate->role_list;
67996 + polstate->role_list = role;
67997 + }
67998 +
67999 + /* used for hash chains */
68000 + role->next = NULL;
68001 +
68002 + if (role->roletype & GR_ROLE_DOMAIN) {
68003 + for (i = 0; i < role->domain_child_num; i++)
68004 + __insert_acl_role_label(role, role->domain_children[i]);
68005 + } else
68006 + __insert_acl_role_label(role, role->uidgid);
68007 +}
68008 +
68009 +static int
68010 +insert_name_entry(char *name, const ino_t inode, const dev_t device, __u8 deleted)
68011 +{
68012 + struct name_entry **curr, *nentry;
68013 + struct inodev_entry *ientry;
68014 + unsigned int len = strlen(name);
68015 + unsigned int key = full_name_hash(name, len);
68016 + unsigned int index = key % polstate->name_set.n_size;
68017 +
68018 + curr = &polstate->name_set.n_hash[index];
68019 +
68020 + while (*curr && ((*curr)->key != key || !gr_streq((*curr)->name, name, (*curr)->len, len)))
68021 + curr = &((*curr)->next);
68022 +
68023 + if (*curr != NULL)
68024 + return 1;
68025 +
68026 + nentry = acl_alloc(sizeof (struct name_entry));
68027 + if (nentry == NULL)
68028 + return 0;
68029 + ientry = acl_alloc(sizeof (struct inodev_entry));
68030 + if (ientry == NULL)
68031 + return 0;
68032 + ientry->nentry = nentry;
68033 +
68034 + nentry->key = key;
68035 + nentry->name = name;
68036 + nentry->inode = inode;
68037 + nentry->device = device;
68038 + nentry->len = len;
68039 + nentry->deleted = deleted;
68040 +
68041 + nentry->prev = NULL;
68042 + curr = &polstate->name_set.n_hash[index];
68043 + if (*curr != NULL)
68044 + (*curr)->prev = nentry;
68045 + nentry->next = *curr;
68046 + *curr = nentry;
68047 +
68048 + /* insert us into the table searchable by inode/dev */
68049 + __insert_inodev_entry(polstate, ientry);
68050 +
68051 + return 1;
68052 +}
68053 +
68054 +/* allocating chained hash tables, so optimal size is where lambda ~ 1 */
68055 +
68056 +static void *
68057 +create_table(__u32 * len, int elementsize)
68058 +{
68059 + unsigned int table_sizes[] = {
68060 + 7, 13, 31, 61, 127, 251, 509, 1021, 2039, 4093, 8191, 16381,
68061 + 32749, 65521, 131071, 262139, 524287, 1048573, 2097143,
68062 + 4194301, 8388593, 16777213, 33554393, 67108859
68063 + };
68064 + void *newtable = NULL;
68065 + unsigned int pwr = 0;
68066 +
68067 + while ((pwr < ((sizeof (table_sizes) / sizeof (table_sizes[0])) - 1)) &&
68068 + table_sizes[pwr] <= *len)
68069 + pwr++;
68070 +
68071 + if (table_sizes[pwr] <= *len || (table_sizes[pwr] > ULONG_MAX / elementsize))
68072 + return newtable;
68073 +
68074 + if ((table_sizes[pwr] * elementsize) <= PAGE_SIZE)
68075 + newtable =
68076 + kmalloc(table_sizes[pwr] * elementsize, GFP_KERNEL);
68077 + else
68078 + newtable = vmalloc(table_sizes[pwr] * elementsize);
68079 +
68080 + *len = table_sizes[pwr];
68081 +
68082 + return newtable;
68083 +}
68084 +
68085 +static int
68086 +init_variables(const struct gr_arg *arg, bool reload)
68087 +{
68088 + struct task_struct *reaper = init_pid_ns.child_reaper;
68089 + unsigned int stacksize;
68090 +
68091 + polstate->subj_map_set.s_size = arg->role_db.num_subjects;
68092 + polstate->acl_role_set.r_size = arg->role_db.num_roles + arg->role_db.num_domain_children;
68093 + polstate->name_set.n_size = arg->role_db.num_objects;
68094 + polstate->inodev_set.i_size = arg->role_db.num_objects;
68095 +
68096 + if (!polstate->subj_map_set.s_size || !polstate->acl_role_set.r_size ||
68097 + !polstate->name_set.n_size || !polstate->inodev_set.i_size)
68098 + return 1;
68099 +
68100 + if (!reload) {
68101 + if (!gr_init_uidset())
68102 + return 1;
68103 + }
68104 +
68105 + /* set up the stack that holds allocation info */
68106 +
68107 + stacksize = arg->role_db.num_pointers + 5;
68108 +
68109 + if (!acl_alloc_stack_init(stacksize))
68110 + return 1;
68111 +
68112 + if (!reload) {
68113 + /* grab reference for the real root dentry and vfsmount */
68114 + get_fs_root(reaper->fs, &gr_real_root);
68115 +
68116 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
68117 + 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);
68118 +#endif
68119 +
68120 + fakefs_obj_rw = kzalloc(sizeof(struct acl_object_label), GFP_KERNEL);
68121 + if (fakefs_obj_rw == NULL)
68122 + return 1;
68123 + fakefs_obj_rw->mode = GR_FIND | GR_READ | GR_WRITE;
68124 +
68125 + fakefs_obj_rwx = kzalloc(sizeof(struct acl_object_label), GFP_KERNEL);
68126 + if (fakefs_obj_rwx == NULL)
68127 + return 1;
68128 + fakefs_obj_rwx->mode = GR_FIND | GR_READ | GR_WRITE | GR_EXEC;
68129 + }
68130 +
68131 + polstate->subj_map_set.s_hash =
68132 + (struct subject_map **) create_table(&polstate->subj_map_set.s_size, sizeof(void *));
68133 + polstate->acl_role_set.r_hash =
68134 + (struct acl_role_label **) create_table(&polstate->acl_role_set.r_size, sizeof(void *));
68135 + polstate->name_set.n_hash = (struct name_entry **) create_table(&polstate->name_set.n_size, sizeof(void *));
68136 + polstate->inodev_set.i_hash =
68137 + (struct inodev_entry **) create_table(&polstate->inodev_set.i_size, sizeof(void *));
68138 +
68139 + if (!polstate->subj_map_set.s_hash || !polstate->acl_role_set.r_hash ||
68140 + !polstate->name_set.n_hash || !polstate->inodev_set.i_hash)
68141 + return 1;
68142 +
68143 + memset(polstate->subj_map_set.s_hash, 0,
68144 + sizeof(struct subject_map *) * polstate->subj_map_set.s_size);
68145 + memset(polstate->acl_role_set.r_hash, 0,
68146 + sizeof (struct acl_role_label *) * polstate->acl_role_set.r_size);
68147 + memset(polstate->name_set.n_hash, 0,
68148 + sizeof (struct name_entry *) * polstate->name_set.n_size);
68149 + memset(polstate->inodev_set.i_hash, 0,
68150 + sizeof (struct inodev_entry *) * polstate->inodev_set.i_size);
68151 +
68152 + return 0;
68153 +}
68154 +
68155 +/* free information not needed after startup
68156 + currently contains user->kernel pointer mappings for subjects
68157 +*/
68158 +
68159 +static void
68160 +free_init_variables(void)
68161 +{
68162 + __u32 i;
68163 +
68164 + if (polstate->subj_map_set.s_hash) {
68165 + for (i = 0; i < polstate->subj_map_set.s_size; i++) {
68166 + if (polstate->subj_map_set.s_hash[i]) {
68167 + kfree(polstate->subj_map_set.s_hash[i]);
68168 + polstate->subj_map_set.s_hash[i] = NULL;
68169 + }
68170 + }
68171 +
68172 + if ((polstate->subj_map_set.s_size * sizeof (struct subject_map *)) <=
68173 + PAGE_SIZE)
68174 + kfree(polstate->subj_map_set.s_hash);
68175 + else
68176 + vfree(polstate->subj_map_set.s_hash);
68177 + }
68178 +
68179 + return;
68180 +}
68181 +
68182 +static void
68183 +free_variables(bool reload)
68184 +{
68185 + struct acl_subject_label *s;
68186 + struct acl_role_label *r;
68187 + struct task_struct *task, *task2;
68188 + unsigned int x;
68189 +
68190 + if (!reload) {
68191 + gr_clear_learn_entries();
68192 +
68193 + read_lock(&tasklist_lock);
68194 + do_each_thread(task2, task) {
68195 + task->acl_sp_role = 0;
68196 + task->acl_role_id = 0;
68197 + task->inherited = 0;
68198 + task->acl = NULL;
68199 + task->role = NULL;
68200 + } while_each_thread(task2, task);
68201 + read_unlock(&tasklist_lock);
68202 +
68203 + kfree(fakefs_obj_rw);
68204 + fakefs_obj_rw = NULL;
68205 + kfree(fakefs_obj_rwx);
68206 + fakefs_obj_rwx = NULL;
68207 +
68208 + /* release the reference to the real root dentry and vfsmount */
68209 + path_put(&gr_real_root);
68210 + memset(&gr_real_root, 0, sizeof(gr_real_root));
68211 + }
68212 +
68213 + /* free all object hash tables */
68214 +
68215 + FOR_EACH_ROLE_START(r)
68216 + if (r->subj_hash == NULL)
68217 + goto next_role;
68218 + FOR_EACH_SUBJECT_START(r, s, x)
68219 + if (s->obj_hash == NULL)
68220 + break;
68221 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
68222 + kfree(s->obj_hash);
68223 + else
68224 + vfree(s->obj_hash);
68225 + FOR_EACH_SUBJECT_END(s, x)
68226 + FOR_EACH_NESTED_SUBJECT_START(r, s)
68227 + if (s->obj_hash == NULL)
68228 + break;
68229 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
68230 + kfree(s->obj_hash);
68231 + else
68232 + vfree(s->obj_hash);
68233 + FOR_EACH_NESTED_SUBJECT_END(s)
68234 + if ((r->subj_hash_size * sizeof (struct acl_subject_label *)) <= PAGE_SIZE)
68235 + kfree(r->subj_hash);
68236 + else
68237 + vfree(r->subj_hash);
68238 + r->subj_hash = NULL;
68239 +next_role:
68240 + FOR_EACH_ROLE_END(r)
68241 +
68242 + acl_free_all();
68243 +
68244 + if (polstate->acl_role_set.r_hash) {
68245 + if ((polstate->acl_role_set.r_size * sizeof (struct acl_role_label *)) <=
68246 + PAGE_SIZE)
68247 + kfree(polstate->acl_role_set.r_hash);
68248 + else
68249 + vfree(polstate->acl_role_set.r_hash);
68250 + }
68251 + if (polstate->name_set.n_hash) {
68252 + if ((polstate->name_set.n_size * sizeof (struct name_entry *)) <=
68253 + PAGE_SIZE)
68254 + kfree(polstate->name_set.n_hash);
68255 + else
68256 + vfree(polstate->name_set.n_hash);
68257 + }
68258 +
68259 + if (polstate->inodev_set.i_hash) {
68260 + if ((polstate->inodev_set.i_size * sizeof (struct inodev_entry *)) <=
68261 + PAGE_SIZE)
68262 + kfree(polstate->inodev_set.i_hash);
68263 + else
68264 + vfree(polstate->inodev_set.i_hash);
68265 + }
68266 +
68267 + if (!reload)
68268 + gr_free_uidset();
68269 +
68270 + memset(&polstate->name_set, 0, sizeof (struct name_db));
68271 + memset(&polstate->inodev_set, 0, sizeof (struct inodev_db));
68272 + memset(&polstate->acl_role_set, 0, sizeof (struct acl_role_db));
68273 + memset(&polstate->subj_map_set, 0, sizeof (struct acl_subj_map_db));
68274 +
68275 + polstate->default_role = NULL;
68276 + polstate->kernel_role = NULL;
68277 + polstate->role_list = NULL;
68278 +
68279 + return;
68280 +}
68281 +
68282 +static struct acl_subject_label *
68283 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied);
68284 +
68285 +static int alloc_and_copy_string(char **name, unsigned int maxlen)
68286 +{
68287 + unsigned int len = strnlen_user(*name, maxlen);
68288 + char *tmp;
68289 +
68290 + if (!len || len >= maxlen)
68291 + return -EINVAL;
68292 +
68293 + if ((tmp = (char *) acl_alloc(len)) == NULL)
68294 + return -ENOMEM;
68295 +
68296 + if (copy_from_user(tmp, *name, len))
68297 + return -EFAULT;
68298 +
68299 + tmp[len-1] = '\0';
68300 + *name = tmp;
68301 +
68302 + return 0;
68303 +}
68304 +
68305 +static int
68306 +copy_user_glob(struct acl_object_label *obj)
68307 +{
68308 + struct acl_object_label *g_tmp, **guser;
68309 + int error;
68310 +
68311 + if (obj->globbed == NULL)
68312 + return 0;
68313 +
68314 + guser = &obj->globbed;
68315 + while (*guser) {
68316 + g_tmp = (struct acl_object_label *)
68317 + acl_alloc(sizeof (struct acl_object_label));
68318 + if (g_tmp == NULL)
68319 + return -ENOMEM;
68320 +
68321 + if (copy_acl_object_label(g_tmp, *guser))
68322 + return -EFAULT;
68323 +
68324 + error = alloc_and_copy_string(&g_tmp->filename, PATH_MAX);
68325 + if (error)
68326 + return error;
68327 +
68328 + *guser = g_tmp;
68329 + guser = &(g_tmp->next);
68330 + }
68331 +
68332 + return 0;
68333 +}
68334 +
68335 +static int
68336 +copy_user_objs(struct acl_object_label *userp, struct acl_subject_label *subj,
68337 + struct acl_role_label *role)
68338 +{
68339 + struct acl_object_label *o_tmp;
68340 + int ret;
68341 +
68342 + while (userp) {
68343 + if ((o_tmp = (struct acl_object_label *)
68344 + acl_alloc(sizeof (struct acl_object_label))) == NULL)
68345 + return -ENOMEM;
68346 +
68347 + if (copy_acl_object_label(o_tmp, userp))
68348 + return -EFAULT;
68349 +
68350 + userp = o_tmp->prev;
68351 +
68352 + ret = alloc_and_copy_string(&o_tmp->filename, PATH_MAX);
68353 + if (ret)
68354 + return ret;
68355 +
68356 + insert_acl_obj_label(o_tmp, subj);
68357 + if (!insert_name_entry(o_tmp->filename, o_tmp->inode,
68358 + o_tmp->device, (o_tmp->mode & GR_DELETED) ? 1 : 0))
68359 + return -ENOMEM;
68360 +
68361 + ret = copy_user_glob(o_tmp);
68362 + if (ret)
68363 + return ret;
68364 +
68365 + if (o_tmp->nested) {
68366 + int already_copied;
68367 +
68368 + o_tmp->nested = do_copy_user_subj(o_tmp->nested, role, &already_copied);
68369 + if (IS_ERR(o_tmp->nested))
68370 + return PTR_ERR(o_tmp->nested);
68371 +
68372 + /* insert into nested subject list if we haven't copied this one yet
68373 + to prevent duplicate entries */
68374 + if (!already_copied) {
68375 + o_tmp->nested->next = role->hash->first;
68376 + role->hash->first = o_tmp->nested;
68377 + }
68378 + }
68379 + }
68380 +
68381 + return 0;
68382 +}
68383 +
68384 +static __u32
68385 +count_user_subjs(struct acl_subject_label *userp)
68386 +{
68387 + struct acl_subject_label s_tmp;
68388 + __u32 num = 0;
68389 +
68390 + while (userp) {
68391 + if (copy_acl_subject_label(&s_tmp, userp))
68392 + break;
68393 +
68394 + userp = s_tmp.prev;
68395 + }
68396 +
68397 + return num;
68398 +}
68399 +
68400 +static int
68401 +copy_user_allowedips(struct acl_role_label *rolep)
68402 +{
68403 + struct role_allowed_ip *ruserip, *rtmp = NULL, *rlast;
68404 +
68405 + ruserip = rolep->allowed_ips;
68406 +
68407 + while (ruserip) {
68408 + rlast = rtmp;
68409 +
68410 + if ((rtmp = (struct role_allowed_ip *)
68411 + acl_alloc(sizeof (struct role_allowed_ip))) == NULL)
68412 + return -ENOMEM;
68413 +
68414 + if (copy_role_allowed_ip(rtmp, ruserip))
68415 + return -EFAULT;
68416 +
68417 + ruserip = rtmp->prev;
68418 +
68419 + if (!rlast) {
68420 + rtmp->prev = NULL;
68421 + rolep->allowed_ips = rtmp;
68422 + } else {
68423 + rlast->next = rtmp;
68424 + rtmp->prev = rlast;
68425 + }
68426 +
68427 + if (!ruserip)
68428 + rtmp->next = NULL;
68429 + }
68430 +
68431 + return 0;
68432 +}
68433 +
68434 +static int
68435 +copy_user_transitions(struct acl_role_label *rolep)
68436 +{
68437 + struct role_transition *rusertp, *rtmp = NULL, *rlast;
68438 + int error;
68439 +
68440 + rusertp = rolep->transitions;
68441 +
68442 + while (rusertp) {
68443 + rlast = rtmp;
68444 +
68445 + if ((rtmp = (struct role_transition *)
68446 + acl_alloc(sizeof (struct role_transition))) == NULL)
68447 + return -ENOMEM;
68448 +
68449 + if (copy_role_transition(rtmp, rusertp))
68450 + return -EFAULT;
68451 +
68452 + rusertp = rtmp->prev;
68453 +
68454 + error = alloc_and_copy_string(&rtmp->rolename, GR_SPROLE_LEN);
68455 + if (error)
68456 + return error;
68457 +
68458 + if (!rlast) {
68459 + rtmp->prev = NULL;
68460 + rolep->transitions = rtmp;
68461 + } else {
68462 + rlast->next = rtmp;
68463 + rtmp->prev = rlast;
68464 + }
68465 +
68466 + if (!rusertp)
68467 + rtmp->next = NULL;
68468 + }
68469 +
68470 + return 0;
68471 +}
68472 +
68473 +static __u32 count_user_objs(const struct acl_object_label __user *userp)
68474 +{
68475 + struct acl_object_label o_tmp;
68476 + __u32 num = 0;
68477 +
68478 + while (userp) {
68479 + if (copy_acl_object_label(&o_tmp, userp))
68480 + break;
68481 +
68482 + userp = o_tmp.prev;
68483 + num++;
68484 + }
68485 +
68486 + return num;
68487 +}
68488 +
68489 +static struct acl_subject_label *
68490 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied)
68491 +{
68492 + struct acl_subject_label *s_tmp = NULL, *s_tmp2;
68493 + __u32 num_objs;
68494 + struct acl_ip_label **i_tmp, *i_utmp2;
68495 + struct gr_hash_struct ghash;
68496 + struct subject_map *subjmap;
68497 + unsigned int i_num;
68498 + int err;
68499 +
68500 + if (already_copied != NULL)
68501 + *already_copied = 0;
68502 +
68503 + s_tmp = lookup_subject_map(userp);
68504 +
68505 + /* we've already copied this subject into the kernel, just return
68506 + the reference to it, and don't copy it over again
68507 + */
68508 + if (s_tmp) {
68509 + if (already_copied != NULL)
68510 + *already_copied = 1;
68511 + return(s_tmp);
68512 + }
68513 +
68514 + if ((s_tmp = (struct acl_subject_label *)
68515 + acl_alloc(sizeof (struct acl_subject_label))) == NULL)
68516 + return ERR_PTR(-ENOMEM);
68517 +
68518 + subjmap = (struct subject_map *)kmalloc(sizeof (struct subject_map), GFP_KERNEL);
68519 + if (subjmap == NULL)
68520 + return ERR_PTR(-ENOMEM);
68521 +
68522 + subjmap->user = userp;
68523 + subjmap->kernel = s_tmp;
68524 + insert_subj_map_entry(subjmap);
68525 +
68526 + if (copy_acl_subject_label(s_tmp, userp))
68527 + return ERR_PTR(-EFAULT);
68528 +
68529 + err = alloc_and_copy_string(&s_tmp->filename, PATH_MAX);
68530 + if (err)
68531 + return ERR_PTR(err);
68532 +
68533 + if (!strcmp(s_tmp->filename, "/"))
68534 + role->root_label = s_tmp;
68535 +
68536 + if (copy_gr_hash_struct(&ghash, s_tmp->hash))
68537 + return ERR_PTR(-EFAULT);
68538 +
68539 + /* copy user and group transition tables */
68540 +
68541 + if (s_tmp->user_trans_num) {
68542 + uid_t *uidlist;
68543 +
68544 + uidlist = (uid_t *)acl_alloc_num(s_tmp->user_trans_num, sizeof(uid_t));
68545 + if (uidlist == NULL)
68546 + return ERR_PTR(-ENOMEM);
68547 + if (copy_from_user(uidlist, s_tmp->user_transitions, s_tmp->user_trans_num * sizeof(uid_t)))
68548 + return ERR_PTR(-EFAULT);
68549 +
68550 + s_tmp->user_transitions = uidlist;
68551 + }
68552 +
68553 + if (s_tmp->group_trans_num) {
68554 + gid_t *gidlist;
68555 +
68556 + gidlist = (gid_t *)acl_alloc_num(s_tmp->group_trans_num, sizeof(gid_t));
68557 + if (gidlist == NULL)
68558 + return ERR_PTR(-ENOMEM);
68559 + if (copy_from_user(gidlist, s_tmp->group_transitions, s_tmp->group_trans_num * sizeof(gid_t)))
68560 + return ERR_PTR(-EFAULT);
68561 +
68562 + s_tmp->group_transitions = gidlist;
68563 + }
68564 +
68565 + /* set up object hash table */
68566 + num_objs = count_user_objs(ghash.first);
68567 +
68568 + s_tmp->obj_hash_size = num_objs;
68569 + s_tmp->obj_hash =
68570 + (struct acl_object_label **)
68571 + create_table(&(s_tmp->obj_hash_size), sizeof(void *));
68572 +
68573 + if (!s_tmp->obj_hash)
68574 + return ERR_PTR(-ENOMEM);
68575 +
68576 + memset(s_tmp->obj_hash, 0,
68577 + s_tmp->obj_hash_size *
68578 + sizeof (struct acl_object_label *));
68579 +
68580 + /* add in objects */
68581 + err = copy_user_objs(ghash.first, s_tmp, role);
68582 +
68583 + if (err)
68584 + return ERR_PTR(err);
68585 +
68586 + /* set pointer for parent subject */
68587 + if (s_tmp->parent_subject) {
68588 + s_tmp2 = do_copy_user_subj(s_tmp->parent_subject, role, NULL);
68589 +
68590 + if (IS_ERR(s_tmp2))
68591 + return s_tmp2;
68592 +
68593 + s_tmp->parent_subject = s_tmp2;
68594 + }
68595 +
68596 + /* add in ip acls */
68597 +
68598 + if (!s_tmp->ip_num) {
68599 + s_tmp->ips = NULL;
68600 + goto insert;
68601 + }
68602 +
68603 + i_tmp =
68604 + (struct acl_ip_label **) acl_alloc_num(s_tmp->ip_num,
68605 + sizeof (struct acl_ip_label *));
68606 +
68607 + if (!i_tmp)
68608 + return ERR_PTR(-ENOMEM);
68609 +
68610 + for (i_num = 0; i_num < s_tmp->ip_num; i_num++) {
68611 + *(i_tmp + i_num) =
68612 + (struct acl_ip_label *)
68613 + acl_alloc(sizeof (struct acl_ip_label));
68614 + if (!*(i_tmp + i_num))
68615 + return ERR_PTR(-ENOMEM);
68616 +
68617 + if (copy_pointer_from_array(&i_utmp2, i_num, s_tmp->ips))
68618 + return ERR_PTR(-EFAULT);
68619 +
68620 + if (copy_acl_ip_label(*(i_tmp + i_num), i_utmp2))
68621 + return ERR_PTR(-EFAULT);
68622 +
68623 + if ((*(i_tmp + i_num))->iface == NULL)
68624 + continue;
68625 +
68626 + err = alloc_and_copy_string(&(*(i_tmp + i_num))->iface, IFNAMSIZ);
68627 + if (err)
68628 + return ERR_PTR(err);
68629 + }
68630 +
68631 + s_tmp->ips = i_tmp;
68632 +
68633 +insert:
68634 + if (!insert_name_entry(s_tmp->filename, s_tmp->inode,
68635 + s_tmp->device, (s_tmp->mode & GR_DELETED) ? 1 : 0))
68636 + return ERR_PTR(-ENOMEM);
68637 +
68638 + return s_tmp;
68639 +}
68640 +
68641 +static int
68642 +copy_user_subjs(struct acl_subject_label *userp, struct acl_role_label *role)
68643 +{
68644 + struct acl_subject_label s_pre;
68645 + struct acl_subject_label * ret;
68646 + int err;
68647 +
68648 + while (userp) {
68649 + if (copy_acl_subject_label(&s_pre, userp))
68650 + return -EFAULT;
68651 +
68652 + ret = do_copy_user_subj(userp, role, NULL);
68653 +
68654 + err = PTR_ERR(ret);
68655 + if (IS_ERR(ret))
68656 + return err;
68657 +
68658 + insert_acl_subj_label(ret, role);
68659 +
68660 + userp = s_pre.prev;
68661 + }
68662 +
68663 + return 0;
68664 +}
68665 +
68666 +static int
68667 +copy_user_acl(struct gr_arg *arg)
68668 +{
68669 + struct acl_role_label *r_tmp = NULL, **r_utmp, *r_utmp2;
68670 + struct acl_subject_label *subj_list;
68671 + struct sprole_pw *sptmp;
68672 + struct gr_hash_struct *ghash;
68673 + uid_t *domainlist;
68674 + unsigned int r_num;
68675 + int err = 0;
68676 + __u16 i;
68677 + __u32 num_subjs;
68678 +
68679 + /* we need a default and kernel role */
68680 + if (arg->role_db.num_roles < 2)
68681 + return -EINVAL;
68682 +
68683 + /* copy special role authentication info from userspace */
68684 +
68685 + polstate->num_sprole_pws = arg->num_sprole_pws;
68686 + polstate->acl_special_roles = (struct sprole_pw **) acl_alloc_num(polstate->num_sprole_pws, sizeof(struct sprole_pw *));
68687 +
68688 + if (!polstate->acl_special_roles && polstate->num_sprole_pws)
68689 + return -ENOMEM;
68690 +
68691 + for (i = 0; i < polstate->num_sprole_pws; i++) {
68692 + sptmp = (struct sprole_pw *) acl_alloc(sizeof(struct sprole_pw));
68693 + if (!sptmp)
68694 + return -ENOMEM;
68695 + if (copy_sprole_pw(sptmp, i, arg->sprole_pws))
68696 + return -EFAULT;
68697 +
68698 + err = alloc_and_copy_string((char **)&sptmp->rolename, GR_SPROLE_LEN);
68699 + if (err)
68700 + return err;
68701 +
68702 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
68703 + printk(KERN_ALERT "Copying special role %s\n", sptmp->rolename);
68704 +#endif
68705 +
68706 + polstate->acl_special_roles[i] = sptmp;
68707 + }
68708 +
68709 + r_utmp = (struct acl_role_label **) arg->role_db.r_table;
68710 +
68711 + for (r_num = 0; r_num < arg->role_db.num_roles; r_num++) {
68712 + r_tmp = acl_alloc(sizeof (struct acl_role_label));
68713 +
68714 + if (!r_tmp)
68715 + return -ENOMEM;
68716 +
68717 + if (copy_pointer_from_array(&r_utmp2, r_num, r_utmp))
68718 + return -EFAULT;
68719 +
68720 + if (copy_acl_role_label(r_tmp, r_utmp2))
68721 + return -EFAULT;
68722 +
68723 + err = alloc_and_copy_string(&r_tmp->rolename, GR_SPROLE_LEN);
68724 + if (err)
68725 + return err;
68726 +
68727 + if (!strcmp(r_tmp->rolename, "default")
68728 + && (r_tmp->roletype & GR_ROLE_DEFAULT)) {
68729 + polstate->default_role = r_tmp;
68730 + } else if (!strcmp(r_tmp->rolename, ":::kernel:::")) {
68731 + polstate->kernel_role = r_tmp;
68732 + }
68733 +
68734 + if ((ghash = (struct gr_hash_struct *) acl_alloc(sizeof(struct gr_hash_struct))) == NULL)
68735 + return -ENOMEM;
68736 +
68737 + if (copy_gr_hash_struct(ghash, r_tmp->hash))
68738 + return -EFAULT;
68739 +
68740 + r_tmp->hash = ghash;
68741 +
68742 + num_subjs = count_user_subjs(r_tmp->hash->first);
68743 +
68744 + r_tmp->subj_hash_size = num_subjs;
68745 + r_tmp->subj_hash =
68746 + (struct acl_subject_label **)
68747 + create_table(&(r_tmp->subj_hash_size), sizeof(void *));
68748 +
68749 + if (!r_tmp->subj_hash)
68750 + return -ENOMEM;
68751 +
68752 + err = copy_user_allowedips(r_tmp);
68753 + if (err)
68754 + return err;
68755 +
68756 + /* copy domain info */
68757 + if (r_tmp->domain_children != NULL) {
68758 + domainlist = acl_alloc_num(r_tmp->domain_child_num, sizeof(uid_t));
68759 + if (domainlist == NULL)
68760 + return -ENOMEM;
68761 +
68762 + if (copy_from_user(domainlist, r_tmp->domain_children, r_tmp->domain_child_num * sizeof(uid_t)))
68763 + return -EFAULT;
68764 +
68765 + r_tmp->domain_children = domainlist;
68766 + }
68767 +
68768 + err = copy_user_transitions(r_tmp);
68769 + if (err)
68770 + return err;
68771 +
68772 + memset(r_tmp->subj_hash, 0,
68773 + r_tmp->subj_hash_size *
68774 + sizeof (struct acl_subject_label *));
68775 +
68776 + /* acquire the list of subjects, then NULL out
68777 + the list prior to parsing the subjects for this role,
68778 + as during this parsing the list is replaced with a list
68779 + of *nested* subjects for the role
68780 + */
68781 + subj_list = r_tmp->hash->first;
68782 +
68783 + /* set nested subject list to null */
68784 + r_tmp->hash->first = NULL;
68785 +
68786 + err = copy_user_subjs(subj_list, r_tmp);
68787 +
68788 + if (err)
68789 + return err;
68790 +
68791 + insert_acl_role_label(r_tmp);
68792 + }
68793 +
68794 + if (polstate->default_role == NULL || polstate->kernel_role == NULL)
68795 + return -EINVAL;
68796 +
68797 + return err;
68798 +}
68799 +
68800 +static int gracl_reload_apply_policies(void *reload)
68801 +{
68802 + struct gr_reload_state *reload_state = (struct gr_reload_state *)reload;
68803 + struct task_struct *task, *task2;
68804 + struct acl_role_label *role, *rtmp;
68805 + struct acl_subject_label *subj;
68806 + const struct cred *cred;
68807 + int role_applied;
68808 + int ret = 0;
68809 +
68810 + memcpy(&reload_state->oldpolicy, reload_state->oldpolicy_ptr, sizeof(struct gr_policy_state));
68811 + memcpy(&reload_state->oldalloc, reload_state->oldalloc_ptr, sizeof(struct gr_alloc_state));
68812 +
68813 + /* first make sure we'll be able to apply the new policy cleanly */
68814 + do_each_thread(task2, task) {
68815 + if (task->exec_file == NULL)
68816 + continue;
68817 + role_applied = 0;
68818 + if (!reload_state->oldmode && task->role->roletype & GR_ROLE_SPECIAL) {
68819 + /* preserve special roles */
68820 + FOR_EACH_ROLE_START(role)
68821 + if ((role->roletype & GR_ROLE_SPECIAL) && !strcmp(task->role->rolename, role->rolename)) {
68822 + rtmp = task->role;
68823 + task->role = role;
68824 + role_applied = 1;
68825 + break;
68826 + }
68827 + FOR_EACH_ROLE_END(role)
68828 + }
68829 + if (!role_applied) {
68830 + cred = __task_cred(task);
68831 + rtmp = task->role;
68832 + task->role = __lookup_acl_role_label(polstate, task, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid));
68833 + }
68834 + /* this handles non-nested inherited subjects, nested subjects will still
68835 + be dropped currently */
68836 + subj = __gr_get_subject_for_task(polstate, task, task->acl->filename);
68837 + task->tmpacl = __gr_get_subject_for_task(polstate, task, NULL);
68838 + /* change the role back so that we've made no modifications to the policy */
68839 + task->role = rtmp;
68840 +
68841 + if (subj == NULL || task->tmpacl == NULL) {
68842 + ret = -EINVAL;
68843 + goto out;
68844 + }
68845 + } while_each_thread(task2, task);
68846 +
68847 + /* now actually apply the policy */
68848 +
68849 + do_each_thread(task2, task) {
68850 + if (task->exec_file) {
68851 + role_applied = 0;
68852 + if (!reload_state->oldmode && task->role->roletype & GR_ROLE_SPECIAL) {
68853 + /* preserve special roles */
68854 + FOR_EACH_ROLE_START(role)
68855 + if ((role->roletype & GR_ROLE_SPECIAL) && !strcmp(task->role->rolename, role->rolename)) {
68856 + task->role = role;
68857 + role_applied = 1;
68858 + break;
68859 + }
68860 + FOR_EACH_ROLE_END(role)
68861 + }
68862 + if (!role_applied) {
68863 + cred = __task_cred(task);
68864 + task->role = __lookup_acl_role_label(polstate, task, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid));
68865 + }
68866 + /* this handles non-nested inherited subjects, nested subjects will still
68867 + be dropped currently */
68868 + if (!reload_state->oldmode && task->inherited)
68869 + subj = __gr_get_subject_for_task(polstate, task, task->acl->filename);
68870 + else {
68871 + /* looked up and tagged to the task previously */
68872 + subj = task->tmpacl;
68873 + }
68874 + /* subj will be non-null */
68875 + __gr_apply_subject_to_task(polstate, task, subj);
68876 + if (reload_state->oldmode) {
68877 + task->acl_role_id = 0;
68878 + task->acl_sp_role = 0;
68879 + task->inherited = 0;
68880 + }
68881 + } else {
68882 + // it's a kernel process
68883 + task->role = polstate->kernel_role;
68884 + task->acl = polstate->kernel_role->root_label;
68885 +#ifdef CONFIG_GRKERNSEC_ACL_HIDEKERN
68886 + task->acl->mode &= ~GR_PROCFIND;
68887 +#endif
68888 + }
68889 + } while_each_thread(task2, task);
68890 +
68891 + memcpy(reload_state->oldpolicy_ptr, &reload_state->newpolicy, sizeof(struct gr_policy_state));
68892 + memcpy(reload_state->oldalloc_ptr, &reload_state->newalloc, sizeof(struct gr_alloc_state));
68893 +
68894 +out:
68895 +
68896 + return ret;
68897 +}
68898 +
68899 +static int gracl_reload(struct gr_arg *args, unsigned char oldmode)
68900 +{
68901 + struct gr_reload_state new_reload_state = { };
68902 + int err;
68903 +
68904 + new_reload_state.oldpolicy_ptr = polstate;
68905 + new_reload_state.oldalloc_ptr = current_alloc_state;
68906 + new_reload_state.oldmode = oldmode;
68907 +
68908 + current_alloc_state = &new_reload_state.newalloc;
68909 + polstate = &new_reload_state.newpolicy;
68910 +
68911 + /* everything relevant is now saved off, copy in the new policy */
68912 + if (init_variables(args, true)) {
68913 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_INITF_ACL_MSG, GR_VERSION);
68914 + err = -ENOMEM;
68915 + goto error;
68916 + }
68917 +
68918 + err = copy_user_acl(args);
68919 + free_init_variables();
68920 + if (err)
68921 + goto error;
68922 + /* the new policy is copied in, with the old policy available via saved_state
68923 + first go through applying roles, making sure to preserve special roles
68924 + then apply new subjects, making sure to preserve inherited and nested subjects,
68925 + though currently only inherited subjects will be preserved
68926 + */
68927 + err = stop_machine(gracl_reload_apply_policies, &new_reload_state, NULL);
68928 + if (err)
68929 + goto error;
68930 +
68931 + /* we've now applied the new policy, so restore the old policy state to free it */
68932 + polstate = &new_reload_state.oldpolicy;
68933 + current_alloc_state = &new_reload_state.oldalloc;
68934 + free_variables(true);
68935 +
68936 + /* oldpolicy/oldalloc_ptr point to the new policy/alloc states as they were copied
68937 + to running_polstate/current_alloc_state inside stop_machine
68938 + */
68939 + err = 0;
68940 + goto out;
68941 +error:
68942 + /* on error of loading the new policy, we'll just keep the previous
68943 + policy set around
68944 + */
68945 + free_variables(true);
68946 +
68947 + /* doesn't affect runtime, but maintains consistent state */
68948 +out:
68949 + polstate = new_reload_state.oldpolicy_ptr;
68950 + current_alloc_state = new_reload_state.oldalloc_ptr;
68951 +
68952 + return err;
68953 +}
68954 +
68955 +static int
68956 +gracl_init(struct gr_arg *args)
68957 +{
68958 + int error = 0;
68959 +
68960 + memcpy(&gr_system_salt, args->salt, sizeof(gr_system_salt));
68961 + memcpy(&gr_system_sum, args->sum, sizeof(gr_system_sum));
68962 +
68963 + if (init_variables(args, false)) {
68964 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_INITF_ACL_MSG, GR_VERSION);
68965 + error = -ENOMEM;
68966 + goto out;
68967 + }
68968 +
68969 + error = copy_user_acl(args);
68970 + free_init_variables();
68971 + if (error)
68972 + goto out;
68973 +
68974 + error = gr_set_acls(0);
68975 + if (error)
68976 + goto out;
68977 +
68978 + gr_enable_rbac_system();
68979 +
68980 + return 0;
68981 +
68982 +out:
68983 + free_variables(false);
68984 + return error;
68985 +}
68986 +
68987 +static int
68988 +lookup_special_role_auth(__u16 mode, const char *rolename, unsigned char **salt,
68989 + unsigned char **sum)
68990 +{
68991 + struct acl_role_label *r;
68992 + struct role_allowed_ip *ipp;
68993 + struct role_transition *trans;
68994 + unsigned int i;
68995 + int found = 0;
68996 + u32 curr_ip = current->signal->curr_ip;
68997 +
68998 + current->signal->saved_ip = curr_ip;
68999 +
69000 + /* check transition table */
69001 +
69002 + for (trans = current->role->transitions; trans; trans = trans->next) {
69003 + if (!strcmp(rolename, trans->rolename)) {
69004 + found = 1;
69005 + break;
69006 + }
69007 + }
69008 +
69009 + if (!found)
69010 + return 0;
69011 +
69012 + /* handle special roles that do not require authentication
69013 + and check ip */
69014 +
69015 + FOR_EACH_ROLE_START(r)
69016 + if (!strcmp(rolename, r->rolename) &&
69017 + (r->roletype & GR_ROLE_SPECIAL)) {
69018 + found = 0;
69019 + if (r->allowed_ips != NULL) {
69020 + for (ipp = r->allowed_ips; ipp; ipp = ipp->next) {
69021 + if ((ntohl(curr_ip) & ipp->netmask) ==
69022 + (ntohl(ipp->addr) & ipp->netmask))
69023 + found = 1;
69024 + }
69025 + } else
69026 + found = 2;
69027 + if (!found)
69028 + return 0;
69029 +
69030 + if (((mode == GR_SPROLE) && (r->roletype & GR_ROLE_NOPW)) ||
69031 + ((mode == GR_SPROLEPAM) && (r->roletype & GR_ROLE_PAM))) {
69032 + *salt = NULL;
69033 + *sum = NULL;
69034 + return 1;
69035 + }
69036 + }
69037 + FOR_EACH_ROLE_END(r)
69038 +
69039 + for (i = 0; i < polstate->num_sprole_pws; i++) {
69040 + if (!strcmp(rolename, polstate->acl_special_roles[i]->rolename)) {
69041 + *salt = polstate->acl_special_roles[i]->salt;
69042 + *sum = polstate->acl_special_roles[i]->sum;
69043 + return 1;
69044 + }
69045 + }
69046 +
69047 + return 0;
69048 +}
69049 +
69050 +int gr_check_secure_terminal(struct task_struct *task)
69051 +{
69052 + struct task_struct *p, *p2, *p3;
69053 + struct files_struct *files;
69054 + struct fdtable *fdt;
69055 + struct file *our_file = NULL, *file;
69056 + int i;
69057 +
69058 + if (task->signal->tty == NULL)
69059 + return 1;
69060 +
69061 + files = get_files_struct(task);
69062 + if (files != NULL) {
69063 + rcu_read_lock();
69064 + fdt = files_fdtable(files);
69065 + for (i=0; i < fdt->max_fds; i++) {
69066 + file = fcheck_files(files, i);
69067 + if (file && (our_file == NULL) && (file->private_data == task->signal->tty)) {
69068 + get_file(file);
69069 + our_file = file;
69070 + }
69071 + }
69072 + rcu_read_unlock();
69073 + put_files_struct(files);
69074 + }
69075 +
69076 + if (our_file == NULL)
69077 + return 1;
69078 +
69079 + read_lock(&tasklist_lock);
69080 + do_each_thread(p2, p) {
69081 + files = get_files_struct(p);
69082 + if (files == NULL ||
69083 + (p->signal && p->signal->tty == task->signal->tty)) {
69084 + if (files != NULL)
69085 + put_files_struct(files);
69086 + continue;
69087 + }
69088 + rcu_read_lock();
69089 + fdt = files_fdtable(files);
69090 + for (i=0; i < fdt->max_fds; i++) {
69091 + file = fcheck_files(files, i);
69092 + if (file && S_ISCHR(file->f_path.dentry->d_inode->i_mode) &&
69093 + file->f_path.dentry->d_inode->i_rdev == our_file->f_path.dentry->d_inode->i_rdev) {
69094 + p3 = task;
69095 + while (task_pid_nr(p3) > 0) {
69096 + if (p3 == p)
69097 + break;
69098 + p3 = p3->real_parent;
69099 + }
69100 + if (p3 == p)
69101 + break;
69102 + gr_log_ttysniff(GR_DONT_AUDIT_GOOD, GR_TTYSNIFF_ACL_MSG, p);
69103 + gr_handle_alertkill(p);
69104 + rcu_read_unlock();
69105 + put_files_struct(files);
69106 + read_unlock(&tasklist_lock);
69107 + fput(our_file);
69108 + return 0;
69109 + }
69110 + }
69111 + rcu_read_unlock();
69112 + put_files_struct(files);
69113 + } while_each_thread(p2, p);
69114 + read_unlock(&tasklist_lock);
69115 +
69116 + fput(our_file);
69117 + return 1;
69118 +}
69119 +
69120 +ssize_t
69121 +write_grsec_handler(struct file *file, const char __user * buf, size_t count, loff_t *ppos)
69122 +{
69123 + struct gr_arg_wrapper uwrap;
69124 + unsigned char *sprole_salt = NULL;
69125 + unsigned char *sprole_sum = NULL;
69126 + int error = 0;
69127 + int error2 = 0;
69128 + size_t req_count = 0;
69129 + unsigned char oldmode = 0;
69130 +
69131 + mutex_lock(&gr_dev_mutex);
69132 +
69133 + if (gr_acl_is_enabled() && !(current->acl->mode & GR_KERNELAUTH)) {
69134 + error = -EPERM;
69135 + goto out;
69136 + }
69137 +
69138 +#ifdef CONFIG_COMPAT
69139 + pax_open_kernel();
69140 + if (is_compat_task()) {
69141 + copy_gr_arg_wrapper = &copy_gr_arg_wrapper_compat;
69142 + copy_gr_arg = &copy_gr_arg_compat;
69143 + copy_acl_object_label = &copy_acl_object_label_compat;
69144 + copy_acl_subject_label = &copy_acl_subject_label_compat;
69145 + copy_acl_role_label = &copy_acl_role_label_compat;
69146 + copy_acl_ip_label = &copy_acl_ip_label_compat;
69147 + copy_role_allowed_ip = &copy_role_allowed_ip_compat;
69148 + copy_role_transition = &copy_role_transition_compat;
69149 + copy_sprole_pw = &copy_sprole_pw_compat;
69150 + copy_gr_hash_struct = &copy_gr_hash_struct_compat;
69151 + copy_pointer_from_array = &copy_pointer_from_array_compat;
69152 + get_gr_arg_wrapper_size = &get_gr_arg_wrapper_size_compat;
69153 + } else {
69154 + copy_gr_arg_wrapper = &copy_gr_arg_wrapper_normal;
69155 + copy_gr_arg = &copy_gr_arg_normal;
69156 + copy_acl_object_label = &copy_acl_object_label_normal;
69157 + copy_acl_subject_label = &copy_acl_subject_label_normal;
69158 + copy_acl_role_label = &copy_acl_role_label_normal;
69159 + copy_acl_ip_label = &copy_acl_ip_label_normal;
69160 + copy_role_allowed_ip = &copy_role_allowed_ip_normal;
69161 + copy_role_transition = &copy_role_transition_normal;
69162 + copy_sprole_pw = &copy_sprole_pw_normal;
69163 + copy_gr_hash_struct = &copy_gr_hash_struct_normal;
69164 + copy_pointer_from_array = &copy_pointer_from_array_normal;
69165 + get_gr_arg_wrapper_size = &get_gr_arg_wrapper_size_normal;
69166 + }
69167 + pax_close_kernel();
69168 +#endif
69169 +
69170 + req_count = get_gr_arg_wrapper_size();
69171 +
69172 + if (count != req_count) {
69173 + gr_log_int_int(GR_DONT_AUDIT_GOOD, GR_DEV_ACL_MSG, (int)count, (int)req_count);
69174 + error = -EINVAL;
69175 + goto out;
69176 + }
69177 +
69178 +
69179 + if (gr_auth_expires && time_after_eq(get_seconds(), gr_auth_expires)) {
69180 + gr_auth_expires = 0;
69181 + gr_auth_attempts = 0;
69182 + }
69183 +
69184 + error = copy_gr_arg_wrapper(buf, &uwrap);
69185 + if (error)
69186 + goto out;
69187 +
69188 + error = copy_gr_arg(uwrap.arg, &gr_usermode);
69189 + if (error)
69190 + goto out;
69191 +
69192 + if (gr_usermode.mode != GR_SPROLE && gr_usermode.mode != GR_SPROLEPAM &&
69193 + gr_auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
69194 + time_after(gr_auth_expires, get_seconds())) {
69195 + error = -EBUSY;
69196 + goto out;
69197 + }
69198 +
69199 + /* if non-root trying to do anything other than use a special role,
69200 + do not attempt authentication, do not count towards authentication
69201 + locking
69202 + */
69203 +
69204 + if (gr_usermode.mode != GR_SPROLE && gr_usermode.mode != GR_STATUS &&
69205 + gr_usermode.mode != GR_UNSPROLE && gr_usermode.mode != GR_SPROLEPAM &&
69206 + gr_is_global_nonroot(current_uid())) {
69207 + error = -EPERM;
69208 + goto out;
69209 + }
69210 +
69211 + /* ensure pw and special role name are null terminated */
69212 +
69213 + gr_usermode.pw[GR_PW_LEN - 1] = '\0';
69214 + gr_usermode.sp_role[GR_SPROLE_LEN - 1] = '\0';
69215 +
69216 + /* Okay.
69217 + * We have our enough of the argument structure..(we have yet
69218 + * to copy_from_user the tables themselves) . Copy the tables
69219 + * only if we need them, i.e. for loading operations. */
69220 +
69221 + switch (gr_usermode.mode) {
69222 + case GR_STATUS:
69223 + if (gr_acl_is_enabled()) {
69224 + error = 1;
69225 + if (!gr_check_secure_terminal(current))
69226 + error = 3;
69227 + } else
69228 + error = 2;
69229 + goto out;
69230 + case GR_SHUTDOWN:
69231 + if (gr_acl_is_enabled() && !(chkpw(&gr_usermode, (unsigned char *)&gr_system_salt, (unsigned char *)&gr_system_sum))) {
69232 + stop_machine(gr_rbac_disable, NULL, NULL);
69233 + free_variables(false);
69234 + memset(&gr_usermode, 0, sizeof(gr_usermode));
69235 + memset(&gr_system_salt, 0, sizeof(gr_system_salt));
69236 + memset(&gr_system_sum, 0, sizeof(gr_system_sum));
69237 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTS_ACL_MSG);
69238 + } else if (gr_acl_is_enabled()) {
69239 + gr_log_noargs(GR_DONT_AUDIT, GR_SHUTF_ACL_MSG);
69240 + error = -EPERM;
69241 + } else {
69242 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTI_ACL_MSG);
69243 + error = -EAGAIN;
69244 + }
69245 + break;
69246 + case GR_ENABLE:
69247 + if (!gr_acl_is_enabled() && !(error2 = gracl_init(&gr_usermode)))
69248 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_ENABLE_ACL_MSG, GR_VERSION);
69249 + else {
69250 + if (gr_acl_is_enabled())
69251 + error = -EAGAIN;
69252 + else
69253 + error = error2;
69254 + gr_log_str(GR_DONT_AUDIT, GR_ENABLEF_ACL_MSG, GR_VERSION);
69255 + }
69256 + break;
69257 + case GR_OLDRELOAD:
69258 + oldmode = 1;
69259 + case GR_RELOAD:
69260 + if (!gr_acl_is_enabled()) {
69261 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOADI_ACL_MSG, GR_VERSION);
69262 + error = -EAGAIN;
69263 + } else if (!(chkpw(&gr_usermode, (unsigned char *)&gr_system_salt, (unsigned char *)&gr_system_sum))) {
69264 + error2 = gracl_reload(&gr_usermode, oldmode);
69265 + if (!error2)
69266 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOAD_ACL_MSG, GR_VERSION);
69267 + else {
69268 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
69269 + error = error2;
69270 + }
69271 + } else {
69272 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
69273 + error = -EPERM;
69274 + }
69275 + break;
69276 + case GR_SEGVMOD:
69277 + if (unlikely(!gr_acl_is_enabled())) {
69278 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODI_ACL_MSG);
69279 + error = -EAGAIN;
69280 + break;
69281 + }
69282 +
69283 + if (!(chkpw(&gr_usermode, (unsigned char *)&gr_system_salt, (unsigned char *)&gr_system_sum))) {
69284 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODS_ACL_MSG);
69285 + if (gr_usermode.segv_device && gr_usermode.segv_inode) {
69286 + struct acl_subject_label *segvacl;
69287 + segvacl =
69288 + lookup_acl_subj_label(gr_usermode.segv_inode,
69289 + gr_usermode.segv_device,
69290 + current->role);
69291 + if (segvacl) {
69292 + segvacl->crashes = 0;
69293 + segvacl->expires = 0;
69294 + }
69295 + } else if (gr_find_uid(gr_usermode.segv_uid) >= 0) {
69296 + gr_remove_uid(gr_usermode.segv_uid);
69297 + }
69298 + } else {
69299 + gr_log_noargs(GR_DONT_AUDIT, GR_SEGVMODF_ACL_MSG);
69300 + error = -EPERM;
69301 + }
69302 + break;
69303 + case GR_SPROLE:
69304 + case GR_SPROLEPAM:
69305 + if (unlikely(!gr_acl_is_enabled())) {
69306 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SPROLEI_ACL_MSG);
69307 + error = -EAGAIN;
69308 + break;
69309 + }
69310 +
69311 + if (current->role->expires && time_after_eq(get_seconds(), current->role->expires)) {
69312 + current->role->expires = 0;
69313 + current->role->auth_attempts = 0;
69314 + }
69315 +
69316 + if (current->role->auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
69317 + time_after(current->role->expires, get_seconds())) {
69318 + error = -EBUSY;
69319 + goto out;
69320 + }
69321 +
69322 + if (lookup_special_role_auth
69323 + (gr_usermode.mode, gr_usermode.sp_role, &sprole_salt, &sprole_sum)
69324 + && ((!sprole_salt && !sprole_sum)
69325 + || !(chkpw(&gr_usermode, sprole_salt, sprole_sum)))) {
69326 + char *p = "";
69327 + assign_special_role(gr_usermode.sp_role);
69328 + read_lock(&tasklist_lock);
69329 + if (current->real_parent)
69330 + p = current->real_parent->role->rolename;
69331 + read_unlock(&tasklist_lock);
69332 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLES_ACL_MSG,
69333 + p, acl_sp_role_value);
69334 + } else {
69335 + gr_log_str(GR_DONT_AUDIT, GR_SPROLEF_ACL_MSG, gr_usermode.sp_role);
69336 + error = -EPERM;
69337 + if(!(current->role->auth_attempts++))
69338 + current->role->expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
69339 +
69340 + goto out;
69341 + }
69342 + break;
69343 + case GR_UNSPROLE:
69344 + if (unlikely(!gr_acl_is_enabled())) {
69345 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_UNSPROLEI_ACL_MSG);
69346 + error = -EAGAIN;
69347 + break;
69348 + }
69349 +
69350 + if (current->role->roletype & GR_ROLE_SPECIAL) {
69351 + char *p = "";
69352 + int i = 0;
69353 +
69354 + read_lock(&tasklist_lock);
69355 + if (current->real_parent) {
69356 + p = current->real_parent->role->rolename;
69357 + i = current->real_parent->acl_role_id;
69358 + }
69359 + read_unlock(&tasklist_lock);
69360 +
69361 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_UNSPROLES_ACL_MSG, p, i);
69362 + gr_set_acls(1);
69363 + } else {
69364 + error = -EPERM;
69365 + goto out;
69366 + }
69367 + break;
69368 + default:
69369 + gr_log_int(GR_DONT_AUDIT, GR_INVMODE_ACL_MSG, gr_usermode.mode);
69370 + error = -EINVAL;
69371 + break;
69372 + }
69373 +
69374 + if (error != -EPERM)
69375 + goto out;
69376 +
69377 + if(!(gr_auth_attempts++))
69378 + gr_auth_expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
69379 +
69380 + out:
69381 + mutex_unlock(&gr_dev_mutex);
69382 +
69383 + if (!error)
69384 + error = req_count;
69385 +
69386 + return error;
69387 +}
69388 +
69389 +int
69390 +gr_set_acls(const int type)
69391 +{
69392 + struct task_struct *task, *task2;
69393 + struct acl_role_label *role = current->role;
69394 + struct acl_subject_label *subj;
69395 + __u16 acl_role_id = current->acl_role_id;
69396 + const struct cred *cred;
69397 + int ret;
69398 +
69399 + rcu_read_lock();
69400 + read_lock(&tasklist_lock);
69401 + read_lock(&grsec_exec_file_lock);
69402 + do_each_thread(task2, task) {
69403 + /* check to see if we're called from the exit handler,
69404 + if so, only replace ACLs that have inherited the admin
69405 + ACL */
69406 +
69407 + if (type && (task->role != role ||
69408 + task->acl_role_id != acl_role_id))
69409 + continue;
69410 +
69411 + task->acl_role_id = 0;
69412 + task->acl_sp_role = 0;
69413 + task->inherited = 0;
69414 +
69415 + if (task->exec_file) {
69416 + cred = __task_cred(task);
69417 + task->role = __lookup_acl_role_label(polstate, task, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid));
69418 + subj = __gr_get_subject_for_task(polstate, task, NULL);
69419 + if (subj == NULL) {
69420 + ret = -EINVAL;
69421 + read_unlock(&grsec_exec_file_lock);
69422 + read_unlock(&tasklist_lock);
69423 + rcu_read_unlock();
69424 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_DEFACL_MSG, task->comm, task_pid_nr(task));
69425 + return ret;
69426 + }
69427 + __gr_apply_subject_to_task(polstate, task, subj);
69428 + } else {
69429 + // it's a kernel process
69430 + task->role = polstate->kernel_role;
69431 + task->acl = polstate->kernel_role->root_label;
69432 +#ifdef CONFIG_GRKERNSEC_ACL_HIDEKERN
69433 + task->acl->mode &= ~GR_PROCFIND;
69434 +#endif
69435 + }
69436 + } while_each_thread(task2, task);
69437 + read_unlock(&grsec_exec_file_lock);
69438 + read_unlock(&tasklist_lock);
69439 + rcu_read_unlock();
69440 +
69441 + return 0;
69442 +}
69443 diff --git a/grsecurity/gracl_res.c b/grsecurity/gracl_res.c
69444 new file mode 100644
69445 index 0000000..39645c9
69446 --- /dev/null
69447 +++ b/grsecurity/gracl_res.c
69448 @@ -0,0 +1,68 @@
69449 +#include <linux/kernel.h>
69450 +#include <linux/sched.h>
69451 +#include <linux/gracl.h>
69452 +#include <linux/grinternal.h>
69453 +
69454 +static const char *restab_log[] = {
69455 + [RLIMIT_CPU] = "RLIMIT_CPU",
69456 + [RLIMIT_FSIZE] = "RLIMIT_FSIZE",
69457 + [RLIMIT_DATA] = "RLIMIT_DATA",
69458 + [RLIMIT_STACK] = "RLIMIT_STACK",
69459 + [RLIMIT_CORE] = "RLIMIT_CORE",
69460 + [RLIMIT_RSS] = "RLIMIT_RSS",
69461 + [RLIMIT_NPROC] = "RLIMIT_NPROC",
69462 + [RLIMIT_NOFILE] = "RLIMIT_NOFILE",
69463 + [RLIMIT_MEMLOCK] = "RLIMIT_MEMLOCK",
69464 + [RLIMIT_AS] = "RLIMIT_AS",
69465 + [RLIMIT_LOCKS] = "RLIMIT_LOCKS",
69466 + [RLIMIT_SIGPENDING] = "RLIMIT_SIGPENDING",
69467 + [RLIMIT_MSGQUEUE] = "RLIMIT_MSGQUEUE",
69468 + [RLIMIT_NICE] = "RLIMIT_NICE",
69469 + [RLIMIT_RTPRIO] = "RLIMIT_RTPRIO",
69470 + [RLIMIT_RTTIME] = "RLIMIT_RTTIME",
69471 + [GR_CRASH_RES] = "RLIMIT_CRASH"
69472 +};
69473 +
69474 +void
69475 +gr_log_resource(const struct task_struct *task,
69476 + const int res, const unsigned long wanted, const int gt)
69477 +{
69478 + const struct cred *cred;
69479 + unsigned long rlim;
69480 +
69481 + if (!gr_acl_is_enabled() && !grsec_resource_logging)
69482 + return;
69483 +
69484 + // not yet supported resource
69485 + if (unlikely(!restab_log[res]))
69486 + return;
69487 +
69488 + if (res == RLIMIT_CPU || res == RLIMIT_RTTIME)
69489 + rlim = task_rlimit_max(task, res);
69490 + else
69491 + rlim = task_rlimit(task, res);
69492 +
69493 + if (likely((rlim == RLIM_INFINITY) || (gt && wanted <= rlim) || (!gt && wanted < rlim)))
69494 + return;
69495 +
69496 + rcu_read_lock();
69497 + cred = __task_cred(task);
69498 +
69499 + if (res == RLIMIT_NPROC &&
69500 + (cap_raised(cred->cap_effective, CAP_SYS_ADMIN) ||
69501 + cap_raised(cred->cap_effective, CAP_SYS_RESOURCE)))
69502 + goto out_rcu_unlock;
69503 + else if (res == RLIMIT_MEMLOCK &&
69504 + cap_raised(cred->cap_effective, CAP_IPC_LOCK))
69505 + goto out_rcu_unlock;
69506 + else if (res == RLIMIT_NICE && cap_raised(cred->cap_effective, CAP_SYS_NICE))
69507 + goto out_rcu_unlock;
69508 + rcu_read_unlock();
69509 +
69510 + gr_log_res_ulong2_str(GR_DONT_AUDIT, GR_RESOURCE_MSG, task, wanted, restab_log[res], rlim);
69511 +
69512 + return;
69513 +out_rcu_unlock:
69514 + rcu_read_unlock();
69515 + return;
69516 +}
69517 diff --git a/grsecurity/gracl_segv.c b/grsecurity/gracl_segv.c
69518 new file mode 100644
69519 index 0000000..2040e61
69520 --- /dev/null
69521 +++ b/grsecurity/gracl_segv.c
69522 @@ -0,0 +1,313 @@
69523 +#include <linux/kernel.h>
69524 +#include <linux/mm.h>
69525 +#include <asm/uaccess.h>
69526 +#include <asm/errno.h>
69527 +#include <asm/mman.h>
69528 +#include <net/sock.h>
69529 +#include <linux/file.h>
69530 +#include <linux/fs.h>
69531 +#include <linux/net.h>
69532 +#include <linux/in.h>
69533 +#include <linux/slab.h>
69534 +#include <linux/types.h>
69535 +#include <linux/sched.h>
69536 +#include <linux/timer.h>
69537 +#include <linux/gracl.h>
69538 +#include <linux/grsecurity.h>
69539 +#include <linux/grinternal.h>
69540 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
69541 +#include <linux/magic.h>
69542 +#include <linux/pagemap.h>
69543 +#include "../fs/btrfs/async-thread.h"
69544 +#include "../fs/btrfs/ctree.h"
69545 +#include "../fs/btrfs/btrfs_inode.h"
69546 +#endif
69547 +
69548 +static struct crash_uid *uid_set;
69549 +static unsigned short uid_used;
69550 +static DEFINE_SPINLOCK(gr_uid_lock);
69551 +extern rwlock_t gr_inode_lock;
69552 +extern struct acl_subject_label *
69553 + lookup_acl_subj_label(const ino_t inode, const dev_t dev,
69554 + struct acl_role_label *role);
69555 +
69556 +static inline dev_t __get_dev(const struct dentry *dentry)
69557 +{
69558 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
69559 + if (dentry->d_sb->s_magic == BTRFS_SUPER_MAGIC)
69560 + return BTRFS_I(dentry->d_inode)->root->anon_dev;
69561 + else
69562 +#endif
69563 + return dentry->d_sb->s_dev;
69564 +}
69565 +
69566 +int
69567 +gr_init_uidset(void)
69568 +{
69569 + uid_set =
69570 + kmalloc(GR_UIDTABLE_MAX * sizeof (struct crash_uid), GFP_KERNEL);
69571 + uid_used = 0;
69572 +
69573 + return uid_set ? 1 : 0;
69574 +}
69575 +
69576 +void
69577 +gr_free_uidset(void)
69578 +{
69579 + if (uid_set) {
69580 + struct crash_uid *tmpset;
69581 + spin_lock(&gr_uid_lock);
69582 + tmpset = uid_set;
69583 + uid_set = NULL;
69584 + uid_used = 0;
69585 + spin_unlock(&gr_uid_lock);
69586 + if (tmpset)
69587 + kfree(tmpset);
69588 + }
69589 +
69590 + return;
69591 +}
69592 +
69593 +int
69594 +gr_find_uid(const uid_t uid)
69595 +{
69596 + struct crash_uid *tmp = uid_set;
69597 + uid_t buid;
69598 + int low = 0, high = uid_used - 1, mid;
69599 +
69600 + while (high >= low) {
69601 + mid = (low + high) >> 1;
69602 + buid = tmp[mid].uid;
69603 + if (buid == uid)
69604 + return mid;
69605 + if (buid > uid)
69606 + high = mid - 1;
69607 + if (buid < uid)
69608 + low = mid + 1;
69609 + }
69610 +
69611 + return -1;
69612 +}
69613 +
69614 +static __inline__ void
69615 +gr_insertsort(void)
69616 +{
69617 + unsigned short i, j;
69618 + struct crash_uid index;
69619 +
69620 + for (i = 1; i < uid_used; i++) {
69621 + index = uid_set[i];
69622 + j = i;
69623 + while ((j > 0) && uid_set[j - 1].uid > index.uid) {
69624 + uid_set[j] = uid_set[j - 1];
69625 + j--;
69626 + }
69627 + uid_set[j] = index;
69628 + }
69629 +
69630 + return;
69631 +}
69632 +
69633 +static __inline__ void
69634 +gr_insert_uid(const kuid_t kuid, const unsigned long expires)
69635 +{
69636 + int loc;
69637 + uid_t uid = GR_GLOBAL_UID(kuid);
69638 +
69639 + if (uid_used == GR_UIDTABLE_MAX)
69640 + return;
69641 +
69642 + loc = gr_find_uid(uid);
69643 +
69644 + if (loc >= 0) {
69645 + uid_set[loc].expires = expires;
69646 + return;
69647 + }
69648 +
69649 + uid_set[uid_used].uid = uid;
69650 + uid_set[uid_used].expires = expires;
69651 + uid_used++;
69652 +
69653 + gr_insertsort();
69654 +
69655 + return;
69656 +}
69657 +
69658 +void
69659 +gr_remove_uid(const unsigned short loc)
69660 +{
69661 + unsigned short i;
69662 +
69663 + for (i = loc + 1; i < uid_used; i++)
69664 + uid_set[i - 1] = uid_set[i];
69665 +
69666 + uid_used--;
69667 +
69668 + return;
69669 +}
69670 +
69671 +int
69672 +gr_check_crash_uid(const kuid_t kuid)
69673 +{
69674 + int loc;
69675 + int ret = 0;
69676 + uid_t uid;
69677 +
69678 + if (unlikely(!gr_acl_is_enabled()))
69679 + return 0;
69680 +
69681 + uid = GR_GLOBAL_UID(kuid);
69682 +
69683 + spin_lock(&gr_uid_lock);
69684 + loc = gr_find_uid(uid);
69685 +
69686 + if (loc < 0)
69687 + goto out_unlock;
69688 +
69689 + if (time_before_eq(uid_set[loc].expires, get_seconds()))
69690 + gr_remove_uid(loc);
69691 + else
69692 + ret = 1;
69693 +
69694 +out_unlock:
69695 + spin_unlock(&gr_uid_lock);
69696 + return ret;
69697 +}
69698 +
69699 +static __inline__ int
69700 +proc_is_setxid(const struct cred *cred)
69701 +{
69702 + if (!uid_eq(cred->uid, cred->euid) || !uid_eq(cred->uid, cred->suid) ||
69703 + !uid_eq(cred->uid, cred->fsuid))
69704 + return 1;
69705 + if (!gid_eq(cred->gid, cred->egid) || !gid_eq(cred->gid, cred->sgid) ||
69706 + !gid_eq(cred->gid, cred->fsgid))
69707 + return 1;
69708 +
69709 + return 0;
69710 +}
69711 +
69712 +extern int gr_fake_force_sig(int sig, struct task_struct *t);
69713 +
69714 +void
69715 +gr_handle_crash(struct task_struct *task, const int sig)
69716 +{
69717 + struct acl_subject_label *curr;
69718 + struct task_struct *tsk, *tsk2;
69719 + const struct cred *cred;
69720 + const struct cred *cred2;
69721 +
69722 + if (sig != SIGSEGV && sig != SIGKILL && sig != SIGBUS && sig != SIGILL)
69723 + return;
69724 +
69725 + if (unlikely(!gr_acl_is_enabled()))
69726 + return;
69727 +
69728 + curr = task->acl;
69729 +
69730 + if (!(curr->resmask & (1U << GR_CRASH_RES)))
69731 + return;
69732 +
69733 + if (time_before_eq(curr->expires, get_seconds())) {
69734 + curr->expires = 0;
69735 + curr->crashes = 0;
69736 + }
69737 +
69738 + curr->crashes++;
69739 +
69740 + if (!curr->expires)
69741 + curr->expires = get_seconds() + curr->res[GR_CRASH_RES].rlim_max;
69742 +
69743 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
69744 + time_after(curr->expires, get_seconds())) {
69745 + rcu_read_lock();
69746 + cred = __task_cred(task);
69747 + if (gr_is_global_nonroot(cred->uid) && proc_is_setxid(cred)) {
69748 + gr_log_crash1(GR_DONT_AUDIT, GR_SEGVSTART_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
69749 + spin_lock(&gr_uid_lock);
69750 + gr_insert_uid(cred->uid, curr->expires);
69751 + spin_unlock(&gr_uid_lock);
69752 + curr->expires = 0;
69753 + curr->crashes = 0;
69754 + read_lock(&tasklist_lock);
69755 + do_each_thread(tsk2, tsk) {
69756 + cred2 = __task_cred(tsk);
69757 + if (tsk != task && uid_eq(cred2->uid, cred->uid))
69758 + gr_fake_force_sig(SIGKILL, tsk);
69759 + } while_each_thread(tsk2, tsk);
69760 + read_unlock(&tasklist_lock);
69761 + } else {
69762 + gr_log_crash2(GR_DONT_AUDIT, GR_SEGVNOSUID_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
69763 + read_lock(&tasklist_lock);
69764 + read_lock(&grsec_exec_file_lock);
69765 + do_each_thread(tsk2, tsk) {
69766 + if (likely(tsk != task)) {
69767 + // if this thread has the same subject as the one that triggered
69768 + // RES_CRASH and it's the same binary, kill it
69769 + if (tsk->acl == task->acl && gr_is_same_file(tsk->exec_file, task->exec_file))
69770 + gr_fake_force_sig(SIGKILL, tsk);
69771 + }
69772 + } while_each_thread(tsk2, tsk);
69773 + read_unlock(&grsec_exec_file_lock);
69774 + read_unlock(&tasklist_lock);
69775 + }
69776 + rcu_read_unlock();
69777 + }
69778 +
69779 + return;
69780 +}
69781 +
69782 +int
69783 +gr_check_crash_exec(const struct file *filp)
69784 +{
69785 + struct acl_subject_label *curr;
69786 +
69787 + if (unlikely(!gr_acl_is_enabled()))
69788 + return 0;
69789 +
69790 + read_lock(&gr_inode_lock);
69791 + curr = lookup_acl_subj_label(filp->f_path.dentry->d_inode->i_ino,
69792 + __get_dev(filp->f_path.dentry),
69793 + current->role);
69794 + read_unlock(&gr_inode_lock);
69795 +
69796 + if (!curr || !(curr->resmask & (1U << GR_CRASH_RES)) ||
69797 + (!curr->crashes && !curr->expires))
69798 + return 0;
69799 +
69800 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
69801 + time_after(curr->expires, get_seconds()))
69802 + return 1;
69803 + else if (time_before_eq(curr->expires, get_seconds())) {
69804 + curr->crashes = 0;
69805 + curr->expires = 0;
69806 + }
69807 +
69808 + return 0;
69809 +}
69810 +
69811 +void
69812 +gr_handle_alertkill(struct task_struct *task)
69813 +{
69814 + struct acl_subject_label *curracl;
69815 + __u32 curr_ip;
69816 + struct task_struct *p, *p2;
69817 +
69818 + if (unlikely(!gr_acl_is_enabled()))
69819 + return;
69820 +
69821 + curracl = task->acl;
69822 + curr_ip = task->signal->curr_ip;
69823 +
69824 + if ((curracl->mode & GR_KILLIPPROC) && curr_ip) {
69825 + read_lock(&tasklist_lock);
69826 + do_each_thread(p2, p) {
69827 + if (p->signal->curr_ip == curr_ip)
69828 + gr_fake_force_sig(SIGKILL, p);
69829 + } while_each_thread(p2, p);
69830 + read_unlock(&tasklist_lock);
69831 + } else if (curracl->mode & GR_KILLPROC)
69832 + gr_fake_force_sig(SIGKILL, task);
69833 +
69834 + return;
69835 +}
69836 diff --git a/grsecurity/gracl_shm.c b/grsecurity/gracl_shm.c
69837 new file mode 100644
69838 index 0000000..98011b0
69839 --- /dev/null
69840 +++ b/grsecurity/gracl_shm.c
69841 @@ -0,0 +1,40 @@
69842 +#include <linux/kernel.h>
69843 +#include <linux/mm.h>
69844 +#include <linux/sched.h>
69845 +#include <linux/file.h>
69846 +#include <linux/ipc.h>
69847 +#include <linux/gracl.h>
69848 +#include <linux/grsecurity.h>
69849 +#include <linux/grinternal.h>
69850 +
69851 +int
69852 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
69853 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
69854 +{
69855 + struct task_struct *task;
69856 +
69857 + if (!gr_acl_is_enabled())
69858 + return 1;
69859 +
69860 + rcu_read_lock();
69861 + read_lock(&tasklist_lock);
69862 +
69863 + task = find_task_by_vpid(shm_cprid);
69864 +
69865 + if (unlikely(!task))
69866 + task = find_task_by_vpid(shm_lapid);
69867 +
69868 + if (unlikely(task && (time_before_eq((unsigned long)task->start_time.tv_sec, (unsigned long)shm_createtime) ||
69869 + (task_pid_nr(task) == shm_lapid)) &&
69870 + (task->acl->mode & GR_PROTSHM) &&
69871 + (task->acl != current->acl))) {
69872 + read_unlock(&tasklist_lock);
69873 + rcu_read_unlock();
69874 + gr_log_int3(GR_DONT_AUDIT, GR_SHMAT_ACL_MSG, GR_GLOBAL_UID(cuid), shm_cprid, shmid);
69875 + return 0;
69876 + }
69877 + read_unlock(&tasklist_lock);
69878 + rcu_read_unlock();
69879 +
69880 + return 1;
69881 +}
69882 diff --git a/grsecurity/grsec_chdir.c b/grsecurity/grsec_chdir.c
69883 new file mode 100644
69884 index 0000000..bc0be01
69885 --- /dev/null
69886 +++ b/grsecurity/grsec_chdir.c
69887 @@ -0,0 +1,19 @@
69888 +#include <linux/kernel.h>
69889 +#include <linux/sched.h>
69890 +#include <linux/fs.h>
69891 +#include <linux/file.h>
69892 +#include <linux/grsecurity.h>
69893 +#include <linux/grinternal.h>
69894 +
69895 +void
69896 +gr_log_chdir(const struct dentry *dentry, const struct vfsmount *mnt)
69897 +{
69898 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
69899 + if ((grsec_enable_chdir && grsec_enable_group &&
69900 + in_group_p(grsec_audit_gid)) || (grsec_enable_chdir &&
69901 + !grsec_enable_group)) {
69902 + gr_log_fs_generic(GR_DO_AUDIT, GR_CHDIR_AUDIT_MSG, dentry, mnt);
69903 + }
69904 +#endif
69905 + return;
69906 +}
69907 diff --git a/grsecurity/grsec_chroot.c b/grsecurity/grsec_chroot.c
69908 new file mode 100644
69909 index 0000000..e10b319
69910 --- /dev/null
69911 +++ b/grsecurity/grsec_chroot.c
69912 @@ -0,0 +1,370 @@
69913 +#include <linux/kernel.h>
69914 +#include <linux/module.h>
69915 +#include <linux/sched.h>
69916 +#include <linux/file.h>
69917 +#include <linux/fs.h>
69918 +#include <linux/mount.h>
69919 +#include <linux/types.h>
69920 +#include "../fs/mount.h"
69921 +#include <linux/grsecurity.h>
69922 +#include <linux/grinternal.h>
69923 +
69924 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
69925 +int gr_init_ran;
69926 +#endif
69927 +
69928 +void gr_set_chroot_entries(struct task_struct *task, const struct path *path)
69929 +{
69930 +#ifdef CONFIG_GRKERNSEC
69931 + if (task_pid_nr(task) > 1 && path->dentry != init_task.fs->root.dentry &&
69932 + path->dentry != task->nsproxy->mnt_ns->root->mnt.mnt_root
69933 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
69934 + && gr_init_ran
69935 +#endif
69936 + )
69937 + task->gr_is_chrooted = 1;
69938 + else {
69939 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
69940 + if (task_pid_nr(task) == 1 && !gr_init_ran)
69941 + gr_init_ran = 1;
69942 +#endif
69943 + task->gr_is_chrooted = 0;
69944 + }
69945 +
69946 + task->gr_chroot_dentry = path->dentry;
69947 +#endif
69948 + return;
69949 +}
69950 +
69951 +void gr_clear_chroot_entries(struct task_struct *task)
69952 +{
69953 +#ifdef CONFIG_GRKERNSEC
69954 + task->gr_is_chrooted = 0;
69955 + task->gr_chroot_dentry = NULL;
69956 +#endif
69957 + return;
69958 +}
69959 +
69960 +int
69961 +gr_handle_chroot_unix(const pid_t pid)
69962 +{
69963 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
69964 + struct task_struct *p;
69965 +
69966 + if (unlikely(!grsec_enable_chroot_unix))
69967 + return 1;
69968 +
69969 + if (likely(!proc_is_chrooted(current)))
69970 + return 1;
69971 +
69972 + rcu_read_lock();
69973 + read_lock(&tasklist_lock);
69974 + p = find_task_by_vpid_unrestricted(pid);
69975 + if (unlikely(p && !have_same_root(current, p))) {
69976 + read_unlock(&tasklist_lock);
69977 + rcu_read_unlock();
69978 + gr_log_noargs(GR_DONT_AUDIT, GR_UNIX_CHROOT_MSG);
69979 + return 0;
69980 + }
69981 + read_unlock(&tasklist_lock);
69982 + rcu_read_unlock();
69983 +#endif
69984 + return 1;
69985 +}
69986 +
69987 +int
69988 +gr_handle_chroot_nice(void)
69989 +{
69990 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
69991 + if (grsec_enable_chroot_nice && proc_is_chrooted(current)) {
69992 + gr_log_noargs(GR_DONT_AUDIT, GR_NICE_CHROOT_MSG);
69993 + return -EPERM;
69994 + }
69995 +#endif
69996 + return 0;
69997 +}
69998 +
69999 +int
70000 +gr_handle_chroot_setpriority(struct task_struct *p, const int niceval)
70001 +{
70002 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
70003 + if (grsec_enable_chroot_nice && (niceval < task_nice(p))
70004 + && proc_is_chrooted(current)) {
70005 + gr_log_str_int(GR_DONT_AUDIT, GR_PRIORITY_CHROOT_MSG, p->comm, task_pid_nr(p));
70006 + return -EACCES;
70007 + }
70008 +#endif
70009 + return 0;
70010 +}
70011 +
70012 +int
70013 +gr_handle_chroot_fowner(struct pid *pid, enum pid_type type)
70014 +{
70015 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
70016 + struct task_struct *p;
70017 + int ret = 0;
70018 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || !pid)
70019 + return ret;
70020 +
70021 + read_lock(&tasklist_lock);
70022 + do_each_pid_task(pid, type, p) {
70023 + if (!have_same_root(current, p)) {
70024 + ret = 1;
70025 + goto out;
70026 + }
70027 + } while_each_pid_task(pid, type, p);
70028 +out:
70029 + read_unlock(&tasklist_lock);
70030 + return ret;
70031 +#endif
70032 + return 0;
70033 +}
70034 +
70035 +int
70036 +gr_pid_is_chrooted(struct task_struct *p)
70037 +{
70038 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
70039 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || p == NULL)
70040 + return 0;
70041 +
70042 + if ((p->exit_state & (EXIT_ZOMBIE | EXIT_DEAD)) ||
70043 + !have_same_root(current, p)) {
70044 + return 1;
70045 + }
70046 +#endif
70047 + return 0;
70048 +}
70049 +
70050 +EXPORT_SYMBOL(gr_pid_is_chrooted);
70051 +
70052 +#if defined(CONFIG_GRKERNSEC_CHROOT_DOUBLE) || defined(CONFIG_GRKERNSEC_CHROOT_FCHDIR)
70053 +int gr_is_outside_chroot(const struct dentry *u_dentry, const struct vfsmount *u_mnt)
70054 +{
70055 + struct path path, currentroot;
70056 + int ret = 0;
70057 +
70058 + path.dentry = (struct dentry *)u_dentry;
70059 + path.mnt = (struct vfsmount *)u_mnt;
70060 + get_fs_root(current->fs, &currentroot);
70061 + if (path_is_under(&path, &currentroot))
70062 + ret = 1;
70063 + path_put(&currentroot);
70064 +
70065 + return ret;
70066 +}
70067 +#endif
70068 +
70069 +int
70070 +gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt)
70071 +{
70072 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
70073 + if (!grsec_enable_chroot_fchdir)
70074 + return 1;
70075 +
70076 + if (!proc_is_chrooted(current))
70077 + return 1;
70078 + else if (!gr_is_outside_chroot(u_dentry, u_mnt)) {
70079 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_FCHDIR_MSG, u_dentry, u_mnt);
70080 + return 0;
70081 + }
70082 +#endif
70083 + return 1;
70084 +}
70085 +
70086 +int
70087 +gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
70088 + const time_t shm_createtime)
70089 +{
70090 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
70091 + struct task_struct *p;
70092 + time_t starttime;
70093 +
70094 + if (unlikely(!grsec_enable_chroot_shmat))
70095 + return 1;
70096 +
70097 + if (likely(!proc_is_chrooted(current)))
70098 + return 1;
70099 +
70100 + rcu_read_lock();
70101 + read_lock(&tasklist_lock);
70102 +
70103 + if ((p = find_task_by_vpid_unrestricted(shm_cprid))) {
70104 + starttime = p->start_time.tv_sec;
70105 + if (time_before_eq((unsigned long)starttime, (unsigned long)shm_createtime)) {
70106 + if (have_same_root(current, p)) {
70107 + goto allow;
70108 + } else {
70109 + read_unlock(&tasklist_lock);
70110 + rcu_read_unlock();
70111 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
70112 + return 0;
70113 + }
70114 + }
70115 + /* creator exited, pid reuse, fall through to next check */
70116 + }
70117 + if ((p = find_task_by_vpid_unrestricted(shm_lapid))) {
70118 + if (unlikely(!have_same_root(current, p))) {
70119 + read_unlock(&tasklist_lock);
70120 + rcu_read_unlock();
70121 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
70122 + return 0;
70123 + }
70124 + }
70125 +
70126 +allow:
70127 + read_unlock(&tasklist_lock);
70128 + rcu_read_unlock();
70129 +#endif
70130 + return 1;
70131 +}
70132 +
70133 +void
70134 +gr_log_chroot_exec(const struct dentry *dentry, const struct vfsmount *mnt)
70135 +{
70136 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
70137 + if (grsec_enable_chroot_execlog && proc_is_chrooted(current))
70138 + gr_log_fs_generic(GR_DO_AUDIT, GR_EXEC_CHROOT_MSG, dentry, mnt);
70139 +#endif
70140 + return;
70141 +}
70142 +
70143 +int
70144 +gr_handle_chroot_mknod(const struct dentry *dentry,
70145 + const struct vfsmount *mnt, const int mode)
70146 +{
70147 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
70148 + if (grsec_enable_chroot_mknod && !S_ISFIFO(mode) && !S_ISREG(mode) &&
70149 + proc_is_chrooted(current)) {
70150 + gr_log_fs_generic(GR_DONT_AUDIT, GR_MKNOD_CHROOT_MSG, dentry, mnt);
70151 + return -EPERM;
70152 + }
70153 +#endif
70154 + return 0;
70155 +}
70156 +
70157 +int
70158 +gr_handle_chroot_mount(const struct dentry *dentry,
70159 + const struct vfsmount *mnt, const char *dev_name)
70160 +{
70161 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
70162 + if (grsec_enable_chroot_mount && proc_is_chrooted(current)) {
70163 + gr_log_str_fs(GR_DONT_AUDIT, GR_MOUNT_CHROOT_MSG, dev_name ? dev_name : "none", dentry, mnt);
70164 + return -EPERM;
70165 + }
70166 +#endif
70167 + return 0;
70168 +}
70169 +
70170 +int
70171 +gr_handle_chroot_pivot(void)
70172 +{
70173 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
70174 + if (grsec_enable_chroot_pivot && proc_is_chrooted(current)) {
70175 + gr_log_noargs(GR_DONT_AUDIT, GR_PIVOT_CHROOT_MSG);
70176 + return -EPERM;
70177 + }
70178 +#endif
70179 + return 0;
70180 +}
70181 +
70182 +int
70183 +gr_handle_chroot_chroot(const struct dentry *dentry, const struct vfsmount *mnt)
70184 +{
70185 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
70186 + if (grsec_enable_chroot_double && proc_is_chrooted(current) &&
70187 + !gr_is_outside_chroot(dentry, mnt)) {
70188 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_CHROOT_MSG, dentry, mnt);
70189 + return -EPERM;
70190 + }
70191 +#endif
70192 + return 0;
70193 +}
70194 +
70195 +extern const char *captab_log[];
70196 +extern int captab_log_entries;
70197 +
70198 +int
70199 +gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
70200 +{
70201 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
70202 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
70203 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
70204 + if (cap_raised(chroot_caps, cap)) {
70205 + if (cap_raised(cred->cap_effective, cap) && cap < captab_log_entries) {
70206 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_CHROOT_MSG, task, captab_log[cap]);
70207 + }
70208 + return 0;
70209 + }
70210 + }
70211 +#endif
70212 + return 1;
70213 +}
70214 +
70215 +int
70216 +gr_chroot_is_capable(const int cap)
70217 +{
70218 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
70219 + return gr_task_chroot_is_capable(current, current_cred(), cap);
70220 +#endif
70221 + return 1;
70222 +}
70223 +
70224 +int
70225 +gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap)
70226 +{
70227 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
70228 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
70229 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
70230 + if (cap_raised(chroot_caps, cap)) {
70231 + return 0;
70232 + }
70233 + }
70234 +#endif
70235 + return 1;
70236 +}
70237 +
70238 +int
70239 +gr_chroot_is_capable_nolog(const int cap)
70240 +{
70241 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
70242 + return gr_task_chroot_is_capable_nolog(current, cap);
70243 +#endif
70244 + return 1;
70245 +}
70246 +
70247 +int
70248 +gr_handle_chroot_sysctl(const int op)
70249 +{
70250 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
70251 + if (grsec_enable_chroot_sysctl && (op & MAY_WRITE) &&
70252 + proc_is_chrooted(current))
70253 + return -EACCES;
70254 +#endif
70255 + return 0;
70256 +}
70257 +
70258 +void
70259 +gr_handle_chroot_chdir(const struct path *path)
70260 +{
70261 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
70262 + if (grsec_enable_chroot_chdir)
70263 + set_fs_pwd(current->fs, path);
70264 +#endif
70265 + return;
70266 +}
70267 +
70268 +int
70269 +gr_handle_chroot_chmod(const struct dentry *dentry,
70270 + const struct vfsmount *mnt, const int mode)
70271 +{
70272 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
70273 + /* allow chmod +s on directories, but not files */
70274 + if (grsec_enable_chroot_chmod && !S_ISDIR(dentry->d_inode->i_mode) &&
70275 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))) &&
70276 + proc_is_chrooted(current)) {
70277 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHMOD_CHROOT_MSG, dentry, mnt);
70278 + return -EPERM;
70279 + }
70280 +#endif
70281 + return 0;
70282 +}
70283 diff --git a/grsecurity/grsec_disabled.c b/grsecurity/grsec_disabled.c
70284 new file mode 100644
70285 index 0000000..0866ab2
70286 --- /dev/null
70287 +++ b/grsecurity/grsec_disabled.c
70288 @@ -0,0 +1,427 @@
70289 +#include <linux/kernel.h>
70290 +#include <linux/module.h>
70291 +#include <linux/sched.h>
70292 +#include <linux/file.h>
70293 +#include <linux/fs.h>
70294 +#include <linux/kdev_t.h>
70295 +#include <linux/net.h>
70296 +#include <linux/in.h>
70297 +#include <linux/ip.h>
70298 +#include <linux/skbuff.h>
70299 +#include <linux/sysctl.h>
70300 +
70301 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
70302 +void
70303 +pax_set_initial_flags(struct linux_binprm *bprm)
70304 +{
70305 + return;
70306 +}
70307 +#endif
70308 +
70309 +#ifdef CONFIG_SYSCTL
70310 +__u32
70311 +gr_handle_sysctl(const struct ctl_table * table, const int op)
70312 +{
70313 + return 0;
70314 +}
70315 +#endif
70316 +
70317 +#ifdef CONFIG_TASKSTATS
70318 +int gr_is_taskstats_denied(int pid)
70319 +{
70320 + return 0;
70321 +}
70322 +#endif
70323 +
70324 +int
70325 +gr_acl_is_enabled(void)
70326 +{
70327 + return 0;
70328 +}
70329 +
70330 +void
70331 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
70332 +{
70333 + return;
70334 +}
70335 +
70336 +int
70337 +gr_handle_rawio(const struct inode *inode)
70338 +{
70339 + return 0;
70340 +}
70341 +
70342 +void
70343 +gr_acl_handle_psacct(struct task_struct *task, const long code)
70344 +{
70345 + return;
70346 +}
70347 +
70348 +int
70349 +gr_handle_ptrace(struct task_struct *task, const long request)
70350 +{
70351 + return 0;
70352 +}
70353 +
70354 +int
70355 +gr_handle_proc_ptrace(struct task_struct *task)
70356 +{
70357 + return 0;
70358 +}
70359 +
70360 +int
70361 +gr_set_acls(const int type)
70362 +{
70363 + return 0;
70364 +}
70365 +
70366 +int
70367 +gr_check_hidden_task(const struct task_struct *tsk)
70368 +{
70369 + return 0;
70370 +}
70371 +
70372 +int
70373 +gr_check_protected_task(const struct task_struct *task)
70374 +{
70375 + return 0;
70376 +}
70377 +
70378 +int
70379 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
70380 +{
70381 + return 0;
70382 +}
70383 +
70384 +void
70385 +gr_copy_label(struct task_struct *tsk)
70386 +{
70387 + return;
70388 +}
70389 +
70390 +void
70391 +gr_set_pax_flags(struct task_struct *task)
70392 +{
70393 + return;
70394 +}
70395 +
70396 +int
70397 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
70398 + const int unsafe_share)
70399 +{
70400 + return 0;
70401 +}
70402 +
70403 +void
70404 +gr_handle_delete(const ino_t ino, const dev_t dev)
70405 +{
70406 + return;
70407 +}
70408 +
70409 +void
70410 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
70411 +{
70412 + return;
70413 +}
70414 +
70415 +void
70416 +gr_handle_crash(struct task_struct *task, const int sig)
70417 +{
70418 + return;
70419 +}
70420 +
70421 +int
70422 +gr_check_crash_exec(const struct file *filp)
70423 +{
70424 + return 0;
70425 +}
70426 +
70427 +int
70428 +gr_check_crash_uid(const kuid_t uid)
70429 +{
70430 + return 0;
70431 +}
70432 +
70433 +void
70434 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
70435 + struct dentry *old_dentry,
70436 + struct dentry *new_dentry,
70437 + struct vfsmount *mnt, const __u8 replace)
70438 +{
70439 + return;
70440 +}
70441 +
70442 +int
70443 +gr_search_socket(const int family, const int type, const int protocol)
70444 +{
70445 + return 1;
70446 +}
70447 +
70448 +int
70449 +gr_search_connectbind(const int mode, const struct socket *sock,
70450 + const struct sockaddr_in *addr)
70451 +{
70452 + return 0;
70453 +}
70454 +
70455 +void
70456 +gr_handle_alertkill(struct task_struct *task)
70457 +{
70458 + return;
70459 +}
70460 +
70461 +__u32
70462 +gr_acl_handle_execve(const struct dentry * dentry, const struct vfsmount * mnt)
70463 +{
70464 + return 1;
70465 +}
70466 +
70467 +__u32
70468 +gr_acl_handle_hidden_file(const struct dentry * dentry,
70469 + const struct vfsmount * mnt)
70470 +{
70471 + return 1;
70472 +}
70473 +
70474 +__u32
70475 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
70476 + int acc_mode)
70477 +{
70478 + return 1;
70479 +}
70480 +
70481 +__u32
70482 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
70483 +{
70484 + return 1;
70485 +}
70486 +
70487 +__u32
70488 +gr_acl_handle_unlink(const struct dentry * dentry, const struct vfsmount * mnt)
70489 +{
70490 + return 1;
70491 +}
70492 +
70493 +int
70494 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot,
70495 + unsigned int *vm_flags)
70496 +{
70497 + return 1;
70498 +}
70499 +
70500 +__u32
70501 +gr_acl_handle_truncate(const struct dentry * dentry,
70502 + const struct vfsmount * mnt)
70503 +{
70504 + return 1;
70505 +}
70506 +
70507 +__u32
70508 +gr_acl_handle_utime(const struct dentry * dentry, const struct vfsmount * mnt)
70509 +{
70510 + return 1;
70511 +}
70512 +
70513 +__u32
70514 +gr_acl_handle_access(const struct dentry * dentry,
70515 + const struct vfsmount * mnt, const int fmode)
70516 +{
70517 + return 1;
70518 +}
70519 +
70520 +__u32
70521 +gr_acl_handle_chmod(const struct dentry * dentry, const struct vfsmount * mnt,
70522 + umode_t *mode)
70523 +{
70524 + return 1;
70525 +}
70526 +
70527 +__u32
70528 +gr_acl_handle_chown(const struct dentry * dentry, const struct vfsmount * mnt)
70529 +{
70530 + return 1;
70531 +}
70532 +
70533 +__u32
70534 +gr_acl_handle_setxattr(const struct dentry * dentry, const struct vfsmount * mnt)
70535 +{
70536 + return 1;
70537 +}
70538 +
70539 +void
70540 +grsecurity_init(void)
70541 +{
70542 + return;
70543 +}
70544 +
70545 +umode_t gr_acl_umask(void)
70546 +{
70547 + return 0;
70548 +}
70549 +
70550 +__u32
70551 +gr_acl_handle_mknod(const struct dentry * new_dentry,
70552 + const struct dentry * parent_dentry,
70553 + const struct vfsmount * parent_mnt,
70554 + const int mode)
70555 +{
70556 + return 1;
70557 +}
70558 +
70559 +__u32
70560 +gr_acl_handle_mkdir(const struct dentry * new_dentry,
70561 + const struct dentry * parent_dentry,
70562 + const struct vfsmount * parent_mnt)
70563 +{
70564 + return 1;
70565 +}
70566 +
70567 +__u32
70568 +gr_acl_handle_symlink(const struct dentry * new_dentry,
70569 + const struct dentry * parent_dentry,
70570 + const struct vfsmount * parent_mnt, const struct filename *from)
70571 +{
70572 + return 1;
70573 +}
70574 +
70575 +__u32
70576 +gr_acl_handle_link(const struct dentry * new_dentry,
70577 + const struct dentry * parent_dentry,
70578 + const struct vfsmount * parent_mnt,
70579 + const struct dentry * old_dentry,
70580 + const struct vfsmount * old_mnt, const struct filename *to)
70581 +{
70582 + return 1;
70583 +}
70584 +
70585 +int
70586 +gr_acl_handle_rename(const struct dentry *new_dentry,
70587 + const struct dentry *parent_dentry,
70588 + const struct vfsmount *parent_mnt,
70589 + const struct dentry *old_dentry,
70590 + const struct inode *old_parent_inode,
70591 + const struct vfsmount *old_mnt, const struct filename *newname)
70592 +{
70593 + return 0;
70594 +}
70595 +
70596 +int
70597 +gr_acl_handle_filldir(const struct file *file, const char *name,
70598 + const int namelen, const ino_t ino)
70599 +{
70600 + return 1;
70601 +}
70602 +
70603 +int
70604 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
70605 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
70606 +{
70607 + return 1;
70608 +}
70609 +
70610 +int
70611 +gr_search_bind(const struct socket *sock, const struct sockaddr_in *addr)
70612 +{
70613 + return 0;
70614 +}
70615 +
70616 +int
70617 +gr_search_accept(const struct socket *sock)
70618 +{
70619 + return 0;
70620 +}
70621 +
70622 +int
70623 +gr_search_listen(const struct socket *sock)
70624 +{
70625 + return 0;
70626 +}
70627 +
70628 +int
70629 +gr_search_connect(const struct socket *sock, const struct sockaddr_in *addr)
70630 +{
70631 + return 0;
70632 +}
70633 +
70634 +__u32
70635 +gr_acl_handle_unix(const struct dentry * dentry, const struct vfsmount * mnt)
70636 +{
70637 + return 1;
70638 +}
70639 +
70640 +__u32
70641 +gr_acl_handle_creat(const struct dentry * dentry,
70642 + const struct dentry * p_dentry,
70643 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
70644 + const int imode)
70645 +{
70646 + return 1;
70647 +}
70648 +
70649 +void
70650 +gr_acl_handle_exit(void)
70651 +{
70652 + return;
70653 +}
70654 +
70655 +int
70656 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
70657 +{
70658 + return 1;
70659 +}
70660 +
70661 +void
70662 +gr_set_role_label(const kuid_t uid, const kgid_t gid)
70663 +{
70664 + return;
70665 +}
70666 +
70667 +int
70668 +gr_acl_handle_procpidmem(const struct task_struct *task)
70669 +{
70670 + return 0;
70671 +}
70672 +
70673 +int
70674 +gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb)
70675 +{
70676 + return 0;
70677 +}
70678 +
70679 +int
70680 +gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr)
70681 +{
70682 + return 0;
70683 +}
70684 +
70685 +int
70686 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
70687 +{
70688 + return 0;
70689 +}
70690 +
70691 +int
70692 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
70693 +{
70694 + return 0;
70695 +}
70696 +
70697 +int gr_acl_enable_at_secure(void)
70698 +{
70699 + return 0;
70700 +}
70701 +
70702 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
70703 +{
70704 + return dentry->d_sb->s_dev;
70705 +}
70706 +
70707 +void gr_put_exec_file(struct task_struct *task)
70708 +{
70709 + return;
70710 +}
70711 +
70712 +#ifdef CONFIG_SECURITY
70713 +EXPORT_SYMBOL(gr_check_user_change);
70714 +EXPORT_SYMBOL(gr_check_group_change);
70715 +#endif
70716 diff --git a/grsecurity/grsec_exec.c b/grsecurity/grsec_exec.c
70717 new file mode 100644
70718 index 0000000..387032b
70719 --- /dev/null
70720 +++ b/grsecurity/grsec_exec.c
70721 @@ -0,0 +1,187 @@
70722 +#include <linux/kernel.h>
70723 +#include <linux/sched.h>
70724 +#include <linux/file.h>
70725 +#include <linux/binfmts.h>
70726 +#include <linux/fs.h>
70727 +#include <linux/types.h>
70728 +#include <linux/grdefs.h>
70729 +#include <linux/grsecurity.h>
70730 +#include <linux/grinternal.h>
70731 +#include <linux/capability.h>
70732 +#include <linux/module.h>
70733 +#include <linux/compat.h>
70734 +
70735 +#include <asm/uaccess.h>
70736 +
70737 +#ifdef CONFIG_GRKERNSEC_EXECLOG
70738 +static char gr_exec_arg_buf[132];
70739 +static DEFINE_MUTEX(gr_exec_arg_mutex);
70740 +#endif
70741 +
70742 +struct user_arg_ptr {
70743 +#ifdef CONFIG_COMPAT
70744 + bool is_compat;
70745 +#endif
70746 + union {
70747 + const char __user *const __user *native;
70748 +#ifdef CONFIG_COMPAT
70749 + const compat_uptr_t __user *compat;
70750 +#endif
70751 + } ptr;
70752 +};
70753 +
70754 +extern const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr);
70755 +
70756 +void
70757 +gr_handle_exec_args(struct linux_binprm *bprm, struct user_arg_ptr argv)
70758 +{
70759 +#ifdef CONFIG_GRKERNSEC_EXECLOG
70760 + char *grarg = gr_exec_arg_buf;
70761 + unsigned int i, x, execlen = 0;
70762 + char c;
70763 +
70764 + if (!((grsec_enable_execlog && grsec_enable_group &&
70765 + in_group_p(grsec_audit_gid))
70766 + || (grsec_enable_execlog && !grsec_enable_group)))
70767 + return;
70768 +
70769 + mutex_lock(&gr_exec_arg_mutex);
70770 + memset(grarg, 0, sizeof(gr_exec_arg_buf));
70771 +
70772 + for (i = 0; i < bprm->argc && execlen < 128; i++) {
70773 + const char __user *p;
70774 + unsigned int len;
70775 +
70776 + p = get_user_arg_ptr(argv, i);
70777 + if (IS_ERR(p))
70778 + goto log;
70779 +
70780 + len = strnlen_user(p, 128 - execlen);
70781 + if (len > 128 - execlen)
70782 + len = 128 - execlen;
70783 + else if (len > 0)
70784 + len--;
70785 + if (copy_from_user(grarg + execlen, p, len))
70786 + goto log;
70787 +
70788 + /* rewrite unprintable characters */
70789 + for (x = 0; x < len; x++) {
70790 + c = *(grarg + execlen + x);
70791 + if (c < 32 || c > 126)
70792 + *(grarg + execlen + x) = ' ';
70793 + }
70794 +
70795 + execlen += len;
70796 + *(grarg + execlen) = ' ';
70797 + *(grarg + execlen + 1) = '\0';
70798 + execlen++;
70799 + }
70800 +
70801 + log:
70802 + gr_log_fs_str(GR_DO_AUDIT, GR_EXEC_AUDIT_MSG, bprm->file->f_path.dentry,
70803 + bprm->file->f_path.mnt, grarg);
70804 + mutex_unlock(&gr_exec_arg_mutex);
70805 +#endif
70806 + return;
70807 +}
70808 +
70809 +#ifdef CONFIG_GRKERNSEC
70810 +extern int gr_acl_is_capable(const int cap);
70811 +extern int gr_acl_is_capable_nolog(const int cap);
70812 +extern int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
70813 +extern int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap);
70814 +extern int gr_chroot_is_capable(const int cap);
70815 +extern int gr_chroot_is_capable_nolog(const int cap);
70816 +extern int gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
70817 +extern int gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap);
70818 +#endif
70819 +
70820 +const char *captab_log[] = {
70821 + "CAP_CHOWN",
70822 + "CAP_DAC_OVERRIDE",
70823 + "CAP_DAC_READ_SEARCH",
70824 + "CAP_FOWNER",
70825 + "CAP_FSETID",
70826 + "CAP_KILL",
70827 + "CAP_SETGID",
70828 + "CAP_SETUID",
70829 + "CAP_SETPCAP",
70830 + "CAP_LINUX_IMMUTABLE",
70831 + "CAP_NET_BIND_SERVICE",
70832 + "CAP_NET_BROADCAST",
70833 + "CAP_NET_ADMIN",
70834 + "CAP_NET_RAW",
70835 + "CAP_IPC_LOCK",
70836 + "CAP_IPC_OWNER",
70837 + "CAP_SYS_MODULE",
70838 + "CAP_SYS_RAWIO",
70839 + "CAP_SYS_CHROOT",
70840 + "CAP_SYS_PTRACE",
70841 + "CAP_SYS_PACCT",
70842 + "CAP_SYS_ADMIN",
70843 + "CAP_SYS_BOOT",
70844 + "CAP_SYS_NICE",
70845 + "CAP_SYS_RESOURCE",
70846 + "CAP_SYS_TIME",
70847 + "CAP_SYS_TTY_CONFIG",
70848 + "CAP_MKNOD",
70849 + "CAP_LEASE",
70850 + "CAP_AUDIT_WRITE",
70851 + "CAP_AUDIT_CONTROL",
70852 + "CAP_SETFCAP",
70853 + "CAP_MAC_OVERRIDE",
70854 + "CAP_MAC_ADMIN",
70855 + "CAP_SYSLOG",
70856 + "CAP_WAKE_ALARM"
70857 +};
70858 +
70859 +int captab_log_entries = sizeof(captab_log)/sizeof(captab_log[0]);
70860 +
70861 +int gr_is_capable(const int cap)
70862 +{
70863 +#ifdef CONFIG_GRKERNSEC
70864 + if (gr_acl_is_capable(cap) && gr_chroot_is_capable(cap))
70865 + return 1;
70866 + return 0;
70867 +#else
70868 + return 1;
70869 +#endif
70870 +}
70871 +
70872 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
70873 +{
70874 +#ifdef CONFIG_GRKERNSEC
70875 + if (gr_task_acl_is_capable(task, cred, cap) && gr_task_chroot_is_capable(task, cred, cap))
70876 + return 1;
70877 + return 0;
70878 +#else
70879 + return 1;
70880 +#endif
70881 +}
70882 +
70883 +int gr_is_capable_nolog(const int cap)
70884 +{
70885 +#ifdef CONFIG_GRKERNSEC
70886 + if (gr_acl_is_capable_nolog(cap) && gr_chroot_is_capable_nolog(cap))
70887 + return 1;
70888 + return 0;
70889 +#else
70890 + return 1;
70891 +#endif
70892 +}
70893 +
70894 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap)
70895 +{
70896 +#ifdef CONFIG_GRKERNSEC
70897 + if (gr_task_acl_is_capable_nolog(task, cap) && gr_task_chroot_is_capable_nolog(task, cap))
70898 + return 1;
70899 + return 0;
70900 +#else
70901 + return 1;
70902 +#endif
70903 +}
70904 +
70905 +EXPORT_SYMBOL(gr_is_capable);
70906 +EXPORT_SYMBOL(gr_is_capable_nolog);
70907 +EXPORT_SYMBOL(gr_task_is_capable);
70908 +EXPORT_SYMBOL(gr_task_is_capable_nolog);
70909 diff --git a/grsecurity/grsec_fifo.c b/grsecurity/grsec_fifo.c
70910 new file mode 100644
70911 index 0000000..06cc6ea
70912 --- /dev/null
70913 +++ b/grsecurity/grsec_fifo.c
70914 @@ -0,0 +1,24 @@
70915 +#include <linux/kernel.h>
70916 +#include <linux/sched.h>
70917 +#include <linux/fs.h>
70918 +#include <linux/file.h>
70919 +#include <linux/grinternal.h>
70920 +
70921 +int
70922 +gr_handle_fifo(const struct dentry *dentry, const struct vfsmount *mnt,
70923 + const struct dentry *dir, const int flag, const int acc_mode)
70924 +{
70925 +#ifdef CONFIG_GRKERNSEC_FIFO
70926 + const struct cred *cred = current_cred();
70927 +
70928 + if (grsec_enable_fifo && S_ISFIFO(dentry->d_inode->i_mode) &&
70929 + !(flag & O_EXCL) && (dir->d_inode->i_mode & S_ISVTX) &&
70930 + !uid_eq(dentry->d_inode->i_uid, dir->d_inode->i_uid) &&
70931 + !uid_eq(cred->fsuid, dentry->d_inode->i_uid)) {
70932 + if (!inode_permission(dentry->d_inode, acc_mode))
70933 + 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));
70934 + return -EACCES;
70935 + }
70936 +#endif
70937 + return 0;
70938 +}
70939 diff --git a/grsecurity/grsec_fork.c b/grsecurity/grsec_fork.c
70940 new file mode 100644
70941 index 0000000..8ca18bf
70942 --- /dev/null
70943 +++ b/grsecurity/grsec_fork.c
70944 @@ -0,0 +1,23 @@
70945 +#include <linux/kernel.h>
70946 +#include <linux/sched.h>
70947 +#include <linux/grsecurity.h>
70948 +#include <linux/grinternal.h>
70949 +#include <linux/errno.h>
70950 +
70951 +void
70952 +gr_log_forkfail(const int retval)
70953 +{
70954 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
70955 + if (grsec_enable_forkfail && (retval == -EAGAIN || retval == -ENOMEM)) {
70956 + switch (retval) {
70957 + case -EAGAIN:
70958 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "EAGAIN");
70959 + break;
70960 + case -ENOMEM:
70961 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "ENOMEM");
70962 + break;
70963 + }
70964 + }
70965 +#endif
70966 + return;
70967 +}
70968 diff --git a/grsecurity/grsec_init.c b/grsecurity/grsec_init.c
70969 new file mode 100644
70970 index 0000000..a88e901
70971 --- /dev/null
70972 +++ b/grsecurity/grsec_init.c
70973 @@ -0,0 +1,272 @@
70974 +#include <linux/kernel.h>
70975 +#include <linux/sched.h>
70976 +#include <linux/mm.h>
70977 +#include <linux/gracl.h>
70978 +#include <linux/slab.h>
70979 +#include <linux/vmalloc.h>
70980 +#include <linux/percpu.h>
70981 +#include <linux/module.h>
70982 +
70983 +int grsec_enable_ptrace_readexec;
70984 +int grsec_enable_setxid;
70985 +int grsec_enable_symlinkown;
70986 +kgid_t grsec_symlinkown_gid;
70987 +int grsec_enable_brute;
70988 +int grsec_enable_link;
70989 +int grsec_enable_dmesg;
70990 +int grsec_enable_harden_ptrace;
70991 +int grsec_enable_harden_ipc;
70992 +int grsec_enable_fifo;
70993 +int grsec_enable_execlog;
70994 +int grsec_enable_signal;
70995 +int grsec_enable_forkfail;
70996 +int grsec_enable_audit_ptrace;
70997 +int grsec_enable_time;
70998 +int grsec_enable_group;
70999 +kgid_t grsec_audit_gid;
71000 +int grsec_enable_chdir;
71001 +int grsec_enable_mount;
71002 +int grsec_enable_rofs;
71003 +int grsec_deny_new_usb;
71004 +int grsec_enable_chroot_findtask;
71005 +int grsec_enable_chroot_mount;
71006 +int grsec_enable_chroot_shmat;
71007 +int grsec_enable_chroot_fchdir;
71008 +int grsec_enable_chroot_double;
71009 +int grsec_enable_chroot_pivot;
71010 +int grsec_enable_chroot_chdir;
71011 +int grsec_enable_chroot_chmod;
71012 +int grsec_enable_chroot_mknod;
71013 +int grsec_enable_chroot_nice;
71014 +int grsec_enable_chroot_execlog;
71015 +int grsec_enable_chroot_caps;
71016 +int grsec_enable_chroot_sysctl;
71017 +int grsec_enable_chroot_unix;
71018 +int grsec_enable_tpe;
71019 +kgid_t grsec_tpe_gid;
71020 +int grsec_enable_blackhole;
71021 +#ifdef CONFIG_IPV6_MODULE
71022 +EXPORT_SYMBOL(grsec_enable_blackhole);
71023 +#endif
71024 +int grsec_lastack_retries;
71025 +int grsec_enable_tpe_all;
71026 +int grsec_enable_tpe_invert;
71027 +int grsec_enable_socket_all;
71028 +kgid_t grsec_socket_all_gid;
71029 +int grsec_enable_socket_client;
71030 +kgid_t grsec_socket_client_gid;
71031 +int grsec_enable_socket_server;
71032 +kgid_t grsec_socket_server_gid;
71033 +int grsec_resource_logging;
71034 +int grsec_disable_privio;
71035 +int grsec_enable_log_rwxmaps;
71036 +int grsec_lock;
71037 +
71038 +DEFINE_SPINLOCK(grsec_alert_lock);
71039 +unsigned long grsec_alert_wtime = 0;
71040 +unsigned long grsec_alert_fyet = 0;
71041 +
71042 +DEFINE_SPINLOCK(grsec_audit_lock);
71043 +
71044 +DEFINE_RWLOCK(grsec_exec_file_lock);
71045 +
71046 +char *gr_shared_page[4];
71047 +
71048 +char *gr_alert_log_fmt;
71049 +char *gr_audit_log_fmt;
71050 +char *gr_alert_log_buf;
71051 +char *gr_audit_log_buf;
71052 +
71053 +void __init
71054 +grsecurity_init(void)
71055 +{
71056 + int j;
71057 + /* create the per-cpu shared pages */
71058 +
71059 +#ifdef CONFIG_X86
71060 + memset((char *)(0x41a + PAGE_OFFSET), 0, 36);
71061 +#endif
71062 +
71063 + for (j = 0; j < 4; j++) {
71064 + gr_shared_page[j] = (char *)__alloc_percpu(PAGE_SIZE, __alignof__(unsigned long long));
71065 + if (gr_shared_page[j] == NULL) {
71066 + panic("Unable to allocate grsecurity shared page");
71067 + return;
71068 + }
71069 + }
71070 +
71071 + /* allocate log buffers */
71072 + gr_alert_log_fmt = kmalloc(512, GFP_KERNEL);
71073 + if (!gr_alert_log_fmt) {
71074 + panic("Unable to allocate grsecurity alert log format buffer");
71075 + return;
71076 + }
71077 + gr_audit_log_fmt = kmalloc(512, GFP_KERNEL);
71078 + if (!gr_audit_log_fmt) {
71079 + panic("Unable to allocate grsecurity audit log format buffer");
71080 + return;
71081 + }
71082 + gr_alert_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
71083 + if (!gr_alert_log_buf) {
71084 + panic("Unable to allocate grsecurity alert log buffer");
71085 + return;
71086 + }
71087 + gr_audit_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
71088 + if (!gr_audit_log_buf) {
71089 + panic("Unable to allocate grsecurity audit log buffer");
71090 + return;
71091 + }
71092 +
71093 +#ifdef CONFIG_GRKERNSEC_IO
71094 +#if !defined(CONFIG_GRKERNSEC_SYSCTL_DISTRO)
71095 + grsec_disable_privio = 1;
71096 +#elif defined(CONFIG_GRKERNSEC_SYSCTL_ON)
71097 + grsec_disable_privio = 1;
71098 +#else
71099 + grsec_disable_privio = 0;
71100 +#endif
71101 +#endif
71102 +
71103 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
71104 + /* for backward compatibility, tpe_invert always defaults to on if
71105 + enabled in the kernel
71106 + */
71107 + grsec_enable_tpe_invert = 1;
71108 +#endif
71109 +
71110 +#if !defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_SYSCTL_ON)
71111 +#ifndef CONFIG_GRKERNSEC_SYSCTL
71112 + grsec_lock = 1;
71113 +#endif
71114 +
71115 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
71116 + grsec_enable_log_rwxmaps = 1;
71117 +#endif
71118 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
71119 + grsec_enable_group = 1;
71120 + grsec_audit_gid = KGIDT_INIT(CONFIG_GRKERNSEC_AUDIT_GID);
71121 +#endif
71122 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
71123 + grsec_enable_ptrace_readexec = 1;
71124 +#endif
71125 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
71126 + grsec_enable_chdir = 1;
71127 +#endif
71128 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
71129 + grsec_enable_harden_ptrace = 1;
71130 +#endif
71131 +#ifdef CONFIG_GRKERNSEC_HARDEN_IPC
71132 + grsec_enable_harden_ipc = 1;
71133 +#endif
71134 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
71135 + grsec_enable_mount = 1;
71136 +#endif
71137 +#ifdef CONFIG_GRKERNSEC_LINK
71138 + grsec_enable_link = 1;
71139 +#endif
71140 +#ifdef CONFIG_GRKERNSEC_BRUTE
71141 + grsec_enable_brute = 1;
71142 +#endif
71143 +#ifdef CONFIG_GRKERNSEC_DMESG
71144 + grsec_enable_dmesg = 1;
71145 +#endif
71146 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
71147 + grsec_enable_blackhole = 1;
71148 + grsec_lastack_retries = 4;
71149 +#endif
71150 +#ifdef CONFIG_GRKERNSEC_FIFO
71151 + grsec_enable_fifo = 1;
71152 +#endif
71153 +#ifdef CONFIG_GRKERNSEC_EXECLOG
71154 + grsec_enable_execlog = 1;
71155 +#endif
71156 +#ifdef CONFIG_GRKERNSEC_SETXID
71157 + grsec_enable_setxid = 1;
71158 +#endif
71159 +#ifdef CONFIG_GRKERNSEC_SIGNAL
71160 + grsec_enable_signal = 1;
71161 +#endif
71162 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
71163 + grsec_enable_forkfail = 1;
71164 +#endif
71165 +#ifdef CONFIG_GRKERNSEC_TIME
71166 + grsec_enable_time = 1;
71167 +#endif
71168 +#ifdef CONFIG_GRKERNSEC_RESLOG
71169 + grsec_resource_logging = 1;
71170 +#endif
71171 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
71172 + grsec_enable_chroot_findtask = 1;
71173 +#endif
71174 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
71175 + grsec_enable_chroot_unix = 1;
71176 +#endif
71177 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
71178 + grsec_enable_chroot_mount = 1;
71179 +#endif
71180 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
71181 + grsec_enable_chroot_fchdir = 1;
71182 +#endif
71183 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
71184 + grsec_enable_chroot_shmat = 1;
71185 +#endif
71186 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
71187 + grsec_enable_audit_ptrace = 1;
71188 +#endif
71189 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
71190 + grsec_enable_chroot_double = 1;
71191 +#endif
71192 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
71193 + grsec_enable_chroot_pivot = 1;
71194 +#endif
71195 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
71196 + grsec_enable_chroot_chdir = 1;
71197 +#endif
71198 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
71199 + grsec_enable_chroot_chmod = 1;
71200 +#endif
71201 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
71202 + grsec_enable_chroot_mknod = 1;
71203 +#endif
71204 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
71205 + grsec_enable_chroot_nice = 1;
71206 +#endif
71207 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
71208 + grsec_enable_chroot_execlog = 1;
71209 +#endif
71210 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
71211 + grsec_enable_chroot_caps = 1;
71212 +#endif
71213 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
71214 + grsec_enable_chroot_sysctl = 1;
71215 +#endif
71216 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
71217 + grsec_enable_symlinkown = 1;
71218 + grsec_symlinkown_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SYMLINKOWN_GID);
71219 +#endif
71220 +#ifdef CONFIG_GRKERNSEC_TPE
71221 + grsec_enable_tpe = 1;
71222 + grsec_tpe_gid = KGIDT_INIT(CONFIG_GRKERNSEC_TPE_GID);
71223 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
71224 + grsec_enable_tpe_all = 1;
71225 +#endif
71226 +#endif
71227 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
71228 + grsec_enable_socket_all = 1;
71229 + grsec_socket_all_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_ALL_GID);
71230 +#endif
71231 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
71232 + grsec_enable_socket_client = 1;
71233 + grsec_socket_client_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_CLIENT_GID);
71234 +#endif
71235 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
71236 + grsec_enable_socket_server = 1;
71237 + grsec_socket_server_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_SERVER_GID);
71238 +#endif
71239 +#endif
71240 +#ifdef CONFIG_GRKERNSEC_DENYUSB_FORCE
71241 + grsec_deny_new_usb = 1;
71242 +#endif
71243 +
71244 + return;
71245 +}
71246 diff --git a/grsecurity/grsec_ipc.c b/grsecurity/grsec_ipc.c
71247 new file mode 100644
71248 index 0000000..f365de0
71249 --- /dev/null
71250 +++ b/grsecurity/grsec_ipc.c
71251 @@ -0,0 +1,22 @@
71252 +#include <linux/kernel.h>
71253 +#include <linux/mm.h>
71254 +#include <linux/sched.h>
71255 +#include <linux/file.h>
71256 +#include <linux/ipc.h>
71257 +#include <linux/ipc_namespace.h>
71258 +#include <linux/grsecurity.h>
71259 +#include <linux/grinternal.h>
71260 +
71261 +int
71262 +gr_ipc_permitted(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp, int requested_mode, int granted_mode)
71263 +{
71264 +#ifdef CONFIG_GRKERNSEC_HARDEN_IPC
71265 + int write = (requested_mode & 00002);
71266 +
71267 + if (grsec_enable_harden_ipc && !(requested_mode & ~granted_mode & 0007) && !ns_capable_nolog(ns->user_ns, CAP_IPC_OWNER)) {
71268 + gr_log_str2_int(GR_DONT_AUDIT, GR_IPC_DENIED_MSG, write ? "write" : "read", write ? "writ" : "read", GR_GLOBAL_UID(ipcp->cuid));
71269 + return 0;
71270 + }
71271 +#endif
71272 + return 1;
71273 +}
71274 diff --git a/grsecurity/grsec_link.c b/grsecurity/grsec_link.c
71275 new file mode 100644
71276 index 0000000..5e05e20
71277 --- /dev/null
71278 +++ b/grsecurity/grsec_link.c
71279 @@ -0,0 +1,58 @@
71280 +#include <linux/kernel.h>
71281 +#include <linux/sched.h>
71282 +#include <linux/fs.h>
71283 +#include <linux/file.h>
71284 +#include <linux/grinternal.h>
71285 +
71286 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target)
71287 +{
71288 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
71289 + const struct inode *link_inode = link->dentry->d_inode;
71290 +
71291 + if (grsec_enable_symlinkown && in_group_p(grsec_symlinkown_gid) &&
71292 + /* ignore root-owned links, e.g. /proc/self */
71293 + gr_is_global_nonroot(link_inode->i_uid) && target &&
71294 + !uid_eq(link_inode->i_uid, target->i_uid)) {
71295 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINKOWNER_MSG, link->dentry, link->mnt, link_inode->i_uid, target->i_uid);
71296 + return 1;
71297 + }
71298 +#endif
71299 + return 0;
71300 +}
71301 +
71302 +int
71303 +gr_handle_follow_link(const struct inode *parent,
71304 + const struct inode *inode,
71305 + const struct dentry *dentry, const struct vfsmount *mnt)
71306 +{
71307 +#ifdef CONFIG_GRKERNSEC_LINK
71308 + const struct cred *cred = current_cred();
71309 +
71310 + if (grsec_enable_link && S_ISLNK(inode->i_mode) &&
71311 + (parent->i_mode & S_ISVTX) && !uid_eq(parent->i_uid, inode->i_uid) &&
71312 + (parent->i_mode & S_IWOTH) && !uid_eq(cred->fsuid, inode->i_uid)) {
71313 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid);
71314 + return -EACCES;
71315 + }
71316 +#endif
71317 + return 0;
71318 +}
71319 +
71320 +int
71321 +gr_handle_hardlink(const struct dentry *dentry,
71322 + const struct vfsmount *mnt,
71323 + struct inode *inode, const int mode, const struct filename *to)
71324 +{
71325 +#ifdef CONFIG_GRKERNSEC_LINK
71326 + const struct cred *cred = current_cred();
71327 +
71328 + if (grsec_enable_link && !uid_eq(cred->fsuid, inode->i_uid) &&
71329 + (!S_ISREG(mode) || is_privileged_binary(dentry) ||
71330 + (inode_permission(inode, MAY_READ | MAY_WRITE))) &&
71331 + !capable(CAP_FOWNER) && gr_is_global_nonroot(cred->uid)) {
71332 + gr_log_fs_int2_str(GR_DONT_AUDIT, GR_HARDLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid, to->name);
71333 + return -EPERM;
71334 + }
71335 +#endif
71336 + return 0;
71337 +}
71338 diff --git a/grsecurity/grsec_log.c b/grsecurity/grsec_log.c
71339 new file mode 100644
71340 index 0000000..dbe0a6b
71341 --- /dev/null
71342 +++ b/grsecurity/grsec_log.c
71343 @@ -0,0 +1,341 @@
71344 +#include <linux/kernel.h>
71345 +#include <linux/sched.h>
71346 +#include <linux/file.h>
71347 +#include <linux/tty.h>
71348 +#include <linux/fs.h>
71349 +#include <linux/mm.h>
71350 +#include <linux/grinternal.h>
71351 +
71352 +#ifdef CONFIG_TREE_PREEMPT_RCU
71353 +#define DISABLE_PREEMPT() preempt_disable()
71354 +#define ENABLE_PREEMPT() preempt_enable()
71355 +#else
71356 +#define DISABLE_PREEMPT()
71357 +#define ENABLE_PREEMPT()
71358 +#endif
71359 +
71360 +#define BEGIN_LOCKS(x) \
71361 + DISABLE_PREEMPT(); \
71362 + rcu_read_lock(); \
71363 + read_lock(&tasklist_lock); \
71364 + read_lock(&grsec_exec_file_lock); \
71365 + if (x != GR_DO_AUDIT) \
71366 + spin_lock(&grsec_alert_lock); \
71367 + else \
71368 + spin_lock(&grsec_audit_lock)
71369 +
71370 +#define END_LOCKS(x) \
71371 + if (x != GR_DO_AUDIT) \
71372 + spin_unlock(&grsec_alert_lock); \
71373 + else \
71374 + spin_unlock(&grsec_audit_lock); \
71375 + read_unlock(&grsec_exec_file_lock); \
71376 + read_unlock(&tasklist_lock); \
71377 + rcu_read_unlock(); \
71378 + ENABLE_PREEMPT(); \
71379 + if (x == GR_DONT_AUDIT) \
71380 + gr_handle_alertkill(current)
71381 +
71382 +enum {
71383 + FLOODING,
71384 + NO_FLOODING
71385 +};
71386 +
71387 +extern char *gr_alert_log_fmt;
71388 +extern char *gr_audit_log_fmt;
71389 +extern char *gr_alert_log_buf;
71390 +extern char *gr_audit_log_buf;
71391 +
71392 +static int gr_log_start(int audit)
71393 +{
71394 + char *loglevel = (audit == GR_DO_AUDIT) ? KERN_INFO : KERN_ALERT;
71395 + char *fmt = (audit == GR_DO_AUDIT) ? gr_audit_log_fmt : gr_alert_log_fmt;
71396 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
71397 +#if (CONFIG_GRKERNSEC_FLOODTIME > 0 && CONFIG_GRKERNSEC_FLOODBURST > 0)
71398 + unsigned long curr_secs = get_seconds();
71399 +
71400 + if (audit == GR_DO_AUDIT)
71401 + goto set_fmt;
71402 +
71403 + if (!grsec_alert_wtime || time_after(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)) {
71404 + grsec_alert_wtime = curr_secs;
71405 + grsec_alert_fyet = 0;
71406 + } else if (time_before_eq(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)
71407 + && (grsec_alert_fyet < CONFIG_GRKERNSEC_FLOODBURST)) {
71408 + grsec_alert_fyet++;
71409 + } else if (grsec_alert_fyet == CONFIG_GRKERNSEC_FLOODBURST) {
71410 + grsec_alert_wtime = curr_secs;
71411 + grsec_alert_fyet++;
71412 + printk(KERN_ALERT "grsec: more alerts, logging disabled for %d seconds\n", CONFIG_GRKERNSEC_FLOODTIME);
71413 + return FLOODING;
71414 + }
71415 + else return FLOODING;
71416 +
71417 +set_fmt:
71418 +#endif
71419 + memset(buf, 0, PAGE_SIZE);
71420 + if (current->signal->curr_ip && gr_acl_is_enabled()) {
71421 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: (%.64s:%c:%.950s) ");
71422 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
71423 + } else if (current->signal->curr_ip) {
71424 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: ");
71425 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip);
71426 + } else if (gr_acl_is_enabled()) {
71427 + sprintf(fmt, "%s%s", loglevel, "grsec: (%.64s:%c:%.950s) ");
71428 + snprintf(buf, PAGE_SIZE - 1, fmt, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
71429 + } else {
71430 + sprintf(fmt, "%s%s", loglevel, "grsec: ");
71431 + strcpy(buf, fmt);
71432 + }
71433 +
71434 + return NO_FLOODING;
71435 +}
71436 +
71437 +static void gr_log_middle(int audit, const char *msg, va_list ap)
71438 + __attribute__ ((format (printf, 2, 0)));
71439 +
71440 +static void gr_log_middle(int audit, const char *msg, va_list ap)
71441 +{
71442 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
71443 + unsigned int len = strlen(buf);
71444 +
71445 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
71446 +
71447 + return;
71448 +}
71449 +
71450 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
71451 + __attribute__ ((format (printf, 2, 3)));
71452 +
71453 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
71454 +{
71455 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
71456 + unsigned int len = strlen(buf);
71457 + va_list ap;
71458 +
71459 + va_start(ap, msg);
71460 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
71461 + va_end(ap);
71462 +
71463 + return;
71464 +}
71465 +
71466 +static void gr_log_end(int audit, int append_default)
71467 +{
71468 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
71469 + if (append_default) {
71470 + struct task_struct *task = current;
71471 + struct task_struct *parent = task->real_parent;
71472 + const struct cred *cred = __task_cred(task);
71473 + const struct cred *pcred = __task_cred(parent);
71474 + unsigned int len = strlen(buf);
71475 +
71476 + 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));
71477 + }
71478 +
71479 + printk("%s\n", buf);
71480 +
71481 + return;
71482 +}
71483 +
71484 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...)
71485 +{
71486 + int logtype;
71487 + char *result = (audit == GR_DO_AUDIT) ? "successful" : "denied";
71488 + char *str1 = NULL, *str2 = NULL, *str3 = NULL;
71489 + void *voidptr = NULL;
71490 + int num1 = 0, num2 = 0;
71491 + unsigned long ulong1 = 0, ulong2 = 0;
71492 + struct dentry *dentry = NULL;
71493 + struct vfsmount *mnt = NULL;
71494 + struct file *file = NULL;
71495 + struct task_struct *task = NULL;
71496 + struct vm_area_struct *vma = NULL;
71497 + const struct cred *cred, *pcred;
71498 + va_list ap;
71499 +
71500 + BEGIN_LOCKS(audit);
71501 + logtype = gr_log_start(audit);
71502 + if (logtype == FLOODING) {
71503 + END_LOCKS(audit);
71504 + return;
71505 + }
71506 + va_start(ap, argtypes);
71507 + switch (argtypes) {
71508 + case GR_TTYSNIFF:
71509 + task = va_arg(ap, struct task_struct *);
71510 + 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));
71511 + break;
71512 + case GR_SYSCTL_HIDDEN:
71513 + str1 = va_arg(ap, char *);
71514 + gr_log_middle_varargs(audit, msg, result, str1);
71515 + break;
71516 + case GR_RBAC:
71517 + dentry = va_arg(ap, struct dentry *);
71518 + mnt = va_arg(ap, struct vfsmount *);
71519 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt));
71520 + break;
71521 + case GR_RBAC_STR:
71522 + dentry = va_arg(ap, struct dentry *);
71523 + mnt = va_arg(ap, struct vfsmount *);
71524 + str1 = va_arg(ap, char *);
71525 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1);
71526 + break;
71527 + case GR_STR_RBAC:
71528 + str1 = va_arg(ap, char *);
71529 + dentry = va_arg(ap, struct dentry *);
71530 + mnt = va_arg(ap, struct vfsmount *);
71531 + gr_log_middle_varargs(audit, msg, result, str1, gr_to_filename(dentry, mnt));
71532 + break;
71533 + case GR_RBAC_MODE2:
71534 + dentry = va_arg(ap, struct dentry *);
71535 + mnt = va_arg(ap, struct vfsmount *);
71536 + str1 = va_arg(ap, char *);
71537 + str2 = va_arg(ap, char *);
71538 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2);
71539 + break;
71540 + case GR_RBAC_MODE3:
71541 + dentry = va_arg(ap, struct dentry *);
71542 + mnt = va_arg(ap, struct vfsmount *);
71543 + str1 = va_arg(ap, char *);
71544 + str2 = va_arg(ap, char *);
71545 + str3 = va_arg(ap, char *);
71546 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2, str3);
71547 + break;
71548 + case GR_FILENAME:
71549 + dentry = va_arg(ap, struct dentry *);
71550 + mnt = va_arg(ap, struct vfsmount *);
71551 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt));
71552 + break;
71553 + case GR_STR_FILENAME:
71554 + str1 = va_arg(ap, char *);
71555 + dentry = va_arg(ap, struct dentry *);
71556 + mnt = va_arg(ap, struct vfsmount *);
71557 + gr_log_middle_varargs(audit, msg, str1, gr_to_filename(dentry, mnt));
71558 + break;
71559 + case GR_FILENAME_STR:
71560 + dentry = va_arg(ap, struct dentry *);
71561 + mnt = va_arg(ap, struct vfsmount *);
71562 + str1 = va_arg(ap, char *);
71563 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), str1);
71564 + break;
71565 + case GR_FILENAME_TWO_INT:
71566 + dentry = va_arg(ap, struct dentry *);
71567 + mnt = va_arg(ap, struct vfsmount *);
71568 + num1 = va_arg(ap, int);
71569 + num2 = va_arg(ap, int);
71570 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2);
71571 + break;
71572 + case GR_FILENAME_TWO_INT_STR:
71573 + dentry = va_arg(ap, struct dentry *);
71574 + mnt = va_arg(ap, struct vfsmount *);
71575 + num1 = va_arg(ap, int);
71576 + num2 = va_arg(ap, int);
71577 + str1 = va_arg(ap, char *);
71578 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2, str1);
71579 + break;
71580 + case GR_TEXTREL:
71581 + file = va_arg(ap, struct file *);
71582 + ulong1 = va_arg(ap, unsigned long);
71583 + ulong2 = va_arg(ap, unsigned long);
71584 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>", ulong1, ulong2);
71585 + break;
71586 + case GR_PTRACE:
71587 + task = va_arg(ap, struct task_struct *);
71588 + 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));
71589 + break;
71590 + case GR_RESOURCE:
71591 + task = va_arg(ap, struct task_struct *);
71592 + cred = __task_cred(task);
71593 + pcred = __task_cred(task->real_parent);
71594 + ulong1 = va_arg(ap, unsigned long);
71595 + str1 = va_arg(ap, char *);
71596 + ulong2 = va_arg(ap, unsigned long);
71597 + 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));
71598 + break;
71599 + case GR_CAP:
71600 + task = va_arg(ap, struct task_struct *);
71601 + cred = __task_cred(task);
71602 + pcred = __task_cred(task->real_parent);
71603 + str1 = va_arg(ap, char *);
71604 + 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));
71605 + break;
71606 + case GR_SIG:
71607 + str1 = va_arg(ap, char *);
71608 + voidptr = va_arg(ap, void *);
71609 + gr_log_middle_varargs(audit, msg, str1, voidptr);
71610 + break;
71611 + case GR_SIG2:
71612 + task = va_arg(ap, struct task_struct *);
71613 + cred = __task_cred(task);
71614 + pcred = __task_cred(task->real_parent);
71615 + num1 = va_arg(ap, int);
71616 + 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));
71617 + break;
71618 + case GR_CRASH1:
71619 + task = va_arg(ap, struct task_struct *);
71620 + cred = __task_cred(task);
71621 + pcred = __task_cred(task->real_parent);
71622 + ulong1 = va_arg(ap, unsigned long);
71623 + 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);
71624 + break;
71625 + case GR_CRASH2:
71626 + task = va_arg(ap, struct task_struct *);
71627 + cred = __task_cred(task);
71628 + pcred = __task_cred(task->real_parent);
71629 + ulong1 = va_arg(ap, unsigned long);
71630 + 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);
71631 + break;
71632 + case GR_RWXMAP:
71633 + file = va_arg(ap, struct file *);
71634 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>");
71635 + break;
71636 + case GR_RWXMAPVMA:
71637 + vma = va_arg(ap, struct vm_area_struct *);
71638 + if (vma->vm_file)
71639 + str1 = gr_to_filename(vma->vm_file->f_path.dentry, vma->vm_file->f_path.mnt);
71640 + else if (vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP))
71641 + str1 = "<stack>";
71642 + else if (vma->vm_start <= current->mm->brk &&
71643 + vma->vm_end >= current->mm->start_brk)
71644 + str1 = "<heap>";
71645 + else
71646 + str1 = "<anonymous mapping>";
71647 + gr_log_middle_varargs(audit, msg, str1);
71648 + break;
71649 + case GR_PSACCT:
71650 + {
71651 + unsigned int wday, cday;
71652 + __u8 whr, chr;
71653 + __u8 wmin, cmin;
71654 + __u8 wsec, csec;
71655 + char cur_tty[64] = { 0 };
71656 + char parent_tty[64] = { 0 };
71657 +
71658 + task = va_arg(ap, struct task_struct *);
71659 + wday = va_arg(ap, unsigned int);
71660 + cday = va_arg(ap, unsigned int);
71661 + whr = va_arg(ap, int);
71662 + chr = va_arg(ap, int);
71663 + wmin = va_arg(ap, int);
71664 + cmin = va_arg(ap, int);
71665 + wsec = va_arg(ap, int);
71666 + csec = va_arg(ap, int);
71667 + ulong1 = va_arg(ap, unsigned long);
71668 + cred = __task_cred(task);
71669 + pcred = __task_cred(task->real_parent);
71670 +
71671 + 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));
71672 + }
71673 + break;
71674 + default:
71675 + gr_log_middle(audit, msg, ap);
71676 + }
71677 + va_end(ap);
71678 + // these don't need DEFAULTSECARGS printed on the end
71679 + if (argtypes == GR_CRASH1 || argtypes == GR_CRASH2)
71680 + gr_log_end(audit, 0);
71681 + else
71682 + gr_log_end(audit, 1);
71683 + END_LOCKS(audit);
71684 +}
71685 diff --git a/grsecurity/grsec_mem.c b/grsecurity/grsec_mem.c
71686 new file mode 100644
71687 index 0000000..f536303
71688 --- /dev/null
71689 +++ b/grsecurity/grsec_mem.c
71690 @@ -0,0 +1,40 @@
71691 +#include <linux/kernel.h>
71692 +#include <linux/sched.h>
71693 +#include <linux/mm.h>
71694 +#include <linux/mman.h>
71695 +#include <linux/grinternal.h>
71696 +
71697 +void
71698 +gr_handle_ioperm(void)
71699 +{
71700 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPERM_MSG);
71701 + return;
71702 +}
71703 +
71704 +void
71705 +gr_handle_iopl(void)
71706 +{
71707 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPL_MSG);
71708 + return;
71709 +}
71710 +
71711 +void
71712 +gr_handle_mem_readwrite(u64 from, u64 to)
71713 +{
71714 + gr_log_two_u64(GR_DONT_AUDIT, GR_MEM_READWRITE_MSG, from, to);
71715 + return;
71716 +}
71717 +
71718 +void
71719 +gr_handle_vm86(void)
71720 +{
71721 + gr_log_noargs(GR_DONT_AUDIT, GR_VM86_MSG);
71722 + return;
71723 +}
71724 +
71725 +void
71726 +gr_log_badprocpid(const char *entry)
71727 +{
71728 + gr_log_str(GR_DONT_AUDIT, GR_BADPROCPID_MSG, entry);
71729 + return;
71730 +}
71731 diff --git a/grsecurity/grsec_mount.c b/grsecurity/grsec_mount.c
71732 new file mode 100644
71733 index 0000000..2131422
71734 --- /dev/null
71735 +++ b/grsecurity/grsec_mount.c
71736 @@ -0,0 +1,62 @@
71737 +#include <linux/kernel.h>
71738 +#include <linux/sched.h>
71739 +#include <linux/mount.h>
71740 +#include <linux/grsecurity.h>
71741 +#include <linux/grinternal.h>
71742 +
71743 +void
71744 +gr_log_remount(const char *devname, const int retval)
71745 +{
71746 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
71747 + if (grsec_enable_mount && (retval >= 0))
71748 + gr_log_str(GR_DO_AUDIT, GR_REMOUNT_AUDIT_MSG, devname ? devname : "none");
71749 +#endif
71750 + return;
71751 +}
71752 +
71753 +void
71754 +gr_log_unmount(const char *devname, const int retval)
71755 +{
71756 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
71757 + if (grsec_enable_mount && (retval >= 0))
71758 + gr_log_str(GR_DO_AUDIT, GR_UNMOUNT_AUDIT_MSG, devname ? devname : "none");
71759 +#endif
71760 + return;
71761 +}
71762 +
71763 +void
71764 +gr_log_mount(const char *from, const char *to, const int retval)
71765 +{
71766 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
71767 + if (grsec_enable_mount && (retval >= 0))
71768 + gr_log_str_str(GR_DO_AUDIT, GR_MOUNT_AUDIT_MSG, from ? from : "none", to);
71769 +#endif
71770 + return;
71771 +}
71772 +
71773 +int
71774 +gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags)
71775 +{
71776 +#ifdef CONFIG_GRKERNSEC_ROFS
71777 + if (grsec_enable_rofs && !(mnt_flags & MNT_READONLY)) {
71778 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_MOUNT_MSG, dentry, mnt);
71779 + return -EPERM;
71780 + } else
71781 + return 0;
71782 +#endif
71783 + return 0;
71784 +}
71785 +
71786 +int
71787 +gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode)
71788 +{
71789 +#ifdef CONFIG_GRKERNSEC_ROFS
71790 + if (grsec_enable_rofs && (acc_mode & MAY_WRITE) &&
71791 + dentry->d_inode && S_ISBLK(dentry->d_inode->i_mode)) {
71792 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_BLOCKWRITE_MSG, dentry, mnt);
71793 + return -EPERM;
71794 + } else
71795 + return 0;
71796 +#endif
71797 + return 0;
71798 +}
71799 diff --git a/grsecurity/grsec_pax.c b/grsecurity/grsec_pax.c
71800 new file mode 100644
71801 index 0000000..6ee9d50
71802 --- /dev/null
71803 +++ b/grsecurity/grsec_pax.c
71804 @@ -0,0 +1,45 @@
71805 +#include <linux/kernel.h>
71806 +#include <linux/sched.h>
71807 +#include <linux/mm.h>
71808 +#include <linux/file.h>
71809 +#include <linux/grinternal.h>
71810 +#include <linux/grsecurity.h>
71811 +
71812 +void
71813 +gr_log_textrel(struct vm_area_struct * vma)
71814 +{
71815 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
71816 + if (grsec_enable_log_rwxmaps)
71817 + gr_log_textrel_ulong_ulong(GR_DONT_AUDIT, GR_TEXTREL_AUDIT_MSG, vma->vm_file, vma->vm_start, vma->vm_pgoff);
71818 +#endif
71819 + return;
71820 +}
71821 +
71822 +void gr_log_ptgnustack(struct file *file)
71823 +{
71824 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
71825 + if (grsec_enable_log_rwxmaps)
71826 + gr_log_rwxmap(GR_DONT_AUDIT, GR_PTGNUSTACK_MSG, file);
71827 +#endif
71828 + return;
71829 +}
71830 +
71831 +void
71832 +gr_log_rwxmmap(struct file *file)
71833 +{
71834 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
71835 + if (grsec_enable_log_rwxmaps)
71836 + gr_log_rwxmap(GR_DONT_AUDIT, GR_RWXMMAP_MSG, file);
71837 +#endif
71838 + return;
71839 +}
71840 +
71841 +void
71842 +gr_log_rwxmprotect(struct vm_area_struct *vma)
71843 +{
71844 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
71845 + if (grsec_enable_log_rwxmaps)
71846 + gr_log_rwxmap_vma(GR_DONT_AUDIT, GR_RWXMPROTECT_MSG, vma);
71847 +#endif
71848 + return;
71849 +}
71850 diff --git a/grsecurity/grsec_ptrace.c b/grsecurity/grsec_ptrace.c
71851 new file mode 100644
71852 index 0000000..f7f29aa
71853 --- /dev/null
71854 +++ b/grsecurity/grsec_ptrace.c
71855 @@ -0,0 +1,30 @@
71856 +#include <linux/kernel.h>
71857 +#include <linux/sched.h>
71858 +#include <linux/grinternal.h>
71859 +#include <linux/security.h>
71860 +
71861 +void
71862 +gr_audit_ptrace(struct task_struct *task)
71863 +{
71864 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
71865 + if (grsec_enable_audit_ptrace)
71866 + gr_log_ptrace(GR_DO_AUDIT, GR_PTRACE_AUDIT_MSG, task);
71867 +#endif
71868 + return;
71869 +}
71870 +
71871 +int
71872 +gr_ptrace_readexec(struct file *file, int unsafe_flags)
71873 +{
71874 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
71875 + const struct dentry *dentry = file->f_path.dentry;
71876 + const struct vfsmount *mnt = file->f_path.mnt;
71877 +
71878 + if (grsec_enable_ptrace_readexec && (unsafe_flags & LSM_UNSAFE_PTRACE) &&
71879 + (inode_permission(dentry->d_inode, MAY_READ) || !gr_acl_handle_open(dentry, mnt, MAY_READ))) {
71880 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_READEXEC_MSG, dentry, mnt);
71881 + return -EACCES;
71882 + }
71883 +#endif
71884 + return 0;
71885 +}
71886 diff --git a/grsecurity/grsec_sig.c b/grsecurity/grsec_sig.c
71887 new file mode 100644
71888 index 0000000..3860c7e
71889 --- /dev/null
71890 +++ b/grsecurity/grsec_sig.c
71891 @@ -0,0 +1,236 @@
71892 +#include <linux/kernel.h>
71893 +#include <linux/sched.h>
71894 +#include <linux/fs.h>
71895 +#include <linux/delay.h>
71896 +#include <linux/grsecurity.h>
71897 +#include <linux/grinternal.h>
71898 +#include <linux/hardirq.h>
71899 +
71900 +char *signames[] = {
71901 + [SIGSEGV] = "Segmentation fault",
71902 + [SIGILL] = "Illegal instruction",
71903 + [SIGABRT] = "Abort",
71904 + [SIGBUS] = "Invalid alignment/Bus error"
71905 +};
71906 +
71907 +void
71908 +gr_log_signal(const int sig, const void *addr, const struct task_struct *t)
71909 +{
71910 +#ifdef CONFIG_GRKERNSEC_SIGNAL
71911 + if (grsec_enable_signal && ((sig == SIGSEGV) || (sig == SIGILL) ||
71912 + (sig == SIGABRT) || (sig == SIGBUS))) {
71913 + if (task_pid_nr(t) == task_pid_nr(current)) {
71914 + gr_log_sig_addr(GR_DONT_AUDIT_GOOD, GR_UNISIGLOG_MSG, signames[sig], addr);
71915 + } else {
71916 + gr_log_sig_task(GR_DONT_AUDIT_GOOD, GR_DUALSIGLOG_MSG, t, sig);
71917 + }
71918 + }
71919 +#endif
71920 + return;
71921 +}
71922 +
71923 +int
71924 +gr_handle_signal(const struct task_struct *p, const int sig)
71925 +{
71926 +#ifdef CONFIG_GRKERNSEC
71927 + /* ignore the 0 signal for protected task checks */
71928 + if (task_pid_nr(current) > 1 && sig && gr_check_protected_task(p)) {
71929 + gr_log_sig_task(GR_DONT_AUDIT, GR_SIG_ACL_MSG, p, sig);
71930 + return -EPERM;
71931 + } else if (gr_pid_is_chrooted((struct task_struct *)p)) {
71932 + return -EPERM;
71933 + }
71934 +#endif
71935 + return 0;
71936 +}
71937 +
71938 +#ifdef CONFIG_GRKERNSEC
71939 +extern int specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t);
71940 +
71941 +int gr_fake_force_sig(int sig, struct task_struct *t)
71942 +{
71943 + unsigned long int flags;
71944 + int ret, blocked, ignored;
71945 + struct k_sigaction *action;
71946 +
71947 + spin_lock_irqsave(&t->sighand->siglock, flags);
71948 + action = &t->sighand->action[sig-1];
71949 + ignored = action->sa.sa_handler == SIG_IGN;
71950 + blocked = sigismember(&t->blocked, sig);
71951 + if (blocked || ignored) {
71952 + action->sa.sa_handler = SIG_DFL;
71953 + if (blocked) {
71954 + sigdelset(&t->blocked, sig);
71955 + recalc_sigpending_and_wake(t);
71956 + }
71957 + }
71958 + if (action->sa.sa_handler == SIG_DFL)
71959 + t->signal->flags &= ~SIGNAL_UNKILLABLE;
71960 + ret = specific_send_sig_info(sig, SEND_SIG_PRIV, t);
71961 +
71962 + spin_unlock_irqrestore(&t->sighand->siglock, flags);
71963 +
71964 + return ret;
71965 +}
71966 +#endif
71967 +
71968 +#define GR_USER_BAN_TIME (15 * 60)
71969 +#define GR_DAEMON_BRUTE_TIME (30 * 60)
71970 +
71971 +void gr_handle_brute_attach(int dumpable)
71972 +{
71973 +#ifdef CONFIG_GRKERNSEC_BRUTE
71974 + struct task_struct *p = current;
71975 + kuid_t uid = GLOBAL_ROOT_UID;
71976 + int daemon = 0;
71977 +
71978 + if (!grsec_enable_brute)
71979 + return;
71980 +
71981 + rcu_read_lock();
71982 + read_lock(&tasklist_lock);
71983 + read_lock(&grsec_exec_file_lock);
71984 + if (p->real_parent && gr_is_same_file(p->real_parent->exec_file, p->exec_file)) {
71985 + p->real_parent->brute_expires = get_seconds() + GR_DAEMON_BRUTE_TIME;
71986 + p->real_parent->brute = 1;
71987 + daemon = 1;
71988 + } else {
71989 + const struct cred *cred = __task_cred(p), *cred2;
71990 + struct task_struct *tsk, *tsk2;
71991 +
71992 + if (dumpable != SUID_DUMP_USER && gr_is_global_nonroot(cred->uid)) {
71993 + struct user_struct *user;
71994 +
71995 + uid = cred->uid;
71996 +
71997 + /* this is put upon execution past expiration */
71998 + user = find_user(uid);
71999 + if (user == NULL)
72000 + goto unlock;
72001 + user->suid_banned = 1;
72002 + user->suid_ban_expires = get_seconds() + GR_USER_BAN_TIME;
72003 + if (user->suid_ban_expires == ~0UL)
72004 + user->suid_ban_expires--;
72005 +
72006 + /* only kill other threads of the same binary, from the same user */
72007 + do_each_thread(tsk2, tsk) {
72008 + cred2 = __task_cred(tsk);
72009 + if (tsk != p && uid_eq(cred2->uid, uid) && gr_is_same_file(tsk->exec_file, p->exec_file))
72010 + gr_fake_force_sig(SIGKILL, tsk);
72011 + } while_each_thread(tsk2, tsk);
72012 + }
72013 + }
72014 +unlock:
72015 + read_unlock(&grsec_exec_file_lock);
72016 + read_unlock(&tasklist_lock);
72017 + rcu_read_unlock();
72018 +
72019 + if (gr_is_global_nonroot(uid))
72020 + 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);
72021 + else if (daemon)
72022 + gr_log_noargs(GR_DONT_AUDIT, GR_BRUTE_DAEMON_MSG);
72023 +
72024 +#endif
72025 + return;
72026 +}
72027 +
72028 +void gr_handle_brute_check(void)
72029 +{
72030 +#ifdef CONFIG_GRKERNSEC_BRUTE
72031 + struct task_struct *p = current;
72032 +
72033 + if (unlikely(p->brute)) {
72034 + if (!grsec_enable_brute)
72035 + p->brute = 0;
72036 + else if (time_before(get_seconds(), p->brute_expires))
72037 + msleep(30 * 1000);
72038 + }
72039 +#endif
72040 + return;
72041 +}
72042 +
72043 +void gr_handle_kernel_exploit(void)
72044 +{
72045 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
72046 + const struct cred *cred;
72047 + struct task_struct *tsk, *tsk2;
72048 + struct user_struct *user;
72049 + kuid_t uid;
72050 +
72051 + if (in_irq() || in_serving_softirq() || in_nmi())
72052 + panic("grsec: halting the system due to suspicious kernel crash caused in interrupt context");
72053 +
72054 + uid = current_uid();
72055 +
72056 + if (gr_is_global_root(uid))
72057 + panic("grsec: halting the system due to suspicious kernel crash caused by root");
72058 + else {
72059 + /* kill all the processes of this user, hold a reference
72060 + to their creds struct, and prevent them from creating
72061 + another process until system reset
72062 + */
72063 + printk(KERN_ALERT "grsec: banning user with uid %u until system restart for suspicious kernel crash\n",
72064 + GR_GLOBAL_UID(uid));
72065 + /* we intentionally leak this ref */
72066 + user = get_uid(current->cred->user);
72067 + if (user)
72068 + user->kernel_banned = 1;
72069 +
72070 + /* kill all processes of this user */
72071 + read_lock(&tasklist_lock);
72072 + do_each_thread(tsk2, tsk) {
72073 + cred = __task_cred(tsk);
72074 + if (uid_eq(cred->uid, uid))
72075 + gr_fake_force_sig(SIGKILL, tsk);
72076 + } while_each_thread(tsk2, tsk);
72077 + read_unlock(&tasklist_lock);
72078 + }
72079 +#endif
72080 +}
72081 +
72082 +#ifdef CONFIG_GRKERNSEC_BRUTE
72083 +static bool suid_ban_expired(struct user_struct *user)
72084 +{
72085 + if (user->suid_ban_expires != ~0UL && time_after_eq(get_seconds(), user->suid_ban_expires)) {
72086 + user->suid_banned = 0;
72087 + user->suid_ban_expires = 0;
72088 + free_uid(user);
72089 + return true;
72090 + }
72091 +
72092 + return false;
72093 +}
72094 +#endif
72095 +
72096 +int gr_process_kernel_exec_ban(void)
72097 +{
72098 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
72099 + if (unlikely(current->cred->user->kernel_banned))
72100 + return -EPERM;
72101 +#endif
72102 + return 0;
72103 +}
72104 +
72105 +int gr_process_kernel_setuid_ban(struct user_struct *user)
72106 +{
72107 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
72108 + if (unlikely(user->kernel_banned))
72109 + gr_fake_force_sig(SIGKILL, current);
72110 +#endif
72111 + return 0;
72112 +}
72113 +
72114 +int gr_process_suid_exec_ban(const struct linux_binprm *bprm)
72115 +{
72116 +#ifdef CONFIG_GRKERNSEC_BRUTE
72117 + struct user_struct *user = current->cred->user;
72118 + if (unlikely(user->suid_banned)) {
72119 + if (suid_ban_expired(user))
72120 + return 0;
72121 + /* disallow execution of suid binaries only */
72122 + else if (!uid_eq(bprm->cred->euid, current->cred->uid))
72123 + return -EPERM;
72124 + }
72125 +#endif
72126 + return 0;
72127 +}
72128 diff --git a/grsecurity/grsec_sock.c b/grsecurity/grsec_sock.c
72129 new file mode 100644
72130 index 0000000..4030d57
72131 --- /dev/null
72132 +++ b/grsecurity/grsec_sock.c
72133 @@ -0,0 +1,244 @@
72134 +#include <linux/kernel.h>
72135 +#include <linux/module.h>
72136 +#include <linux/sched.h>
72137 +#include <linux/file.h>
72138 +#include <linux/net.h>
72139 +#include <linux/in.h>
72140 +#include <linux/ip.h>
72141 +#include <net/sock.h>
72142 +#include <net/inet_sock.h>
72143 +#include <linux/grsecurity.h>
72144 +#include <linux/grinternal.h>
72145 +#include <linux/gracl.h>
72146 +
72147 +extern int gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb);
72148 +extern int gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr);
72149 +
72150 +EXPORT_SYMBOL(gr_search_udp_recvmsg);
72151 +EXPORT_SYMBOL(gr_search_udp_sendmsg);
72152 +
72153 +#ifdef CONFIG_UNIX_MODULE
72154 +EXPORT_SYMBOL(gr_acl_handle_unix);
72155 +EXPORT_SYMBOL(gr_acl_handle_mknod);
72156 +EXPORT_SYMBOL(gr_handle_chroot_unix);
72157 +EXPORT_SYMBOL(gr_handle_create);
72158 +#endif
72159 +
72160 +#ifdef CONFIG_GRKERNSEC
72161 +#define gr_conn_table_size 32749
72162 +struct conn_table_entry {
72163 + struct conn_table_entry *next;
72164 + struct signal_struct *sig;
72165 +};
72166 +
72167 +struct conn_table_entry *gr_conn_table[gr_conn_table_size];
72168 +DEFINE_SPINLOCK(gr_conn_table_lock);
72169 +
72170 +extern const char * gr_socktype_to_name(unsigned char type);
72171 +extern const char * gr_proto_to_name(unsigned char proto);
72172 +extern const char * gr_sockfamily_to_name(unsigned char family);
72173 +
72174 +static __inline__ int
72175 +conn_hash(__u32 saddr, __u32 daddr, __u16 sport, __u16 dport, unsigned int size)
72176 +{
72177 + return ((daddr + saddr + (sport << 8) + (dport << 16)) % size);
72178 +}
72179 +
72180 +static __inline__ int
72181 +conn_match(const struct signal_struct *sig, __u32 saddr, __u32 daddr,
72182 + __u16 sport, __u16 dport)
72183 +{
72184 + if (unlikely(sig->gr_saddr == saddr && sig->gr_daddr == daddr &&
72185 + sig->gr_sport == sport && sig->gr_dport == dport))
72186 + return 1;
72187 + else
72188 + return 0;
72189 +}
72190 +
72191 +static void gr_add_to_task_ip_table_nolock(struct signal_struct *sig, struct conn_table_entry *newent)
72192 +{
72193 + struct conn_table_entry **match;
72194 + unsigned int index;
72195 +
72196 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
72197 + sig->gr_sport, sig->gr_dport,
72198 + gr_conn_table_size);
72199 +
72200 + newent->sig = sig;
72201 +
72202 + match = &gr_conn_table[index];
72203 + newent->next = *match;
72204 + *match = newent;
72205 +
72206 + return;
72207 +}
72208 +
72209 +static void gr_del_task_from_ip_table_nolock(struct signal_struct *sig)
72210 +{
72211 + struct conn_table_entry *match, *last = NULL;
72212 + unsigned int index;
72213 +
72214 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
72215 + sig->gr_sport, sig->gr_dport,
72216 + gr_conn_table_size);
72217 +
72218 + match = gr_conn_table[index];
72219 + while (match && !conn_match(match->sig,
72220 + sig->gr_saddr, sig->gr_daddr, sig->gr_sport,
72221 + sig->gr_dport)) {
72222 + last = match;
72223 + match = match->next;
72224 + }
72225 +
72226 + if (match) {
72227 + if (last)
72228 + last->next = match->next;
72229 + else
72230 + gr_conn_table[index] = NULL;
72231 + kfree(match);
72232 + }
72233 +
72234 + return;
72235 +}
72236 +
72237 +static struct signal_struct * gr_lookup_task_ip_table(__u32 saddr, __u32 daddr,
72238 + __u16 sport, __u16 dport)
72239 +{
72240 + struct conn_table_entry *match;
72241 + unsigned int index;
72242 +
72243 + index = conn_hash(saddr, daddr, sport, dport, gr_conn_table_size);
72244 +
72245 + match = gr_conn_table[index];
72246 + while (match && !conn_match(match->sig, saddr, daddr, sport, dport))
72247 + match = match->next;
72248 +
72249 + if (match)
72250 + return match->sig;
72251 + else
72252 + return NULL;
72253 +}
72254 +
72255 +#endif
72256 +
72257 +void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet)
72258 +{
72259 +#ifdef CONFIG_GRKERNSEC
72260 + struct signal_struct *sig = task->signal;
72261 + struct conn_table_entry *newent;
72262 +
72263 + newent = kmalloc(sizeof(struct conn_table_entry), GFP_ATOMIC);
72264 + if (newent == NULL)
72265 + return;
72266 + /* no bh lock needed since we are called with bh disabled */
72267 + spin_lock(&gr_conn_table_lock);
72268 + gr_del_task_from_ip_table_nolock(sig);
72269 + sig->gr_saddr = inet->inet_rcv_saddr;
72270 + sig->gr_daddr = inet->inet_daddr;
72271 + sig->gr_sport = inet->inet_sport;
72272 + sig->gr_dport = inet->inet_dport;
72273 + gr_add_to_task_ip_table_nolock(sig, newent);
72274 + spin_unlock(&gr_conn_table_lock);
72275 +#endif
72276 + return;
72277 +}
72278 +
72279 +void gr_del_task_from_ip_table(struct task_struct *task)
72280 +{
72281 +#ifdef CONFIG_GRKERNSEC
72282 + spin_lock_bh(&gr_conn_table_lock);
72283 + gr_del_task_from_ip_table_nolock(task->signal);
72284 + spin_unlock_bh(&gr_conn_table_lock);
72285 +#endif
72286 + return;
72287 +}
72288 +
72289 +void
72290 +gr_attach_curr_ip(const struct sock *sk)
72291 +{
72292 +#ifdef CONFIG_GRKERNSEC
72293 + struct signal_struct *p, *set;
72294 + const struct inet_sock *inet = inet_sk(sk);
72295 +
72296 + if (unlikely(sk->sk_protocol != IPPROTO_TCP))
72297 + return;
72298 +
72299 + set = current->signal;
72300 +
72301 + spin_lock_bh(&gr_conn_table_lock);
72302 + p = gr_lookup_task_ip_table(inet->inet_daddr, inet->inet_rcv_saddr,
72303 + inet->inet_dport, inet->inet_sport);
72304 + if (unlikely(p != NULL)) {
72305 + set->curr_ip = p->curr_ip;
72306 + set->used_accept = 1;
72307 + gr_del_task_from_ip_table_nolock(p);
72308 + spin_unlock_bh(&gr_conn_table_lock);
72309 + return;
72310 + }
72311 + spin_unlock_bh(&gr_conn_table_lock);
72312 +
72313 + set->curr_ip = inet->inet_daddr;
72314 + set->used_accept = 1;
72315 +#endif
72316 + return;
72317 +}
72318 +
72319 +int
72320 +gr_handle_sock_all(const int family, const int type, const int protocol)
72321 +{
72322 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
72323 + if (grsec_enable_socket_all && in_group_p(grsec_socket_all_gid) &&
72324 + (family != AF_UNIX)) {
72325 + if (family == AF_INET)
72326 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), gr_proto_to_name(protocol));
72327 + else
72328 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), protocol);
72329 + return -EACCES;
72330 + }
72331 +#endif
72332 + return 0;
72333 +}
72334 +
72335 +int
72336 +gr_handle_sock_server(const struct sockaddr *sck)
72337 +{
72338 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
72339 + if (grsec_enable_socket_server &&
72340 + in_group_p(grsec_socket_server_gid) &&
72341 + sck && (sck->sa_family != AF_UNIX) &&
72342 + (sck->sa_family != AF_LOCAL)) {
72343 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
72344 + return -EACCES;
72345 + }
72346 +#endif
72347 + return 0;
72348 +}
72349 +
72350 +int
72351 +gr_handle_sock_server_other(const struct sock *sck)
72352 +{
72353 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
72354 + if (grsec_enable_socket_server &&
72355 + in_group_p(grsec_socket_server_gid) &&
72356 + sck && (sck->sk_family != AF_UNIX) &&
72357 + (sck->sk_family != AF_LOCAL)) {
72358 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
72359 + return -EACCES;
72360 + }
72361 +#endif
72362 + return 0;
72363 +}
72364 +
72365 +int
72366 +gr_handle_sock_client(const struct sockaddr *sck)
72367 +{
72368 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
72369 + if (grsec_enable_socket_client && in_group_p(grsec_socket_client_gid) &&
72370 + sck && (sck->sa_family != AF_UNIX) &&
72371 + (sck->sa_family != AF_LOCAL)) {
72372 + gr_log_noargs(GR_DONT_AUDIT, GR_CONNECT_MSG);
72373 + return -EACCES;
72374 + }
72375 +#endif
72376 + return 0;
72377 +}
72378 diff --git a/grsecurity/grsec_sysctl.c b/grsecurity/grsec_sysctl.c
72379 new file mode 100644
72380 index 0000000..8159888
72381 --- /dev/null
72382 +++ b/grsecurity/grsec_sysctl.c
72383 @@ -0,0 +1,479 @@
72384 +#include <linux/kernel.h>
72385 +#include <linux/sched.h>
72386 +#include <linux/sysctl.h>
72387 +#include <linux/grsecurity.h>
72388 +#include <linux/grinternal.h>
72389 +
72390 +int
72391 +gr_handle_sysctl_mod(const char *dirname, const char *name, const int op)
72392 +{
72393 +#ifdef CONFIG_GRKERNSEC_SYSCTL
72394 + if (dirname == NULL || name == NULL)
72395 + return 0;
72396 + if (!strcmp(dirname, "grsecurity") && grsec_lock && (op & MAY_WRITE)) {
72397 + gr_log_str(GR_DONT_AUDIT, GR_SYSCTL_MSG, name);
72398 + return -EACCES;
72399 + }
72400 +#endif
72401 + return 0;
72402 +}
72403 +
72404 +#if defined(CONFIG_GRKERNSEC_ROFS) || defined(CONFIG_GRKERNSEC_DENYUSB)
72405 +static int __maybe_unused __read_only one = 1;
72406 +#endif
72407 +
72408 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS) || \
72409 + defined(CONFIG_GRKERNSEC_DENYUSB)
72410 +struct ctl_table grsecurity_table[] = {
72411 +#ifdef CONFIG_GRKERNSEC_SYSCTL
72412 +#ifdef CONFIG_GRKERNSEC_SYSCTL_DISTRO
72413 +#ifdef CONFIG_GRKERNSEC_IO
72414 + {
72415 + .procname = "disable_priv_io",
72416 + .data = &grsec_disable_privio,
72417 + .maxlen = sizeof(int),
72418 + .mode = 0600,
72419 + .proc_handler = &proc_dointvec,
72420 + },
72421 +#endif
72422 +#endif
72423 +#ifdef CONFIG_GRKERNSEC_LINK
72424 + {
72425 + .procname = "linking_restrictions",
72426 + .data = &grsec_enable_link,
72427 + .maxlen = sizeof(int),
72428 + .mode = 0600,
72429 + .proc_handler = &proc_dointvec,
72430 + },
72431 +#endif
72432 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
72433 + {
72434 + .procname = "enforce_symlinksifowner",
72435 + .data = &grsec_enable_symlinkown,
72436 + .maxlen = sizeof(int),
72437 + .mode = 0600,
72438 + .proc_handler = &proc_dointvec,
72439 + },
72440 + {
72441 + .procname = "symlinkown_gid",
72442 + .data = &grsec_symlinkown_gid,
72443 + .maxlen = sizeof(int),
72444 + .mode = 0600,
72445 + .proc_handler = &proc_dointvec,
72446 + },
72447 +#endif
72448 +#ifdef CONFIG_GRKERNSEC_BRUTE
72449 + {
72450 + .procname = "deter_bruteforce",
72451 + .data = &grsec_enable_brute,
72452 + .maxlen = sizeof(int),
72453 + .mode = 0600,
72454 + .proc_handler = &proc_dointvec,
72455 + },
72456 +#endif
72457 +#ifdef CONFIG_GRKERNSEC_FIFO
72458 + {
72459 + .procname = "fifo_restrictions",
72460 + .data = &grsec_enable_fifo,
72461 + .maxlen = sizeof(int),
72462 + .mode = 0600,
72463 + .proc_handler = &proc_dointvec,
72464 + },
72465 +#endif
72466 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
72467 + {
72468 + .procname = "ptrace_readexec",
72469 + .data = &grsec_enable_ptrace_readexec,
72470 + .maxlen = sizeof(int),
72471 + .mode = 0600,
72472 + .proc_handler = &proc_dointvec,
72473 + },
72474 +#endif
72475 +#ifdef CONFIG_GRKERNSEC_SETXID
72476 + {
72477 + .procname = "consistent_setxid",
72478 + .data = &grsec_enable_setxid,
72479 + .maxlen = sizeof(int),
72480 + .mode = 0600,
72481 + .proc_handler = &proc_dointvec,
72482 + },
72483 +#endif
72484 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
72485 + {
72486 + .procname = "ip_blackhole",
72487 + .data = &grsec_enable_blackhole,
72488 + .maxlen = sizeof(int),
72489 + .mode = 0600,
72490 + .proc_handler = &proc_dointvec,
72491 + },
72492 + {
72493 + .procname = "lastack_retries",
72494 + .data = &grsec_lastack_retries,
72495 + .maxlen = sizeof(int),
72496 + .mode = 0600,
72497 + .proc_handler = &proc_dointvec,
72498 + },
72499 +#endif
72500 +#ifdef CONFIG_GRKERNSEC_EXECLOG
72501 + {
72502 + .procname = "exec_logging",
72503 + .data = &grsec_enable_execlog,
72504 + .maxlen = sizeof(int),
72505 + .mode = 0600,
72506 + .proc_handler = &proc_dointvec,
72507 + },
72508 +#endif
72509 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
72510 + {
72511 + .procname = "rwxmap_logging",
72512 + .data = &grsec_enable_log_rwxmaps,
72513 + .maxlen = sizeof(int),
72514 + .mode = 0600,
72515 + .proc_handler = &proc_dointvec,
72516 + },
72517 +#endif
72518 +#ifdef CONFIG_GRKERNSEC_SIGNAL
72519 + {
72520 + .procname = "signal_logging",
72521 + .data = &grsec_enable_signal,
72522 + .maxlen = sizeof(int),
72523 + .mode = 0600,
72524 + .proc_handler = &proc_dointvec,
72525 + },
72526 +#endif
72527 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
72528 + {
72529 + .procname = "forkfail_logging",
72530 + .data = &grsec_enable_forkfail,
72531 + .maxlen = sizeof(int),
72532 + .mode = 0600,
72533 + .proc_handler = &proc_dointvec,
72534 + },
72535 +#endif
72536 +#ifdef CONFIG_GRKERNSEC_TIME
72537 + {
72538 + .procname = "timechange_logging",
72539 + .data = &grsec_enable_time,
72540 + .maxlen = sizeof(int),
72541 + .mode = 0600,
72542 + .proc_handler = &proc_dointvec,
72543 + },
72544 +#endif
72545 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
72546 + {
72547 + .procname = "chroot_deny_shmat",
72548 + .data = &grsec_enable_chroot_shmat,
72549 + .maxlen = sizeof(int),
72550 + .mode = 0600,
72551 + .proc_handler = &proc_dointvec,
72552 + },
72553 +#endif
72554 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
72555 + {
72556 + .procname = "chroot_deny_unix",
72557 + .data = &grsec_enable_chroot_unix,
72558 + .maxlen = sizeof(int),
72559 + .mode = 0600,
72560 + .proc_handler = &proc_dointvec,
72561 + },
72562 +#endif
72563 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
72564 + {
72565 + .procname = "chroot_deny_mount",
72566 + .data = &grsec_enable_chroot_mount,
72567 + .maxlen = sizeof(int),
72568 + .mode = 0600,
72569 + .proc_handler = &proc_dointvec,
72570 + },
72571 +#endif
72572 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
72573 + {
72574 + .procname = "chroot_deny_fchdir",
72575 + .data = &grsec_enable_chroot_fchdir,
72576 + .maxlen = sizeof(int),
72577 + .mode = 0600,
72578 + .proc_handler = &proc_dointvec,
72579 + },
72580 +#endif
72581 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
72582 + {
72583 + .procname = "chroot_deny_chroot",
72584 + .data = &grsec_enable_chroot_double,
72585 + .maxlen = sizeof(int),
72586 + .mode = 0600,
72587 + .proc_handler = &proc_dointvec,
72588 + },
72589 +#endif
72590 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
72591 + {
72592 + .procname = "chroot_deny_pivot",
72593 + .data = &grsec_enable_chroot_pivot,
72594 + .maxlen = sizeof(int),
72595 + .mode = 0600,
72596 + .proc_handler = &proc_dointvec,
72597 + },
72598 +#endif
72599 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
72600 + {
72601 + .procname = "chroot_enforce_chdir",
72602 + .data = &grsec_enable_chroot_chdir,
72603 + .maxlen = sizeof(int),
72604 + .mode = 0600,
72605 + .proc_handler = &proc_dointvec,
72606 + },
72607 +#endif
72608 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
72609 + {
72610 + .procname = "chroot_deny_chmod",
72611 + .data = &grsec_enable_chroot_chmod,
72612 + .maxlen = sizeof(int),
72613 + .mode = 0600,
72614 + .proc_handler = &proc_dointvec,
72615 + },
72616 +#endif
72617 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
72618 + {
72619 + .procname = "chroot_deny_mknod",
72620 + .data = &grsec_enable_chroot_mknod,
72621 + .maxlen = sizeof(int),
72622 + .mode = 0600,
72623 + .proc_handler = &proc_dointvec,
72624 + },
72625 +#endif
72626 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
72627 + {
72628 + .procname = "chroot_restrict_nice",
72629 + .data = &grsec_enable_chroot_nice,
72630 + .maxlen = sizeof(int),
72631 + .mode = 0600,
72632 + .proc_handler = &proc_dointvec,
72633 + },
72634 +#endif
72635 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
72636 + {
72637 + .procname = "chroot_execlog",
72638 + .data = &grsec_enable_chroot_execlog,
72639 + .maxlen = sizeof(int),
72640 + .mode = 0600,
72641 + .proc_handler = &proc_dointvec,
72642 + },
72643 +#endif
72644 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
72645 + {
72646 + .procname = "chroot_caps",
72647 + .data = &grsec_enable_chroot_caps,
72648 + .maxlen = sizeof(int),
72649 + .mode = 0600,
72650 + .proc_handler = &proc_dointvec,
72651 + },
72652 +#endif
72653 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
72654 + {
72655 + .procname = "chroot_deny_sysctl",
72656 + .data = &grsec_enable_chroot_sysctl,
72657 + .maxlen = sizeof(int),
72658 + .mode = 0600,
72659 + .proc_handler = &proc_dointvec,
72660 + },
72661 +#endif
72662 +#ifdef CONFIG_GRKERNSEC_TPE
72663 + {
72664 + .procname = "tpe",
72665 + .data = &grsec_enable_tpe,
72666 + .maxlen = sizeof(int),
72667 + .mode = 0600,
72668 + .proc_handler = &proc_dointvec,
72669 + },
72670 + {
72671 + .procname = "tpe_gid",
72672 + .data = &grsec_tpe_gid,
72673 + .maxlen = sizeof(int),
72674 + .mode = 0600,
72675 + .proc_handler = &proc_dointvec,
72676 + },
72677 +#endif
72678 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
72679 + {
72680 + .procname = "tpe_invert",
72681 + .data = &grsec_enable_tpe_invert,
72682 + .maxlen = sizeof(int),
72683 + .mode = 0600,
72684 + .proc_handler = &proc_dointvec,
72685 + },
72686 +#endif
72687 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
72688 + {
72689 + .procname = "tpe_restrict_all",
72690 + .data = &grsec_enable_tpe_all,
72691 + .maxlen = sizeof(int),
72692 + .mode = 0600,
72693 + .proc_handler = &proc_dointvec,
72694 + },
72695 +#endif
72696 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
72697 + {
72698 + .procname = "socket_all",
72699 + .data = &grsec_enable_socket_all,
72700 + .maxlen = sizeof(int),
72701 + .mode = 0600,
72702 + .proc_handler = &proc_dointvec,
72703 + },
72704 + {
72705 + .procname = "socket_all_gid",
72706 + .data = &grsec_socket_all_gid,
72707 + .maxlen = sizeof(int),
72708 + .mode = 0600,
72709 + .proc_handler = &proc_dointvec,
72710 + },
72711 +#endif
72712 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
72713 + {
72714 + .procname = "socket_client",
72715 + .data = &grsec_enable_socket_client,
72716 + .maxlen = sizeof(int),
72717 + .mode = 0600,
72718 + .proc_handler = &proc_dointvec,
72719 + },
72720 + {
72721 + .procname = "socket_client_gid",
72722 + .data = &grsec_socket_client_gid,
72723 + .maxlen = sizeof(int),
72724 + .mode = 0600,
72725 + .proc_handler = &proc_dointvec,
72726 + },
72727 +#endif
72728 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
72729 + {
72730 + .procname = "socket_server",
72731 + .data = &grsec_enable_socket_server,
72732 + .maxlen = sizeof(int),
72733 + .mode = 0600,
72734 + .proc_handler = &proc_dointvec,
72735 + },
72736 + {
72737 + .procname = "socket_server_gid",
72738 + .data = &grsec_socket_server_gid,
72739 + .maxlen = sizeof(int),
72740 + .mode = 0600,
72741 + .proc_handler = &proc_dointvec,
72742 + },
72743 +#endif
72744 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
72745 + {
72746 + .procname = "audit_group",
72747 + .data = &grsec_enable_group,
72748 + .maxlen = sizeof(int),
72749 + .mode = 0600,
72750 + .proc_handler = &proc_dointvec,
72751 + },
72752 + {
72753 + .procname = "audit_gid",
72754 + .data = &grsec_audit_gid,
72755 + .maxlen = sizeof(int),
72756 + .mode = 0600,
72757 + .proc_handler = &proc_dointvec,
72758 + },
72759 +#endif
72760 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
72761 + {
72762 + .procname = "audit_chdir",
72763 + .data = &grsec_enable_chdir,
72764 + .maxlen = sizeof(int),
72765 + .mode = 0600,
72766 + .proc_handler = &proc_dointvec,
72767 + },
72768 +#endif
72769 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
72770 + {
72771 + .procname = "audit_mount",
72772 + .data = &grsec_enable_mount,
72773 + .maxlen = sizeof(int),
72774 + .mode = 0600,
72775 + .proc_handler = &proc_dointvec,
72776 + },
72777 +#endif
72778 +#ifdef CONFIG_GRKERNSEC_DMESG
72779 + {
72780 + .procname = "dmesg",
72781 + .data = &grsec_enable_dmesg,
72782 + .maxlen = sizeof(int),
72783 + .mode = 0600,
72784 + .proc_handler = &proc_dointvec,
72785 + },
72786 +#endif
72787 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
72788 + {
72789 + .procname = "chroot_findtask",
72790 + .data = &grsec_enable_chroot_findtask,
72791 + .maxlen = sizeof(int),
72792 + .mode = 0600,
72793 + .proc_handler = &proc_dointvec,
72794 + },
72795 +#endif
72796 +#ifdef CONFIG_GRKERNSEC_RESLOG
72797 + {
72798 + .procname = "resource_logging",
72799 + .data = &grsec_resource_logging,
72800 + .maxlen = sizeof(int),
72801 + .mode = 0600,
72802 + .proc_handler = &proc_dointvec,
72803 + },
72804 +#endif
72805 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
72806 + {
72807 + .procname = "audit_ptrace",
72808 + .data = &grsec_enable_audit_ptrace,
72809 + .maxlen = sizeof(int),
72810 + .mode = 0600,
72811 + .proc_handler = &proc_dointvec,
72812 + },
72813 +#endif
72814 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
72815 + {
72816 + .procname = "harden_ptrace",
72817 + .data = &grsec_enable_harden_ptrace,
72818 + .maxlen = sizeof(int),
72819 + .mode = 0600,
72820 + .proc_handler = &proc_dointvec,
72821 + },
72822 +#endif
72823 +#ifdef CONFIG_GRKERNSEC_HARDEN_IPC
72824 + {
72825 + .procname = "harden_ipc",
72826 + .data = &grsec_enable_harden_ipc,
72827 + .maxlen = sizeof(int),
72828 + .mode = 0600,
72829 + .proc_handler = &proc_dointvec,
72830 + },
72831 +#endif
72832 + {
72833 + .procname = "grsec_lock",
72834 + .data = &grsec_lock,
72835 + .maxlen = sizeof(int),
72836 + .mode = 0600,
72837 + .proc_handler = &proc_dointvec,
72838 + },
72839 +#endif
72840 +#ifdef CONFIG_GRKERNSEC_ROFS
72841 + {
72842 + .procname = "romount_protect",
72843 + .data = &grsec_enable_rofs,
72844 + .maxlen = sizeof(int),
72845 + .mode = 0600,
72846 + .proc_handler = &proc_dointvec_minmax,
72847 + .extra1 = &one,
72848 + .extra2 = &one,
72849 + },
72850 +#endif
72851 +#if defined(CONFIG_GRKERNSEC_DENYUSB) && !defined(CONFIG_GRKERNSEC_DENYUSB_FORCE)
72852 + {
72853 + .procname = "deny_new_usb",
72854 + .data = &grsec_deny_new_usb,
72855 + .maxlen = sizeof(int),
72856 + .mode = 0600,
72857 + .proc_handler = &proc_dointvec,
72858 + },
72859 +#endif
72860 + { }
72861 +};
72862 +#endif
72863 diff --git a/grsecurity/grsec_time.c b/grsecurity/grsec_time.c
72864 new file mode 100644
72865 index 0000000..0dc13c3
72866 --- /dev/null
72867 +++ b/grsecurity/grsec_time.c
72868 @@ -0,0 +1,16 @@
72869 +#include <linux/kernel.h>
72870 +#include <linux/sched.h>
72871 +#include <linux/grinternal.h>
72872 +#include <linux/module.h>
72873 +
72874 +void
72875 +gr_log_timechange(void)
72876 +{
72877 +#ifdef CONFIG_GRKERNSEC_TIME
72878 + if (grsec_enable_time)
72879 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_TIME_MSG);
72880 +#endif
72881 + return;
72882 +}
72883 +
72884 +EXPORT_SYMBOL(gr_log_timechange);
72885 diff --git a/grsecurity/grsec_tpe.c b/grsecurity/grsec_tpe.c
72886 new file mode 100644
72887 index 0000000..ee57dcf
72888 --- /dev/null
72889 +++ b/grsecurity/grsec_tpe.c
72890 @@ -0,0 +1,73 @@
72891 +#include <linux/kernel.h>
72892 +#include <linux/sched.h>
72893 +#include <linux/file.h>
72894 +#include <linux/fs.h>
72895 +#include <linux/grinternal.h>
72896 +
72897 +extern int gr_acl_tpe_check(void);
72898 +
72899 +int
72900 +gr_tpe_allow(const struct file *file)
72901 +{
72902 +#ifdef CONFIG_GRKERNSEC
72903 + struct inode *inode = file->f_path.dentry->d_parent->d_inode;
72904 + const struct cred *cred = current_cred();
72905 + char *msg = NULL;
72906 + char *msg2 = NULL;
72907 +
72908 + // never restrict root
72909 + if (gr_is_global_root(cred->uid))
72910 + return 1;
72911 +
72912 + if (grsec_enable_tpe) {
72913 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
72914 + if (grsec_enable_tpe_invert && !in_group_p(grsec_tpe_gid))
72915 + msg = "not being in trusted group";
72916 + else if (!grsec_enable_tpe_invert && in_group_p(grsec_tpe_gid))
72917 + msg = "being in untrusted group";
72918 +#else
72919 + if (in_group_p(grsec_tpe_gid))
72920 + msg = "being in untrusted group";
72921 +#endif
72922 + }
72923 + if (!msg && gr_acl_tpe_check())
72924 + msg = "being in untrusted role";
72925 +
72926 + // not in any affected group/role
72927 + if (!msg)
72928 + goto next_check;
72929 +
72930 + if (gr_is_global_nonroot(inode->i_uid))
72931 + msg2 = "file in non-root-owned directory";
72932 + else if (inode->i_mode & S_IWOTH)
72933 + msg2 = "file in world-writable directory";
72934 + else if (inode->i_mode & S_IWGRP)
72935 + msg2 = "file in group-writable directory";
72936 +
72937 + if (msg && msg2) {
72938 + char fullmsg[70] = {0};
72939 + snprintf(fullmsg, sizeof(fullmsg)-1, "%s and %s", msg, msg2);
72940 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, fullmsg, file->f_path.dentry, file->f_path.mnt);
72941 + return 0;
72942 + }
72943 + msg = NULL;
72944 +next_check:
72945 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
72946 + if (!grsec_enable_tpe || !grsec_enable_tpe_all)
72947 + return 1;
72948 +
72949 + if (gr_is_global_nonroot(inode->i_uid) && !uid_eq(inode->i_uid, cred->uid))
72950 + msg = "directory not owned by user";
72951 + else if (inode->i_mode & S_IWOTH)
72952 + msg = "file in world-writable directory";
72953 + else if (inode->i_mode & S_IWGRP)
72954 + msg = "file in group-writable directory";
72955 +
72956 + if (msg) {
72957 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, msg, file->f_path.dentry, file->f_path.mnt);
72958 + return 0;
72959 + }
72960 +#endif
72961 +#endif
72962 + return 1;
72963 +}
72964 diff --git a/grsecurity/grsec_usb.c b/grsecurity/grsec_usb.c
72965 new file mode 100644
72966 index 0000000..ae02d8e
72967 --- /dev/null
72968 +++ b/grsecurity/grsec_usb.c
72969 @@ -0,0 +1,15 @@
72970 +#include <linux/kernel.h>
72971 +#include <linux/grinternal.h>
72972 +#include <linux/module.h>
72973 +
72974 +int gr_handle_new_usb(void)
72975 +{
72976 +#ifdef CONFIG_GRKERNSEC_DENYUSB
72977 + if (grsec_deny_new_usb) {
72978 + printk(KERN_ALERT "grsec: denied insert of new USB device\n");
72979 + return 1;
72980 + }
72981 +#endif
72982 + return 0;
72983 +}
72984 +EXPORT_SYMBOL_GPL(gr_handle_new_usb);
72985 diff --git a/grsecurity/grsum.c b/grsecurity/grsum.c
72986 new file mode 100644
72987 index 0000000..9f7b1ac
72988 --- /dev/null
72989 +++ b/grsecurity/grsum.c
72990 @@ -0,0 +1,61 @@
72991 +#include <linux/err.h>
72992 +#include <linux/kernel.h>
72993 +#include <linux/sched.h>
72994 +#include <linux/mm.h>
72995 +#include <linux/scatterlist.h>
72996 +#include <linux/crypto.h>
72997 +#include <linux/gracl.h>
72998 +
72999 +
73000 +#if !defined(CONFIG_CRYPTO) || defined(CONFIG_CRYPTO_MODULE) || !defined(CONFIG_CRYPTO_SHA256) || defined(CONFIG_CRYPTO_SHA256_MODULE)
73001 +#error "crypto and sha256 must be built into the kernel"
73002 +#endif
73003 +
73004 +int
73005 +chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum)
73006 +{
73007 + char *p;
73008 + struct crypto_hash *tfm;
73009 + struct hash_desc desc;
73010 + struct scatterlist sg;
73011 + unsigned char temp_sum[GR_SHA_LEN];
73012 + volatile int retval = 0;
73013 + volatile int dummy = 0;
73014 + unsigned int i;
73015 +
73016 + sg_init_table(&sg, 1);
73017 +
73018 + tfm = crypto_alloc_hash("sha256", 0, CRYPTO_ALG_ASYNC);
73019 + if (IS_ERR(tfm)) {
73020 + /* should never happen, since sha256 should be built in */
73021 + return 1;
73022 + }
73023 +
73024 + desc.tfm = tfm;
73025 + desc.flags = 0;
73026 +
73027 + crypto_hash_init(&desc);
73028 +
73029 + p = salt;
73030 + sg_set_buf(&sg, p, GR_SALT_LEN);
73031 + crypto_hash_update(&desc, &sg, sg.length);
73032 +
73033 + p = entry->pw;
73034 + sg_set_buf(&sg, p, strlen(p));
73035 +
73036 + crypto_hash_update(&desc, &sg, sg.length);
73037 +
73038 + crypto_hash_final(&desc, temp_sum);
73039 +
73040 + memset(entry->pw, 0, GR_PW_LEN);
73041 +
73042 + for (i = 0; i < GR_SHA_LEN; i++)
73043 + if (sum[i] != temp_sum[i])
73044 + retval = 1;
73045 + else
73046 + dummy = 1; // waste a cycle
73047 +
73048 + crypto_free_hash(tfm);
73049 +
73050 + return retval;
73051 +}
73052 diff --git a/include/asm-generic/4level-fixup.h b/include/asm-generic/4level-fixup.h
73053 index 77ff547..181834f 100644
73054 --- a/include/asm-generic/4level-fixup.h
73055 +++ b/include/asm-generic/4level-fixup.h
73056 @@ -13,8 +13,10 @@
73057 #define pmd_alloc(mm, pud, address) \
73058 ((unlikely(pgd_none(*(pud))) && __pmd_alloc(mm, pud, address))? \
73059 NULL: pmd_offset(pud, address))
73060 +#define pmd_alloc_kernel(mm, pud, address) pmd_alloc((mm), (pud), (address))
73061
73062 #define pud_alloc(mm, pgd, address) (pgd)
73063 +#define pud_alloc_kernel(mm, pgd, address) pud_alloc((mm), (pgd), (address))
73064 #define pud_offset(pgd, start) (pgd)
73065 #define pud_none(pud) 0
73066 #define pud_bad(pud) 0
73067 diff --git a/include/asm-generic/atomic-long.h b/include/asm-generic/atomic-long.h
73068 index b7babf0..97f4c4f 100644
73069 --- a/include/asm-generic/atomic-long.h
73070 +++ b/include/asm-generic/atomic-long.h
73071 @@ -22,6 +22,12 @@
73072
73073 typedef atomic64_t atomic_long_t;
73074
73075 +#ifdef CONFIG_PAX_REFCOUNT
73076 +typedef atomic64_unchecked_t atomic_long_unchecked_t;
73077 +#else
73078 +typedef atomic64_t atomic_long_unchecked_t;
73079 +#endif
73080 +
73081 #define ATOMIC_LONG_INIT(i) ATOMIC64_INIT(i)
73082
73083 static inline long atomic_long_read(atomic_long_t *l)
73084 @@ -31,6 +37,15 @@ static inline long atomic_long_read(atomic_long_t *l)
73085 return (long)atomic64_read(v);
73086 }
73087
73088 +#ifdef CONFIG_PAX_REFCOUNT
73089 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
73090 +{
73091 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
73092 +
73093 + return (long)atomic64_read_unchecked(v);
73094 +}
73095 +#endif
73096 +
73097 static inline void atomic_long_set(atomic_long_t *l, long i)
73098 {
73099 atomic64_t *v = (atomic64_t *)l;
73100 @@ -38,6 +53,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
73101 atomic64_set(v, i);
73102 }
73103
73104 +#ifdef CONFIG_PAX_REFCOUNT
73105 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
73106 +{
73107 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
73108 +
73109 + atomic64_set_unchecked(v, i);
73110 +}
73111 +#endif
73112 +
73113 static inline void atomic_long_inc(atomic_long_t *l)
73114 {
73115 atomic64_t *v = (atomic64_t *)l;
73116 @@ -45,6 +69,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
73117 atomic64_inc(v);
73118 }
73119
73120 +#ifdef CONFIG_PAX_REFCOUNT
73121 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
73122 +{
73123 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
73124 +
73125 + atomic64_inc_unchecked(v);
73126 +}
73127 +#endif
73128 +
73129 static inline void atomic_long_dec(atomic_long_t *l)
73130 {
73131 atomic64_t *v = (atomic64_t *)l;
73132 @@ -52,6 +85,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
73133 atomic64_dec(v);
73134 }
73135
73136 +#ifdef CONFIG_PAX_REFCOUNT
73137 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
73138 +{
73139 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
73140 +
73141 + atomic64_dec_unchecked(v);
73142 +}
73143 +#endif
73144 +
73145 static inline void atomic_long_add(long i, atomic_long_t *l)
73146 {
73147 atomic64_t *v = (atomic64_t *)l;
73148 @@ -59,6 +101,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
73149 atomic64_add(i, v);
73150 }
73151
73152 +#ifdef CONFIG_PAX_REFCOUNT
73153 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
73154 +{
73155 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
73156 +
73157 + atomic64_add_unchecked(i, v);
73158 +}
73159 +#endif
73160 +
73161 static inline void atomic_long_sub(long i, atomic_long_t *l)
73162 {
73163 atomic64_t *v = (atomic64_t *)l;
73164 @@ -66,6 +117,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
73165 atomic64_sub(i, v);
73166 }
73167
73168 +#ifdef CONFIG_PAX_REFCOUNT
73169 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
73170 +{
73171 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
73172 +
73173 + atomic64_sub_unchecked(i, v);
73174 +}
73175 +#endif
73176 +
73177 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
73178 {
73179 atomic64_t *v = (atomic64_t *)l;
73180 @@ -94,13 +154,22 @@ static inline int atomic_long_add_negative(long i, atomic_long_t *l)
73181 return atomic64_add_negative(i, v);
73182 }
73183
73184 -static inline long atomic_long_add_return(long i, atomic_long_t *l)
73185 +static inline long __intentional_overflow(-1) atomic_long_add_return(long i, atomic_long_t *l)
73186 {
73187 atomic64_t *v = (atomic64_t *)l;
73188
73189 return (long)atomic64_add_return(i, v);
73190 }
73191
73192 +#ifdef CONFIG_PAX_REFCOUNT
73193 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
73194 +{
73195 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
73196 +
73197 + return (long)atomic64_add_return_unchecked(i, v);
73198 +}
73199 +#endif
73200 +
73201 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
73202 {
73203 atomic64_t *v = (atomic64_t *)l;
73204 @@ -115,6 +184,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
73205 return (long)atomic64_inc_return(v);
73206 }
73207
73208 +#ifdef CONFIG_PAX_REFCOUNT
73209 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
73210 +{
73211 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
73212 +
73213 + return (long)atomic64_inc_return_unchecked(v);
73214 +}
73215 +#endif
73216 +
73217 static inline long atomic_long_dec_return(atomic_long_t *l)
73218 {
73219 atomic64_t *v = (atomic64_t *)l;
73220 @@ -140,6 +218,12 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
73221
73222 typedef atomic_t atomic_long_t;
73223
73224 +#ifdef CONFIG_PAX_REFCOUNT
73225 +typedef atomic_unchecked_t atomic_long_unchecked_t;
73226 +#else
73227 +typedef atomic_t atomic_long_unchecked_t;
73228 +#endif
73229 +
73230 #define ATOMIC_LONG_INIT(i) ATOMIC_INIT(i)
73231 static inline long atomic_long_read(atomic_long_t *l)
73232 {
73233 @@ -148,6 +232,15 @@ static inline long atomic_long_read(atomic_long_t *l)
73234 return (long)atomic_read(v);
73235 }
73236
73237 +#ifdef CONFIG_PAX_REFCOUNT
73238 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
73239 +{
73240 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
73241 +
73242 + return (long)atomic_read_unchecked(v);
73243 +}
73244 +#endif
73245 +
73246 static inline void atomic_long_set(atomic_long_t *l, long i)
73247 {
73248 atomic_t *v = (atomic_t *)l;
73249 @@ -155,6 +248,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
73250 atomic_set(v, i);
73251 }
73252
73253 +#ifdef CONFIG_PAX_REFCOUNT
73254 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
73255 +{
73256 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
73257 +
73258 + atomic_set_unchecked(v, i);
73259 +}
73260 +#endif
73261 +
73262 static inline void atomic_long_inc(atomic_long_t *l)
73263 {
73264 atomic_t *v = (atomic_t *)l;
73265 @@ -162,6 +264,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
73266 atomic_inc(v);
73267 }
73268
73269 +#ifdef CONFIG_PAX_REFCOUNT
73270 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
73271 +{
73272 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
73273 +
73274 + atomic_inc_unchecked(v);
73275 +}
73276 +#endif
73277 +
73278 static inline void atomic_long_dec(atomic_long_t *l)
73279 {
73280 atomic_t *v = (atomic_t *)l;
73281 @@ -169,6 +280,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
73282 atomic_dec(v);
73283 }
73284
73285 +#ifdef CONFIG_PAX_REFCOUNT
73286 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
73287 +{
73288 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
73289 +
73290 + atomic_dec_unchecked(v);
73291 +}
73292 +#endif
73293 +
73294 static inline void atomic_long_add(long i, atomic_long_t *l)
73295 {
73296 atomic_t *v = (atomic_t *)l;
73297 @@ -176,6 +296,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
73298 atomic_add(i, v);
73299 }
73300
73301 +#ifdef CONFIG_PAX_REFCOUNT
73302 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
73303 +{
73304 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
73305 +
73306 + atomic_add_unchecked(i, v);
73307 +}
73308 +#endif
73309 +
73310 static inline void atomic_long_sub(long i, atomic_long_t *l)
73311 {
73312 atomic_t *v = (atomic_t *)l;
73313 @@ -183,6 +312,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
73314 atomic_sub(i, v);
73315 }
73316
73317 +#ifdef CONFIG_PAX_REFCOUNT
73318 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
73319 +{
73320 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
73321 +
73322 + atomic_sub_unchecked(i, v);
73323 +}
73324 +#endif
73325 +
73326 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
73327 {
73328 atomic_t *v = (atomic_t *)l;
73329 @@ -218,6 +356,16 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
73330 return (long)atomic_add_return(i, v);
73331 }
73332
73333 +#ifdef CONFIG_PAX_REFCOUNT
73334 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
73335 +{
73336 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
73337 +
73338 + return (long)atomic_add_return_unchecked(i, v);
73339 +}
73340 +
73341 +#endif
73342 +
73343 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
73344 {
73345 atomic_t *v = (atomic_t *)l;
73346 @@ -232,6 +380,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
73347 return (long)atomic_inc_return(v);
73348 }
73349
73350 +#ifdef CONFIG_PAX_REFCOUNT
73351 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
73352 +{
73353 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
73354 +
73355 + return (long)atomic_inc_return_unchecked(v);
73356 +}
73357 +#endif
73358 +
73359 static inline long atomic_long_dec_return(atomic_long_t *l)
73360 {
73361 atomic_t *v = (atomic_t *)l;
73362 @@ -255,4 +412,57 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
73363
73364 #endif /* BITS_PER_LONG == 64 */
73365
73366 +#ifdef CONFIG_PAX_REFCOUNT
73367 +static inline void pax_refcount_needs_these_functions(void)
73368 +{
73369 + atomic_read_unchecked((atomic_unchecked_t *)NULL);
73370 + atomic_set_unchecked((atomic_unchecked_t *)NULL, 0);
73371 + atomic_add_unchecked(0, (atomic_unchecked_t *)NULL);
73372 + atomic_sub_unchecked(0, (atomic_unchecked_t *)NULL);
73373 + atomic_inc_unchecked((atomic_unchecked_t *)NULL);
73374 + (void)atomic_inc_and_test_unchecked((atomic_unchecked_t *)NULL);
73375 + atomic_inc_return_unchecked((atomic_unchecked_t *)NULL);
73376 + atomic_add_return_unchecked(0, (atomic_unchecked_t *)NULL);
73377 + atomic_dec_unchecked((atomic_unchecked_t *)NULL);
73378 + atomic_cmpxchg_unchecked((atomic_unchecked_t *)NULL, 0, 0);
73379 + (void)atomic_xchg_unchecked((atomic_unchecked_t *)NULL, 0);
73380 +#ifdef CONFIG_X86
73381 + atomic_clear_mask_unchecked(0, NULL);
73382 + atomic_set_mask_unchecked(0, NULL);
73383 +#endif
73384 +
73385 + atomic_long_read_unchecked((atomic_long_unchecked_t *)NULL);
73386 + atomic_long_set_unchecked((atomic_long_unchecked_t *)NULL, 0);
73387 + atomic_long_add_unchecked(0, (atomic_long_unchecked_t *)NULL);
73388 + atomic_long_sub_unchecked(0, (atomic_long_unchecked_t *)NULL);
73389 + atomic_long_inc_unchecked((atomic_long_unchecked_t *)NULL);
73390 + atomic_long_add_return_unchecked(0, (atomic_long_unchecked_t *)NULL);
73391 + atomic_long_inc_return_unchecked((atomic_long_unchecked_t *)NULL);
73392 + atomic_long_dec_unchecked((atomic_long_unchecked_t *)NULL);
73393 +}
73394 +#else
73395 +#define atomic_read_unchecked(v) atomic_read(v)
73396 +#define atomic_set_unchecked(v, i) atomic_set((v), (i))
73397 +#define atomic_add_unchecked(i, v) atomic_add((i), (v))
73398 +#define atomic_sub_unchecked(i, v) atomic_sub((i), (v))
73399 +#define atomic_inc_unchecked(v) atomic_inc(v)
73400 +#define atomic_inc_and_test_unchecked(v) atomic_inc_and_test(v)
73401 +#define atomic_inc_return_unchecked(v) atomic_inc_return(v)
73402 +#define atomic_add_return_unchecked(i, v) atomic_add_return((i), (v))
73403 +#define atomic_dec_unchecked(v) atomic_dec(v)
73404 +#define atomic_cmpxchg_unchecked(v, o, n) atomic_cmpxchg((v), (o), (n))
73405 +#define atomic_xchg_unchecked(v, i) atomic_xchg((v), (i))
73406 +#define atomic_clear_mask_unchecked(mask, v) atomic_clear_mask((mask), (v))
73407 +#define atomic_set_mask_unchecked(mask, v) atomic_set_mask((mask), (v))
73408 +
73409 +#define atomic_long_read_unchecked(v) atomic_long_read(v)
73410 +#define atomic_long_set_unchecked(v, i) atomic_long_set((v), (i))
73411 +#define atomic_long_add_unchecked(i, v) atomic_long_add((i), (v))
73412 +#define atomic_long_sub_unchecked(i, v) atomic_long_sub((i), (v))
73413 +#define atomic_long_inc_unchecked(v) atomic_long_inc(v)
73414 +#define atomic_long_add_return_unchecked(i, v) atomic_long_add_return((i), (v))
73415 +#define atomic_long_inc_return_unchecked(v) atomic_long_inc_return(v)
73416 +#define atomic_long_dec_unchecked(v) atomic_long_dec(v)
73417 +#endif
73418 +
73419 #endif /* _ASM_GENERIC_ATOMIC_LONG_H */
73420 diff --git a/include/asm-generic/atomic.h b/include/asm-generic/atomic.h
73421 index 33bd2de..f31bff97 100644
73422 --- a/include/asm-generic/atomic.h
73423 +++ b/include/asm-generic/atomic.h
73424 @@ -153,7 +153,7 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
73425 * Atomically clears the bits set in @mask from @v
73426 */
73427 #ifndef atomic_clear_mask
73428 -static inline void atomic_clear_mask(unsigned long mask, atomic_t *v)
73429 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
73430 {
73431 unsigned long flags;
73432
73433 diff --git a/include/asm-generic/atomic64.h b/include/asm-generic/atomic64.h
73434 index b18ce4f..2ee2843 100644
73435 --- a/include/asm-generic/atomic64.h
73436 +++ b/include/asm-generic/atomic64.h
73437 @@ -16,6 +16,8 @@ typedef struct {
73438 long long counter;
73439 } atomic64_t;
73440
73441 +typedef atomic64_t atomic64_unchecked_t;
73442 +
73443 #define ATOMIC64_INIT(i) { (i) }
73444
73445 extern long long atomic64_read(const atomic64_t *v);
73446 @@ -39,4 +41,14 @@ extern int atomic64_add_unless(atomic64_t *v, long long a, long long u);
73447 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
73448 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
73449
73450 +#define atomic64_read_unchecked(v) atomic64_read(v)
73451 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
73452 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
73453 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
73454 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
73455 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
73456 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
73457 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
73458 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
73459 +
73460 #endif /* _ASM_GENERIC_ATOMIC64_H */
73461 diff --git a/include/asm-generic/bitops/__fls.h b/include/asm-generic/bitops/__fls.h
73462 index a60a7cc..0fe12f2 100644
73463 --- a/include/asm-generic/bitops/__fls.h
73464 +++ b/include/asm-generic/bitops/__fls.h
73465 @@ -9,7 +9,7 @@
73466 *
73467 * Undefined if no set bit exists, so code should check against 0 first.
73468 */
73469 -static __always_inline unsigned long __fls(unsigned long word)
73470 +static __always_inline unsigned long __intentional_overflow(-1) __fls(unsigned long word)
73471 {
73472 int num = BITS_PER_LONG - 1;
73473
73474 diff --git a/include/asm-generic/bitops/fls.h b/include/asm-generic/bitops/fls.h
73475 index 0576d1f..dad6c71 100644
73476 --- a/include/asm-generic/bitops/fls.h
73477 +++ b/include/asm-generic/bitops/fls.h
73478 @@ -9,7 +9,7 @@
73479 * Note fls(0) = 0, fls(1) = 1, fls(0x80000000) = 32.
73480 */
73481
73482 -static __always_inline int fls(int x)
73483 +static __always_inline int __intentional_overflow(-1) fls(int x)
73484 {
73485 int r = 32;
73486
73487 diff --git a/include/asm-generic/bitops/fls64.h b/include/asm-generic/bitops/fls64.h
73488 index b097cf8..3d40e14 100644
73489 --- a/include/asm-generic/bitops/fls64.h
73490 +++ b/include/asm-generic/bitops/fls64.h
73491 @@ -15,7 +15,7 @@
73492 * at position 64.
73493 */
73494 #if BITS_PER_LONG == 32
73495 -static __always_inline int fls64(__u64 x)
73496 +static __always_inline int __intentional_overflow(-1) fls64(__u64 x)
73497 {
73498 __u32 h = x >> 32;
73499 if (h)
73500 @@ -23,7 +23,7 @@ static __always_inline int fls64(__u64 x)
73501 return fls(x);
73502 }
73503 #elif BITS_PER_LONG == 64
73504 -static __always_inline int fls64(__u64 x)
73505 +static __always_inline int __intentional_overflow(-1) fls64(__u64 x)
73506 {
73507 if (x == 0)
73508 return 0;
73509 diff --git a/include/asm-generic/cache.h b/include/asm-generic/cache.h
73510 index 1bfcfe5..e04c5c9 100644
73511 --- a/include/asm-generic/cache.h
73512 +++ b/include/asm-generic/cache.h
73513 @@ -6,7 +6,7 @@
73514 * cache lines need to provide their own cache.h.
73515 */
73516
73517 -#define L1_CACHE_SHIFT 5
73518 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
73519 +#define L1_CACHE_SHIFT 5UL
73520 +#define L1_CACHE_BYTES (1UL << L1_CACHE_SHIFT)
73521
73522 #endif /* __ASM_GENERIC_CACHE_H */
73523 diff --git a/include/asm-generic/emergency-restart.h b/include/asm-generic/emergency-restart.h
73524 index 0d68a1e..b74a761 100644
73525 --- a/include/asm-generic/emergency-restart.h
73526 +++ b/include/asm-generic/emergency-restart.h
73527 @@ -1,7 +1,7 @@
73528 #ifndef _ASM_GENERIC_EMERGENCY_RESTART_H
73529 #define _ASM_GENERIC_EMERGENCY_RESTART_H
73530
73531 -static inline void machine_emergency_restart(void)
73532 +static inline __noreturn void machine_emergency_restart(void)
73533 {
73534 machine_restart(NULL);
73535 }
73536 diff --git a/include/asm-generic/kmap_types.h b/include/asm-generic/kmap_types.h
73537 index 90f99c7..00ce236 100644
73538 --- a/include/asm-generic/kmap_types.h
73539 +++ b/include/asm-generic/kmap_types.h
73540 @@ -2,9 +2,9 @@
73541 #define _ASM_GENERIC_KMAP_TYPES_H
73542
73543 #ifdef __WITH_KM_FENCE
73544 -# define KM_TYPE_NR 41
73545 +# define KM_TYPE_NR 42
73546 #else
73547 -# define KM_TYPE_NR 20
73548 +# define KM_TYPE_NR 21
73549 #endif
73550
73551 #endif
73552 diff --git a/include/asm-generic/local.h b/include/asm-generic/local.h
73553 index 9ceb03b..62b0b8f 100644
73554 --- a/include/asm-generic/local.h
73555 +++ b/include/asm-generic/local.h
73556 @@ -23,24 +23,37 @@ typedef struct
73557 atomic_long_t a;
73558 } local_t;
73559
73560 +typedef struct {
73561 + atomic_long_unchecked_t a;
73562 +} local_unchecked_t;
73563 +
73564 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
73565
73566 #define local_read(l) atomic_long_read(&(l)->a)
73567 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
73568 #define local_set(l,i) atomic_long_set((&(l)->a),(i))
73569 +#define local_set_unchecked(l,i) atomic_long_set_unchecked((&(l)->a),(i))
73570 #define local_inc(l) atomic_long_inc(&(l)->a)
73571 +#define local_inc_unchecked(l) atomic_long_inc_unchecked(&(l)->a)
73572 #define local_dec(l) atomic_long_dec(&(l)->a)
73573 +#define local_dec_unchecked(l) atomic_long_dec_unchecked(&(l)->a)
73574 #define local_add(i,l) atomic_long_add((i),(&(l)->a))
73575 +#define local_add_unchecked(i,l) atomic_long_add_unchecked((i),(&(l)->a))
73576 #define local_sub(i,l) atomic_long_sub((i),(&(l)->a))
73577 +#define local_sub_unchecked(i,l) atomic_long_sub_unchecked((i),(&(l)->a))
73578
73579 #define local_sub_and_test(i, l) atomic_long_sub_and_test((i), (&(l)->a))
73580 #define local_dec_and_test(l) atomic_long_dec_and_test(&(l)->a)
73581 #define local_inc_and_test(l) atomic_long_inc_and_test(&(l)->a)
73582 #define local_add_negative(i, l) atomic_long_add_negative((i), (&(l)->a))
73583 #define local_add_return(i, l) atomic_long_add_return((i), (&(l)->a))
73584 +#define local_add_return_unchecked(i, l) atomic_long_add_return_unchecked((i), (&(l)->a))
73585 #define local_sub_return(i, l) atomic_long_sub_return((i), (&(l)->a))
73586 #define local_inc_return(l) atomic_long_inc_return(&(l)->a)
73587 +#define local_dec_return(l) atomic_long_dec_return(&(l)->a)
73588
73589 #define local_cmpxchg(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
73590 +#define local_cmpxchg_unchecked(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
73591 #define local_xchg(l, n) atomic_long_xchg((&(l)->a), (n))
73592 #define local_add_unless(l, _a, u) atomic_long_add_unless((&(l)->a), (_a), (u))
73593 #define local_inc_not_zero(l) atomic_long_inc_not_zero(&(l)->a)
73594 diff --git a/include/asm-generic/pgtable-nopmd.h b/include/asm-generic/pgtable-nopmd.h
73595 index 725612b..9cc513a 100644
73596 --- a/include/asm-generic/pgtable-nopmd.h
73597 +++ b/include/asm-generic/pgtable-nopmd.h
73598 @@ -1,14 +1,19 @@
73599 #ifndef _PGTABLE_NOPMD_H
73600 #define _PGTABLE_NOPMD_H
73601
73602 -#ifndef __ASSEMBLY__
73603 -
73604 #include <asm-generic/pgtable-nopud.h>
73605
73606 -struct mm_struct;
73607 -
73608 #define __PAGETABLE_PMD_FOLDED
73609
73610 +#define PMD_SHIFT PUD_SHIFT
73611 +#define PTRS_PER_PMD 1
73612 +#define PMD_SIZE (_AC(1,UL) << PMD_SHIFT)
73613 +#define PMD_MASK (~(PMD_SIZE-1))
73614 +
73615 +#ifndef __ASSEMBLY__
73616 +
73617 +struct mm_struct;
73618 +
73619 /*
73620 * Having the pmd type consist of a pud gets the size right, and allows
73621 * us to conceptually access the pud entry that this pmd is folded into
73622 @@ -16,11 +21,6 @@ struct mm_struct;
73623 */
73624 typedef struct { pud_t pud; } pmd_t;
73625
73626 -#define PMD_SHIFT PUD_SHIFT
73627 -#define PTRS_PER_PMD 1
73628 -#define PMD_SIZE (1UL << PMD_SHIFT)
73629 -#define PMD_MASK (~(PMD_SIZE-1))
73630 -
73631 /*
73632 * The "pud_xxx()" functions here are trivial for a folded two-level
73633 * setup: the pmd is never bad, and a pmd always exists (as it's folded
73634 diff --git a/include/asm-generic/pgtable-nopud.h b/include/asm-generic/pgtable-nopud.h
73635 index 810431d..0ec4804f 100644
73636 --- a/include/asm-generic/pgtable-nopud.h
73637 +++ b/include/asm-generic/pgtable-nopud.h
73638 @@ -1,10 +1,15 @@
73639 #ifndef _PGTABLE_NOPUD_H
73640 #define _PGTABLE_NOPUD_H
73641
73642 -#ifndef __ASSEMBLY__
73643 -
73644 #define __PAGETABLE_PUD_FOLDED
73645
73646 +#define PUD_SHIFT PGDIR_SHIFT
73647 +#define PTRS_PER_PUD 1
73648 +#define PUD_SIZE (_AC(1,UL) << PUD_SHIFT)
73649 +#define PUD_MASK (~(PUD_SIZE-1))
73650 +
73651 +#ifndef __ASSEMBLY__
73652 +
73653 /*
73654 * Having the pud type consist of a pgd gets the size right, and allows
73655 * us to conceptually access the pgd entry that this pud is folded into
73656 @@ -12,11 +17,6 @@
73657 */
73658 typedef struct { pgd_t pgd; } pud_t;
73659
73660 -#define PUD_SHIFT PGDIR_SHIFT
73661 -#define PTRS_PER_PUD 1
73662 -#define PUD_SIZE (1UL << PUD_SHIFT)
73663 -#define PUD_MASK (~(PUD_SIZE-1))
73664 -
73665 /*
73666 * The "pgd_xxx()" functions here are trivial for a folded two-level
73667 * setup: the pud is never bad, and a pud always exists (as it's folded
73668 @@ -29,6 +29,7 @@ static inline void pgd_clear(pgd_t *pgd) { }
73669 #define pud_ERROR(pud) (pgd_ERROR((pud).pgd))
73670
73671 #define pgd_populate(mm, pgd, pud) do { } while (0)
73672 +#define pgd_populate_kernel(mm, pgd, pud) do { } while (0)
73673 /*
73674 * (puds are folded into pgds so this doesn't get actually called,
73675 * but the define is needed for a generic inline function.)
73676 diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
73677 index f330d28..83ce28f 100644
73678 --- a/include/asm-generic/pgtable.h
73679 +++ b/include/asm-generic/pgtable.h
73680 @@ -737,6 +737,22 @@ static inline pmd_t pmd_mknuma(pmd_t pmd)
73681 }
73682 #endif /* CONFIG_NUMA_BALANCING */
73683
73684 +#ifndef __HAVE_ARCH_PAX_OPEN_KERNEL
73685 +#ifdef CONFIG_PAX_KERNEXEC
73686 +#error KERNEXEC requires pax_open_kernel
73687 +#else
73688 +static inline unsigned long pax_open_kernel(void) { return 0; }
73689 +#endif
73690 +#endif
73691 +
73692 +#ifndef __HAVE_ARCH_PAX_CLOSE_KERNEL
73693 +#ifdef CONFIG_PAX_KERNEXEC
73694 +#error KERNEXEC requires pax_close_kernel
73695 +#else
73696 +static inline unsigned long pax_close_kernel(void) { return 0; }
73697 +#endif
73698 +#endif
73699 +
73700 #endif /* CONFIG_MMU */
73701
73702 #endif /* !__ASSEMBLY__ */
73703 diff --git a/include/asm-generic/uaccess.h b/include/asm-generic/uaccess.h
73704 index dc1269c..48a4f51 100644
73705 --- a/include/asm-generic/uaccess.h
73706 +++ b/include/asm-generic/uaccess.h
73707 @@ -343,4 +343,20 @@ clear_user(void __user *to, unsigned long n)
73708 return __clear_user(to, n);
73709 }
73710
73711 +#ifndef __HAVE_ARCH_PAX_OPEN_USERLAND
73712 +#ifdef CONFIG_PAX_MEMORY_UDEREF
73713 +#error UDEREF requires pax_open_userland
73714 +#else
73715 +static inline unsigned long pax_open_userland(void) { return 0; }
73716 +#endif
73717 +#endif
73718 +
73719 +#ifndef __HAVE_ARCH_PAX_CLOSE_USERLAND
73720 +#ifdef CONFIG_PAX_MEMORY_UDEREF
73721 +#error UDEREF requires pax_close_userland
73722 +#else
73723 +static inline unsigned long pax_close_userland(void) { return 0; }
73724 +#endif
73725 +#endif
73726 +
73727 #endif /* __ASM_GENERIC_UACCESS_H */
73728 diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
73729 index 83e2c31..eeb4a04 100644
73730 --- a/include/asm-generic/vmlinux.lds.h
73731 +++ b/include/asm-generic/vmlinux.lds.h
73732 @@ -232,6 +232,7 @@
73733 .rodata : AT(ADDR(.rodata) - LOAD_OFFSET) { \
73734 VMLINUX_SYMBOL(__start_rodata) = .; \
73735 *(.rodata) *(.rodata.*) \
73736 + *(.data..read_only) \
73737 *(__vermagic) /* Kernel version magic */ \
73738 . = ALIGN(8); \
73739 VMLINUX_SYMBOL(__start___tracepoints_ptrs) = .; \
73740 @@ -715,17 +716,18 @@
73741 * section in the linker script will go there too. @phdr should have
73742 * a leading colon.
73743 *
73744 - * Note that this macros defines __per_cpu_load as an absolute symbol.
73745 + * Note that this macros defines per_cpu_load as an absolute symbol.
73746 * If there is no need to put the percpu section at a predetermined
73747 * address, use PERCPU_SECTION.
73748 */
73749 #define PERCPU_VADDR(cacheline, vaddr, phdr) \
73750 - VMLINUX_SYMBOL(__per_cpu_load) = .; \
73751 - .data..percpu vaddr : AT(VMLINUX_SYMBOL(__per_cpu_load) \
73752 + per_cpu_load = .; \
73753 + .data..percpu vaddr : AT(VMLINUX_SYMBOL(per_cpu_load) \
73754 - LOAD_OFFSET) { \
73755 + VMLINUX_SYMBOL(__per_cpu_load) = . + per_cpu_load; \
73756 PERCPU_INPUT(cacheline) \
73757 } phdr \
73758 - . = VMLINUX_SYMBOL(__per_cpu_load) + SIZEOF(.data..percpu);
73759 + . = VMLINUX_SYMBOL(per_cpu_load) + SIZEOF(.data..percpu);
73760
73761 /**
73762 * PERCPU_SECTION - define output section for percpu area, simple version
73763 diff --git a/include/crypto/algapi.h b/include/crypto/algapi.h
73764 index 418d270..bfd2794 100644
73765 --- a/include/crypto/algapi.h
73766 +++ b/include/crypto/algapi.h
73767 @@ -34,7 +34,7 @@ struct crypto_type {
73768 unsigned int maskclear;
73769 unsigned int maskset;
73770 unsigned int tfmsize;
73771 -};
73772 +} __do_const;
73773
73774 struct crypto_instance {
73775 struct crypto_alg alg;
73776 diff --git a/include/drm/drmP.h b/include/drm/drmP.h
73777 index b46fb45..b30d6d5 100644
73778 --- a/include/drm/drmP.h
73779 +++ b/include/drm/drmP.h
73780 @@ -66,6 +66,7 @@
73781 #include <linux/workqueue.h>
73782 #include <linux/poll.h>
73783 #include <asm/pgalloc.h>
73784 +#include <asm/local.h>
73785 #include <drm/drm.h>
73786 #include <drm/drm_sarea.h>
73787 #include <drm/drm_vma_manager.h>
73788 @@ -277,10 +278,12 @@ do { \
73789 * \param cmd command.
73790 * \param arg argument.
73791 */
73792 -typedef int drm_ioctl_t(struct drm_device *dev, void *data,
73793 +typedef int (* const drm_ioctl_t)(struct drm_device *dev, void *data,
73794 + struct drm_file *file_priv);
73795 +typedef int (* drm_ioctl_no_const_t)(struct drm_device *dev, void *data,
73796 struct drm_file *file_priv);
73797
73798 -typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
73799 +typedef int (* const drm_ioctl_compat_t)(struct file *filp, unsigned int cmd,
73800 unsigned long arg);
73801
73802 #define DRM_IOCTL_NR(n) _IOC_NR(n)
73803 @@ -296,10 +299,10 @@ typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
73804 struct drm_ioctl_desc {
73805 unsigned int cmd;
73806 int flags;
73807 - drm_ioctl_t *func;
73808 + drm_ioctl_t func;
73809 unsigned int cmd_drv;
73810 const char *name;
73811 -};
73812 +} __do_const;
73813
73814 /**
73815 * Creates a driver or general drm_ioctl_desc array entry for the given
73816 @@ -1027,7 +1030,7 @@ struct drm_info_list {
73817 int (*show)(struct seq_file*, void*); /** show callback */
73818 u32 driver_features; /**< Required driver features for this entry */
73819 void *data;
73820 -};
73821 +} __do_const;
73822
73823 /**
73824 * debugfs node structure. This structure represents a debugfs file.
73825 @@ -1098,7 +1101,7 @@ struct drm_device {
73826
73827 /** \name Usage Counters */
73828 /*@{ */
73829 - int open_count; /**< Outstanding files open */
73830 + local_t open_count; /**< Outstanding files open */
73831 atomic_t ioctl_count; /**< Outstanding IOCTLs pending */
73832 atomic_t vma_count; /**< Outstanding vma areas open */
73833 int buf_use; /**< Buffers in use -- cannot alloc */
73834 @@ -1109,7 +1112,7 @@ struct drm_device {
73835 /*@{ */
73836 unsigned long counters;
73837 enum drm_stat_type types[15];
73838 - atomic_t counts[15];
73839 + atomic_unchecked_t counts[15];
73840 /*@} */
73841
73842 struct list_head filelist;
73843 diff --git a/include/drm/drm_crtc_helper.h b/include/drm/drm_crtc_helper.h
73844 index f43d556..94d9343 100644
73845 --- a/include/drm/drm_crtc_helper.h
73846 +++ b/include/drm/drm_crtc_helper.h
73847 @@ -109,7 +109,7 @@ struct drm_encoder_helper_funcs {
73848 struct drm_connector *connector);
73849 /* disable encoder when not in use - more explicit than dpms off */
73850 void (*disable)(struct drm_encoder *encoder);
73851 -};
73852 +} __no_const;
73853
73854 /**
73855 * drm_connector_helper_funcs - helper operations for connectors
73856 diff --git a/include/drm/i915_pciids.h b/include/drm/i915_pciids.h
73857 index 8a10f5c..5de7f5c 100644
73858 --- a/include/drm/i915_pciids.h
73859 +++ b/include/drm/i915_pciids.h
73860 @@ -37,7 +37,7 @@
73861 */
73862 #define INTEL_VGA_DEVICE(id, info) { \
73863 0x8086, id, \
73864 - ~0, ~0, \
73865 + PCI_ANY_ID, PCI_ANY_ID, \
73866 0x030000, 0xff0000, \
73867 (unsigned long) info }
73868
73869 diff --git a/include/drm/ttm/ttm_memory.h b/include/drm/ttm/ttm_memory.h
73870 index 72dcbe8..8db58d7 100644
73871 --- a/include/drm/ttm/ttm_memory.h
73872 +++ b/include/drm/ttm/ttm_memory.h
73873 @@ -48,7 +48,7 @@
73874
73875 struct ttm_mem_shrink {
73876 int (*do_shrink) (struct ttm_mem_shrink *);
73877 -};
73878 +} __no_const;
73879
73880 /**
73881 * struct ttm_mem_global - Global memory accounting structure.
73882 diff --git a/include/keys/asymmetric-subtype.h b/include/keys/asymmetric-subtype.h
73883 index 4b840e8..155d235 100644
73884 --- a/include/keys/asymmetric-subtype.h
73885 +++ b/include/keys/asymmetric-subtype.h
73886 @@ -37,7 +37,7 @@ struct asymmetric_key_subtype {
73887 /* Verify the signature on a key of this subtype (optional) */
73888 int (*verify_signature)(const struct key *key,
73889 const struct public_key_signature *sig);
73890 -};
73891 +} __do_const;
73892
73893 /**
73894 * asymmetric_key_subtype - Get the subtype from an asymmetric key
73895 diff --git a/include/linux/atmdev.h b/include/linux/atmdev.h
73896 index c1da539..1dcec55 100644
73897 --- a/include/linux/atmdev.h
73898 +++ b/include/linux/atmdev.h
73899 @@ -28,7 +28,7 @@ struct compat_atm_iobuf {
73900 #endif
73901
73902 struct k_atm_aal_stats {
73903 -#define __HANDLE_ITEM(i) atomic_t i
73904 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
73905 __AAL_STAT_ITEMS
73906 #undef __HANDLE_ITEM
73907 };
73908 @@ -200,7 +200,7 @@ struct atmdev_ops { /* only send is required */
73909 int (*change_qos)(struct atm_vcc *vcc,struct atm_qos *qos,int flags);
73910 int (*proc_read)(struct atm_dev *dev,loff_t *pos,char *page);
73911 struct module *owner;
73912 -};
73913 +} __do_const ;
73914
73915 struct atmphy_ops {
73916 int (*start)(struct atm_dev *dev);
73917 diff --git a/include/linux/audit.h b/include/linux/audit.h
73918 index 729a4d1..9b304ae 100644
73919 --- a/include/linux/audit.h
73920 +++ b/include/linux/audit.h
73921 @@ -193,7 +193,7 @@ static inline void audit_ptrace(struct task_struct *t)
73922 extern unsigned int audit_serial(void);
73923 extern int auditsc_get_stamp(struct audit_context *ctx,
73924 struct timespec *t, unsigned int *serial);
73925 -extern int audit_set_loginuid(kuid_t loginuid);
73926 +extern int __intentional_overflow(-1) audit_set_loginuid(kuid_t loginuid);
73927
73928 static inline kuid_t audit_get_loginuid(struct task_struct *tsk)
73929 {
73930 diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h
73931 index 7554fd4..0f86379 100644
73932 --- a/include/linux/binfmts.h
73933 +++ b/include/linux/binfmts.h
73934 @@ -73,8 +73,10 @@ struct linux_binfmt {
73935 int (*load_binary)(struct linux_binprm *);
73936 int (*load_shlib)(struct file *);
73937 int (*core_dump)(struct coredump_params *cprm);
73938 + void (*handle_mprotect)(struct vm_area_struct *vma, unsigned long newflags);
73939 + void (*handle_mmap)(struct file *);
73940 unsigned long min_coredump; /* minimal dump size */
73941 -};
73942 +} __do_const;
73943
73944 extern void __register_binfmt(struct linux_binfmt *fmt, int insert);
73945
73946 diff --git a/include/linux/bitops.h b/include/linux/bitops.h
73947 index a3b6b82..2a7d758 100644
73948 --- a/include/linux/bitops.h
73949 +++ b/include/linux/bitops.h
73950 @@ -91,7 +91,7 @@ static inline __u64 ror64(__u64 word, unsigned int shift)
73951 * @word: value to rotate
73952 * @shift: bits to roll
73953 */
73954 -static inline __u32 rol32(__u32 word, unsigned int shift)
73955 +static inline __u32 __intentional_overflow(-1) rol32(__u32 word, unsigned int shift)
73956 {
73957 return (word << shift) | (word >> (32 - shift));
73958 }
73959 @@ -101,7 +101,7 @@ static inline __u32 rol32(__u32 word, unsigned int shift)
73960 * @word: value to rotate
73961 * @shift: bits to roll
73962 */
73963 -static inline __u32 ror32(__u32 word, unsigned int shift)
73964 +static inline __u32 __intentional_overflow(-1) ror32(__u32 word, unsigned int shift)
73965 {
73966 return (word >> shift) | (word << (32 - shift));
73967 }
73968 @@ -157,7 +157,7 @@ static inline __s32 sign_extend32(__u32 value, int index)
73969 return (__s32)(value << shift) >> shift;
73970 }
73971
73972 -static inline unsigned fls_long(unsigned long l)
73973 +static inline unsigned __intentional_overflow(-1) fls_long(unsigned long l)
73974 {
73975 if (sizeof(l) == 4)
73976 return fls(l);
73977 diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
73978 index 0e6f765..885bb2b 100644
73979 --- a/include/linux/blkdev.h
73980 +++ b/include/linux/blkdev.h
73981 @@ -1537,7 +1537,7 @@ struct block_device_operations {
73982 /* this callback is with swap_lock and sometimes page table lock held */
73983 void (*swap_slot_free_notify) (struct block_device *, unsigned long);
73984 struct module *owner;
73985 -};
73986 +} __do_const;
73987
73988 extern int __blkdev_driver_ioctl(struct block_device *, fmode_t, unsigned int,
73989 unsigned long);
73990 diff --git a/include/linux/blktrace_api.h b/include/linux/blktrace_api.h
73991 index 7c2e030..b72475d 100644
73992 --- a/include/linux/blktrace_api.h
73993 +++ b/include/linux/blktrace_api.h
73994 @@ -23,7 +23,7 @@ struct blk_trace {
73995 struct dentry *dir;
73996 struct dentry *dropped_file;
73997 struct dentry *msg_file;
73998 - atomic_t dropped;
73999 + atomic_unchecked_t dropped;
74000 };
74001
74002 extern int blk_trace_ioctl(struct block_device *, unsigned, char __user *);
74003 diff --git a/include/linux/cache.h b/include/linux/cache.h
74004 index 4c57065..40346da 100644
74005 --- a/include/linux/cache.h
74006 +++ b/include/linux/cache.h
74007 @@ -16,6 +16,14 @@
74008 #define __read_mostly
74009 #endif
74010
74011 +#ifndef __read_only
74012 +#ifdef CONFIG_PAX_KERNEXEC
74013 +#error KERNEXEC requires __read_only
74014 +#else
74015 +#define __read_only __read_mostly
74016 +#endif
74017 +#endif
74018 +
74019 #ifndef ____cacheline_aligned
74020 #define ____cacheline_aligned __attribute__((__aligned__(SMP_CACHE_BYTES)))
74021 #endif
74022 diff --git a/include/linux/capability.h b/include/linux/capability.h
74023 index a6ee1f9..e1ca49d 100644
74024 --- a/include/linux/capability.h
74025 +++ b/include/linux/capability.h
74026 @@ -212,8 +212,13 @@ extern bool capable(int cap);
74027 extern bool ns_capable(struct user_namespace *ns, int cap);
74028 extern bool inode_capable(const struct inode *inode, int cap);
74029 extern bool file_ns_capable(const struct file *file, struct user_namespace *ns, int cap);
74030 +extern bool capable_nolog(int cap);
74031 +extern bool ns_capable_nolog(struct user_namespace *ns, int cap);
74032 +extern bool inode_capable_nolog(const struct inode *inode, int cap);
74033
74034 /* audit system wants to get cap info from files as well */
74035 extern int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data *cpu_caps);
74036
74037 +extern int is_privileged_binary(const struct dentry *dentry);
74038 +
74039 #endif /* !_LINUX_CAPABILITY_H */
74040 diff --git a/include/linux/cdrom.h b/include/linux/cdrom.h
74041 index 8609d57..86e4d79 100644
74042 --- a/include/linux/cdrom.h
74043 +++ b/include/linux/cdrom.h
74044 @@ -87,7 +87,6 @@ struct cdrom_device_ops {
74045
74046 /* driver specifications */
74047 const int capability; /* capability flags */
74048 - int n_minors; /* number of active minor devices */
74049 /* handle uniform packets for scsi type devices (scsi,atapi) */
74050 int (*generic_packet) (struct cdrom_device_info *,
74051 struct packet_command *);
74052 diff --git a/include/linux/cleancache.h b/include/linux/cleancache.h
74053 index 4ce9056..86caac6 100644
74054 --- a/include/linux/cleancache.h
74055 +++ b/include/linux/cleancache.h
74056 @@ -31,7 +31,7 @@ struct cleancache_ops {
74057 void (*invalidate_page)(int, struct cleancache_filekey, pgoff_t);
74058 void (*invalidate_inode)(int, struct cleancache_filekey);
74059 void (*invalidate_fs)(int);
74060 -};
74061 +} __no_const;
74062
74063 extern struct cleancache_ops *
74064 cleancache_register_ops(struct cleancache_ops *ops);
74065 diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
74066 index 73bdb69..d66d47a 100644
74067 --- a/include/linux/clk-provider.h
74068 +++ b/include/linux/clk-provider.h
74069 @@ -141,6 +141,7 @@ struct clk_ops {
74070 unsigned long);
74071 void (*init)(struct clk_hw *hw);
74072 };
74073 +typedef struct clk_ops __no_const clk_ops_no_const;
74074
74075 /**
74076 * struct clk_init_data - holds init data that's common to all clocks and is
74077 diff --git a/include/linux/compat.h b/include/linux/compat.h
74078 index 345da00..b6eff26 100644
74079 --- a/include/linux/compat.h
74080 +++ b/include/linux/compat.h
74081 @@ -313,7 +313,7 @@ compat_sys_get_robust_list(int pid, compat_uptr_t __user *head_ptr,
74082 compat_size_t __user *len_ptr);
74083
74084 asmlinkage long compat_sys_ipc(u32, int, int, u32, compat_uptr_t, u32);
74085 -asmlinkage long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg);
74086 +asmlinkage long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg) __intentional_overflow(0);
74087 asmlinkage long compat_sys_semctl(int semid, int semnum, int cmd, int arg);
74088 asmlinkage long compat_sys_msgsnd(int msqid, compat_uptr_t msgp,
74089 compat_ssize_t msgsz, int msgflg);
74090 @@ -420,7 +420,7 @@ extern int compat_ptrace_request(struct task_struct *child,
74091 extern long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
74092 compat_ulong_t addr, compat_ulong_t data);
74093 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
74094 - compat_long_t addr, compat_long_t data);
74095 + compat_ulong_t addr, compat_ulong_t data);
74096
74097 asmlinkage long compat_sys_lookup_dcookie(u32, u32, char __user *, size_t);
74098 /*
74099 diff --git a/include/linux/compiler-gcc4.h b/include/linux/compiler-gcc4.h
74100 index ded4299..da50e3b 100644
74101 --- a/include/linux/compiler-gcc4.h
74102 +++ b/include/linux/compiler-gcc4.h
74103 @@ -39,9 +39,29 @@
74104 # define __compiletime_warning(message) __attribute__((warning(message)))
74105 # define __compiletime_error(message) __attribute__((error(message)))
74106 #endif /* __CHECKER__ */
74107 +
74108 +#define __alloc_size(...) __attribute((alloc_size(__VA_ARGS__)))
74109 +#define __bos(ptr, arg) __builtin_object_size((ptr), (arg))
74110 +#define __bos0(ptr) __bos((ptr), 0)
74111 +#define __bos1(ptr) __bos((ptr), 1)
74112 #endif /* GCC_VERSION >= 40300 */
74113
74114 #if GCC_VERSION >= 40500
74115 +
74116 +#ifdef CONSTIFY_PLUGIN
74117 +#define __no_const __attribute__((no_const))
74118 +#define __do_const __attribute__((do_const))
74119 +#endif
74120 +
74121 +#ifdef SIZE_OVERFLOW_PLUGIN
74122 +#define __size_overflow(...) __attribute__((size_overflow(__VA_ARGS__)))
74123 +#define __intentional_overflow(...) __attribute__((intentional_overflow(__VA_ARGS__)))
74124 +#endif
74125 +
74126 +#ifdef LATENT_ENTROPY_PLUGIN
74127 +#define __latent_entropy __attribute__((latent_entropy))
74128 +#endif
74129 +
74130 /*
74131 * Mark a position in code as unreachable. This can be used to
74132 * suppress control flow warnings after asm blocks that transfer
74133 diff --git a/include/linux/compiler.h b/include/linux/compiler.h
74134 index 92669cd..1771a15 100644
74135 --- a/include/linux/compiler.h
74136 +++ b/include/linux/compiler.h
74137 @@ -5,11 +5,14 @@
74138
74139 #ifdef __CHECKER__
74140 # define __user __attribute__((noderef, address_space(1)))
74141 +# define __force_user __force __user
74142 # define __kernel __attribute__((address_space(0)))
74143 +# define __force_kernel __force __kernel
74144 # define __safe __attribute__((safe))
74145 # define __force __attribute__((force))
74146 # define __nocast __attribute__((nocast))
74147 # define __iomem __attribute__((noderef, address_space(2)))
74148 +# define __force_iomem __force __iomem
74149 # define __must_hold(x) __attribute__((context(x,1,1)))
74150 # define __acquires(x) __attribute__((context(x,0,1)))
74151 # define __releases(x) __attribute__((context(x,1,0)))
74152 @@ -17,20 +20,37 @@
74153 # define __release(x) __context__(x,-1)
74154 # define __cond_lock(x,c) ((c) ? ({ __acquire(x); 1; }) : 0)
74155 # define __percpu __attribute__((noderef, address_space(3)))
74156 +# define __force_percpu __force __percpu
74157 #ifdef CONFIG_SPARSE_RCU_POINTER
74158 # define __rcu __attribute__((noderef, address_space(4)))
74159 +# define __force_rcu __force __rcu
74160 #else
74161 # define __rcu
74162 +# define __force_rcu
74163 #endif
74164 extern void __chk_user_ptr(const volatile void __user *);
74165 extern void __chk_io_ptr(const volatile void __iomem *);
74166 #else
74167 -# define __user
74168 -# define __kernel
74169 +# ifdef CHECKER_PLUGIN
74170 +//# define __user
74171 +//# define __force_user
74172 +//# define __kernel
74173 +//# define __force_kernel
74174 +# else
74175 +# ifdef STRUCTLEAK_PLUGIN
74176 +# define __user __attribute__((user))
74177 +# else
74178 +# define __user
74179 +# endif
74180 +# define __force_user
74181 +# define __kernel
74182 +# define __force_kernel
74183 +# endif
74184 # define __safe
74185 # define __force
74186 # define __nocast
74187 # define __iomem
74188 +# define __force_iomem
74189 # define __chk_user_ptr(x) (void)0
74190 # define __chk_io_ptr(x) (void)0
74191 # define __builtin_warning(x, y...) (1)
74192 @@ -41,7 +61,9 @@ extern void __chk_io_ptr(const volatile void __iomem *);
74193 # define __release(x) (void)0
74194 # define __cond_lock(x,c) (c)
74195 # define __percpu
74196 +# define __force_percpu
74197 # define __rcu
74198 +# define __force_rcu
74199 #endif
74200
74201 /* Indirect macros required for expanded argument pasting, eg. __LINE__. */
74202 @@ -275,6 +297,26 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
74203 # define __attribute_const__ /* unimplemented */
74204 #endif
74205
74206 +#ifndef __no_const
74207 +# define __no_const
74208 +#endif
74209 +
74210 +#ifndef __do_const
74211 +# define __do_const
74212 +#endif
74213 +
74214 +#ifndef __size_overflow
74215 +# define __size_overflow(...)
74216 +#endif
74217 +
74218 +#ifndef __intentional_overflow
74219 +# define __intentional_overflow(...)
74220 +#endif
74221 +
74222 +#ifndef __latent_entropy
74223 +# define __latent_entropy
74224 +#endif
74225 +
74226 /*
74227 * Tell gcc if a function is cold. The compiler will assume any path
74228 * directly leading to the call is unlikely.
74229 @@ -284,6 +326,22 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
74230 #define __cold
74231 #endif
74232
74233 +#ifndef __alloc_size
74234 +#define __alloc_size(...)
74235 +#endif
74236 +
74237 +#ifndef __bos
74238 +#define __bos(ptr, arg)
74239 +#endif
74240 +
74241 +#ifndef __bos0
74242 +#define __bos0(ptr)
74243 +#endif
74244 +
74245 +#ifndef __bos1
74246 +#define __bos1(ptr)
74247 +#endif
74248 +
74249 /* Simple shorthand for a section definition */
74250 #ifndef __section
74251 # define __section(S) __attribute__ ((__section__(#S)))
74252 @@ -349,7 +407,8 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
74253 * use is to mediate communication between process-level code and irq/NMI
74254 * handlers, all running on the same CPU.
74255 */
74256 -#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
74257 +#define ACCESS_ONCE(x) (*(volatile const typeof(x) *)&(x))
74258 +#define ACCESS_ONCE_RW(x) (*(volatile typeof(x) *)&(x))
74259
74260 /* Ignore/forbid kprobes attach on very low level functions marked by this attribute: */
74261 #ifdef CONFIG_KPROBES
74262 diff --git a/include/linux/completion.h b/include/linux/completion.h
74263 index 3cd574d..240dcb0 100644
74264 --- a/include/linux/completion.h
74265 +++ b/include/linux/completion.h
74266 @@ -78,16 +78,16 @@ static inline void init_completion(struct completion *x)
74267
74268 extern void wait_for_completion(struct completion *);
74269 extern void wait_for_completion_io(struct completion *);
74270 -extern int wait_for_completion_interruptible(struct completion *x);
74271 -extern int wait_for_completion_killable(struct completion *x);
74272 +extern int wait_for_completion_interruptible(struct completion *x) __intentional_overflow(-1);
74273 +extern int wait_for_completion_killable(struct completion *x) __intentional_overflow(-1);
74274 extern unsigned long wait_for_completion_timeout(struct completion *x,
74275 - unsigned long timeout);
74276 + unsigned long timeout) __intentional_overflow(-1);
74277 extern unsigned long wait_for_completion_io_timeout(struct completion *x,
74278 - unsigned long timeout);
74279 + unsigned long timeout) __intentional_overflow(-1);
74280 extern long wait_for_completion_interruptible_timeout(
74281 - struct completion *x, unsigned long timeout);
74282 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
74283 extern long wait_for_completion_killable_timeout(
74284 - struct completion *x, unsigned long timeout);
74285 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
74286 extern bool try_wait_for_completion(struct completion *x);
74287 extern bool completion_done(struct completion *x);
74288
74289 diff --git a/include/linux/configfs.h b/include/linux/configfs.h
74290 index 34025df..d94bbbc 100644
74291 --- a/include/linux/configfs.h
74292 +++ b/include/linux/configfs.h
74293 @@ -125,7 +125,7 @@ struct configfs_attribute {
74294 const char *ca_name;
74295 struct module *ca_owner;
74296 umode_t ca_mode;
74297 -};
74298 +} __do_const;
74299
74300 /*
74301 * Users often need to create attribute structures for their configurable
74302 diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
74303 index fcabc42..cba5d93 100644
74304 --- a/include/linux/cpufreq.h
74305 +++ b/include/linux/cpufreq.h
74306 @@ -167,6 +167,7 @@ struct global_attr {
74307 ssize_t (*store)(struct kobject *a, struct attribute *b,
74308 const char *c, size_t count);
74309 };
74310 +typedef struct global_attr __no_const global_attr_no_const;
74311
74312 #define define_one_global_ro(_name) \
74313 static struct global_attr _name = \
74314 @@ -208,7 +209,7 @@ struct cpufreq_driver {
74315 int (*suspend) (struct cpufreq_policy *policy);
74316 int (*resume) (struct cpufreq_policy *policy);
74317 struct freq_attr **attr;
74318 -};
74319 +} __do_const;
74320
74321 /* flags */
74322 #define CPUFREQ_STICKY 0x01 /* the driver isn't removed even if
74323 diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
74324 index 781addc..d1e1fe6 100644
74325 --- a/include/linux/cpuidle.h
74326 +++ b/include/linux/cpuidle.h
74327 @@ -50,7 +50,8 @@ struct cpuidle_state {
74328 int index);
74329
74330 int (*enter_dead) (struct cpuidle_device *dev, int index);
74331 -};
74332 +} __do_const;
74333 +typedef struct cpuidle_state __no_const cpuidle_state_no_const;
74334
74335 /* Idle State Flags */
74336 #define CPUIDLE_FLAG_TIME_VALID (0x01) /* is residency time measurable? */
74337 @@ -192,7 +193,7 @@ struct cpuidle_governor {
74338 void (*reflect) (struct cpuidle_device *dev, int index);
74339
74340 struct module *owner;
74341 -};
74342 +} __do_const;
74343
74344 #ifdef CONFIG_CPU_IDLE
74345
74346 diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
74347 index d08e4d2..95fad61 100644
74348 --- a/include/linux/cpumask.h
74349 +++ b/include/linux/cpumask.h
74350 @@ -118,17 +118,17 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
74351 }
74352
74353 /* Valid inputs for n are -1 and 0. */
74354 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
74355 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
74356 {
74357 return n+1;
74358 }
74359
74360 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
74361 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
74362 {
74363 return n+1;
74364 }
74365
74366 -static inline unsigned int cpumask_next_and(int n,
74367 +static inline unsigned int __intentional_overflow(-1) cpumask_next_and(int n,
74368 const struct cpumask *srcp,
74369 const struct cpumask *andp)
74370 {
74371 @@ -167,7 +167,7 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
74372 *
74373 * Returns >= nr_cpu_ids if no further cpus set.
74374 */
74375 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
74376 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
74377 {
74378 /* -1 is a legal arg here. */
74379 if (n != -1)
74380 @@ -182,7 +182,7 @@ static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
74381 *
74382 * Returns >= nr_cpu_ids if no further cpus unset.
74383 */
74384 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
74385 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
74386 {
74387 /* -1 is a legal arg here. */
74388 if (n != -1)
74389 @@ -190,7 +190,7 @@ static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
74390 return find_next_zero_bit(cpumask_bits(srcp), nr_cpumask_bits, n+1);
74391 }
74392
74393 -int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *);
74394 +int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *) __intentional_overflow(-1);
74395 int cpumask_any_but(const struct cpumask *mask, unsigned int cpu);
74396
74397 /**
74398 diff --git a/include/linux/cred.h b/include/linux/cred.h
74399 index 04421e8..6bce4ef 100644
74400 --- a/include/linux/cred.h
74401 +++ b/include/linux/cred.h
74402 @@ -194,6 +194,9 @@ static inline void validate_creds_for_do_exit(struct task_struct *tsk)
74403 static inline void validate_process_creds(void)
74404 {
74405 }
74406 +static inline void validate_task_creds(struct task_struct *task)
74407 +{
74408 +}
74409 #endif
74410
74411 /**
74412 diff --git a/include/linux/crypto.h b/include/linux/crypto.h
74413 index b92eadf..b4ecdc1 100644
74414 --- a/include/linux/crypto.h
74415 +++ b/include/linux/crypto.h
74416 @@ -373,7 +373,7 @@ struct cipher_tfm {
74417 const u8 *key, unsigned int keylen);
74418 void (*cit_encrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
74419 void (*cit_decrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
74420 -};
74421 +} __no_const;
74422
74423 struct hash_tfm {
74424 int (*init)(struct hash_desc *desc);
74425 @@ -394,13 +394,13 @@ struct compress_tfm {
74426 int (*cot_decompress)(struct crypto_tfm *tfm,
74427 const u8 *src, unsigned int slen,
74428 u8 *dst, unsigned int *dlen);
74429 -};
74430 +} __no_const;
74431
74432 struct rng_tfm {
74433 int (*rng_gen_random)(struct crypto_rng *tfm, u8 *rdata,
74434 unsigned int dlen);
74435 int (*rng_reset)(struct crypto_rng *tfm, u8 *seed, unsigned int slen);
74436 -};
74437 +} __no_const;
74438
74439 #define crt_ablkcipher crt_u.ablkcipher
74440 #define crt_aead crt_u.aead
74441 diff --git a/include/linux/ctype.h b/include/linux/ctype.h
74442 index 653589e..4ef254a 100644
74443 --- a/include/linux/ctype.h
74444 +++ b/include/linux/ctype.h
74445 @@ -56,7 +56,7 @@ static inline unsigned char __toupper(unsigned char c)
74446 * Fast implementation of tolower() for internal usage. Do not use in your
74447 * code.
74448 */
74449 -static inline char _tolower(const char c)
74450 +static inline unsigned char _tolower(const unsigned char c)
74451 {
74452 return c | 0x20;
74453 }
74454 diff --git a/include/linux/decompress/mm.h b/include/linux/decompress/mm.h
74455 index 7925bf0..d5143d2 100644
74456 --- a/include/linux/decompress/mm.h
74457 +++ b/include/linux/decompress/mm.h
74458 @@ -77,7 +77,7 @@ static void free(void *where)
74459 * warnings when not needed (indeed large_malloc / large_free are not
74460 * needed by inflate */
74461
74462 -#define malloc(a) kmalloc(a, GFP_KERNEL)
74463 +#define malloc(a) kmalloc((a), GFP_KERNEL)
74464 #define free(a) kfree(a)
74465
74466 #define large_malloc(a) vmalloc(a)
74467 diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h
74468 index 5f1ab92..39c35ae 100644
74469 --- a/include/linux/devfreq.h
74470 +++ b/include/linux/devfreq.h
74471 @@ -114,7 +114,7 @@ struct devfreq_governor {
74472 int (*get_target_freq)(struct devfreq *this, unsigned long *freq);
74473 int (*event_handler)(struct devfreq *devfreq,
74474 unsigned int event, void *data);
74475 -};
74476 +} __do_const;
74477
74478 /**
74479 * struct devfreq - Device devfreq structure
74480 diff --git a/include/linux/device.h b/include/linux/device.h
74481 index 2a9d6ed..d14551e3 100644
74482 --- a/include/linux/device.h
74483 +++ b/include/linux/device.h
74484 @@ -313,7 +313,7 @@ struct subsys_interface {
74485 struct list_head node;
74486 int (*add_dev)(struct device *dev, struct subsys_interface *sif);
74487 int (*remove_dev)(struct device *dev, struct subsys_interface *sif);
74488 -};
74489 +} __do_const;
74490
74491 int subsys_interface_register(struct subsys_interface *sif);
74492 void subsys_interface_unregister(struct subsys_interface *sif);
74493 @@ -501,7 +501,7 @@ struct device_type {
74494 void (*release)(struct device *dev);
74495
74496 const struct dev_pm_ops *pm;
74497 -};
74498 +} __do_const;
74499
74500 /* interface for exporting device attributes */
74501 struct device_attribute {
74502 @@ -511,11 +511,12 @@ struct device_attribute {
74503 ssize_t (*store)(struct device *dev, struct device_attribute *attr,
74504 const char *buf, size_t count);
74505 };
74506 +typedef struct device_attribute __no_const device_attribute_no_const;
74507
74508 struct dev_ext_attribute {
74509 struct device_attribute attr;
74510 void *var;
74511 -};
74512 +} __do_const;
74513
74514 ssize_t device_show_ulong(struct device *dev, struct device_attribute *attr,
74515 char *buf);
74516 diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
74517 index 3a8d0a2..c762be2 100644
74518 --- a/include/linux/dma-mapping.h
74519 +++ b/include/linux/dma-mapping.h
74520 @@ -54,7 +54,7 @@ struct dma_map_ops {
74521 u64 (*get_required_mask)(struct device *dev);
74522 #endif
74523 int is_phys;
74524 -};
74525 +} __do_const;
74526
74527 #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
74528
74529 diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
74530 index 0bc7275..4ccbf11 100644
74531 --- a/include/linux/dmaengine.h
74532 +++ b/include/linux/dmaengine.h
74533 @@ -1078,9 +1078,9 @@ struct dma_pinned_list {
74534 struct dma_pinned_list *dma_pin_iovec_pages(struct iovec *iov, size_t len);
74535 void dma_unpin_iovec_pages(struct dma_pinned_list* pinned_list);
74536
74537 -dma_cookie_t dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
74538 +dma_cookie_t __intentional_overflow(0) dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
74539 struct dma_pinned_list *pinned_list, unsigned char *kdata, size_t len);
74540 -dma_cookie_t dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
74541 +dma_cookie_t __intentional_overflow(0) dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
74542 struct dma_pinned_list *pinned_list, struct page *page,
74543 unsigned int offset, size_t len);
74544
74545 diff --git a/include/linux/efi.h b/include/linux/efi.h
74546 index 094ddd0..f1dfcd3 100644
74547 --- a/include/linux/efi.h
74548 +++ b/include/linux/efi.h
74549 @@ -745,6 +745,7 @@ struct efivar_operations {
74550 efi_set_variable_t *set_variable;
74551 efi_query_variable_store_t *query_variable_store;
74552 };
74553 +typedef struct efivar_operations __no_const efivar_operations_no_const;
74554
74555 struct efivars {
74556 /*
74557 diff --git a/include/linux/elf.h b/include/linux/elf.h
74558 index 40a3c0e0..4c45a38 100644
74559 --- a/include/linux/elf.h
74560 +++ b/include/linux/elf.h
74561 @@ -24,6 +24,7 @@ extern Elf32_Dyn _DYNAMIC [];
74562 #define elf_note elf32_note
74563 #define elf_addr_t Elf32_Off
74564 #define Elf_Half Elf32_Half
74565 +#define elf_dyn Elf32_Dyn
74566
74567 #else
74568
74569 @@ -34,6 +35,7 @@ extern Elf64_Dyn _DYNAMIC [];
74570 #define elf_note elf64_note
74571 #define elf_addr_t Elf64_Off
74572 #define Elf_Half Elf64_Half
74573 +#define elf_dyn Elf64_Dyn
74574
74575 #endif
74576
74577 diff --git a/include/linux/err.h b/include/linux/err.h
74578 index 15f92e0..e825a8e 100644
74579 --- a/include/linux/err.h
74580 +++ b/include/linux/err.h
74581 @@ -19,12 +19,12 @@
74582
74583 #define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
74584
74585 -static inline void * __must_check ERR_PTR(long error)
74586 +static inline void * __must_check __intentional_overflow(-1) ERR_PTR(long error)
74587 {
74588 return (void *) error;
74589 }
74590
74591 -static inline long __must_check PTR_ERR(__force const void *ptr)
74592 +static inline long __must_check __intentional_overflow(-1) PTR_ERR(__force const void *ptr)
74593 {
74594 return (long) ptr;
74595 }
74596 diff --git a/include/linux/extcon.h b/include/linux/extcon.h
74597 index fcb51c8..bdafcf6 100644
74598 --- a/include/linux/extcon.h
74599 +++ b/include/linux/extcon.h
74600 @@ -134,7 +134,7 @@ struct extcon_dev {
74601 /* /sys/class/extcon/.../mutually_exclusive/... */
74602 struct attribute_group attr_g_muex;
74603 struct attribute **attrs_muex;
74604 - struct device_attribute *d_attrs_muex;
74605 + device_attribute_no_const *d_attrs_muex;
74606 };
74607
74608 /**
74609 diff --git a/include/linux/fb.h b/include/linux/fb.h
74610 index ffac70a..ca3e711 100644
74611 --- a/include/linux/fb.h
74612 +++ b/include/linux/fb.h
74613 @@ -304,7 +304,7 @@ struct fb_ops {
74614 /* called at KDB enter and leave time to prepare the console */
74615 int (*fb_debug_enter)(struct fb_info *info);
74616 int (*fb_debug_leave)(struct fb_info *info);
74617 -};
74618 +} __do_const;
74619
74620 #ifdef CONFIG_FB_TILEBLITTING
74621 #define FB_TILE_CURSOR_NONE 0
74622 diff --git a/include/linux/fdtable.h b/include/linux/fdtable.h
74623 index 085197b..0fa6f0b 100644
74624 --- a/include/linux/fdtable.h
74625 +++ b/include/linux/fdtable.h
74626 @@ -95,7 +95,7 @@ struct files_struct *get_files_struct(struct task_struct *);
74627 void put_files_struct(struct files_struct *fs);
74628 void reset_files_struct(struct files_struct *);
74629 int unshare_files(struct files_struct **);
74630 -struct files_struct *dup_fd(struct files_struct *, int *);
74631 +struct files_struct *dup_fd(struct files_struct *, int *) __latent_entropy;
74632 void do_close_on_exec(struct files_struct *);
74633 int iterate_fd(struct files_struct *, unsigned,
74634 int (*)(const void *, struct file *, unsigned),
74635 diff --git a/include/linux/frontswap.h b/include/linux/frontswap.h
74636 index 8293262..2b3b8bd 100644
74637 --- a/include/linux/frontswap.h
74638 +++ b/include/linux/frontswap.h
74639 @@ -11,7 +11,7 @@ struct frontswap_ops {
74640 int (*load)(unsigned, pgoff_t, struct page *);
74641 void (*invalidate_page)(unsigned, pgoff_t);
74642 void (*invalidate_area)(unsigned);
74643 -};
74644 +} __no_const;
74645
74646 extern bool frontswap_enabled;
74647 extern struct frontswap_ops *
74648 diff --git a/include/linux/fs.h b/include/linux/fs.h
74649 index 164d2a9..0ffa41d0 100644
74650 --- a/include/linux/fs.h
74651 +++ b/include/linux/fs.h
74652 @@ -1552,7 +1552,8 @@ struct file_operations {
74653 long (*fallocate)(struct file *file, int mode, loff_t offset,
74654 loff_t len);
74655 int (*show_fdinfo)(struct seq_file *m, struct file *f);
74656 -};
74657 +} __do_const;
74658 +typedef struct file_operations __no_const file_operations_no_const;
74659
74660 struct inode_operations {
74661 struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int);
74662 @@ -2747,4 +2748,14 @@ static inline bool dir_relax(struct inode *inode)
74663 return !IS_DEADDIR(inode);
74664 }
74665
74666 +static inline bool is_sidechannel_device(const struct inode *inode)
74667 +{
74668 +#ifdef CONFIG_GRKERNSEC_DEVICE_SIDECHANNEL
74669 + umode_t mode = inode->i_mode;
74670 + return ((S_ISCHR(mode) || S_ISBLK(mode)) && (mode & (S_IROTH | S_IWOTH)));
74671 +#else
74672 + return false;
74673 +#endif
74674 +}
74675 +
74676 #endif /* _LINUX_FS_H */
74677 diff --git a/include/linux/fs_struct.h b/include/linux/fs_struct.h
74678 index 0efc3e6..e0e1e5f 100644
74679 --- a/include/linux/fs_struct.h
74680 +++ b/include/linux/fs_struct.h
74681 @@ -6,7 +6,7 @@
74682 #include <linux/seqlock.h>
74683
74684 struct fs_struct {
74685 - int users;
74686 + atomic_t users;
74687 spinlock_t lock;
74688 seqcount_t seq;
74689 int umask;
74690 diff --git a/include/linux/fscache-cache.h b/include/linux/fscache-cache.h
74691 index 7823e9e..56b6f2f 100644
74692 --- a/include/linux/fscache-cache.h
74693 +++ b/include/linux/fscache-cache.h
74694 @@ -113,7 +113,7 @@ struct fscache_operation {
74695 fscache_operation_release_t release;
74696 };
74697
74698 -extern atomic_t fscache_op_debug_id;
74699 +extern atomic_unchecked_t fscache_op_debug_id;
74700 extern void fscache_op_work_func(struct work_struct *work);
74701
74702 extern void fscache_enqueue_operation(struct fscache_operation *);
74703 @@ -135,7 +135,7 @@ static inline void fscache_operation_init(struct fscache_operation *op,
74704 INIT_WORK(&op->work, fscache_op_work_func);
74705 atomic_set(&op->usage, 1);
74706 op->state = FSCACHE_OP_ST_INITIALISED;
74707 - op->debug_id = atomic_inc_return(&fscache_op_debug_id);
74708 + op->debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
74709 op->processor = processor;
74710 op->release = release;
74711 INIT_LIST_HEAD(&op->pend_link);
74712 diff --git a/include/linux/fscache.h b/include/linux/fscache.h
74713 index 19b4645..3b73dfc 100644
74714 --- a/include/linux/fscache.h
74715 +++ b/include/linux/fscache.h
74716 @@ -152,7 +152,7 @@ struct fscache_cookie_def {
74717 * - this is mandatory for any object that may have data
74718 */
74719 void (*now_uncached)(void *cookie_netfs_data);
74720 -};
74721 +} __do_const;
74722
74723 /*
74724 * fscache cached network filesystem type
74725 diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
74726 index 1c804b0..1432c2b 100644
74727 --- a/include/linux/fsnotify.h
74728 +++ b/include/linux/fsnotify.h
74729 @@ -195,6 +195,9 @@ static inline void fsnotify_access(struct file *file)
74730 struct inode *inode = file_inode(file);
74731 __u32 mask = FS_ACCESS;
74732
74733 + if (is_sidechannel_device(inode))
74734 + return;
74735 +
74736 if (S_ISDIR(inode->i_mode))
74737 mask |= FS_ISDIR;
74738
74739 @@ -213,6 +216,9 @@ static inline void fsnotify_modify(struct file *file)
74740 struct inode *inode = file_inode(file);
74741 __u32 mask = FS_MODIFY;
74742
74743 + if (is_sidechannel_device(inode))
74744 + return;
74745 +
74746 if (S_ISDIR(inode->i_mode))
74747 mask |= FS_ISDIR;
74748
74749 @@ -315,7 +321,7 @@ static inline void fsnotify_change(struct dentry *dentry, unsigned int ia_valid)
74750 */
74751 static inline const unsigned char *fsnotify_oldname_init(const unsigned char *name)
74752 {
74753 - return kstrdup(name, GFP_KERNEL);
74754 + return (const unsigned char *)kstrdup((const char *)name, GFP_KERNEL);
74755 }
74756
74757 /*
74758 diff --git a/include/linux/genhd.h b/include/linux/genhd.h
74759 index 9f3c275..8bdff5d 100644
74760 --- a/include/linux/genhd.h
74761 +++ b/include/linux/genhd.h
74762 @@ -194,7 +194,7 @@ struct gendisk {
74763 struct kobject *slave_dir;
74764
74765 struct timer_rand_state *random;
74766 - atomic_t sync_io; /* RAID */
74767 + atomic_unchecked_t sync_io; /* RAID */
74768 struct disk_events *ev;
74769 #ifdef CONFIG_BLK_DEV_INTEGRITY
74770 struct blk_integrity *integrity;
74771 @@ -435,7 +435,7 @@ extern void disk_flush_events(struct gendisk *disk, unsigned int mask);
74772 extern unsigned int disk_clear_events(struct gendisk *disk, unsigned int mask);
74773
74774 /* drivers/char/random.c */
74775 -extern void add_disk_randomness(struct gendisk *disk);
74776 +extern void add_disk_randomness(struct gendisk *disk) __latent_entropy;
74777 extern void rand_initialize_disk(struct gendisk *disk);
74778
74779 static inline sector_t get_start_sect(struct block_device *bdev)
74780 diff --git a/include/linux/genl_magic_func.h b/include/linux/genl_magic_func.h
74781 index 023bc34..b02b46a 100644
74782 --- a/include/linux/genl_magic_func.h
74783 +++ b/include/linux/genl_magic_func.h
74784 @@ -246,7 +246,7 @@ const char *CONCAT_(GENL_MAGIC_FAMILY, _genl_cmd_to_str)(__u8 cmd)
74785 },
74786
74787 #define ZZZ_genl_ops CONCAT_(GENL_MAGIC_FAMILY, _genl_ops)
74788 -static struct genl_ops ZZZ_genl_ops[] __read_mostly = {
74789 +static struct genl_ops ZZZ_genl_ops[] = {
74790 #include GENL_MAGIC_INCLUDE_FILE
74791 };
74792
74793 diff --git a/include/linux/gfp.h b/include/linux/gfp.h
74794 index 9b4dd49..61fd41d 100644
74795 --- a/include/linux/gfp.h
74796 +++ b/include/linux/gfp.h
74797 @@ -35,6 +35,13 @@ struct vm_area_struct;
74798 #define ___GFP_NO_KSWAPD 0x400000u
74799 #define ___GFP_OTHER_NODE 0x800000u
74800 #define ___GFP_WRITE 0x1000000u
74801 +
74802 +#ifdef CONFIG_PAX_USERCOPY_SLABS
74803 +#define ___GFP_USERCOPY 0x2000000u
74804 +#else
74805 +#define ___GFP_USERCOPY 0
74806 +#endif
74807 +
74808 /* If the above are modified, __GFP_BITS_SHIFT may need updating */
74809
74810 /*
74811 @@ -92,6 +99,7 @@ struct vm_area_struct;
74812 #define __GFP_OTHER_NODE ((__force gfp_t)___GFP_OTHER_NODE) /* On behalf of other node */
74813 #define __GFP_KMEMCG ((__force gfp_t)___GFP_KMEMCG) /* Allocation comes from a memcg-accounted resource */
74814 #define __GFP_WRITE ((__force gfp_t)___GFP_WRITE) /* Allocator intends to dirty page */
74815 +#define __GFP_USERCOPY ((__force gfp_t)___GFP_USERCOPY)/* Allocator intends to copy page to/from userland */
74816
74817 /*
74818 * This may seem redundant, but it's a way of annotating false positives vs.
74819 @@ -99,7 +107,7 @@ struct vm_area_struct;
74820 */
74821 #define __GFP_NOTRACK_FALSE_POSITIVE (__GFP_NOTRACK)
74822
74823 -#define __GFP_BITS_SHIFT 25 /* Room for N __GFP_FOO bits */
74824 +#define __GFP_BITS_SHIFT 26 /* Room for N __GFP_FOO bits */
74825 #define __GFP_BITS_MASK ((__force gfp_t)((1 << __GFP_BITS_SHIFT) - 1))
74826
74827 /* This equals 0, but use constants in case they ever change */
74828 @@ -153,6 +161,8 @@ struct vm_area_struct;
74829 /* 4GB DMA on some platforms */
74830 #define GFP_DMA32 __GFP_DMA32
74831
74832 +#define GFP_USERCOPY __GFP_USERCOPY
74833 +
74834 /* Convert GFP flags to their corresponding migrate type */
74835 static inline int allocflags_to_migratetype(gfp_t gfp_flags)
74836 {
74837 diff --git a/include/linux/gracl.h b/include/linux/gracl.h
74838 new file mode 100644
74839 index 0000000..edb2cb6
74840 --- /dev/null
74841 +++ b/include/linux/gracl.h
74842 @@ -0,0 +1,340 @@
74843 +#ifndef GR_ACL_H
74844 +#define GR_ACL_H
74845 +
74846 +#include <linux/grdefs.h>
74847 +#include <linux/resource.h>
74848 +#include <linux/capability.h>
74849 +#include <linux/dcache.h>
74850 +#include <asm/resource.h>
74851 +
74852 +/* Major status information */
74853 +
74854 +#define GR_VERSION "grsecurity 3.0"
74855 +#define GRSECURITY_VERSION 0x3000
74856 +
74857 +enum {
74858 + GR_SHUTDOWN = 0,
74859 + GR_ENABLE = 1,
74860 + GR_SPROLE = 2,
74861 + GR_OLDRELOAD = 3,
74862 + GR_SEGVMOD = 4,
74863 + GR_STATUS = 5,
74864 + GR_UNSPROLE = 6,
74865 + GR_PASSSET = 7,
74866 + GR_SPROLEPAM = 8,
74867 + GR_RELOAD = 9,
74868 +};
74869 +
74870 +/* Password setup definitions
74871 + * kernel/grhash.c */
74872 +enum {
74873 + GR_PW_LEN = 128,
74874 + GR_SALT_LEN = 16,
74875 + GR_SHA_LEN = 32,
74876 +};
74877 +
74878 +enum {
74879 + GR_SPROLE_LEN = 64,
74880 +};
74881 +
74882 +enum {
74883 + GR_NO_GLOB = 0,
74884 + GR_REG_GLOB,
74885 + GR_CREATE_GLOB
74886 +};
74887 +
74888 +#define GR_NLIMITS 32
74889 +
74890 +/* Begin Data Structures */
74891 +
74892 +struct sprole_pw {
74893 + unsigned char *rolename;
74894 + unsigned char salt[GR_SALT_LEN];
74895 + unsigned char sum[GR_SHA_LEN]; /* 256-bit SHA hash of the password */
74896 +};
74897 +
74898 +struct name_entry {
74899 + __u32 key;
74900 + ino_t inode;
74901 + dev_t device;
74902 + char *name;
74903 + __u16 len;
74904 + __u8 deleted;
74905 + struct name_entry *prev;
74906 + struct name_entry *next;
74907 +};
74908 +
74909 +struct inodev_entry {
74910 + struct name_entry *nentry;
74911 + struct inodev_entry *prev;
74912 + struct inodev_entry *next;
74913 +};
74914 +
74915 +struct acl_role_db {
74916 + struct acl_role_label **r_hash;
74917 + __u32 r_size;
74918 +};
74919 +
74920 +struct inodev_db {
74921 + struct inodev_entry **i_hash;
74922 + __u32 i_size;
74923 +};
74924 +
74925 +struct name_db {
74926 + struct name_entry **n_hash;
74927 + __u32 n_size;
74928 +};
74929 +
74930 +struct crash_uid {
74931 + uid_t uid;
74932 + unsigned long expires;
74933 +};
74934 +
74935 +struct gr_hash_struct {
74936 + void **table;
74937 + void **nametable;
74938 + void *first;
74939 + __u32 table_size;
74940 + __u32 used_size;
74941 + int type;
74942 +};
74943 +
74944 +/* Userspace Grsecurity ACL data structures */
74945 +
74946 +struct acl_subject_label {
74947 + char *filename;
74948 + ino_t inode;
74949 + dev_t device;
74950 + __u32 mode;
74951 + kernel_cap_t cap_mask;
74952 + kernel_cap_t cap_lower;
74953 + kernel_cap_t cap_invert_audit;
74954 +
74955 + struct rlimit res[GR_NLIMITS];
74956 + __u32 resmask;
74957 +
74958 + __u8 user_trans_type;
74959 + __u8 group_trans_type;
74960 + uid_t *user_transitions;
74961 + gid_t *group_transitions;
74962 + __u16 user_trans_num;
74963 + __u16 group_trans_num;
74964 +
74965 + __u32 sock_families[2];
74966 + __u32 ip_proto[8];
74967 + __u32 ip_type;
74968 + struct acl_ip_label **ips;
74969 + __u32 ip_num;
74970 + __u32 inaddr_any_override;
74971 +
74972 + __u32 crashes;
74973 + unsigned long expires;
74974 +
74975 + struct acl_subject_label *parent_subject;
74976 + struct gr_hash_struct *hash;
74977 + struct acl_subject_label *prev;
74978 + struct acl_subject_label *next;
74979 +
74980 + struct acl_object_label **obj_hash;
74981 + __u32 obj_hash_size;
74982 + __u16 pax_flags;
74983 +};
74984 +
74985 +struct role_allowed_ip {
74986 + __u32 addr;
74987 + __u32 netmask;
74988 +
74989 + struct role_allowed_ip *prev;
74990 + struct role_allowed_ip *next;
74991 +};
74992 +
74993 +struct role_transition {
74994 + char *rolename;
74995 +
74996 + struct role_transition *prev;
74997 + struct role_transition *next;
74998 +};
74999 +
75000 +struct acl_role_label {
75001 + char *rolename;
75002 + uid_t uidgid;
75003 + __u16 roletype;
75004 +
75005 + __u16 auth_attempts;
75006 + unsigned long expires;
75007 +
75008 + struct acl_subject_label *root_label;
75009 + struct gr_hash_struct *hash;
75010 +
75011 + struct acl_role_label *prev;
75012 + struct acl_role_label *next;
75013 +
75014 + struct role_transition *transitions;
75015 + struct role_allowed_ip *allowed_ips;
75016 + uid_t *domain_children;
75017 + __u16 domain_child_num;
75018 +
75019 + umode_t umask;
75020 +
75021 + struct acl_subject_label **subj_hash;
75022 + __u32 subj_hash_size;
75023 +};
75024 +
75025 +struct user_acl_role_db {
75026 + struct acl_role_label **r_table;
75027 + __u32 num_pointers; /* Number of allocations to track */
75028 + __u32 num_roles; /* Number of roles */
75029 + __u32 num_domain_children; /* Number of domain children */
75030 + __u32 num_subjects; /* Number of subjects */
75031 + __u32 num_objects; /* Number of objects */
75032 +};
75033 +
75034 +struct acl_object_label {
75035 + char *filename;
75036 + ino_t inode;
75037 + dev_t device;
75038 + __u32 mode;
75039 +
75040 + struct acl_subject_label *nested;
75041 + struct acl_object_label *globbed;
75042 +
75043 + /* next two structures not used */
75044 +
75045 + struct acl_object_label *prev;
75046 + struct acl_object_label *next;
75047 +};
75048 +
75049 +struct acl_ip_label {
75050 + char *iface;
75051 + __u32 addr;
75052 + __u32 netmask;
75053 + __u16 low, high;
75054 + __u8 mode;
75055 + __u32 type;
75056 + __u32 proto[8];
75057 +
75058 + /* next two structures not used */
75059 +
75060 + struct acl_ip_label *prev;
75061 + struct acl_ip_label *next;
75062 +};
75063 +
75064 +struct gr_arg {
75065 + struct user_acl_role_db role_db;
75066 + unsigned char pw[GR_PW_LEN];
75067 + unsigned char salt[GR_SALT_LEN];
75068 + unsigned char sum[GR_SHA_LEN];
75069 + unsigned char sp_role[GR_SPROLE_LEN];
75070 + struct sprole_pw *sprole_pws;
75071 + dev_t segv_device;
75072 + ino_t segv_inode;
75073 + uid_t segv_uid;
75074 + __u16 num_sprole_pws;
75075 + __u16 mode;
75076 +};
75077 +
75078 +struct gr_arg_wrapper {
75079 + struct gr_arg *arg;
75080 + __u32 version;
75081 + __u32 size;
75082 +};
75083 +
75084 +struct subject_map {
75085 + struct acl_subject_label *user;
75086 + struct acl_subject_label *kernel;
75087 + struct subject_map *prev;
75088 + struct subject_map *next;
75089 +};
75090 +
75091 +struct acl_subj_map_db {
75092 + struct subject_map **s_hash;
75093 + __u32 s_size;
75094 +};
75095 +
75096 +struct gr_policy_state {
75097 + struct sprole_pw **acl_special_roles;
75098 + __u16 num_sprole_pws;
75099 + struct acl_role_label *kernel_role;
75100 + struct acl_role_label *role_list;
75101 + struct acl_role_label *default_role;
75102 + struct acl_role_db acl_role_set;
75103 + struct acl_subj_map_db subj_map_set;
75104 + struct name_db name_set;
75105 + struct inodev_db inodev_set;
75106 +};
75107 +
75108 +struct gr_alloc_state {
75109 + unsigned long alloc_stack_next;
75110 + unsigned long alloc_stack_size;
75111 + void **alloc_stack;
75112 +};
75113 +
75114 +struct gr_reload_state {
75115 + struct gr_policy_state oldpolicy;
75116 + struct gr_alloc_state oldalloc;
75117 + struct gr_policy_state newpolicy;
75118 + struct gr_alloc_state newalloc;
75119 + struct gr_policy_state *oldpolicy_ptr;
75120 + struct gr_alloc_state *oldalloc_ptr;
75121 + unsigned char oldmode;
75122 +};
75123 +
75124 +/* End Data Structures Section */
75125 +
75126 +/* Hash functions generated by empirical testing by Brad Spengler
75127 + Makes good use of the low bits of the inode. Generally 0-1 times
75128 + in loop for successful match. 0-3 for unsuccessful match.
75129 + Shift/add algorithm with modulus of table size and an XOR*/
75130 +
75131 +static __inline__ unsigned int
75132 +gr_rhash(const uid_t uid, const __u16 type, const unsigned int sz)
75133 +{
75134 + return ((((uid + type) << (16 + type)) ^ uid) % sz);
75135 +}
75136 +
75137 + static __inline__ unsigned int
75138 +gr_shash(const struct acl_subject_label *userp, const unsigned int sz)
75139 +{
75140 + return ((const unsigned long)userp % sz);
75141 +}
75142 +
75143 +static __inline__ unsigned int
75144 +gr_fhash(const ino_t ino, const dev_t dev, const unsigned int sz)
75145 +{
75146 + return (((ino + dev) ^ ((ino << 13) + (ino << 23) + (dev << 9))) % sz);
75147 +}
75148 +
75149 +static __inline__ unsigned int
75150 +gr_nhash(const char *name, const __u16 len, const unsigned int sz)
75151 +{
75152 + return full_name_hash((const unsigned char *)name, len) % sz;
75153 +}
75154 +
75155 +#define FOR_EACH_SUBJECT_START(role,subj,iter) \
75156 + subj = NULL; \
75157 + iter = 0; \
75158 + while (iter < role->subj_hash_size) { \
75159 + if (subj == NULL) \
75160 + subj = role->subj_hash[iter]; \
75161 + if (subj == NULL) { \
75162 + iter++; \
75163 + continue; \
75164 + }
75165 +
75166 +#define FOR_EACH_SUBJECT_END(subj,iter) \
75167 + subj = subj->next; \
75168 + if (subj == NULL) \
75169 + iter++; \
75170 + }
75171 +
75172 +
75173 +#define FOR_EACH_NESTED_SUBJECT_START(role,subj) \
75174 + subj = role->hash->first; \
75175 + while (subj != NULL) {
75176 +
75177 +#define FOR_EACH_NESTED_SUBJECT_END(subj) \
75178 + subj = subj->next; \
75179 + }
75180 +
75181 +#endif
75182 +
75183 diff --git a/include/linux/gracl_compat.h b/include/linux/gracl_compat.h
75184 new file mode 100644
75185 index 0000000..33ebd1f
75186 --- /dev/null
75187 +++ b/include/linux/gracl_compat.h
75188 @@ -0,0 +1,156 @@
75189 +#ifndef GR_ACL_COMPAT_H
75190 +#define GR_ACL_COMPAT_H
75191 +
75192 +#include <linux/resource.h>
75193 +#include <asm/resource.h>
75194 +
75195 +struct sprole_pw_compat {
75196 + compat_uptr_t rolename;
75197 + unsigned char salt[GR_SALT_LEN];
75198 + unsigned char sum[GR_SHA_LEN];
75199 +};
75200 +
75201 +struct gr_hash_struct_compat {
75202 + compat_uptr_t table;
75203 + compat_uptr_t nametable;
75204 + compat_uptr_t first;
75205 + __u32 table_size;
75206 + __u32 used_size;
75207 + int type;
75208 +};
75209 +
75210 +struct acl_subject_label_compat {
75211 + compat_uptr_t filename;
75212 + compat_ino_t inode;
75213 + __u32 device;
75214 + __u32 mode;
75215 + kernel_cap_t cap_mask;
75216 + kernel_cap_t cap_lower;
75217 + kernel_cap_t cap_invert_audit;
75218 +
75219 + struct compat_rlimit res[GR_NLIMITS];
75220 + __u32 resmask;
75221 +
75222 + __u8 user_trans_type;
75223 + __u8 group_trans_type;
75224 + compat_uptr_t user_transitions;
75225 + compat_uptr_t group_transitions;
75226 + __u16 user_trans_num;
75227 + __u16 group_trans_num;
75228 +
75229 + __u32 sock_families[2];
75230 + __u32 ip_proto[8];
75231 + __u32 ip_type;
75232 + compat_uptr_t ips;
75233 + __u32 ip_num;
75234 + __u32 inaddr_any_override;
75235 +
75236 + __u32 crashes;
75237 + compat_ulong_t expires;
75238 +
75239 + compat_uptr_t parent_subject;
75240 + compat_uptr_t hash;
75241 + compat_uptr_t prev;
75242 + compat_uptr_t next;
75243 +
75244 + compat_uptr_t obj_hash;
75245 + __u32 obj_hash_size;
75246 + __u16 pax_flags;
75247 +};
75248 +
75249 +struct role_allowed_ip_compat {
75250 + __u32 addr;
75251 + __u32 netmask;
75252 +
75253 + compat_uptr_t prev;
75254 + compat_uptr_t next;
75255 +};
75256 +
75257 +struct role_transition_compat {
75258 + compat_uptr_t rolename;
75259 +
75260 + compat_uptr_t prev;
75261 + compat_uptr_t next;
75262 +};
75263 +
75264 +struct acl_role_label_compat {
75265 + compat_uptr_t rolename;
75266 + uid_t uidgid;
75267 + __u16 roletype;
75268 +
75269 + __u16 auth_attempts;
75270 + compat_ulong_t expires;
75271 +
75272 + compat_uptr_t root_label;
75273 + compat_uptr_t hash;
75274 +
75275 + compat_uptr_t prev;
75276 + compat_uptr_t next;
75277 +
75278 + compat_uptr_t transitions;
75279 + compat_uptr_t allowed_ips;
75280 + compat_uptr_t domain_children;
75281 + __u16 domain_child_num;
75282 +
75283 + umode_t umask;
75284 +
75285 + compat_uptr_t subj_hash;
75286 + __u32 subj_hash_size;
75287 +};
75288 +
75289 +struct user_acl_role_db_compat {
75290 + compat_uptr_t r_table;
75291 + __u32 num_pointers;
75292 + __u32 num_roles;
75293 + __u32 num_domain_children;
75294 + __u32 num_subjects;
75295 + __u32 num_objects;
75296 +};
75297 +
75298 +struct acl_object_label_compat {
75299 + compat_uptr_t filename;
75300 + compat_ino_t inode;
75301 + __u32 device;
75302 + __u32 mode;
75303 +
75304 + compat_uptr_t nested;
75305 + compat_uptr_t globbed;
75306 +
75307 + compat_uptr_t prev;
75308 + compat_uptr_t next;
75309 +};
75310 +
75311 +struct acl_ip_label_compat {
75312 + compat_uptr_t iface;
75313 + __u32 addr;
75314 + __u32 netmask;
75315 + __u16 low, high;
75316 + __u8 mode;
75317 + __u32 type;
75318 + __u32 proto[8];
75319 +
75320 + compat_uptr_t prev;
75321 + compat_uptr_t next;
75322 +};
75323 +
75324 +struct gr_arg_compat {
75325 + struct user_acl_role_db_compat role_db;
75326 + unsigned char pw[GR_PW_LEN];
75327 + unsigned char salt[GR_SALT_LEN];
75328 + unsigned char sum[GR_SHA_LEN];
75329 + unsigned char sp_role[GR_SPROLE_LEN];
75330 + compat_uptr_t sprole_pws;
75331 + __u32 segv_device;
75332 + compat_ino_t segv_inode;
75333 + uid_t segv_uid;
75334 + __u16 num_sprole_pws;
75335 + __u16 mode;
75336 +};
75337 +
75338 +struct gr_arg_wrapper_compat {
75339 + compat_uptr_t arg;
75340 + __u32 version;
75341 + __u32 size;
75342 +};
75343 +
75344 +#endif
75345 diff --git a/include/linux/gralloc.h b/include/linux/gralloc.h
75346 new file mode 100644
75347 index 0000000..323ecf2
75348 --- /dev/null
75349 +++ b/include/linux/gralloc.h
75350 @@ -0,0 +1,9 @@
75351 +#ifndef __GRALLOC_H
75352 +#define __GRALLOC_H
75353 +
75354 +void acl_free_all(void);
75355 +int acl_alloc_stack_init(unsigned long size);
75356 +void *acl_alloc(unsigned long len);
75357 +void *acl_alloc_num(unsigned long num, unsigned long len);
75358 +
75359 +#endif
75360 diff --git a/include/linux/grdefs.h b/include/linux/grdefs.h
75361 new file mode 100644
75362 index 0000000..be66033
75363 --- /dev/null
75364 +++ b/include/linux/grdefs.h
75365 @@ -0,0 +1,140 @@
75366 +#ifndef GRDEFS_H
75367 +#define GRDEFS_H
75368 +
75369 +/* Begin grsecurity status declarations */
75370 +
75371 +enum {
75372 + GR_READY = 0x01,
75373 + GR_STATUS_INIT = 0x00 // disabled state
75374 +};
75375 +
75376 +/* Begin ACL declarations */
75377 +
75378 +/* Role flags */
75379 +
75380 +enum {
75381 + GR_ROLE_USER = 0x0001,
75382 + GR_ROLE_GROUP = 0x0002,
75383 + GR_ROLE_DEFAULT = 0x0004,
75384 + GR_ROLE_SPECIAL = 0x0008,
75385 + GR_ROLE_AUTH = 0x0010,
75386 + GR_ROLE_NOPW = 0x0020,
75387 + GR_ROLE_GOD = 0x0040,
75388 + GR_ROLE_LEARN = 0x0080,
75389 + GR_ROLE_TPE = 0x0100,
75390 + GR_ROLE_DOMAIN = 0x0200,
75391 + GR_ROLE_PAM = 0x0400,
75392 + GR_ROLE_PERSIST = 0x0800
75393 +};
75394 +
75395 +/* ACL Subject and Object mode flags */
75396 +enum {
75397 + GR_DELETED = 0x80000000
75398 +};
75399 +
75400 +/* ACL Object-only mode flags */
75401 +enum {
75402 + GR_READ = 0x00000001,
75403 + GR_APPEND = 0x00000002,
75404 + GR_WRITE = 0x00000004,
75405 + GR_EXEC = 0x00000008,
75406 + GR_FIND = 0x00000010,
75407 + GR_INHERIT = 0x00000020,
75408 + GR_SETID = 0x00000040,
75409 + GR_CREATE = 0x00000080,
75410 + GR_DELETE = 0x00000100,
75411 + GR_LINK = 0x00000200,
75412 + GR_AUDIT_READ = 0x00000400,
75413 + GR_AUDIT_APPEND = 0x00000800,
75414 + GR_AUDIT_WRITE = 0x00001000,
75415 + GR_AUDIT_EXEC = 0x00002000,
75416 + GR_AUDIT_FIND = 0x00004000,
75417 + GR_AUDIT_INHERIT= 0x00008000,
75418 + GR_AUDIT_SETID = 0x00010000,
75419 + GR_AUDIT_CREATE = 0x00020000,
75420 + GR_AUDIT_DELETE = 0x00040000,
75421 + GR_AUDIT_LINK = 0x00080000,
75422 + GR_PTRACERD = 0x00100000,
75423 + GR_NOPTRACE = 0x00200000,
75424 + GR_SUPPRESS = 0x00400000,
75425 + GR_NOLEARN = 0x00800000,
75426 + GR_INIT_TRANSFER= 0x01000000
75427 +};
75428 +
75429 +#define GR_AUDITS (GR_AUDIT_READ | GR_AUDIT_WRITE | GR_AUDIT_APPEND | GR_AUDIT_EXEC | \
75430 + GR_AUDIT_FIND | GR_AUDIT_INHERIT | GR_AUDIT_SETID | \
75431 + GR_AUDIT_CREATE | GR_AUDIT_DELETE | GR_AUDIT_LINK)
75432 +
75433 +/* ACL subject-only mode flags */
75434 +enum {
75435 + GR_KILL = 0x00000001,
75436 + GR_VIEW = 0x00000002,
75437 + GR_PROTECTED = 0x00000004,
75438 + GR_LEARN = 0x00000008,
75439 + GR_OVERRIDE = 0x00000010,
75440 + /* just a placeholder, this mode is only used in userspace */
75441 + GR_DUMMY = 0x00000020,
75442 + GR_PROTSHM = 0x00000040,
75443 + GR_KILLPROC = 0x00000080,
75444 + GR_KILLIPPROC = 0x00000100,
75445 + /* just a placeholder, this mode is only used in userspace */
75446 + GR_NOTROJAN = 0x00000200,
75447 + GR_PROTPROCFD = 0x00000400,
75448 + GR_PROCACCT = 0x00000800,
75449 + GR_RELAXPTRACE = 0x00001000,
75450 + //GR_NESTED = 0x00002000,
75451 + GR_INHERITLEARN = 0x00004000,
75452 + GR_PROCFIND = 0x00008000,
75453 + GR_POVERRIDE = 0x00010000,
75454 + GR_KERNELAUTH = 0x00020000,
75455 + GR_ATSECURE = 0x00040000,
75456 + GR_SHMEXEC = 0x00080000
75457 +};
75458 +
75459 +enum {
75460 + GR_PAX_ENABLE_SEGMEXEC = 0x0001,
75461 + GR_PAX_ENABLE_PAGEEXEC = 0x0002,
75462 + GR_PAX_ENABLE_MPROTECT = 0x0004,
75463 + GR_PAX_ENABLE_RANDMMAP = 0x0008,
75464 + GR_PAX_ENABLE_EMUTRAMP = 0x0010,
75465 + GR_PAX_DISABLE_SEGMEXEC = 0x0100,
75466 + GR_PAX_DISABLE_PAGEEXEC = 0x0200,
75467 + GR_PAX_DISABLE_MPROTECT = 0x0400,
75468 + GR_PAX_DISABLE_RANDMMAP = 0x0800,
75469 + GR_PAX_DISABLE_EMUTRAMP = 0x1000,
75470 +};
75471 +
75472 +enum {
75473 + GR_ID_USER = 0x01,
75474 + GR_ID_GROUP = 0x02,
75475 +};
75476 +
75477 +enum {
75478 + GR_ID_ALLOW = 0x01,
75479 + GR_ID_DENY = 0x02,
75480 +};
75481 +
75482 +#define GR_CRASH_RES 31
75483 +#define GR_UIDTABLE_MAX 500
75484 +
75485 +/* begin resource learning section */
75486 +enum {
75487 + GR_RLIM_CPU_BUMP = 60,
75488 + GR_RLIM_FSIZE_BUMP = 50000,
75489 + GR_RLIM_DATA_BUMP = 10000,
75490 + GR_RLIM_STACK_BUMP = 1000,
75491 + GR_RLIM_CORE_BUMP = 10000,
75492 + GR_RLIM_RSS_BUMP = 500000,
75493 + GR_RLIM_NPROC_BUMP = 1,
75494 + GR_RLIM_NOFILE_BUMP = 5,
75495 + GR_RLIM_MEMLOCK_BUMP = 50000,
75496 + GR_RLIM_AS_BUMP = 500000,
75497 + GR_RLIM_LOCKS_BUMP = 2,
75498 + GR_RLIM_SIGPENDING_BUMP = 5,
75499 + GR_RLIM_MSGQUEUE_BUMP = 10000,
75500 + GR_RLIM_NICE_BUMP = 1,
75501 + GR_RLIM_RTPRIO_BUMP = 1,
75502 + GR_RLIM_RTTIME_BUMP = 1000000
75503 +};
75504 +
75505 +#endif
75506 diff --git a/include/linux/grinternal.h b/include/linux/grinternal.h
75507 new file mode 100644
75508 index 0000000..d25522e
75509 --- /dev/null
75510 +++ b/include/linux/grinternal.h
75511 @@ -0,0 +1,229 @@
75512 +#ifndef __GRINTERNAL_H
75513 +#define __GRINTERNAL_H
75514 +
75515 +#ifdef CONFIG_GRKERNSEC
75516 +
75517 +#include <linux/fs.h>
75518 +#include <linux/mnt_namespace.h>
75519 +#include <linux/nsproxy.h>
75520 +#include <linux/gracl.h>
75521 +#include <linux/grdefs.h>
75522 +#include <linux/grmsg.h>
75523 +
75524 +void gr_add_learn_entry(const char *fmt, ...)
75525 + __attribute__ ((format (printf, 1, 2)));
75526 +__u32 gr_search_file(const struct dentry *dentry, const __u32 mode,
75527 + const struct vfsmount *mnt);
75528 +__u32 gr_check_create(const struct dentry *new_dentry,
75529 + const struct dentry *parent,
75530 + const struct vfsmount *mnt, const __u32 mode);
75531 +int gr_check_protected_task(const struct task_struct *task);
75532 +__u32 to_gr_audit(const __u32 reqmode);
75533 +int gr_set_acls(const int type);
75534 +int gr_acl_is_enabled(void);
75535 +char gr_roletype_to_char(void);
75536 +
75537 +void gr_handle_alertkill(struct task_struct *task);
75538 +char *gr_to_filename(const struct dentry *dentry,
75539 + const struct vfsmount *mnt);
75540 +char *gr_to_filename1(const struct dentry *dentry,
75541 + const struct vfsmount *mnt);
75542 +char *gr_to_filename2(const struct dentry *dentry,
75543 + const struct vfsmount *mnt);
75544 +char *gr_to_filename3(const struct dentry *dentry,
75545 + const struct vfsmount *mnt);
75546 +
75547 +extern int grsec_enable_ptrace_readexec;
75548 +extern int grsec_enable_harden_ptrace;
75549 +extern int grsec_enable_link;
75550 +extern int grsec_enable_fifo;
75551 +extern int grsec_enable_execve;
75552 +extern int grsec_enable_shm;
75553 +extern int grsec_enable_execlog;
75554 +extern int grsec_enable_signal;
75555 +extern int grsec_enable_audit_ptrace;
75556 +extern int grsec_enable_forkfail;
75557 +extern int grsec_enable_time;
75558 +extern int grsec_enable_rofs;
75559 +extern int grsec_deny_new_usb;
75560 +extern int grsec_enable_chroot_shmat;
75561 +extern int grsec_enable_chroot_mount;
75562 +extern int grsec_enable_chroot_double;
75563 +extern int grsec_enable_chroot_pivot;
75564 +extern int grsec_enable_chroot_chdir;
75565 +extern int grsec_enable_chroot_chmod;
75566 +extern int grsec_enable_chroot_mknod;
75567 +extern int grsec_enable_chroot_fchdir;
75568 +extern int grsec_enable_chroot_nice;
75569 +extern int grsec_enable_chroot_execlog;
75570 +extern int grsec_enable_chroot_caps;
75571 +extern int grsec_enable_chroot_sysctl;
75572 +extern int grsec_enable_chroot_unix;
75573 +extern int grsec_enable_symlinkown;
75574 +extern kgid_t grsec_symlinkown_gid;
75575 +extern int grsec_enable_tpe;
75576 +extern kgid_t grsec_tpe_gid;
75577 +extern int grsec_enable_tpe_all;
75578 +extern int grsec_enable_tpe_invert;
75579 +extern int grsec_enable_socket_all;
75580 +extern kgid_t grsec_socket_all_gid;
75581 +extern int grsec_enable_socket_client;
75582 +extern kgid_t grsec_socket_client_gid;
75583 +extern int grsec_enable_socket_server;
75584 +extern kgid_t grsec_socket_server_gid;
75585 +extern kgid_t grsec_audit_gid;
75586 +extern int grsec_enable_group;
75587 +extern int grsec_enable_log_rwxmaps;
75588 +extern int grsec_enable_mount;
75589 +extern int grsec_enable_chdir;
75590 +extern int grsec_resource_logging;
75591 +extern int grsec_enable_blackhole;
75592 +extern int grsec_lastack_retries;
75593 +extern int grsec_enable_brute;
75594 +extern int grsec_enable_harden_ipc;
75595 +extern int grsec_lock;
75596 +
75597 +extern spinlock_t grsec_alert_lock;
75598 +extern unsigned long grsec_alert_wtime;
75599 +extern unsigned long grsec_alert_fyet;
75600 +
75601 +extern spinlock_t grsec_audit_lock;
75602 +
75603 +extern rwlock_t grsec_exec_file_lock;
75604 +
75605 +#define gr_task_fullpath(tsk) ((tsk)->exec_file ? \
75606 + gr_to_filename2((tsk)->exec_file->f_path.dentry, \
75607 + (tsk)->exec_file->f_path.mnt) : "/")
75608 +
75609 +#define gr_parent_task_fullpath(tsk) ((tsk)->real_parent->exec_file ? \
75610 + gr_to_filename3((tsk)->real_parent->exec_file->f_path.dentry, \
75611 + (tsk)->real_parent->exec_file->f_path.mnt) : "/")
75612 +
75613 +#define gr_task_fullpath0(tsk) ((tsk)->exec_file ? \
75614 + gr_to_filename((tsk)->exec_file->f_path.dentry, \
75615 + (tsk)->exec_file->f_path.mnt) : "/")
75616 +
75617 +#define gr_parent_task_fullpath0(tsk) ((tsk)->real_parent->exec_file ? \
75618 + gr_to_filename1((tsk)->real_parent->exec_file->f_path.dentry, \
75619 + (tsk)->real_parent->exec_file->f_path.mnt) : "/")
75620 +
75621 +#define proc_is_chrooted(tsk_a) ((tsk_a)->gr_is_chrooted)
75622 +
75623 +#define have_same_root(tsk_a,tsk_b) ((tsk_a)->gr_chroot_dentry == (tsk_b)->gr_chroot_dentry)
75624 +
75625 +static inline bool gr_is_same_file(const struct file *file1, const struct file *file2)
75626 +{
75627 + if (file1 && file2) {
75628 + const struct inode *inode1 = file1->f_path.dentry->d_inode;
75629 + const struct inode *inode2 = file2->f_path.dentry->d_inode;
75630 + if (inode1->i_ino == inode2->i_ino && inode1->i_sb->s_dev == inode2->i_sb->s_dev)
75631 + return true;
75632 + }
75633 +
75634 + return false;
75635 +}
75636 +
75637 +#define GR_CHROOT_CAPS {{ \
75638 + CAP_TO_MASK(CAP_LINUX_IMMUTABLE) | CAP_TO_MASK(CAP_NET_ADMIN) | \
75639 + CAP_TO_MASK(CAP_SYS_MODULE) | CAP_TO_MASK(CAP_SYS_RAWIO) | \
75640 + CAP_TO_MASK(CAP_SYS_PACCT) | CAP_TO_MASK(CAP_SYS_ADMIN) | \
75641 + CAP_TO_MASK(CAP_SYS_BOOT) | CAP_TO_MASK(CAP_SYS_TIME) | \
75642 + CAP_TO_MASK(CAP_NET_RAW) | CAP_TO_MASK(CAP_SYS_TTY_CONFIG) | \
75643 + CAP_TO_MASK(CAP_IPC_OWNER) | CAP_TO_MASK(CAP_SETFCAP), \
75644 + CAP_TO_MASK(CAP_SYSLOG) | CAP_TO_MASK(CAP_MAC_ADMIN) }}
75645 +
75646 +#define security_learn(normal_msg,args...) \
75647 +({ \
75648 + read_lock(&grsec_exec_file_lock); \
75649 + gr_add_learn_entry(normal_msg "\n", ## args); \
75650 + read_unlock(&grsec_exec_file_lock); \
75651 +})
75652 +
75653 +enum {
75654 + GR_DO_AUDIT,
75655 + GR_DONT_AUDIT,
75656 + /* used for non-audit messages that we shouldn't kill the task on */
75657 + GR_DONT_AUDIT_GOOD
75658 +};
75659 +
75660 +enum {
75661 + GR_TTYSNIFF,
75662 + GR_RBAC,
75663 + GR_RBAC_STR,
75664 + GR_STR_RBAC,
75665 + GR_RBAC_MODE2,
75666 + GR_RBAC_MODE3,
75667 + GR_FILENAME,
75668 + GR_SYSCTL_HIDDEN,
75669 + GR_NOARGS,
75670 + GR_ONE_INT,
75671 + GR_ONE_INT_TWO_STR,
75672 + GR_ONE_STR,
75673 + GR_STR_INT,
75674 + GR_TWO_STR_INT,
75675 + GR_TWO_INT,
75676 + GR_TWO_U64,
75677 + GR_THREE_INT,
75678 + GR_FIVE_INT_TWO_STR,
75679 + GR_TWO_STR,
75680 + GR_THREE_STR,
75681 + GR_FOUR_STR,
75682 + GR_STR_FILENAME,
75683 + GR_FILENAME_STR,
75684 + GR_FILENAME_TWO_INT,
75685 + GR_FILENAME_TWO_INT_STR,
75686 + GR_TEXTREL,
75687 + GR_PTRACE,
75688 + GR_RESOURCE,
75689 + GR_CAP,
75690 + GR_SIG,
75691 + GR_SIG2,
75692 + GR_CRASH1,
75693 + GR_CRASH2,
75694 + GR_PSACCT,
75695 + GR_RWXMAP,
75696 + GR_RWXMAPVMA
75697 +};
75698 +
75699 +#define gr_log_hidden_sysctl(audit, msg, str) gr_log_varargs(audit, msg, GR_SYSCTL_HIDDEN, str)
75700 +#define gr_log_ttysniff(audit, msg, task) gr_log_varargs(audit, msg, GR_TTYSNIFF, task)
75701 +#define gr_log_fs_rbac_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_RBAC, dentry, mnt)
75702 +#define gr_log_fs_rbac_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_RBAC_STR, dentry, mnt, str)
75703 +#define gr_log_fs_str_rbac(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_RBAC, str, dentry, mnt)
75704 +#define gr_log_fs_rbac_mode2(audit, msg, dentry, mnt, str1, str2) gr_log_varargs(audit, msg, GR_RBAC_MODE2, dentry, mnt, str1, str2)
75705 +#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)
75706 +#define gr_log_fs_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_FILENAME, dentry, mnt)
75707 +#define gr_log_noargs(audit, msg) gr_log_varargs(audit, msg, GR_NOARGS)
75708 +#define gr_log_int(audit, msg, num) gr_log_varargs(audit, msg, GR_ONE_INT, num)
75709 +#define gr_log_int_str2(audit, msg, num, str1, str2) gr_log_varargs(audit, msg, GR_ONE_INT_TWO_STR, num, str1, str2)
75710 +#define gr_log_str(audit, msg, str) gr_log_varargs(audit, msg, GR_ONE_STR, str)
75711 +#define gr_log_str_int(audit, msg, str, num) gr_log_varargs(audit, msg, GR_STR_INT, str, num)
75712 +#define gr_log_int_int(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_INT, num1, num2)
75713 +#define gr_log_two_u64(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_U64, num1, num2)
75714 +#define gr_log_int3(audit, msg, num1, num2, num3) gr_log_varargs(audit, msg, GR_THREE_INT, num1, num2, num3)
75715 +#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)
75716 +#define gr_log_str_str(audit, msg, str1, str2) gr_log_varargs(audit, msg, GR_TWO_STR, str1, str2)
75717 +#define gr_log_str2_int(audit, msg, str1, str2, num) gr_log_varargs(audit, msg, GR_TWO_STR_INT, str1, str2, num)
75718 +#define gr_log_str3(audit, msg, str1, str2, str3) gr_log_varargs(audit, msg, GR_THREE_STR, str1, str2, str3)
75719 +#define gr_log_str4(audit, msg, str1, str2, str3, str4) gr_log_varargs(audit, msg, GR_FOUR_STR, str1, str2, str3, str4)
75720 +#define gr_log_str_fs(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_FILENAME, str, dentry, mnt)
75721 +#define gr_log_fs_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_FILENAME_STR, dentry, mnt, str)
75722 +#define gr_log_fs_int2(audit, msg, dentry, mnt, num1, num2) gr_log_varargs(audit, msg, GR_FILENAME_TWO_INT, dentry, mnt, num1, num2)
75723 +#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)
75724 +#define gr_log_textrel_ulong_ulong(audit, msg, file, ulong1, ulong2) gr_log_varargs(audit, msg, GR_TEXTREL, file, ulong1, ulong2)
75725 +#define gr_log_ptrace(audit, msg, task) gr_log_varargs(audit, msg, GR_PTRACE, task)
75726 +#define gr_log_res_ulong2_str(audit, msg, task, ulong1, str, ulong2) gr_log_varargs(audit, msg, GR_RESOURCE, task, ulong1, str, ulong2)
75727 +#define gr_log_cap(audit, msg, task, str) gr_log_varargs(audit, msg, GR_CAP, task, str)
75728 +#define gr_log_sig_addr(audit, msg, str, addr) gr_log_varargs(audit, msg, GR_SIG, str, addr)
75729 +#define gr_log_sig_task(audit, msg, task, num) gr_log_varargs(audit, msg, GR_SIG2, task, num)
75730 +#define gr_log_crash1(audit, msg, task, ulong) gr_log_varargs(audit, msg, GR_CRASH1, task, ulong)
75731 +#define gr_log_crash2(audit, msg, task, ulong1) gr_log_varargs(audit, msg, GR_CRASH2, task, ulong1)
75732 +#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)
75733 +#define gr_log_rwxmap(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAP, str)
75734 +#define gr_log_rwxmap_vma(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAPVMA, str)
75735 +
75736 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...);
75737 +
75738 +#endif
75739 +
75740 +#endif
75741 diff --git a/include/linux/grmsg.h b/include/linux/grmsg.h
75742 new file mode 100644
75743 index 0000000..378a81a
75744 --- /dev/null
75745 +++ b/include/linux/grmsg.h
75746 @@ -0,0 +1,114 @@
75747 +#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"
75748 +#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"
75749 +#define GR_PTRACE_ACL_MSG "denied ptrace of %.950s(%.16s:%d) by "
75750 +#define GR_STOPMOD_MSG "denied modification of module state by "
75751 +#define GR_ROFS_BLOCKWRITE_MSG "denied write to block device %.950s by "
75752 +#define GR_ROFS_MOUNT_MSG "denied writable mount of %.950s by "
75753 +#define GR_IOPERM_MSG "denied use of ioperm() by "
75754 +#define GR_IOPL_MSG "denied use of iopl() by "
75755 +#define GR_SHMAT_ACL_MSG "denied attach of shared memory of UID %u, PID %d, ID %u by "
75756 +#define GR_UNIX_CHROOT_MSG "denied connect() to abstract AF_UNIX socket outside of chroot by "
75757 +#define GR_SHMAT_CHROOT_MSG "denied attach of shared memory outside of chroot by "
75758 +#define GR_MEM_READWRITE_MSG "denied access of range %Lx -> %Lx in /dev/mem by "
75759 +#define GR_SYMLINK_MSG "not following symlink %.950s owned by %d.%d by "
75760 +#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"
75761 +#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"
75762 +#define GR_HIDDEN_ACL_MSG "%s access to hidden file %.950s by "
75763 +#define GR_OPEN_ACL_MSG "%s open of %.950s for%s%s by "
75764 +#define GR_CREATE_ACL_MSG "%s create of %.950s for%s%s by "
75765 +#define GR_FIFO_MSG "denied writing FIFO %.950s of %d.%d by "
75766 +#define GR_MKNOD_CHROOT_MSG "denied mknod of %.950s from chroot by "
75767 +#define GR_MKNOD_ACL_MSG "%s mknod of %.950s by "
75768 +#define GR_UNIXCONNECT_ACL_MSG "%s connect() to the unix domain socket %.950s by "
75769 +#define GR_TTYSNIFF_ACL_MSG "terminal being sniffed by IP:%pI4 %.480s[%.16s:%d], parent %.480s[%.16s:%d] against "
75770 +#define GR_MKDIR_ACL_MSG "%s mkdir of %.950s by "
75771 +#define GR_RMDIR_ACL_MSG "%s rmdir of %.950s by "
75772 +#define GR_UNLINK_ACL_MSG "%s unlink of %.950s by "
75773 +#define GR_SYMLINK_ACL_MSG "%s symlink from %.480s to %.480s by "
75774 +#define GR_HARDLINK_MSG "denied hardlink of %.930s (owned by %d.%d) to %.30s for "
75775 +#define GR_LINK_ACL_MSG "%s link of %.480s to %.480s by "
75776 +#define GR_INHERIT_ACL_MSG "successful inherit of %.480s's ACL for %.480s by "
75777 +#define GR_RENAME_ACL_MSG "%s rename of %.480s to %.480s by "
75778 +#define GR_UNSAFESHARE_EXEC_ACL_MSG "denied exec with cloned fs of %.950s by "
75779 +#define GR_PTRACE_EXEC_ACL_MSG "denied ptrace of %.950s by "
75780 +#define GR_EXEC_ACL_MSG "%s execution of %.950s by "
75781 +#define GR_EXEC_TPE_MSG "denied untrusted exec (due to %.70s) of %.950s by "
75782 +#define GR_SEGVSTART_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning uid %u from login for %lu seconds"
75783 +#define GR_SEGVNOSUID_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning execution for %lu seconds"
75784 +#define GR_MOUNT_CHROOT_MSG "denied mount of %.256s as %.930s from chroot by "
75785 +#define GR_PIVOT_CHROOT_MSG "denied pivot_root from chroot by "
75786 +#define GR_TRUNCATE_ACL_MSG "%s truncate of %.950s by "
75787 +#define GR_ATIME_ACL_MSG "%s access time change of %.950s by "
75788 +#define GR_ACCESS_ACL_MSG "%s access of %.950s for%s%s%s by "
75789 +#define GR_CHROOT_CHROOT_MSG "denied double chroot to %.950s by "
75790 +#define GR_CHMOD_CHROOT_MSG "denied chmod +s of %.950s by "
75791 +#define GR_CHMOD_ACL_MSG "%s chmod of %.950s by "
75792 +#define GR_CHROOT_FCHDIR_MSG "denied fchdir outside of chroot to %.950s by "
75793 +#define GR_CHOWN_ACL_MSG "%s chown of %.950s by "
75794 +#define GR_SETXATTR_ACL_MSG "%s setting extended attributes of %.950s by "
75795 +#define GR_WRITLIB_ACL_MSG "denied load of writable library %.950s by "
75796 +#define GR_INITF_ACL_MSG "init_variables() failed %s by "
75797 +#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"
75798 +#define GR_DEV_ACL_MSG "/dev/grsec: %d bytes sent %d required, being fed garbage by "
75799 +#define GR_SHUTS_ACL_MSG "shutdown auth success for "
75800 +#define GR_SHUTF_ACL_MSG "shutdown auth failure for "
75801 +#define GR_SHUTI_ACL_MSG "ignoring shutdown for disabled RBAC system for "
75802 +#define GR_SEGVMODS_ACL_MSG "segvmod auth success for "
75803 +#define GR_SEGVMODF_ACL_MSG "segvmod auth failure for "
75804 +#define GR_SEGVMODI_ACL_MSG "ignoring segvmod for disabled RBAC system for "
75805 +#define GR_ENABLE_ACL_MSG "%s RBAC system loaded by "
75806 +#define GR_ENABLEF_ACL_MSG "unable to load %s for "
75807 +#define GR_RELOADI_ACL_MSG "ignoring reload request for disabled RBAC system"
75808 +#define GR_RELOAD_ACL_MSG "%s RBAC system reloaded by "
75809 +#define GR_RELOADF_ACL_MSG "failed reload of %s for "
75810 +#define GR_SPROLEI_ACL_MSG "ignoring change to special role for disabled RBAC system for "
75811 +#define GR_SPROLES_ACL_MSG "successful change to special role %s (id %d) by "
75812 +#define GR_SPROLEL_ACL_MSG "special role %s (id %d) exited by "
75813 +#define GR_SPROLEF_ACL_MSG "special role %s failure for "
75814 +#define GR_UNSPROLEI_ACL_MSG "ignoring unauth of special role for disabled RBAC system for "
75815 +#define GR_UNSPROLES_ACL_MSG "successful unauth of special role %s (id %d) by "
75816 +#define GR_INVMODE_ACL_MSG "invalid mode %d by "
75817 +#define GR_PRIORITY_CHROOT_MSG "denied priority change of process (%.16s:%d) by "
75818 +#define GR_FAILFORK_MSG "failed fork with errno %s by "
75819 +#define GR_NICE_CHROOT_MSG "denied priority change by "
75820 +#define GR_UNISIGLOG_MSG "%.32s occurred at %p in "
75821 +#define GR_DUALSIGLOG_MSG "signal %d sent to " DEFAULTSECMSG " by "
75822 +#define GR_SIG_ACL_MSG "denied send of signal %d to protected task " DEFAULTSECMSG " by "
75823 +#define GR_SYSCTL_MSG "denied modification of grsecurity sysctl value : %.32s by "
75824 +#define GR_SYSCTL_ACL_MSG "%s sysctl of %.950s for%s%s by "
75825 +#define GR_TIME_MSG "time set by "
75826 +#define GR_DEFACL_MSG "fatal: unable to find subject for (%.16s:%d), loaded by "
75827 +#define GR_MMAP_ACL_MSG "%s executable mmap of %.950s by "
75828 +#define GR_MPROTECT_ACL_MSG "%s executable mprotect of %.950s by "
75829 +#define GR_SOCK_MSG "denied socket(%.16s,%.16s,%.16s) by "
75830 +#define GR_SOCK_NOINET_MSG "denied socket(%.16s,%.16s,%d) by "
75831 +#define GR_BIND_MSG "denied bind() by "
75832 +#define GR_CONNECT_MSG "denied connect() by "
75833 +#define GR_BIND_ACL_MSG "denied bind() to %pI4 port %u sock type %.16s protocol %.16s by "
75834 +#define GR_CONNECT_ACL_MSG "denied connect() to %pI4 port %u sock type %.16s protocol %.16s by "
75835 +#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"
75836 +#define GR_EXEC_CHROOT_MSG "exec of %.980s within chroot by process "
75837 +#define GR_CAP_ACL_MSG "use of %s denied for "
75838 +#define GR_CAP_CHROOT_MSG "use of %s in chroot denied for "
75839 +#define GR_CAP_ACL_MSG2 "use of %s permitted for "
75840 +#define GR_USRCHANGE_ACL_MSG "change to uid %u denied for "
75841 +#define GR_GRPCHANGE_ACL_MSG "change to gid %u denied for "
75842 +#define GR_REMOUNT_AUDIT_MSG "remount of %.256s by "
75843 +#define GR_UNMOUNT_AUDIT_MSG "unmount of %.256s by "
75844 +#define GR_MOUNT_AUDIT_MSG "mount of %.256s to %.256s by "
75845 +#define GR_CHDIR_AUDIT_MSG "chdir to %.980s by "
75846 +#define GR_EXEC_AUDIT_MSG "exec of %.930s (%.128s) by "
75847 +#define GR_RESOURCE_MSG "denied resource overstep by requesting %lu for %.16s against limit %lu for "
75848 +#define GR_RWXMMAP_MSG "denied RWX mmap of %.950s by "
75849 +#define GR_RWXMPROTECT_MSG "denied RWX mprotect of %.950s by "
75850 +#define GR_TEXTREL_AUDIT_MSG "denied text relocation in %.950s, VMA:0x%08lx 0x%08lx by "
75851 +#define GR_PTGNUSTACK_MSG "denied marking stack executable as requested by PT_GNU_STACK marking in %.950s by "
75852 +#define GR_VM86_MSG "denied use of vm86 by "
75853 +#define GR_PTRACE_AUDIT_MSG "process %.950s(%.16s:%d) attached to via ptrace by "
75854 +#define GR_PTRACE_READEXEC_MSG "denied ptrace of unreadable binary %.950s by "
75855 +#define GR_INIT_TRANSFER_MSG "persistent special role transferred privilege to init by "
75856 +#define GR_BADPROCPID_MSG "denied read of sensitive /proc/pid/%s entry via fd passed across exec by "
75857 +#define GR_SYMLINKOWNER_MSG "denied following symlink %.950s since symlink owner %u does not match target owner %u, by "
75858 +#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 "
75859 +#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 "
75860 +#define GR_IPC_DENIED_MSG "denied %s of globally-%sable IPC with creator uid %u by "
75861 diff --git a/include/linux/grsecurity.h b/include/linux/grsecurity.h
75862 new file mode 100644
75863 index 0000000..134860c
75864 --- /dev/null
75865 +++ b/include/linux/grsecurity.h
75866 @@ -0,0 +1,243 @@
75867 +#ifndef GR_SECURITY_H
75868 +#define GR_SECURITY_H
75869 +#include <linux/fs.h>
75870 +#include <linux/fs_struct.h>
75871 +#include <linux/binfmts.h>
75872 +#include <linux/gracl.h>
75873 +
75874 +/* notify of brain-dead configs */
75875 +#if defined(CONFIG_GRKERNSEC_PROC_USER) && defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
75876 +#error "CONFIG_GRKERNSEC_PROC_USER and CONFIG_GRKERNSEC_PROC_USERGROUP cannot both be enabled."
75877 +#endif
75878 +#if defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_PAGEEXEC) && !defined(CONFIG_PAX_SEGMEXEC) && !defined(CONFIG_PAX_KERNEXEC)
75879 +#error "CONFIG_PAX_NOEXEC enabled, but PAGEEXEC, SEGMEXEC, and KERNEXEC are disabled."
75880 +#endif
75881 +#if defined(CONFIG_PAX_ASLR) && !defined(CONFIG_PAX_RANDKSTACK) && !defined(CONFIG_PAX_RANDUSTACK) && !defined(CONFIG_PAX_RANDMMAP)
75882 +#error "CONFIG_PAX_ASLR enabled, but RANDKSTACK, RANDUSTACK, and RANDMMAP are disabled."
75883 +#endif
75884 +#if defined(CONFIG_PAX) && !defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_ASLR)
75885 +#error "CONFIG_PAX enabled, but no PaX options are enabled."
75886 +#endif
75887 +
75888 +int gr_handle_new_usb(void);
75889 +
75890 +void gr_handle_brute_attach(int dumpable);
75891 +void gr_handle_brute_check(void);
75892 +void gr_handle_kernel_exploit(void);
75893 +
75894 +char gr_roletype_to_char(void);
75895 +
75896 +int gr_acl_enable_at_secure(void);
75897 +
75898 +int gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs);
75899 +int gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs);
75900 +
75901 +void gr_del_task_from_ip_table(struct task_struct *p);
75902 +
75903 +int gr_pid_is_chrooted(struct task_struct *p);
75904 +int gr_handle_chroot_fowner(struct pid *pid, enum pid_type type);
75905 +int gr_handle_chroot_nice(void);
75906 +int gr_handle_chroot_sysctl(const int op);
75907 +int gr_handle_chroot_setpriority(struct task_struct *p,
75908 + const int niceval);
75909 +int gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt);
75910 +int gr_handle_chroot_chroot(const struct dentry *dentry,
75911 + const struct vfsmount *mnt);
75912 +void gr_handle_chroot_chdir(const struct path *path);
75913 +int gr_handle_chroot_chmod(const struct dentry *dentry,
75914 + const struct vfsmount *mnt, const int mode);
75915 +int gr_handle_chroot_mknod(const struct dentry *dentry,
75916 + const struct vfsmount *mnt, const int mode);
75917 +int gr_handle_chroot_mount(const struct dentry *dentry,
75918 + const struct vfsmount *mnt,
75919 + const char *dev_name);
75920 +int gr_handle_chroot_pivot(void);
75921 +int gr_handle_chroot_unix(const pid_t pid);
75922 +
75923 +int gr_handle_rawio(const struct inode *inode);
75924 +
75925 +void gr_handle_ioperm(void);
75926 +void gr_handle_iopl(void);
75927 +
75928 +umode_t gr_acl_umask(void);
75929 +
75930 +int gr_tpe_allow(const struct file *file);
75931 +
75932 +void gr_set_chroot_entries(struct task_struct *task, const struct path *path);
75933 +void gr_clear_chroot_entries(struct task_struct *task);
75934 +
75935 +void gr_log_forkfail(const int retval);
75936 +void gr_log_timechange(void);
75937 +void gr_log_signal(const int sig, const void *addr, const struct task_struct *t);
75938 +void gr_log_chdir(const struct dentry *dentry,
75939 + const struct vfsmount *mnt);
75940 +void gr_log_chroot_exec(const struct dentry *dentry,
75941 + const struct vfsmount *mnt);
75942 +void gr_log_remount(const char *devname, const int retval);
75943 +void gr_log_unmount(const char *devname, const int retval);
75944 +void gr_log_mount(const char *from, const char *to, const int retval);
75945 +void gr_log_textrel(struct vm_area_struct *vma);
75946 +void gr_log_ptgnustack(struct file *file);
75947 +void gr_log_rwxmmap(struct file *file);
75948 +void gr_log_rwxmprotect(struct vm_area_struct *vma);
75949 +
75950 +int gr_handle_follow_link(const struct inode *parent,
75951 + const struct inode *inode,
75952 + const struct dentry *dentry,
75953 + const struct vfsmount *mnt);
75954 +int gr_handle_fifo(const struct dentry *dentry,
75955 + const struct vfsmount *mnt,
75956 + const struct dentry *dir, const int flag,
75957 + const int acc_mode);
75958 +int gr_handle_hardlink(const struct dentry *dentry,
75959 + const struct vfsmount *mnt,
75960 + struct inode *inode,
75961 + const int mode, const struct filename *to);
75962 +
75963 +int gr_is_capable(const int cap);
75964 +int gr_is_capable_nolog(const int cap);
75965 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
75966 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap);
75967 +
75968 +void gr_copy_label(struct task_struct *tsk);
75969 +void gr_handle_crash(struct task_struct *task, const int sig);
75970 +int gr_handle_signal(const struct task_struct *p, const int sig);
75971 +int gr_check_crash_uid(const kuid_t uid);
75972 +int gr_check_protected_task(const struct task_struct *task);
75973 +int gr_check_protected_task_fowner(struct pid *pid, enum pid_type type);
75974 +int gr_acl_handle_mmap(const struct file *file,
75975 + const unsigned long prot);
75976 +int gr_acl_handle_mprotect(const struct file *file,
75977 + const unsigned long prot);
75978 +int gr_check_hidden_task(const struct task_struct *tsk);
75979 +__u32 gr_acl_handle_truncate(const struct dentry *dentry,
75980 + const struct vfsmount *mnt);
75981 +__u32 gr_acl_handle_utime(const struct dentry *dentry,
75982 + const struct vfsmount *mnt);
75983 +__u32 gr_acl_handle_access(const struct dentry *dentry,
75984 + const struct vfsmount *mnt, const int fmode);
75985 +__u32 gr_acl_handle_chmod(const struct dentry *dentry,
75986 + const struct vfsmount *mnt, umode_t *mode);
75987 +__u32 gr_acl_handle_chown(const struct dentry *dentry,
75988 + const struct vfsmount *mnt);
75989 +__u32 gr_acl_handle_setxattr(const struct dentry *dentry,
75990 + const struct vfsmount *mnt);
75991 +int gr_handle_ptrace(struct task_struct *task, const long request);
75992 +int gr_handle_proc_ptrace(struct task_struct *task);
75993 +__u32 gr_acl_handle_execve(const struct dentry *dentry,
75994 + const struct vfsmount *mnt);
75995 +int gr_check_crash_exec(const struct file *filp);
75996 +int gr_acl_is_enabled(void);
75997 +void gr_set_role_label(struct task_struct *task, const kuid_t uid,
75998 + const kgid_t gid);
75999 +int gr_set_proc_label(const struct dentry *dentry,
76000 + const struct vfsmount *mnt,
76001 + const int unsafe_flags);
76002 +__u32 gr_acl_handle_hidden_file(const struct dentry *dentry,
76003 + const struct vfsmount *mnt);
76004 +__u32 gr_acl_handle_open(const struct dentry *dentry,
76005 + const struct vfsmount *mnt, int acc_mode);
76006 +__u32 gr_acl_handle_creat(const struct dentry *dentry,
76007 + const struct dentry *p_dentry,
76008 + const struct vfsmount *p_mnt,
76009 + int open_flags, int acc_mode, const int imode);
76010 +void gr_handle_create(const struct dentry *dentry,
76011 + const struct vfsmount *mnt);
76012 +void gr_handle_proc_create(const struct dentry *dentry,
76013 + const struct inode *inode);
76014 +__u32 gr_acl_handle_mknod(const struct dentry *new_dentry,
76015 + const struct dentry *parent_dentry,
76016 + const struct vfsmount *parent_mnt,
76017 + const int mode);
76018 +__u32 gr_acl_handle_mkdir(const struct dentry *new_dentry,
76019 + const struct dentry *parent_dentry,
76020 + const struct vfsmount *parent_mnt);
76021 +__u32 gr_acl_handle_rmdir(const struct dentry *dentry,
76022 + const struct vfsmount *mnt);
76023 +void gr_handle_delete(const ino_t ino, const dev_t dev);
76024 +__u32 gr_acl_handle_unlink(const struct dentry *dentry,
76025 + const struct vfsmount *mnt);
76026 +__u32 gr_acl_handle_symlink(const struct dentry *new_dentry,
76027 + const struct dentry *parent_dentry,
76028 + const struct vfsmount *parent_mnt,
76029 + const struct filename *from);
76030 +__u32 gr_acl_handle_link(const struct dentry *new_dentry,
76031 + const struct dentry *parent_dentry,
76032 + const struct vfsmount *parent_mnt,
76033 + const struct dentry *old_dentry,
76034 + const struct vfsmount *old_mnt, const struct filename *to);
76035 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target);
76036 +int gr_acl_handle_rename(struct dentry *new_dentry,
76037 + struct dentry *parent_dentry,
76038 + const struct vfsmount *parent_mnt,
76039 + struct dentry *old_dentry,
76040 + struct inode *old_parent_inode,
76041 + struct vfsmount *old_mnt, const struct filename *newname);
76042 +void gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
76043 + struct dentry *old_dentry,
76044 + struct dentry *new_dentry,
76045 + struct vfsmount *mnt, const __u8 replace);
76046 +__u32 gr_check_link(const struct dentry *new_dentry,
76047 + const struct dentry *parent_dentry,
76048 + const struct vfsmount *parent_mnt,
76049 + const struct dentry *old_dentry,
76050 + const struct vfsmount *old_mnt);
76051 +int gr_acl_handle_filldir(const struct file *file, const char *name,
76052 + const unsigned int namelen, const ino_t ino);
76053 +
76054 +__u32 gr_acl_handle_unix(const struct dentry *dentry,
76055 + const struct vfsmount *mnt);
76056 +void gr_acl_handle_exit(void);
76057 +void gr_acl_handle_psacct(struct task_struct *task, const long code);
76058 +int gr_acl_handle_procpidmem(const struct task_struct *task);
76059 +int gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags);
76060 +int gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode);
76061 +void gr_audit_ptrace(struct task_struct *task);
76062 +dev_t gr_get_dev_from_dentry(struct dentry *dentry);
76063 +void gr_put_exec_file(struct task_struct *task);
76064 +
76065 +int gr_ptrace_readexec(struct file *file, int unsafe_flags);
76066 +
76067 +#if defined(CONFIG_GRKERNSEC) && (defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC))
76068 +extern void gr_learn_resource(const struct task_struct *task, const int res,
76069 + const unsigned long wanted, const int gt);
76070 +#else
76071 +static inline void gr_learn_resource(const struct task_struct *task, const int res,
76072 + const unsigned long wanted, const int gt)
76073 +{
76074 +}
76075 +#endif
76076 +
76077 +#ifdef CONFIG_GRKERNSEC_RESLOG
76078 +extern void gr_log_resource(const struct task_struct *task, const int res,
76079 + const unsigned long wanted, const int gt);
76080 +#else
76081 +static inline void gr_log_resource(const struct task_struct *task, const int res,
76082 + const unsigned long wanted, const int gt)
76083 +{
76084 +}
76085 +#endif
76086 +
76087 +#ifdef CONFIG_GRKERNSEC
76088 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p);
76089 +void gr_handle_vm86(void);
76090 +void gr_handle_mem_readwrite(u64 from, u64 to);
76091 +
76092 +void gr_log_badprocpid(const char *entry);
76093 +
76094 +extern int grsec_enable_dmesg;
76095 +extern int grsec_disable_privio;
76096 +
76097 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
76098 +extern kgid_t grsec_proc_gid;
76099 +#endif
76100 +
76101 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
76102 +extern int grsec_enable_chroot_findtask;
76103 +#endif
76104 +#ifdef CONFIG_GRKERNSEC_SETXID
76105 +extern int grsec_enable_setxid;
76106 +#endif
76107 +#endif
76108 +
76109 +#endif
76110 diff --git a/include/linux/grsock.h b/include/linux/grsock.h
76111 new file mode 100644
76112 index 0000000..e7ffaaf
76113 --- /dev/null
76114 +++ b/include/linux/grsock.h
76115 @@ -0,0 +1,19 @@
76116 +#ifndef __GRSOCK_H
76117 +#define __GRSOCK_H
76118 +
76119 +extern void gr_attach_curr_ip(const struct sock *sk);
76120 +extern int gr_handle_sock_all(const int family, const int type,
76121 + const int protocol);
76122 +extern int gr_handle_sock_server(const struct sockaddr *sck);
76123 +extern int gr_handle_sock_server_other(const struct sock *sck);
76124 +extern int gr_handle_sock_client(const struct sockaddr *sck);
76125 +extern int gr_search_connect(struct socket * sock,
76126 + struct sockaddr_in * addr);
76127 +extern int gr_search_bind(struct socket * sock,
76128 + struct sockaddr_in * addr);
76129 +extern int gr_search_listen(struct socket * sock);
76130 +extern int gr_search_accept(struct socket * sock);
76131 +extern int gr_search_socket(const int domain, const int type,
76132 + const int protocol);
76133 +
76134 +#endif
76135 diff --git a/include/linux/highmem.h b/include/linux/highmem.h
76136 index 7fb31da..08b5114 100644
76137 --- a/include/linux/highmem.h
76138 +++ b/include/linux/highmem.h
76139 @@ -189,6 +189,18 @@ static inline void clear_highpage(struct page *page)
76140 kunmap_atomic(kaddr);
76141 }
76142
76143 +static inline void sanitize_highpage(struct page *page)
76144 +{
76145 + void *kaddr;
76146 + unsigned long flags;
76147 +
76148 + local_irq_save(flags);
76149 + kaddr = kmap_atomic(page);
76150 + clear_page(kaddr);
76151 + kunmap_atomic(kaddr);
76152 + local_irq_restore(flags);
76153 +}
76154 +
76155 static inline void zero_user_segments(struct page *page,
76156 unsigned start1, unsigned end1,
76157 unsigned start2, unsigned end2)
76158 diff --git a/include/linux/hwmon-sysfs.h b/include/linux/hwmon-sysfs.h
76159 index 1c7b89a..7dda400 100644
76160 --- a/include/linux/hwmon-sysfs.h
76161 +++ b/include/linux/hwmon-sysfs.h
76162 @@ -25,7 +25,8 @@
76163 struct sensor_device_attribute{
76164 struct device_attribute dev_attr;
76165 int index;
76166 -};
76167 +} __do_const;
76168 +typedef struct sensor_device_attribute __no_const sensor_device_attribute_no_const;
76169 #define to_sensor_dev_attr(_dev_attr) \
76170 container_of(_dev_attr, struct sensor_device_attribute, dev_attr)
76171
76172 @@ -41,7 +42,8 @@ struct sensor_device_attribute_2 {
76173 struct device_attribute dev_attr;
76174 u8 index;
76175 u8 nr;
76176 -};
76177 +} __do_const;
76178 +typedef struct sensor_device_attribute_2 __no_const sensor_device_attribute_2_no_const;
76179 #define to_sensor_dev_attr_2(_dev_attr) \
76180 container_of(_dev_attr, struct sensor_device_attribute_2, dev_attr)
76181
76182 diff --git a/include/linux/i2c.h b/include/linux/i2c.h
76183 index 2ab11dc..663a3f2 100644
76184 --- a/include/linux/i2c.h
76185 +++ b/include/linux/i2c.h
76186 @@ -366,6 +366,7 @@ struct i2c_algorithm {
76187 /* To determine what the adapter supports */
76188 u32 (*functionality) (struct i2c_adapter *);
76189 };
76190 +typedef struct i2c_algorithm __no_const i2c_algorithm_no_const;
76191
76192 /**
76193 * struct i2c_bus_recovery_info - I2C bus recovery information
76194 diff --git a/include/linux/i2o.h b/include/linux/i2o.h
76195 index d23c3c2..eb63c81 100644
76196 --- a/include/linux/i2o.h
76197 +++ b/include/linux/i2o.h
76198 @@ -565,7 +565,7 @@ struct i2o_controller {
76199 struct i2o_device *exec; /* Executive */
76200 #if BITS_PER_LONG == 64
76201 spinlock_t context_list_lock; /* lock for context_list */
76202 - atomic_t context_list_counter; /* needed for unique contexts */
76203 + atomic_unchecked_t context_list_counter; /* needed for unique contexts */
76204 struct list_head context_list; /* list of context id's
76205 and pointers */
76206 #endif
76207 diff --git a/include/linux/if_pppox.h b/include/linux/if_pppox.h
76208 index aff7ad8..3942bbd 100644
76209 --- a/include/linux/if_pppox.h
76210 +++ b/include/linux/if_pppox.h
76211 @@ -76,7 +76,7 @@ struct pppox_proto {
76212 int (*ioctl)(struct socket *sock, unsigned int cmd,
76213 unsigned long arg);
76214 struct module *owner;
76215 -};
76216 +} __do_const;
76217
76218 extern int register_pppox_proto(int proto_num, const struct pppox_proto *pp);
76219 extern void unregister_pppox_proto(int proto_num);
76220 diff --git a/include/linux/init.h b/include/linux/init.h
76221 index f1c27a71..7d6010e 100644
76222 --- a/include/linux/init.h
76223 +++ b/include/linux/init.h
76224 @@ -39,9 +39,17 @@
76225 * Also note, that this data cannot be "const".
76226 */
76227
76228 +#define add_init_latent_entropy __latent_entropy
76229 +
76230 +#ifdef CONFIG_MEMORY_HOTPLUG
76231 +#define add_meminit_latent_entropy
76232 +#else
76233 +#define add_meminit_latent_entropy __latent_entropy
76234 +#endif
76235 +
76236 /* These are for everybody (although not all archs will actually
76237 discard it in modules) */
76238 -#define __init __section(.init.text) __cold notrace
76239 +#define __init __section(.init.text) __cold notrace add_init_latent_entropy
76240 #define __initdata __section(.init.data)
76241 #define __initconst __constsection(.init.rodata)
76242 #define __exitdata __section(.exit.data)
76243 @@ -102,7 +110,7 @@
76244 #define __cpuexitconst
76245
76246 /* Used for MEMORY_HOTPLUG */
76247 -#define __meminit __section(.meminit.text) __cold notrace
76248 +#define __meminit __section(.meminit.text) __cold notrace add_meminit_latent_entropy
76249 #define __meminitdata __section(.meminit.data)
76250 #define __meminitconst __constsection(.meminit.rodata)
76251 #define __memexit __section(.memexit.text) __exitused __cold notrace
76252 diff --git a/include/linux/init_task.h b/include/linux/init_task.h
76253 index 5cd0f09..c9f67cc 100644
76254 --- a/include/linux/init_task.h
76255 +++ b/include/linux/init_task.h
76256 @@ -154,6 +154,12 @@ extern struct task_group root_task_group;
76257
76258 #define INIT_TASK_COMM "swapper"
76259
76260 +#ifdef CONFIG_X86
76261 +#define INIT_TASK_THREAD_INFO .tinfo = INIT_THREAD_INFO,
76262 +#else
76263 +#define INIT_TASK_THREAD_INFO
76264 +#endif
76265 +
76266 /*
76267 * INIT_TASK is used to set up the first task table, touch at
76268 * your own risk!. Base=0, limit=0x1fffff (=2MB)
76269 @@ -193,6 +199,7 @@ extern struct task_group root_task_group;
76270 RCU_POINTER_INITIALIZER(cred, &init_cred), \
76271 .comm = INIT_TASK_COMM, \
76272 .thread = INIT_THREAD, \
76273 + INIT_TASK_THREAD_INFO \
76274 .fs = &init_fs, \
76275 .files = &init_files, \
76276 .signal = &init_signals, \
76277 diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
76278 index 5e865b5..71bd258 100644
76279 --- a/include/linux/interrupt.h
76280 +++ b/include/linux/interrupt.h
76281 @@ -361,7 +361,7 @@ enum
76282 /* map softirq index to softirq name. update 'softirq_to_name' in
76283 * kernel/softirq.c when adding a new softirq.
76284 */
76285 -extern char *softirq_to_name[NR_SOFTIRQS];
76286 +extern const char * const softirq_to_name[NR_SOFTIRQS];
76287
76288 /* softirq mask and active fields moved to irq_cpustat_t in
76289 * asm/hardirq.h to get better cache usage. KAO
76290 @@ -369,12 +369,12 @@ extern char *softirq_to_name[NR_SOFTIRQS];
76291
76292 struct softirq_action
76293 {
76294 - void (*action)(struct softirq_action *);
76295 -};
76296 + void (*action)(void);
76297 +} __no_const;
76298
76299 asmlinkage void do_softirq(void);
76300 asmlinkage void __do_softirq(void);
76301 -extern void open_softirq(int nr, void (*action)(struct softirq_action *));
76302 +extern void open_softirq(int nr, void (*action)(void));
76303 extern void softirq_init(void);
76304 extern void __raise_softirq_irqoff(unsigned int nr);
76305
76306 diff --git a/include/linux/iommu.h b/include/linux/iommu.h
76307 index 7ea319e..f9e971d 100644
76308 --- a/include/linux/iommu.h
76309 +++ b/include/linux/iommu.h
76310 @@ -129,7 +129,7 @@ struct iommu_ops {
76311 u32 (*domain_get_windows)(struct iommu_domain *domain);
76312
76313 unsigned long pgsize_bitmap;
76314 -};
76315 +} __do_const;
76316
76317 #define IOMMU_GROUP_NOTIFY_ADD_DEVICE 1 /* Device added */
76318 #define IOMMU_GROUP_NOTIFY_DEL_DEVICE 2 /* Pre Device removed */
76319 diff --git a/include/linux/ioport.h b/include/linux/ioport.h
76320 index 89b7c24..382af74 100644
76321 --- a/include/linux/ioport.h
76322 +++ b/include/linux/ioport.h
76323 @@ -161,7 +161,7 @@ struct resource *lookup_resource(struct resource *root, resource_size_t start);
76324 int adjust_resource(struct resource *res, resource_size_t start,
76325 resource_size_t size);
76326 resource_size_t resource_alignment(struct resource *res);
76327 -static inline resource_size_t resource_size(const struct resource *res)
76328 +static inline resource_size_t __intentional_overflow(-1) resource_size(const struct resource *res)
76329 {
76330 return res->end - res->start + 1;
76331 }
76332 diff --git a/include/linux/irq.h b/include/linux/irq.h
76333 index 56bb0dc..8ae94d62 100644
76334 --- a/include/linux/irq.h
76335 +++ b/include/linux/irq.h
76336 @@ -333,7 +333,8 @@ struct irq_chip {
76337 void (*irq_print_chip)(struct irq_data *data, struct seq_file *p);
76338
76339 unsigned long flags;
76340 -};
76341 +} __do_const;
76342 +typedef struct irq_chip __no_const irq_chip_no_const;
76343
76344 /*
76345 * irq_chip specific flags
76346 diff --git a/include/linux/irqchip/arm-gic.h b/include/linux/irqchip/arm-gic.h
76347 index 0e5d9ec..46acb3a 100644
76348 --- a/include/linux/irqchip/arm-gic.h
76349 +++ b/include/linux/irqchip/arm-gic.h
76350 @@ -59,9 +59,11 @@
76351
76352 #ifndef __ASSEMBLY__
76353
76354 +#include <linux/irq.h>
76355 +
76356 struct device_node;
76357
76358 -extern struct irq_chip gic_arch_extn;
76359 +extern irq_chip_no_const gic_arch_extn;
76360
76361 void gic_init_bases(unsigned int, int, void __iomem *, void __iomem *,
76362 u32 offset, struct device_node *);
76363 diff --git a/include/linux/jiffies.h b/include/linux/jiffies.h
76364 index d235e88..8ccbe74 100644
76365 --- a/include/linux/jiffies.h
76366 +++ b/include/linux/jiffies.h
76367 @@ -292,14 +292,14 @@ extern unsigned long preset_lpj;
76368 /*
76369 * Convert various time units to each other:
76370 */
76371 -extern unsigned int jiffies_to_msecs(const unsigned long j);
76372 -extern unsigned int jiffies_to_usecs(const unsigned long j);
76373 -extern unsigned long msecs_to_jiffies(const unsigned int m);
76374 -extern unsigned long usecs_to_jiffies(const unsigned int u);
76375 -extern unsigned long timespec_to_jiffies(const struct timespec *value);
76376 +extern unsigned int jiffies_to_msecs(const unsigned long j) __intentional_overflow(-1);
76377 +extern unsigned int jiffies_to_usecs(const unsigned long j) __intentional_overflow(-1);
76378 +extern unsigned long msecs_to_jiffies(const unsigned int m) __intentional_overflow(-1);
76379 +extern unsigned long usecs_to_jiffies(const unsigned int u) __intentional_overflow(-1);
76380 +extern unsigned long timespec_to_jiffies(const struct timespec *value) __intentional_overflow(-1);
76381 extern void jiffies_to_timespec(const unsigned long jiffies,
76382 struct timespec *value);
76383 -extern unsigned long timeval_to_jiffies(const struct timeval *value);
76384 +extern unsigned long timeval_to_jiffies(const struct timeval *value) __intentional_overflow(-1);
76385 extern void jiffies_to_timeval(const unsigned long jiffies,
76386 struct timeval *value);
76387
76388 diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h
76389 index 6883e19..e854fcb 100644
76390 --- a/include/linux/kallsyms.h
76391 +++ b/include/linux/kallsyms.h
76392 @@ -15,7 +15,8 @@
76393
76394 struct module;
76395
76396 -#ifdef CONFIG_KALLSYMS
76397 +#if !defined(__INCLUDED_BY_HIDESYM) || !defined(CONFIG_KALLSYMS)
76398 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
76399 /* Lookup the address for a symbol. Returns 0 if not found. */
76400 unsigned long kallsyms_lookup_name(const char *name);
76401
76402 @@ -106,6 +107,21 @@ static inline int lookup_symbol_attrs(unsigned long addr, unsigned long *size, u
76403 /* Stupid that this does nothing, but I didn't create this mess. */
76404 #define __print_symbol(fmt, addr)
76405 #endif /*CONFIG_KALLSYMS*/
76406 +#else /* when included by kallsyms.c, vsnprintf.c, kprobes.c, or
76407 + arch/x86/kernel/dumpstack.c, with HIDESYM enabled */
76408 +extern unsigned long kallsyms_lookup_name(const char *name);
76409 +extern void __print_symbol(const char *fmt, unsigned long address);
76410 +extern int sprint_backtrace(char *buffer, unsigned long address);
76411 +extern int sprint_symbol(char *buffer, unsigned long address);
76412 +extern int sprint_symbol_no_offset(char *buffer, unsigned long address);
76413 +const char *kallsyms_lookup(unsigned long addr,
76414 + unsigned long *symbolsize,
76415 + unsigned long *offset,
76416 + char **modname, char *namebuf);
76417 +extern int kallsyms_lookup_size_offset(unsigned long addr,
76418 + unsigned long *symbolsize,
76419 + unsigned long *offset);
76420 +#endif
76421
76422 /* This macro allows us to keep printk typechecking */
76423 static __printf(1, 2)
76424 diff --git a/include/linux/key-type.h b/include/linux/key-type.h
76425 index 518a53a..5e28358 100644
76426 --- a/include/linux/key-type.h
76427 +++ b/include/linux/key-type.h
76428 @@ -125,7 +125,7 @@ struct key_type {
76429 /* internal fields */
76430 struct list_head link; /* link in types list */
76431 struct lock_class_key lock_class; /* key->sem lock class */
76432 -};
76433 +} __do_const;
76434
76435 extern struct key_type key_type_keyring;
76436
76437 diff --git a/include/linux/kgdb.h b/include/linux/kgdb.h
76438 index c6e091b..a940adf 100644
76439 --- a/include/linux/kgdb.h
76440 +++ b/include/linux/kgdb.h
76441 @@ -52,7 +52,7 @@ extern int kgdb_connected;
76442 extern int kgdb_io_module_registered;
76443
76444 extern atomic_t kgdb_setting_breakpoint;
76445 -extern atomic_t kgdb_cpu_doing_single_step;
76446 +extern atomic_unchecked_t kgdb_cpu_doing_single_step;
76447
76448 extern struct task_struct *kgdb_usethread;
76449 extern struct task_struct *kgdb_contthread;
76450 @@ -254,7 +254,7 @@ struct kgdb_arch {
76451 void (*correct_hw_break)(void);
76452
76453 void (*enable_nmi)(bool on);
76454 -};
76455 +} __do_const;
76456
76457 /**
76458 * struct kgdb_io - Describe the interface for an I/O driver to talk with KGDB.
76459 @@ -279,7 +279,7 @@ struct kgdb_io {
76460 void (*pre_exception) (void);
76461 void (*post_exception) (void);
76462 int is_console;
76463 -};
76464 +} __do_const;
76465
76466 extern struct kgdb_arch arch_kgdb_ops;
76467
76468 diff --git a/include/linux/kmod.h b/include/linux/kmod.h
76469 index 0555cc6..40116ce 100644
76470 --- a/include/linux/kmod.h
76471 +++ b/include/linux/kmod.h
76472 @@ -34,6 +34,8 @@ extern char modprobe_path[]; /* for sysctl */
76473 * usually useless though. */
76474 extern __printf(2, 3)
76475 int __request_module(bool wait, const char *name, ...);
76476 +extern __printf(3, 4)
76477 +int ___request_module(bool wait, char *param_name, const char *name, ...);
76478 #define request_module(mod...) __request_module(true, mod)
76479 #define request_module_nowait(mod...) __request_module(false, mod)
76480 #define try_then_request_module(x, mod...) \
76481 @@ -57,6 +59,9 @@ struct subprocess_info {
76482 struct work_struct work;
76483 struct completion *complete;
76484 char *path;
76485 +#ifdef CONFIG_GRKERNSEC
76486 + char *origpath;
76487 +#endif
76488 char **argv;
76489 char **envp;
76490 int wait;
76491 diff --git a/include/linux/kobject.h b/include/linux/kobject.h
76492 index de6dcbcc..4735f88 100644
76493 --- a/include/linux/kobject.h
76494 +++ b/include/linux/kobject.h
76495 @@ -115,7 +115,7 @@ struct kobj_type {
76496 struct attribute **default_attrs;
76497 const struct kobj_ns_type_operations *(*child_ns_type)(struct kobject *kobj);
76498 const void *(*namespace)(struct kobject *kobj);
76499 -};
76500 +} __do_const;
76501
76502 struct kobj_uevent_env {
76503 char *envp[UEVENT_NUM_ENVP];
76504 @@ -138,6 +138,7 @@ struct kobj_attribute {
76505 ssize_t (*store)(struct kobject *kobj, struct kobj_attribute *attr,
76506 const char *buf, size_t count);
76507 };
76508 +typedef struct kobj_attribute __no_const kobj_attribute_no_const;
76509
76510 extern const struct sysfs_ops kobj_sysfs_ops;
76511
76512 diff --git a/include/linux/kobject_ns.h b/include/linux/kobject_ns.h
76513 index df32d25..fb52e27 100644
76514 --- a/include/linux/kobject_ns.h
76515 +++ b/include/linux/kobject_ns.h
76516 @@ -44,7 +44,7 @@ struct kobj_ns_type_operations {
76517 const void *(*netlink_ns)(struct sock *sk);
76518 const void *(*initial_ns)(void);
76519 void (*drop_ns)(void *);
76520 -};
76521 +} __do_const;
76522
76523 int kobj_ns_type_register(const struct kobj_ns_type_operations *ops);
76524 int kobj_ns_type_registered(enum kobj_ns_type type);
76525 diff --git a/include/linux/kref.h b/include/linux/kref.h
76526 index 484604d..0f6c5b6 100644
76527 --- a/include/linux/kref.h
76528 +++ b/include/linux/kref.h
76529 @@ -68,7 +68,7 @@ static inline void kref_get(struct kref *kref)
76530 static inline int kref_sub(struct kref *kref, unsigned int count,
76531 void (*release)(struct kref *kref))
76532 {
76533 - WARN_ON(release == NULL);
76534 + BUG_ON(release == NULL);
76535
76536 if (atomic_sub_and_test((int) count, &kref->refcount)) {
76537 release(kref);
76538 diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
76539 index 0fbbc7a..db081e3 100644
76540 --- a/include/linux/kvm_host.h
76541 +++ b/include/linux/kvm_host.h
76542 @@ -458,7 +458,7 @@ static inline void kvm_irqfd_exit(void)
76543 {
76544 }
76545 #endif
76546 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
76547 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
76548 struct module *module);
76549 void kvm_exit(void);
76550
76551 @@ -632,7 +632,7 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu,
76552 struct kvm_guest_debug *dbg);
76553 int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run);
76554
76555 -int kvm_arch_init(void *opaque);
76556 +int kvm_arch_init(const void *opaque);
76557 void kvm_arch_exit(void);
76558
76559 int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu);
76560 diff --git a/include/linux/libata.h b/include/linux/libata.h
76561 index 0e23c26..6ad8c33 100644
76562 --- a/include/linux/libata.h
76563 +++ b/include/linux/libata.h
76564 @@ -972,7 +972,7 @@ struct ata_port_operations {
76565 * fields must be pointers.
76566 */
76567 const struct ata_port_operations *inherits;
76568 -};
76569 +} __do_const;
76570
76571 struct ata_port_info {
76572 unsigned long flags;
76573 diff --git a/include/linux/linkage.h b/include/linux/linkage.h
76574 index d3e8ad2..a949f68 100644
76575 --- a/include/linux/linkage.h
76576 +++ b/include/linux/linkage.h
76577 @@ -31,6 +31,7 @@
76578 #endif
76579
76580 #define __page_aligned_data __section(.data..page_aligned) __aligned(PAGE_SIZE)
76581 +#define __page_aligned_rodata __read_only __aligned(PAGE_SIZE)
76582 #define __page_aligned_bss __section(.bss..page_aligned) __aligned(PAGE_SIZE)
76583
76584 /*
76585 diff --git a/include/linux/list.h b/include/linux/list.h
76586 index f4d8a2f..38e6e46 100644
76587 --- a/include/linux/list.h
76588 +++ b/include/linux/list.h
76589 @@ -112,6 +112,19 @@ extern void __list_del_entry(struct list_head *entry);
76590 extern void list_del(struct list_head *entry);
76591 #endif
76592
76593 +extern void __pax_list_add(struct list_head *new,
76594 + struct list_head *prev,
76595 + struct list_head *next);
76596 +static inline void pax_list_add(struct list_head *new, struct list_head *head)
76597 +{
76598 + __pax_list_add(new, head, head->next);
76599 +}
76600 +static inline void pax_list_add_tail(struct list_head *new, struct list_head *head)
76601 +{
76602 + __pax_list_add(new, head->prev, head);
76603 +}
76604 +extern void pax_list_del(struct list_head *entry);
76605 +
76606 /**
76607 * list_replace - replace old entry by new one
76608 * @old : the element to be replaced
76609 @@ -145,6 +158,8 @@ static inline void list_del_init(struct list_head *entry)
76610 INIT_LIST_HEAD(entry);
76611 }
76612
76613 +extern void pax_list_del_init(struct list_head *entry);
76614 +
76615 /**
76616 * list_move - delete from one list and add as another's head
76617 * @list: the entry to move
76618 diff --git a/include/linux/math64.h b/include/linux/math64.h
76619 index 69ed5f5..243ed51 100644
76620 --- a/include/linux/math64.h
76621 +++ b/include/linux/math64.h
76622 @@ -15,7 +15,7 @@
76623 * This is commonly provided by 32bit archs to provide an optimized 64bit
76624 * divide.
76625 */
76626 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
76627 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
76628 {
76629 *remainder = dividend % divisor;
76630 return dividend / divisor;
76631 @@ -42,7 +42,7 @@ static inline u64 div64_u64_rem(u64 dividend, u64 divisor, u64 *remainder)
76632 /**
76633 * div64_u64 - unsigned 64bit divide with 64bit divisor
76634 */
76635 -static inline u64 div64_u64(u64 dividend, u64 divisor)
76636 +static inline u64 __intentional_overflow(-1) div64_u64(u64 dividend, u64 divisor)
76637 {
76638 return dividend / divisor;
76639 }
76640 @@ -61,7 +61,7 @@ static inline s64 div64_s64(s64 dividend, s64 divisor)
76641 #define div64_ul(x, y) div_u64((x), (y))
76642
76643 #ifndef div_u64_rem
76644 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
76645 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
76646 {
76647 *remainder = do_div(dividend, divisor);
76648 return dividend;
76649 @@ -77,7 +77,7 @@ extern u64 div64_u64_rem(u64 dividend, u64 divisor, u64 *remainder);
76650 #endif
76651
76652 #ifndef div64_u64
76653 -extern u64 div64_u64(u64 dividend, u64 divisor);
76654 +extern u64 __intentional_overflow(-1) div64_u64(u64 dividend, u64 divisor);
76655 #endif
76656
76657 #ifndef div64_s64
76658 @@ -94,7 +94,7 @@ extern s64 div64_s64(s64 dividend, s64 divisor);
76659 * divide.
76660 */
76661 #ifndef div_u64
76662 -static inline u64 div_u64(u64 dividend, u32 divisor)
76663 +static inline u64 __intentional_overflow(-1) div_u64(u64 dividend, u32 divisor)
76664 {
76665 u32 remainder;
76666 return div_u64_rem(dividend, divisor, &remainder);
76667 diff --git a/include/linux/mempolicy.h b/include/linux/mempolicy.h
76668 index da6716b..2e31db3 100644
76669 --- a/include/linux/mempolicy.h
76670 +++ b/include/linux/mempolicy.h
76671 @@ -91,6 +91,10 @@ static inline struct mempolicy *mpol_dup(struct mempolicy *pol)
76672 }
76673
76674 #define vma_policy(vma) ((vma)->vm_policy)
76675 +static inline void set_vma_policy(struct vm_area_struct *vma, struct mempolicy *pol)
76676 +{
76677 + vma->vm_policy = pol;
76678 +}
76679
76680 static inline void mpol_get(struct mempolicy *pol)
76681 {
76682 @@ -240,6 +244,9 @@ mpol_shared_policy_lookup(struct shared_policy *sp, unsigned long idx)
76683 }
76684
76685 #define vma_policy(vma) NULL
76686 +static inline void set_vma_policy(struct vm_area_struct *vma, struct mempolicy *pol)
76687 +{
76688 +}
76689
76690 static inline int
76691 vma_dup_policy(struct vm_area_struct *src, struct vm_area_struct *dst)
76692 diff --git a/include/linux/mm.h b/include/linux/mm.h
76693 index 8b6e55e..c4edf39 100644
76694 --- a/include/linux/mm.h
76695 +++ b/include/linux/mm.h
76696 @@ -113,6 +113,11 @@ extern unsigned int kobjsize(const void *objp);
76697 #define VM_HUGETLB 0x00400000 /* Huge TLB Page VM */
76698 #define VM_NONLINEAR 0x00800000 /* Is non-linear (remap_file_pages) */
76699 #define VM_ARCH_1 0x01000000 /* Architecture-specific flag */
76700 +
76701 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
76702 +#define VM_PAGEEXEC 0x02000000 /* vma->vm_page_prot needs special handling */
76703 +#endif
76704 +
76705 #define VM_DONTDUMP 0x04000000 /* Do not include in the core dump */
76706
76707 #ifdef CONFIG_MEM_SOFT_DIRTY
76708 @@ -215,8 +220,8 @@ struct vm_operations_struct {
76709 /* called by access_process_vm when get_user_pages() fails, typically
76710 * for use by special VMAs that can switch between memory and hardware
76711 */
76712 - int (*access)(struct vm_area_struct *vma, unsigned long addr,
76713 - void *buf, int len, int write);
76714 + ssize_t (*access)(struct vm_area_struct *vma, unsigned long addr,
76715 + void *buf, size_t len, int write);
76716 #ifdef CONFIG_NUMA
76717 /*
76718 * set_policy() op must add a reference to any non-NULL @new mempolicy
76719 @@ -246,6 +251,7 @@ struct vm_operations_struct {
76720 int (*remap_pages)(struct vm_area_struct *vma, unsigned long addr,
76721 unsigned long size, pgoff_t pgoff);
76722 };
76723 +typedef struct vm_operations_struct __no_const vm_operations_struct_no_const;
76724
76725 struct mmu_gather;
76726 struct inode;
76727 @@ -977,8 +983,8 @@ int follow_pfn(struct vm_area_struct *vma, unsigned long address,
76728 unsigned long *pfn);
76729 int follow_phys(struct vm_area_struct *vma, unsigned long address,
76730 unsigned int flags, unsigned long *prot, resource_size_t *phys);
76731 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
76732 - void *buf, int len, int write);
76733 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
76734 + void *buf, size_t len, int write);
76735
76736 static inline void unmap_shared_mapping_range(struct address_space *mapping,
76737 loff_t const holebegin, loff_t const holelen)
76738 @@ -1017,9 +1023,9 @@ static inline int fixup_user_fault(struct task_struct *tsk,
76739 }
76740 #endif
76741
76742 -extern int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write);
76743 -extern int access_remote_vm(struct mm_struct *mm, unsigned long addr,
76744 - void *buf, int len, int write);
76745 +extern ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write);
76746 +extern ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
76747 + void *buf, size_t len, int write);
76748
76749 long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
76750 unsigned long start, unsigned long nr_pages,
76751 @@ -1051,34 +1057,6 @@ int set_page_dirty(struct page *page);
76752 int set_page_dirty_lock(struct page *page);
76753 int clear_page_dirty_for_io(struct page *page);
76754
76755 -/* Is the vma a continuation of the stack vma above it? */
76756 -static inline int vma_growsdown(struct vm_area_struct *vma, unsigned long addr)
76757 -{
76758 - return vma && (vma->vm_end == addr) && (vma->vm_flags & VM_GROWSDOWN);
76759 -}
76760 -
76761 -static inline int stack_guard_page_start(struct vm_area_struct *vma,
76762 - unsigned long addr)
76763 -{
76764 - return (vma->vm_flags & VM_GROWSDOWN) &&
76765 - (vma->vm_start == addr) &&
76766 - !vma_growsdown(vma->vm_prev, addr);
76767 -}
76768 -
76769 -/* Is the vma a continuation of the stack vma below it? */
76770 -static inline int vma_growsup(struct vm_area_struct *vma, unsigned long addr)
76771 -{
76772 - return vma && (vma->vm_start == addr) && (vma->vm_flags & VM_GROWSUP);
76773 -}
76774 -
76775 -static inline int stack_guard_page_end(struct vm_area_struct *vma,
76776 - unsigned long addr)
76777 -{
76778 - return (vma->vm_flags & VM_GROWSUP) &&
76779 - (vma->vm_end == addr) &&
76780 - !vma_growsup(vma->vm_next, addr);
76781 -}
76782 -
76783 extern pid_t
76784 vm_is_stack(struct task_struct *task, struct vm_area_struct *vma, int in_group);
76785
76786 @@ -1178,6 +1156,15 @@ static inline void sync_mm_rss(struct mm_struct *mm)
76787 }
76788 #endif
76789
76790 +#ifdef CONFIG_MMU
76791 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags);
76792 +#else
76793 +static inline pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
76794 +{
76795 + return __pgprot(0);
76796 +}
76797 +#endif
76798 +
76799 int vma_wants_writenotify(struct vm_area_struct *vma);
76800
76801 extern pte_t *__get_locked_pte(struct mm_struct *mm, unsigned long addr,
76802 @@ -1196,8 +1183,15 @@ static inline int __pud_alloc(struct mm_struct *mm, pgd_t *pgd,
76803 {
76804 return 0;
76805 }
76806 +
76807 +static inline int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd,
76808 + unsigned long address)
76809 +{
76810 + return 0;
76811 +}
76812 #else
76813 int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
76814 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
76815 #endif
76816
76817 #ifdef __PAGETABLE_PMD_FOLDED
76818 @@ -1206,8 +1200,15 @@ static inline int __pmd_alloc(struct mm_struct *mm, pud_t *pud,
76819 {
76820 return 0;
76821 }
76822 +
76823 +static inline int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud,
76824 + unsigned long address)
76825 +{
76826 + return 0;
76827 +}
76828 #else
76829 int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address);
76830 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address);
76831 #endif
76832
76833 int __pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma,
76834 @@ -1225,11 +1226,23 @@ static inline pud_t *pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long a
76835 NULL: pud_offset(pgd, address);
76836 }
76837
76838 +static inline pud_t *pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
76839 +{
76840 + return (unlikely(pgd_none(*pgd)) && __pud_alloc_kernel(mm, pgd, address))?
76841 + NULL: pud_offset(pgd, address);
76842 +}
76843 +
76844 static inline pmd_t *pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
76845 {
76846 return (unlikely(pud_none(*pud)) && __pmd_alloc(mm, pud, address))?
76847 NULL: pmd_offset(pud, address);
76848 }
76849 +
76850 +static inline pmd_t *pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
76851 +{
76852 + return (unlikely(pud_none(*pud)) && __pmd_alloc_kernel(mm, pud, address))?
76853 + NULL: pmd_offset(pud, address);
76854 +}
76855 #endif /* CONFIG_MMU && !__ARCH_HAS_4LEVEL_HACK */
76856
76857 #if USE_SPLIT_PTLOCKS
76858 @@ -1517,7 +1530,7 @@ extern int install_special_mapping(struct mm_struct *mm,
76859 unsigned long addr, unsigned long len,
76860 unsigned long flags, struct page **pages);
76861
76862 -extern unsigned long get_unmapped_area(struct file *, unsigned long, unsigned long, unsigned long, unsigned long);
76863 +extern unsigned long get_unmapped_area(struct file *, unsigned long, unsigned long, unsigned long, unsigned long) __intentional_overflow(-1);
76864
76865 extern unsigned long mmap_region(struct file *file, unsigned long addr,
76866 unsigned long len, vm_flags_t vm_flags, unsigned long pgoff);
76867 @@ -1525,6 +1538,7 @@ extern unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
76868 unsigned long len, unsigned long prot, unsigned long flags,
76869 unsigned long pgoff, unsigned long *populate);
76870 extern int do_munmap(struct mm_struct *, unsigned long, size_t);
76871 +extern int __do_munmap(struct mm_struct *, unsigned long, size_t);
76872
76873 #ifdef CONFIG_MMU
76874 extern int __mm_populate(unsigned long addr, unsigned long len,
76875 @@ -1553,10 +1567,11 @@ struct vm_unmapped_area_info {
76876 unsigned long high_limit;
76877 unsigned long align_mask;
76878 unsigned long align_offset;
76879 + unsigned long threadstack_offset;
76880 };
76881
76882 -extern unsigned long unmapped_area(struct vm_unmapped_area_info *info);
76883 -extern unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info);
76884 +extern unsigned long unmapped_area(const struct vm_unmapped_area_info *info);
76885 +extern unsigned long unmapped_area_topdown(const struct vm_unmapped_area_info *info);
76886
76887 /*
76888 * Search for an unmapped address range.
76889 @@ -1568,7 +1583,7 @@ extern unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info);
76890 * - satisfies (begin_addr & align_mask) == (align_offset & align_mask)
76891 */
76892 static inline unsigned long
76893 -vm_unmapped_area(struct vm_unmapped_area_info *info)
76894 +vm_unmapped_area(const struct vm_unmapped_area_info *info)
76895 {
76896 if (!(info->flags & VM_UNMAPPED_AREA_TOPDOWN))
76897 return unmapped_area(info);
76898 @@ -1631,6 +1646,10 @@ extern struct vm_area_struct * find_vma(struct mm_struct * mm, unsigned long add
76899 extern struct vm_area_struct * find_vma_prev(struct mm_struct * mm, unsigned long addr,
76900 struct vm_area_struct **pprev);
76901
76902 +extern struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma);
76903 +extern __must_check long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma);
76904 +extern void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl);
76905 +
76906 /* Look up the first VMA which intersects the interval start_addr..end_addr-1,
76907 NULL if none. Assume start_addr < end_addr. */
76908 static inline struct vm_area_struct * find_vma_intersection(struct mm_struct * mm, unsigned long start_addr, unsigned long end_addr)
76909 @@ -1659,15 +1678,6 @@ static inline struct vm_area_struct *find_exact_vma(struct mm_struct *mm,
76910 return vma;
76911 }
76912
76913 -#ifdef CONFIG_MMU
76914 -pgprot_t vm_get_page_prot(unsigned long vm_flags);
76915 -#else
76916 -static inline pgprot_t vm_get_page_prot(unsigned long vm_flags)
76917 -{
76918 - return __pgprot(0);
76919 -}
76920 -#endif
76921 -
76922 #ifdef CONFIG_ARCH_USES_NUMA_PROT_NONE
76923 unsigned long change_prot_numa(struct vm_area_struct *vma,
76924 unsigned long start, unsigned long end);
76925 @@ -1719,6 +1729,11 @@ void vm_stat_account(struct mm_struct *, unsigned long, struct file *, long);
76926 static inline void vm_stat_account(struct mm_struct *mm,
76927 unsigned long flags, struct file *file, long pages)
76928 {
76929 +
76930 +#ifdef CONFIG_PAX_RANDMMAP
76931 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
76932 +#endif
76933 +
76934 mm->total_vm += pages;
76935 }
76936 #endif /* CONFIG_PROC_FS */
76937 @@ -1800,7 +1815,7 @@ extern int unpoison_memory(unsigned long pfn);
76938 extern int sysctl_memory_failure_early_kill;
76939 extern int sysctl_memory_failure_recovery;
76940 extern void shake_page(struct page *p, int access);
76941 -extern atomic_long_t num_poisoned_pages;
76942 +extern atomic_long_unchecked_t num_poisoned_pages;
76943 extern int soft_offline_page(struct page *page, int flags);
76944
76945 extern void dump_page(struct page *page);
76946 @@ -1837,5 +1852,11 @@ void __init setup_nr_node_ids(void);
76947 static inline void setup_nr_node_ids(void) {}
76948 #endif
76949
76950 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
76951 +extern void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot);
76952 +#else
76953 +static inline void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot) {}
76954 +#endif
76955 +
76956 #endif /* __KERNEL__ */
76957 #endif /* _LINUX_MM_H */
76958 diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
76959 index d9851ee..619492d 100644
76960 --- a/include/linux/mm_types.h
76961 +++ b/include/linux/mm_types.h
76962 @@ -289,6 +289,8 @@ struct vm_area_struct {
76963 #ifdef CONFIG_NUMA
76964 struct mempolicy *vm_policy; /* NUMA policy for the VMA */
76965 #endif
76966 +
76967 + struct vm_area_struct *vm_mirror;/* PaX: mirror vma or NULL */
76968 };
76969
76970 struct core_thread {
76971 @@ -436,6 +438,24 @@ struct mm_struct {
76972 int first_nid;
76973 #endif
76974 struct uprobes_state uprobes_state;
76975 +
76976 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
76977 + unsigned long pax_flags;
76978 +#endif
76979 +
76980 +#ifdef CONFIG_PAX_DLRESOLVE
76981 + unsigned long call_dl_resolve;
76982 +#endif
76983 +
76984 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
76985 + unsigned long call_syscall;
76986 +#endif
76987 +
76988 +#ifdef CONFIG_PAX_ASLR
76989 + unsigned long delta_mmap; /* randomized offset */
76990 + unsigned long delta_stack; /* randomized offset */
76991 +#endif
76992 +
76993 };
76994
76995 /* first nid will either be a valid NID or one of these values */
76996 diff --git a/include/linux/mmiotrace.h b/include/linux/mmiotrace.h
76997 index c5d5278..f0b68c8 100644
76998 --- a/include/linux/mmiotrace.h
76999 +++ b/include/linux/mmiotrace.h
77000 @@ -46,7 +46,7 @@ extern int kmmio_handler(struct pt_regs *regs, unsigned long addr);
77001 /* Called from ioremap.c */
77002 extern void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
77003 void __iomem *addr);
77004 -extern void mmiotrace_iounmap(volatile void __iomem *addr);
77005 +extern void mmiotrace_iounmap(const volatile void __iomem *addr);
77006
77007 /* For anyone to insert markers. Remember trailing newline. */
77008 extern __printf(1, 2) int mmiotrace_printk(const char *fmt, ...);
77009 @@ -66,7 +66,7 @@ static inline void mmiotrace_ioremap(resource_size_t offset,
77010 {
77011 }
77012
77013 -static inline void mmiotrace_iounmap(volatile void __iomem *addr)
77014 +static inline void mmiotrace_iounmap(const volatile void __iomem *addr)
77015 {
77016 }
77017
77018 diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
77019 index bd791e4..8617c34f 100644
77020 --- a/include/linux/mmzone.h
77021 +++ b/include/linux/mmzone.h
77022 @@ -396,7 +396,7 @@ struct zone {
77023 unsigned long flags; /* zone flags, see below */
77024
77025 /* Zone statistics */
77026 - atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
77027 + atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
77028
77029 /*
77030 * The target ratio of ACTIVE_ANON to INACTIVE_ANON pages on
77031 diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
77032 index 45e9214..a7227d6 100644
77033 --- a/include/linux/mod_devicetable.h
77034 +++ b/include/linux/mod_devicetable.h
77035 @@ -13,7 +13,7 @@
77036 typedef unsigned long kernel_ulong_t;
77037 #endif
77038
77039 -#define PCI_ANY_ID (~0)
77040 +#define PCI_ANY_ID ((__u16)~0)
77041
77042 struct pci_device_id {
77043 __u32 vendor, device; /* Vendor and device ID or PCI_ANY_ID*/
77044 @@ -139,7 +139,7 @@ struct usb_device_id {
77045 #define USB_DEVICE_ID_MATCH_INT_PROTOCOL 0x0200
77046 #define USB_DEVICE_ID_MATCH_INT_NUMBER 0x0400
77047
77048 -#define HID_ANY_ID (~0)
77049 +#define HID_ANY_ID (~0U)
77050 #define HID_BUS_ANY 0xffff
77051 #define HID_GROUP_ANY 0x0000
77052
77053 @@ -467,7 +467,7 @@ struct dmi_system_id {
77054 const char *ident;
77055 struct dmi_strmatch matches[4];
77056 void *driver_data;
77057 -};
77058 +} __do_const;
77059 /*
77060 * struct dmi_device_id appears during expansion of
77061 * "MODULE_DEVICE_TABLE(dmi, x)". Compiler doesn't look inside it
77062 diff --git a/include/linux/module.h b/include/linux/module.h
77063 index 05f2447..2aee07c 100644
77064 --- a/include/linux/module.h
77065 +++ b/include/linux/module.h
77066 @@ -17,9 +17,11 @@
77067 #include <linux/moduleparam.h>
77068 #include <linux/tracepoint.h>
77069 #include <linux/export.h>
77070 +#include <linux/fs.h>
77071
77072 #include <linux/percpu.h>
77073 #include <asm/module.h>
77074 +#include <asm/pgtable.h>
77075
77076 /* In stripped ARM and x86-64 modules, ~ is surprisingly rare. */
77077 #define MODULE_SIG_STRING "~Module signature appended~\n"
77078 @@ -55,12 +57,13 @@ struct module_attribute {
77079 int (*test)(struct module *);
77080 void (*free)(struct module *);
77081 };
77082 +typedef struct module_attribute __no_const module_attribute_no_const;
77083
77084 struct module_version_attribute {
77085 struct module_attribute mattr;
77086 const char *module_name;
77087 const char *version;
77088 -} __attribute__ ((__aligned__(sizeof(void *))));
77089 +} __do_const __attribute__ ((__aligned__(sizeof(void *))));
77090
77091 extern ssize_t __modver_version_show(struct module_attribute *,
77092 struct module_kobject *, char *);
77093 @@ -238,7 +241,7 @@ struct module
77094
77095 /* Sysfs stuff. */
77096 struct module_kobject mkobj;
77097 - struct module_attribute *modinfo_attrs;
77098 + module_attribute_no_const *modinfo_attrs;
77099 const char *version;
77100 const char *srcversion;
77101 struct kobject *holders_dir;
77102 @@ -287,19 +290,16 @@ struct module
77103 int (*init)(void);
77104
77105 /* If this is non-NULL, vfree after init() returns */
77106 - void *module_init;
77107 + void *module_init_rx, *module_init_rw;
77108
77109 /* Here is the actual code + data, vfree'd on unload. */
77110 - void *module_core;
77111 + void *module_core_rx, *module_core_rw;
77112
77113 /* Here are the sizes of the init and core sections */
77114 - unsigned int init_size, core_size;
77115 + unsigned int init_size_rw, core_size_rw;
77116
77117 /* The size of the executable code in each section. */
77118 - unsigned int init_text_size, core_text_size;
77119 -
77120 - /* Size of RO sections of the module (text+rodata) */
77121 - unsigned int init_ro_size, core_ro_size;
77122 + unsigned int init_size_rx, core_size_rx;
77123
77124 /* Arch-specific module values */
77125 struct mod_arch_specific arch;
77126 @@ -355,6 +355,10 @@ struct module
77127 #ifdef CONFIG_EVENT_TRACING
77128 struct ftrace_event_call **trace_events;
77129 unsigned int num_trace_events;
77130 + struct file_operations trace_id;
77131 + struct file_operations trace_enable;
77132 + struct file_operations trace_format;
77133 + struct file_operations trace_filter;
77134 #endif
77135 #ifdef CONFIG_FTRACE_MCOUNT_RECORD
77136 unsigned int num_ftrace_callsites;
77137 @@ -402,16 +406,46 @@ bool is_module_address(unsigned long addr);
77138 bool is_module_percpu_address(unsigned long addr);
77139 bool is_module_text_address(unsigned long addr);
77140
77141 +static inline int within_module_range(unsigned long addr, void *start, unsigned long size)
77142 +{
77143 +
77144 +#ifdef CONFIG_PAX_KERNEXEC
77145 + if (ktla_ktva(addr) >= (unsigned long)start &&
77146 + ktla_ktva(addr) < (unsigned long)start + size)
77147 + return 1;
77148 +#endif
77149 +
77150 + return ((void *)addr >= start && (void *)addr < start + size);
77151 +}
77152 +
77153 +static inline int within_module_core_rx(unsigned long addr, const struct module *mod)
77154 +{
77155 + return within_module_range(addr, mod->module_core_rx, mod->core_size_rx);
77156 +}
77157 +
77158 +static inline int within_module_core_rw(unsigned long addr, const struct module *mod)
77159 +{
77160 + return within_module_range(addr, mod->module_core_rw, mod->core_size_rw);
77161 +}
77162 +
77163 +static inline int within_module_init_rx(unsigned long addr, const struct module *mod)
77164 +{
77165 + return within_module_range(addr, mod->module_init_rx, mod->init_size_rx);
77166 +}
77167 +
77168 +static inline int within_module_init_rw(unsigned long addr, const struct module *mod)
77169 +{
77170 + return within_module_range(addr, mod->module_init_rw, mod->init_size_rw);
77171 +}
77172 +
77173 static inline int within_module_core(unsigned long addr, const struct module *mod)
77174 {
77175 - return (unsigned long)mod->module_core <= addr &&
77176 - addr < (unsigned long)mod->module_core + mod->core_size;
77177 + return within_module_core_rx(addr, mod) || within_module_core_rw(addr, mod);
77178 }
77179
77180 static inline int within_module_init(unsigned long addr, const struct module *mod)
77181 {
77182 - return (unsigned long)mod->module_init <= addr &&
77183 - addr < (unsigned long)mod->module_init + mod->init_size;
77184 + return within_module_init_rx(addr, mod) || within_module_init_rw(addr, mod);
77185 }
77186
77187 /* Search for module by name: must hold module_mutex. */
77188 diff --git a/include/linux/moduleloader.h b/include/linux/moduleloader.h
77189 index 560ca53..ef621ef 100644
77190 --- a/include/linux/moduleloader.h
77191 +++ b/include/linux/moduleloader.h
77192 @@ -25,9 +25,21 @@ unsigned int arch_mod_section_prepend(struct module *mod, unsigned int section);
77193 sections. Returns NULL on failure. */
77194 void *module_alloc(unsigned long size);
77195
77196 +#ifdef CONFIG_PAX_KERNEXEC
77197 +void *module_alloc_exec(unsigned long size);
77198 +#else
77199 +#define module_alloc_exec(x) module_alloc(x)
77200 +#endif
77201 +
77202 /* Free memory returned from module_alloc. */
77203 void module_free(struct module *mod, void *module_region);
77204
77205 +#ifdef CONFIG_PAX_KERNEXEC
77206 +void module_free_exec(struct module *mod, void *module_region);
77207 +#else
77208 +#define module_free_exec(x, y) module_free((x), (y))
77209 +#endif
77210 +
77211 /*
77212 * Apply the given relocation to the (simplified) ELF. Return -error
77213 * or 0.
77214 @@ -45,7 +57,9 @@ static inline int apply_relocate(Elf_Shdr *sechdrs,
77215 unsigned int relsec,
77216 struct module *me)
77217 {
77218 +#ifdef CONFIG_MODULES
77219 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
77220 +#endif
77221 return -ENOEXEC;
77222 }
77223 #endif
77224 @@ -67,7 +81,9 @@ static inline int apply_relocate_add(Elf_Shdr *sechdrs,
77225 unsigned int relsec,
77226 struct module *me)
77227 {
77228 +#ifdef CONFIG_MODULES
77229 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
77230 +#endif
77231 return -ENOEXEC;
77232 }
77233 #endif
77234 diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
77235 index c3eb102..073c4a6 100644
77236 --- a/include/linux/moduleparam.h
77237 +++ b/include/linux/moduleparam.h
77238 @@ -295,7 +295,7 @@ static inline void __kernel_param_unlock(void)
77239 * @len is usually just sizeof(string).
77240 */
77241 #define module_param_string(name, string, len, perm) \
77242 - static const struct kparam_string __param_string_##name \
77243 + static const struct kparam_string __param_string_##name __used \
77244 = { len, string }; \
77245 __module_param_call(MODULE_PARAM_PREFIX, name, \
77246 &param_ops_string, \
77247 @@ -434,7 +434,7 @@ extern int param_set_bint(const char *val, const struct kernel_param *kp);
77248 */
77249 #define module_param_array_named(name, array, type, nump, perm) \
77250 param_check_##type(name, &(array)[0]); \
77251 - static const struct kparam_array __param_arr_##name \
77252 + static const struct kparam_array __param_arr_##name __used \
77253 = { .max = ARRAY_SIZE(array), .num = nump, \
77254 .ops = &param_ops_##type, \
77255 .elemsize = sizeof(array[0]), .elem = array }; \
77256 diff --git a/include/linux/namei.h b/include/linux/namei.h
77257 index 8e47bc7..c70fd73 100644
77258 --- a/include/linux/namei.h
77259 +++ b/include/linux/namei.h
77260 @@ -19,7 +19,7 @@ struct nameidata {
77261 unsigned seq;
77262 int last_type;
77263 unsigned depth;
77264 - char *saved_names[MAX_NESTED_LINKS + 1];
77265 + const char *saved_names[MAX_NESTED_LINKS + 1];
77266 };
77267
77268 /*
77269 @@ -83,12 +83,12 @@ extern void unlock_rename(struct dentry *, struct dentry *);
77270
77271 extern void nd_jump_link(struct nameidata *nd, struct path *path);
77272
77273 -static inline void nd_set_link(struct nameidata *nd, char *path)
77274 +static inline void nd_set_link(struct nameidata *nd, const char *path)
77275 {
77276 nd->saved_names[nd->depth] = path;
77277 }
77278
77279 -static inline char *nd_get_link(struct nameidata *nd)
77280 +static inline const char *nd_get_link(const struct nameidata *nd)
77281 {
77282 return nd->saved_names[nd->depth];
77283 }
77284 diff --git a/include/linux/net.h b/include/linux/net.h
77285 index 8bd9d92..08b1c20 100644
77286 --- a/include/linux/net.h
77287 +++ b/include/linux/net.h
77288 @@ -191,7 +191,7 @@ struct net_proto_family {
77289 int (*create)(struct net *net, struct socket *sock,
77290 int protocol, int kern);
77291 struct module *owner;
77292 -};
77293 +} __do_const;
77294
77295 struct iovec;
77296 struct kvec;
77297 diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
77298 index 25f5d2d1..5cf2120 100644
77299 --- a/include/linux/netdevice.h
77300 +++ b/include/linux/netdevice.h
77301 @@ -1098,6 +1098,7 @@ struct net_device_ops {
77302 sa_family_t sa_family,
77303 __be16 port);
77304 };
77305 +typedef struct net_device_ops __no_const net_device_ops_no_const;
77306
77307 /*
77308 * The DEVICE structure.
77309 @@ -1169,7 +1170,7 @@ struct net_device {
77310 int iflink;
77311
77312 struct net_device_stats stats;
77313 - atomic_long_t rx_dropped; /* dropped packets by core network
77314 + atomic_long_unchecked_t rx_dropped; /* dropped packets by core network
77315 * Do not use this in drivers.
77316 */
77317
77318 diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h
77319 index 708fe72ab9..77084a3 100644
77320 --- a/include/linux/netfilter.h
77321 +++ b/include/linux/netfilter.h
77322 @@ -82,7 +82,7 @@ struct nf_sockopt_ops {
77323 #endif
77324 /* Use the module struct to lock set/get code in place */
77325 struct module *owner;
77326 -};
77327 +} __do_const;
77328
77329 /* Function to register/unregister hook points. */
77330 int nf_register_hook(struct nf_hook_ops *reg);
77331 diff --git a/include/linux/netfilter/nfnetlink.h b/include/linux/netfilter/nfnetlink.h
77332 index cadb740..d7c37c0 100644
77333 --- a/include/linux/netfilter/nfnetlink.h
77334 +++ b/include/linux/netfilter/nfnetlink.h
77335 @@ -16,7 +16,7 @@ struct nfnl_callback {
77336 const struct nlattr * const cda[]);
77337 const struct nla_policy *policy; /* netlink attribute policy */
77338 const u_int16_t attr_count; /* number of nlattr's */
77339 -};
77340 +} __do_const;
77341
77342 struct nfnetlink_subsystem {
77343 const char *name;
77344 diff --git a/include/linux/netfilter/xt_gradm.h b/include/linux/netfilter/xt_gradm.h
77345 new file mode 100644
77346 index 0000000..33f4af8
77347 --- /dev/null
77348 +++ b/include/linux/netfilter/xt_gradm.h
77349 @@ -0,0 +1,9 @@
77350 +#ifndef _LINUX_NETFILTER_XT_GRADM_H
77351 +#define _LINUX_NETFILTER_XT_GRADM_H 1
77352 +
77353 +struct xt_gradm_mtinfo {
77354 + __u16 flags;
77355 + __u16 invflags;
77356 +};
77357 +
77358 +#endif
77359 diff --git a/include/linux/nls.h b/include/linux/nls.h
77360 index 5dc635f..35f5e11 100644
77361 --- a/include/linux/nls.h
77362 +++ b/include/linux/nls.h
77363 @@ -31,7 +31,7 @@ struct nls_table {
77364 const unsigned char *charset2upper;
77365 struct module *owner;
77366 struct nls_table *next;
77367 -};
77368 +} __do_const;
77369
77370 /* this value hold the maximum octet of charset */
77371 #define NLS_MAX_CHARSET_SIZE 6 /* for UTF-8 */
77372 diff --git a/include/linux/notifier.h b/include/linux/notifier.h
77373 index d14a4c3..a078786 100644
77374 --- a/include/linux/notifier.h
77375 +++ b/include/linux/notifier.h
77376 @@ -54,7 +54,8 @@ struct notifier_block {
77377 notifier_fn_t notifier_call;
77378 struct notifier_block __rcu *next;
77379 int priority;
77380 -};
77381 +} __do_const;
77382 +typedef struct notifier_block __no_const notifier_block_no_const;
77383
77384 struct atomic_notifier_head {
77385 spinlock_t lock;
77386 diff --git a/include/linux/oprofile.h b/include/linux/oprofile.h
77387 index b2a0f15..4d7da32 100644
77388 --- a/include/linux/oprofile.h
77389 +++ b/include/linux/oprofile.h
77390 @@ -138,9 +138,9 @@ int oprofilefs_create_ulong(struct dentry * root,
77391 int oprofilefs_create_ro_ulong(struct dentry * root,
77392 char const * name, ulong * val);
77393
77394 -/** Create a file for read-only access to an atomic_t. */
77395 +/** Create a file for read-only access to an atomic_unchecked_t. */
77396 int oprofilefs_create_ro_atomic(struct dentry * root,
77397 - char const * name, atomic_t * val);
77398 + char const * name, atomic_unchecked_t * val);
77399
77400 /** create a directory */
77401 struct dentry *oprofilefs_mkdir(struct dentry *parent, char const *name);
77402 diff --git a/include/linux/pci_hotplug.h b/include/linux/pci_hotplug.h
77403 index 430dd96..544e26e 100644
77404 --- a/include/linux/pci_hotplug.h
77405 +++ b/include/linux/pci_hotplug.h
77406 @@ -71,7 +71,8 @@ struct hotplug_slot_ops {
77407 int (*get_latch_status) (struct hotplug_slot *slot, u8 *value);
77408 int (*get_adapter_status) (struct hotplug_slot *slot, u8 *value);
77409 int (*reset_slot) (struct hotplug_slot *slot, int probe);
77410 -};
77411 +} __do_const;
77412 +typedef struct hotplug_slot_ops __no_const hotplug_slot_ops_no_const;
77413
77414 /**
77415 * struct hotplug_slot_info - used to notify the hotplug pci core of the state of the slot
77416 diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
77417 index c8ba627..24bdfa8 100644
77418 --- a/include/linux/perf_event.h
77419 +++ b/include/linux/perf_event.h
77420 @@ -327,8 +327,8 @@ struct perf_event {
77421
77422 enum perf_event_active_state state;
77423 unsigned int attach_state;
77424 - local64_t count;
77425 - atomic64_t child_count;
77426 + local64_t count; /* PaX: fix it one day */
77427 + atomic64_unchecked_t child_count;
77428
77429 /*
77430 * These are the total time in nanoseconds that the event
77431 @@ -379,8 +379,8 @@ struct perf_event {
77432 * These accumulate total time (in nanoseconds) that children
77433 * events have been enabled and running, respectively.
77434 */
77435 - atomic64_t child_total_time_enabled;
77436 - atomic64_t child_total_time_running;
77437 + atomic64_unchecked_t child_total_time_enabled;
77438 + atomic64_unchecked_t child_total_time_running;
77439
77440 /*
77441 * Protect attach/detach and child_list:
77442 @@ -702,7 +702,7 @@ static inline void perf_callchain_store(struct perf_callchain_entry *entry, u64
77443 entry->ip[entry->nr++] = ip;
77444 }
77445
77446 -extern int sysctl_perf_event_paranoid;
77447 +extern int sysctl_perf_event_legitimately_concerned;
77448 extern int sysctl_perf_event_mlock;
77449 extern int sysctl_perf_event_sample_rate;
77450 extern int sysctl_perf_cpu_time_max_percent;
77451 @@ -717,19 +717,24 @@ extern int perf_cpu_time_max_percent_handler(struct ctl_table *table, int write,
77452 loff_t *ppos);
77453
77454
77455 +static inline bool perf_paranoid_any(void)
77456 +{
77457 + return sysctl_perf_event_legitimately_concerned > 2;
77458 +}
77459 +
77460 static inline bool perf_paranoid_tracepoint_raw(void)
77461 {
77462 - return sysctl_perf_event_paranoid > -1;
77463 + return sysctl_perf_event_legitimately_concerned > -1;
77464 }
77465
77466 static inline bool perf_paranoid_cpu(void)
77467 {
77468 - return sysctl_perf_event_paranoid > 0;
77469 + return sysctl_perf_event_legitimately_concerned > 0;
77470 }
77471
77472 static inline bool perf_paranoid_kernel(void)
77473 {
77474 - return sysctl_perf_event_paranoid > 1;
77475 + return sysctl_perf_event_legitimately_concerned > 1;
77476 }
77477
77478 extern void perf_event_init(void);
77479 @@ -845,7 +850,7 @@ struct perf_pmu_events_attr {
77480 struct device_attribute attr;
77481 u64 id;
77482 const char *event_str;
77483 -};
77484 +} __do_const;
77485
77486 #define PMU_EVENT_ATTR(_name, _var, _id, _show) \
77487 static struct perf_pmu_events_attr _var = { \
77488 diff --git a/include/linux/pipe_fs_i.h b/include/linux/pipe_fs_i.h
77489 index b8809fe..ae4ccd0 100644
77490 --- a/include/linux/pipe_fs_i.h
77491 +++ b/include/linux/pipe_fs_i.h
77492 @@ -47,10 +47,10 @@ struct pipe_inode_info {
77493 struct mutex mutex;
77494 wait_queue_head_t wait;
77495 unsigned int nrbufs, curbuf, buffers;
77496 - unsigned int readers;
77497 - unsigned int writers;
77498 - unsigned int files;
77499 - unsigned int waiting_writers;
77500 + atomic_t readers;
77501 + atomic_t writers;
77502 + atomic_t files;
77503 + atomic_t waiting_writers;
77504 unsigned int r_counter;
77505 unsigned int w_counter;
77506 struct page *tmp_page;
77507 diff --git a/include/linux/platform_data/usb-ehci-s5p.h b/include/linux/platform_data/usb-ehci-s5p.h
77508 index 5f28cae..3d23723 100644
77509 --- a/include/linux/platform_data/usb-ehci-s5p.h
77510 +++ b/include/linux/platform_data/usb-ehci-s5p.h
77511 @@ -14,7 +14,7 @@
77512 struct s5p_ehci_platdata {
77513 int (*phy_init)(struct platform_device *pdev, int type);
77514 int (*phy_exit)(struct platform_device *pdev, int type);
77515 -};
77516 +} __no_const;
77517
77518 extern void s5p_ehci_set_platdata(struct s5p_ehci_platdata *pd);
77519
77520 diff --git a/include/linux/platform_data/usb-ohci-exynos.h b/include/linux/platform_data/usb-ohci-exynos.h
77521 index c256c59..8ea94c7 100644
77522 --- a/include/linux/platform_data/usb-ohci-exynos.h
77523 +++ b/include/linux/platform_data/usb-ohci-exynos.h
77524 @@ -14,7 +14,7 @@
77525 struct exynos4_ohci_platdata {
77526 int (*phy_init)(struct platform_device *pdev, int type);
77527 int (*phy_exit)(struct platform_device *pdev, int type);
77528 -};
77529 +} __no_const;
77530
77531 extern void exynos4_ohci_set_platdata(struct exynos4_ohci_platdata *pd);
77532
77533 diff --git a/include/linux/pm.h b/include/linux/pm.h
77534 index a224c7f..92d8a97 100644
77535 --- a/include/linux/pm.h
77536 +++ b/include/linux/pm.h
77537 @@ -576,6 +576,7 @@ extern int dev_pm_put_subsys_data(struct device *dev);
77538 struct dev_pm_domain {
77539 struct dev_pm_ops ops;
77540 };
77541 +typedef struct dev_pm_domain __no_const dev_pm_domain_no_const;
77542
77543 /*
77544 * The PM_EVENT_ messages are also used by drivers implementing the legacy
77545 diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
77546 index 7c1d252..c5c773e 100644
77547 --- a/include/linux/pm_domain.h
77548 +++ b/include/linux/pm_domain.h
77549 @@ -48,7 +48,7 @@ struct gpd_dev_ops {
77550
77551 struct gpd_cpu_data {
77552 unsigned int saved_exit_latency;
77553 - struct cpuidle_state *idle_state;
77554 + cpuidle_state_no_const *idle_state;
77555 };
77556
77557 struct generic_pm_domain {
77558 diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h
77559 index 6fa7cea..7bf6415 100644
77560 --- a/include/linux/pm_runtime.h
77561 +++ b/include/linux/pm_runtime.h
77562 @@ -103,7 +103,7 @@ static inline bool pm_runtime_callbacks_present(struct device *dev)
77563
77564 static inline void pm_runtime_mark_last_busy(struct device *dev)
77565 {
77566 - ACCESS_ONCE(dev->power.last_busy) = jiffies;
77567 + ACCESS_ONCE_RW(dev->power.last_busy) = jiffies;
77568 }
77569
77570 #else /* !CONFIG_PM_RUNTIME */
77571 diff --git a/include/linux/pnp.h b/include/linux/pnp.h
77572 index 195aafc..49a7bc2 100644
77573 --- a/include/linux/pnp.h
77574 +++ b/include/linux/pnp.h
77575 @@ -297,7 +297,7 @@ static inline void pnp_set_drvdata(struct pnp_dev *pdev, void *data)
77576 struct pnp_fixup {
77577 char id[7];
77578 void (*quirk_function) (struct pnp_dev * dev); /* fixup function */
77579 -};
77580 +} __do_const;
77581
77582 /* config parameters */
77583 #define PNP_CONFIG_NORMAL 0x0001
77584 diff --git a/include/linux/poison.h b/include/linux/poison.h
77585 index 2110a81..13a11bb 100644
77586 --- a/include/linux/poison.h
77587 +++ b/include/linux/poison.h
77588 @@ -19,8 +19,8 @@
77589 * under normal circumstances, used to verify that nobody uses
77590 * non-initialized list entries.
77591 */
77592 -#define LIST_POISON1 ((void *) 0x00100100 + POISON_POINTER_DELTA)
77593 -#define LIST_POISON2 ((void *) 0x00200200 + POISON_POINTER_DELTA)
77594 +#define LIST_POISON1 ((void *) (long)0xFFFFFF01)
77595 +#define LIST_POISON2 ((void *) (long)0xFFFFFF02)
77596
77597 /********** include/linux/timer.h **********/
77598 /*
77599 diff --git a/include/linux/power/smartreflex.h b/include/linux/power/smartreflex.h
77600 index d8b187c3..9a9257a 100644
77601 --- a/include/linux/power/smartreflex.h
77602 +++ b/include/linux/power/smartreflex.h
77603 @@ -238,7 +238,7 @@ struct omap_sr_class_data {
77604 int (*notify)(struct omap_sr *sr, u32 status);
77605 u8 notify_flags;
77606 u8 class_type;
77607 -};
77608 +} __do_const;
77609
77610 /**
77611 * struct omap_sr_nvalue_table - Smartreflex n-target value info
77612 diff --git a/include/linux/ppp-comp.h b/include/linux/ppp-comp.h
77613 index 4ea1d37..80f4b33 100644
77614 --- a/include/linux/ppp-comp.h
77615 +++ b/include/linux/ppp-comp.h
77616 @@ -84,7 +84,7 @@ struct compressor {
77617 struct module *owner;
77618 /* Extra skb space needed by the compressor algorithm */
77619 unsigned int comp_extra;
77620 -};
77621 +} __do_const;
77622
77623 /*
77624 * The return value from decompress routine is the length of the
77625 diff --git a/include/linux/preempt.h b/include/linux/preempt.h
77626 index f5d4723..a6ea2fa 100644
77627 --- a/include/linux/preempt.h
77628 +++ b/include/linux/preempt.h
77629 @@ -18,8 +18,13 @@
77630 # define sub_preempt_count(val) do { preempt_count() -= (val); } while (0)
77631 #endif
77632
77633 +#define raw_add_preempt_count(val) do { preempt_count() += (val); } while (0)
77634 +#define raw_sub_preempt_count(val) do { preempt_count() -= (val); } while (0)
77635 +
77636 #define inc_preempt_count() add_preempt_count(1)
77637 +#define raw_inc_preempt_count() raw_add_preempt_count(1)
77638 #define dec_preempt_count() sub_preempt_count(1)
77639 +#define raw_dec_preempt_count() raw_sub_preempt_count(1)
77640
77641 #define preempt_count() (current_thread_info()->preempt_count)
77642
77643 @@ -64,6 +69,12 @@ do { \
77644 barrier(); \
77645 } while (0)
77646
77647 +#define raw_preempt_disable() \
77648 +do { \
77649 + raw_inc_preempt_count(); \
77650 + barrier(); \
77651 +} while (0)
77652 +
77653 #define sched_preempt_enable_no_resched() \
77654 do { \
77655 barrier(); \
77656 @@ -72,6 +83,12 @@ do { \
77657
77658 #define preempt_enable_no_resched() sched_preempt_enable_no_resched()
77659
77660 +#define raw_preempt_enable_no_resched() \
77661 +do { \
77662 + barrier(); \
77663 + raw_dec_preempt_count(); \
77664 +} while (0)
77665 +
77666 #define preempt_enable() \
77667 do { \
77668 preempt_enable_no_resched(); \
77669 @@ -116,8 +133,10 @@ do { \
77670 * region.
77671 */
77672 #define preempt_disable() barrier()
77673 +#define raw_preempt_disable() barrier()
77674 #define sched_preempt_enable_no_resched() barrier()
77675 #define preempt_enable_no_resched() barrier()
77676 +#define raw_preempt_enable_no_resched() barrier()
77677 #define preempt_enable() barrier()
77678
77679 #define preempt_disable_notrace() barrier()
77680 diff --git a/include/linux/printk.h b/include/linux/printk.h
77681 index e6131a78..8e9fb61 100644
77682 --- a/include/linux/printk.h
77683 +++ b/include/linux/printk.h
77684 @@ -106,6 +106,8 @@ static inline __printf(1, 2) __cold
77685 void early_printk(const char *s, ...) { }
77686 #endif
77687
77688 +extern int kptr_restrict;
77689 +
77690 #ifdef CONFIG_PRINTK
77691 asmlinkage __printf(5, 0)
77692 int vprintk_emit(int facility, int level,
77693 @@ -140,7 +142,6 @@ extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
77694
77695 extern int printk_delay_msec;
77696 extern int dmesg_restrict;
77697 -extern int kptr_restrict;
77698
77699 extern void wake_up_klogd(void);
77700
77701 diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
77702 index 608e60a..c26f864 100644
77703 --- a/include/linux/proc_fs.h
77704 +++ b/include/linux/proc_fs.h
77705 @@ -34,6 +34,19 @@ static inline struct proc_dir_entry *proc_create(
77706 return proc_create_data(name, mode, parent, proc_fops, NULL);
77707 }
77708
77709 +static inline struct proc_dir_entry *proc_create_grsec(const char *name, umode_t mode,
77710 + struct proc_dir_entry *parent, const struct file_operations *proc_fops)
77711 +{
77712 +#ifdef CONFIG_GRKERNSEC_PROC_USER
77713 + return proc_create_data(name, S_IRUSR, parent, proc_fops, NULL);
77714 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
77715 + return proc_create_data(name, S_IRUSR | S_IRGRP, parent, proc_fops, NULL);
77716 +#else
77717 + return proc_create_data(name, mode, parent, proc_fops, NULL);
77718 +#endif
77719 +}
77720 +
77721 +
77722 extern void proc_set_size(struct proc_dir_entry *, loff_t);
77723 extern void proc_set_user(struct proc_dir_entry *, kuid_t, kgid_t);
77724 extern void *PDE_DATA(const struct inode *);
77725 diff --git a/include/linux/proc_ns.h b/include/linux/proc_ns.h
77726 index 34a1e10..03a6d03 100644
77727 --- a/include/linux/proc_ns.h
77728 +++ b/include/linux/proc_ns.h
77729 @@ -14,7 +14,7 @@ struct proc_ns_operations {
77730 void (*put)(void *ns);
77731 int (*install)(struct nsproxy *nsproxy, void *ns);
77732 unsigned int (*inum)(void *ns);
77733 -};
77734 +} __do_const;
77735
77736 struct proc_ns {
77737 void *ns;
77738 diff --git a/include/linux/quota.h b/include/linux/quota.h
77739 index cc7494a..1e27036 100644
77740 --- a/include/linux/quota.h
77741 +++ b/include/linux/quota.h
77742 @@ -70,7 +70,7 @@ struct kqid { /* Type in which we store the quota identifier */
77743
77744 extern bool qid_eq(struct kqid left, struct kqid right);
77745 extern bool qid_lt(struct kqid left, struct kqid right);
77746 -extern qid_t from_kqid(struct user_namespace *to, struct kqid qid);
77747 +extern qid_t from_kqid(struct user_namespace *to, struct kqid qid) __intentional_overflow(-1);
77748 extern qid_t from_kqid_munged(struct user_namespace *to, struct kqid qid);
77749 extern bool qid_valid(struct kqid qid);
77750
77751 diff --git a/include/linux/random.h b/include/linux/random.h
77752 index bf9085e..1e8bbcf 100644
77753 --- a/include/linux/random.h
77754 +++ b/include/linux/random.h
77755 @@ -10,9 +10,19 @@
77756
77757
77758 extern void add_device_randomness(const void *, unsigned int);
77759 +
77760 +static inline void add_latent_entropy(void)
77761 +{
77762 +
77763 +#ifdef LATENT_ENTROPY_PLUGIN
77764 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
77765 +#endif
77766 +
77767 +}
77768 +
77769 extern void add_input_randomness(unsigned int type, unsigned int code,
77770 - unsigned int value);
77771 -extern void add_interrupt_randomness(int irq, int irq_flags);
77772 + unsigned int value) __latent_entropy;
77773 +extern void add_interrupt_randomness(int irq, int irq_flags) __latent_entropy;
77774
77775 extern void get_random_bytes(void *buf, int nbytes);
77776 extern void get_random_bytes_arch(void *buf, int nbytes);
77777 @@ -23,16 +33,21 @@ extern int random_int_secret_init(void);
77778 extern const struct file_operations random_fops, urandom_fops;
77779 #endif
77780
77781 -unsigned int get_random_int(void);
77782 +unsigned int __intentional_overflow(-1) get_random_int(void);
77783 unsigned long randomize_range(unsigned long start, unsigned long end, unsigned long len);
77784
77785 -u32 prandom_u32(void);
77786 +u32 prandom_u32(void) __intentional_overflow(-1);
77787 void prandom_bytes(void *buf, int nbytes);
77788 void prandom_seed(u32 seed);
77789
77790 u32 prandom_u32_state(struct rnd_state *);
77791 void prandom_bytes_state(struct rnd_state *state, void *buf, int nbytes);
77792
77793 +static inline unsigned long __intentional_overflow(-1) pax_get_random_long(void)
77794 +{
77795 + return prandom_u32() + (sizeof(long) > 4 ? (unsigned long)prandom_u32() << 32 : 0);
77796 +}
77797 +
77798 /*
77799 * Handle minimum values for seeds
77800 */
77801 diff --git a/include/linux/rculist.h b/include/linux/rculist.h
77802 index 4106721..132d42c 100644
77803 --- a/include/linux/rculist.h
77804 +++ b/include/linux/rculist.h
77805 @@ -44,6 +44,9 @@ extern void __list_add_rcu(struct list_head *new,
77806 struct list_head *prev, struct list_head *next);
77807 #endif
77808
77809 +extern void __pax_list_add_rcu(struct list_head *new,
77810 + struct list_head *prev, struct list_head *next);
77811 +
77812 /**
77813 * list_add_rcu - add a new entry to rcu-protected list
77814 * @new: new entry to be added
77815 @@ -65,6 +68,11 @@ static inline void list_add_rcu(struct list_head *new, struct list_head *head)
77816 __list_add_rcu(new, head, head->next);
77817 }
77818
77819 +static inline void pax_list_add_rcu(struct list_head *new, struct list_head *head)
77820 +{
77821 + __pax_list_add_rcu(new, head, head->next);
77822 +}
77823 +
77824 /**
77825 * list_add_tail_rcu - add a new entry to rcu-protected list
77826 * @new: new entry to be added
77827 @@ -87,6 +95,12 @@ static inline void list_add_tail_rcu(struct list_head *new,
77828 __list_add_rcu(new, head->prev, head);
77829 }
77830
77831 +static inline void pax_list_add_tail_rcu(struct list_head *new,
77832 + struct list_head *head)
77833 +{
77834 + __pax_list_add_rcu(new, head->prev, head);
77835 +}
77836 +
77837 /**
77838 * list_del_rcu - deletes entry from list without re-initialization
77839 * @entry: the element to delete from the list.
77840 @@ -117,6 +131,8 @@ static inline void list_del_rcu(struct list_head *entry)
77841 entry->prev = LIST_POISON2;
77842 }
77843
77844 +extern void pax_list_del_rcu(struct list_head *entry);
77845 +
77846 /**
77847 * hlist_del_init_rcu - deletes entry from hash list with re-initialization
77848 * @n: the element to delete from the hash list.
77849 diff --git a/include/linux/reboot.h b/include/linux/reboot.h
77850 index 8e00f9f..9449b55 100644
77851 --- a/include/linux/reboot.h
77852 +++ b/include/linux/reboot.h
77853 @@ -43,9 +43,9 @@ extern int unregister_reboot_notifier(struct notifier_block *);
77854 * Architecture-specific implementations of sys_reboot commands.
77855 */
77856
77857 -extern void machine_restart(char *cmd);
77858 -extern void machine_halt(void);
77859 -extern void machine_power_off(void);
77860 +extern void machine_restart(char *cmd) __noreturn;
77861 +extern void machine_halt(void) __noreturn;
77862 +extern void machine_power_off(void) __noreturn;
77863
77864 extern void machine_shutdown(void);
77865 struct pt_regs;
77866 @@ -56,9 +56,9 @@ extern void machine_crash_shutdown(struct pt_regs *);
77867 */
77868
77869 extern void kernel_restart_prepare(char *cmd);
77870 -extern void kernel_restart(char *cmd);
77871 -extern void kernel_halt(void);
77872 -extern void kernel_power_off(void);
77873 +extern void kernel_restart(char *cmd) __noreturn;
77874 +extern void kernel_halt(void) __noreturn;
77875 +extern void kernel_power_off(void) __noreturn;
77876
77877 extern int C_A_D; /* for sysctl */
77878 void ctrl_alt_del(void);
77879 @@ -72,7 +72,7 @@ extern int orderly_poweroff(bool force);
77880 * Emergency restart, callable from an interrupt handler.
77881 */
77882
77883 -extern void emergency_restart(void);
77884 +extern void emergency_restart(void) __noreturn;
77885 #include <asm/emergency-restart.h>
77886
77887 #endif /* _LINUX_REBOOT_H */
77888 diff --git a/include/linux/regset.h b/include/linux/regset.h
77889 index 8e0c9fe..ac4d221 100644
77890 --- a/include/linux/regset.h
77891 +++ b/include/linux/regset.h
77892 @@ -161,7 +161,8 @@ struct user_regset {
77893 unsigned int align;
77894 unsigned int bias;
77895 unsigned int core_note_type;
77896 -};
77897 +} __do_const;
77898 +typedef struct user_regset __no_const user_regset_no_const;
77899
77900 /**
77901 * struct user_regset_view - available regsets
77902 diff --git a/include/linux/relay.h b/include/linux/relay.h
77903 index d7c8359..818daf5 100644
77904 --- a/include/linux/relay.h
77905 +++ b/include/linux/relay.h
77906 @@ -157,7 +157,7 @@ struct rchan_callbacks
77907 * The callback should return 0 if successful, negative if not.
77908 */
77909 int (*remove_buf_file)(struct dentry *dentry);
77910 -};
77911 +} __no_const;
77912
77913 /*
77914 * CONFIG_RELAY kernel API, kernel/relay.c
77915 diff --git a/include/linux/rio.h b/include/linux/rio.h
77916 index b71d573..2f940bd 100644
77917 --- a/include/linux/rio.h
77918 +++ b/include/linux/rio.h
77919 @@ -355,7 +355,7 @@ struct rio_ops {
77920 int (*map_inb)(struct rio_mport *mport, dma_addr_t lstart,
77921 u64 rstart, u32 size, u32 flags);
77922 void (*unmap_inb)(struct rio_mport *mport, dma_addr_t lstart);
77923 -};
77924 +} __no_const;
77925
77926 #define RIO_RESOURCE_MEM 0x00000100
77927 #define RIO_RESOURCE_DOORBELL 0x00000200
77928 diff --git a/include/linux/rmap.h b/include/linux/rmap.h
77929 index 6dacb93..6174423 100644
77930 --- a/include/linux/rmap.h
77931 +++ b/include/linux/rmap.h
77932 @@ -145,8 +145,8 @@ static inline void anon_vma_unlock_read(struct anon_vma *anon_vma)
77933 void anon_vma_init(void); /* create anon_vma_cachep */
77934 int anon_vma_prepare(struct vm_area_struct *);
77935 void unlink_anon_vmas(struct vm_area_struct *);
77936 -int anon_vma_clone(struct vm_area_struct *, struct vm_area_struct *);
77937 -int anon_vma_fork(struct vm_area_struct *, struct vm_area_struct *);
77938 +int anon_vma_clone(struct vm_area_struct *, const struct vm_area_struct *);
77939 +int anon_vma_fork(struct vm_area_struct *, const struct vm_area_struct *);
77940
77941 static inline void anon_vma_merge(struct vm_area_struct *vma,
77942 struct vm_area_struct *next)
77943 diff --git a/include/linux/sched.h b/include/linux/sched.h
77944 index b1e963e..114b8fd 100644
77945 --- a/include/linux/sched.h
77946 +++ b/include/linux/sched.h
77947 @@ -62,6 +62,7 @@ struct bio_list;
77948 struct fs_struct;
77949 struct perf_event_context;
77950 struct blk_plug;
77951 +struct linux_binprm;
77952
77953 /*
77954 * List of flags we want to share for kernel threads,
77955 @@ -295,7 +296,7 @@ extern char __sched_text_start[], __sched_text_end[];
77956 extern int in_sched_functions(unsigned long addr);
77957
77958 #define MAX_SCHEDULE_TIMEOUT LONG_MAX
77959 -extern signed long schedule_timeout(signed long timeout);
77960 +extern signed long schedule_timeout(signed long timeout) __intentional_overflow(-1);
77961 extern signed long schedule_timeout_interruptible(signed long timeout);
77962 extern signed long schedule_timeout_killable(signed long timeout);
77963 extern signed long schedule_timeout_uninterruptible(signed long timeout);
77964 @@ -306,6 +307,19 @@ struct nsproxy;
77965 struct user_namespace;
77966
77967 #ifdef CONFIG_MMU
77968 +
77969 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
77970 +extern unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags);
77971 +#else
77972 +static inline unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
77973 +{
77974 + return 0;
77975 +}
77976 +#endif
77977 +
77978 +extern bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset);
77979 +extern unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset);
77980 +
77981 extern void arch_pick_mmap_layout(struct mm_struct *mm);
77982 extern unsigned long
77983 arch_get_unmapped_area(struct file *, unsigned long, unsigned long,
77984 @@ -585,6 +599,17 @@ struct signal_struct {
77985 #ifdef CONFIG_TASKSTATS
77986 struct taskstats *stats;
77987 #endif
77988 +
77989 +#ifdef CONFIG_GRKERNSEC
77990 + u32 curr_ip;
77991 + u32 saved_ip;
77992 + u32 gr_saddr;
77993 + u32 gr_daddr;
77994 + u16 gr_sport;
77995 + u16 gr_dport;
77996 + u8 used_accept:1;
77997 +#endif
77998 +
77999 #ifdef CONFIG_AUDIT
78000 unsigned audit_tty;
78001 unsigned audit_tty_log_passwd;
78002 @@ -665,6 +690,14 @@ struct user_struct {
78003 struct key *session_keyring; /* UID's default session keyring */
78004 #endif
78005
78006 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
78007 + unsigned char kernel_banned;
78008 +#endif
78009 +#ifdef CONFIG_GRKERNSEC_BRUTE
78010 + unsigned char suid_banned;
78011 + unsigned long suid_ban_expires;
78012 +#endif
78013 +
78014 /* Hash table maintenance information */
78015 struct hlist_node uidhash_node;
78016 kuid_t uid;
78017 @@ -1150,8 +1183,8 @@ struct task_struct {
78018 struct list_head thread_group;
78019
78020 struct completion *vfork_done; /* for vfork() */
78021 - int __user *set_child_tid; /* CLONE_CHILD_SETTID */
78022 - int __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
78023 + pid_t __user *set_child_tid; /* CLONE_CHILD_SETTID */
78024 + pid_t __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
78025
78026 cputime_t utime, stime, utimescaled, stimescaled;
78027 cputime_t gtime;
78028 @@ -1176,11 +1209,6 @@ struct task_struct {
78029 struct task_cputime cputime_expires;
78030 struct list_head cpu_timers[3];
78031
78032 -/* process credentials */
78033 - const struct cred __rcu *real_cred; /* objective and real subjective task
78034 - * credentials (COW) */
78035 - const struct cred __rcu *cred; /* effective (overridable) subjective task
78036 - * credentials (COW) */
78037 char comm[TASK_COMM_LEN]; /* executable name excluding path
78038 - access with [gs]et_task_comm (which lock
78039 it with task_lock())
78040 @@ -1197,6 +1225,10 @@ struct task_struct {
78041 #endif
78042 /* CPU-specific state of this task */
78043 struct thread_struct thread;
78044 +/* thread_info moved to task_struct */
78045 +#ifdef CONFIG_X86
78046 + struct thread_info tinfo;
78047 +#endif
78048 /* filesystem information */
78049 struct fs_struct *fs;
78050 /* open file information */
78051 @@ -1270,6 +1302,10 @@ struct task_struct {
78052 gfp_t lockdep_reclaim_gfp;
78053 #endif
78054
78055 +/* process credentials */
78056 + const struct cred __rcu *real_cred; /* objective and real subjective task
78057 + * credentials (COW) */
78058 +
78059 /* journalling filesystem info */
78060 void *journal_info;
78061
78062 @@ -1308,6 +1344,10 @@ struct task_struct {
78063 /* cg_list protected by css_set_lock and tsk->alloc_lock */
78064 struct list_head cg_list;
78065 #endif
78066 +
78067 + const struct cred __rcu *cred; /* effective (overridable) subjective task
78068 + * credentials (COW) */
78069 +
78070 #ifdef CONFIG_FUTEX
78071 struct robust_list_head __user *robust_list;
78072 #ifdef CONFIG_COMPAT
78073 @@ -1411,8 +1451,78 @@ struct task_struct {
78074 unsigned int sequential_io;
78075 unsigned int sequential_io_avg;
78076 #endif
78077 +
78078 +#ifdef CONFIG_GRKERNSEC
78079 + /* grsecurity */
78080 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
78081 + u64 exec_id;
78082 +#endif
78083 +#ifdef CONFIG_GRKERNSEC_SETXID
78084 + const struct cred *delayed_cred;
78085 +#endif
78086 + struct dentry *gr_chroot_dentry;
78087 + struct acl_subject_label *acl;
78088 + struct acl_subject_label *tmpacl;
78089 + struct acl_role_label *role;
78090 + struct file *exec_file;
78091 + unsigned long brute_expires;
78092 + u16 acl_role_id;
78093 + u8 inherited;
78094 + /* is this the task that authenticated to the special role */
78095 + u8 acl_sp_role;
78096 + u8 is_writable;
78097 + u8 brute;
78098 + u8 gr_is_chrooted;
78099 +#endif
78100 +
78101 };
78102
78103 +#define MF_PAX_PAGEEXEC 0x01000000 /* Paging based non-executable pages */
78104 +#define MF_PAX_EMUTRAMP 0x02000000 /* Emulate trampolines */
78105 +#define MF_PAX_MPROTECT 0x04000000 /* Restrict mprotect() */
78106 +#define MF_PAX_RANDMMAP 0x08000000 /* Randomize mmap() base */
78107 +/*#define MF_PAX_RANDEXEC 0x10000000*/ /* Randomize ET_EXEC base */
78108 +#define MF_PAX_SEGMEXEC 0x20000000 /* Segmentation based non-executable pages */
78109 +
78110 +#ifdef CONFIG_PAX_SOFTMODE
78111 +extern int pax_softmode;
78112 +#endif
78113 +
78114 +extern int pax_check_flags(unsigned long *);
78115 +
78116 +/* if tsk != current then task_lock must be held on it */
78117 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
78118 +static inline unsigned long pax_get_flags(struct task_struct *tsk)
78119 +{
78120 + if (likely(tsk->mm))
78121 + return tsk->mm->pax_flags;
78122 + else
78123 + return 0UL;
78124 +}
78125 +
78126 +/* if tsk != current then task_lock must be held on it */
78127 +static inline long pax_set_flags(struct task_struct *tsk, unsigned long flags)
78128 +{
78129 + if (likely(tsk->mm)) {
78130 + tsk->mm->pax_flags = flags;
78131 + return 0;
78132 + }
78133 + return -EINVAL;
78134 +}
78135 +#endif
78136 +
78137 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
78138 +extern void pax_set_initial_flags(struct linux_binprm *bprm);
78139 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
78140 +extern void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
78141 +#endif
78142 +
78143 +struct path;
78144 +extern char *pax_get_path(const struct path *path, char *buf, int buflen);
78145 +extern void pax_report_fault(struct pt_regs *regs, void *pc, void *sp);
78146 +extern void pax_report_insns(struct pt_regs *regs, void *pc, void *sp);
78147 +extern void pax_report_refcount_overflow(struct pt_regs *regs);
78148 +
78149 /* Future-safe accessor for struct task_struct's cpus_allowed. */
78150 #define tsk_cpus_allowed(tsk) (&(tsk)->cpus_allowed)
78151
78152 @@ -1471,7 +1581,7 @@ struct pid_namespace;
78153 pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
78154 struct pid_namespace *ns);
78155
78156 -static inline pid_t task_pid_nr(struct task_struct *tsk)
78157 +static inline pid_t task_pid_nr(const struct task_struct *tsk)
78158 {
78159 return tsk->pid;
78160 }
78161 @@ -1921,7 +2031,9 @@ void yield(void);
78162 extern struct exec_domain default_exec_domain;
78163
78164 union thread_union {
78165 +#ifndef CONFIG_X86
78166 struct thread_info thread_info;
78167 +#endif
78168 unsigned long stack[THREAD_SIZE/sizeof(long)];
78169 };
78170
78171 @@ -1954,6 +2066,7 @@ extern struct pid_namespace init_pid_ns;
78172 */
78173
78174 extern struct task_struct *find_task_by_vpid(pid_t nr);
78175 +extern struct task_struct *find_task_by_vpid_unrestricted(pid_t nr);
78176 extern struct task_struct *find_task_by_pid_ns(pid_t nr,
78177 struct pid_namespace *ns);
78178
78179 @@ -2118,7 +2231,7 @@ extern void __cleanup_sighand(struct sighand_struct *);
78180 extern void exit_itimers(struct signal_struct *);
78181 extern void flush_itimer_signals(void);
78182
78183 -extern void do_group_exit(int);
78184 +extern __noreturn void do_group_exit(int);
78185
78186 extern int allow_signal(int);
78187 extern int disallow_signal(int);
78188 @@ -2309,9 +2422,9 @@ static inline unsigned long *end_of_stack(struct task_struct *p)
78189
78190 #endif
78191
78192 -static inline int object_is_on_stack(void *obj)
78193 +static inline int object_starts_on_stack(void *obj)
78194 {
78195 - void *stack = task_stack_page(current);
78196 + const void *stack = task_stack_page(current);
78197
78198 return (obj >= stack) && (obj < (stack + THREAD_SIZE));
78199 }
78200 diff --git a/include/linux/sched/sysctl.h b/include/linux/sched/sysctl.h
78201 index bf8086b..962b035 100644
78202 --- a/include/linux/sched/sysctl.h
78203 +++ b/include/linux/sched/sysctl.h
78204 @@ -30,6 +30,7 @@ enum { sysctl_hung_task_timeout_secs = 0 };
78205 #define DEFAULT_MAX_MAP_COUNT (USHRT_MAX - MAPCOUNT_ELF_CORE_MARGIN)
78206
78207 extern int sysctl_max_map_count;
78208 +extern unsigned long sysctl_heap_stack_gap;
78209
78210 extern unsigned int sysctl_sched_latency;
78211 extern unsigned int sysctl_sched_min_granularity;
78212 diff --git a/include/linux/security.h b/include/linux/security.h
78213 index 9d37e2b..43368e4 100644
78214 --- a/include/linux/security.h
78215 +++ b/include/linux/security.h
78216 @@ -27,6 +27,7 @@
78217 #include <linux/slab.h>
78218 #include <linux/err.h>
78219 #include <linux/string.h>
78220 +#include <linux/grsecurity.h>
78221
78222 struct linux_binprm;
78223 struct cred;
78224 @@ -116,8 +117,6 @@ struct seq_file;
78225
78226 extern int cap_netlink_send(struct sock *sk, struct sk_buff *skb);
78227
78228 -void reset_security_ops(void);
78229 -
78230 #ifdef CONFIG_MMU
78231 extern unsigned long mmap_min_addr;
78232 extern unsigned long dac_mmap_min_addr;
78233 diff --git a/include/linux/semaphore.h b/include/linux/semaphore.h
78234 index dc368b8..e895209 100644
78235 --- a/include/linux/semaphore.h
78236 +++ b/include/linux/semaphore.h
78237 @@ -37,7 +37,7 @@ static inline void sema_init(struct semaphore *sem, int val)
78238 }
78239
78240 extern void down(struct semaphore *sem);
78241 -extern int __must_check down_interruptible(struct semaphore *sem);
78242 +extern int __must_check down_interruptible(struct semaphore *sem) __intentional_overflow(-1);
78243 extern int __must_check down_killable(struct semaphore *sem);
78244 extern int __must_check down_trylock(struct semaphore *sem);
78245 extern int __must_check down_timeout(struct semaphore *sem, long jiffies);
78246 diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
78247 index 4e32edc..f8f2d18 100644
78248 --- a/include/linux/seq_file.h
78249 +++ b/include/linux/seq_file.h
78250 @@ -26,6 +26,9 @@ struct seq_file {
78251 struct mutex lock;
78252 const struct seq_operations *op;
78253 int poll_event;
78254 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
78255 + u64 exec_id;
78256 +#endif
78257 #ifdef CONFIG_USER_NS
78258 struct user_namespace *user_ns;
78259 #endif
78260 @@ -38,6 +41,7 @@ struct seq_operations {
78261 void * (*next) (struct seq_file *m, void *v, loff_t *pos);
78262 int (*show) (struct seq_file *m, void *v);
78263 };
78264 +typedef struct seq_operations __no_const seq_operations_no_const;
78265
78266 #define SEQ_SKIP 1
78267
78268 diff --git a/include/linux/shm.h b/include/linux/shm.h
78269 index 429c199..4d42e38 100644
78270 --- a/include/linux/shm.h
78271 +++ b/include/linux/shm.h
78272 @@ -21,6 +21,10 @@ struct shmid_kernel /* private to the kernel */
78273
78274 /* The task created the shm object. NULL if the task is dead. */
78275 struct task_struct *shm_creator;
78276 +#ifdef CONFIG_GRKERNSEC
78277 + time_t shm_createtime;
78278 + pid_t shm_lapid;
78279 +#endif
78280 };
78281
78282 /* shm_mode upper byte flags */
78283 diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
78284 index f66f346..2e304d5 100644
78285 --- a/include/linux/skbuff.h
78286 +++ b/include/linux/skbuff.h
78287 @@ -639,7 +639,7 @@ extern bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from,
78288 extern struct sk_buff *__alloc_skb(unsigned int size,
78289 gfp_t priority, int flags, int node);
78290 extern struct sk_buff *build_skb(void *data, unsigned int frag_size);
78291 -static inline struct sk_buff *alloc_skb(unsigned int size,
78292 +static inline struct sk_buff * __intentional_overflow(0) alloc_skb(unsigned int size,
78293 gfp_t priority)
78294 {
78295 return __alloc_skb(size, priority, 0, NUMA_NO_NODE);
78296 @@ -755,7 +755,7 @@ static inline struct skb_shared_hwtstamps *skb_hwtstamps(struct sk_buff *skb)
78297 */
78298 static inline int skb_queue_empty(const struct sk_buff_head *list)
78299 {
78300 - return list->next == (struct sk_buff *)list;
78301 + return list->next == (const struct sk_buff *)list;
78302 }
78303
78304 /**
78305 @@ -768,7 +768,7 @@ static inline int skb_queue_empty(const struct sk_buff_head *list)
78306 static inline bool skb_queue_is_last(const struct sk_buff_head *list,
78307 const struct sk_buff *skb)
78308 {
78309 - return skb->next == (struct sk_buff *)list;
78310 + return skb->next == (const struct sk_buff *)list;
78311 }
78312
78313 /**
78314 @@ -781,7 +781,7 @@ static inline bool skb_queue_is_last(const struct sk_buff_head *list,
78315 static inline bool skb_queue_is_first(const struct sk_buff_head *list,
78316 const struct sk_buff *skb)
78317 {
78318 - return skb->prev == (struct sk_buff *)list;
78319 + return skb->prev == (const struct sk_buff *)list;
78320 }
78321
78322 /**
78323 @@ -1741,7 +1741,7 @@ static inline int pskb_network_may_pull(struct sk_buff *skb, unsigned int len)
78324 * NET_IP_ALIGN(2) + ethernet_header(14) + IP_header(20/40) + ports(8)
78325 */
78326 #ifndef NET_SKB_PAD
78327 -#define NET_SKB_PAD max(32, L1_CACHE_BYTES)
78328 +#define NET_SKB_PAD max(_AC(32,UL), L1_CACHE_BYTES)
78329 #endif
78330
78331 extern int ___pskb_trim(struct sk_buff *skb, unsigned int len);
78332 @@ -2339,7 +2339,7 @@ extern struct sk_buff *skb_recv_datagram(struct sock *sk, unsigned flags,
78333 int noblock, int *err);
78334 extern unsigned int datagram_poll(struct file *file, struct socket *sock,
78335 struct poll_table_struct *wait);
78336 -extern int skb_copy_datagram_iovec(const struct sk_buff *from,
78337 +extern int __intentional_overflow(0) skb_copy_datagram_iovec(const struct sk_buff *from,
78338 int offset, struct iovec *to,
78339 int size);
78340 extern int skb_copy_and_csum_datagram_iovec(struct sk_buff *skb,
78341 @@ -2618,6 +2618,9 @@ static inline void nf_reset(struct sk_buff *skb)
78342 nf_bridge_put(skb->nf_bridge);
78343 skb->nf_bridge = NULL;
78344 #endif
78345 +#if IS_ENABLED(CONFIG_NETFILTER_XT_TARGET_TRACE)
78346 + skb->nf_trace = 0;
78347 +#endif
78348 }
78349
78350 static inline void nf_reset_trace(struct sk_buff *skb)
78351 diff --git a/include/linux/slab.h b/include/linux/slab.h
78352 index 74f1058..914b7da 100644
78353 --- a/include/linux/slab.h
78354 +++ b/include/linux/slab.h
78355 @@ -14,15 +14,29 @@
78356 #include <linux/gfp.h>
78357 #include <linux/types.h>
78358 #include <linux/workqueue.h>
78359 -
78360 +#include <linux/err.h>
78361
78362 /*
78363 * Flags to pass to kmem_cache_create().
78364 * The ones marked DEBUG are only valid if CONFIG_SLAB_DEBUG is set.
78365 */
78366 #define SLAB_DEBUG_FREE 0x00000100UL /* DEBUG: Perform (expensive) checks on free */
78367 +
78368 +#ifdef CONFIG_PAX_USERCOPY_SLABS
78369 +#define SLAB_USERCOPY 0x00000200UL /* PaX: Allow copying objs to/from userland */
78370 +#else
78371 +#define SLAB_USERCOPY 0x00000000UL
78372 +#endif
78373 +
78374 #define SLAB_RED_ZONE 0x00000400UL /* DEBUG: Red zone objs in a cache */
78375 #define SLAB_POISON 0x00000800UL /* DEBUG: Poison objects */
78376 +
78377 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
78378 +#define SLAB_NO_SANITIZE 0x00001000UL /* PaX: Do not sanitize objs on free */
78379 +#else
78380 +#define SLAB_NO_SANITIZE 0x00000000UL
78381 +#endif
78382 +
78383 #define SLAB_HWCACHE_ALIGN 0x00002000UL /* Align objs on cache lines */
78384 #define SLAB_CACHE_DMA 0x00004000UL /* Use GFP_DMA memory */
78385 #define SLAB_STORE_USER 0x00010000UL /* DEBUG: Store the last owner for bug hunting */
78386 @@ -91,10 +105,13 @@
78387 * ZERO_SIZE_PTR can be passed to kfree though in the same way that NULL can.
78388 * Both make kfree a no-op.
78389 */
78390 -#define ZERO_SIZE_PTR ((void *)16)
78391 +#define ZERO_SIZE_PTR \
78392 +({ \
78393 + BUILD_BUG_ON(!(MAX_ERRNO & ~PAGE_MASK));\
78394 + (void *)(-MAX_ERRNO-1L); \
78395 +})
78396
78397 -#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) <= \
78398 - (unsigned long)ZERO_SIZE_PTR)
78399 +#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) - 1 >= (unsigned long)ZERO_SIZE_PTR - 1)
78400
78401 #include <linux/kmemleak.h>
78402
78403 @@ -135,6 +152,8 @@ void * __must_check krealloc(const void *, size_t, gfp_t);
78404 void kfree(const void *);
78405 void kzfree(const void *);
78406 size_t ksize(const void *);
78407 +const char *check_heap_object(const void *ptr, unsigned long n);
78408 +bool is_usercopy_object(const void *ptr);
78409
78410 /*
78411 * Some archs want to perform DMA into kmalloc caches and need a guaranteed
78412 @@ -167,7 +186,7 @@ struct kmem_cache {
78413 unsigned int align; /* Alignment as calculated */
78414 unsigned long flags; /* Active flags on the slab */
78415 const char *name; /* Slab name for sysfs */
78416 - int refcount; /* Use counter */
78417 + atomic_t refcount; /* Use counter */
78418 void (*ctor)(void *); /* Called on object slot creation */
78419 struct list_head list; /* List of all slab caches on the system */
78420 };
78421 @@ -241,6 +260,10 @@ extern struct kmem_cache *kmalloc_caches[KMALLOC_SHIFT_HIGH + 1];
78422 extern struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
78423 #endif
78424
78425 +#ifdef CONFIG_PAX_USERCOPY_SLABS
78426 +extern struct kmem_cache *kmalloc_usercopy_caches[KMALLOC_SHIFT_HIGH + 1];
78427 +#endif
78428 +
78429 /*
78430 * Figure out which kmalloc slab an allocation of a certain size
78431 * belongs to.
78432 @@ -249,7 +272,7 @@ extern struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
78433 * 2 = 120 .. 192 bytes
78434 * n = 2^(n-1) .. 2^n -1
78435 */
78436 -static __always_inline int kmalloc_index(size_t size)
78437 +static __always_inline __size_overflow(1) int kmalloc_index(size_t size)
78438 {
78439 if (!size)
78440 return 0;
78441 @@ -292,11 +315,11 @@ static __always_inline int kmalloc_index(size_t size)
78442 }
78443 #endif /* !CONFIG_SLOB */
78444
78445 -void *__kmalloc(size_t size, gfp_t flags);
78446 +void *__kmalloc(size_t size, gfp_t flags) __alloc_size(1);
78447 void *kmem_cache_alloc(struct kmem_cache *, gfp_t flags);
78448
78449 #ifdef CONFIG_NUMA
78450 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
78451 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __alloc_size(1);
78452 void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
78453 #else
78454 static __always_inline void *__kmalloc_node(size_t size, gfp_t flags, int node)
78455 diff --git a/include/linux/slab_def.h b/include/linux/slab_def.h
78456 index e9346b4..1494959 100644
78457 --- a/include/linux/slab_def.h
78458 +++ b/include/linux/slab_def.h
78459 @@ -36,7 +36,7 @@ struct kmem_cache {
78460 /* 4) cache creation/removal */
78461 const char *name;
78462 struct list_head list;
78463 - int refcount;
78464 + atomic_t refcount;
78465 int object_size;
78466 int align;
78467
78468 @@ -52,10 +52,14 @@ struct kmem_cache {
78469 unsigned long node_allocs;
78470 unsigned long node_frees;
78471 unsigned long node_overflow;
78472 - atomic_t allochit;
78473 - atomic_t allocmiss;
78474 - atomic_t freehit;
78475 - atomic_t freemiss;
78476 + atomic_unchecked_t allochit;
78477 + atomic_unchecked_t allocmiss;
78478 + atomic_unchecked_t freehit;
78479 + atomic_unchecked_t freemiss;
78480 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
78481 + atomic_unchecked_t sanitized;
78482 + atomic_unchecked_t not_sanitized;
78483 +#endif
78484
78485 /*
78486 * If debugging is enabled, then the allocator can add additional
78487 diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
78488 index cc0b67e..a0329b1 100644
78489 --- a/include/linux/slub_def.h
78490 +++ b/include/linux/slub_def.h
78491 @@ -74,7 +74,7 @@ struct kmem_cache {
78492 struct kmem_cache_order_objects max;
78493 struct kmem_cache_order_objects min;
78494 gfp_t allocflags; /* gfp flags to use on each alloc */
78495 - int refcount; /* Refcount for slab cache destroy */
78496 + atomic_t refcount; /* Refcount for slab cache destroy */
78497 void (*ctor)(void *);
78498 int inuse; /* Offset to metadata */
78499 int align; /* Alignment */
78500 diff --git a/include/linux/smp.h b/include/linux/smp.h
78501 index 731f523..3340268 100644
78502 --- a/include/linux/smp.h
78503 +++ b/include/linux/smp.h
78504 @@ -186,7 +186,9 @@ static inline void __smp_call_function_single(int cpuid,
78505 #endif
78506
78507 #define get_cpu() ({ preempt_disable(); smp_processor_id(); })
78508 +#define raw_get_cpu() ({ raw_preempt_disable(); raw_smp_processor_id(); })
78509 #define put_cpu() preempt_enable()
78510 +#define raw_put_cpu_no_resched() raw_preempt_enable_no_resched()
78511
78512 /*
78513 * Callback to arch code if there's nosmp or maxcpus=0 on the
78514 diff --git a/include/linux/sock_diag.h b/include/linux/sock_diag.h
78515 index 54f91d3..be2c379 100644
78516 --- a/include/linux/sock_diag.h
78517 +++ b/include/linux/sock_diag.h
78518 @@ -11,7 +11,7 @@ struct sock;
78519 struct sock_diag_handler {
78520 __u8 family;
78521 int (*dump)(struct sk_buff *skb, struct nlmsghdr *nlh);
78522 -};
78523 +} __do_const;
78524
78525 int sock_diag_register(const struct sock_diag_handler *h);
78526 void sock_diag_unregister(const struct sock_diag_handler *h);
78527 diff --git a/include/linux/sonet.h b/include/linux/sonet.h
78528 index 680f9a3..f13aeb0 100644
78529 --- a/include/linux/sonet.h
78530 +++ b/include/linux/sonet.h
78531 @@ -7,7 +7,7 @@
78532 #include <uapi/linux/sonet.h>
78533
78534 struct k_sonet_stats {
78535 -#define __HANDLE_ITEM(i) atomic_t i
78536 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
78537 __SONET_ITEMS
78538 #undef __HANDLE_ITEM
78539 };
78540 diff --git a/include/linux/sunrpc/addr.h b/include/linux/sunrpc/addr.h
78541 index 07d8e53..dc934c9 100644
78542 --- a/include/linux/sunrpc/addr.h
78543 +++ b/include/linux/sunrpc/addr.h
78544 @@ -23,9 +23,9 @@ static inline unsigned short rpc_get_port(const struct sockaddr *sap)
78545 {
78546 switch (sap->sa_family) {
78547 case AF_INET:
78548 - return ntohs(((struct sockaddr_in *)sap)->sin_port);
78549 + return ntohs(((const struct sockaddr_in *)sap)->sin_port);
78550 case AF_INET6:
78551 - return ntohs(((struct sockaddr_in6 *)sap)->sin6_port);
78552 + return ntohs(((const struct sockaddr_in6 *)sap)->sin6_port);
78553 }
78554 return 0;
78555 }
78556 @@ -58,7 +58,7 @@ static inline bool __rpc_cmp_addr4(const struct sockaddr *sap1,
78557 static inline bool __rpc_copy_addr4(struct sockaddr *dst,
78558 const struct sockaddr *src)
78559 {
78560 - const struct sockaddr_in *ssin = (struct sockaddr_in *) src;
78561 + const struct sockaddr_in *ssin = (const struct sockaddr_in *) src;
78562 struct sockaddr_in *dsin = (struct sockaddr_in *) dst;
78563
78564 dsin->sin_family = ssin->sin_family;
78565 @@ -164,7 +164,7 @@ static inline u32 rpc_get_scope_id(const struct sockaddr *sa)
78566 if (sa->sa_family != AF_INET6)
78567 return 0;
78568
78569 - return ((struct sockaddr_in6 *) sa)->sin6_scope_id;
78570 + return ((const struct sockaddr_in6 *) sa)->sin6_scope_id;
78571 }
78572
78573 #endif /* _LINUX_SUNRPC_ADDR_H */
78574 diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h
78575 index 6740801..c535f27 100644
78576 --- a/include/linux/sunrpc/clnt.h
78577 +++ b/include/linux/sunrpc/clnt.h
78578 @@ -96,7 +96,7 @@ struct rpc_procinfo {
78579 unsigned int p_timer; /* Which RTT timer to use */
78580 u32 p_statidx; /* Which procedure to account */
78581 const char * p_name; /* name of procedure */
78582 -};
78583 +} __do_const;
78584
78585 #ifdef __KERNEL__
78586
78587 diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h
78588 index 6eecfc2..7ada79d 100644
78589 --- a/include/linux/sunrpc/svc.h
78590 +++ b/include/linux/sunrpc/svc.h
78591 @@ -410,7 +410,7 @@ struct svc_procedure {
78592 unsigned int pc_count; /* call count */
78593 unsigned int pc_cachetype; /* cache info (NFS) */
78594 unsigned int pc_xdrressize; /* maximum size of XDR reply */
78595 -};
78596 +} __do_const;
78597
78598 /*
78599 * Function prototypes.
78600 diff --git a/include/linux/sunrpc/svc_rdma.h b/include/linux/sunrpc/svc_rdma.h
78601 index 0b8e3e6..33e0a01 100644
78602 --- a/include/linux/sunrpc/svc_rdma.h
78603 +++ b/include/linux/sunrpc/svc_rdma.h
78604 @@ -53,15 +53,15 @@ extern unsigned int svcrdma_ord;
78605 extern unsigned int svcrdma_max_requests;
78606 extern unsigned int svcrdma_max_req_size;
78607
78608 -extern atomic_t rdma_stat_recv;
78609 -extern atomic_t rdma_stat_read;
78610 -extern atomic_t rdma_stat_write;
78611 -extern atomic_t rdma_stat_sq_starve;
78612 -extern atomic_t rdma_stat_rq_starve;
78613 -extern atomic_t rdma_stat_rq_poll;
78614 -extern atomic_t rdma_stat_rq_prod;
78615 -extern atomic_t rdma_stat_sq_poll;
78616 -extern atomic_t rdma_stat_sq_prod;
78617 +extern atomic_unchecked_t rdma_stat_recv;
78618 +extern atomic_unchecked_t rdma_stat_read;
78619 +extern atomic_unchecked_t rdma_stat_write;
78620 +extern atomic_unchecked_t rdma_stat_sq_starve;
78621 +extern atomic_unchecked_t rdma_stat_rq_starve;
78622 +extern atomic_unchecked_t rdma_stat_rq_poll;
78623 +extern atomic_unchecked_t rdma_stat_rq_prod;
78624 +extern atomic_unchecked_t rdma_stat_sq_poll;
78625 +extern atomic_unchecked_t rdma_stat_sq_prod;
78626
78627 #define RPCRDMA_VERSION 1
78628
78629 diff --git a/include/linux/sunrpc/svcauth.h b/include/linux/sunrpc/svcauth.h
78630 index 8d71d65..f79586e 100644
78631 --- a/include/linux/sunrpc/svcauth.h
78632 +++ b/include/linux/sunrpc/svcauth.h
78633 @@ -120,7 +120,7 @@ struct auth_ops {
78634 int (*release)(struct svc_rqst *rq);
78635 void (*domain_release)(struct auth_domain *);
78636 int (*set_client)(struct svc_rqst *rq);
78637 -};
78638 +} __do_const;
78639
78640 #define SVC_GARBAGE 1
78641 #define SVC_SYSERR 2
78642 diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
78643 index a5ffd32..0935dea 100644
78644 --- a/include/linux/swiotlb.h
78645 +++ b/include/linux/swiotlb.h
78646 @@ -60,7 +60,8 @@ extern void
78647
78648 extern void
78649 swiotlb_free_coherent(struct device *hwdev, size_t size,
78650 - void *vaddr, dma_addr_t dma_handle);
78651 + void *vaddr, dma_addr_t dma_handle,
78652 + struct dma_attrs *attrs);
78653
78654 extern dma_addr_t swiotlb_map_page(struct device *dev, struct page *page,
78655 unsigned long offset, size_t size,
78656 diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
78657 index 7fac04e..de57300 100644
78658 --- a/include/linux/syscalls.h
78659 +++ b/include/linux/syscalls.h
78660 @@ -97,8 +97,14 @@ struct sigaltstack;
78661 #define __MAP(n,...) __MAP##n(__VA_ARGS__)
78662
78663 #define __SC_DECL(t, a) t a
78664 +#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))
78665 #define __TYPE_IS_LL(t) (__same_type((t)0, 0LL) || __same_type((t)0, 0ULL))
78666 -#define __SC_LONG(t, a) __typeof(__builtin_choose_expr(__TYPE_IS_LL(t), 0LL, 0L)) a
78667 +#define __SC_LONG(t, a) __typeof( \
78668 + __builtin_choose_expr( \
78669 + sizeof(t) > sizeof(int), \
78670 + (t) 0, \
78671 + __builtin_choose_expr(__TYPE_IS_U(t), 0UL, 0L) \
78672 + )) a
78673 #define __SC_CAST(t, a) (t) a
78674 #define __SC_ARGS(t, a) a
78675 #define __SC_TEST(t, a) (void)BUILD_BUG_ON_ZERO(!__TYPE_IS_LL(t) && sizeof(t) > sizeof(long))
78676 @@ -363,11 +369,11 @@ asmlinkage long sys_sync(void);
78677 asmlinkage long sys_fsync(unsigned int fd);
78678 asmlinkage long sys_fdatasync(unsigned int fd);
78679 asmlinkage long sys_bdflush(int func, long data);
78680 -asmlinkage long sys_mount(char __user *dev_name, char __user *dir_name,
78681 - char __user *type, unsigned long flags,
78682 +asmlinkage long sys_mount(const char __user *dev_name, const char __user *dir_name,
78683 + const char __user *type, unsigned long flags,
78684 void __user *data);
78685 -asmlinkage long sys_umount(char __user *name, int flags);
78686 -asmlinkage long sys_oldumount(char __user *name);
78687 +asmlinkage long sys_umount(const char __user *name, int flags);
78688 +asmlinkage long sys_oldumount(const char __user *name);
78689 asmlinkage long sys_truncate(const char __user *path, long length);
78690 asmlinkage long sys_ftruncate(unsigned int fd, unsigned long length);
78691 asmlinkage long sys_stat(const char __user *filename,
78692 @@ -579,7 +585,7 @@ asmlinkage long sys_getsockname(int, struct sockaddr __user *, int __user *);
78693 asmlinkage long sys_getpeername(int, struct sockaddr __user *, int __user *);
78694 asmlinkage long sys_send(int, void __user *, size_t, unsigned);
78695 asmlinkage long sys_sendto(int, void __user *, size_t, unsigned,
78696 - struct sockaddr __user *, int);
78697 + struct sockaddr __user *, int) __intentional_overflow(0);
78698 asmlinkage long sys_sendmsg(int fd, struct msghdr __user *msg, unsigned flags);
78699 asmlinkage long sys_sendmmsg(int fd, struct mmsghdr __user *msg,
78700 unsigned int vlen, unsigned flags);
78701 diff --git a/include/linux/syscore_ops.h b/include/linux/syscore_ops.h
78702 index 27b3b0b..e093dd9 100644
78703 --- a/include/linux/syscore_ops.h
78704 +++ b/include/linux/syscore_ops.h
78705 @@ -16,7 +16,7 @@ struct syscore_ops {
78706 int (*suspend)(void);
78707 void (*resume)(void);
78708 void (*shutdown)(void);
78709 -};
78710 +} __do_const;
78711
78712 extern void register_syscore_ops(struct syscore_ops *ops);
78713 extern void unregister_syscore_ops(struct syscore_ops *ops);
78714 diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
78715 index 14a8ff2..af52bad 100644
78716 --- a/include/linux/sysctl.h
78717 +++ b/include/linux/sysctl.h
78718 @@ -34,13 +34,13 @@ struct ctl_table_root;
78719 struct ctl_table_header;
78720 struct ctl_dir;
78721
78722 -typedef struct ctl_table ctl_table;
78723 -
78724 typedef int proc_handler (struct ctl_table *ctl, int write,
78725 void __user *buffer, size_t *lenp, loff_t *ppos);
78726
78727 extern int proc_dostring(struct ctl_table *, int,
78728 void __user *, size_t *, loff_t *);
78729 +extern int proc_dostring_modpriv(struct ctl_table *, int,
78730 + void __user *, size_t *, loff_t *);
78731 extern int proc_dointvec(struct ctl_table *, int,
78732 void __user *, size_t *, loff_t *);
78733 extern int proc_dointvec_minmax(struct ctl_table *, int,
78734 @@ -115,7 +115,9 @@ struct ctl_table
78735 struct ctl_table_poll *poll;
78736 void *extra1;
78737 void *extra2;
78738 -};
78739 +} __do_const;
78740 +typedef struct ctl_table __no_const ctl_table_no_const;
78741 +typedef struct ctl_table ctl_table;
78742
78743 struct ctl_node {
78744 struct rb_node node;
78745 diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
78746 index 11baec7..706f99f 100644
78747 --- a/include/linux/sysfs.h
78748 +++ b/include/linux/sysfs.h
78749 @@ -33,7 +33,8 @@ struct attribute {
78750 struct lock_class_key *key;
78751 struct lock_class_key skey;
78752 #endif
78753 -};
78754 +} __do_const;
78755 +typedef struct attribute __no_const attribute_no_const;
78756
78757 /**
78758 * sysfs_attr_init - initialize a dynamically allocated sysfs attribute
78759 @@ -62,7 +63,8 @@ struct attribute_group {
78760 struct attribute *, int);
78761 struct attribute **attrs;
78762 struct bin_attribute **bin_attrs;
78763 -};
78764 +} __do_const;
78765 +typedef struct attribute_group __no_const attribute_group_no_const;
78766
78767 /**
78768 * Use these macros to make defining attributes easier. See include/linux/device.h
78769 @@ -126,7 +128,8 @@ struct bin_attribute {
78770 char *, loff_t, size_t);
78771 int (*mmap)(struct file *, struct kobject *, struct bin_attribute *attr,
78772 struct vm_area_struct *vma);
78773 -};
78774 +} __do_const;
78775 +typedef struct bin_attribute __no_const bin_attribute_no_const;
78776
78777 /**
78778 * sysfs_bin_attr_init - initialize a dynamically allocated bin_attribute
78779 diff --git a/include/linux/sysrq.h b/include/linux/sysrq.h
78780 index 7faf933..9b85a0c 100644
78781 --- a/include/linux/sysrq.h
78782 +++ b/include/linux/sysrq.h
78783 @@ -16,6 +16,7 @@
78784
78785 #include <linux/errno.h>
78786 #include <linux/types.h>
78787 +#include <linux/compiler.h>
78788
78789 /* Enable/disable SYSRQ support by default (0==no, 1==yes). */
78790 #define SYSRQ_DEFAULT_ENABLE 1
78791 @@ -36,7 +37,7 @@ struct sysrq_key_op {
78792 char *help_msg;
78793 char *action_msg;
78794 int enable_mask;
78795 -};
78796 +} __do_const;
78797
78798 #ifdef CONFIG_MAGIC_SYSRQ
78799
78800 diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h
78801 index 4ae6f32..425d3e1 100644
78802 --- a/include/linux/thread_info.h
78803 +++ b/include/linux/thread_info.h
78804 @@ -150,6 +150,15 @@ static inline bool test_and_clear_restore_sigmask(void)
78805 #error "no set_restore_sigmask() provided and default one won't work"
78806 #endif
78807
78808 +extern void __check_object_size(const void *ptr, unsigned long n, bool to_user);
78809 +static inline void check_object_size(const void *ptr, unsigned long n, bool to_user)
78810 +{
78811 +#ifndef CONFIG_PAX_USERCOPY_DEBUG
78812 + if (!__builtin_constant_p(n))
78813 +#endif
78814 + __check_object_size(ptr, n, to_user);
78815 +}
78816 +
78817 #endif /* __KERNEL__ */
78818
78819 #endif /* _LINUX_THREAD_INFO_H */
78820 diff --git a/include/linux/tty.h b/include/linux/tty.h
78821 index 64f8646..1515fc7 100644
78822 --- a/include/linux/tty.h
78823 +++ b/include/linux/tty.h
78824 @@ -197,7 +197,7 @@ struct tty_port {
78825 const struct tty_port_operations *ops; /* Port operations */
78826 spinlock_t lock; /* Lock protecting tty field */
78827 int blocked_open; /* Waiting to open */
78828 - int count; /* Usage count */
78829 + atomic_t count; /* Usage count */
78830 wait_queue_head_t open_wait; /* Open waiters */
78831 wait_queue_head_t close_wait; /* Close waiters */
78832 wait_queue_head_t delta_msr_wait; /* Modem status change */
78833 @@ -546,7 +546,7 @@ extern int tty_port_open(struct tty_port *port,
78834 struct tty_struct *tty, struct file *filp);
78835 static inline int tty_port_users(struct tty_port *port)
78836 {
78837 - return port->count + port->blocked_open;
78838 + return atomic_read(&port->count) + port->blocked_open;
78839 }
78840
78841 extern int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc);
78842 diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h
78843 index 756a609..b302dd6 100644
78844 --- a/include/linux/tty_driver.h
78845 +++ b/include/linux/tty_driver.h
78846 @@ -285,7 +285,7 @@ struct tty_operations {
78847 void (*poll_put_char)(struct tty_driver *driver, int line, char ch);
78848 #endif
78849 const struct file_operations *proc_fops;
78850 -};
78851 +} __do_const;
78852
78853 struct tty_driver {
78854 int magic; /* magic number for this structure */
78855 diff --git a/include/linux/tty_ldisc.h b/include/linux/tty_ldisc.h
78856 index f15c898..207b7d1 100644
78857 --- a/include/linux/tty_ldisc.h
78858 +++ b/include/linux/tty_ldisc.h
78859 @@ -211,7 +211,7 @@ struct tty_ldisc_ops {
78860
78861 struct module *owner;
78862
78863 - int refcount;
78864 + atomic_t refcount;
78865 };
78866
78867 struct tty_ldisc {
78868 diff --git a/include/linux/types.h b/include/linux/types.h
78869 index 4d118ba..c3ee9bf 100644
78870 --- a/include/linux/types.h
78871 +++ b/include/linux/types.h
78872 @@ -176,10 +176,26 @@ typedef struct {
78873 int counter;
78874 } atomic_t;
78875
78876 +#ifdef CONFIG_PAX_REFCOUNT
78877 +typedef struct {
78878 + int counter;
78879 +} atomic_unchecked_t;
78880 +#else
78881 +typedef atomic_t atomic_unchecked_t;
78882 +#endif
78883 +
78884 #ifdef CONFIG_64BIT
78885 typedef struct {
78886 long counter;
78887 } atomic64_t;
78888 +
78889 +#ifdef CONFIG_PAX_REFCOUNT
78890 +typedef struct {
78891 + long counter;
78892 +} atomic64_unchecked_t;
78893 +#else
78894 +typedef atomic64_t atomic64_unchecked_t;
78895 +#endif
78896 #endif
78897
78898 struct list_head {
78899 diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h
78900 index 5ca0951..ab496a5 100644
78901 --- a/include/linux/uaccess.h
78902 +++ b/include/linux/uaccess.h
78903 @@ -76,11 +76,11 @@ static inline unsigned long __copy_from_user_nocache(void *to,
78904 long ret; \
78905 mm_segment_t old_fs = get_fs(); \
78906 \
78907 - set_fs(KERNEL_DS); \
78908 pagefault_disable(); \
78909 - ret = __copy_from_user_inatomic(&(retval), (__force typeof(retval) __user *)(addr), sizeof(retval)); \
78910 - pagefault_enable(); \
78911 + set_fs(KERNEL_DS); \
78912 + ret = __copy_from_user_inatomic(&(retval), (typeof(retval) __force_user *)(addr), sizeof(retval)); \
78913 set_fs(old_fs); \
78914 + pagefault_enable(); \
78915 ret; \
78916 })
78917
78918 diff --git a/include/linux/uidgid.h b/include/linux/uidgid.h
78919 index 8e522cbc..aa8572d 100644
78920 --- a/include/linux/uidgid.h
78921 +++ b/include/linux/uidgid.h
78922 @@ -197,4 +197,9 @@ static inline bool kgid_has_mapping(struct user_namespace *ns, kgid_t gid)
78923
78924 #endif /* CONFIG_USER_NS */
78925
78926 +#define GR_GLOBAL_UID(x) from_kuid_munged(&init_user_ns, (x))
78927 +#define GR_GLOBAL_GID(x) from_kgid_munged(&init_user_ns, (x))
78928 +#define gr_is_global_root(x) uid_eq((x), GLOBAL_ROOT_UID)
78929 +#define gr_is_global_nonroot(x) (!uid_eq((x), GLOBAL_ROOT_UID))
78930 +
78931 #endif /* _LINUX_UIDGID_H */
78932 diff --git a/include/linux/unaligned/access_ok.h b/include/linux/unaligned/access_ok.h
78933 index 99c1b4d..562e6f3 100644
78934 --- a/include/linux/unaligned/access_ok.h
78935 +++ b/include/linux/unaligned/access_ok.h
78936 @@ -4,34 +4,34 @@
78937 #include <linux/kernel.h>
78938 #include <asm/byteorder.h>
78939
78940 -static inline u16 get_unaligned_le16(const void *p)
78941 +static inline u16 __intentional_overflow(-1) get_unaligned_le16(const void *p)
78942 {
78943 - return le16_to_cpup((__le16 *)p);
78944 + return le16_to_cpup((const __le16 *)p);
78945 }
78946
78947 -static inline u32 get_unaligned_le32(const void *p)
78948 +static inline u32 __intentional_overflow(-1) get_unaligned_le32(const void *p)
78949 {
78950 - return le32_to_cpup((__le32 *)p);
78951 + return le32_to_cpup((const __le32 *)p);
78952 }
78953
78954 -static inline u64 get_unaligned_le64(const void *p)
78955 +static inline u64 __intentional_overflow(-1) get_unaligned_le64(const void *p)
78956 {
78957 - return le64_to_cpup((__le64 *)p);
78958 + return le64_to_cpup((const __le64 *)p);
78959 }
78960
78961 -static inline u16 get_unaligned_be16(const void *p)
78962 +static inline u16 __intentional_overflow(-1) get_unaligned_be16(const void *p)
78963 {
78964 - return be16_to_cpup((__be16 *)p);
78965 + return be16_to_cpup((const __be16 *)p);
78966 }
78967
78968 -static inline u32 get_unaligned_be32(const void *p)
78969 +static inline u32 __intentional_overflow(-1) get_unaligned_be32(const void *p)
78970 {
78971 - return be32_to_cpup((__be32 *)p);
78972 + return be32_to_cpup((const __be32 *)p);
78973 }
78974
78975 -static inline u64 get_unaligned_be64(const void *p)
78976 +static inline u64 __intentional_overflow(-1) get_unaligned_be64(const void *p)
78977 {
78978 - return be64_to_cpup((__be64 *)p);
78979 + return be64_to_cpup((const __be64 *)p);
78980 }
78981
78982 static inline void put_unaligned_le16(u16 val, void *p)
78983 diff --git a/include/linux/usb.h b/include/linux/usb.h
78984 index 6b02370..2355ffa 100644
78985 --- a/include/linux/usb.h
78986 +++ b/include/linux/usb.h
78987 @@ -563,7 +563,7 @@ struct usb_device {
78988 int maxchild;
78989
78990 u32 quirks;
78991 - atomic_t urbnum;
78992 + atomic_unchecked_t urbnum;
78993
78994 unsigned long active_duration;
78995
78996 @@ -1639,7 +1639,7 @@ void usb_buffer_unmap_sg(const struct usb_device *dev, int is_in,
78997
78998 extern int usb_control_msg(struct usb_device *dev, unsigned int pipe,
78999 __u8 request, __u8 requesttype, __u16 value, __u16 index,
79000 - void *data, __u16 size, int timeout);
79001 + void *data, __u16 size, int timeout) __intentional_overflow(-1);
79002 extern int usb_interrupt_msg(struct usb_device *usb_dev, unsigned int pipe,
79003 void *data, int len, int *actual_length, int timeout);
79004 extern int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,
79005 diff --git a/include/linux/usb/renesas_usbhs.h b/include/linux/usb/renesas_usbhs.h
79006 index e452ba6..78f8e80 100644
79007 --- a/include/linux/usb/renesas_usbhs.h
79008 +++ b/include/linux/usb/renesas_usbhs.h
79009 @@ -39,7 +39,7 @@ enum {
79010 */
79011 struct renesas_usbhs_driver_callback {
79012 int (*notify_hotplug)(struct platform_device *pdev);
79013 -};
79014 +} __no_const;
79015
79016 /*
79017 * callback functions for platform
79018 diff --git a/include/linux/vermagic.h b/include/linux/vermagic.h
79019 index 6f8fbcf..8259001 100644
79020 --- a/include/linux/vermagic.h
79021 +++ b/include/linux/vermagic.h
79022 @@ -25,9 +25,35 @@
79023 #define MODULE_ARCH_VERMAGIC ""
79024 #endif
79025
79026 +#ifdef CONFIG_PAX_REFCOUNT
79027 +#define MODULE_PAX_REFCOUNT "REFCOUNT "
79028 +#else
79029 +#define MODULE_PAX_REFCOUNT ""
79030 +#endif
79031 +
79032 +#ifdef CONSTIFY_PLUGIN
79033 +#define MODULE_CONSTIFY_PLUGIN "CONSTIFY_PLUGIN "
79034 +#else
79035 +#define MODULE_CONSTIFY_PLUGIN ""
79036 +#endif
79037 +
79038 +#ifdef STACKLEAK_PLUGIN
79039 +#define MODULE_STACKLEAK_PLUGIN "STACKLEAK_PLUGIN "
79040 +#else
79041 +#define MODULE_STACKLEAK_PLUGIN ""
79042 +#endif
79043 +
79044 +#ifdef CONFIG_GRKERNSEC
79045 +#define MODULE_GRSEC "GRSEC "
79046 +#else
79047 +#define MODULE_GRSEC ""
79048 +#endif
79049 +
79050 #define VERMAGIC_STRING \
79051 UTS_RELEASE " " \
79052 MODULE_VERMAGIC_SMP MODULE_VERMAGIC_PREEMPT \
79053 MODULE_VERMAGIC_MODULE_UNLOAD MODULE_VERMAGIC_MODVERSIONS \
79054 - MODULE_ARCH_VERMAGIC
79055 + MODULE_ARCH_VERMAGIC \
79056 + MODULE_PAX_REFCOUNT MODULE_CONSTIFY_PLUGIN MODULE_STACKLEAK_PLUGIN \
79057 + MODULE_GRSEC
79058
79059 diff --git a/include/linux/vga_switcheroo.h b/include/linux/vga_switcheroo.h
79060 index 502073a..a7de024 100644
79061 --- a/include/linux/vga_switcheroo.h
79062 +++ b/include/linux/vga_switcheroo.h
79063 @@ -63,8 +63,8 @@ int vga_switcheroo_get_client_state(struct pci_dev *dev);
79064
79065 void vga_switcheroo_set_dynamic_switch(struct pci_dev *pdev, enum vga_switcheroo_state dynamic);
79066
79067 -int vga_switcheroo_init_domain_pm_ops(struct device *dev, struct dev_pm_domain *domain);
79068 -int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, struct dev_pm_domain *domain);
79069 +int vga_switcheroo_init_domain_pm_ops(struct device *dev, dev_pm_domain_no_const *domain);
79070 +int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, dev_pm_domain_no_const *domain);
79071 #else
79072
79073 static inline void vga_switcheroo_unregister_client(struct pci_dev *dev) {}
79074 @@ -81,8 +81,8 @@ static inline int vga_switcheroo_get_client_state(struct pci_dev *dev) { return
79075
79076 static inline void vga_switcheroo_set_dynamic_switch(struct pci_dev *pdev, enum vga_switcheroo_state dynamic) {}
79077
79078 -static inline int vga_switcheroo_init_domain_pm_ops(struct device *dev, struct dev_pm_domain *domain) { return -EINVAL; }
79079 -static inline int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, struct dev_pm_domain *domain) { return -EINVAL; }
79080 +static inline int vga_switcheroo_init_domain_pm_ops(struct device *dev, dev_pm_domain_no_const *domain) { return -EINVAL; }
79081 +static inline int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, dev_pm_domain_no_const *domain) { return -EINVAL; }
79082
79083 #endif
79084 #endif /* _LINUX_VGA_SWITCHEROO_H_ */
79085 diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
79086 index 4b8a891..cb8df6e 100644
79087 --- a/include/linux/vmalloc.h
79088 +++ b/include/linux/vmalloc.h
79089 @@ -16,6 +16,11 @@ struct vm_area_struct; /* vma defining user mapping in mm_types.h */
79090 #define VM_USERMAP 0x00000008 /* suitable for remap_vmalloc_range */
79091 #define VM_VPAGES 0x00000010 /* buffer for pages was vmalloc'ed */
79092 #define VM_UNINITIALIZED 0x00000020 /* vm_struct is not fully initialized */
79093 +
79094 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
79095 +#define VM_KERNEXEC 0x00000040 /* allocate from executable kernel memory range */
79096 +#endif
79097 +
79098 /* bits [20..32] reserved for arch specific ioremap internals */
79099
79100 /*
79101 @@ -142,7 +147,7 @@ extern void free_vm_area(struct vm_struct *area);
79102
79103 /* for /dev/kmem */
79104 extern long vread(char *buf, char *addr, unsigned long count);
79105 -extern long vwrite(char *buf, char *addr, unsigned long count);
79106 +extern long vwrite(char *buf, char *addr, unsigned long count) __size_overflow(3);
79107
79108 /*
79109 * Internals. Dont't use..
79110 diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h
79111 index e4b9480..5a5f65a 100644
79112 --- a/include/linux/vmstat.h
79113 +++ b/include/linux/vmstat.h
79114 @@ -90,18 +90,18 @@ static inline void vm_events_fold_cpu(int cpu)
79115 /*
79116 * Zone based page accounting with per cpu differentials.
79117 */
79118 -extern atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
79119 +extern atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
79120
79121 static inline void zone_page_state_add(long x, struct zone *zone,
79122 enum zone_stat_item item)
79123 {
79124 - atomic_long_add(x, &zone->vm_stat[item]);
79125 - atomic_long_add(x, &vm_stat[item]);
79126 + atomic_long_add_unchecked(x, &zone->vm_stat[item]);
79127 + atomic_long_add_unchecked(x, &vm_stat[item]);
79128 }
79129
79130 -static inline unsigned long global_page_state(enum zone_stat_item item)
79131 +static inline unsigned long __intentional_overflow(-1) global_page_state(enum zone_stat_item item)
79132 {
79133 - long x = atomic_long_read(&vm_stat[item]);
79134 + long x = atomic_long_read_unchecked(&vm_stat[item]);
79135 #ifdef CONFIG_SMP
79136 if (x < 0)
79137 x = 0;
79138 @@ -109,10 +109,10 @@ static inline unsigned long global_page_state(enum zone_stat_item item)
79139 return x;
79140 }
79141
79142 -static inline unsigned long zone_page_state(struct zone *zone,
79143 +static inline unsigned long __intentional_overflow(-1) zone_page_state(struct zone *zone,
79144 enum zone_stat_item item)
79145 {
79146 - long x = atomic_long_read(&zone->vm_stat[item]);
79147 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
79148 #ifdef CONFIG_SMP
79149 if (x < 0)
79150 x = 0;
79151 @@ -129,7 +129,7 @@ static inline unsigned long zone_page_state(struct zone *zone,
79152 static inline unsigned long zone_page_state_snapshot(struct zone *zone,
79153 enum zone_stat_item item)
79154 {
79155 - long x = atomic_long_read(&zone->vm_stat[item]);
79156 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
79157
79158 #ifdef CONFIG_SMP
79159 int cpu;
79160 @@ -220,8 +220,8 @@ static inline void __mod_zone_page_state(struct zone *zone,
79161
79162 static inline void __inc_zone_state(struct zone *zone, enum zone_stat_item item)
79163 {
79164 - atomic_long_inc(&zone->vm_stat[item]);
79165 - atomic_long_inc(&vm_stat[item]);
79166 + atomic_long_inc_unchecked(&zone->vm_stat[item]);
79167 + atomic_long_inc_unchecked(&vm_stat[item]);
79168 }
79169
79170 static inline void __inc_zone_page_state(struct page *page,
79171 @@ -232,8 +232,8 @@ static inline void __inc_zone_page_state(struct page *page,
79172
79173 static inline void __dec_zone_state(struct zone *zone, enum zone_stat_item item)
79174 {
79175 - atomic_long_dec(&zone->vm_stat[item]);
79176 - atomic_long_dec(&vm_stat[item]);
79177 + atomic_long_dec_unchecked(&zone->vm_stat[item]);
79178 + atomic_long_dec_unchecked(&vm_stat[item]);
79179 }
79180
79181 static inline void __dec_zone_page_state(struct page *page,
79182 diff --git a/include/linux/xattr.h b/include/linux/xattr.h
79183 index 91b0a68..0e9adf6 100644
79184 --- a/include/linux/xattr.h
79185 +++ b/include/linux/xattr.h
79186 @@ -28,7 +28,7 @@ struct xattr_handler {
79187 size_t size, int handler_flags);
79188 int (*set)(struct dentry *dentry, const char *name, const void *buffer,
79189 size_t size, int flags, int handler_flags);
79190 -};
79191 +} __do_const;
79192
79193 struct xattr {
79194 const char *name;
79195 @@ -37,6 +37,9 @@ struct xattr {
79196 };
79197
79198 ssize_t xattr_getsecurity(struct inode *, const char *, void *, size_t);
79199 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
79200 +ssize_t pax_getxattr(struct dentry *, void *, size_t);
79201 +#endif
79202 ssize_t vfs_getxattr(struct dentry *, const char *, void *, size_t);
79203 ssize_t vfs_listxattr(struct dentry *d, char *list, size_t size);
79204 int __vfs_setxattr_noperm(struct dentry *, const char *, const void *, size_t, int);
79205 diff --git a/include/linux/zlib.h b/include/linux/zlib.h
79206 index 9c5a6b4..09c9438 100644
79207 --- a/include/linux/zlib.h
79208 +++ b/include/linux/zlib.h
79209 @@ -31,6 +31,7 @@
79210 #define _ZLIB_H
79211
79212 #include <linux/zconf.h>
79213 +#include <linux/compiler.h>
79214
79215 /* zlib deflate based on ZLIB_VERSION "1.1.3" */
79216 /* zlib inflate based on ZLIB_VERSION "1.2.3" */
79217 @@ -179,7 +180,7 @@ typedef z_stream *z_streamp;
79218
79219 /* basic functions */
79220
79221 -extern int zlib_deflate_workspacesize (int windowBits, int memLevel);
79222 +extern int zlib_deflate_workspacesize (int windowBits, int memLevel) __intentional_overflow(0);
79223 /*
79224 Returns the number of bytes that needs to be allocated for a per-
79225 stream workspace with the specified parameters. A pointer to this
79226 diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
79227 index c768c9f..bdcaa5a 100644
79228 --- a/include/media/v4l2-dev.h
79229 +++ b/include/media/v4l2-dev.h
79230 @@ -76,7 +76,7 @@ struct v4l2_file_operations {
79231 int (*mmap) (struct file *, struct vm_area_struct *);
79232 int (*open) (struct file *);
79233 int (*release) (struct file *);
79234 -};
79235 +} __do_const;
79236
79237 /*
79238 * Newer version of video_device, handled by videodev2.c
79239 diff --git a/include/media/v4l2-device.h b/include/media/v4l2-device.h
79240 index c9b1593..a572459 100644
79241 --- a/include/media/v4l2-device.h
79242 +++ b/include/media/v4l2-device.h
79243 @@ -95,7 +95,7 @@ int __must_check v4l2_device_register(struct device *dev, struct v4l2_device *v4
79244 this function returns 0. If the name ends with a digit (e.g. cx18),
79245 then the name will be set to cx18-0 since cx180 looks really odd. */
79246 int v4l2_device_set_name(struct v4l2_device *v4l2_dev, const char *basename,
79247 - atomic_t *instance);
79248 + atomic_unchecked_t *instance);
79249
79250 /* Set v4l2_dev->dev to NULL. Call when the USB parent disconnects.
79251 Since the parent disappears this ensures that v4l2_dev doesn't have an
79252 diff --git a/include/net/9p/transport.h b/include/net/9p/transport.h
79253 index 9a36d92..0aafe2a 100644
79254 --- a/include/net/9p/transport.h
79255 +++ b/include/net/9p/transport.h
79256 @@ -60,7 +60,7 @@ struct p9_trans_module {
79257 int (*cancel) (struct p9_client *, struct p9_req_t *req);
79258 int (*zc_request)(struct p9_client *, struct p9_req_t *,
79259 char *, char *, int , int, int, int);
79260 -};
79261 +} __do_const;
79262
79263 void v9fs_register_trans(struct p9_trans_module *m);
79264 void v9fs_unregister_trans(struct p9_trans_module *m);
79265 diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
79266 index 1a966af..2767cf6 100644
79267 --- a/include/net/bluetooth/l2cap.h
79268 +++ b/include/net/bluetooth/l2cap.h
79269 @@ -551,7 +551,7 @@ struct l2cap_ops {
79270 void (*defer) (struct l2cap_chan *chan);
79271 struct sk_buff *(*alloc_skb) (struct l2cap_chan *chan,
79272 unsigned long len, int nb);
79273 -};
79274 +} __do_const;
79275
79276 struct l2cap_conn {
79277 struct hci_conn *hcon;
79278 diff --git a/include/net/caif/cfctrl.h b/include/net/caif/cfctrl.h
79279 index f2ae33d..c457cf0 100644
79280 --- a/include/net/caif/cfctrl.h
79281 +++ b/include/net/caif/cfctrl.h
79282 @@ -52,7 +52,7 @@ struct cfctrl_rsp {
79283 void (*radioset_rsp)(void);
79284 void (*reject_rsp)(struct cflayer *layer, u8 linkid,
79285 struct cflayer *client_layer);
79286 -};
79287 +} __no_const;
79288
79289 /* Link Setup Parameters for CAIF-Links. */
79290 struct cfctrl_link_param {
79291 @@ -101,8 +101,8 @@ struct cfctrl_request_info {
79292 struct cfctrl {
79293 struct cfsrvl serv;
79294 struct cfctrl_rsp res;
79295 - atomic_t req_seq_no;
79296 - atomic_t rsp_seq_no;
79297 + atomic_unchecked_t req_seq_no;
79298 + atomic_unchecked_t rsp_seq_no;
79299 struct list_head list;
79300 /* Protects from simultaneous access to first_req list */
79301 spinlock_t info_list_lock;
79302 diff --git a/include/net/flow.h b/include/net/flow.h
79303 index 628e11b..4c475df 100644
79304 --- a/include/net/flow.h
79305 +++ b/include/net/flow.h
79306 @@ -221,6 +221,6 @@ extern struct flow_cache_object *flow_cache_lookup(
79307
79308 extern void flow_cache_flush(void);
79309 extern void flow_cache_flush_deferred(void);
79310 -extern atomic_t flow_cache_genid;
79311 +extern atomic_unchecked_t flow_cache_genid;
79312
79313 #endif
79314 diff --git a/include/net/genetlink.h b/include/net/genetlink.h
79315 index 8e0b6c8..73cf605 100644
79316 --- a/include/net/genetlink.h
79317 +++ b/include/net/genetlink.h
79318 @@ -120,7 +120,7 @@ struct genl_ops {
79319 struct netlink_callback *cb);
79320 int (*done)(struct netlink_callback *cb);
79321 struct list_head ops_list;
79322 -};
79323 +} __do_const;
79324
79325 extern int __genl_register_family(struct genl_family *family);
79326
79327 diff --git a/include/net/gro_cells.h b/include/net/gro_cells.h
79328 index 734d9b5..48a9a4b 100644
79329 --- a/include/net/gro_cells.h
79330 +++ b/include/net/gro_cells.h
79331 @@ -29,7 +29,7 @@ static inline void gro_cells_receive(struct gro_cells *gcells, struct sk_buff *s
79332 cell += skb_get_rx_queue(skb) & gcells->gro_cells_mask;
79333
79334 if (skb_queue_len(&cell->napi_skbs) > netdev_max_backlog) {
79335 - atomic_long_inc(&dev->rx_dropped);
79336 + atomic_long_inc_unchecked(&dev->rx_dropped);
79337 kfree_skb(skb);
79338 return;
79339 }
79340 diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h
79341 index de2c785..0588a6b 100644
79342 --- a/include/net/inet_connection_sock.h
79343 +++ b/include/net/inet_connection_sock.h
79344 @@ -62,7 +62,7 @@ struct inet_connection_sock_af_ops {
79345 void (*addr2sockaddr)(struct sock *sk, struct sockaddr *);
79346 int (*bind_conflict)(const struct sock *sk,
79347 const struct inet_bind_bucket *tb, bool relax);
79348 -};
79349 +} __do_const;
79350
79351 /** inet_connection_sock - INET connection oriented sock
79352 *
79353 diff --git a/include/net/inetpeer.h b/include/net/inetpeer.h
79354 index 53f464d..0bd0b49 100644
79355 --- a/include/net/inetpeer.h
79356 +++ b/include/net/inetpeer.h
79357 @@ -47,8 +47,8 @@ struct inet_peer {
79358 */
79359 union {
79360 struct {
79361 - atomic_t rid; /* Frag reception counter */
79362 - atomic_t ip_id_count; /* IP ID for the next packet */
79363 + atomic_unchecked_t rid; /* Frag reception counter */
79364 + atomic_unchecked_t ip_id_count; /* IP ID for the next packet */
79365 };
79366 struct rcu_head rcu;
79367 struct inet_peer *gc_next;
79368 @@ -178,16 +178,13 @@ static inline void inet_peer_refcheck(const struct inet_peer *p)
79369 /* can be called with or without local BH being disabled */
79370 static inline int inet_getid(struct inet_peer *p, int more)
79371 {
79372 - int old, new;
79373 + int id;
79374 more++;
79375 inet_peer_refcheck(p);
79376 - do {
79377 - old = atomic_read(&p->ip_id_count);
79378 - new = old + more;
79379 - if (!new)
79380 - new = 1;
79381 - } while (atomic_cmpxchg(&p->ip_id_count, old, new) != old);
79382 - return new;
79383 + id = atomic_add_return_unchecked(more, &p->ip_id_count);
79384 + if (!id)
79385 + id = atomic_inc_return_unchecked(&p->ip_id_count);
79386 + return id;
79387 }
79388
79389 #endif /* _NET_INETPEER_H */
79390 diff --git a/include/net/ip.h b/include/net/ip.h
79391 index 301f10c..b52cdaf 100644
79392 --- a/include/net/ip.h
79393 +++ b/include/net/ip.h
79394 @@ -212,7 +212,7 @@ extern struct local_ports {
79395 } sysctl_local_ports;
79396 extern void inet_get_local_port_range(int *low, int *high);
79397
79398 -extern unsigned long *sysctl_local_reserved_ports;
79399 +extern unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
79400 static inline int inet_is_reserved_local_port(int port)
79401 {
79402 return test_bit(port, sysctl_local_reserved_ports);
79403 diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
79404 index cbf2be3..3683f6d 100644
79405 --- a/include/net/ip_fib.h
79406 +++ b/include/net/ip_fib.h
79407 @@ -169,7 +169,7 @@ extern __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh);
79408
79409 #define FIB_RES_SADDR(net, res) \
79410 ((FIB_RES_NH(res).nh_saddr_genid == \
79411 - atomic_read(&(net)->ipv4.dev_addr_genid)) ? \
79412 + atomic_read_unchecked(&(net)->ipv4.dev_addr_genid)) ? \
79413 FIB_RES_NH(res).nh_saddr : \
79414 fib_info_update_nh_saddr((net), &FIB_RES_NH(res)))
79415 #define FIB_RES_GW(res) (FIB_RES_NH(res).nh_gw)
79416 diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
79417 index 772252d..1e69799 100644
79418 --- a/include/net/ip_vs.h
79419 +++ b/include/net/ip_vs.h
79420 @@ -558,7 +558,7 @@ struct ip_vs_conn {
79421 struct ip_vs_conn *control; /* Master control connection */
79422 atomic_t n_control; /* Number of controlled ones */
79423 struct ip_vs_dest *dest; /* real server */
79424 - atomic_t in_pkts; /* incoming packet counter */
79425 + atomic_unchecked_t in_pkts; /* incoming packet counter */
79426
79427 /* packet transmitter for different forwarding methods. If it
79428 mangles the packet, it must return NF_DROP or better NF_STOLEN,
79429 @@ -705,7 +705,7 @@ struct ip_vs_dest {
79430 __be16 port; /* port number of the server */
79431 union nf_inet_addr addr; /* IP address of the server */
79432 volatile unsigned int flags; /* dest status flags */
79433 - atomic_t conn_flags; /* flags to copy to conn */
79434 + atomic_unchecked_t conn_flags; /* flags to copy to conn */
79435 atomic_t weight; /* server weight */
79436
79437 atomic_t refcnt; /* reference counter */
79438 @@ -960,11 +960,11 @@ struct netns_ipvs {
79439 /* ip_vs_lblc */
79440 int sysctl_lblc_expiration;
79441 struct ctl_table_header *lblc_ctl_header;
79442 - struct ctl_table *lblc_ctl_table;
79443 + ctl_table_no_const *lblc_ctl_table;
79444 /* ip_vs_lblcr */
79445 int sysctl_lblcr_expiration;
79446 struct ctl_table_header *lblcr_ctl_header;
79447 - struct ctl_table *lblcr_ctl_table;
79448 + ctl_table_no_const *lblcr_ctl_table;
79449 /* ip_vs_est */
79450 struct list_head est_list; /* estimator list */
79451 spinlock_t est_lock;
79452 diff --git a/include/net/irda/ircomm_tty.h b/include/net/irda/ircomm_tty.h
79453 index 80ffde3..968b0f4 100644
79454 --- a/include/net/irda/ircomm_tty.h
79455 +++ b/include/net/irda/ircomm_tty.h
79456 @@ -35,6 +35,7 @@
79457 #include <linux/termios.h>
79458 #include <linux/timer.h>
79459 #include <linux/tty.h> /* struct tty_struct */
79460 +#include <asm/local.h>
79461
79462 #include <net/irda/irias_object.h>
79463 #include <net/irda/ircomm_core.h>
79464 diff --git a/include/net/iucv/af_iucv.h b/include/net/iucv/af_iucv.h
79465 index 714cc9a..ea05f3e 100644
79466 --- a/include/net/iucv/af_iucv.h
79467 +++ b/include/net/iucv/af_iucv.h
79468 @@ -149,7 +149,7 @@ struct iucv_skb_cb {
79469 struct iucv_sock_list {
79470 struct hlist_head head;
79471 rwlock_t lock;
79472 - atomic_t autobind_name;
79473 + atomic_unchecked_t autobind_name;
79474 };
79475
79476 unsigned int iucv_sock_poll(struct file *file, struct socket *sock,
79477 diff --git a/include/net/llc_c_ac.h b/include/net/llc_c_ac.h
79478 index df83f69..9b640b8 100644
79479 --- a/include/net/llc_c_ac.h
79480 +++ b/include/net/llc_c_ac.h
79481 @@ -87,7 +87,7 @@
79482 #define LLC_CONN_AC_STOP_SENDACK_TMR 70
79483 #define LLC_CONN_AC_START_SENDACK_TMR_IF_NOT_RUNNING 71
79484
79485 -typedef int (*llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
79486 +typedef int (* const llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
79487
79488 extern int llc_conn_ac_clear_remote_busy(struct sock *sk, struct sk_buff *skb);
79489 extern int llc_conn_ac_conn_ind(struct sock *sk, struct sk_buff *skb);
79490 diff --git a/include/net/llc_c_ev.h b/include/net/llc_c_ev.h
79491 index 6ca3113..f8026dd 100644
79492 --- a/include/net/llc_c_ev.h
79493 +++ b/include/net/llc_c_ev.h
79494 @@ -125,8 +125,8 @@ static __inline__ struct llc_conn_state_ev *llc_conn_ev(struct sk_buff *skb)
79495 return (struct llc_conn_state_ev *)skb->cb;
79496 }
79497
79498 -typedef int (*llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
79499 -typedef int (*llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
79500 +typedef int (* const llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
79501 +typedef int (* const llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
79502
79503 extern int llc_conn_ev_conn_req(struct sock *sk, struct sk_buff *skb);
79504 extern int llc_conn_ev_data_req(struct sock *sk, struct sk_buff *skb);
79505 diff --git a/include/net/llc_c_st.h b/include/net/llc_c_st.h
79506 index 0e79cfb..f46db31 100644
79507 --- a/include/net/llc_c_st.h
79508 +++ b/include/net/llc_c_st.h
79509 @@ -37,7 +37,7 @@ struct llc_conn_state_trans {
79510 u8 next_state;
79511 llc_conn_ev_qfyr_t *ev_qualifiers;
79512 llc_conn_action_t *ev_actions;
79513 -};
79514 +} __do_const;
79515
79516 struct llc_conn_state {
79517 u8 current_state;
79518 diff --git a/include/net/llc_s_ac.h b/include/net/llc_s_ac.h
79519 index 37a3bbd..55a4241 100644
79520 --- a/include/net/llc_s_ac.h
79521 +++ b/include/net/llc_s_ac.h
79522 @@ -23,7 +23,7 @@
79523 #define SAP_ACT_TEST_IND 9
79524
79525 /* All action functions must look like this */
79526 -typedef int (*llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
79527 +typedef int (* const llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
79528
79529 extern int llc_sap_action_unitdata_ind(struct llc_sap *sap,
79530 struct sk_buff *skb);
79531 diff --git a/include/net/llc_s_st.h b/include/net/llc_s_st.h
79532 index 567c681..cd73ac0 100644
79533 --- a/include/net/llc_s_st.h
79534 +++ b/include/net/llc_s_st.h
79535 @@ -20,7 +20,7 @@ struct llc_sap_state_trans {
79536 llc_sap_ev_t ev;
79537 u8 next_state;
79538 llc_sap_action_t *ev_actions;
79539 -};
79540 +} __do_const;
79541
79542 struct llc_sap_state {
79543 u8 curr_state;
79544 diff --git a/include/net/mac80211.h b/include/net/mac80211.h
79545 index cc6035f..a8406fc 100644
79546 --- a/include/net/mac80211.h
79547 +++ b/include/net/mac80211.h
79548 @@ -4361,7 +4361,7 @@ struct rate_control_ops {
79549 void (*add_sta_debugfs)(void *priv, void *priv_sta,
79550 struct dentry *dir);
79551 void (*remove_sta_debugfs)(void *priv, void *priv_sta);
79552 -};
79553 +} __do_const;
79554
79555 static inline int rate_supported(struct ieee80211_sta *sta,
79556 enum ieee80211_band band,
79557 diff --git a/include/net/neighbour.h b/include/net/neighbour.h
79558 index 536501a..7c6193c 100644
79559 --- a/include/net/neighbour.h
79560 +++ b/include/net/neighbour.h
79561 @@ -123,7 +123,7 @@ struct neigh_ops {
79562 void (*error_report)(struct neighbour *, struct sk_buff *);
79563 int (*output)(struct neighbour *, struct sk_buff *);
79564 int (*connected_output)(struct neighbour *, struct sk_buff *);
79565 -};
79566 +} __do_const;
79567
79568 struct pneigh_entry {
79569 struct pneigh_entry *next;
79570 diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
79571 index 9d22f08..980fbf8 100644
79572 --- a/include/net/net_namespace.h
79573 +++ b/include/net/net_namespace.h
79574 @@ -120,7 +120,7 @@ struct net {
79575 struct netns_ipvs *ipvs;
79576 #endif
79577 struct sock *diag_nlsk;
79578 - atomic_t fnhe_genid;
79579 + atomic_unchecked_t fnhe_genid;
79580 };
79581
79582 /*
79583 @@ -277,7 +277,11 @@ static inline struct net *read_pnet(struct net * const *pnet)
79584 #define __net_init __init
79585 #define __net_exit __exit_refok
79586 #define __net_initdata __initdata
79587 +#ifdef CONSTIFY_PLUGIN
79588 #define __net_initconst __initconst
79589 +#else
79590 +#define __net_initconst __initdata
79591 +#endif
79592 #endif
79593
79594 struct pernet_operations {
79595 @@ -287,7 +291,7 @@ struct pernet_operations {
79596 void (*exit_batch)(struct list_head *net_exit_list);
79597 int *id;
79598 size_t size;
79599 -};
79600 +} __do_const;
79601
79602 /*
79603 * Use these carefully. If you implement a network device and it
79604 @@ -335,23 +339,23 @@ static inline void unregister_net_sysctl_table(struct ctl_table_header *header)
79605
79606 static inline int rt_genid_ipv4(struct net *net)
79607 {
79608 - return atomic_read(&net->ipv4.rt_genid);
79609 + return atomic_read_unchecked(&net->ipv4.rt_genid);
79610 }
79611
79612 static inline void rt_genid_bump_ipv4(struct net *net)
79613 {
79614 - atomic_inc(&net->ipv4.rt_genid);
79615 + atomic_inc_unchecked(&net->ipv4.rt_genid);
79616 }
79617
79618 #if IS_ENABLED(CONFIG_IPV6)
79619 static inline int rt_genid_ipv6(struct net *net)
79620 {
79621 - return atomic_read(&net->ipv6.rt_genid);
79622 + return atomic_read_unchecked(&net->ipv6.rt_genid);
79623 }
79624
79625 static inline void rt_genid_bump_ipv6(struct net *net)
79626 {
79627 - atomic_inc(&net->ipv6.rt_genid);
79628 + atomic_inc_unchecked(&net->ipv6.rt_genid);
79629 }
79630 #else
79631 static inline int rt_genid_ipv6(struct net *net)
79632 @@ -373,12 +377,12 @@ static inline void rt_genid_bump_all(struct net *net)
79633
79634 static inline int fnhe_genid(struct net *net)
79635 {
79636 - return atomic_read(&net->fnhe_genid);
79637 + return atomic_read_unchecked(&net->fnhe_genid);
79638 }
79639
79640 static inline void fnhe_genid_bump(struct net *net)
79641 {
79642 - atomic_inc(&net->fnhe_genid);
79643 + atomic_inc_unchecked(&net->fnhe_genid);
79644 }
79645
79646 #endif /* __NET_NET_NAMESPACE_H */
79647 diff --git a/include/net/netdma.h b/include/net/netdma.h
79648 index 8ba8ce2..99b7fff 100644
79649 --- a/include/net/netdma.h
79650 +++ b/include/net/netdma.h
79651 @@ -24,7 +24,7 @@
79652 #include <linux/dmaengine.h>
79653 #include <linux/skbuff.h>
79654
79655 -int dma_skb_copy_datagram_iovec(struct dma_chan* chan,
79656 +int __intentional_overflow(3,5) dma_skb_copy_datagram_iovec(struct dma_chan* chan,
79657 struct sk_buff *skb, int offset, struct iovec *to,
79658 size_t len, struct dma_pinned_list *pinned_list);
79659
79660 diff --git a/include/net/netlink.h b/include/net/netlink.h
79661 index 9690b0f..87aded7 100644
79662 --- a/include/net/netlink.h
79663 +++ b/include/net/netlink.h
79664 @@ -534,7 +534,7 @@ static inline void *nlmsg_get_pos(struct sk_buff *skb)
79665 static inline void nlmsg_trim(struct sk_buff *skb, const void *mark)
79666 {
79667 if (mark)
79668 - skb_trim(skb, (unsigned char *) mark - skb->data);
79669 + skb_trim(skb, (const unsigned char *) mark - skb->data);
79670 }
79671
79672 /**
79673 diff --git a/include/net/netns/conntrack.h b/include/net/netns/conntrack.h
79674 index c9c0c53..53f24c3 100644
79675 --- a/include/net/netns/conntrack.h
79676 +++ b/include/net/netns/conntrack.h
79677 @@ -12,10 +12,10 @@ struct nf_conntrack_ecache;
79678 struct nf_proto_net {
79679 #ifdef CONFIG_SYSCTL
79680 struct ctl_table_header *ctl_table_header;
79681 - struct ctl_table *ctl_table;
79682 + ctl_table_no_const *ctl_table;
79683 #ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
79684 struct ctl_table_header *ctl_compat_header;
79685 - struct ctl_table *ctl_compat_table;
79686 + ctl_table_no_const *ctl_compat_table;
79687 #endif
79688 #endif
79689 unsigned int users;
79690 @@ -58,7 +58,7 @@ struct nf_ip_net {
79691 struct nf_icmp_net icmpv6;
79692 #if defined(CONFIG_SYSCTL) && defined(CONFIG_NF_CONNTRACK_PROC_COMPAT)
79693 struct ctl_table_header *ctl_table_header;
79694 - struct ctl_table *ctl_table;
79695 + ctl_table_no_const *ctl_table;
79696 #endif
79697 };
79698
79699 diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h
79700 index bf2ec22..5e7f9d9 100644
79701 --- a/include/net/netns/ipv4.h
79702 +++ b/include/net/netns/ipv4.h
79703 @@ -67,7 +67,7 @@ struct netns_ipv4 {
79704 kgid_t sysctl_ping_group_range[2];
79705 long sysctl_tcp_mem[3];
79706
79707 - atomic_t dev_addr_genid;
79708 + atomic_unchecked_t dev_addr_genid;
79709
79710 #ifdef CONFIG_IP_MROUTE
79711 #ifndef CONFIG_IP_MROUTE_MULTIPLE_TABLES
79712 @@ -77,6 +77,6 @@ struct netns_ipv4 {
79713 struct fib_rules_ops *mr_rules_ops;
79714 #endif
79715 #endif
79716 - atomic_t rt_genid;
79717 + atomic_unchecked_t rt_genid;
79718 };
79719 #endif
79720 diff --git a/include/net/netns/ipv6.h b/include/net/netns/ipv6.h
79721 index 0fb2401..477d81c 100644
79722 --- a/include/net/netns/ipv6.h
79723 +++ b/include/net/netns/ipv6.h
79724 @@ -71,8 +71,8 @@ struct netns_ipv6 {
79725 struct fib_rules_ops *mr6_rules_ops;
79726 #endif
79727 #endif
79728 - atomic_t dev_addr_genid;
79729 - atomic_t rt_genid;
79730 + atomic_unchecked_t dev_addr_genid;
79731 + atomic_unchecked_t rt_genid;
79732 };
79733
79734 #if IS_ENABLED(CONFIG_NF_DEFRAG_IPV6)
79735 diff --git a/include/net/ping.h b/include/net/ping.h
79736 index 2b496e9..935fd8d 100644
79737 --- a/include/net/ping.h
79738 +++ b/include/net/ping.h
79739 @@ -56,7 +56,7 @@ struct ping_iter_state {
79740 extern struct proto ping_prot;
79741 extern struct ping_table ping_table;
79742 #if IS_ENABLED(CONFIG_IPV6)
79743 -extern struct pingv6_ops pingv6_ops;
79744 +extern struct pingv6_ops *pingv6_ops;
79745 #endif
79746
79747 struct pingfakehdr {
79748 diff --git a/include/net/protocol.h b/include/net/protocol.h
79749 index 047c047..b9dad15 100644
79750 --- a/include/net/protocol.h
79751 +++ b/include/net/protocol.h
79752 @@ -44,7 +44,7 @@ struct net_protocol {
79753 void (*err_handler)(struct sk_buff *skb, u32 info);
79754 unsigned int no_policy:1,
79755 netns_ok:1;
79756 -};
79757 +} __do_const;
79758
79759 #if IS_ENABLED(CONFIG_IPV6)
79760 struct inet6_protocol {
79761 @@ -57,7 +57,7 @@ struct inet6_protocol {
79762 u8 type, u8 code, int offset,
79763 __be32 info);
79764 unsigned int flags; /* INET6_PROTO_xxx */
79765 -};
79766 +} __do_const;
79767
79768 #define INET6_PROTO_NOPOLICY 0x1
79769 #define INET6_PROTO_FINAL 0x2
79770 diff --git a/include/net/rtnetlink.h b/include/net/rtnetlink.h
79771 index 7026648..584cc8c 100644
79772 --- a/include/net/rtnetlink.h
79773 +++ b/include/net/rtnetlink.h
79774 @@ -81,7 +81,7 @@ struct rtnl_link_ops {
79775 const struct net_device *dev);
79776 unsigned int (*get_num_tx_queues)(void);
79777 unsigned int (*get_num_rx_queues)(void);
79778 -};
79779 +} __do_const;
79780
79781 extern int __rtnl_link_register(struct rtnl_link_ops *ops);
79782 extern void __rtnl_link_unregister(struct rtnl_link_ops *ops);
79783 diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h
79784 index 4ef75af..5aa073a 100644
79785 --- a/include/net/sctp/sm.h
79786 +++ b/include/net/sctp/sm.h
79787 @@ -81,7 +81,7 @@ typedef void (sctp_timer_event_t) (unsigned long);
79788 typedef struct {
79789 sctp_state_fn_t *fn;
79790 const char *name;
79791 -} sctp_sm_table_entry_t;
79792 +} __do_const sctp_sm_table_entry_t;
79793
79794 /* A naming convention of "sctp_sf_xxx" applies to all the state functions
79795 * currently in use.
79796 @@ -293,7 +293,7 @@ __u32 sctp_generate_tag(const struct sctp_endpoint *);
79797 __u32 sctp_generate_tsn(const struct sctp_endpoint *);
79798
79799 /* Extern declarations for major data structures. */
79800 -extern sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
79801 +extern sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
79802
79803
79804 /* Get the size of a DATA chunk payload. */
79805 diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
79806 index 2174d8d..71d5257 100644
79807 --- a/include/net/sctp/structs.h
79808 +++ b/include/net/sctp/structs.h
79809 @@ -508,7 +508,7 @@ struct sctp_pf {
79810 struct sctp_association *asoc);
79811 void (*addr_v4map) (struct sctp_sock *, union sctp_addr *);
79812 struct sctp_af *af;
79813 -};
79814 +} __do_const;
79815
79816
79817 /* Structure to track chunk fragments that have been acked, but peer
79818 diff --git a/include/net/sock.h b/include/net/sock.h
79819 index 808cbc2..8617e9c 100644
79820 --- a/include/net/sock.h
79821 +++ b/include/net/sock.h
79822 @@ -332,7 +332,7 @@ struct sock {
79823 unsigned int sk_napi_id;
79824 unsigned int sk_ll_usec;
79825 #endif
79826 - atomic_t sk_drops;
79827 + atomic_unchecked_t sk_drops;
79828 int sk_rcvbuf;
79829
79830 struct sk_filter __rcu *sk_filter;
79831 @@ -1194,7 +1194,7 @@ static inline u64 memcg_memory_allocated_read(struct cg_proto *prot)
79832 return ret >> PAGE_SHIFT;
79833 }
79834
79835 -static inline long
79836 +static inline long __intentional_overflow(-1)
79837 sk_memory_allocated(const struct sock *sk)
79838 {
79839 struct proto *prot = sk->sk_prot;
79840 @@ -1821,7 +1821,7 @@ static inline void sk_nocaps_add(struct sock *sk, netdev_features_t flags)
79841 }
79842
79843 static inline int skb_do_copy_data_nocache(struct sock *sk, struct sk_buff *skb,
79844 - char __user *from, char *to,
79845 + char __user *from, unsigned char *to,
79846 int copy, int offset)
79847 {
79848 if (skb->ip_summed == CHECKSUM_NONE) {
79849 @@ -2083,7 +2083,7 @@ static inline void sk_stream_moderate_sndbuf(struct sock *sk)
79850 }
79851 }
79852
79853 -struct sk_buff *sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
79854 +struct sk_buff * __intentional_overflow(0) sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
79855
79856 /**
79857 * sk_page_frag - return an appropriate page_frag
79858 diff --git a/include/net/tcp.h b/include/net/tcp.h
79859 index b1aa324..b8530ea 100644
79860 --- a/include/net/tcp.h
79861 +++ b/include/net/tcp.h
79862 @@ -527,7 +527,7 @@ extern void tcp_retransmit_timer(struct sock *sk);
79863 extern void tcp_xmit_retransmit_queue(struct sock *);
79864 extern void tcp_simple_retransmit(struct sock *);
79865 extern int tcp_trim_head(struct sock *, struct sk_buff *, u32);
79866 -extern int tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
79867 +extern int __intentional_overflow(3) tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
79868
79869 extern void tcp_send_probe0(struct sock *);
79870 extern void tcp_send_partial(struct sock *);
79871 @@ -699,8 +699,8 @@ struct tcp_skb_cb {
79872 struct inet6_skb_parm h6;
79873 #endif
79874 } header; /* For incoming frames */
79875 - __u32 seq; /* Starting sequence number */
79876 - __u32 end_seq; /* SEQ + FIN + SYN + datalen */
79877 + __u32 seq __intentional_overflow(0); /* Starting sequence number */
79878 + __u32 end_seq __intentional_overflow(0); /* SEQ + FIN + SYN + datalen */
79879 __u32 when; /* used to compute rtt's */
79880 __u8 tcp_flags; /* TCP header flags. (tcp[13]) */
79881
79882 @@ -714,7 +714,7 @@ struct tcp_skb_cb {
79883
79884 __u8 ip_dsfield; /* IPv4 tos or IPv6 dsfield */
79885 /* 1 byte hole */
79886 - __u32 ack_seq; /* Sequence number ACK'd */
79887 + __u32 ack_seq __intentional_overflow(0); /* Sequence number ACK'd */
79888 };
79889
79890 #define TCP_SKB_CB(__skb) ((struct tcp_skb_cb *)&((__skb)->cb[0]))
79891 diff --git a/include/net/xfrm.h b/include/net/xfrm.h
79892 index e253bf0..2278b4b 100644
79893 --- a/include/net/xfrm.h
79894 +++ b/include/net/xfrm.h
79895 @@ -287,7 +287,6 @@ struct xfrm_dst;
79896 struct xfrm_policy_afinfo {
79897 unsigned short family;
79898 struct dst_ops *dst_ops;
79899 - void (*garbage_collect)(struct net *net);
79900 struct dst_entry *(*dst_lookup)(struct net *net, int tos,
79901 const xfrm_address_t *saddr,
79902 const xfrm_address_t *daddr);
79903 @@ -305,7 +304,7 @@ struct xfrm_policy_afinfo {
79904 struct net_device *dev,
79905 const struct flowi *fl);
79906 struct dst_entry *(*blackhole_route)(struct net *net, struct dst_entry *orig);
79907 -};
79908 +} __do_const;
79909
79910 extern int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo);
79911 extern int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo);
79912 @@ -342,7 +341,7 @@ struct xfrm_state_afinfo {
79913 int (*transport_finish)(struct sk_buff *skb,
79914 int async);
79915 void (*local_error)(struct sk_buff *skb, u32 mtu);
79916 -};
79917 +} __do_const;
79918
79919 extern int xfrm_state_register_afinfo(struct xfrm_state_afinfo *afinfo);
79920 extern int xfrm_state_unregister_afinfo(struct xfrm_state_afinfo *afinfo);
79921 @@ -427,7 +426,7 @@ struct xfrm_mode {
79922 struct module *owner;
79923 unsigned int encap;
79924 int flags;
79925 -};
79926 +} __do_const;
79927
79928 /* Flags for xfrm_mode. */
79929 enum {
79930 @@ -524,7 +523,7 @@ struct xfrm_policy {
79931 struct timer_list timer;
79932
79933 struct flow_cache_object flo;
79934 - atomic_t genid;
79935 + atomic_unchecked_t genid;
79936 u32 priority;
79937 u32 index;
79938 struct xfrm_mark mark;
79939 @@ -1164,6 +1163,7 @@ static inline void xfrm_sk_free_policy(struct sock *sk)
79940 }
79941
79942 extern void xfrm_garbage_collect(struct net *net);
79943 +extern void xfrm_garbage_collect_deferred(struct net *net);
79944
79945 #else
79946
79947 @@ -1202,6 +1202,9 @@ static inline int xfrm6_policy_check_reverse(struct sock *sk, int dir,
79948 static inline void xfrm_garbage_collect(struct net *net)
79949 {
79950 }
79951 +static inline void xfrm_garbage_collect_deferred(struct net *net)
79952 +{
79953 +}
79954 #endif
79955
79956 static __inline__
79957 diff --git a/include/rdma/iw_cm.h b/include/rdma/iw_cm.h
79958 index 1017e0b..227aa4d 100644
79959 --- a/include/rdma/iw_cm.h
79960 +++ b/include/rdma/iw_cm.h
79961 @@ -122,7 +122,7 @@ struct iw_cm_verbs {
79962 int backlog);
79963
79964 int (*destroy_listen)(struct iw_cm_id *cm_id);
79965 -};
79966 +} __no_const;
79967
79968 /**
79969 * iw_create_cm_id - Create an IW CM identifier.
79970 diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h
79971 index e1379b4..67eafbe 100644
79972 --- a/include/scsi/libfc.h
79973 +++ b/include/scsi/libfc.h
79974 @@ -762,6 +762,7 @@ struct libfc_function_template {
79975 */
79976 void (*disc_stop_final) (struct fc_lport *);
79977 };
79978 +typedef struct libfc_function_template __no_const libfc_function_template_no_const;
79979
79980 /**
79981 * struct fc_disc - Discovery context
79982 @@ -866,7 +867,7 @@ struct fc_lport {
79983 struct fc_vport *vport;
79984
79985 /* Operational Information */
79986 - struct libfc_function_template tt;
79987 + libfc_function_template_no_const tt;
79988 u8 link_up;
79989 u8 qfull;
79990 enum fc_lport_state state;
79991 diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
79992 index d65fbec..f80fef2 100644
79993 --- a/include/scsi/scsi_device.h
79994 +++ b/include/scsi/scsi_device.h
79995 @@ -180,9 +180,9 @@ struct scsi_device {
79996 unsigned int max_device_blocked; /* what device_blocked counts down from */
79997 #define SCSI_DEFAULT_DEVICE_BLOCKED 3
79998
79999 - atomic_t iorequest_cnt;
80000 - atomic_t iodone_cnt;
80001 - atomic_t ioerr_cnt;
80002 + atomic_unchecked_t iorequest_cnt;
80003 + atomic_unchecked_t iodone_cnt;
80004 + atomic_unchecked_t ioerr_cnt;
80005
80006 struct device sdev_gendev,
80007 sdev_dev;
80008 diff --git a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h
80009 index b797e8f..8e2c3aa 100644
80010 --- a/include/scsi/scsi_transport_fc.h
80011 +++ b/include/scsi/scsi_transport_fc.h
80012 @@ -751,7 +751,8 @@ struct fc_function_template {
80013 unsigned long show_host_system_hostname:1;
80014
80015 unsigned long disable_target_scan:1;
80016 -};
80017 +} __do_const;
80018 +typedef struct fc_function_template __no_const fc_function_template_no_const;
80019
80020
80021 /**
80022 diff --git a/include/sound/compress_driver.h b/include/sound/compress_driver.h
80023 index ae6c3b8..fd748ac 100644
80024 --- a/include/sound/compress_driver.h
80025 +++ b/include/sound/compress_driver.h
80026 @@ -128,7 +128,7 @@ struct snd_compr_ops {
80027 struct snd_compr_caps *caps);
80028 int (*get_codec_caps) (struct snd_compr_stream *stream,
80029 struct snd_compr_codec_caps *codec);
80030 -};
80031 +} __no_const;
80032
80033 /**
80034 * struct snd_compr: Compressed device
80035 diff --git a/include/sound/soc.h b/include/sound/soc.h
80036 index d22cb0a..c6ba150 100644
80037 --- a/include/sound/soc.h
80038 +++ b/include/sound/soc.h
80039 @@ -780,7 +780,7 @@ struct snd_soc_codec_driver {
80040 /* probe ordering - for components with runtime dependencies */
80041 int probe_order;
80042 int remove_order;
80043 -};
80044 +} __do_const;
80045
80046 /* SoC platform interface */
80047 struct snd_soc_platform_driver {
80048 @@ -826,7 +826,7 @@ struct snd_soc_platform_driver {
80049 unsigned int (*read)(struct snd_soc_platform *, unsigned int);
80050 int (*write)(struct snd_soc_platform *, unsigned int, unsigned int);
80051 int (*bespoke_trigger)(struct snd_pcm_substream *, int);
80052 -};
80053 +} __do_const;
80054
80055 struct snd_soc_platform {
80056 const char *name;
80057 diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
80058 index 5bdb8b7..bb1096c 100644
80059 --- a/include/target/target_core_base.h
80060 +++ b/include/target/target_core_base.h
80061 @@ -663,7 +663,7 @@ struct se_device {
80062 spinlock_t stats_lock;
80063 /* Active commands on this virtual SE device */
80064 atomic_t simple_cmds;
80065 - atomic_t dev_ordered_id;
80066 + atomic_unchecked_t dev_ordered_id;
80067 atomic_t dev_ordered_sync;
80068 atomic_t dev_qf_count;
80069 int export_count;
80070 diff --git a/include/trace/events/fs.h b/include/trace/events/fs.h
80071 new file mode 100644
80072 index 0000000..fb634b7
80073 --- /dev/null
80074 +++ b/include/trace/events/fs.h
80075 @@ -0,0 +1,53 @@
80076 +#undef TRACE_SYSTEM
80077 +#define TRACE_SYSTEM fs
80078 +
80079 +#if !defined(_TRACE_FS_H) || defined(TRACE_HEADER_MULTI_READ)
80080 +#define _TRACE_FS_H
80081 +
80082 +#include <linux/fs.h>
80083 +#include <linux/tracepoint.h>
80084 +
80085 +TRACE_EVENT(do_sys_open,
80086 +
80087 + TP_PROTO(const char *filename, int flags, int mode),
80088 +
80089 + TP_ARGS(filename, flags, mode),
80090 +
80091 + TP_STRUCT__entry(
80092 + __string( filename, filename )
80093 + __field( int, flags )
80094 + __field( int, mode )
80095 + ),
80096 +
80097 + TP_fast_assign(
80098 + __assign_str(filename, filename);
80099 + __entry->flags = flags;
80100 + __entry->mode = mode;
80101 + ),
80102 +
80103 + TP_printk("\"%s\" %x %o",
80104 + __get_str(filename), __entry->flags, __entry->mode)
80105 +);
80106 +
80107 +TRACE_EVENT(open_exec,
80108 +
80109 + TP_PROTO(const char *filename),
80110 +
80111 + TP_ARGS(filename),
80112 +
80113 + TP_STRUCT__entry(
80114 + __string( filename, filename )
80115 + ),
80116 +
80117 + TP_fast_assign(
80118 + __assign_str(filename, filename);
80119 + ),
80120 +
80121 + TP_printk("\"%s\"",
80122 + __get_str(filename))
80123 +);
80124 +
80125 +#endif /* _TRACE_FS_H */
80126 +
80127 +/* This part must be outside protection */
80128 +#include <trace/define_trace.h>
80129 diff --git a/include/trace/events/irq.h b/include/trace/events/irq.h
80130 index 1c09820..7f5ec79 100644
80131 --- a/include/trace/events/irq.h
80132 +++ b/include/trace/events/irq.h
80133 @@ -36,7 +36,7 @@ struct softirq_action;
80134 */
80135 TRACE_EVENT(irq_handler_entry,
80136
80137 - TP_PROTO(int irq, struct irqaction *action),
80138 + TP_PROTO(int irq, const struct irqaction *action),
80139
80140 TP_ARGS(irq, action),
80141
80142 @@ -66,7 +66,7 @@ TRACE_EVENT(irq_handler_entry,
80143 */
80144 TRACE_EVENT(irq_handler_exit,
80145
80146 - TP_PROTO(int irq, struct irqaction *action, int ret),
80147 + TP_PROTO(int irq, const struct irqaction *action, int ret),
80148
80149 TP_ARGS(irq, action, ret),
80150
80151 diff --git a/include/uapi/linux/a.out.h b/include/uapi/linux/a.out.h
80152 index 7caf44c..23c6f27 100644
80153 --- a/include/uapi/linux/a.out.h
80154 +++ b/include/uapi/linux/a.out.h
80155 @@ -39,6 +39,14 @@ enum machine_type {
80156 M_MIPS2 = 152 /* MIPS R6000/R4000 binary */
80157 };
80158
80159 +/* Constants for the N_FLAGS field */
80160 +#define F_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
80161 +#define F_PAX_EMUTRAMP 2 /* Emulate trampolines */
80162 +#define F_PAX_MPROTECT 4 /* Restrict mprotect() */
80163 +#define F_PAX_RANDMMAP 8 /* Randomize mmap() base */
80164 +/*#define F_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
80165 +#define F_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
80166 +
80167 #if !defined (N_MAGIC)
80168 #define N_MAGIC(exec) ((exec).a_info & 0xffff)
80169 #endif
80170 diff --git a/include/uapi/linux/byteorder/little_endian.h b/include/uapi/linux/byteorder/little_endian.h
80171 index d876736..ccce5c0 100644
80172 --- a/include/uapi/linux/byteorder/little_endian.h
80173 +++ b/include/uapi/linux/byteorder/little_endian.h
80174 @@ -42,51 +42,51 @@
80175
80176 static inline __le64 __cpu_to_le64p(const __u64 *p)
80177 {
80178 - return (__force __le64)*p;
80179 + return (__force const __le64)*p;
80180 }
80181 -static inline __u64 __le64_to_cpup(const __le64 *p)
80182 +static inline __u64 __intentional_overflow(-1) __le64_to_cpup(const __le64 *p)
80183 {
80184 - return (__force __u64)*p;
80185 + return (__force const __u64)*p;
80186 }
80187 static inline __le32 __cpu_to_le32p(const __u32 *p)
80188 {
80189 - return (__force __le32)*p;
80190 + return (__force const __le32)*p;
80191 }
80192 static inline __u32 __le32_to_cpup(const __le32 *p)
80193 {
80194 - return (__force __u32)*p;
80195 + return (__force const __u32)*p;
80196 }
80197 static inline __le16 __cpu_to_le16p(const __u16 *p)
80198 {
80199 - return (__force __le16)*p;
80200 + return (__force const __le16)*p;
80201 }
80202 static inline __u16 __le16_to_cpup(const __le16 *p)
80203 {
80204 - return (__force __u16)*p;
80205 + return (__force const __u16)*p;
80206 }
80207 static inline __be64 __cpu_to_be64p(const __u64 *p)
80208 {
80209 - return (__force __be64)__swab64p(p);
80210 + return (__force const __be64)__swab64p(p);
80211 }
80212 static inline __u64 __be64_to_cpup(const __be64 *p)
80213 {
80214 - return __swab64p((__u64 *)p);
80215 + return __swab64p((const __u64 *)p);
80216 }
80217 static inline __be32 __cpu_to_be32p(const __u32 *p)
80218 {
80219 - return (__force __be32)__swab32p(p);
80220 + return (__force const __be32)__swab32p(p);
80221 }
80222 -static inline __u32 __be32_to_cpup(const __be32 *p)
80223 +static inline __u32 __intentional_overflow(-1) __be32_to_cpup(const __be32 *p)
80224 {
80225 - return __swab32p((__u32 *)p);
80226 + return __swab32p((const __u32 *)p);
80227 }
80228 static inline __be16 __cpu_to_be16p(const __u16 *p)
80229 {
80230 - return (__force __be16)__swab16p(p);
80231 + return (__force const __be16)__swab16p(p);
80232 }
80233 static inline __u16 __be16_to_cpup(const __be16 *p)
80234 {
80235 - return __swab16p((__u16 *)p);
80236 + return __swab16p((const __u16 *)p);
80237 }
80238 #define __cpu_to_le64s(x) do { (void)(x); } while (0)
80239 #define __le64_to_cpus(x) do { (void)(x); } while (0)
80240 diff --git a/include/uapi/linux/elf.h b/include/uapi/linux/elf.h
80241 index ef6103b..d4e65dd 100644
80242 --- a/include/uapi/linux/elf.h
80243 +++ b/include/uapi/linux/elf.h
80244 @@ -37,6 +37,17 @@ typedef __s64 Elf64_Sxword;
80245 #define PT_GNU_EH_FRAME 0x6474e550
80246
80247 #define PT_GNU_STACK (PT_LOOS + 0x474e551)
80248 +#define PT_GNU_RELRO (PT_LOOS + 0x474e552)
80249 +
80250 +#define PT_PAX_FLAGS (PT_LOOS + 0x5041580)
80251 +
80252 +/* Constants for the e_flags field */
80253 +#define EF_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
80254 +#define EF_PAX_EMUTRAMP 2 /* Emulate trampolines */
80255 +#define EF_PAX_MPROTECT 4 /* Restrict mprotect() */
80256 +#define EF_PAX_RANDMMAP 8 /* Randomize mmap() base */
80257 +/*#define EF_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
80258 +#define EF_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
80259
80260 /*
80261 * Extended Numbering
80262 @@ -94,6 +105,8 @@ typedef __s64 Elf64_Sxword;
80263 #define DT_DEBUG 21
80264 #define DT_TEXTREL 22
80265 #define DT_JMPREL 23
80266 +#define DT_FLAGS 30
80267 + #define DF_TEXTREL 0x00000004
80268 #define DT_ENCODING 32
80269 #define OLD_DT_LOOS 0x60000000
80270 #define DT_LOOS 0x6000000d
80271 @@ -240,6 +253,19 @@ typedef struct elf64_hdr {
80272 #define PF_W 0x2
80273 #define PF_X 0x1
80274
80275 +#define PF_PAGEEXEC (1U << 4) /* Enable PAGEEXEC */
80276 +#define PF_NOPAGEEXEC (1U << 5) /* Disable PAGEEXEC */
80277 +#define PF_SEGMEXEC (1U << 6) /* Enable SEGMEXEC */
80278 +#define PF_NOSEGMEXEC (1U << 7) /* Disable SEGMEXEC */
80279 +#define PF_MPROTECT (1U << 8) /* Enable MPROTECT */
80280 +#define PF_NOMPROTECT (1U << 9) /* Disable MPROTECT */
80281 +/*#define PF_RANDEXEC (1U << 10)*/ /* Enable RANDEXEC */
80282 +/*#define PF_NORANDEXEC (1U << 11)*/ /* Disable RANDEXEC */
80283 +#define PF_EMUTRAMP (1U << 12) /* Enable EMUTRAMP */
80284 +#define PF_NOEMUTRAMP (1U << 13) /* Disable EMUTRAMP */
80285 +#define PF_RANDMMAP (1U << 14) /* Enable RANDMMAP */
80286 +#define PF_NORANDMMAP (1U << 15) /* Disable RANDMMAP */
80287 +
80288 typedef struct elf32_phdr{
80289 Elf32_Word p_type;
80290 Elf32_Off p_offset;
80291 @@ -332,6 +358,8 @@ typedef struct elf64_shdr {
80292 #define EI_OSABI 7
80293 #define EI_PAD 8
80294
80295 +#define EI_PAX 14
80296 +
80297 #define ELFMAG0 0x7f /* EI_MAG */
80298 #define ELFMAG1 'E'
80299 #define ELFMAG2 'L'
80300 diff --git a/include/uapi/linux/personality.h b/include/uapi/linux/personality.h
80301 index aa169c4..6a2771d 100644
80302 --- a/include/uapi/linux/personality.h
80303 +++ b/include/uapi/linux/personality.h
80304 @@ -30,6 +30,7 @@ enum {
80305 #define PER_CLEAR_ON_SETID (READ_IMPLIES_EXEC | \
80306 ADDR_NO_RANDOMIZE | \
80307 ADDR_COMPAT_LAYOUT | \
80308 + ADDR_LIMIT_3GB | \
80309 MMAP_PAGE_ZERO)
80310
80311 /*
80312 diff --git a/include/uapi/linux/screen_info.h b/include/uapi/linux/screen_info.h
80313 index 7530e74..e714828 100644
80314 --- a/include/uapi/linux/screen_info.h
80315 +++ b/include/uapi/linux/screen_info.h
80316 @@ -43,7 +43,8 @@ struct screen_info {
80317 __u16 pages; /* 0x32 */
80318 __u16 vesa_attributes; /* 0x34 */
80319 __u32 capabilities; /* 0x36 */
80320 - __u8 _reserved[6]; /* 0x3a */
80321 + __u16 vesapm_size; /* 0x3a */
80322 + __u8 _reserved[4]; /* 0x3c */
80323 } __attribute__((packed));
80324
80325 #define VIDEO_TYPE_MDA 0x10 /* Monochrome Text Display */
80326 diff --git a/include/uapi/linux/swab.h b/include/uapi/linux/swab.h
80327 index 0e011eb..82681b1 100644
80328 --- a/include/uapi/linux/swab.h
80329 +++ b/include/uapi/linux/swab.h
80330 @@ -43,7 +43,7 @@
80331 * ___swab16, ___swab32, ___swab64, ___swahw32, ___swahb32
80332 */
80333
80334 -static inline __attribute_const__ __u16 __fswab16(__u16 val)
80335 +static inline __intentional_overflow(-1) __attribute_const__ __u16 __fswab16(__u16 val)
80336 {
80337 #ifdef __HAVE_BUILTIN_BSWAP16__
80338 return __builtin_bswap16(val);
80339 @@ -54,7 +54,7 @@ static inline __attribute_const__ __u16 __fswab16(__u16 val)
80340 #endif
80341 }
80342
80343 -static inline __attribute_const__ __u32 __fswab32(__u32 val)
80344 +static inline __intentional_overflow(-1) __attribute_const__ __u32 __fswab32(__u32 val)
80345 {
80346 #ifdef __HAVE_BUILTIN_BSWAP32__
80347 return __builtin_bswap32(val);
80348 @@ -65,7 +65,7 @@ static inline __attribute_const__ __u32 __fswab32(__u32 val)
80349 #endif
80350 }
80351
80352 -static inline __attribute_const__ __u64 __fswab64(__u64 val)
80353 +static inline __intentional_overflow(-1) __attribute_const__ __u64 __fswab64(__u64 val)
80354 {
80355 #ifdef __HAVE_BUILTIN_BSWAP64__
80356 return __builtin_bswap64(val);
80357 diff --git a/include/uapi/linux/sysctl.h b/include/uapi/linux/sysctl.h
80358 index 6d67213..8dab561 100644
80359 --- a/include/uapi/linux/sysctl.h
80360 +++ b/include/uapi/linux/sysctl.h
80361 @@ -155,7 +155,11 @@ enum
80362 KERN_PANIC_ON_NMI=76, /* int: whether we will panic on an unrecovered */
80363 };
80364
80365 -
80366 +#ifdef CONFIG_PAX_SOFTMODE
80367 +enum {
80368 + PAX_SOFTMODE=1 /* PaX: disable/enable soft mode */
80369 +};
80370 +#endif
80371
80372 /* CTL_VM names: */
80373 enum
80374 diff --git a/include/uapi/linux/xattr.h b/include/uapi/linux/xattr.h
80375 index e4629b9..6958086 100644
80376 --- a/include/uapi/linux/xattr.h
80377 +++ b/include/uapi/linux/xattr.h
80378 @@ -63,5 +63,9 @@
80379 #define XATTR_POSIX_ACL_DEFAULT "posix_acl_default"
80380 #define XATTR_NAME_POSIX_ACL_DEFAULT XATTR_SYSTEM_PREFIX XATTR_POSIX_ACL_DEFAULT
80381
80382 +/* User namespace */
80383 +#define XATTR_PAX_PREFIX XATTR_USER_PREFIX "pax."
80384 +#define XATTR_PAX_FLAGS_SUFFIX "flags"
80385 +#define XATTR_NAME_PAX_FLAGS XATTR_PAX_PREFIX XATTR_PAX_FLAGS_SUFFIX
80386
80387 #endif /* _UAPI_LINUX_XATTR_H */
80388 diff --git a/include/video/udlfb.h b/include/video/udlfb.h
80389 index f9466fa..f4e2b81 100644
80390 --- a/include/video/udlfb.h
80391 +++ b/include/video/udlfb.h
80392 @@ -53,10 +53,10 @@ struct dlfb_data {
80393 u32 pseudo_palette[256];
80394 int blank_mode; /*one of FB_BLANK_ */
80395 /* blit-only rendering path metrics, exposed through sysfs */
80396 - atomic_t bytes_rendered; /* raw pixel-bytes driver asked to render */
80397 - atomic_t bytes_identical; /* saved effort with backbuffer comparison */
80398 - atomic_t bytes_sent; /* to usb, after compression including overhead */
80399 - atomic_t cpu_kcycles_used; /* transpired during pixel processing */
80400 + atomic_unchecked_t bytes_rendered; /* raw pixel-bytes driver asked to render */
80401 + atomic_unchecked_t bytes_identical; /* saved effort with backbuffer comparison */
80402 + atomic_unchecked_t bytes_sent; /* to usb, after compression including overhead */
80403 + atomic_unchecked_t cpu_kcycles_used; /* transpired during pixel processing */
80404 };
80405
80406 #define NR_USB_REQUEST_I2C_SUB_IO 0x02
80407 diff --git a/include/video/uvesafb.h b/include/video/uvesafb.h
80408 index 30f5362..8ed8ac9 100644
80409 --- a/include/video/uvesafb.h
80410 +++ b/include/video/uvesafb.h
80411 @@ -122,6 +122,7 @@ struct uvesafb_par {
80412 u8 ypan; /* 0 - nothing, 1 - ypan, 2 - ywrap */
80413 u8 pmi_setpal; /* PMI for palette changes */
80414 u16 *pmi_base; /* protected mode interface location */
80415 + u8 *pmi_code; /* protected mode code location */
80416 void *pmi_start;
80417 void *pmi_pal;
80418 u8 *vbe_state_orig; /*
80419 diff --git a/init/Kconfig b/init/Kconfig
80420 index 3ecd8a1..627843f 100644
80421 --- a/init/Kconfig
80422 +++ b/init/Kconfig
80423 @@ -1086,6 +1086,7 @@ endif # CGROUPS
80424
80425 config CHECKPOINT_RESTORE
80426 bool "Checkpoint/restore support" if EXPERT
80427 + depends on !GRKERNSEC
80428 default n
80429 help
80430 Enables additional kernel features in a sake of checkpoint/restore.
80431 @@ -1557,7 +1558,7 @@ config SLUB_DEBUG
80432
80433 config COMPAT_BRK
80434 bool "Disable heap randomization"
80435 - default y
80436 + default n
80437 help
80438 Randomizing heap placement makes heap exploits harder, but it
80439 also breaks ancient binaries (including anything libc5 based).
80440 @@ -1832,7 +1833,7 @@ config INIT_ALL_POSSIBLE
80441 config STOP_MACHINE
80442 bool
80443 default y
80444 - depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU
80445 + depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU || GRKERNSEC
80446 help
80447 Need stop_machine() primitive.
80448
80449 diff --git a/init/Makefile b/init/Makefile
80450 index 7bc47ee..6da2dc7 100644
80451 --- a/init/Makefile
80452 +++ b/init/Makefile
80453 @@ -2,6 +2,9 @@
80454 # Makefile for the linux kernel.
80455 #
80456
80457 +ccflags-y := $(GCC_PLUGINS_CFLAGS)
80458 +asflags-y := $(GCC_PLUGINS_AFLAGS)
80459 +
80460 obj-y := main.o version.o mounts.o
80461 ifneq ($(CONFIG_BLK_DEV_INITRD),y)
80462 obj-y += noinitramfs.o
80463 diff --git a/init/do_mounts.c b/init/do_mounts.c
80464 index a51cddc..25c2768 100644
80465 --- a/init/do_mounts.c
80466 +++ b/init/do_mounts.c
80467 @@ -357,11 +357,11 @@ static void __init get_fs_names(char *page)
80468 static int __init do_mount_root(char *name, char *fs, int flags, void *data)
80469 {
80470 struct super_block *s;
80471 - int err = sys_mount(name, "/root", fs, flags, data);
80472 + int err = sys_mount((char __force_user *)name, (char __force_user *)"/root", (char __force_user *)fs, flags, (void __force_user *)data);
80473 if (err)
80474 return err;
80475
80476 - sys_chdir("/root");
80477 + sys_chdir((const char __force_user *)"/root");
80478 s = current->fs->pwd.dentry->d_sb;
80479 ROOT_DEV = s->s_dev;
80480 printk(KERN_INFO
80481 @@ -482,18 +482,18 @@ void __init change_floppy(char *fmt, ...)
80482 va_start(args, fmt);
80483 vsprintf(buf, fmt, args);
80484 va_end(args);
80485 - fd = sys_open("/dev/root", O_RDWR | O_NDELAY, 0);
80486 + fd = sys_open((char __user *)"/dev/root", O_RDWR | O_NDELAY, 0);
80487 if (fd >= 0) {
80488 sys_ioctl(fd, FDEJECT, 0);
80489 sys_close(fd);
80490 }
80491 printk(KERN_NOTICE "VFS: Insert %s and press ENTER\n", buf);
80492 - fd = sys_open("/dev/console", O_RDWR, 0);
80493 + fd = sys_open((__force const char __user *)"/dev/console", O_RDWR, 0);
80494 if (fd >= 0) {
80495 sys_ioctl(fd, TCGETS, (long)&termios);
80496 termios.c_lflag &= ~ICANON;
80497 sys_ioctl(fd, TCSETSF, (long)&termios);
80498 - sys_read(fd, &c, 1);
80499 + sys_read(fd, (char __user *)&c, 1);
80500 termios.c_lflag |= ICANON;
80501 sys_ioctl(fd, TCSETSF, (long)&termios);
80502 sys_close(fd);
80503 @@ -587,8 +587,8 @@ void __init prepare_namespace(void)
80504 mount_root();
80505 out:
80506 devtmpfs_mount("dev");
80507 - sys_mount(".", "/", NULL, MS_MOVE, NULL);
80508 - sys_chroot(".");
80509 + sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
80510 + sys_chroot((const char __force_user *)".");
80511 }
80512
80513 static bool is_tmpfs;
80514 diff --git a/init/do_mounts.h b/init/do_mounts.h
80515 index f5b978a..69dbfe8 100644
80516 --- a/init/do_mounts.h
80517 +++ b/init/do_mounts.h
80518 @@ -15,15 +15,15 @@ extern int root_mountflags;
80519
80520 static inline int create_dev(char *name, dev_t dev)
80521 {
80522 - sys_unlink(name);
80523 - return sys_mknod(name, S_IFBLK|0600, new_encode_dev(dev));
80524 + sys_unlink((char __force_user *)name);
80525 + return sys_mknod((char __force_user *)name, S_IFBLK|0600, new_encode_dev(dev));
80526 }
80527
80528 #if BITS_PER_LONG == 32
80529 static inline u32 bstat(char *name)
80530 {
80531 struct stat64 stat;
80532 - if (sys_stat64(name, &stat) != 0)
80533 + if (sys_stat64((char __force_user *)name, (struct stat64 __force_user *)&stat) != 0)
80534 return 0;
80535 if (!S_ISBLK(stat.st_mode))
80536 return 0;
80537 @@ -35,7 +35,7 @@ static inline u32 bstat(char *name)
80538 static inline u32 bstat(char *name)
80539 {
80540 struct stat stat;
80541 - if (sys_newstat(name, &stat) != 0)
80542 + if (sys_newstat((const char __force_user *)name, (struct stat __force_user *)&stat) != 0)
80543 return 0;
80544 if (!S_ISBLK(stat.st_mode))
80545 return 0;
80546 diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c
80547 index 3e0878e..8a9d7a0 100644
80548 --- a/init/do_mounts_initrd.c
80549 +++ b/init/do_mounts_initrd.c
80550 @@ -37,13 +37,13 @@ static int init_linuxrc(struct subprocess_info *info, struct cred *new)
80551 {
80552 sys_unshare(CLONE_FS | CLONE_FILES);
80553 /* stdin/stdout/stderr for /linuxrc */
80554 - sys_open("/dev/console", O_RDWR, 0);
80555 + sys_open((const char __force_user *)"/dev/console", O_RDWR, 0);
80556 sys_dup(0);
80557 sys_dup(0);
80558 /* move initrd over / and chdir/chroot in initrd root */
80559 - sys_chdir("/root");
80560 - sys_mount(".", "/", NULL, MS_MOVE, NULL);
80561 - sys_chroot(".");
80562 + sys_chdir((const char __force_user *)"/root");
80563 + sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
80564 + sys_chroot((const char __force_user *)".");
80565 sys_setsid();
80566 return 0;
80567 }
80568 @@ -59,8 +59,8 @@ static void __init handle_initrd(void)
80569 create_dev("/dev/root.old", Root_RAM0);
80570 /* mount initrd on rootfs' /root */
80571 mount_block_root("/dev/root.old", root_mountflags & ~MS_RDONLY);
80572 - sys_mkdir("/old", 0700);
80573 - sys_chdir("/old");
80574 + sys_mkdir((const char __force_user *)"/old", 0700);
80575 + sys_chdir((const char __force_user *)"/old");
80576
80577 /* try loading default modules from initrd */
80578 load_default_modules();
80579 @@ -80,31 +80,31 @@ static void __init handle_initrd(void)
80580 current->flags &= ~PF_FREEZER_SKIP;
80581
80582 /* move initrd to rootfs' /old */
80583 - sys_mount("..", ".", NULL, MS_MOVE, NULL);
80584 + sys_mount((char __force_user *)"..", (char __force_user *)".", NULL, MS_MOVE, NULL);
80585 /* switch root and cwd back to / of rootfs */
80586 - sys_chroot("..");
80587 + sys_chroot((const char __force_user *)"..");
80588
80589 if (new_decode_dev(real_root_dev) == Root_RAM0) {
80590 - sys_chdir("/old");
80591 + sys_chdir((const char __force_user *)"/old");
80592 return;
80593 }
80594
80595 - sys_chdir("/");
80596 + sys_chdir((const char __force_user *)"/");
80597 ROOT_DEV = new_decode_dev(real_root_dev);
80598 mount_root();
80599
80600 printk(KERN_NOTICE "Trying to move old root to /initrd ... ");
80601 - error = sys_mount("/old", "/root/initrd", NULL, MS_MOVE, NULL);
80602 + error = sys_mount((char __force_user *)"/old", (char __force_user *)"/root/initrd", NULL, MS_MOVE, NULL);
80603 if (!error)
80604 printk("okay\n");
80605 else {
80606 - int fd = sys_open("/dev/root.old", O_RDWR, 0);
80607 + int fd = sys_open((const char __force_user *)"/dev/root.old", O_RDWR, 0);
80608 if (error == -ENOENT)
80609 printk("/initrd does not exist. Ignored.\n");
80610 else
80611 printk("failed\n");
80612 printk(KERN_NOTICE "Unmounting old root\n");
80613 - sys_umount("/old", MNT_DETACH);
80614 + sys_umount((char __force_user *)"/old", MNT_DETACH);
80615 printk(KERN_NOTICE "Trying to free ramdisk memory ... ");
80616 if (fd < 0) {
80617 error = fd;
80618 @@ -127,11 +127,11 @@ int __init initrd_load(void)
80619 * mounted in the normal path.
80620 */
80621 if (rd_load_image("/initrd.image") && ROOT_DEV != Root_RAM0) {
80622 - sys_unlink("/initrd.image");
80623 + sys_unlink((const char __force_user *)"/initrd.image");
80624 handle_initrd();
80625 return 1;
80626 }
80627 }
80628 - sys_unlink("/initrd.image");
80629 + sys_unlink((const char __force_user *)"/initrd.image");
80630 return 0;
80631 }
80632 diff --git a/init/do_mounts_md.c b/init/do_mounts_md.c
80633 index 8cb6db5..d729f50 100644
80634 --- a/init/do_mounts_md.c
80635 +++ b/init/do_mounts_md.c
80636 @@ -180,7 +180,7 @@ static void __init md_setup_drive(void)
80637 partitioned ? "_d" : "", minor,
80638 md_setup_args[ent].device_names);
80639
80640 - fd = sys_open(name, 0, 0);
80641 + fd = sys_open((char __force_user *)name, 0, 0);
80642 if (fd < 0) {
80643 printk(KERN_ERR "md: open failed - cannot start "
80644 "array %s\n", name);
80645 @@ -243,7 +243,7 @@ static void __init md_setup_drive(void)
80646 * array without it
80647 */
80648 sys_close(fd);
80649 - fd = sys_open(name, 0, 0);
80650 + fd = sys_open((char __force_user *)name, 0, 0);
80651 sys_ioctl(fd, BLKRRPART, 0);
80652 }
80653 sys_close(fd);
80654 @@ -293,7 +293,7 @@ static void __init autodetect_raid(void)
80655
80656 wait_for_device_probe();
80657
80658 - fd = sys_open("/dev/md0", 0, 0);
80659 + fd = sys_open((const char __force_user *) "/dev/md0", 0, 0);
80660 if (fd >= 0) {
80661 sys_ioctl(fd, RAID_AUTORUN, raid_autopart);
80662 sys_close(fd);
80663 diff --git a/init/init_task.c b/init/init_task.c
80664 index ba0a7f36..2bcf1d5 100644
80665 --- a/init/init_task.c
80666 +++ b/init/init_task.c
80667 @@ -22,5 +22,9 @@ EXPORT_SYMBOL(init_task);
80668 * Initial thread structure. Alignment of this is handled by a special
80669 * linker map entry.
80670 */
80671 +#ifdef CONFIG_X86
80672 +union thread_union init_thread_union __init_task_data;
80673 +#else
80674 union thread_union init_thread_union __init_task_data =
80675 { INIT_THREAD_INFO(init_task) };
80676 +#endif
80677 diff --git a/init/initramfs.c b/init/initramfs.c
80678 index a67ef9d..2d17ed9 100644
80679 --- a/init/initramfs.c
80680 +++ b/init/initramfs.c
80681 @@ -84,7 +84,7 @@ static void __init free_hash(void)
80682 }
80683 }
80684
80685 -static long __init do_utime(char *filename, time_t mtime)
80686 +static long __init do_utime(char __force_user *filename, time_t mtime)
80687 {
80688 struct timespec t[2];
80689
80690 @@ -119,7 +119,7 @@ static void __init dir_utime(void)
80691 struct dir_entry *de, *tmp;
80692 list_for_each_entry_safe(de, tmp, &dir_list, list) {
80693 list_del(&de->list);
80694 - do_utime(de->name, de->mtime);
80695 + do_utime((char __force_user *)de->name, de->mtime);
80696 kfree(de->name);
80697 kfree(de);
80698 }
80699 @@ -281,7 +281,7 @@ static int __init maybe_link(void)
80700 if (nlink >= 2) {
80701 char *old = find_link(major, minor, ino, mode, collected);
80702 if (old)
80703 - return (sys_link(old, collected) < 0) ? -1 : 1;
80704 + return (sys_link((char __force_user *)old, (char __force_user *)collected) < 0) ? -1 : 1;
80705 }
80706 return 0;
80707 }
80708 @@ -290,11 +290,11 @@ static void __init clean_path(char *path, umode_t mode)
80709 {
80710 struct stat st;
80711
80712 - if (!sys_newlstat(path, &st) && (st.st_mode^mode) & S_IFMT) {
80713 + if (!sys_newlstat((char __force_user *)path, (struct stat __force_user *)&st) && (st.st_mode^mode) & S_IFMT) {
80714 if (S_ISDIR(st.st_mode))
80715 - sys_rmdir(path);
80716 + sys_rmdir((char __force_user *)path);
80717 else
80718 - sys_unlink(path);
80719 + sys_unlink((char __force_user *)path);
80720 }
80721 }
80722
80723 @@ -315,7 +315,7 @@ static int __init do_name(void)
80724 int openflags = O_WRONLY|O_CREAT;
80725 if (ml != 1)
80726 openflags |= O_TRUNC;
80727 - wfd = sys_open(collected, openflags, mode);
80728 + wfd = sys_open((char __force_user *)collected, openflags, mode);
80729
80730 if (wfd >= 0) {
80731 sys_fchown(wfd, uid, gid);
80732 @@ -327,17 +327,17 @@ static int __init do_name(void)
80733 }
80734 }
80735 } else if (S_ISDIR(mode)) {
80736 - sys_mkdir(collected, mode);
80737 - sys_chown(collected, uid, gid);
80738 - sys_chmod(collected, mode);
80739 + sys_mkdir((char __force_user *)collected, mode);
80740 + sys_chown((char __force_user *)collected, uid, gid);
80741 + sys_chmod((char __force_user *)collected, mode);
80742 dir_add(collected, mtime);
80743 } else if (S_ISBLK(mode) || S_ISCHR(mode) ||
80744 S_ISFIFO(mode) || S_ISSOCK(mode)) {
80745 if (maybe_link() == 0) {
80746 - sys_mknod(collected, mode, rdev);
80747 - sys_chown(collected, uid, gid);
80748 - sys_chmod(collected, mode);
80749 - do_utime(collected, mtime);
80750 + sys_mknod((char __force_user *)collected, mode, rdev);
80751 + sys_chown((char __force_user *)collected, uid, gid);
80752 + sys_chmod((char __force_user *)collected, mode);
80753 + do_utime((char __force_user *)collected, mtime);
80754 }
80755 }
80756 return 0;
80757 @@ -346,15 +346,15 @@ static int __init do_name(void)
80758 static int __init do_copy(void)
80759 {
80760 if (count >= body_len) {
80761 - sys_write(wfd, victim, body_len);
80762 + sys_write(wfd, (char __force_user *)victim, body_len);
80763 sys_close(wfd);
80764 - do_utime(vcollected, mtime);
80765 + do_utime((char __force_user *)vcollected, mtime);
80766 kfree(vcollected);
80767 eat(body_len);
80768 state = SkipIt;
80769 return 0;
80770 } else {
80771 - sys_write(wfd, victim, count);
80772 + sys_write(wfd, (char __force_user *)victim, count);
80773 body_len -= count;
80774 eat(count);
80775 return 1;
80776 @@ -365,9 +365,9 @@ static int __init do_symlink(void)
80777 {
80778 collected[N_ALIGN(name_len) + body_len] = '\0';
80779 clean_path(collected, 0);
80780 - sys_symlink(collected + N_ALIGN(name_len), collected);
80781 - sys_lchown(collected, uid, gid);
80782 - do_utime(collected, mtime);
80783 + sys_symlink((char __force_user *)collected + N_ALIGN(name_len), (char __force_user *)collected);
80784 + sys_lchown((char __force_user *)collected, uid, gid);
80785 + do_utime((char __force_user *)collected, mtime);
80786 state = SkipIt;
80787 next_state = Reset;
80788 return 0;
80789 @@ -583,7 +583,7 @@ static int __init populate_rootfs(void)
80790 {
80791 char *err = unpack_to_rootfs(__initramfs_start, __initramfs_size);
80792 if (err)
80793 - panic(err); /* Failed to decompress INTERNAL initramfs */
80794 + panic("%s", err); /* Failed to decompress INTERNAL initramfs */
80795 if (initrd_start) {
80796 #ifdef CONFIG_BLK_DEV_RAM
80797 int fd;
80798 diff --git a/init/main.c b/init/main.c
80799 index 63d3e8f..50bd5f8 100644
80800 --- a/init/main.c
80801 +++ b/init/main.c
80802 @@ -103,6 +103,8 @@ static inline void mark_rodata_ro(void) { }
80803 extern void tc_init(void);
80804 #endif
80805
80806 +extern void grsecurity_init(void);
80807 +
80808 /*
80809 * Debug helper: via this flag we know that we are in 'early bootup code'
80810 * where only the boot processor is running with IRQ disabled. This means
80811 @@ -156,6 +158,75 @@ static int __init set_reset_devices(char *str)
80812
80813 __setup("reset_devices", set_reset_devices);
80814
80815 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
80816 +kgid_t grsec_proc_gid = KGIDT_INIT(CONFIG_GRKERNSEC_PROC_GID);
80817 +static int __init setup_grsec_proc_gid(char *str)
80818 +{
80819 + grsec_proc_gid = KGIDT_INIT(simple_strtol(str, NULL, 0));
80820 + return 1;
80821 +}
80822 +__setup("grsec_proc_gid=", setup_grsec_proc_gid);
80823 +#endif
80824 +
80825 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
80826 +unsigned long pax_user_shadow_base __read_only;
80827 +EXPORT_SYMBOL(pax_user_shadow_base);
80828 +extern char pax_enter_kernel_user[];
80829 +extern char pax_exit_kernel_user[];
80830 +#endif
80831 +
80832 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_MEMORY_UDEREF)
80833 +static int __init setup_pax_nouderef(char *str)
80834 +{
80835 +#ifdef CONFIG_X86_32
80836 + unsigned int cpu;
80837 + struct desc_struct *gdt;
80838 +
80839 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
80840 + gdt = get_cpu_gdt_table(cpu);
80841 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
80842 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
80843 + gdt[GDT_ENTRY_DEFAULT_USER_CS].limit = 0xf;
80844 + gdt[GDT_ENTRY_DEFAULT_USER_DS].limit = 0xf;
80845 + }
80846 + loadsegment(ds, __KERNEL_DS);
80847 + loadsegment(es, __KERNEL_DS);
80848 + loadsegment(ss, __KERNEL_DS);
80849 +#else
80850 + memcpy(pax_enter_kernel_user, (unsigned char []){0xc3}, 1);
80851 + memcpy(pax_exit_kernel_user, (unsigned char []){0xc3}, 1);
80852 + clone_pgd_mask = ~(pgdval_t)0UL;
80853 + pax_user_shadow_base = 0UL;
80854 + setup_clear_cpu_cap(X86_FEATURE_PCID);
80855 + setup_clear_cpu_cap(X86_FEATURE_INVPCID);
80856 +#endif
80857 +
80858 + return 0;
80859 +}
80860 +early_param("pax_nouderef", setup_pax_nouderef);
80861 +
80862 +#ifdef CONFIG_X86_64
80863 +static int __init setup_pax_weakuderef(char *str)
80864 +{
80865 + if (clone_pgd_mask != ~(pgdval_t)0UL)
80866 + pax_user_shadow_base = 1UL << TASK_SIZE_MAX_SHIFT;
80867 + return 1;
80868 +}
80869 +__setup("pax_weakuderef", setup_pax_weakuderef);
80870 +#endif
80871 +#endif
80872 +
80873 +#ifdef CONFIG_PAX_SOFTMODE
80874 +int pax_softmode;
80875 +
80876 +static int __init setup_pax_softmode(char *str)
80877 +{
80878 + get_option(&str, &pax_softmode);
80879 + return 1;
80880 +}
80881 +__setup("pax_softmode=", setup_pax_softmode);
80882 +#endif
80883 +
80884 static const char * argv_init[MAX_INIT_ARGS+2] = { "init", NULL, };
80885 const char * envp_init[MAX_INIT_ENVS+2] = { "HOME=/", "TERM=linux", NULL, };
80886 static const char *panic_later, *panic_param;
80887 @@ -682,25 +753,24 @@ int __init_or_module do_one_initcall(initcall_t fn)
80888 {
80889 int count = preempt_count();
80890 int ret;
80891 - char msgbuf[64];
80892 + const char *msg1 = "", *msg2 = "";
80893
80894 if (initcall_debug)
80895 ret = do_one_initcall_debug(fn);
80896 else
80897 ret = fn();
80898
80899 - msgbuf[0] = 0;
80900 -
80901 if (preempt_count() != count) {
80902 - sprintf(msgbuf, "preemption imbalance ");
80903 + msg1 = " preemption imbalance";
80904 preempt_count() = count;
80905 }
80906 if (irqs_disabled()) {
80907 - strlcat(msgbuf, "disabled interrupts ", sizeof(msgbuf));
80908 + msg2 = " disabled interrupts";
80909 local_irq_enable();
80910 }
80911 - WARN(msgbuf[0], "initcall %pF returned with %s\n", fn, msgbuf);
80912 + WARN(*msg1 || *msg2, "initcall %pF returned with%s%s\n", fn, msg1, msg2);
80913
80914 + add_latent_entropy();
80915 return ret;
80916 }
80917
80918 @@ -807,10 +877,14 @@ static int run_init_process(const char *init_filename)
80919 {
80920 argv_init[0] = init_filename;
80921 return do_execve(init_filename,
80922 - (const char __user *const __user *)argv_init,
80923 - (const char __user *const __user *)envp_init);
80924 + (const char __user *const __force_user *)argv_init,
80925 + (const char __user *const __force_user *)envp_init);
80926 }
80927
80928 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
80929 +extern int gr_init_ran;
80930 +#endif
80931 +
80932 static noinline void __init kernel_init_freeable(void);
80933
80934 static int __ref kernel_init(void *unused)
80935 @@ -831,6 +905,11 @@ static int __ref kernel_init(void *unused)
80936 pr_err("Failed to execute %s\n", ramdisk_execute_command);
80937 }
80938
80939 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
80940 + /* if no initrd was used, be extra sure we enforce chroot restrictions */
80941 + gr_init_ran = 1;
80942 +#endif
80943 +
80944 /*
80945 * We try each of these until one succeeds.
80946 *
80947 @@ -885,7 +964,7 @@ static noinline void __init kernel_init_freeable(void)
80948 do_basic_setup();
80949
80950 /* Open the /dev/console on the rootfs, this should never fail */
80951 - if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)
80952 + if (sys_open((const char __force_user *) "/dev/console", O_RDWR, 0) < 0)
80953 pr_err("Warning: unable to open an initial console.\n");
80954
80955 (void) sys_dup(0);
80956 @@ -898,11 +977,13 @@ static noinline void __init kernel_init_freeable(void)
80957 if (!ramdisk_execute_command)
80958 ramdisk_execute_command = "/init";
80959
80960 - if (sys_access((const char __user *) ramdisk_execute_command, 0) != 0) {
80961 + if (sys_access((const char __force_user *) ramdisk_execute_command, 0) != 0) {
80962 ramdisk_execute_command = NULL;
80963 prepare_namespace();
80964 }
80965
80966 + grsecurity_init();
80967 +
80968 /*
80969 * Ok, we have completed the initial bootup, and
80970 * we're essentially up and running. Get rid of the
80971 diff --git a/ipc/ipc_sysctl.c b/ipc/ipc_sysctl.c
80972 index b0e99de..09f385c 100644
80973 --- a/ipc/ipc_sysctl.c
80974 +++ b/ipc/ipc_sysctl.c
80975 @@ -30,7 +30,7 @@ static void *get_ipc(ctl_table *table)
80976 static int proc_ipc_dointvec(ctl_table *table, int write,
80977 void __user *buffer, size_t *lenp, loff_t *ppos)
80978 {
80979 - struct ctl_table ipc_table;
80980 + ctl_table_no_const ipc_table;
80981
80982 memcpy(&ipc_table, table, sizeof(ipc_table));
80983 ipc_table.data = get_ipc(table);
80984 @@ -41,7 +41,7 @@ static int proc_ipc_dointvec(ctl_table *table, int write,
80985 static int proc_ipc_dointvec_minmax(ctl_table *table, int write,
80986 void __user *buffer, size_t *lenp, loff_t *ppos)
80987 {
80988 - struct ctl_table ipc_table;
80989 + ctl_table_no_const ipc_table;
80990
80991 memcpy(&ipc_table, table, sizeof(ipc_table));
80992 ipc_table.data = get_ipc(table);
80993 @@ -65,7 +65,7 @@ static int proc_ipc_dointvec_minmax_orphans(ctl_table *table, int write,
80994 static int proc_ipc_callback_dointvec_minmax(ctl_table *table, int write,
80995 void __user *buffer, size_t *lenp, loff_t *ppos)
80996 {
80997 - struct ctl_table ipc_table;
80998 + ctl_table_no_const ipc_table;
80999 size_t lenp_bef = *lenp;
81000 int rc;
81001
81002 @@ -88,7 +88,7 @@ static int proc_ipc_callback_dointvec_minmax(ctl_table *table, int write,
81003 static int proc_ipc_doulongvec_minmax(ctl_table *table, int write,
81004 void __user *buffer, size_t *lenp, loff_t *ppos)
81005 {
81006 - struct ctl_table ipc_table;
81007 + ctl_table_no_const ipc_table;
81008 memcpy(&ipc_table, table, sizeof(ipc_table));
81009 ipc_table.data = get_ipc(table);
81010
81011 @@ -122,7 +122,7 @@ static void ipc_auto_callback(int val)
81012 static int proc_ipcauto_dointvec_minmax(ctl_table *table, int write,
81013 void __user *buffer, size_t *lenp, loff_t *ppos)
81014 {
81015 - struct ctl_table ipc_table;
81016 + ctl_table_no_const ipc_table;
81017 size_t lenp_bef = *lenp;
81018 int oldval;
81019 int rc;
81020 diff --git a/ipc/mq_sysctl.c b/ipc/mq_sysctl.c
81021 index 383d638..943fdbb 100644
81022 --- a/ipc/mq_sysctl.c
81023 +++ b/ipc/mq_sysctl.c
81024 @@ -25,7 +25,7 @@ static void *get_mq(ctl_table *table)
81025 static int proc_mq_dointvec_minmax(ctl_table *table, int write,
81026 void __user *buffer, size_t *lenp, loff_t *ppos)
81027 {
81028 - struct ctl_table mq_table;
81029 + ctl_table_no_const mq_table;
81030 memcpy(&mq_table, table, sizeof(mq_table));
81031 mq_table.data = get_mq(table);
81032
81033 diff --git a/ipc/mqueue.c b/ipc/mqueue.c
81034 index ae1996d..a35f2cc 100644
81035 --- a/ipc/mqueue.c
81036 +++ b/ipc/mqueue.c
81037 @@ -278,6 +278,7 @@ static struct inode *mqueue_get_inode(struct super_block *sb,
81038 mq_bytes = mq_treesize + (info->attr.mq_maxmsg *
81039 info->attr.mq_msgsize);
81040
81041 + gr_learn_resource(current, RLIMIT_MSGQUEUE, u->mq_bytes + mq_bytes, 1);
81042 spin_lock(&mq_lock);
81043 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
81044 u->mq_bytes + mq_bytes > rlimit(RLIMIT_MSGQUEUE)) {
81045 diff --git a/ipc/msg.c b/ipc/msg.c
81046 index 558aa91..359e718 100644
81047 --- a/ipc/msg.c
81048 +++ b/ipc/msg.c
81049 @@ -297,18 +297,19 @@ static inline int msg_security(struct kern_ipc_perm *ipcp, int msgflg)
81050 return security_msg_queue_associate(msq, msgflg);
81051 }
81052
81053 +static struct ipc_ops msg_ops = {
81054 + .getnew = newque,
81055 + .associate = msg_security,
81056 + .more_checks = NULL
81057 +};
81058 +
81059 SYSCALL_DEFINE2(msgget, key_t, key, int, msgflg)
81060 {
81061 struct ipc_namespace *ns;
81062 - struct ipc_ops msg_ops;
81063 struct ipc_params msg_params;
81064
81065 ns = current->nsproxy->ipc_ns;
81066
81067 - msg_ops.getnew = newque;
81068 - msg_ops.associate = msg_security;
81069 - msg_ops.more_checks = NULL;
81070 -
81071 msg_params.key = key;
81072 msg_params.flg = msgflg;
81073
81074 diff --git a/ipc/sem.c b/ipc/sem.c
81075 index db9d241..bc8427c 100644
81076 --- a/ipc/sem.c
81077 +++ b/ipc/sem.c
81078 @@ -562,10 +562,15 @@ static inline int sem_more_checks(struct kern_ipc_perm *ipcp,
81079 return 0;
81080 }
81081
81082 +static struct ipc_ops sem_ops = {
81083 + .getnew = newary,
81084 + .associate = sem_security,
81085 + .more_checks = sem_more_checks
81086 +};
81087 +
81088 SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
81089 {
81090 struct ipc_namespace *ns;
81091 - struct ipc_ops sem_ops;
81092 struct ipc_params sem_params;
81093
81094 ns = current->nsproxy->ipc_ns;
81095 @@ -573,10 +578,6 @@ SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
81096 if (nsems < 0 || nsems > ns->sc_semmsl)
81097 return -EINVAL;
81098
81099 - sem_ops.getnew = newary;
81100 - sem_ops.associate = sem_security;
81101 - sem_ops.more_checks = sem_more_checks;
81102 -
81103 sem_params.key = key;
81104 sem_params.flg = semflg;
81105 sem_params.u.nsems = nsems;
81106 diff --git a/ipc/shm.c b/ipc/shm.c
81107 index 7a51443..3a257d8 100644
81108 --- a/ipc/shm.c
81109 +++ b/ipc/shm.c
81110 @@ -72,6 +72,14 @@ static void shm_destroy (struct ipc_namespace *ns, struct shmid_kernel *shp);
81111 static int sysvipc_shm_proc_show(struct seq_file *s, void *it);
81112 #endif
81113
81114 +#ifdef CONFIG_GRKERNSEC
81115 +extern int gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
81116 + const time_t shm_createtime, const kuid_t cuid,
81117 + const int shmid);
81118 +extern int gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
81119 + const time_t shm_createtime);
81120 +#endif
81121 +
81122 void shm_init_ns(struct ipc_namespace *ns)
81123 {
81124 ns->shm_ctlmax = SHMMAX;
81125 @@ -554,6 +562,14 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
81126 shp->shm_lprid = 0;
81127 shp->shm_atim = shp->shm_dtim = 0;
81128 shp->shm_ctim = get_seconds();
81129 +#ifdef CONFIG_GRKERNSEC
81130 + {
81131 + struct timespec timeval;
81132 + do_posix_clock_monotonic_gettime(&timeval);
81133 +
81134 + shp->shm_createtime = timeval.tv_sec;
81135 + }
81136 +#endif
81137 shp->shm_segsz = size;
81138 shp->shm_nattch = 0;
81139 shp->shm_file = file;
81140 @@ -607,18 +623,19 @@ static inline int shm_more_checks(struct kern_ipc_perm *ipcp,
81141 return 0;
81142 }
81143
81144 +static struct ipc_ops shm_ops = {
81145 + .getnew = newseg,
81146 + .associate = shm_security,
81147 + .more_checks = shm_more_checks
81148 +};
81149 +
81150 SYSCALL_DEFINE3(shmget, key_t, key, size_t, size, int, shmflg)
81151 {
81152 struct ipc_namespace *ns;
81153 - struct ipc_ops shm_ops;
81154 struct ipc_params shm_params;
81155
81156 ns = current->nsproxy->ipc_ns;
81157
81158 - shm_ops.getnew = newseg;
81159 - shm_ops.associate = shm_security;
81160 - shm_ops.more_checks = shm_more_checks;
81161 -
81162 shm_params.key = key;
81163 shm_params.flg = shmflg;
81164 shm_params.u.size = size;
81165 @@ -1089,6 +1106,12 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
81166 f_mode = FMODE_READ | FMODE_WRITE;
81167 }
81168 if (shmflg & SHM_EXEC) {
81169 +
81170 +#ifdef CONFIG_PAX_MPROTECT
81171 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
81172 + goto out;
81173 +#endif
81174 +
81175 prot |= PROT_EXEC;
81176 acc_mode |= S_IXUGO;
81177 }
81178 @@ -1113,6 +1136,15 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
81179 if (err)
81180 goto out_unlock;
81181
81182 +#ifdef CONFIG_GRKERNSEC
81183 + if (!gr_handle_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime,
81184 + shp->shm_perm.cuid, shmid) ||
81185 + !gr_chroot_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime)) {
81186 + err = -EACCES;
81187 + goto out_unlock;
81188 + }
81189 +#endif
81190 +
81191 ipc_lock_object(&shp->shm_perm);
81192
81193 /* check if shm_destroy() is tearing down shp */
81194 @@ -1125,6 +1157,9 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
81195 path = shp->shm_file->f_path;
81196 path_get(&path);
81197 shp->shm_nattch++;
81198 +#ifdef CONFIG_GRKERNSEC
81199 + shp->shm_lapid = current->pid;
81200 +#endif
81201 size = i_size_read(path.dentry->d_inode);
81202 ipc_unlock_object(&shp->shm_perm);
81203 rcu_read_unlock();
81204 diff --git a/ipc/util.c b/ipc/util.c
81205 index 7684f41..f7da711 100644
81206 --- a/ipc/util.c
81207 +++ b/ipc/util.c
81208 @@ -71,6 +71,8 @@ struct ipc_proc_iface {
81209 int (*show)(struct seq_file *, void *);
81210 };
81211
81212 +extern int gr_ipc_permitted(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp, int requested_mode, int granted_mode);
81213 +
81214 static void ipc_memory_notifier(struct work_struct *work)
81215 {
81216 ipcns_notify(IPCNS_MEMCHANGED);
81217 @@ -560,6 +562,9 @@ int ipcperms(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp, short flag)
81218 granted_mode >>= 6;
81219 else if (in_group_p(ipcp->cgid) || in_group_p(ipcp->gid))
81220 granted_mode >>= 3;
81221 + else if (!gr_ipc_permitted(ns, ipcp, requested_mode, granted_mode))
81222 + return -1;
81223 +
81224 /* is there some bit set in requested_mode but not in granted_mode? */
81225 if ((requested_mode & ~granted_mode & 0007) &&
81226 !ns_capable(ns->user_ns, CAP_IPC_OWNER))
81227 diff --git a/kernel/acct.c b/kernel/acct.c
81228 index 8d6e145..33e0b1e 100644
81229 --- a/kernel/acct.c
81230 +++ b/kernel/acct.c
81231 @@ -556,7 +556,7 @@ static void do_acct_process(struct bsd_acct_struct *acct,
81232 */
81233 flim = current->signal->rlim[RLIMIT_FSIZE].rlim_cur;
81234 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY;
81235 - file->f_op->write(file, (char *)&ac,
81236 + file->f_op->write(file, (char __force_user *)&ac,
81237 sizeof(acct_t), &file->f_pos);
81238 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = flim;
81239 set_fs(fs);
81240 diff --git a/kernel/audit.c b/kernel/audit.c
81241 index 7ddfd8a..49766eb 100644
81242 --- a/kernel/audit.c
81243 +++ b/kernel/audit.c
81244 @@ -118,7 +118,7 @@ u32 audit_sig_sid = 0;
81245 3) suppressed due to audit_rate_limit
81246 4) suppressed due to audit_backlog_limit
81247 */
81248 -static atomic_t audit_lost = ATOMIC_INIT(0);
81249 +static atomic_unchecked_t audit_lost = ATOMIC_INIT(0);
81250
81251 /* The netlink socket. */
81252 static struct sock *audit_sock;
81253 @@ -240,7 +240,7 @@ void audit_log_lost(const char *message)
81254 unsigned long now;
81255 int print;
81256
81257 - atomic_inc(&audit_lost);
81258 + atomic_inc_unchecked(&audit_lost);
81259
81260 print = (audit_failure == AUDIT_FAIL_PANIC || !audit_rate_limit);
81261
81262 @@ -259,7 +259,7 @@ void audit_log_lost(const char *message)
81263 printk(KERN_WARNING
81264 "audit: audit_lost=%d audit_rate_limit=%d "
81265 "audit_backlog_limit=%d\n",
81266 - atomic_read(&audit_lost),
81267 + atomic_read_unchecked(&audit_lost),
81268 audit_rate_limit,
81269 audit_backlog_limit);
81270 audit_panic(message);
81271 @@ -665,7 +665,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
81272 status_set.pid = audit_pid;
81273 status_set.rate_limit = audit_rate_limit;
81274 status_set.backlog_limit = audit_backlog_limit;
81275 - status_set.lost = atomic_read(&audit_lost);
81276 + status_set.lost = atomic_read_unchecked(&audit_lost);
81277 status_set.backlog = skb_queue_len(&audit_skb_queue);
81278 audit_send_reply(NETLINK_CB(skb).portid, seq, AUDIT_GET, 0, 0,
81279 &status_set, sizeof(status_set));
81280 @@ -1252,7 +1252,7 @@ void audit_log_n_hex(struct audit_buffer *ab, const unsigned char *buf,
81281 int i, avail, new_len;
81282 unsigned char *ptr;
81283 struct sk_buff *skb;
81284 - static const unsigned char *hex = "0123456789ABCDEF";
81285 + static const unsigned char hex[] = "0123456789ABCDEF";
81286
81287 if (!ab)
81288 return;
81289 diff --git a/kernel/auditsc.c b/kernel/auditsc.c
81290 index 9845cb3..3ec9369 100644
81291 --- a/kernel/auditsc.c
81292 +++ b/kernel/auditsc.c
81293 @@ -1962,7 +1962,7 @@ int auditsc_get_stamp(struct audit_context *ctx,
81294 }
81295
81296 /* global counter which is incremented every time something logs in */
81297 -static atomic_t session_id = ATOMIC_INIT(0);
81298 +static atomic_unchecked_t session_id = ATOMIC_INIT(0);
81299
81300 /**
81301 * audit_set_loginuid - set current task's audit_context loginuid
81302 @@ -1986,7 +1986,7 @@ int audit_set_loginuid(kuid_t loginuid)
81303 return -EPERM;
81304 #endif /* CONFIG_AUDIT_LOGINUID_IMMUTABLE */
81305
81306 - sessionid = atomic_inc_return(&session_id);
81307 + sessionid = atomic_inc_return_unchecked(&session_id);
81308 if (context && context->in_syscall) {
81309 struct audit_buffer *ab;
81310
81311 diff --git a/kernel/capability.c b/kernel/capability.c
81312 index 4e66bf9..cdccecf 100644
81313 --- a/kernel/capability.c
81314 +++ b/kernel/capability.c
81315 @@ -202,6 +202,9 @@ SYSCALL_DEFINE2(capget, cap_user_header_t, header, cap_user_data_t, dataptr)
81316 * before modification is attempted and the application
81317 * fails.
81318 */
81319 + if (tocopy > ARRAY_SIZE(kdata))
81320 + return -EFAULT;
81321 +
81322 if (copy_to_user(dataptr, kdata, tocopy
81323 * sizeof(struct __user_cap_data_struct))) {
81324 return -EFAULT;
81325 @@ -303,10 +306,11 @@ bool has_ns_capability(struct task_struct *t,
81326 int ret;
81327
81328 rcu_read_lock();
81329 - ret = security_capable(__task_cred(t), ns, cap);
81330 + ret = security_capable(__task_cred(t), ns, cap) == 0 &&
81331 + gr_task_is_capable(t, __task_cred(t), cap);
81332 rcu_read_unlock();
81333
81334 - return (ret == 0);
81335 + return ret;
81336 }
81337
81338 /**
81339 @@ -343,10 +347,10 @@ bool has_ns_capability_noaudit(struct task_struct *t,
81340 int ret;
81341
81342 rcu_read_lock();
81343 - ret = security_capable_noaudit(__task_cred(t), ns, cap);
81344 + ret = security_capable_noaudit(__task_cred(t), ns, cap) == 0 && gr_task_is_capable_nolog(t, cap);
81345 rcu_read_unlock();
81346
81347 - return (ret == 0);
81348 + return ret;
81349 }
81350
81351 /**
81352 @@ -384,7 +388,7 @@ bool ns_capable(struct user_namespace *ns, int cap)
81353 BUG();
81354 }
81355
81356 - if (security_capable(current_cred(), ns, cap) == 0) {
81357 + if (security_capable(current_cred(), ns, cap) == 0 && gr_is_capable(cap)) {
81358 current->flags |= PF_SUPERPRIV;
81359 return true;
81360 }
81361 @@ -392,6 +396,21 @@ bool ns_capable(struct user_namespace *ns, int cap)
81362 }
81363 EXPORT_SYMBOL(ns_capable);
81364
81365 +bool ns_capable_nolog(struct user_namespace *ns, int cap)
81366 +{
81367 + if (unlikely(!cap_valid(cap))) {
81368 + printk(KERN_CRIT "capable_nolog() called with invalid cap=%u\n", cap);
81369 + BUG();
81370 + }
81371 +
81372 + if (security_capable_noaudit(current_cred(), ns, cap) == 0 && gr_is_capable_nolog(cap)) {
81373 + current->flags |= PF_SUPERPRIV;
81374 + return true;
81375 + }
81376 + return false;
81377 +}
81378 +EXPORT_SYMBOL(ns_capable_nolog);
81379 +
81380 /**
81381 * file_ns_capable - Determine if the file's opener had a capability in effect
81382 * @file: The file we want to check
81383 @@ -432,6 +451,12 @@ bool capable(int cap)
81384 }
81385 EXPORT_SYMBOL(capable);
81386
81387 +bool capable_nolog(int cap)
81388 +{
81389 + return ns_capable_nolog(&init_user_ns, cap);
81390 +}
81391 +EXPORT_SYMBOL(capable_nolog);
81392 +
81393 /**
81394 * inode_capable - Check superior capability over inode
81395 * @inode: The inode in question
81396 @@ -453,3 +478,11 @@ bool inode_capable(const struct inode *inode, int cap)
81397 return ns_capable(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
81398 }
81399 EXPORT_SYMBOL(inode_capable);
81400 +
81401 +bool inode_capable_nolog(const struct inode *inode, int cap)
81402 +{
81403 + struct user_namespace *ns = current_user_ns();
81404 +
81405 + return ns_capable_nolog(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
81406 +}
81407 +EXPORT_SYMBOL(inode_capable_nolog);
81408 diff --git a/kernel/cgroup.c b/kernel/cgroup.c
81409 index 5c9127d..f871169 100644
81410 --- a/kernel/cgroup.c
81411 +++ b/kernel/cgroup.c
81412 @@ -5844,7 +5844,7 @@ static int cgroup_css_links_read(struct cgroup_subsys_state *css,
81413 struct css_set *cset = link->cset;
81414 struct task_struct *task;
81415 int count = 0;
81416 - seq_printf(seq, "css_set %p\n", cset);
81417 + seq_printf(seq, "css_set %pK\n", cset);
81418 list_for_each_entry(task, &cset->tasks, cg_list) {
81419 if (count++ > MAX_TASKS_SHOWN_PER_CSS) {
81420 seq_puts(seq, " ...\n");
81421 diff --git a/kernel/compat.c b/kernel/compat.c
81422 index 0a09e48..f44f3f0 100644
81423 --- a/kernel/compat.c
81424 +++ b/kernel/compat.c
81425 @@ -13,6 +13,7 @@
81426
81427 #include <linux/linkage.h>
81428 #include <linux/compat.h>
81429 +#include <linux/module.h>
81430 #include <linux/errno.h>
81431 #include <linux/time.h>
81432 #include <linux/signal.h>
81433 @@ -220,7 +221,7 @@ static long compat_nanosleep_restart(struct restart_block *restart)
81434 mm_segment_t oldfs;
81435 long ret;
81436
81437 - restart->nanosleep.rmtp = (struct timespec __user *) &rmt;
81438 + restart->nanosleep.rmtp = (struct timespec __force_user *) &rmt;
81439 oldfs = get_fs();
81440 set_fs(KERNEL_DS);
81441 ret = hrtimer_nanosleep_restart(restart);
81442 @@ -252,7 +253,7 @@ asmlinkage long compat_sys_nanosleep(struct compat_timespec __user *rqtp,
81443 oldfs = get_fs();
81444 set_fs(KERNEL_DS);
81445 ret = hrtimer_nanosleep(&tu,
81446 - rmtp ? (struct timespec __user *)&rmt : NULL,
81447 + rmtp ? (struct timespec __force_user *)&rmt : NULL,
81448 HRTIMER_MODE_REL, CLOCK_MONOTONIC);
81449 set_fs(oldfs);
81450
81451 @@ -361,7 +362,7 @@ asmlinkage long compat_sys_sigpending(compat_old_sigset_t __user *set)
81452 mm_segment_t old_fs = get_fs();
81453
81454 set_fs(KERNEL_DS);
81455 - ret = sys_sigpending((old_sigset_t __user *) &s);
81456 + ret = sys_sigpending((old_sigset_t __force_user *) &s);
81457 set_fs(old_fs);
81458 if (ret == 0)
81459 ret = put_user(s, set);
81460 @@ -451,7 +452,7 @@ asmlinkage long compat_sys_old_getrlimit(unsigned int resource,
81461 mm_segment_t old_fs = get_fs();
81462
81463 set_fs(KERNEL_DS);
81464 - ret = sys_old_getrlimit(resource, &r);
81465 + ret = sys_old_getrlimit(resource, (struct rlimit __force_user *)&r);
81466 set_fs(old_fs);
81467
81468 if (!ret) {
81469 @@ -533,8 +534,8 @@ COMPAT_SYSCALL_DEFINE4(wait4,
81470 set_fs (KERNEL_DS);
81471 ret = sys_wait4(pid,
81472 (stat_addr ?
81473 - (unsigned int __user *) &status : NULL),
81474 - options, (struct rusage __user *) &r);
81475 + (unsigned int __force_user *) &status : NULL),
81476 + options, (struct rusage __force_user *) &r);
81477 set_fs (old_fs);
81478
81479 if (ret > 0) {
81480 @@ -560,8 +561,8 @@ COMPAT_SYSCALL_DEFINE5(waitid,
81481 memset(&info, 0, sizeof(info));
81482
81483 set_fs(KERNEL_DS);
81484 - ret = sys_waitid(which, pid, (siginfo_t __user *)&info, options,
81485 - uru ? (struct rusage __user *)&ru : NULL);
81486 + ret = sys_waitid(which, pid, (siginfo_t __force_user *)&info, options,
81487 + uru ? (struct rusage __force_user *)&ru : NULL);
81488 set_fs(old_fs);
81489
81490 if ((ret < 0) || (info.si_signo == 0))
81491 @@ -695,8 +696,8 @@ long compat_sys_timer_settime(timer_t timer_id, int flags,
81492 oldfs = get_fs();
81493 set_fs(KERNEL_DS);
81494 err = sys_timer_settime(timer_id, flags,
81495 - (struct itimerspec __user *) &newts,
81496 - (struct itimerspec __user *) &oldts);
81497 + (struct itimerspec __force_user *) &newts,
81498 + (struct itimerspec __force_user *) &oldts);
81499 set_fs(oldfs);
81500 if (!err && old && put_compat_itimerspec(old, &oldts))
81501 return -EFAULT;
81502 @@ -713,7 +714,7 @@ long compat_sys_timer_gettime(timer_t timer_id,
81503 oldfs = get_fs();
81504 set_fs(KERNEL_DS);
81505 err = sys_timer_gettime(timer_id,
81506 - (struct itimerspec __user *) &ts);
81507 + (struct itimerspec __force_user *) &ts);
81508 set_fs(oldfs);
81509 if (!err && put_compat_itimerspec(setting, &ts))
81510 return -EFAULT;
81511 @@ -732,7 +733,7 @@ long compat_sys_clock_settime(clockid_t which_clock,
81512 oldfs = get_fs();
81513 set_fs(KERNEL_DS);
81514 err = sys_clock_settime(which_clock,
81515 - (struct timespec __user *) &ts);
81516 + (struct timespec __force_user *) &ts);
81517 set_fs(oldfs);
81518 return err;
81519 }
81520 @@ -747,7 +748,7 @@ long compat_sys_clock_gettime(clockid_t which_clock,
81521 oldfs = get_fs();
81522 set_fs(KERNEL_DS);
81523 err = sys_clock_gettime(which_clock,
81524 - (struct timespec __user *) &ts);
81525 + (struct timespec __force_user *) &ts);
81526 set_fs(oldfs);
81527 if (!err && put_compat_timespec(&ts, tp))
81528 return -EFAULT;
81529 @@ -767,7 +768,7 @@ long compat_sys_clock_adjtime(clockid_t which_clock,
81530
81531 oldfs = get_fs();
81532 set_fs(KERNEL_DS);
81533 - ret = sys_clock_adjtime(which_clock, (struct timex __user *) &txc);
81534 + ret = sys_clock_adjtime(which_clock, (struct timex __force_user *) &txc);
81535 set_fs(oldfs);
81536
81537 err = compat_put_timex(utp, &txc);
81538 @@ -787,7 +788,7 @@ long compat_sys_clock_getres(clockid_t which_clock,
81539 oldfs = get_fs();
81540 set_fs(KERNEL_DS);
81541 err = sys_clock_getres(which_clock,
81542 - (struct timespec __user *) &ts);
81543 + (struct timespec __force_user *) &ts);
81544 set_fs(oldfs);
81545 if (!err && tp && put_compat_timespec(&ts, tp))
81546 return -EFAULT;
81547 @@ -799,9 +800,9 @@ static long compat_clock_nanosleep_restart(struct restart_block *restart)
81548 long err;
81549 mm_segment_t oldfs;
81550 struct timespec tu;
81551 - struct compat_timespec *rmtp = restart->nanosleep.compat_rmtp;
81552 + struct compat_timespec __user *rmtp = restart->nanosleep.compat_rmtp;
81553
81554 - restart->nanosleep.rmtp = (struct timespec __user *) &tu;
81555 + restart->nanosleep.rmtp = (struct timespec __force_user *) &tu;
81556 oldfs = get_fs();
81557 set_fs(KERNEL_DS);
81558 err = clock_nanosleep_restart(restart);
81559 @@ -833,8 +834,8 @@ long compat_sys_clock_nanosleep(clockid_t which_clock, int flags,
81560 oldfs = get_fs();
81561 set_fs(KERNEL_DS);
81562 err = sys_clock_nanosleep(which_clock, flags,
81563 - (struct timespec __user *) &in,
81564 - (struct timespec __user *) &out);
81565 + (struct timespec __force_user *) &in,
81566 + (struct timespec __force_user *) &out);
81567 set_fs(oldfs);
81568
81569 if ((err == -ERESTART_RESTARTBLOCK) && rmtp &&
81570 diff --git a/kernel/configs.c b/kernel/configs.c
81571 index c18b1f1..b9a0132 100644
81572 --- a/kernel/configs.c
81573 +++ b/kernel/configs.c
81574 @@ -74,8 +74,19 @@ static int __init ikconfig_init(void)
81575 struct proc_dir_entry *entry;
81576
81577 /* create the current config file */
81578 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
81579 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_HIDESYM)
81580 + entry = proc_create("config.gz", S_IFREG | S_IRUSR, NULL,
81581 + &ikconfig_file_ops);
81582 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
81583 + entry = proc_create("config.gz", S_IFREG | S_IRUSR | S_IRGRP, NULL,
81584 + &ikconfig_file_ops);
81585 +#endif
81586 +#else
81587 entry = proc_create("config.gz", S_IFREG | S_IRUGO, NULL,
81588 &ikconfig_file_ops);
81589 +#endif
81590 +
81591 if (!entry)
81592 return -ENOMEM;
81593
81594 diff --git a/kernel/cred.c b/kernel/cred.c
81595 index e0573a4..3874e41 100644
81596 --- a/kernel/cred.c
81597 +++ b/kernel/cred.c
81598 @@ -164,6 +164,16 @@ void exit_creds(struct task_struct *tsk)
81599 validate_creds(cred);
81600 alter_cred_subscribers(cred, -1);
81601 put_cred(cred);
81602 +
81603 +#ifdef CONFIG_GRKERNSEC_SETXID
81604 + cred = (struct cred *) tsk->delayed_cred;
81605 + if (cred != NULL) {
81606 + tsk->delayed_cred = NULL;
81607 + validate_creds(cred);
81608 + alter_cred_subscribers(cred, -1);
81609 + put_cred(cred);
81610 + }
81611 +#endif
81612 }
81613
81614 /**
81615 @@ -411,7 +421,7 @@ static bool cred_cap_issubset(const struct cred *set, const struct cred *subset)
81616 * Always returns 0 thus allowing this function to be tail-called at the end
81617 * of, say, sys_setgid().
81618 */
81619 -int commit_creds(struct cred *new)
81620 +static int __commit_creds(struct cred *new)
81621 {
81622 struct task_struct *task = current;
81623 const struct cred *old = task->real_cred;
81624 @@ -430,6 +440,8 @@ int commit_creds(struct cred *new)
81625
81626 get_cred(new); /* we will require a ref for the subj creds too */
81627
81628 + gr_set_role_label(task, new->uid, new->gid);
81629 +
81630 /* dumpability changes */
81631 if (!uid_eq(old->euid, new->euid) ||
81632 !gid_eq(old->egid, new->egid) ||
81633 @@ -479,6 +491,102 @@ int commit_creds(struct cred *new)
81634 put_cred(old);
81635 return 0;
81636 }
81637 +#ifdef CONFIG_GRKERNSEC_SETXID
81638 +extern int set_user(struct cred *new);
81639 +
81640 +void gr_delayed_cred_worker(void)
81641 +{
81642 + const struct cred *new = current->delayed_cred;
81643 + struct cred *ncred;
81644 +
81645 + current->delayed_cred = NULL;
81646 +
81647 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID) && new != NULL) {
81648 + // from doing get_cred on it when queueing this
81649 + put_cred(new);
81650 + return;
81651 + } else if (new == NULL)
81652 + return;
81653 +
81654 + ncred = prepare_creds();
81655 + if (!ncred)
81656 + goto die;
81657 + // uids
81658 + ncred->uid = new->uid;
81659 + ncred->euid = new->euid;
81660 + ncred->suid = new->suid;
81661 + ncred->fsuid = new->fsuid;
81662 + // gids
81663 + ncred->gid = new->gid;
81664 + ncred->egid = new->egid;
81665 + ncred->sgid = new->sgid;
81666 + ncred->fsgid = new->fsgid;
81667 + // groups
81668 + if (set_groups(ncred, new->group_info) < 0) {
81669 + abort_creds(ncred);
81670 + goto die;
81671 + }
81672 + // caps
81673 + ncred->securebits = new->securebits;
81674 + ncred->cap_inheritable = new->cap_inheritable;
81675 + ncred->cap_permitted = new->cap_permitted;
81676 + ncred->cap_effective = new->cap_effective;
81677 + ncred->cap_bset = new->cap_bset;
81678 +
81679 + if (set_user(ncred)) {
81680 + abort_creds(ncred);
81681 + goto die;
81682 + }
81683 +
81684 + // from doing get_cred on it when queueing this
81685 + put_cred(new);
81686 +
81687 + __commit_creds(ncred);
81688 + return;
81689 +die:
81690 + // from doing get_cred on it when queueing this
81691 + put_cred(new);
81692 + do_group_exit(SIGKILL);
81693 +}
81694 +#endif
81695 +
81696 +int commit_creds(struct cred *new)
81697 +{
81698 +#ifdef CONFIG_GRKERNSEC_SETXID
81699 + int ret;
81700 + int schedule_it = 0;
81701 + struct task_struct *t;
81702 +
81703 + /* we won't get called with tasklist_lock held for writing
81704 + and interrupts disabled as the cred struct in that case is
81705 + init_cred
81706 + */
81707 + if (grsec_enable_setxid && !current_is_single_threaded() &&
81708 + uid_eq(current_uid(), GLOBAL_ROOT_UID) &&
81709 + !uid_eq(new->uid, GLOBAL_ROOT_UID)) {
81710 + schedule_it = 1;
81711 + }
81712 + ret = __commit_creds(new);
81713 + if (schedule_it) {
81714 + rcu_read_lock();
81715 + read_lock(&tasklist_lock);
81716 + for (t = next_thread(current); t != current;
81717 + t = next_thread(t)) {
81718 + if (t->delayed_cred == NULL) {
81719 + t->delayed_cred = get_cred(new);
81720 + set_tsk_thread_flag(t, TIF_GRSEC_SETXID);
81721 + set_tsk_need_resched(t);
81722 + }
81723 + }
81724 + read_unlock(&tasklist_lock);
81725 + rcu_read_unlock();
81726 + }
81727 + return ret;
81728 +#else
81729 + return __commit_creds(new);
81730 +#endif
81731 +}
81732 +
81733 EXPORT_SYMBOL(commit_creds);
81734
81735 /**
81736 diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c
81737 index 0506d44..2c20034 100644
81738 --- a/kernel/debug/debug_core.c
81739 +++ b/kernel/debug/debug_core.c
81740 @@ -123,7 +123,7 @@ static DEFINE_RAW_SPINLOCK(dbg_slave_lock);
81741 */
81742 static atomic_t masters_in_kgdb;
81743 static atomic_t slaves_in_kgdb;
81744 -static atomic_t kgdb_break_tasklet_var;
81745 +static atomic_unchecked_t kgdb_break_tasklet_var;
81746 atomic_t kgdb_setting_breakpoint;
81747
81748 struct task_struct *kgdb_usethread;
81749 @@ -133,7 +133,7 @@ int kgdb_single_step;
81750 static pid_t kgdb_sstep_pid;
81751
81752 /* to keep track of the CPU which is doing the single stepping*/
81753 -atomic_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
81754 +atomic_unchecked_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
81755
81756 /*
81757 * If you are debugging a problem where roundup (the collection of
81758 @@ -541,7 +541,7 @@ return_normal:
81759 * kernel will only try for the value of sstep_tries before
81760 * giving up and continuing on.
81761 */
81762 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1 &&
81763 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1 &&
81764 (kgdb_info[cpu].task &&
81765 kgdb_info[cpu].task->pid != kgdb_sstep_pid) && --sstep_tries) {
81766 atomic_set(&kgdb_active, -1);
81767 @@ -635,8 +635,8 @@ cpu_master_loop:
81768 }
81769
81770 kgdb_restore:
81771 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
81772 - int sstep_cpu = atomic_read(&kgdb_cpu_doing_single_step);
81773 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
81774 + int sstep_cpu = atomic_read_unchecked(&kgdb_cpu_doing_single_step);
81775 if (kgdb_info[sstep_cpu].task)
81776 kgdb_sstep_pid = kgdb_info[sstep_cpu].task->pid;
81777 else
81778 @@ -888,18 +888,18 @@ static void kgdb_unregister_callbacks(void)
81779 static void kgdb_tasklet_bpt(unsigned long ing)
81780 {
81781 kgdb_breakpoint();
81782 - atomic_set(&kgdb_break_tasklet_var, 0);
81783 + atomic_set_unchecked(&kgdb_break_tasklet_var, 0);
81784 }
81785
81786 static DECLARE_TASKLET(kgdb_tasklet_breakpoint, kgdb_tasklet_bpt, 0);
81787
81788 void kgdb_schedule_breakpoint(void)
81789 {
81790 - if (atomic_read(&kgdb_break_tasklet_var) ||
81791 + if (atomic_read_unchecked(&kgdb_break_tasklet_var) ||
81792 atomic_read(&kgdb_active) != -1 ||
81793 atomic_read(&kgdb_setting_breakpoint))
81794 return;
81795 - atomic_inc(&kgdb_break_tasklet_var);
81796 + atomic_inc_unchecked(&kgdb_break_tasklet_var);
81797 tasklet_schedule(&kgdb_tasklet_breakpoint);
81798 }
81799 EXPORT_SYMBOL_GPL(kgdb_schedule_breakpoint);
81800 diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
81801 index 00eb8f7..d7e3244 100644
81802 --- a/kernel/debug/kdb/kdb_main.c
81803 +++ b/kernel/debug/kdb/kdb_main.c
81804 @@ -1974,7 +1974,7 @@ static int kdb_lsmod(int argc, const char **argv)
81805 continue;
81806
81807 kdb_printf("%-20s%8u 0x%p ", mod->name,
81808 - mod->core_size, (void *)mod);
81809 + mod->core_size_rx + mod->core_size_rw, (void *)mod);
81810 #ifdef CONFIG_MODULE_UNLOAD
81811 kdb_printf("%4ld ", module_refcount(mod));
81812 #endif
81813 @@ -1984,7 +1984,7 @@ static int kdb_lsmod(int argc, const char **argv)
81814 kdb_printf(" (Loading)");
81815 else
81816 kdb_printf(" (Live)");
81817 - kdb_printf(" 0x%p", mod->module_core);
81818 + kdb_printf(" 0x%p 0x%p", mod->module_core_rx, mod->module_core_rw);
81819
81820 #ifdef CONFIG_MODULE_UNLOAD
81821 {
81822 diff --git a/kernel/events/core.c b/kernel/events/core.c
81823 index 953c143..5646bb1 100644
81824 --- a/kernel/events/core.c
81825 +++ b/kernel/events/core.c
81826 @@ -157,8 +157,15 @@ static struct srcu_struct pmus_srcu;
81827 * 0 - disallow raw tracepoint access for unpriv
81828 * 1 - disallow cpu events for unpriv
81829 * 2 - disallow kernel profiling for unpriv
81830 + * 3 - disallow all unpriv perf event use
81831 */
81832 -int sysctl_perf_event_paranoid __read_mostly = 1;
81833 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
81834 +int sysctl_perf_event_legitimately_concerned __read_mostly = 3;
81835 +#elif defined(CONFIG_GRKERNSEC_HIDESYM)
81836 +int sysctl_perf_event_legitimately_concerned __read_mostly = 2;
81837 +#else
81838 +int sysctl_perf_event_legitimately_concerned __read_mostly = 1;
81839 +#endif
81840
81841 /* Minimum for 512 kiB + 1 user control page */
81842 int sysctl_perf_event_mlock __read_mostly = 512 + (PAGE_SIZE / 1024); /* 'free' kiB per user */
81843 @@ -271,7 +278,7 @@ void perf_sample_event_took(u64 sample_len_ns)
81844 update_perf_cpu_limits();
81845 }
81846
81847 -static atomic64_t perf_event_id;
81848 +static atomic64_unchecked_t perf_event_id;
81849
81850 static void cpu_ctx_sched_out(struct perf_cpu_context *cpuctx,
81851 enum event_type_t event_type);
81852 @@ -2940,7 +2947,7 @@ static void __perf_event_read(void *info)
81853
81854 static inline u64 perf_event_count(struct perf_event *event)
81855 {
81856 - return local64_read(&event->count) + atomic64_read(&event->child_count);
81857 + return local64_read(&event->count) + atomic64_read_unchecked(&event->child_count);
81858 }
81859
81860 static u64 perf_event_read(struct perf_event *event)
81861 @@ -3308,9 +3315,9 @@ u64 perf_event_read_value(struct perf_event *event, u64 *enabled, u64 *running)
81862 mutex_lock(&event->child_mutex);
81863 total += perf_event_read(event);
81864 *enabled += event->total_time_enabled +
81865 - atomic64_read(&event->child_total_time_enabled);
81866 + atomic64_read_unchecked(&event->child_total_time_enabled);
81867 *running += event->total_time_running +
81868 - atomic64_read(&event->child_total_time_running);
81869 + atomic64_read_unchecked(&event->child_total_time_running);
81870
81871 list_for_each_entry(child, &event->child_list, child_list) {
81872 total += perf_event_read(child);
81873 @@ -3725,10 +3732,10 @@ void perf_event_update_userpage(struct perf_event *event)
81874 userpg->offset -= local64_read(&event->hw.prev_count);
81875
81876 userpg->time_enabled = enabled +
81877 - atomic64_read(&event->child_total_time_enabled);
81878 + atomic64_read_unchecked(&event->child_total_time_enabled);
81879
81880 userpg->time_running = running +
81881 - atomic64_read(&event->child_total_time_running);
81882 + atomic64_read_unchecked(&event->child_total_time_running);
81883
81884 arch_perf_update_userpage(userpg, now);
81885
81886 @@ -4279,7 +4286,7 @@ perf_output_sample_ustack(struct perf_output_handle *handle, u64 dump_size,
81887
81888 /* Data. */
81889 sp = perf_user_stack_pointer(regs);
81890 - rem = __output_copy_user(handle, (void *) sp, dump_size);
81891 + rem = __output_copy_user(handle, (void __user *) sp, dump_size);
81892 dyn_size = dump_size - rem;
81893
81894 perf_output_skip(handle, rem);
81895 @@ -4370,11 +4377,11 @@ static void perf_output_read_one(struct perf_output_handle *handle,
81896 values[n++] = perf_event_count(event);
81897 if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) {
81898 values[n++] = enabled +
81899 - atomic64_read(&event->child_total_time_enabled);
81900 + atomic64_read_unchecked(&event->child_total_time_enabled);
81901 }
81902 if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) {
81903 values[n++] = running +
81904 - atomic64_read(&event->child_total_time_running);
81905 + atomic64_read_unchecked(&event->child_total_time_running);
81906 }
81907 if (read_format & PERF_FORMAT_ID)
81908 values[n++] = primary_event_id(event);
81909 @@ -5112,12 +5119,12 @@ static void perf_event_mmap_event(struct perf_mmap_event *mmap_event)
81910 * need to add enough zero bytes after the string to handle
81911 * the 64bit alignment we do later.
81912 */
81913 - buf = kzalloc(PATH_MAX + sizeof(u64), GFP_KERNEL);
81914 + buf = kzalloc(PATH_MAX, GFP_KERNEL);
81915 if (!buf) {
81916 name = strncpy(tmp, "//enomem", sizeof(tmp));
81917 goto got_name;
81918 }
81919 - name = d_path(&file->f_path, buf, PATH_MAX);
81920 + name = d_path(&file->f_path, buf, PATH_MAX - sizeof(u64));
81921 if (IS_ERR(name)) {
81922 name = strncpy(tmp, "//toolong", sizeof(tmp));
81923 goto got_name;
81924 @@ -6639,7 +6646,7 @@ perf_event_alloc(struct perf_event_attr *attr, int cpu,
81925 event->parent = parent_event;
81926
81927 event->ns = get_pid_ns(task_active_pid_ns(current));
81928 - event->id = atomic64_inc_return(&perf_event_id);
81929 + event->id = atomic64_inc_return_unchecked(&perf_event_id);
81930
81931 event->state = PERF_EVENT_STATE_INACTIVE;
81932
81933 @@ -6938,6 +6945,11 @@ SYSCALL_DEFINE5(perf_event_open,
81934 if (flags & ~PERF_FLAG_ALL)
81935 return -EINVAL;
81936
81937 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
81938 + if (perf_paranoid_any() && !capable(CAP_SYS_ADMIN))
81939 + return -EACCES;
81940 +#endif
81941 +
81942 err = perf_copy_attr(attr_uptr, &attr);
81943 if (err)
81944 return err;
81945 @@ -7271,10 +7283,10 @@ static void sync_child_event(struct perf_event *child_event,
81946 /*
81947 * Add back the child's count to the parent's count:
81948 */
81949 - atomic64_add(child_val, &parent_event->child_count);
81950 - atomic64_add(child_event->total_time_enabled,
81951 + atomic64_add_unchecked(child_val, &parent_event->child_count);
81952 + atomic64_add_unchecked(child_event->total_time_enabled,
81953 &parent_event->child_total_time_enabled);
81954 - atomic64_add(child_event->total_time_running,
81955 + atomic64_add_unchecked(child_event->total_time_running,
81956 &parent_event->child_total_time_running);
81957
81958 /*
81959 diff --git a/kernel/events/internal.h b/kernel/events/internal.h
81960 index ca65997..60df03d 100644
81961 --- a/kernel/events/internal.h
81962 +++ b/kernel/events/internal.h
81963 @@ -81,10 +81,10 @@ static inline unsigned long perf_data_size(struct ring_buffer *rb)
81964 return rb->nr_pages << (PAGE_SHIFT + page_order(rb));
81965 }
81966
81967 -#define DEFINE_OUTPUT_COPY(func_name, memcpy_func) \
81968 -static inline unsigned int \
81969 +#define DEFINE_OUTPUT_COPY(func_name, memcpy_func, user) \
81970 +static inline unsigned long \
81971 func_name(struct perf_output_handle *handle, \
81972 - const void *buf, unsigned int len) \
81973 + const void user *buf, unsigned long len) \
81974 { \
81975 unsigned long size, written; \
81976 \
81977 @@ -116,17 +116,17 @@ static inline int memcpy_common(void *dst, const void *src, size_t n)
81978 return n;
81979 }
81980
81981 -DEFINE_OUTPUT_COPY(__output_copy, memcpy_common)
81982 +DEFINE_OUTPUT_COPY(__output_copy, memcpy_common, )
81983
81984 #define MEMCPY_SKIP(dst, src, n) (n)
81985
81986 -DEFINE_OUTPUT_COPY(__output_skip, MEMCPY_SKIP)
81987 +DEFINE_OUTPUT_COPY(__output_skip, MEMCPY_SKIP, )
81988
81989 #ifndef arch_perf_out_copy_user
81990 #define arch_perf_out_copy_user __copy_from_user_inatomic
81991 #endif
81992
81993 -DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user)
81994 +DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user, __user)
81995
81996 /* Callchain handling */
81997 extern struct perf_callchain_entry *
81998 diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
81999 index ad8e1bd..fed7ba9 100644
82000 --- a/kernel/events/uprobes.c
82001 +++ b/kernel/events/uprobes.c
82002 @@ -1556,7 +1556,7 @@ static int is_trap_at_addr(struct mm_struct *mm, unsigned long vaddr)
82003 {
82004 struct page *page;
82005 uprobe_opcode_t opcode;
82006 - int result;
82007 + long result;
82008
82009 pagefault_disable();
82010 result = __copy_from_user_inatomic(&opcode, (void __user*)vaddr,
82011 diff --git a/kernel/exit.c b/kernel/exit.c
82012 index a949819..a5f127d 100644
82013 --- a/kernel/exit.c
82014 +++ b/kernel/exit.c
82015 @@ -172,6 +172,10 @@ void release_task(struct task_struct * p)
82016 struct task_struct *leader;
82017 int zap_leader;
82018 repeat:
82019 +#ifdef CONFIG_NET
82020 + gr_del_task_from_ip_table(p);
82021 +#endif
82022 +
82023 /* don't need to get the RCU readlock here - the process is dead and
82024 * can't be modifying its own credentials. But shut RCU-lockdep up */
82025 rcu_read_lock();
82026 @@ -329,7 +333,7 @@ int allow_signal(int sig)
82027 * know it'll be handled, so that they don't get converted to
82028 * SIGKILL or just silently dropped.
82029 */
82030 - current->sighand->action[(sig)-1].sa.sa_handler = (void __user *)2;
82031 + current->sighand->action[(sig)-1].sa.sa_handler = (__force void __user *)2;
82032 recalc_sigpending();
82033 spin_unlock_irq(&current->sighand->siglock);
82034 return 0;
82035 @@ -698,6 +702,8 @@ void do_exit(long code)
82036 struct task_struct *tsk = current;
82037 int group_dead;
82038
82039 + set_fs(USER_DS);
82040 +
82041 profile_task_exit(tsk);
82042
82043 WARN_ON(blk_needs_flush_plug(tsk));
82044 @@ -714,7 +720,6 @@ void do_exit(long code)
82045 * mm_release()->clear_child_tid() from writing to a user-controlled
82046 * kernel address.
82047 */
82048 - set_fs(USER_DS);
82049
82050 ptrace_event(PTRACE_EVENT_EXIT, code);
82051
82052 @@ -773,6 +778,9 @@ void do_exit(long code)
82053 tsk->exit_code = code;
82054 taskstats_exit(tsk, group_dead);
82055
82056 + gr_acl_handle_psacct(tsk, code);
82057 + gr_acl_handle_exit();
82058 +
82059 exit_mm(tsk);
82060
82061 if (group_dead)
82062 @@ -894,7 +902,7 @@ SYSCALL_DEFINE1(exit, int, error_code)
82063 * Take down every thread in the group. This is called by fatal signals
82064 * as well as by sys_exit_group (below).
82065 */
82066 -void
82067 +__noreturn void
82068 do_group_exit(int exit_code)
82069 {
82070 struct signal_struct *sig = current->signal;
82071 diff --git a/kernel/fork.c b/kernel/fork.c
82072 index 086fe73..72c1122 100644
82073 --- a/kernel/fork.c
82074 +++ b/kernel/fork.c
82075 @@ -319,7 +319,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
82076 *stackend = STACK_END_MAGIC; /* for overflow detection */
82077
82078 #ifdef CONFIG_CC_STACKPROTECTOR
82079 - tsk->stack_canary = get_random_int();
82080 + tsk->stack_canary = pax_get_random_long();
82081 #endif
82082
82083 /*
82084 @@ -345,12 +345,80 @@ free_tsk:
82085 }
82086
82087 #ifdef CONFIG_MMU
82088 -static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
82089 +static struct vm_area_struct *dup_vma(struct mm_struct *mm, struct mm_struct *oldmm, struct vm_area_struct *mpnt)
82090 +{
82091 + struct vm_area_struct *tmp;
82092 + unsigned long charge;
82093 + struct file *file;
82094 + int retval;
82095 +
82096 + charge = 0;
82097 + if (mpnt->vm_flags & VM_ACCOUNT) {
82098 + unsigned long len = vma_pages(mpnt);
82099 +
82100 + if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
82101 + goto fail_nomem;
82102 + charge = len;
82103 + }
82104 + tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
82105 + if (!tmp)
82106 + goto fail_nomem;
82107 + *tmp = *mpnt;
82108 + tmp->vm_mm = mm;
82109 + INIT_LIST_HEAD(&tmp->anon_vma_chain);
82110 + retval = vma_dup_policy(mpnt, tmp);
82111 + if (retval)
82112 + goto fail_nomem_policy;
82113 + if (anon_vma_fork(tmp, mpnt))
82114 + goto fail_nomem_anon_vma_fork;
82115 + tmp->vm_flags &= ~VM_LOCKED;
82116 + tmp->vm_next = tmp->vm_prev = NULL;
82117 + tmp->vm_mirror = NULL;
82118 + file = tmp->vm_file;
82119 + if (file) {
82120 + struct inode *inode = file_inode(file);
82121 + struct address_space *mapping = file->f_mapping;
82122 +
82123 + get_file(file);
82124 + if (tmp->vm_flags & VM_DENYWRITE)
82125 + atomic_dec(&inode->i_writecount);
82126 + mutex_lock(&mapping->i_mmap_mutex);
82127 + if (tmp->vm_flags & VM_SHARED)
82128 + mapping->i_mmap_writable++;
82129 + flush_dcache_mmap_lock(mapping);
82130 + /* insert tmp into the share list, just after mpnt */
82131 + if (unlikely(tmp->vm_flags & VM_NONLINEAR))
82132 + vma_nonlinear_insert(tmp, &mapping->i_mmap_nonlinear);
82133 + else
82134 + vma_interval_tree_insert_after(tmp, mpnt, &mapping->i_mmap);
82135 + flush_dcache_mmap_unlock(mapping);
82136 + mutex_unlock(&mapping->i_mmap_mutex);
82137 + }
82138 +
82139 + /*
82140 + * Clear hugetlb-related page reserves for children. This only
82141 + * affects MAP_PRIVATE mappings. Faults generated by the child
82142 + * are not guaranteed to succeed, even if read-only
82143 + */
82144 + if (is_vm_hugetlb_page(tmp))
82145 + reset_vma_resv_huge_pages(tmp);
82146 +
82147 + return tmp;
82148 +
82149 +fail_nomem_anon_vma_fork:
82150 + mpol_put(vma_policy(tmp));
82151 +fail_nomem_policy:
82152 + kmem_cache_free(vm_area_cachep, tmp);
82153 +fail_nomem:
82154 + vm_unacct_memory(charge);
82155 + return NULL;
82156 +}
82157 +
82158 +static __latent_entropy int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
82159 {
82160 struct vm_area_struct *mpnt, *tmp, *prev, **pprev;
82161 struct rb_node **rb_link, *rb_parent;
82162 int retval;
82163 - unsigned long charge;
82164
82165 uprobe_start_dup_mmap();
82166 down_write(&oldmm->mmap_sem);
82167 @@ -379,55 +447,15 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
82168
82169 prev = NULL;
82170 for (mpnt = oldmm->mmap; mpnt; mpnt = mpnt->vm_next) {
82171 - struct file *file;
82172 -
82173 if (mpnt->vm_flags & VM_DONTCOPY) {
82174 vm_stat_account(mm, mpnt->vm_flags, mpnt->vm_file,
82175 -vma_pages(mpnt));
82176 continue;
82177 }
82178 - charge = 0;
82179 - if (mpnt->vm_flags & VM_ACCOUNT) {
82180 - unsigned long len = vma_pages(mpnt);
82181 -
82182 - if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
82183 - goto fail_nomem;
82184 - charge = len;
82185 - }
82186 - tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
82187 - if (!tmp)
82188 - goto fail_nomem;
82189 - *tmp = *mpnt;
82190 - INIT_LIST_HEAD(&tmp->anon_vma_chain);
82191 - retval = vma_dup_policy(mpnt, tmp);
82192 - if (retval)
82193 - goto fail_nomem_policy;
82194 - tmp->vm_mm = mm;
82195 - if (anon_vma_fork(tmp, mpnt))
82196 - goto fail_nomem_anon_vma_fork;
82197 - tmp->vm_flags &= ~VM_LOCKED;
82198 - tmp->vm_next = tmp->vm_prev = NULL;
82199 - file = tmp->vm_file;
82200 - if (file) {
82201 - struct inode *inode = file_inode(file);
82202 - struct address_space *mapping = file->f_mapping;
82203 -
82204 - get_file(file);
82205 - if (tmp->vm_flags & VM_DENYWRITE)
82206 - atomic_dec(&inode->i_writecount);
82207 - mutex_lock(&mapping->i_mmap_mutex);
82208 - if (tmp->vm_flags & VM_SHARED)
82209 - mapping->i_mmap_writable++;
82210 - flush_dcache_mmap_lock(mapping);
82211 - /* insert tmp into the share list, just after mpnt */
82212 - if (unlikely(tmp->vm_flags & VM_NONLINEAR))
82213 - vma_nonlinear_insert(tmp,
82214 - &mapping->i_mmap_nonlinear);
82215 - else
82216 - vma_interval_tree_insert_after(tmp, mpnt,
82217 - &mapping->i_mmap);
82218 - flush_dcache_mmap_unlock(mapping);
82219 - mutex_unlock(&mapping->i_mmap_mutex);
82220 + tmp = dup_vma(mm, oldmm, mpnt);
82221 + if (!tmp) {
82222 + retval = -ENOMEM;
82223 + goto out;
82224 }
82225
82226 /*
82227 @@ -459,6 +487,31 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
82228 if (retval)
82229 goto out;
82230 }
82231 +
82232 +#ifdef CONFIG_PAX_SEGMEXEC
82233 + if (oldmm->pax_flags & MF_PAX_SEGMEXEC) {
82234 + struct vm_area_struct *mpnt_m;
82235 +
82236 + for (mpnt = oldmm->mmap, mpnt_m = mm->mmap; mpnt; mpnt = mpnt->vm_next, mpnt_m = mpnt_m->vm_next) {
82237 + BUG_ON(!mpnt_m || mpnt_m->vm_mirror || mpnt->vm_mm != oldmm || mpnt_m->vm_mm != mm);
82238 +
82239 + if (!mpnt->vm_mirror)
82240 + continue;
82241 +
82242 + if (mpnt->vm_end <= SEGMEXEC_TASK_SIZE) {
82243 + BUG_ON(mpnt->vm_mirror->vm_mirror != mpnt);
82244 + mpnt->vm_mirror = mpnt_m;
82245 + } else {
82246 + BUG_ON(mpnt->vm_mirror->vm_mirror == mpnt || mpnt->vm_mirror->vm_mirror->vm_mm != mm);
82247 + mpnt_m->vm_mirror = mpnt->vm_mirror->vm_mirror;
82248 + mpnt_m->vm_mirror->vm_mirror = mpnt_m;
82249 + mpnt->vm_mirror->vm_mirror = mpnt;
82250 + }
82251 + }
82252 + BUG_ON(mpnt_m);
82253 + }
82254 +#endif
82255 +
82256 /* a new mm has just been created */
82257 arch_dup_mmap(oldmm, mm);
82258 retval = 0;
82259 @@ -468,14 +521,6 @@ out:
82260 up_write(&oldmm->mmap_sem);
82261 uprobe_end_dup_mmap();
82262 return retval;
82263 -fail_nomem_anon_vma_fork:
82264 - mpol_put(vma_policy(tmp));
82265 -fail_nomem_policy:
82266 - kmem_cache_free(vm_area_cachep, tmp);
82267 -fail_nomem:
82268 - retval = -ENOMEM;
82269 - vm_unacct_memory(charge);
82270 - goto out;
82271 }
82272
82273 static inline int mm_alloc_pgd(struct mm_struct *mm)
82274 @@ -688,8 +733,8 @@ struct mm_struct *mm_access(struct task_struct *task, unsigned int mode)
82275 return ERR_PTR(err);
82276
82277 mm = get_task_mm(task);
82278 - if (mm && mm != current->mm &&
82279 - !ptrace_may_access(task, mode)) {
82280 + if (mm && ((mm != current->mm && !ptrace_may_access(task, mode)) ||
82281 + (mode == PTRACE_MODE_ATTACH && (gr_handle_proc_ptrace(task) || gr_acl_handle_procpidmem(task))))) {
82282 mmput(mm);
82283 mm = ERR_PTR(-EACCES);
82284 }
82285 @@ -911,13 +956,20 @@ static int copy_fs(unsigned long clone_flags, struct task_struct *tsk)
82286 spin_unlock(&fs->lock);
82287 return -EAGAIN;
82288 }
82289 - fs->users++;
82290 + atomic_inc(&fs->users);
82291 spin_unlock(&fs->lock);
82292 return 0;
82293 }
82294 tsk->fs = copy_fs_struct(fs);
82295 if (!tsk->fs)
82296 return -ENOMEM;
82297 + /* Carry through gr_chroot_dentry and is_chrooted instead
82298 + of recomputing it here. Already copied when the task struct
82299 + is duplicated. This allows pivot_root to not be treated as
82300 + a chroot
82301 + */
82302 + //gr_set_chroot_entries(tsk, &tsk->fs->root);
82303 +
82304 return 0;
82305 }
82306
82307 @@ -1128,7 +1180,7 @@ init_task_pid(struct task_struct *task, enum pid_type type, struct pid *pid)
82308 * parts of the process environment (as per the clone
82309 * flags). The actual kick-off is left to the caller.
82310 */
82311 -static struct task_struct *copy_process(unsigned long clone_flags,
82312 +static __latent_entropy struct task_struct *copy_process(unsigned long clone_flags,
82313 unsigned long stack_start,
82314 unsigned long stack_size,
82315 int __user *child_tidptr,
82316 @@ -1200,6 +1252,9 @@ static struct task_struct *copy_process(unsigned long clone_flags,
82317 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
82318 #endif
82319 retval = -EAGAIN;
82320 +
82321 + gr_learn_resource(p, RLIMIT_NPROC, atomic_read(&p->real_cred->user->processes), 0);
82322 +
82323 if (atomic_read(&p->real_cred->user->processes) >=
82324 task_rlimit(p, RLIMIT_NPROC)) {
82325 if (p->real_cred->user != INIT_USER &&
82326 @@ -1449,6 +1504,11 @@ static struct task_struct *copy_process(unsigned long clone_flags,
82327 goto bad_fork_free_pid;
82328 }
82329
82330 + /* synchronizes with gr_set_acls()
82331 + we need to call this past the point of no return for fork()
82332 + */
82333 + gr_copy_label(p);
82334 +
82335 if (likely(p->pid)) {
82336 ptrace_init_task(p, (clone_flags & CLONE_PTRACE) || trace);
82337
82338 @@ -1534,6 +1594,8 @@ bad_fork_cleanup_count:
82339 bad_fork_free:
82340 free_task(p);
82341 fork_out:
82342 + gr_log_forkfail(retval);
82343 +
82344 return ERR_PTR(retval);
82345 }
82346
82347 @@ -1595,6 +1657,7 @@ long do_fork(unsigned long clone_flags,
82348
82349 p = copy_process(clone_flags, stack_start, stack_size,
82350 child_tidptr, NULL, trace);
82351 + add_latent_entropy();
82352 /*
82353 * Do this prior waking up the new thread - the thread pointer
82354 * might get invalid after that point, if the thread exits quickly.
82355 @@ -1609,6 +1672,8 @@ long do_fork(unsigned long clone_flags,
82356 if (clone_flags & CLONE_PARENT_SETTID)
82357 put_user(nr, parent_tidptr);
82358
82359 + gr_handle_brute_check();
82360 +
82361 if (clone_flags & CLONE_VFORK) {
82362 p->vfork_done = &vfork;
82363 init_completion(&vfork);
82364 @@ -1725,7 +1790,7 @@ void __init proc_caches_init(void)
82365 mm_cachep = kmem_cache_create("mm_struct",
82366 sizeof(struct mm_struct), ARCH_MIN_MMSTRUCT_ALIGN,
82367 SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_NOTRACK, NULL);
82368 - vm_area_cachep = KMEM_CACHE(vm_area_struct, SLAB_PANIC);
82369 + vm_area_cachep = KMEM_CACHE(vm_area_struct, SLAB_PANIC | SLAB_NO_SANITIZE);
82370 mmap_init();
82371 nsproxy_cache_init();
82372 }
82373 @@ -1765,7 +1830,7 @@ static int unshare_fs(unsigned long unshare_flags, struct fs_struct **new_fsp)
82374 return 0;
82375
82376 /* don't need lock here; in the worst case we'll do useless copy */
82377 - if (fs->users == 1)
82378 + if (atomic_read(&fs->users) == 1)
82379 return 0;
82380
82381 *new_fsp = copy_fs_struct(fs);
82382 @@ -1872,7 +1937,8 @@ SYSCALL_DEFINE1(unshare, unsigned long, unshare_flags)
82383 fs = current->fs;
82384 spin_lock(&fs->lock);
82385 current->fs = new_fs;
82386 - if (--fs->users)
82387 + gr_set_chroot_entries(current, &current->fs->root);
82388 + if (atomic_dec_return(&fs->users))
82389 new_fs = NULL;
82390 else
82391 new_fs = fs;
82392 diff --git a/kernel/futex.c b/kernel/futex.c
82393 index 221a58f..1b8cfce 100644
82394 --- a/kernel/futex.c
82395 +++ b/kernel/futex.c
82396 @@ -54,6 +54,7 @@
82397 #include <linux/mount.h>
82398 #include <linux/pagemap.h>
82399 #include <linux/syscalls.h>
82400 +#include <linux/ptrace.h>
82401 #include <linux/signal.h>
82402 #include <linux/export.h>
82403 #include <linux/magic.h>
82404 @@ -243,6 +244,11 @@ get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key, int rw)
82405 struct page *page, *page_head;
82406 int err, ro = 0;
82407
82408 +#ifdef CONFIG_PAX_SEGMEXEC
82409 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && address >= SEGMEXEC_TASK_SIZE)
82410 + return -EFAULT;
82411 +#endif
82412 +
82413 /*
82414 * The futex address must be "naturally" aligned.
82415 */
82416 @@ -441,7 +447,7 @@ static int cmpxchg_futex_value_locked(u32 *curval, u32 __user *uaddr,
82417
82418 static int get_futex_value_locked(u32 *dest, u32 __user *from)
82419 {
82420 - int ret;
82421 + unsigned long ret;
82422
82423 pagefault_disable();
82424 ret = __copy_from_user_inatomic(dest, from, sizeof(u32));
82425 @@ -2734,6 +2740,7 @@ static int __init futex_init(void)
82426 {
82427 u32 curval;
82428 int i;
82429 + mm_segment_t oldfs;
82430
82431 /*
82432 * This will fail and we want it. Some arch implementations do
82433 @@ -2745,8 +2752,11 @@ static int __init futex_init(void)
82434 * implementation, the non-functional ones will return
82435 * -ENOSYS.
82436 */
82437 + oldfs = get_fs();
82438 + set_fs(USER_DS);
82439 if (cmpxchg_futex_value_locked(&curval, NULL, 0, 0) == -EFAULT)
82440 futex_cmpxchg_enabled = 1;
82441 + set_fs(oldfs);
82442
82443 for (i = 0; i < ARRAY_SIZE(futex_queues); i++) {
82444 plist_head_init(&futex_queues[i].chain);
82445 diff --git a/kernel/futex_compat.c b/kernel/futex_compat.c
82446 index f9f44fd..29885e4 100644
82447 --- a/kernel/futex_compat.c
82448 +++ b/kernel/futex_compat.c
82449 @@ -32,7 +32,7 @@ fetch_robust_entry(compat_uptr_t *uentry, struct robust_list __user **entry,
82450 return 0;
82451 }
82452
82453 -static void __user *futex_uaddr(struct robust_list __user *entry,
82454 +static void __user __intentional_overflow(-1) *futex_uaddr(struct robust_list __user *entry,
82455 compat_long_t futex_offset)
82456 {
82457 compat_uptr_t base = ptr_to_compat(entry);
82458 diff --git a/kernel/gcov/base.c b/kernel/gcov/base.c
82459 index 9b22d03..6295b62 100644
82460 --- a/kernel/gcov/base.c
82461 +++ b/kernel/gcov/base.c
82462 @@ -102,11 +102,6 @@ void gcov_enable_events(void)
82463 }
82464
82465 #ifdef CONFIG_MODULES
82466 -static inline int within(void *addr, void *start, unsigned long size)
82467 -{
82468 - return ((addr >= start) && (addr < start + size));
82469 -}
82470 -
82471 /* Update list and generate events when modules are unloaded. */
82472 static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
82473 void *data)
82474 @@ -121,7 +116,7 @@ static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
82475 prev = NULL;
82476 /* Remove entries located in module from linked list. */
82477 for (info = gcov_info_head; info; info = info->next) {
82478 - if (within(info, mod->module_core, mod->core_size)) {
82479 + if (within_module_core_rw((unsigned long)info, mod)) {
82480 if (prev)
82481 prev->next = info->next;
82482 else
82483 diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
82484 index 383319b..56ebb13 100644
82485 --- a/kernel/hrtimer.c
82486 +++ b/kernel/hrtimer.c
82487 @@ -1438,7 +1438,7 @@ void hrtimer_peek_ahead_timers(void)
82488 local_irq_restore(flags);
82489 }
82490
82491 -static void run_hrtimer_softirq(struct softirq_action *h)
82492 +static __latent_entropy void run_hrtimer_softirq(void)
82493 {
82494 hrtimer_peek_ahead_timers();
82495 }
82496 diff --git a/kernel/irq_work.c b/kernel/irq_work.c
82497 index 55fcce6..0e4cf34 100644
82498 --- a/kernel/irq_work.c
82499 +++ b/kernel/irq_work.c
82500 @@ -189,12 +189,13 @@ static int irq_work_cpu_notify(struct notifier_block *self,
82501 return NOTIFY_OK;
82502 }
82503
82504 -static struct notifier_block cpu_notify;
82505 +static struct notifier_block cpu_notify = {
82506 + .notifier_call = irq_work_cpu_notify,
82507 + .priority = 0,
82508 +};
82509
82510 static __init int irq_work_init_cpu_notifier(void)
82511 {
82512 - cpu_notify.notifier_call = irq_work_cpu_notify;
82513 - cpu_notify.priority = 0;
82514 register_cpu_notifier(&cpu_notify);
82515 return 0;
82516 }
82517 diff --git a/kernel/jump_label.c b/kernel/jump_label.c
82518 index 297a924..7290070 100644
82519 --- a/kernel/jump_label.c
82520 +++ b/kernel/jump_label.c
82521 @@ -14,6 +14,7 @@
82522 #include <linux/err.h>
82523 #include <linux/static_key.h>
82524 #include <linux/jump_label_ratelimit.h>
82525 +#include <linux/mm.h>
82526
82527 #ifdef HAVE_JUMP_LABEL
82528
82529 @@ -51,7 +52,9 @@ jump_label_sort_entries(struct jump_entry *start, struct jump_entry *stop)
82530
82531 size = (((unsigned long)stop - (unsigned long)start)
82532 / sizeof(struct jump_entry));
82533 + pax_open_kernel();
82534 sort(start, size, sizeof(struct jump_entry), jump_label_cmp, NULL);
82535 + pax_close_kernel();
82536 }
82537
82538 static void jump_label_update(struct static_key *key, int enable);
82539 @@ -358,10 +361,12 @@ static void jump_label_invalidate_module_init(struct module *mod)
82540 struct jump_entry *iter_stop = iter_start + mod->num_jump_entries;
82541 struct jump_entry *iter;
82542
82543 + pax_open_kernel();
82544 for (iter = iter_start; iter < iter_stop; iter++) {
82545 if (within_module_init(iter->code, mod))
82546 iter->code = 0;
82547 }
82548 + pax_close_kernel();
82549 }
82550
82551 static int
82552 diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
82553 index 3127ad5..159d880 100644
82554 --- a/kernel/kallsyms.c
82555 +++ b/kernel/kallsyms.c
82556 @@ -11,6 +11,9 @@
82557 * Changed the compression method from stem compression to "table lookup"
82558 * compression (see scripts/kallsyms.c for a more complete description)
82559 */
82560 +#ifdef CONFIG_GRKERNSEC_HIDESYM
82561 +#define __INCLUDED_BY_HIDESYM 1
82562 +#endif
82563 #include <linux/kallsyms.h>
82564 #include <linux/module.h>
82565 #include <linux/init.h>
82566 @@ -53,12 +56,33 @@ extern const unsigned long kallsyms_markers[] __attribute__((weak));
82567
82568 static inline int is_kernel_inittext(unsigned long addr)
82569 {
82570 + if (system_state != SYSTEM_BOOTING)
82571 + return 0;
82572 +
82573 if (addr >= (unsigned long)_sinittext
82574 && addr <= (unsigned long)_einittext)
82575 return 1;
82576 return 0;
82577 }
82578
82579 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
82580 +#ifdef CONFIG_MODULES
82581 +static inline int is_module_text(unsigned long addr)
82582 +{
82583 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END)
82584 + return 1;
82585 +
82586 + addr = ktla_ktva(addr);
82587 + return (unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END;
82588 +}
82589 +#else
82590 +static inline int is_module_text(unsigned long addr)
82591 +{
82592 + return 0;
82593 +}
82594 +#endif
82595 +#endif
82596 +
82597 static inline int is_kernel_text(unsigned long addr)
82598 {
82599 if ((addr >= (unsigned long)_stext && addr <= (unsigned long)_etext) ||
82600 @@ -69,13 +93,28 @@ static inline int is_kernel_text(unsigned long addr)
82601
82602 static inline int is_kernel(unsigned long addr)
82603 {
82604 +
82605 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
82606 + if (is_kernel_text(addr) || is_kernel_inittext(addr))
82607 + return 1;
82608 +
82609 + if (ktla_ktva((unsigned long)_text) <= addr && addr < (unsigned long)_end)
82610 +#else
82611 if (addr >= (unsigned long)_stext && addr <= (unsigned long)_end)
82612 +#endif
82613 +
82614 return 1;
82615 return in_gate_area_no_mm(addr);
82616 }
82617
82618 static int is_ksym_addr(unsigned long addr)
82619 {
82620 +
82621 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
82622 + if (is_module_text(addr))
82623 + return 0;
82624 +#endif
82625 +
82626 if (all_var)
82627 return is_kernel(addr);
82628
82629 @@ -480,7 +519,6 @@ static unsigned long get_ksymbol_core(struct kallsym_iter *iter)
82630
82631 static void reset_iter(struct kallsym_iter *iter, loff_t new_pos)
82632 {
82633 - iter->name[0] = '\0';
82634 iter->nameoff = get_symbol_offset(new_pos);
82635 iter->pos = new_pos;
82636 }
82637 @@ -528,6 +566,11 @@ static int s_show(struct seq_file *m, void *p)
82638 {
82639 struct kallsym_iter *iter = m->private;
82640
82641 +#ifdef CONFIG_GRKERNSEC_HIDESYM
82642 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID))
82643 + return 0;
82644 +#endif
82645 +
82646 /* Some debugging symbols have no name. Ignore them. */
82647 if (!iter->name[0])
82648 return 0;
82649 @@ -541,6 +584,7 @@ static int s_show(struct seq_file *m, void *p)
82650 */
82651 type = iter->exported ? toupper(iter->type) :
82652 tolower(iter->type);
82653 +
82654 seq_printf(m, "%pK %c %s\t[%s]\n", (void *)iter->value,
82655 type, iter->name, iter->module_name);
82656 } else
82657 @@ -566,7 +610,7 @@ static int kallsyms_open(struct inode *inode, struct file *file)
82658 struct kallsym_iter *iter;
82659 int ret;
82660
82661 - iter = kmalloc(sizeof(*iter), GFP_KERNEL);
82662 + iter = kzalloc(sizeof(*iter), GFP_KERNEL);
82663 if (!iter)
82664 return -ENOMEM;
82665 reset_iter(iter, 0);
82666 diff --git a/kernel/kcmp.c b/kernel/kcmp.c
82667 index e30ac0f..3528cac 100644
82668 --- a/kernel/kcmp.c
82669 +++ b/kernel/kcmp.c
82670 @@ -99,6 +99,10 @@ SYSCALL_DEFINE5(kcmp, pid_t, pid1, pid_t, pid2, int, type,
82671 struct task_struct *task1, *task2;
82672 int ret;
82673
82674 +#ifdef CONFIG_GRKERNSEC
82675 + return -ENOSYS;
82676 +#endif
82677 +
82678 rcu_read_lock();
82679
82680 /*
82681 diff --git a/kernel/kexec.c b/kernel/kexec.c
82682 index ecd783d..9aa270c 100644
82683 --- a/kernel/kexec.c
82684 +++ b/kernel/kexec.c
82685 @@ -1044,7 +1044,8 @@ asmlinkage long compat_sys_kexec_load(unsigned long entry,
82686 unsigned long flags)
82687 {
82688 struct compat_kexec_segment in;
82689 - struct kexec_segment out, __user *ksegments;
82690 + struct kexec_segment out;
82691 + struct kexec_segment __user *ksegments;
82692 unsigned long i, result;
82693
82694 /* Don't allow clients that don't understand the native
82695 diff --git a/kernel/kmod.c b/kernel/kmod.c
82696 index b086006..6d2e579 100644
82697 --- a/kernel/kmod.c
82698 +++ b/kernel/kmod.c
82699 @@ -75,7 +75,7 @@ static void free_modprobe_argv(struct subprocess_info *info)
82700 kfree(info->argv);
82701 }
82702
82703 -static int call_modprobe(char *module_name, int wait)
82704 +static int call_modprobe(char *module_name, char *module_param, int wait)
82705 {
82706 struct subprocess_info *info;
82707 static char *envp[] = {
82708 @@ -85,7 +85,7 @@ static int call_modprobe(char *module_name, int wait)
82709 NULL
82710 };
82711
82712 - char **argv = kmalloc(sizeof(char *[5]), GFP_KERNEL);
82713 + char **argv = kmalloc(sizeof(char *[6]), GFP_KERNEL);
82714 if (!argv)
82715 goto out;
82716
82717 @@ -97,7 +97,8 @@ static int call_modprobe(char *module_name, int wait)
82718 argv[1] = "-q";
82719 argv[2] = "--";
82720 argv[3] = module_name; /* check free_modprobe_argv() */
82721 - argv[4] = NULL;
82722 + argv[4] = module_param;
82723 + argv[5] = NULL;
82724
82725 info = call_usermodehelper_setup(modprobe_path, argv, envp, GFP_KERNEL,
82726 NULL, free_modprobe_argv, NULL);
82727 @@ -129,9 +130,8 @@ out:
82728 * If module auto-loading support is disabled then this function
82729 * becomes a no-operation.
82730 */
82731 -int __request_module(bool wait, const char *fmt, ...)
82732 +static int ____request_module(bool wait, char *module_param, const char *fmt, va_list ap)
82733 {
82734 - va_list args;
82735 char module_name[MODULE_NAME_LEN];
82736 unsigned int max_modprobes;
82737 int ret;
82738 @@ -150,9 +150,7 @@ int __request_module(bool wait, const char *fmt, ...)
82739 if (!modprobe_path[0])
82740 return 0;
82741
82742 - va_start(args, fmt);
82743 - ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, args);
82744 - va_end(args);
82745 + ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, ap);
82746 if (ret >= MODULE_NAME_LEN)
82747 return -ENAMETOOLONG;
82748
82749 @@ -160,6 +158,20 @@ int __request_module(bool wait, const char *fmt, ...)
82750 if (ret)
82751 return ret;
82752
82753 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
82754 + if (uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
82755 + /* hack to workaround consolekit/udisks stupidity */
82756 + read_lock(&tasklist_lock);
82757 + if (!strcmp(current->comm, "mount") &&
82758 + current->real_parent && !strncmp(current->real_parent->comm, "udisk", 5)) {
82759 + read_unlock(&tasklist_lock);
82760 + printk(KERN_ALERT "grsec: denied attempt to auto-load fs module %.64s by udisks\n", module_name);
82761 + return -EPERM;
82762 + }
82763 + read_unlock(&tasklist_lock);
82764 + }
82765 +#endif
82766 +
82767 /* If modprobe needs a service that is in a module, we get a recursive
82768 * loop. Limit the number of running kmod threads to max_threads/2 or
82769 * MAX_KMOD_CONCURRENT, whichever is the smaller. A cleaner method
82770 @@ -188,11 +200,52 @@ int __request_module(bool wait, const char *fmt, ...)
82771
82772 trace_module_request(module_name, wait, _RET_IP_);
82773
82774 - ret = call_modprobe(module_name, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
82775 + ret = call_modprobe(module_name, module_param, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
82776
82777 atomic_dec(&kmod_concurrent);
82778 return ret;
82779 }
82780 +
82781 +int ___request_module(bool wait, char *module_param, const char *fmt, ...)
82782 +{
82783 + va_list args;
82784 + int ret;
82785 +
82786 + va_start(args, fmt);
82787 + ret = ____request_module(wait, module_param, fmt, args);
82788 + va_end(args);
82789 +
82790 + return ret;
82791 +}
82792 +
82793 +int __request_module(bool wait, const char *fmt, ...)
82794 +{
82795 + va_list args;
82796 + int ret;
82797 +
82798 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
82799 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
82800 + char module_param[MODULE_NAME_LEN];
82801 +
82802 + memset(module_param, 0, sizeof(module_param));
82803 +
82804 + snprintf(module_param, sizeof(module_param) - 1, "grsec_modharden_normal%u_", GR_GLOBAL_UID(current_uid()));
82805 +
82806 + va_start(args, fmt);
82807 + ret = ____request_module(wait, module_param, fmt, args);
82808 + va_end(args);
82809 +
82810 + return ret;
82811 + }
82812 +#endif
82813 +
82814 + va_start(args, fmt);
82815 + ret = ____request_module(wait, NULL, fmt, args);
82816 + va_end(args);
82817 +
82818 + return ret;
82819 +}
82820 +
82821 EXPORT_SYMBOL(__request_module);
82822 #endif /* CONFIG_MODULES */
82823
82824 @@ -218,6 +271,19 @@ static int ____call_usermodehelper(void *data)
82825 */
82826 set_user_nice(current, 0);
82827
82828 +#ifdef CONFIG_GRKERNSEC
82829 + /* this is race-free as far as userland is concerned as we copied
82830 + out the path to be used prior to this point and are now operating
82831 + on that copy
82832 + */
82833 + if ((strncmp(sub_info->path, "/sbin/", 6) && strncmp(sub_info->path, "/usr/lib/", 9) &&
82834 + strncmp(sub_info->path, "/lib/", 5) && strncmp(sub_info->path, "/lib64/", 7)) || strstr(sub_info->path, "..")) {
82835 + printk(KERN_ALERT "grsec: denied exec of usermode helper binary %.950s located outside of /sbin and system library paths\n", sub_info->path);
82836 + retval = -EPERM;
82837 + goto fail;
82838 + }
82839 +#endif
82840 +
82841 retval = -ENOMEM;
82842 new = prepare_kernel_cred(current);
82843 if (!new)
82844 @@ -260,6 +326,10 @@ static int call_helper(void *data)
82845
82846 static void call_usermodehelper_freeinfo(struct subprocess_info *info)
82847 {
82848 +#ifdef CONFIG_GRKERNSEC
82849 + kfree(info->path);
82850 + info->path = info->origpath;
82851 +#endif
82852 if (info->cleanup)
82853 (*info->cleanup)(info);
82854 kfree(info);
82855 @@ -303,7 +373,7 @@ static int wait_for_helper(void *data)
82856 *
82857 * Thus the __user pointer cast is valid here.
82858 */
82859 - sys_wait4(pid, (int __user *)&ret, 0, NULL);
82860 + sys_wait4(pid, (int __force_user *)&ret, 0, NULL);
82861
82862 /*
82863 * If ret is 0, either ____call_usermodehelper failed and the
82864 @@ -542,7 +612,12 @@ struct subprocess_info *call_usermodehelper_setup(char *path, char **argv,
82865 goto out;
82866
82867 INIT_WORK(&sub_info->work, __call_usermodehelper);
82868 +#ifdef CONFIG_GRKERNSEC
82869 + sub_info->origpath = path;
82870 + sub_info->path = kstrdup(path, gfp_mask);
82871 +#else
82872 sub_info->path = path;
82873 +#endif
82874 sub_info->argv = argv;
82875 sub_info->envp = envp;
82876
82877 @@ -650,7 +725,7 @@ EXPORT_SYMBOL(call_usermodehelper);
82878 static int proc_cap_handler(struct ctl_table *table, int write,
82879 void __user *buffer, size_t *lenp, loff_t *ppos)
82880 {
82881 - struct ctl_table t;
82882 + ctl_table_no_const t;
82883 unsigned long cap_array[_KERNEL_CAPABILITY_U32S];
82884 kernel_cap_t new_cap;
82885 int err, i;
82886 diff --git a/kernel/kprobes.c b/kernel/kprobes.c
82887 index a0d367a..11c18b6 100644
82888 --- a/kernel/kprobes.c
82889 +++ b/kernel/kprobes.c
82890 @@ -31,6 +31,9 @@
82891 * <jkenisto@us.ibm.com> and Prasanna S Panchamukhi
82892 * <prasanna@in.ibm.com> added function-return probes.
82893 */
82894 +#ifdef CONFIG_GRKERNSEC_HIDESYM
82895 +#define __INCLUDED_BY_HIDESYM 1
82896 +#endif
82897 #include <linux/kprobes.h>
82898 #include <linux/hash.h>
82899 #include <linux/init.h>
82900 @@ -135,12 +138,12 @@ enum kprobe_slot_state {
82901
82902 static void *alloc_insn_page(void)
82903 {
82904 - return module_alloc(PAGE_SIZE);
82905 + return module_alloc_exec(PAGE_SIZE);
82906 }
82907
82908 static void free_insn_page(void *page)
82909 {
82910 - module_free(NULL, page);
82911 + module_free_exec(NULL, page);
82912 }
82913
82914 struct kprobe_insn_cache kprobe_insn_slots = {
82915 @@ -2066,7 +2069,7 @@ static int __init init_kprobes(void)
82916 {
82917 int i, err = 0;
82918 unsigned long offset = 0, size = 0;
82919 - char *modname, namebuf[128];
82920 + char *modname, namebuf[KSYM_NAME_LEN];
82921 const char *symbol_name;
82922 void *addr;
82923 struct kprobe_blackpoint *kb;
82924 @@ -2151,11 +2154,11 @@ static void __kprobes report_probe(struct seq_file *pi, struct kprobe *p,
82925 kprobe_type = "k";
82926
82927 if (sym)
82928 - seq_printf(pi, "%p %s %s+0x%x %s ",
82929 + seq_printf(pi, "%pK %s %s+0x%x %s ",
82930 p->addr, kprobe_type, sym, offset,
82931 (modname ? modname : " "));
82932 else
82933 - seq_printf(pi, "%p %s %p ",
82934 + seq_printf(pi, "%pK %s %pK ",
82935 p->addr, kprobe_type, p->addr);
82936
82937 if (!pp)
82938 @@ -2192,7 +2195,7 @@ static int __kprobes show_kprobe_addr(struct seq_file *pi, void *v)
82939 const char *sym = NULL;
82940 unsigned int i = *(loff_t *) v;
82941 unsigned long offset = 0;
82942 - char *modname, namebuf[128];
82943 + char *modname, namebuf[KSYM_NAME_LEN];
82944
82945 head = &kprobe_table[i];
82946 preempt_disable();
82947 diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c
82948 index 9659d38..bffd520 100644
82949 --- a/kernel/ksysfs.c
82950 +++ b/kernel/ksysfs.c
82951 @@ -46,6 +46,8 @@ static ssize_t uevent_helper_store(struct kobject *kobj,
82952 {
82953 if (count+1 > UEVENT_HELPER_PATH_LEN)
82954 return -ENOENT;
82955 + if (!capable(CAP_SYS_ADMIN))
82956 + return -EPERM;
82957 memcpy(uevent_helper, buf, count);
82958 uevent_helper[count] = '\0';
82959 if (count && uevent_helper[count-1] == '\n')
82960 @@ -172,7 +174,7 @@ static ssize_t notes_read(struct file *filp, struct kobject *kobj,
82961 return count;
82962 }
82963
82964 -static struct bin_attribute notes_attr = {
82965 +static bin_attribute_no_const notes_attr __read_only = {
82966 .attr = {
82967 .name = "notes",
82968 .mode = S_IRUGO,
82969 diff --git a/kernel/lockdep.c b/kernel/lockdep.c
82970 index e16c45b..6f49c48 100644
82971 --- a/kernel/lockdep.c
82972 +++ b/kernel/lockdep.c
82973 @@ -596,6 +596,10 @@ static int static_obj(void *obj)
82974 end = (unsigned long) &_end,
82975 addr = (unsigned long) obj;
82976
82977 +#ifdef CONFIG_PAX_KERNEXEC
82978 + start = ktla_ktva(start);
82979 +#endif
82980 +
82981 /*
82982 * static variable?
82983 */
82984 @@ -736,6 +740,7 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
82985 if (!static_obj(lock->key)) {
82986 debug_locks_off();
82987 printk("INFO: trying to register non-static key.\n");
82988 + printk("lock:%pS key:%pS.\n", lock, lock->key);
82989 printk("the code is fine but needs lockdep annotation.\n");
82990 printk("turning off the locking correctness validator.\n");
82991 dump_stack();
82992 @@ -3080,7 +3085,7 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,
82993 if (!class)
82994 return 0;
82995 }
82996 - atomic_inc((atomic_t *)&class->ops);
82997 + atomic_inc_unchecked((atomic_unchecked_t *)&class->ops);
82998 if (very_verbose(class)) {
82999 printk("\nacquire class [%p] %s", class->key, class->name);
83000 if (class->name_version > 1)
83001 diff --git a/kernel/lockdep_proc.c b/kernel/lockdep_proc.c
83002 index b2c71c5..7b88d63 100644
83003 --- a/kernel/lockdep_proc.c
83004 +++ b/kernel/lockdep_proc.c
83005 @@ -65,7 +65,7 @@ static int l_show(struct seq_file *m, void *v)
83006 return 0;
83007 }
83008
83009 - seq_printf(m, "%p", class->key);
83010 + seq_printf(m, "%pK", class->key);
83011 #ifdef CONFIG_DEBUG_LOCKDEP
83012 seq_printf(m, " OPS:%8ld", class->ops);
83013 #endif
83014 @@ -83,7 +83,7 @@ static int l_show(struct seq_file *m, void *v)
83015
83016 list_for_each_entry(entry, &class->locks_after, entry) {
83017 if (entry->distance == 1) {
83018 - seq_printf(m, " -> [%p] ", entry->class->key);
83019 + seq_printf(m, " -> [%pK] ", entry->class->key);
83020 print_name(m, entry->class);
83021 seq_puts(m, "\n");
83022 }
83023 @@ -152,7 +152,7 @@ static int lc_show(struct seq_file *m, void *v)
83024 if (!class->key)
83025 continue;
83026
83027 - seq_printf(m, "[%p] ", class->key);
83028 + seq_printf(m, "[%pK] ", class->key);
83029 print_name(m, class);
83030 seq_puts(m, "\n");
83031 }
83032 @@ -495,7 +495,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
83033 if (!i)
83034 seq_line(m, '-', 40-namelen, namelen);
83035
83036 - snprintf(ip, sizeof(ip), "[<%p>]",
83037 + snprintf(ip, sizeof(ip), "[<%pK>]",
83038 (void *)class->contention_point[i]);
83039 seq_printf(m, "%40s %14lu %29s %pS\n",
83040 name, stats->contention_point[i],
83041 @@ -510,7 +510,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
83042 if (!i)
83043 seq_line(m, '-', 40-namelen, namelen);
83044
83045 - snprintf(ip, sizeof(ip), "[<%p>]",
83046 + snprintf(ip, sizeof(ip), "[<%pK>]",
83047 (void *)class->contending_point[i]);
83048 seq_printf(m, "%40s %14lu %29s %pS\n",
83049 name, stats->contending_point[i],
83050 diff --git a/kernel/module.c b/kernel/module.c
83051 index dc58274..3ddfa55 100644
83052 --- a/kernel/module.c
83053 +++ b/kernel/module.c
83054 @@ -61,6 +61,7 @@
83055 #include <linux/pfn.h>
83056 #include <linux/bsearch.h>
83057 #include <linux/fips.h>
83058 +#include <linux/grsecurity.h>
83059 #include <uapi/linux/module.h>
83060 #include "module-internal.h"
83061
83062 @@ -157,7 +158,8 @@ static BLOCKING_NOTIFIER_HEAD(module_notify_list);
83063
83064 /* Bounds of module allocation, for speeding __module_address.
83065 * Protected by module_mutex. */
83066 -static unsigned long module_addr_min = -1UL, module_addr_max = 0;
83067 +static unsigned long module_addr_min_rw = -1UL, module_addr_max_rw = 0;
83068 +static unsigned long module_addr_min_rx = -1UL, module_addr_max_rx = 0;
83069
83070 int register_module_notifier(struct notifier_block * nb)
83071 {
83072 @@ -324,7 +326,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
83073 return true;
83074
83075 list_for_each_entry_rcu(mod, &modules, list) {
83076 - struct symsearch arr[] = {
83077 + struct symsearch modarr[] = {
83078 { mod->syms, mod->syms + mod->num_syms, mod->crcs,
83079 NOT_GPL_ONLY, false },
83080 { mod->gpl_syms, mod->gpl_syms + mod->num_gpl_syms,
83081 @@ -349,7 +351,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
83082 if (mod->state == MODULE_STATE_UNFORMED)
83083 continue;
83084
83085 - if (each_symbol_in_section(arr, ARRAY_SIZE(arr), mod, fn, data))
83086 + if (each_symbol_in_section(modarr, ARRAY_SIZE(modarr), mod, fn, data))
83087 return true;
83088 }
83089 return false;
83090 @@ -491,7 +493,7 @@ static int percpu_modalloc(struct module *mod, struct load_info *info)
83091 if (!pcpusec->sh_size)
83092 return 0;
83093
83094 - if (align > PAGE_SIZE) {
83095 + if (align-1 >= PAGE_SIZE) {
83096 printk(KERN_WARNING "%s: per-cpu alignment %li > %li\n",
83097 mod->name, align, PAGE_SIZE);
83098 align = PAGE_SIZE;
83099 @@ -1097,7 +1099,7 @@ struct module_attribute module_uevent =
83100 static ssize_t show_coresize(struct module_attribute *mattr,
83101 struct module_kobject *mk, char *buffer)
83102 {
83103 - return sprintf(buffer, "%u\n", mk->mod->core_size);
83104 + return sprintf(buffer, "%u\n", mk->mod->core_size_rx + mk->mod->core_size_rw);
83105 }
83106
83107 static struct module_attribute modinfo_coresize =
83108 @@ -1106,7 +1108,7 @@ static struct module_attribute modinfo_coresize =
83109 static ssize_t show_initsize(struct module_attribute *mattr,
83110 struct module_kobject *mk, char *buffer)
83111 {
83112 - return sprintf(buffer, "%u\n", mk->mod->init_size);
83113 + return sprintf(buffer, "%u\n", mk->mod->init_size_rx + mk->mod->init_size_rw);
83114 }
83115
83116 static struct module_attribute modinfo_initsize =
83117 @@ -1321,7 +1323,7 @@ resolve_symbol_wait(struct module *mod,
83118 */
83119 #ifdef CONFIG_SYSFS
83120
83121 -#ifdef CONFIG_KALLSYMS
83122 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
83123 static inline bool sect_empty(const Elf_Shdr *sect)
83124 {
83125 return !(sect->sh_flags & SHF_ALLOC) || sect->sh_size == 0;
83126 @@ -1461,7 +1463,7 @@ static void add_notes_attrs(struct module *mod, const struct load_info *info)
83127 {
83128 unsigned int notes, loaded, i;
83129 struct module_notes_attrs *notes_attrs;
83130 - struct bin_attribute *nattr;
83131 + bin_attribute_no_const *nattr;
83132
83133 /* failed to create section attributes, so can't create notes */
83134 if (!mod->sect_attrs)
83135 @@ -1573,7 +1575,7 @@ static void del_usage_links(struct module *mod)
83136 static int module_add_modinfo_attrs(struct module *mod)
83137 {
83138 struct module_attribute *attr;
83139 - struct module_attribute *temp_attr;
83140 + module_attribute_no_const *temp_attr;
83141 int error = 0;
83142 int i;
83143
83144 @@ -1795,21 +1797,21 @@ static void set_section_ro_nx(void *base,
83145
83146 static void unset_module_core_ro_nx(struct module *mod)
83147 {
83148 - set_page_attributes(mod->module_core + mod->core_text_size,
83149 - mod->module_core + mod->core_size,
83150 + set_page_attributes(mod->module_core_rw,
83151 + mod->module_core_rw + mod->core_size_rw,
83152 set_memory_x);
83153 - set_page_attributes(mod->module_core,
83154 - mod->module_core + mod->core_ro_size,
83155 + set_page_attributes(mod->module_core_rx,
83156 + mod->module_core_rx + mod->core_size_rx,
83157 set_memory_rw);
83158 }
83159
83160 static void unset_module_init_ro_nx(struct module *mod)
83161 {
83162 - set_page_attributes(mod->module_init + mod->init_text_size,
83163 - mod->module_init + mod->init_size,
83164 + set_page_attributes(mod->module_init_rw,
83165 + mod->module_init_rw + mod->init_size_rw,
83166 set_memory_x);
83167 - set_page_attributes(mod->module_init,
83168 - mod->module_init + mod->init_ro_size,
83169 + set_page_attributes(mod->module_init_rx,
83170 + mod->module_init_rx + mod->init_size_rx,
83171 set_memory_rw);
83172 }
83173
83174 @@ -1822,14 +1824,14 @@ void set_all_modules_text_rw(void)
83175 list_for_each_entry_rcu(mod, &modules, list) {
83176 if (mod->state == MODULE_STATE_UNFORMED)
83177 continue;
83178 - if ((mod->module_core) && (mod->core_text_size)) {
83179 - set_page_attributes(mod->module_core,
83180 - mod->module_core + mod->core_text_size,
83181 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
83182 + set_page_attributes(mod->module_core_rx,
83183 + mod->module_core_rx + mod->core_size_rx,
83184 set_memory_rw);
83185 }
83186 - if ((mod->module_init) && (mod->init_text_size)) {
83187 - set_page_attributes(mod->module_init,
83188 - mod->module_init + mod->init_text_size,
83189 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
83190 + set_page_attributes(mod->module_init_rx,
83191 + mod->module_init_rx + mod->init_size_rx,
83192 set_memory_rw);
83193 }
83194 }
83195 @@ -1845,14 +1847,14 @@ void set_all_modules_text_ro(void)
83196 list_for_each_entry_rcu(mod, &modules, list) {
83197 if (mod->state == MODULE_STATE_UNFORMED)
83198 continue;
83199 - if ((mod->module_core) && (mod->core_text_size)) {
83200 - set_page_attributes(mod->module_core,
83201 - mod->module_core + mod->core_text_size,
83202 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
83203 + set_page_attributes(mod->module_core_rx,
83204 + mod->module_core_rx + mod->core_size_rx,
83205 set_memory_ro);
83206 }
83207 - if ((mod->module_init) && (mod->init_text_size)) {
83208 - set_page_attributes(mod->module_init,
83209 - mod->module_init + mod->init_text_size,
83210 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
83211 + set_page_attributes(mod->module_init_rx,
83212 + mod->module_init_rx + mod->init_size_rx,
83213 set_memory_ro);
83214 }
83215 }
83216 @@ -1903,16 +1905,19 @@ static void free_module(struct module *mod)
83217
83218 /* This may be NULL, but that's OK */
83219 unset_module_init_ro_nx(mod);
83220 - module_free(mod, mod->module_init);
83221 + module_free(mod, mod->module_init_rw);
83222 + module_free_exec(mod, mod->module_init_rx);
83223 kfree(mod->args);
83224 percpu_modfree(mod);
83225
83226 /* Free lock-classes: */
83227 - lockdep_free_key_range(mod->module_core, mod->core_size);
83228 + lockdep_free_key_range(mod->module_core_rx, mod->core_size_rx);
83229 + lockdep_free_key_range(mod->module_core_rw, mod->core_size_rw);
83230
83231 /* Finally, free the core (containing the module structure) */
83232 unset_module_core_ro_nx(mod);
83233 - module_free(mod, mod->module_core);
83234 + module_free_exec(mod, mod->module_core_rx);
83235 + module_free(mod, mod->module_core_rw);
83236
83237 #ifdef CONFIG_MPU
83238 update_protections(current->mm);
83239 @@ -1982,9 +1987,31 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
83240 int ret = 0;
83241 const struct kernel_symbol *ksym;
83242
83243 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
83244 + int is_fs_load = 0;
83245 + int register_filesystem_found = 0;
83246 + char *p;
83247 +
83248 + p = strstr(mod->args, "grsec_modharden_fs");
83249 + if (p) {
83250 + char *endptr = p + sizeof("grsec_modharden_fs") - 1;
83251 + /* copy \0 as well */
83252 + memmove(p, endptr, strlen(mod->args) - (unsigned int)(endptr - mod->args) + 1);
83253 + is_fs_load = 1;
83254 + }
83255 +#endif
83256 +
83257 for (i = 1; i < symsec->sh_size / sizeof(Elf_Sym); i++) {
83258 const char *name = info->strtab + sym[i].st_name;
83259
83260 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
83261 + /* it's a real shame this will never get ripped and copied
83262 + upstream! ;(
83263 + */
83264 + if (is_fs_load && !strcmp(name, "register_filesystem"))
83265 + register_filesystem_found = 1;
83266 +#endif
83267 +
83268 switch (sym[i].st_shndx) {
83269 case SHN_COMMON:
83270 /* We compiled with -fno-common. These are not
83271 @@ -2005,7 +2032,9 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
83272 ksym = resolve_symbol_wait(mod, info, name);
83273 /* Ok if resolved. */
83274 if (ksym && !IS_ERR(ksym)) {
83275 + pax_open_kernel();
83276 sym[i].st_value = ksym->value;
83277 + pax_close_kernel();
83278 break;
83279 }
83280
83281 @@ -2024,11 +2053,20 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
83282 secbase = (unsigned long)mod_percpu(mod);
83283 else
83284 secbase = info->sechdrs[sym[i].st_shndx].sh_addr;
83285 + pax_open_kernel();
83286 sym[i].st_value += secbase;
83287 + pax_close_kernel();
83288 break;
83289 }
83290 }
83291
83292 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
83293 + if (is_fs_load && !register_filesystem_found) {
83294 + printk(KERN_ALERT "grsec: Denied attempt to load non-fs module %.64s through mount\n", mod->name);
83295 + ret = -EPERM;
83296 + }
83297 +#endif
83298 +
83299 return ret;
83300 }
83301
83302 @@ -2112,22 +2150,12 @@ static void layout_sections(struct module *mod, struct load_info *info)
83303 || s->sh_entsize != ~0UL
83304 || strstarts(sname, ".init"))
83305 continue;
83306 - s->sh_entsize = get_offset(mod, &mod->core_size, s, i);
83307 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
83308 + s->sh_entsize = get_offset(mod, &mod->core_size_rw, s, i);
83309 + else
83310 + s->sh_entsize = get_offset(mod, &mod->core_size_rx, s, i);
83311 pr_debug("\t%s\n", sname);
83312 }
83313 - switch (m) {
83314 - case 0: /* executable */
83315 - mod->core_size = debug_align(mod->core_size);
83316 - mod->core_text_size = mod->core_size;
83317 - break;
83318 - case 1: /* RO: text and ro-data */
83319 - mod->core_size = debug_align(mod->core_size);
83320 - mod->core_ro_size = mod->core_size;
83321 - break;
83322 - case 3: /* whole core */
83323 - mod->core_size = debug_align(mod->core_size);
83324 - break;
83325 - }
83326 }
83327
83328 pr_debug("Init section allocation order:\n");
83329 @@ -2141,23 +2169,13 @@ static void layout_sections(struct module *mod, struct load_info *info)
83330 || s->sh_entsize != ~0UL
83331 || !strstarts(sname, ".init"))
83332 continue;
83333 - s->sh_entsize = (get_offset(mod, &mod->init_size, s, i)
83334 - | INIT_OFFSET_MASK);
83335 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
83336 + s->sh_entsize = get_offset(mod, &mod->init_size_rw, s, i);
83337 + else
83338 + s->sh_entsize = get_offset(mod, &mod->init_size_rx, s, i);
83339 + s->sh_entsize |= INIT_OFFSET_MASK;
83340 pr_debug("\t%s\n", sname);
83341 }
83342 - switch (m) {
83343 - case 0: /* executable */
83344 - mod->init_size = debug_align(mod->init_size);
83345 - mod->init_text_size = mod->init_size;
83346 - break;
83347 - case 1: /* RO: text and ro-data */
83348 - mod->init_size = debug_align(mod->init_size);
83349 - mod->init_ro_size = mod->init_size;
83350 - break;
83351 - case 3: /* whole init */
83352 - mod->init_size = debug_align(mod->init_size);
83353 - break;
83354 - }
83355 }
83356 }
83357
83358 @@ -2330,7 +2348,7 @@ static void layout_symtab(struct module *mod, struct load_info *info)
83359
83360 /* Put symbol section at end of init part of module. */
83361 symsect->sh_flags |= SHF_ALLOC;
83362 - symsect->sh_entsize = get_offset(mod, &mod->init_size, symsect,
83363 + symsect->sh_entsize = get_offset(mod, &mod->init_size_rx, symsect,
83364 info->index.sym) | INIT_OFFSET_MASK;
83365 pr_debug("\t%s\n", info->secstrings + symsect->sh_name);
83366
83367 @@ -2347,13 +2365,13 @@ static void layout_symtab(struct module *mod, struct load_info *info)
83368 }
83369
83370 /* Append room for core symbols at end of core part. */
83371 - info->symoffs = ALIGN(mod->core_size, symsect->sh_addralign ?: 1);
83372 - info->stroffs = mod->core_size = info->symoffs + ndst * sizeof(Elf_Sym);
83373 - mod->core_size += strtab_size;
83374 + info->symoffs = ALIGN(mod->core_size_rx, symsect->sh_addralign ?: 1);
83375 + info->stroffs = mod->core_size_rx = info->symoffs + ndst * sizeof(Elf_Sym);
83376 + mod->core_size_rx += strtab_size;
83377
83378 /* Put string table section at end of init part of module. */
83379 strsect->sh_flags |= SHF_ALLOC;
83380 - strsect->sh_entsize = get_offset(mod, &mod->init_size, strsect,
83381 + strsect->sh_entsize = get_offset(mod, &mod->init_size_rx, strsect,
83382 info->index.str) | INIT_OFFSET_MASK;
83383 pr_debug("\t%s\n", info->secstrings + strsect->sh_name);
83384 }
83385 @@ -2371,12 +2389,14 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
83386 /* Make sure we get permanent strtab: don't use info->strtab. */
83387 mod->strtab = (void *)info->sechdrs[info->index.str].sh_addr;
83388
83389 + pax_open_kernel();
83390 +
83391 /* Set types up while we still have access to sections. */
83392 for (i = 0; i < mod->num_symtab; i++)
83393 mod->symtab[i].st_info = elf_type(&mod->symtab[i], info);
83394
83395 - mod->core_symtab = dst = mod->module_core + info->symoffs;
83396 - mod->core_strtab = s = mod->module_core + info->stroffs;
83397 + mod->core_symtab = dst = mod->module_core_rx + info->symoffs;
83398 + mod->core_strtab = s = mod->module_core_rx + info->stroffs;
83399 src = mod->symtab;
83400 for (ndst = i = 0; i < mod->num_symtab; i++) {
83401 if (i == 0 ||
83402 @@ -2388,6 +2408,8 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
83403 }
83404 }
83405 mod->core_num_syms = ndst;
83406 +
83407 + pax_close_kernel();
83408 }
83409 #else
83410 static inline void layout_symtab(struct module *mod, struct load_info *info)
83411 @@ -2421,17 +2443,33 @@ void * __weak module_alloc(unsigned long size)
83412 return vmalloc_exec(size);
83413 }
83414
83415 -static void *module_alloc_update_bounds(unsigned long size)
83416 +static void *module_alloc_update_bounds_rw(unsigned long size)
83417 {
83418 void *ret = module_alloc(size);
83419
83420 if (ret) {
83421 mutex_lock(&module_mutex);
83422 /* Update module bounds. */
83423 - if ((unsigned long)ret < module_addr_min)
83424 - module_addr_min = (unsigned long)ret;
83425 - if ((unsigned long)ret + size > module_addr_max)
83426 - module_addr_max = (unsigned long)ret + size;
83427 + if ((unsigned long)ret < module_addr_min_rw)
83428 + module_addr_min_rw = (unsigned long)ret;
83429 + if ((unsigned long)ret + size > module_addr_max_rw)
83430 + module_addr_max_rw = (unsigned long)ret + size;
83431 + mutex_unlock(&module_mutex);
83432 + }
83433 + return ret;
83434 +}
83435 +
83436 +static void *module_alloc_update_bounds_rx(unsigned long size)
83437 +{
83438 + void *ret = module_alloc_exec(size);
83439 +
83440 + if (ret) {
83441 + mutex_lock(&module_mutex);
83442 + /* Update module bounds. */
83443 + if ((unsigned long)ret < module_addr_min_rx)
83444 + module_addr_min_rx = (unsigned long)ret;
83445 + if ((unsigned long)ret + size > module_addr_max_rx)
83446 + module_addr_max_rx = (unsigned long)ret + size;
83447 mutex_unlock(&module_mutex);
83448 }
83449 return ret;
83450 @@ -2706,8 +2744,14 @@ static struct module *setup_load_info(struct load_info *info, int flags)
83451 static int check_modinfo(struct module *mod, struct load_info *info, int flags)
83452 {
83453 const char *modmagic = get_modinfo(info, "vermagic");
83454 + const char *license = get_modinfo(info, "license");
83455 int err;
83456
83457 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
83458 + if (!license || !license_is_gpl_compatible(license))
83459 + return -ENOEXEC;
83460 +#endif
83461 +
83462 if (flags & MODULE_INIT_IGNORE_VERMAGIC)
83463 modmagic = NULL;
83464
83465 @@ -2733,7 +2777,7 @@ static int check_modinfo(struct module *mod, struct load_info *info, int flags)
83466 }
83467
83468 /* Set up license info based on the info section */
83469 - set_license(mod, get_modinfo(info, "license"));
83470 + set_license(mod, license);
83471
83472 return 0;
83473 }
83474 @@ -2814,7 +2858,7 @@ static int move_module(struct module *mod, struct load_info *info)
83475 void *ptr;
83476
83477 /* Do the allocs. */
83478 - ptr = module_alloc_update_bounds(mod->core_size);
83479 + ptr = module_alloc_update_bounds_rw(mod->core_size_rw);
83480 /*
83481 * The pointer to this block is stored in the module structure
83482 * which is inside the block. Just mark it as not being a
83483 @@ -2824,11 +2868,11 @@ static int move_module(struct module *mod, struct load_info *info)
83484 if (!ptr)
83485 return -ENOMEM;
83486
83487 - memset(ptr, 0, mod->core_size);
83488 - mod->module_core = ptr;
83489 + memset(ptr, 0, mod->core_size_rw);
83490 + mod->module_core_rw = ptr;
83491
83492 - if (mod->init_size) {
83493 - ptr = module_alloc_update_bounds(mod->init_size);
83494 + if (mod->init_size_rw) {
83495 + ptr = module_alloc_update_bounds_rw(mod->init_size_rw);
83496 /*
83497 * The pointer to this block is stored in the module structure
83498 * which is inside the block. This block doesn't need to be
83499 @@ -2837,13 +2881,45 @@ static int move_module(struct module *mod, struct load_info *info)
83500 */
83501 kmemleak_ignore(ptr);
83502 if (!ptr) {
83503 - module_free(mod, mod->module_core);
83504 + module_free(mod, mod->module_core_rw);
83505 return -ENOMEM;
83506 }
83507 - memset(ptr, 0, mod->init_size);
83508 - mod->module_init = ptr;
83509 + memset(ptr, 0, mod->init_size_rw);
83510 + mod->module_init_rw = ptr;
83511 } else
83512 - mod->module_init = NULL;
83513 + mod->module_init_rw = NULL;
83514 +
83515 + ptr = module_alloc_update_bounds_rx(mod->core_size_rx);
83516 + kmemleak_not_leak(ptr);
83517 + if (!ptr) {
83518 + if (mod->module_init_rw)
83519 + module_free(mod, mod->module_init_rw);
83520 + module_free(mod, mod->module_core_rw);
83521 + return -ENOMEM;
83522 + }
83523 +
83524 + pax_open_kernel();
83525 + memset(ptr, 0, mod->core_size_rx);
83526 + pax_close_kernel();
83527 + mod->module_core_rx = ptr;
83528 +
83529 + if (mod->init_size_rx) {
83530 + ptr = module_alloc_update_bounds_rx(mod->init_size_rx);
83531 + kmemleak_ignore(ptr);
83532 + if (!ptr && mod->init_size_rx) {
83533 + module_free_exec(mod, mod->module_core_rx);
83534 + if (mod->module_init_rw)
83535 + module_free(mod, mod->module_init_rw);
83536 + module_free(mod, mod->module_core_rw);
83537 + return -ENOMEM;
83538 + }
83539 +
83540 + pax_open_kernel();
83541 + memset(ptr, 0, mod->init_size_rx);
83542 + pax_close_kernel();
83543 + mod->module_init_rx = ptr;
83544 + } else
83545 + mod->module_init_rx = NULL;
83546
83547 /* Transfer each section which specifies SHF_ALLOC */
83548 pr_debug("final section addresses:\n");
83549 @@ -2854,16 +2930,45 @@ static int move_module(struct module *mod, struct load_info *info)
83550 if (!(shdr->sh_flags & SHF_ALLOC))
83551 continue;
83552
83553 - if (shdr->sh_entsize & INIT_OFFSET_MASK)
83554 - dest = mod->module_init
83555 - + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
83556 - else
83557 - dest = mod->module_core + shdr->sh_entsize;
83558 + if (shdr->sh_entsize & INIT_OFFSET_MASK) {
83559 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
83560 + dest = mod->module_init_rw
83561 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
83562 + else
83563 + dest = mod->module_init_rx
83564 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
83565 + } else {
83566 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
83567 + dest = mod->module_core_rw + shdr->sh_entsize;
83568 + else
83569 + dest = mod->module_core_rx + shdr->sh_entsize;
83570 + }
83571 +
83572 + if (shdr->sh_type != SHT_NOBITS) {
83573 +
83574 +#ifdef CONFIG_PAX_KERNEXEC
83575 +#ifdef CONFIG_X86_64
83576 + if ((shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_EXECINSTR))
83577 + set_memory_x((unsigned long)dest, (shdr->sh_size + PAGE_SIZE) >> PAGE_SHIFT);
83578 +#endif
83579 + if (!(shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_ALLOC)) {
83580 + pax_open_kernel();
83581 + memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
83582 + pax_close_kernel();
83583 + } else
83584 +#endif
83585
83586 - if (shdr->sh_type != SHT_NOBITS)
83587 memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
83588 + }
83589 /* Update sh_addr to point to copy in image. */
83590 - shdr->sh_addr = (unsigned long)dest;
83591 +
83592 +#ifdef CONFIG_PAX_KERNEXEC
83593 + if (shdr->sh_flags & SHF_EXECINSTR)
83594 + shdr->sh_addr = ktva_ktla((unsigned long)dest);
83595 + else
83596 +#endif
83597 +
83598 + shdr->sh_addr = (unsigned long)dest;
83599 pr_debug("\t0x%lx %s\n",
83600 (long)shdr->sh_addr, info->secstrings + shdr->sh_name);
83601 }
83602 @@ -2920,12 +3025,12 @@ static void flush_module_icache(const struct module *mod)
83603 * Do it before processing of module parameters, so the module
83604 * can provide parameter accessor functions of its own.
83605 */
83606 - if (mod->module_init)
83607 - flush_icache_range((unsigned long)mod->module_init,
83608 - (unsigned long)mod->module_init
83609 - + mod->init_size);
83610 - flush_icache_range((unsigned long)mod->module_core,
83611 - (unsigned long)mod->module_core + mod->core_size);
83612 + if (mod->module_init_rx)
83613 + flush_icache_range((unsigned long)mod->module_init_rx,
83614 + (unsigned long)mod->module_init_rx
83615 + + mod->init_size_rx);
83616 + flush_icache_range((unsigned long)mod->module_core_rx,
83617 + (unsigned long)mod->module_core_rx + mod->core_size_rx);
83618
83619 set_fs(old_fs);
83620 }
83621 @@ -2982,8 +3087,10 @@ static struct module *layout_and_allocate(struct load_info *info, int flags)
83622 static void module_deallocate(struct module *mod, struct load_info *info)
83623 {
83624 percpu_modfree(mod);
83625 - module_free(mod, mod->module_init);
83626 - module_free(mod, mod->module_core);
83627 + module_free_exec(mod, mod->module_init_rx);
83628 + module_free_exec(mod, mod->module_core_rx);
83629 + module_free(mod, mod->module_init_rw);
83630 + module_free(mod, mod->module_core_rw);
83631 }
83632
83633 int __weak module_finalize(const Elf_Ehdr *hdr,
83634 @@ -2996,7 +3103,9 @@ int __weak module_finalize(const Elf_Ehdr *hdr,
83635 static int post_relocation(struct module *mod, const struct load_info *info)
83636 {
83637 /* Sort exception table now relocations are done. */
83638 + pax_open_kernel();
83639 sort_extable(mod->extable, mod->extable + mod->num_exentries);
83640 + pax_close_kernel();
83641
83642 /* Copy relocated percpu area over. */
83643 percpu_modcopy(mod, (void *)info->sechdrs[info->index.pcpu].sh_addr,
83644 @@ -3050,16 +3159,16 @@ static int do_init_module(struct module *mod)
83645 MODULE_STATE_COMING, mod);
83646
83647 /* Set RO and NX regions for core */
83648 - set_section_ro_nx(mod->module_core,
83649 - mod->core_text_size,
83650 - mod->core_ro_size,
83651 - mod->core_size);
83652 + set_section_ro_nx(mod->module_core_rx,
83653 + mod->core_size_rx,
83654 + mod->core_size_rx,
83655 + mod->core_size_rx);
83656
83657 /* Set RO and NX regions for init */
83658 - set_section_ro_nx(mod->module_init,
83659 - mod->init_text_size,
83660 - mod->init_ro_size,
83661 - mod->init_size);
83662 + set_section_ro_nx(mod->module_init_rx,
83663 + mod->init_size_rx,
83664 + mod->init_size_rx,
83665 + mod->init_size_rx);
83666
83667 do_mod_ctors(mod);
83668 /* Start the module */
83669 @@ -3121,11 +3230,12 @@ static int do_init_module(struct module *mod)
83670 mod->strtab = mod->core_strtab;
83671 #endif
83672 unset_module_init_ro_nx(mod);
83673 - module_free(mod, mod->module_init);
83674 - mod->module_init = NULL;
83675 - mod->init_size = 0;
83676 - mod->init_ro_size = 0;
83677 - mod->init_text_size = 0;
83678 + module_free(mod, mod->module_init_rw);
83679 + module_free_exec(mod, mod->module_init_rx);
83680 + mod->module_init_rw = NULL;
83681 + mod->module_init_rx = NULL;
83682 + mod->init_size_rw = 0;
83683 + mod->init_size_rx = 0;
83684 mutex_unlock(&module_mutex);
83685 wake_up_all(&module_wq);
83686
83687 @@ -3269,9 +3379,38 @@ static int load_module(struct load_info *info, const char __user *uargs,
83688 if (err)
83689 goto free_unload;
83690
83691 + /* Now copy in args */
83692 + mod->args = strndup_user(uargs, ~0UL >> 1);
83693 + if (IS_ERR(mod->args)) {
83694 + err = PTR_ERR(mod->args);
83695 + goto free_unload;
83696 + }
83697 +
83698 /* Set up MODINFO_ATTR fields */
83699 setup_modinfo(mod, info);
83700
83701 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
83702 + {
83703 + char *p, *p2;
83704 +
83705 + if (strstr(mod->args, "grsec_modharden_netdev")) {
83706 + 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);
83707 + err = -EPERM;
83708 + goto free_modinfo;
83709 + } else if ((p = strstr(mod->args, "grsec_modharden_normal"))) {
83710 + p += sizeof("grsec_modharden_normal") - 1;
83711 + p2 = strstr(p, "_");
83712 + if (p2) {
83713 + *p2 = '\0';
83714 + printk(KERN_ALERT "grsec: denied kernel module auto-load of %.64s by uid %.9s\n", mod->name, p);
83715 + *p2 = '_';
83716 + }
83717 + err = -EPERM;
83718 + goto free_modinfo;
83719 + }
83720 + }
83721 +#endif
83722 +
83723 /* Fix up syms, so that st_value is a pointer to location. */
83724 err = simplify_symbols(mod, info);
83725 if (err < 0)
83726 @@ -3287,13 +3426,6 @@ static int load_module(struct load_info *info, const char __user *uargs,
83727
83728 flush_module_icache(mod);
83729
83730 - /* Now copy in args */
83731 - mod->args = strndup_user(uargs, ~0UL >> 1);
83732 - if (IS_ERR(mod->args)) {
83733 - err = PTR_ERR(mod->args);
83734 - goto free_arch_cleanup;
83735 - }
83736 -
83737 dynamic_debug_setup(info->debug, info->num_debug);
83738
83739 /* Finally it's fully formed, ready to start executing. */
83740 @@ -3328,11 +3460,10 @@ static int load_module(struct load_info *info, const char __user *uargs,
83741 ddebug_cleanup:
83742 dynamic_debug_remove(info->debug);
83743 synchronize_sched();
83744 - kfree(mod->args);
83745 - free_arch_cleanup:
83746 module_arch_cleanup(mod);
83747 free_modinfo:
83748 free_modinfo(mod);
83749 + kfree(mod->args);
83750 free_unload:
83751 module_unload_free(mod);
83752 unlink_mod:
83753 @@ -3415,10 +3546,16 @@ static const char *get_ksymbol(struct module *mod,
83754 unsigned long nextval;
83755
83756 /* At worse, next value is at end of module */
83757 - if (within_module_init(addr, mod))
83758 - nextval = (unsigned long)mod->module_init+mod->init_text_size;
83759 + if (within_module_init_rx(addr, mod))
83760 + nextval = (unsigned long)mod->module_init_rx+mod->init_size_rx;
83761 + else if (within_module_init_rw(addr, mod))
83762 + nextval = (unsigned long)mod->module_init_rw+mod->init_size_rw;
83763 + else if (within_module_core_rx(addr, mod))
83764 + nextval = (unsigned long)mod->module_core_rx+mod->core_size_rx;
83765 + else if (within_module_core_rw(addr, mod))
83766 + nextval = (unsigned long)mod->module_core_rw+mod->core_size_rw;
83767 else
83768 - nextval = (unsigned long)mod->module_core+mod->core_text_size;
83769 + return NULL;
83770
83771 /* Scan for closest preceding symbol, and next symbol. (ELF
83772 starts real symbols at 1). */
83773 @@ -3669,7 +3806,7 @@ static int m_show(struct seq_file *m, void *p)
83774 return 0;
83775
83776 seq_printf(m, "%s %u",
83777 - mod->name, mod->init_size + mod->core_size);
83778 + mod->name, mod->init_size_rx + mod->init_size_rw + mod->core_size_rx + mod->core_size_rw);
83779 print_unload_info(m, mod);
83780
83781 /* Informative for users. */
83782 @@ -3678,7 +3815,7 @@ static int m_show(struct seq_file *m, void *p)
83783 mod->state == MODULE_STATE_COMING ? "Loading":
83784 "Live");
83785 /* Used by oprofile and other similar tools. */
83786 - seq_printf(m, " 0x%pK", mod->module_core);
83787 + seq_printf(m, " 0x%pK 0x%pK", mod->module_core_rx, mod->module_core_rw);
83788
83789 /* Taints info */
83790 if (mod->taints)
83791 @@ -3714,7 +3851,17 @@ static const struct file_operations proc_modules_operations = {
83792
83793 static int __init proc_modules_init(void)
83794 {
83795 +#ifndef CONFIG_GRKERNSEC_HIDESYM
83796 +#ifdef CONFIG_GRKERNSEC_PROC_USER
83797 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
83798 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
83799 + proc_create("modules", S_IRUSR | S_IRGRP, NULL, &proc_modules_operations);
83800 +#else
83801 proc_create("modules", 0, NULL, &proc_modules_operations);
83802 +#endif
83803 +#else
83804 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
83805 +#endif
83806 return 0;
83807 }
83808 module_init(proc_modules_init);
83809 @@ -3775,14 +3922,14 @@ struct module *__module_address(unsigned long addr)
83810 {
83811 struct module *mod;
83812
83813 - if (addr < module_addr_min || addr > module_addr_max)
83814 + if ((addr < module_addr_min_rx || addr > module_addr_max_rx) &&
83815 + (addr < module_addr_min_rw || addr > module_addr_max_rw))
83816 return NULL;
83817
83818 list_for_each_entry_rcu(mod, &modules, list) {
83819 if (mod->state == MODULE_STATE_UNFORMED)
83820 continue;
83821 - if (within_module_core(addr, mod)
83822 - || within_module_init(addr, mod))
83823 + if (within_module_init(addr, mod) || within_module_core(addr, mod))
83824 return mod;
83825 }
83826 return NULL;
83827 @@ -3817,11 +3964,20 @@ bool is_module_text_address(unsigned long addr)
83828 */
83829 struct module *__module_text_address(unsigned long addr)
83830 {
83831 - struct module *mod = __module_address(addr);
83832 + struct module *mod;
83833 +
83834 +#ifdef CONFIG_X86_32
83835 + addr = ktla_ktva(addr);
83836 +#endif
83837 +
83838 + if (addr < module_addr_min_rx || addr > module_addr_max_rx)
83839 + return NULL;
83840 +
83841 + mod = __module_address(addr);
83842 +
83843 if (mod) {
83844 /* Make sure it's within the text section. */
83845 - if (!within(addr, mod->module_init, mod->init_text_size)
83846 - && !within(addr, mod->module_core, mod->core_text_size))
83847 + if (!within_module_init_rx(addr, mod) && !within_module_core_rx(addr, mod))
83848 mod = NULL;
83849 }
83850 return mod;
83851 diff --git a/kernel/mutex-debug.c b/kernel/mutex-debug.c
83852 index 7e3443f..b2a1e6b 100644
83853 --- a/kernel/mutex-debug.c
83854 +++ b/kernel/mutex-debug.c
83855 @@ -49,21 +49,21 @@ void debug_mutex_free_waiter(struct mutex_waiter *waiter)
83856 }
83857
83858 void debug_mutex_add_waiter(struct mutex *lock, struct mutex_waiter *waiter,
83859 - struct thread_info *ti)
83860 + struct task_struct *task)
83861 {
83862 SMP_DEBUG_LOCKS_WARN_ON(!spin_is_locked(&lock->wait_lock));
83863
83864 /* Mark the current thread as blocked on the lock: */
83865 - ti->task->blocked_on = waiter;
83866 + task->blocked_on = waiter;
83867 }
83868
83869 void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
83870 - struct thread_info *ti)
83871 + struct task_struct *task)
83872 {
83873 DEBUG_LOCKS_WARN_ON(list_empty(&waiter->list));
83874 - DEBUG_LOCKS_WARN_ON(waiter->task != ti->task);
83875 - DEBUG_LOCKS_WARN_ON(ti->task->blocked_on != waiter);
83876 - ti->task->blocked_on = NULL;
83877 + DEBUG_LOCKS_WARN_ON(waiter->task != task);
83878 + DEBUG_LOCKS_WARN_ON(task->blocked_on != waiter);
83879 + task->blocked_on = NULL;
83880
83881 list_del_init(&waiter->list);
83882 waiter->task = NULL;
83883 diff --git a/kernel/mutex-debug.h b/kernel/mutex-debug.h
83884 index 0799fd3..d06ae3b 100644
83885 --- a/kernel/mutex-debug.h
83886 +++ b/kernel/mutex-debug.h
83887 @@ -20,9 +20,9 @@ extern void debug_mutex_wake_waiter(struct mutex *lock,
83888 extern void debug_mutex_free_waiter(struct mutex_waiter *waiter);
83889 extern void debug_mutex_add_waiter(struct mutex *lock,
83890 struct mutex_waiter *waiter,
83891 - struct thread_info *ti);
83892 + struct task_struct *task);
83893 extern void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
83894 - struct thread_info *ti);
83895 + struct task_struct *task);
83896 extern void debug_mutex_unlock(struct mutex *lock);
83897 extern void debug_mutex_init(struct mutex *lock, const char *name,
83898 struct lock_class_key *key);
83899 diff --git a/kernel/mutex.c b/kernel/mutex.c
83900 index d24105b..15648eb 100644
83901 --- a/kernel/mutex.c
83902 +++ b/kernel/mutex.c
83903 @@ -135,7 +135,7 @@ void mspin_lock(struct mspin_node **lock, struct mspin_node *node)
83904 node->locked = 1;
83905 return;
83906 }
83907 - ACCESS_ONCE(prev->next) = node;
83908 + ACCESS_ONCE_RW(prev->next) = node;
83909 smp_wmb();
83910 /* Wait until the lock holder passes the lock down */
83911 while (!ACCESS_ONCE(node->locked))
83912 @@ -156,7 +156,7 @@ static void mspin_unlock(struct mspin_node **lock, struct mspin_node *node)
83913 while (!(next = ACCESS_ONCE(node->next)))
83914 arch_mutex_cpu_relax();
83915 }
83916 - ACCESS_ONCE(next->locked) = 1;
83917 + ACCESS_ONCE_RW(next->locked) = 1;
83918 smp_wmb();
83919 }
83920
83921 @@ -520,7 +520,7 @@ slowpath:
83922 goto skip_wait;
83923
83924 debug_mutex_lock_common(lock, &waiter);
83925 - debug_mutex_add_waiter(lock, &waiter, task_thread_info(task));
83926 + debug_mutex_add_waiter(lock, &waiter, task);
83927
83928 /* add waiting tasks to the end of the waitqueue (FIFO): */
83929 list_add_tail(&waiter.list, &lock->wait_list);
83930 @@ -564,7 +564,7 @@ slowpath:
83931 schedule_preempt_disabled();
83932 spin_lock_mutex(&lock->wait_lock, flags);
83933 }
83934 - mutex_remove_waiter(lock, &waiter, current_thread_info());
83935 + mutex_remove_waiter(lock, &waiter, task);
83936 /* set it to 0 if there are no waiters left: */
83937 if (likely(list_empty(&lock->wait_list)))
83938 atomic_set(&lock->count, 0);
83939 @@ -601,7 +601,7 @@ skip_wait:
83940 return 0;
83941
83942 err:
83943 - mutex_remove_waiter(lock, &waiter, task_thread_info(task));
83944 + mutex_remove_waiter(lock, &waiter, task);
83945 spin_unlock_mutex(&lock->wait_lock, flags);
83946 debug_mutex_free_waiter(&waiter);
83947 mutex_release(&lock->dep_map, 1, ip);
83948 diff --git a/kernel/notifier.c b/kernel/notifier.c
83949 index 2d5cc4c..d9ea600 100644
83950 --- a/kernel/notifier.c
83951 +++ b/kernel/notifier.c
83952 @@ -5,6 +5,7 @@
83953 #include <linux/rcupdate.h>
83954 #include <linux/vmalloc.h>
83955 #include <linux/reboot.h>
83956 +#include <linux/mm.h>
83957
83958 /*
83959 * Notifier list for kernel code which wants to be called
83960 @@ -24,10 +25,12 @@ static int notifier_chain_register(struct notifier_block **nl,
83961 while ((*nl) != NULL) {
83962 if (n->priority > (*nl)->priority)
83963 break;
83964 - nl = &((*nl)->next);
83965 + nl = (struct notifier_block **)&((*nl)->next);
83966 }
83967 - n->next = *nl;
83968 + pax_open_kernel();
83969 + *(const void **)&n->next = *nl;
83970 rcu_assign_pointer(*nl, n);
83971 + pax_close_kernel();
83972 return 0;
83973 }
83974
83975 @@ -39,10 +42,12 @@ static int notifier_chain_cond_register(struct notifier_block **nl,
83976 return 0;
83977 if (n->priority > (*nl)->priority)
83978 break;
83979 - nl = &((*nl)->next);
83980 + nl = (struct notifier_block **)&((*nl)->next);
83981 }
83982 - n->next = *nl;
83983 + pax_open_kernel();
83984 + *(const void **)&n->next = *nl;
83985 rcu_assign_pointer(*nl, n);
83986 + pax_close_kernel();
83987 return 0;
83988 }
83989
83990 @@ -51,10 +56,12 @@ static int notifier_chain_unregister(struct notifier_block **nl,
83991 {
83992 while ((*nl) != NULL) {
83993 if ((*nl) == n) {
83994 + pax_open_kernel();
83995 rcu_assign_pointer(*nl, n->next);
83996 + pax_close_kernel();
83997 return 0;
83998 }
83999 - nl = &((*nl)->next);
84000 + nl = (struct notifier_block **)&((*nl)->next);
84001 }
84002 return -ENOENT;
84003 }
84004 diff --git a/kernel/panic.c b/kernel/panic.c
84005 index b6c482c..5578061 100644
84006 --- a/kernel/panic.c
84007 +++ b/kernel/panic.c
84008 @@ -407,7 +407,7 @@ static void warn_slowpath_common(const char *file, int line, void *caller,
84009 disable_trace_on_warning();
84010
84011 pr_warn("------------[ cut here ]------------\n");
84012 - pr_warn("WARNING: CPU: %d PID: %d at %s:%d %pS()\n",
84013 + pr_warn("WARNING: CPU: %d PID: %d at %s:%d %pA()\n",
84014 raw_smp_processor_id(), current->pid, file, line, caller);
84015
84016 if (args)
84017 @@ -461,7 +461,8 @@ EXPORT_SYMBOL(warn_slowpath_null);
84018 */
84019 void __stack_chk_fail(void)
84020 {
84021 - panic("stack-protector: Kernel stack is corrupted in: %p\n",
84022 + dump_stack();
84023 + panic("stack-protector: Kernel stack is corrupted in: %pA\n",
84024 __builtin_return_address(0));
84025 }
84026 EXPORT_SYMBOL(__stack_chk_fail);
84027 diff --git a/kernel/pid.c b/kernel/pid.c
84028 index 9b9a266..c20ef80 100644
84029 --- a/kernel/pid.c
84030 +++ b/kernel/pid.c
84031 @@ -33,6 +33,7 @@
84032 #include <linux/rculist.h>
84033 #include <linux/bootmem.h>
84034 #include <linux/hash.h>
84035 +#include <linux/security.h>
84036 #include <linux/pid_namespace.h>
84037 #include <linux/init_task.h>
84038 #include <linux/syscalls.h>
84039 @@ -47,7 +48,7 @@ struct pid init_struct_pid = INIT_STRUCT_PID;
84040
84041 int pid_max = PID_MAX_DEFAULT;
84042
84043 -#define RESERVED_PIDS 300
84044 +#define RESERVED_PIDS 500
84045
84046 int pid_max_min = RESERVED_PIDS + 1;
84047 int pid_max_max = PID_MAX_LIMIT;
84048 @@ -445,10 +446,18 @@ EXPORT_SYMBOL(pid_task);
84049 */
84050 struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
84051 {
84052 + struct task_struct *task;
84053 +
84054 rcu_lockdep_assert(rcu_read_lock_held(),
84055 "find_task_by_pid_ns() needs rcu_read_lock()"
84056 " protection");
84057 - return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
84058 +
84059 + task = pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
84060 +
84061 + if (gr_pid_is_chrooted(task))
84062 + return NULL;
84063 +
84064 + return task;
84065 }
84066
84067 struct task_struct *find_task_by_vpid(pid_t vnr)
84068 @@ -456,6 +465,14 @@ struct task_struct *find_task_by_vpid(pid_t vnr)
84069 return find_task_by_pid_ns(vnr, task_active_pid_ns(current));
84070 }
84071
84072 +struct task_struct *find_task_by_vpid_unrestricted(pid_t vnr)
84073 +{
84074 + rcu_lockdep_assert(rcu_read_lock_held(),
84075 + "find_task_by_pid_ns() needs rcu_read_lock()"
84076 + " protection");
84077 + return pid_task(find_pid_ns(vnr, task_active_pid_ns(current)), PIDTYPE_PID);
84078 +}
84079 +
84080 struct pid *get_task_pid(struct task_struct *task, enum pid_type type)
84081 {
84082 struct pid *pid;
84083 diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c
84084 index 4208655..19f36a5 100644
84085 --- a/kernel/pid_namespace.c
84086 +++ b/kernel/pid_namespace.c
84087 @@ -247,7 +247,7 @@ static int pid_ns_ctl_handler(struct ctl_table *table, int write,
84088 void __user *buffer, size_t *lenp, loff_t *ppos)
84089 {
84090 struct pid_namespace *pid_ns = task_active_pid_ns(current);
84091 - struct ctl_table tmp = *table;
84092 + ctl_table_no_const tmp = *table;
84093
84094 if (write && !ns_capable(pid_ns->user_ns, CAP_SYS_ADMIN))
84095 return -EPERM;
84096 diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c
84097 index c7f31aa..2b44977 100644
84098 --- a/kernel/posix-cpu-timers.c
84099 +++ b/kernel/posix-cpu-timers.c
84100 @@ -1521,14 +1521,14 @@ struct k_clock clock_posix_cpu = {
84101
84102 static __init int init_posix_cpu_timers(void)
84103 {
84104 - struct k_clock process = {
84105 + static struct k_clock process = {
84106 .clock_getres = process_cpu_clock_getres,
84107 .clock_get = process_cpu_clock_get,
84108 .timer_create = process_cpu_timer_create,
84109 .nsleep = process_cpu_nsleep,
84110 .nsleep_restart = process_cpu_nsleep_restart,
84111 };
84112 - struct k_clock thread = {
84113 + static struct k_clock thread = {
84114 .clock_getres = thread_cpu_clock_getres,
84115 .clock_get = thread_cpu_clock_get,
84116 .timer_create = thread_cpu_timer_create,
84117 diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c
84118 index 424c2d4..679242f 100644
84119 --- a/kernel/posix-timers.c
84120 +++ b/kernel/posix-timers.c
84121 @@ -43,6 +43,7 @@
84122 #include <linux/hash.h>
84123 #include <linux/posix-clock.h>
84124 #include <linux/posix-timers.h>
84125 +#include <linux/grsecurity.h>
84126 #include <linux/syscalls.h>
84127 #include <linux/wait.h>
84128 #include <linux/workqueue.h>
84129 @@ -122,7 +123,7 @@ static DEFINE_SPINLOCK(hash_lock);
84130 * which we beg off on and pass to do_sys_settimeofday().
84131 */
84132
84133 -static struct k_clock posix_clocks[MAX_CLOCKS];
84134 +static struct k_clock *posix_clocks[MAX_CLOCKS];
84135
84136 /*
84137 * These ones are defined below.
84138 @@ -275,7 +276,7 @@ static int posix_get_tai(clockid_t which_clock, struct timespec *tp)
84139 */
84140 static __init int init_posix_timers(void)
84141 {
84142 - struct k_clock clock_realtime = {
84143 + static struct k_clock clock_realtime = {
84144 .clock_getres = hrtimer_get_res,
84145 .clock_get = posix_clock_realtime_get,
84146 .clock_set = posix_clock_realtime_set,
84147 @@ -287,7 +288,7 @@ static __init int init_posix_timers(void)
84148 .timer_get = common_timer_get,
84149 .timer_del = common_timer_del,
84150 };
84151 - struct k_clock clock_monotonic = {
84152 + static struct k_clock clock_monotonic = {
84153 .clock_getres = hrtimer_get_res,
84154 .clock_get = posix_ktime_get_ts,
84155 .nsleep = common_nsleep,
84156 @@ -297,19 +298,19 @@ static __init int init_posix_timers(void)
84157 .timer_get = common_timer_get,
84158 .timer_del = common_timer_del,
84159 };
84160 - struct k_clock clock_monotonic_raw = {
84161 + static struct k_clock clock_monotonic_raw = {
84162 .clock_getres = hrtimer_get_res,
84163 .clock_get = posix_get_monotonic_raw,
84164 };
84165 - struct k_clock clock_realtime_coarse = {
84166 + static struct k_clock clock_realtime_coarse = {
84167 .clock_getres = posix_get_coarse_res,
84168 .clock_get = posix_get_realtime_coarse,
84169 };
84170 - struct k_clock clock_monotonic_coarse = {
84171 + static struct k_clock clock_monotonic_coarse = {
84172 .clock_getres = posix_get_coarse_res,
84173 .clock_get = posix_get_monotonic_coarse,
84174 };
84175 - struct k_clock clock_tai = {
84176 + static struct k_clock clock_tai = {
84177 .clock_getres = hrtimer_get_res,
84178 .clock_get = posix_get_tai,
84179 .nsleep = common_nsleep,
84180 @@ -319,7 +320,7 @@ static __init int init_posix_timers(void)
84181 .timer_get = common_timer_get,
84182 .timer_del = common_timer_del,
84183 };
84184 - struct k_clock clock_boottime = {
84185 + static struct k_clock clock_boottime = {
84186 .clock_getres = hrtimer_get_res,
84187 .clock_get = posix_get_boottime,
84188 .nsleep = common_nsleep,
84189 @@ -531,7 +532,7 @@ void posix_timers_register_clock(const clockid_t clock_id,
84190 return;
84191 }
84192
84193 - posix_clocks[clock_id] = *new_clock;
84194 + posix_clocks[clock_id] = new_clock;
84195 }
84196 EXPORT_SYMBOL_GPL(posix_timers_register_clock);
84197
84198 @@ -577,9 +578,9 @@ static struct k_clock *clockid_to_kclock(const clockid_t id)
84199 return (id & CLOCKFD_MASK) == CLOCKFD ?
84200 &clock_posix_dynamic : &clock_posix_cpu;
84201
84202 - if (id >= MAX_CLOCKS || !posix_clocks[id].clock_getres)
84203 + if (id >= MAX_CLOCKS || !posix_clocks[id] || !posix_clocks[id]->clock_getres)
84204 return NULL;
84205 - return &posix_clocks[id];
84206 + return posix_clocks[id];
84207 }
84208
84209 static int common_timer_create(struct k_itimer *new_timer)
84210 @@ -597,7 +598,7 @@ SYSCALL_DEFINE3(timer_create, const clockid_t, which_clock,
84211 struct k_clock *kc = clockid_to_kclock(which_clock);
84212 struct k_itimer *new_timer;
84213 int error, new_timer_id;
84214 - sigevent_t event;
84215 + sigevent_t event = { };
84216 int it_id_set = IT_ID_NOT_SET;
84217
84218 if (!kc)
84219 @@ -1011,6 +1012,13 @@ SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock,
84220 if (copy_from_user(&new_tp, tp, sizeof (*tp)))
84221 return -EFAULT;
84222
84223 + /* only the CLOCK_REALTIME clock can be set, all other clocks
84224 + have their clock_set fptr set to a nosettime dummy function
84225 + CLOCK_REALTIME has a NULL clock_set fptr which causes it to
84226 + call common_clock_set, which calls do_sys_settimeofday, which
84227 + we hook
84228 + */
84229 +
84230 return kc->clock_set(which_clock, &new_tp);
84231 }
84232
84233 diff --git a/kernel/power/process.c b/kernel/power/process.c
84234 index 06ec886..9dba35e 100644
84235 --- a/kernel/power/process.c
84236 +++ b/kernel/power/process.c
84237 @@ -34,6 +34,7 @@ static int try_to_freeze_tasks(bool user_only)
84238 unsigned int elapsed_msecs;
84239 bool wakeup = false;
84240 int sleep_usecs = USEC_PER_MSEC;
84241 + bool timedout = false;
84242
84243 do_gettimeofday(&start);
84244
84245 @@ -44,13 +45,20 @@ static int try_to_freeze_tasks(bool user_only)
84246
84247 while (true) {
84248 todo = 0;
84249 + if (time_after(jiffies, end_time))
84250 + timedout = true;
84251 read_lock(&tasklist_lock);
84252 do_each_thread(g, p) {
84253 if (p == current || !freeze_task(p))
84254 continue;
84255
84256 - if (!freezer_should_skip(p))
84257 + if (!freezer_should_skip(p)) {
84258 todo++;
84259 + if (timedout) {
84260 + printk(KERN_ERR "Task refusing to freeze:\n");
84261 + sched_show_task(p);
84262 + }
84263 + }
84264 } while_each_thread(g, p);
84265 read_unlock(&tasklist_lock);
84266
84267 @@ -59,7 +67,7 @@ static int try_to_freeze_tasks(bool user_only)
84268 todo += wq_busy;
84269 }
84270
84271 - if (!todo || time_after(jiffies, end_time))
84272 + if (!todo || timedout)
84273 break;
84274
84275 if (pm_wakeup_pending()) {
84276 diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
84277 index b4e8500..b457a6c 100644
84278 --- a/kernel/printk/printk.c
84279 +++ b/kernel/printk/printk.c
84280 @@ -385,6 +385,11 @@ static int check_syslog_permissions(int type, bool from_file)
84281 if (from_file && type != SYSLOG_ACTION_OPEN)
84282 return 0;
84283
84284 +#ifdef CONFIG_GRKERNSEC_DMESG
84285 + if (grsec_enable_dmesg && !capable(CAP_SYSLOG) && !capable_nolog(CAP_SYS_ADMIN))
84286 + return -EPERM;
84287 +#endif
84288 +
84289 if (syslog_action_restricted(type)) {
84290 if (capable(CAP_SYSLOG))
84291 return 0;
84292 diff --git a/kernel/profile.c b/kernel/profile.c
84293 index 6631e1e..310c266 100644
84294 --- a/kernel/profile.c
84295 +++ b/kernel/profile.c
84296 @@ -37,7 +37,7 @@ struct profile_hit {
84297 #define NR_PROFILE_HIT (PAGE_SIZE/sizeof(struct profile_hit))
84298 #define NR_PROFILE_GRP (NR_PROFILE_HIT/PROFILE_GRPSZ)
84299
84300 -static atomic_t *prof_buffer;
84301 +static atomic_unchecked_t *prof_buffer;
84302 static unsigned long prof_len, prof_shift;
84303
84304 int prof_on __read_mostly;
84305 @@ -260,7 +260,7 @@ static void profile_flip_buffers(void)
84306 hits[i].pc = 0;
84307 continue;
84308 }
84309 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
84310 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
84311 hits[i].hits = hits[i].pc = 0;
84312 }
84313 }
84314 @@ -321,9 +321,9 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
84315 * Add the current hit(s) and flush the write-queue out
84316 * to the global buffer:
84317 */
84318 - atomic_add(nr_hits, &prof_buffer[pc]);
84319 + atomic_add_unchecked(nr_hits, &prof_buffer[pc]);
84320 for (i = 0; i < NR_PROFILE_HIT; ++i) {
84321 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
84322 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
84323 hits[i].pc = hits[i].hits = 0;
84324 }
84325 out:
84326 @@ -398,7 +398,7 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
84327 {
84328 unsigned long pc;
84329 pc = ((unsigned long)__pc - (unsigned long)_stext) >> prof_shift;
84330 - atomic_add(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
84331 + atomic_add_unchecked(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
84332 }
84333 #endif /* !CONFIG_SMP */
84334
84335 @@ -494,7 +494,7 @@ read_profile(struct file *file, char __user *buf, size_t count, loff_t *ppos)
84336 return -EFAULT;
84337 buf++; p++; count--; read++;
84338 }
84339 - pnt = (char *)prof_buffer + p - sizeof(atomic_t);
84340 + pnt = (char *)prof_buffer + p - sizeof(atomic_unchecked_t);
84341 if (copy_to_user(buf, (void *)pnt, count))
84342 return -EFAULT;
84343 read += count;
84344 @@ -525,7 +525,7 @@ static ssize_t write_profile(struct file *file, const char __user *buf,
84345 }
84346 #endif
84347 profile_discard_flip_buffers();
84348 - memset(prof_buffer, 0, prof_len * sizeof(atomic_t));
84349 + memset(prof_buffer, 0, prof_len * sizeof(atomic_unchecked_t));
84350 return count;
84351 }
84352
84353 diff --git a/kernel/ptrace.c b/kernel/ptrace.c
84354 index 1f4bcb3..99cf7ab 100644
84355 --- a/kernel/ptrace.c
84356 +++ b/kernel/ptrace.c
84357 @@ -327,7 +327,7 @@ static int ptrace_attach(struct task_struct *task, long request,
84358 if (seize)
84359 flags |= PT_SEIZED;
84360 rcu_read_lock();
84361 - if (ns_capable(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
84362 + if (ns_capable_nolog(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
84363 flags |= PT_PTRACE_CAP;
84364 rcu_read_unlock();
84365 task->ptrace = flags;
84366 @@ -538,7 +538,7 @@ int ptrace_readdata(struct task_struct *tsk, unsigned long src, char __user *dst
84367 break;
84368 return -EIO;
84369 }
84370 - if (copy_to_user(dst, buf, retval))
84371 + if (retval > sizeof(buf) || copy_to_user(dst, buf, retval))
84372 return -EFAULT;
84373 copied += retval;
84374 src += retval;
84375 @@ -806,7 +806,7 @@ int ptrace_request(struct task_struct *child, long request,
84376 bool seized = child->ptrace & PT_SEIZED;
84377 int ret = -EIO;
84378 siginfo_t siginfo, *si;
84379 - void __user *datavp = (void __user *) data;
84380 + void __user *datavp = (__force void __user *) data;
84381 unsigned long __user *datalp = datavp;
84382 unsigned long flags;
84383
84384 @@ -1052,14 +1052,21 @@ SYSCALL_DEFINE4(ptrace, long, request, long, pid, unsigned long, addr,
84385 goto out;
84386 }
84387
84388 + if (gr_handle_ptrace(child, request)) {
84389 + ret = -EPERM;
84390 + goto out_put_task_struct;
84391 + }
84392 +
84393 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
84394 ret = ptrace_attach(child, request, addr, data);
84395 /*
84396 * Some architectures need to do book-keeping after
84397 * a ptrace attach.
84398 */
84399 - if (!ret)
84400 + if (!ret) {
84401 arch_ptrace_attach(child);
84402 + gr_audit_ptrace(child);
84403 + }
84404 goto out_put_task_struct;
84405 }
84406
84407 @@ -1087,7 +1094,7 @@ int generic_ptrace_peekdata(struct task_struct *tsk, unsigned long addr,
84408 copied = access_process_vm(tsk, addr, &tmp, sizeof(tmp), 0);
84409 if (copied != sizeof(tmp))
84410 return -EIO;
84411 - return put_user(tmp, (unsigned long __user *)data);
84412 + return put_user(tmp, (__force unsigned long __user *)data);
84413 }
84414
84415 int generic_ptrace_pokedata(struct task_struct *tsk, unsigned long addr,
84416 @@ -1181,7 +1188,7 @@ int compat_ptrace_request(struct task_struct *child, compat_long_t request,
84417 }
84418
84419 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
84420 - compat_long_t addr, compat_long_t data)
84421 + compat_ulong_t addr, compat_ulong_t data)
84422 {
84423 struct task_struct *child;
84424 long ret;
84425 @@ -1197,14 +1204,21 @@ asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
84426 goto out;
84427 }
84428
84429 + if (gr_handle_ptrace(child, request)) {
84430 + ret = -EPERM;
84431 + goto out_put_task_struct;
84432 + }
84433 +
84434 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
84435 ret = ptrace_attach(child, request, addr, data);
84436 /*
84437 * Some architectures need to do book-keeping after
84438 * a ptrace attach.
84439 */
84440 - if (!ret)
84441 + if (!ret) {
84442 arch_ptrace_attach(child);
84443 + gr_audit_ptrace(child);
84444 + }
84445 goto out_put_task_struct;
84446 }
84447
84448 diff --git a/kernel/rcupdate.c b/kernel/rcupdate.c
84449 index b02a339..ce2d20c 100644
84450 --- a/kernel/rcupdate.c
84451 +++ b/kernel/rcupdate.c
84452 @@ -312,10 +312,10 @@ int rcu_jiffies_till_stall_check(void)
84453 * for CONFIG_RCU_CPU_STALL_TIMEOUT.
84454 */
84455 if (till_stall_check < 3) {
84456 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 3;
84457 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 3;
84458 till_stall_check = 3;
84459 } else if (till_stall_check > 300) {
84460 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 300;
84461 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 300;
84462 till_stall_check = 300;
84463 }
84464 return till_stall_check * HZ + RCU_STALL_DELAY_DELTA;
84465 diff --git a/kernel/rcutiny.c b/kernel/rcutiny.c
84466 index 9ed6075..c9e8a63 100644
84467 --- a/kernel/rcutiny.c
84468 +++ b/kernel/rcutiny.c
84469 @@ -45,7 +45,7 @@
84470 /* Forward declarations for rcutiny_plugin.h. */
84471 struct rcu_ctrlblk;
84472 static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp);
84473 -static void rcu_process_callbacks(struct softirq_action *unused);
84474 +static void rcu_process_callbacks(void);
84475 static void __call_rcu(struct rcu_head *head,
84476 void (*func)(struct rcu_head *rcu),
84477 struct rcu_ctrlblk *rcp);
84478 @@ -309,7 +309,7 @@ static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp)
84479 false));
84480 }
84481
84482 -static void rcu_process_callbacks(struct softirq_action *unused)
84483 +static __latent_entropy void rcu_process_callbacks(void)
84484 {
84485 __rcu_process_callbacks(&rcu_sched_ctrlblk);
84486 __rcu_process_callbacks(&rcu_bh_ctrlblk);
84487 diff --git a/kernel/rcutorture.c b/kernel/rcutorture.c
84488 index be63101..05cf721 100644
84489 --- a/kernel/rcutorture.c
84490 +++ b/kernel/rcutorture.c
84491 @@ -170,12 +170,12 @@ static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_count) =
84492 { 0 };
84493 static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_batch) =
84494 { 0 };
84495 -static atomic_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
84496 -static atomic_t n_rcu_torture_alloc;
84497 -static atomic_t n_rcu_torture_alloc_fail;
84498 -static atomic_t n_rcu_torture_free;
84499 -static atomic_t n_rcu_torture_mberror;
84500 -static atomic_t n_rcu_torture_error;
84501 +static atomic_unchecked_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
84502 +static atomic_unchecked_t n_rcu_torture_alloc;
84503 +static atomic_unchecked_t n_rcu_torture_alloc_fail;
84504 +static atomic_unchecked_t n_rcu_torture_free;
84505 +static atomic_unchecked_t n_rcu_torture_mberror;
84506 +static atomic_unchecked_t n_rcu_torture_error;
84507 static long n_rcu_torture_barrier_error;
84508 static long n_rcu_torture_boost_ktrerror;
84509 static long n_rcu_torture_boost_rterror;
84510 @@ -293,11 +293,11 @@ rcu_torture_alloc(void)
84511
84512 spin_lock_bh(&rcu_torture_lock);
84513 if (list_empty(&rcu_torture_freelist)) {
84514 - atomic_inc(&n_rcu_torture_alloc_fail);
84515 + atomic_inc_unchecked(&n_rcu_torture_alloc_fail);
84516 spin_unlock_bh(&rcu_torture_lock);
84517 return NULL;
84518 }
84519 - atomic_inc(&n_rcu_torture_alloc);
84520 + atomic_inc_unchecked(&n_rcu_torture_alloc);
84521 p = rcu_torture_freelist.next;
84522 list_del_init(p);
84523 spin_unlock_bh(&rcu_torture_lock);
84524 @@ -310,7 +310,7 @@ rcu_torture_alloc(void)
84525 static void
84526 rcu_torture_free(struct rcu_torture *p)
84527 {
84528 - atomic_inc(&n_rcu_torture_free);
84529 + atomic_inc_unchecked(&n_rcu_torture_free);
84530 spin_lock_bh(&rcu_torture_lock);
84531 list_add_tail(&p->rtort_free, &rcu_torture_freelist);
84532 spin_unlock_bh(&rcu_torture_lock);
84533 @@ -431,7 +431,7 @@ rcu_torture_cb(struct rcu_head *p)
84534 i = rp->rtort_pipe_count;
84535 if (i > RCU_TORTURE_PIPE_LEN)
84536 i = RCU_TORTURE_PIPE_LEN;
84537 - atomic_inc(&rcu_torture_wcount[i]);
84538 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
84539 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
84540 rp->rtort_mbtest = 0;
84541 rcu_torture_free(rp);
84542 @@ -821,7 +821,7 @@ rcu_torture_writer(void *arg)
84543 i = old_rp->rtort_pipe_count;
84544 if (i > RCU_TORTURE_PIPE_LEN)
84545 i = RCU_TORTURE_PIPE_LEN;
84546 - atomic_inc(&rcu_torture_wcount[i]);
84547 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
84548 old_rp->rtort_pipe_count++;
84549 if (gp_normal == gp_exp)
84550 exp = !!(rcu_random(&rand) & 0x80);
84551 @@ -839,7 +839,7 @@ rcu_torture_writer(void *arg)
84552 i = rp->rtort_pipe_count;
84553 if (i > RCU_TORTURE_PIPE_LEN)
84554 i = RCU_TORTURE_PIPE_LEN;
84555 - atomic_inc(&rcu_torture_wcount[i]);
84556 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
84557 if (++rp->rtort_pipe_count >=
84558 RCU_TORTURE_PIPE_LEN) {
84559 rp->rtort_mbtest = 0;
84560 @@ -938,7 +938,7 @@ static void rcu_torture_timer(unsigned long unused)
84561 return;
84562 }
84563 if (p->rtort_mbtest == 0)
84564 - atomic_inc(&n_rcu_torture_mberror);
84565 + atomic_inc_unchecked(&n_rcu_torture_mberror);
84566 spin_lock(&rand_lock);
84567 cur_ops->read_delay(&rand);
84568 n_rcu_torture_timers++;
84569 @@ -1008,7 +1008,7 @@ rcu_torture_reader(void *arg)
84570 continue;
84571 }
84572 if (p->rtort_mbtest == 0)
84573 - atomic_inc(&n_rcu_torture_mberror);
84574 + atomic_inc_unchecked(&n_rcu_torture_mberror);
84575 cur_ops->read_delay(&rand);
84576 preempt_disable();
84577 pipe_count = p->rtort_pipe_count;
84578 @@ -1071,11 +1071,11 @@ rcu_torture_printk(char *page)
84579 rcu_torture_current,
84580 rcu_torture_current_version,
84581 list_empty(&rcu_torture_freelist),
84582 - atomic_read(&n_rcu_torture_alloc),
84583 - atomic_read(&n_rcu_torture_alloc_fail),
84584 - atomic_read(&n_rcu_torture_free));
84585 + atomic_read_unchecked(&n_rcu_torture_alloc),
84586 + atomic_read_unchecked(&n_rcu_torture_alloc_fail),
84587 + atomic_read_unchecked(&n_rcu_torture_free));
84588 cnt += sprintf(&page[cnt], "rtmbe: %d rtbke: %ld rtbre: %ld ",
84589 - atomic_read(&n_rcu_torture_mberror),
84590 + atomic_read_unchecked(&n_rcu_torture_mberror),
84591 n_rcu_torture_boost_ktrerror,
84592 n_rcu_torture_boost_rterror);
84593 cnt += sprintf(&page[cnt], "rtbf: %ld rtb: %ld nt: %ld ",
84594 @@ -1094,14 +1094,14 @@ rcu_torture_printk(char *page)
84595 n_barrier_attempts,
84596 n_rcu_torture_barrier_error);
84597 cnt += sprintf(&page[cnt], "\n%s%s ", torture_type, TORTURE_FLAG);
84598 - if (atomic_read(&n_rcu_torture_mberror) != 0 ||
84599 + if (atomic_read_unchecked(&n_rcu_torture_mberror) != 0 ||
84600 n_rcu_torture_barrier_error != 0 ||
84601 n_rcu_torture_boost_ktrerror != 0 ||
84602 n_rcu_torture_boost_rterror != 0 ||
84603 n_rcu_torture_boost_failure != 0 ||
84604 i > 1) {
84605 cnt += sprintf(&page[cnt], "!!! ");
84606 - atomic_inc(&n_rcu_torture_error);
84607 + atomic_inc_unchecked(&n_rcu_torture_error);
84608 WARN_ON_ONCE(1);
84609 }
84610 cnt += sprintf(&page[cnt], "Reader Pipe: ");
84611 @@ -1115,7 +1115,7 @@ rcu_torture_printk(char *page)
84612 cnt += sprintf(&page[cnt], "Free-Block Circulation: ");
84613 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
84614 cnt += sprintf(&page[cnt], " %d",
84615 - atomic_read(&rcu_torture_wcount[i]));
84616 + atomic_read_unchecked(&rcu_torture_wcount[i]));
84617 }
84618 cnt += sprintf(&page[cnt], "\n");
84619 if (cur_ops->stats)
84620 @@ -1830,7 +1830,7 @@ rcu_torture_cleanup(void)
84621
84622 rcu_torture_stats_print(); /* -After- the stats thread is stopped! */
84623
84624 - if (atomic_read(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
84625 + if (atomic_read_unchecked(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
84626 rcu_torture_print_module_parms(cur_ops, "End of test: FAILURE");
84627 else if (n_online_successes != n_online_attempts ||
84628 n_offline_successes != n_offline_attempts)
84629 @@ -1952,18 +1952,18 @@ rcu_torture_init(void)
84630
84631 rcu_torture_current = NULL;
84632 rcu_torture_current_version = 0;
84633 - atomic_set(&n_rcu_torture_alloc, 0);
84634 - atomic_set(&n_rcu_torture_alloc_fail, 0);
84635 - atomic_set(&n_rcu_torture_free, 0);
84636 - atomic_set(&n_rcu_torture_mberror, 0);
84637 - atomic_set(&n_rcu_torture_error, 0);
84638 + atomic_set_unchecked(&n_rcu_torture_alloc, 0);
84639 + atomic_set_unchecked(&n_rcu_torture_alloc_fail, 0);
84640 + atomic_set_unchecked(&n_rcu_torture_free, 0);
84641 + atomic_set_unchecked(&n_rcu_torture_mberror, 0);
84642 + atomic_set_unchecked(&n_rcu_torture_error, 0);
84643 n_rcu_torture_barrier_error = 0;
84644 n_rcu_torture_boost_ktrerror = 0;
84645 n_rcu_torture_boost_rterror = 0;
84646 n_rcu_torture_boost_failure = 0;
84647 n_rcu_torture_boosts = 0;
84648 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++)
84649 - atomic_set(&rcu_torture_wcount[i], 0);
84650 + atomic_set_unchecked(&rcu_torture_wcount[i], 0);
84651 for_each_possible_cpu(cpu) {
84652 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
84653 per_cpu(rcu_torture_count, cpu)[i] = 0;
84654 diff --git a/kernel/rcutree.c b/kernel/rcutree.c
84655 index 32618b3..c1fb822 100644
84656 --- a/kernel/rcutree.c
84657 +++ b/kernel/rcutree.c
84658 @@ -382,9 +382,9 @@ static void rcu_eqs_enter_common(struct rcu_dynticks *rdtp, long long oldval,
84659 rcu_prepare_for_idle(smp_processor_id());
84660 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
84661 smp_mb__before_atomic_inc(); /* See above. */
84662 - atomic_inc(&rdtp->dynticks);
84663 + atomic_inc_unchecked(&rdtp->dynticks);
84664 smp_mb__after_atomic_inc(); /* Force ordering with next sojourn. */
84665 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
84666 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
84667
84668 /*
84669 * It is illegal to enter an extended quiescent state while
84670 @@ -501,10 +501,10 @@ static void rcu_eqs_exit_common(struct rcu_dynticks *rdtp, long long oldval,
84671 int user)
84672 {
84673 smp_mb__before_atomic_inc(); /* Force ordering w/previous sojourn. */
84674 - atomic_inc(&rdtp->dynticks);
84675 + atomic_inc_unchecked(&rdtp->dynticks);
84676 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
84677 smp_mb__after_atomic_inc(); /* See above. */
84678 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
84679 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
84680 rcu_cleanup_after_idle(smp_processor_id());
84681 trace_rcu_dyntick(TPS("End"), oldval, rdtp->dynticks_nesting);
84682 if (!user && !is_idle_task(current)) {
84683 @@ -623,14 +623,14 @@ void rcu_nmi_enter(void)
84684 struct rcu_dynticks *rdtp = &__get_cpu_var(rcu_dynticks);
84685
84686 if (rdtp->dynticks_nmi_nesting == 0 &&
84687 - (atomic_read(&rdtp->dynticks) & 0x1))
84688 + (atomic_read_unchecked(&rdtp->dynticks) & 0x1))
84689 return;
84690 rdtp->dynticks_nmi_nesting++;
84691 smp_mb__before_atomic_inc(); /* Force delay from prior write. */
84692 - atomic_inc(&rdtp->dynticks);
84693 + atomic_inc_unchecked(&rdtp->dynticks);
84694 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
84695 smp_mb__after_atomic_inc(); /* See above. */
84696 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
84697 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
84698 }
84699
84700 /**
84701 @@ -649,9 +649,9 @@ void rcu_nmi_exit(void)
84702 return;
84703 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
84704 smp_mb__before_atomic_inc(); /* See above. */
84705 - atomic_inc(&rdtp->dynticks);
84706 + atomic_inc_unchecked(&rdtp->dynticks);
84707 smp_mb__after_atomic_inc(); /* Force delay to next write. */
84708 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
84709 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
84710 }
84711
84712 /**
84713 @@ -665,7 +665,7 @@ int rcu_is_cpu_idle(void)
84714 int ret;
84715
84716 preempt_disable();
84717 - ret = (atomic_read(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
84718 + ret = (atomic_read_unchecked(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
84719 preempt_enable();
84720 return ret;
84721 }
84722 @@ -734,7 +734,7 @@ static int rcu_is_cpu_rrupt_from_idle(void)
84723 static int dyntick_save_progress_counter(struct rcu_data *rdp,
84724 bool *isidle, unsigned long *maxj)
84725 {
84726 - rdp->dynticks_snap = atomic_add_return(0, &rdp->dynticks->dynticks);
84727 + rdp->dynticks_snap = atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
84728 rcu_sysidle_check_cpu(rdp, isidle, maxj);
84729 return (rdp->dynticks_snap & 0x1) == 0;
84730 }
84731 @@ -751,7 +751,7 @@ static int rcu_implicit_dynticks_qs(struct rcu_data *rdp,
84732 unsigned int curr;
84733 unsigned int snap;
84734
84735 - curr = (unsigned int)atomic_add_return(0, &rdp->dynticks->dynticks);
84736 + curr = (unsigned int)atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
84737 snap = (unsigned int)rdp->dynticks_snap;
84738
84739 /*
84740 @@ -1341,9 +1341,9 @@ static int rcu_gp_init(struct rcu_state *rsp)
84741 rdp = this_cpu_ptr(rsp->rda);
84742 rcu_preempt_check_blocked_tasks(rnp);
84743 rnp->qsmask = rnp->qsmaskinit;
84744 - ACCESS_ONCE(rnp->gpnum) = rsp->gpnum;
84745 + ACCESS_ONCE_RW(rnp->gpnum) = rsp->gpnum;
84746 WARN_ON_ONCE(rnp->completed != rsp->completed);
84747 - ACCESS_ONCE(rnp->completed) = rsp->completed;
84748 + ACCESS_ONCE_RW(rnp->completed) = rsp->completed;
84749 if (rnp == rdp->mynode)
84750 __note_gp_changes(rsp, rnp, rdp);
84751 rcu_preempt_boost_start_gp(rnp);
84752 @@ -1434,7 +1434,7 @@ static void rcu_gp_cleanup(struct rcu_state *rsp)
84753 */
84754 rcu_for_each_node_breadth_first(rsp, rnp) {
84755 raw_spin_lock_irq(&rnp->lock);
84756 - ACCESS_ONCE(rnp->completed) = rsp->gpnum;
84757 + ACCESS_ONCE_RW(rnp->completed) = rsp->gpnum;
84758 rdp = this_cpu_ptr(rsp->rda);
84759 if (rnp == rdp->mynode)
84760 __note_gp_changes(rsp, rnp, rdp);
84761 @@ -1766,7 +1766,7 @@ rcu_send_cbs_to_orphanage(int cpu, struct rcu_state *rsp,
84762 rsp->qlen += rdp->qlen;
84763 rdp->n_cbs_orphaned += rdp->qlen;
84764 rdp->qlen_lazy = 0;
84765 - ACCESS_ONCE(rdp->qlen) = 0;
84766 + ACCESS_ONCE_RW(rdp->qlen) = 0;
84767 }
84768
84769 /*
84770 @@ -2012,7 +2012,7 @@ static void rcu_do_batch(struct rcu_state *rsp, struct rcu_data *rdp)
84771 }
84772 smp_mb(); /* List handling before counting for rcu_barrier(). */
84773 rdp->qlen_lazy -= count_lazy;
84774 - ACCESS_ONCE(rdp->qlen) -= count;
84775 + ACCESS_ONCE_RW(rdp->qlen) -= count;
84776 rdp->n_cbs_invoked += count;
84777
84778 /* Reinstate batch limit if we have worked down the excess. */
84779 @@ -2209,7 +2209,7 @@ __rcu_process_callbacks(struct rcu_state *rsp)
84780 /*
84781 * Do RCU core processing for the current CPU.
84782 */
84783 -static void rcu_process_callbacks(struct softirq_action *unused)
84784 +static __latent_entropy void rcu_process_callbacks(void)
84785 {
84786 struct rcu_state *rsp;
84787
84788 @@ -2316,7 +2316,7 @@ __call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu),
84789 WARN_ON_ONCE((unsigned long)head & 0x3); /* Misaligned rcu_head! */
84790 if (debug_rcu_head_queue(head)) {
84791 /* Probable double call_rcu(), so leak the callback. */
84792 - ACCESS_ONCE(head->func) = rcu_leak_callback;
84793 + ACCESS_ONCE_RW(head->func) = rcu_leak_callback;
84794 WARN_ONCE(1, "__call_rcu(): Leaked duplicate callback\n");
84795 return;
84796 }
84797 @@ -2344,7 +2344,7 @@ __call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu),
84798 local_irq_restore(flags);
84799 return;
84800 }
84801 - ACCESS_ONCE(rdp->qlen)++;
84802 + ACCESS_ONCE_RW(rdp->qlen)++;
84803 if (lazy)
84804 rdp->qlen_lazy++;
84805 else
84806 @@ -2553,11 +2553,11 @@ void synchronize_sched_expedited(void)
84807 * counter wrap on a 32-bit system. Quite a few more CPUs would of
84808 * course be required on a 64-bit system.
84809 */
84810 - if (ULONG_CMP_GE((ulong)atomic_long_read(&rsp->expedited_start),
84811 + if (ULONG_CMP_GE((ulong)atomic_long_read_unchecked(&rsp->expedited_start),
84812 (ulong)atomic_long_read(&rsp->expedited_done) +
84813 ULONG_MAX / 8)) {
84814 synchronize_sched();
84815 - atomic_long_inc(&rsp->expedited_wrap);
84816 + atomic_long_inc_unchecked(&rsp->expedited_wrap);
84817 return;
84818 }
84819
84820 @@ -2565,7 +2565,7 @@ void synchronize_sched_expedited(void)
84821 * Take a ticket. Note that atomic_inc_return() implies a
84822 * full memory barrier.
84823 */
84824 - snap = atomic_long_inc_return(&rsp->expedited_start);
84825 + snap = atomic_long_inc_return_unchecked(&rsp->expedited_start);
84826 firstsnap = snap;
84827 get_online_cpus();
84828 WARN_ON_ONCE(cpu_is_offline(raw_smp_processor_id()));
84829 @@ -2578,14 +2578,14 @@ void synchronize_sched_expedited(void)
84830 synchronize_sched_expedited_cpu_stop,
84831 NULL) == -EAGAIN) {
84832 put_online_cpus();
84833 - atomic_long_inc(&rsp->expedited_tryfail);
84834 + atomic_long_inc_unchecked(&rsp->expedited_tryfail);
84835
84836 /* Check to see if someone else did our work for us. */
84837 s = atomic_long_read(&rsp->expedited_done);
84838 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
84839 /* ensure test happens before caller kfree */
84840 smp_mb__before_atomic_inc(); /* ^^^ */
84841 - atomic_long_inc(&rsp->expedited_workdone1);
84842 + atomic_long_inc_unchecked(&rsp->expedited_workdone1);
84843 return;
84844 }
84845
84846 @@ -2594,7 +2594,7 @@ void synchronize_sched_expedited(void)
84847 udelay(trycount * num_online_cpus());
84848 } else {
84849 wait_rcu_gp(call_rcu_sched);
84850 - atomic_long_inc(&rsp->expedited_normal);
84851 + atomic_long_inc_unchecked(&rsp->expedited_normal);
84852 return;
84853 }
84854
84855 @@ -2603,7 +2603,7 @@ void synchronize_sched_expedited(void)
84856 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
84857 /* ensure test happens before caller kfree */
84858 smp_mb__before_atomic_inc(); /* ^^^ */
84859 - atomic_long_inc(&rsp->expedited_workdone2);
84860 + atomic_long_inc_unchecked(&rsp->expedited_workdone2);
84861 return;
84862 }
84863
84864 @@ -2615,10 +2615,10 @@ void synchronize_sched_expedited(void)
84865 * period works for us.
84866 */
84867 get_online_cpus();
84868 - snap = atomic_long_read(&rsp->expedited_start);
84869 + snap = atomic_long_read_unchecked(&rsp->expedited_start);
84870 smp_mb(); /* ensure read is before try_stop_cpus(). */
84871 }
84872 - atomic_long_inc(&rsp->expedited_stoppedcpus);
84873 + atomic_long_inc_unchecked(&rsp->expedited_stoppedcpus);
84874
84875 /*
84876 * Everyone up to our most recent fetch is covered by our grace
84877 @@ -2627,16 +2627,16 @@ void synchronize_sched_expedited(void)
84878 * than we did already did their update.
84879 */
84880 do {
84881 - atomic_long_inc(&rsp->expedited_done_tries);
84882 + atomic_long_inc_unchecked(&rsp->expedited_done_tries);
84883 s = atomic_long_read(&rsp->expedited_done);
84884 if (ULONG_CMP_GE((ulong)s, (ulong)snap)) {
84885 /* ensure test happens before caller kfree */
84886 smp_mb__before_atomic_inc(); /* ^^^ */
84887 - atomic_long_inc(&rsp->expedited_done_lost);
84888 + atomic_long_inc_unchecked(&rsp->expedited_done_lost);
84889 break;
84890 }
84891 } while (atomic_long_cmpxchg(&rsp->expedited_done, s, snap) != s);
84892 - atomic_long_inc(&rsp->expedited_done_exit);
84893 + atomic_long_inc_unchecked(&rsp->expedited_done_exit);
84894
84895 put_online_cpus();
84896 }
84897 @@ -2829,7 +2829,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
84898 * ACCESS_ONCE() to prevent the compiler from speculating
84899 * the increment to precede the early-exit check.
84900 */
84901 - ACCESS_ONCE(rsp->n_barrier_done)++;
84902 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
84903 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 1);
84904 _rcu_barrier_trace(rsp, "Inc1", -1, rsp->n_barrier_done);
84905 smp_mb(); /* Order ->n_barrier_done increment with below mechanism. */
84906 @@ -2879,7 +2879,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
84907
84908 /* Increment ->n_barrier_done to prevent duplicate work. */
84909 smp_mb(); /* Keep increment after above mechanism. */
84910 - ACCESS_ONCE(rsp->n_barrier_done)++;
84911 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
84912 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 0);
84913 _rcu_barrier_trace(rsp, "Inc2", -1, rsp->n_barrier_done);
84914 smp_mb(); /* Keep increment before caller's subsequent code. */
84915 @@ -2924,10 +2924,10 @@ rcu_boot_init_percpu_data(int cpu, struct rcu_state *rsp)
84916 rdp->grpmask = 1UL << (cpu - rdp->mynode->grplo);
84917 init_callback_list(rdp);
84918 rdp->qlen_lazy = 0;
84919 - ACCESS_ONCE(rdp->qlen) = 0;
84920 + ACCESS_ONCE_RW(rdp->qlen) = 0;
84921 rdp->dynticks = &per_cpu(rcu_dynticks, cpu);
84922 WARN_ON_ONCE(rdp->dynticks->dynticks_nesting != DYNTICK_TASK_EXIT_IDLE);
84923 - WARN_ON_ONCE(atomic_read(&rdp->dynticks->dynticks) != 1);
84924 + WARN_ON_ONCE(atomic_read_unchecked(&rdp->dynticks->dynticks) != 1);
84925 rdp->cpu = cpu;
84926 rdp->rsp = rsp;
84927 rcu_boot_init_nocb_percpu_data(rdp);
84928 @@ -2961,8 +2961,8 @@ rcu_init_percpu_data(int cpu, struct rcu_state *rsp, int preemptible)
84929 init_callback_list(rdp); /* Re-enable callbacks on this CPU. */
84930 rdp->dynticks->dynticks_nesting = DYNTICK_TASK_EXIT_IDLE;
84931 rcu_sysidle_init_percpu_data(rdp->dynticks);
84932 - atomic_set(&rdp->dynticks->dynticks,
84933 - (atomic_read(&rdp->dynticks->dynticks) & ~0x1) + 1);
84934 + atomic_set_unchecked(&rdp->dynticks->dynticks,
84935 + (atomic_read_unchecked(&rdp->dynticks->dynticks) & ~0x1) + 1);
84936 raw_spin_unlock(&rnp->lock); /* irqs remain disabled. */
84937
84938 /* Add CPU to rcu_node bitmasks. */
84939 diff --git a/kernel/rcutree.h b/kernel/rcutree.h
84940 index 5f97eab..db8f687 100644
84941 --- a/kernel/rcutree.h
84942 +++ b/kernel/rcutree.h
84943 @@ -87,11 +87,11 @@ struct rcu_dynticks {
84944 long long dynticks_nesting; /* Track irq/process nesting level. */
84945 /* Process level is worth LLONG_MAX/2. */
84946 int dynticks_nmi_nesting; /* Track NMI nesting level. */
84947 - atomic_t dynticks; /* Even value for idle, else odd. */
84948 + atomic_unchecked_t dynticks;/* Even value for idle, else odd. */
84949 #ifdef CONFIG_NO_HZ_FULL_SYSIDLE
84950 long long dynticks_idle_nesting;
84951 /* irq/process nesting level from idle. */
84952 - atomic_t dynticks_idle; /* Even value for idle, else odd. */
84953 + atomic_unchecked_t dynticks_idle; /* Even value for idle, else odd. */
84954 /* "Idle" excludes userspace execution. */
84955 unsigned long dynticks_idle_jiffies;
84956 /* End of last non-NMI non-idle period. */
84957 @@ -427,17 +427,17 @@ struct rcu_state {
84958 /* _rcu_barrier(). */
84959 /* End of fields guarded by barrier_mutex. */
84960
84961 - atomic_long_t expedited_start; /* Starting ticket. */
84962 - atomic_long_t expedited_done; /* Done ticket. */
84963 - atomic_long_t expedited_wrap; /* # near-wrap incidents. */
84964 - atomic_long_t expedited_tryfail; /* # acquisition failures. */
84965 - atomic_long_t expedited_workdone1; /* # done by others #1. */
84966 - atomic_long_t expedited_workdone2; /* # done by others #2. */
84967 - atomic_long_t expedited_normal; /* # fallbacks to normal. */
84968 - atomic_long_t expedited_stoppedcpus; /* # successful stop_cpus. */
84969 - atomic_long_t expedited_done_tries; /* # tries to update _done. */
84970 - atomic_long_t expedited_done_lost; /* # times beaten to _done. */
84971 - atomic_long_t expedited_done_exit; /* # times exited _done loop. */
84972 + atomic_long_unchecked_t expedited_start; /* Starting ticket. */
84973 + atomic_long_t expedited_done; /* Done ticket. */
84974 + atomic_long_unchecked_t expedited_wrap; /* # near-wrap incidents. */
84975 + atomic_long_unchecked_t expedited_tryfail; /* # acquisition failures. */
84976 + atomic_long_unchecked_t expedited_workdone1; /* # done by others #1. */
84977 + atomic_long_unchecked_t expedited_workdone2; /* # done by others #2. */
84978 + atomic_long_unchecked_t expedited_normal; /* # fallbacks to normal. */
84979 + atomic_long_unchecked_t expedited_stoppedcpus; /* # successful stop_cpus. */
84980 + atomic_long_unchecked_t expedited_done_tries; /* # tries to update _done. */
84981 + atomic_long_unchecked_t expedited_done_lost; /* # times beaten to _done. */
84982 + atomic_long_unchecked_t expedited_done_exit; /* # times exited _done loop. */
84983
84984 unsigned long jiffies_force_qs; /* Time at which to invoke */
84985 /* force_quiescent_state(). */
84986 diff --git a/kernel/rcutree_plugin.h b/kernel/rcutree_plugin.h
84987 index 130c97b..bcbe7f7 100644
84988 --- a/kernel/rcutree_plugin.h
84989 +++ b/kernel/rcutree_plugin.h
84990 @@ -744,7 +744,7 @@ static int rcu_preempted_readers_exp(struct rcu_node *rnp)
84991 static int sync_rcu_preempt_exp_done(struct rcu_node *rnp)
84992 {
84993 return !rcu_preempted_readers_exp(rnp) &&
84994 - ACCESS_ONCE(rnp->expmask) == 0;
84995 + ACCESS_ONCE_RW(rnp->expmask) == 0;
84996 }
84997
84998 /*
84999 @@ -900,7 +900,7 @@ void synchronize_rcu_expedited(void)
85000
85001 /* Clean up and exit. */
85002 smp_mb(); /* ensure expedited GP seen before counter increment. */
85003 - ACCESS_ONCE(sync_rcu_preempt_exp_count)++;
85004 + ACCESS_ONCE_RW(sync_rcu_preempt_exp_count)++;
85005 unlock_mb_ret:
85006 mutex_unlock(&sync_rcu_preempt_exp_mutex);
85007 mb_ret:
85008 @@ -1474,7 +1474,7 @@ static void rcu_boost_kthread_setaffinity(struct rcu_node *rnp, int outgoingcpu)
85009 free_cpumask_var(cm);
85010 }
85011
85012 -static struct smp_hotplug_thread rcu_cpu_thread_spec = {
85013 +static struct smp_hotplug_thread rcu_cpu_thread_spec __read_only = {
85014 .store = &rcu_cpu_kthread_task,
85015 .thread_should_run = rcu_cpu_kthread_should_run,
85016 .thread_fn = rcu_cpu_kthread,
85017 @@ -1939,7 +1939,7 @@ static void print_cpu_stall_info(struct rcu_state *rsp, int cpu)
85018 print_cpu_stall_fast_no_hz(fast_no_hz, cpu);
85019 pr_err("\t%d: (%lu %s) idle=%03x/%llx/%d softirq=%u/%u %s\n",
85020 cpu, ticks_value, ticks_title,
85021 - atomic_read(&rdtp->dynticks) & 0xfff,
85022 + atomic_read_unchecked(&rdtp->dynticks) & 0xfff,
85023 rdtp->dynticks_nesting, rdtp->dynticks_nmi_nesting,
85024 rdp->softirq_snap, kstat_softirqs_cpu(RCU_SOFTIRQ, cpu),
85025 fast_no_hz);
85026 @@ -2102,7 +2102,7 @@ static void __call_rcu_nocb_enqueue(struct rcu_data *rdp,
85027
85028 /* Enqueue the callback on the nocb list and update counts. */
85029 old_rhpp = xchg(&rdp->nocb_tail, rhtp);
85030 - ACCESS_ONCE(*old_rhpp) = rhp;
85031 + ACCESS_ONCE_RW(*old_rhpp) = rhp;
85032 atomic_long_add(rhcount, &rdp->nocb_q_count);
85033 atomic_long_add(rhcount_lazy, &rdp->nocb_q_count_lazy);
85034
85035 @@ -2242,12 +2242,12 @@ static int rcu_nocb_kthread(void *arg)
85036 * Extract queued callbacks, update counts, and wait
85037 * for a grace period to elapse.
85038 */
85039 - ACCESS_ONCE(rdp->nocb_head) = NULL;
85040 + ACCESS_ONCE_RW(rdp->nocb_head) = NULL;
85041 tail = xchg(&rdp->nocb_tail, &rdp->nocb_head);
85042 c = atomic_long_xchg(&rdp->nocb_q_count, 0);
85043 cl = atomic_long_xchg(&rdp->nocb_q_count_lazy, 0);
85044 - ACCESS_ONCE(rdp->nocb_p_count) += c;
85045 - ACCESS_ONCE(rdp->nocb_p_count_lazy) += cl;
85046 + ACCESS_ONCE_RW(rdp->nocb_p_count) += c;
85047 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) += cl;
85048 rcu_nocb_wait_gp(rdp);
85049
85050 /* Each pass through the following loop invokes a callback. */
85051 @@ -2269,8 +2269,8 @@ static int rcu_nocb_kthread(void *arg)
85052 list = next;
85053 }
85054 trace_rcu_batch_end(rdp->rsp->name, c, !!list, 0, 0, 1);
85055 - ACCESS_ONCE(rdp->nocb_p_count) -= c;
85056 - ACCESS_ONCE(rdp->nocb_p_count_lazy) -= cl;
85057 + ACCESS_ONCE_RW(rdp->nocb_p_count) -= c;
85058 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) -= cl;
85059 rdp->n_nocbs_invoked += c;
85060 }
85061 return 0;
85062 @@ -2297,7 +2297,7 @@ static void __init rcu_spawn_nocb_kthreads(struct rcu_state *rsp)
85063 t = kthread_run(rcu_nocb_kthread, rdp,
85064 "rcuo%c/%d", rsp->abbr, cpu);
85065 BUG_ON(IS_ERR(t));
85066 - ACCESS_ONCE(rdp->nocb_kthread) = t;
85067 + ACCESS_ONCE_RW(rdp->nocb_kthread) = t;
85068 }
85069 }
85070
85071 @@ -2423,11 +2423,11 @@ static void rcu_sysidle_enter(struct rcu_dynticks *rdtp, int irq)
85072
85073 /* Record start of fully idle period. */
85074 j = jiffies;
85075 - ACCESS_ONCE(rdtp->dynticks_idle_jiffies) = j;
85076 + ACCESS_ONCE_RW(rdtp->dynticks_idle_jiffies) = j;
85077 smp_mb__before_atomic_inc();
85078 - atomic_inc(&rdtp->dynticks_idle);
85079 + atomic_inc_unchecked(&rdtp->dynticks_idle);
85080 smp_mb__after_atomic_inc();
85081 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks_idle) & 0x1);
85082 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks_idle) & 0x1);
85083 }
85084
85085 /*
85086 @@ -2492,9 +2492,9 @@ static void rcu_sysidle_exit(struct rcu_dynticks *rdtp, int irq)
85087
85088 /* Record end of idle period. */
85089 smp_mb__before_atomic_inc();
85090 - atomic_inc(&rdtp->dynticks_idle);
85091 + atomic_inc_unchecked(&rdtp->dynticks_idle);
85092 smp_mb__after_atomic_inc();
85093 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks_idle) & 0x1));
85094 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks_idle) & 0x1));
85095
85096 /*
85097 * If we are the timekeeping CPU, we are permitted to be non-idle
85098 @@ -2535,7 +2535,7 @@ static void rcu_sysidle_check_cpu(struct rcu_data *rdp, bool *isidle,
85099 WARN_ON_ONCE(smp_processor_id() != tick_do_timer_cpu);
85100
85101 /* Pick up current idle and NMI-nesting counter and check. */
85102 - cur = atomic_read(&rdtp->dynticks_idle);
85103 + cur = atomic_read_unchecked(&rdtp->dynticks_idle);
85104 if (cur & 0x1) {
85105 *isidle = false; /* We are not idle! */
85106 return;
85107 @@ -2598,7 +2598,7 @@ static void rcu_sysidle(unsigned long j)
85108 case RCU_SYSIDLE_NOT:
85109
85110 /* First time all are idle, so note a short idle period. */
85111 - ACCESS_ONCE(full_sysidle_state) = RCU_SYSIDLE_SHORT;
85112 + ACCESS_ONCE_RW(full_sysidle_state) = RCU_SYSIDLE_SHORT;
85113 break;
85114
85115 case RCU_SYSIDLE_SHORT:
85116 @@ -2635,7 +2635,7 @@ static void rcu_sysidle(unsigned long j)
85117 static void rcu_sysidle_cancel(void)
85118 {
85119 smp_mb();
85120 - ACCESS_ONCE(full_sysidle_state) = RCU_SYSIDLE_NOT;
85121 + ACCESS_ONCE_RW(full_sysidle_state) = RCU_SYSIDLE_NOT;
85122 }
85123
85124 /*
85125 @@ -2683,7 +2683,7 @@ static void rcu_sysidle_cb(struct rcu_head *rhp)
85126 smp_mb(); /* grace period precedes setting inuse. */
85127
85128 rshp = container_of(rhp, struct rcu_sysidle_head, rh);
85129 - ACCESS_ONCE(rshp->inuse) = 0;
85130 + ACCESS_ONCE_RW(rshp->inuse) = 0;
85131 }
85132
85133 /*
85134 diff --git a/kernel/rcutree_trace.c b/kernel/rcutree_trace.c
85135 index cf6c174..a8f4b50 100644
85136 --- a/kernel/rcutree_trace.c
85137 +++ b/kernel/rcutree_trace.c
85138 @@ -121,7 +121,7 @@ static void print_one_rcu_data(struct seq_file *m, struct rcu_data *rdp)
85139 ulong2long(rdp->completed), ulong2long(rdp->gpnum),
85140 rdp->passed_quiesce, rdp->qs_pending);
85141 seq_printf(m, " dt=%d/%llx/%d df=%lu",
85142 - atomic_read(&rdp->dynticks->dynticks),
85143 + atomic_read_unchecked(&rdp->dynticks->dynticks),
85144 rdp->dynticks->dynticks_nesting,
85145 rdp->dynticks->dynticks_nmi_nesting,
85146 rdp->dynticks_fqs);
85147 @@ -182,17 +182,17 @@ static int show_rcuexp(struct seq_file *m, void *v)
85148 struct rcu_state *rsp = (struct rcu_state *)m->private;
85149
85150 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",
85151 - atomic_long_read(&rsp->expedited_start),
85152 + atomic_long_read_unchecked(&rsp->expedited_start),
85153 atomic_long_read(&rsp->expedited_done),
85154 - atomic_long_read(&rsp->expedited_wrap),
85155 - atomic_long_read(&rsp->expedited_tryfail),
85156 - atomic_long_read(&rsp->expedited_workdone1),
85157 - atomic_long_read(&rsp->expedited_workdone2),
85158 - atomic_long_read(&rsp->expedited_normal),
85159 - atomic_long_read(&rsp->expedited_stoppedcpus),
85160 - atomic_long_read(&rsp->expedited_done_tries),
85161 - atomic_long_read(&rsp->expedited_done_lost),
85162 - atomic_long_read(&rsp->expedited_done_exit));
85163 + atomic_long_read_unchecked(&rsp->expedited_wrap),
85164 + atomic_long_read_unchecked(&rsp->expedited_tryfail),
85165 + atomic_long_read_unchecked(&rsp->expedited_workdone1),
85166 + atomic_long_read_unchecked(&rsp->expedited_workdone2),
85167 + atomic_long_read_unchecked(&rsp->expedited_normal),
85168 + atomic_long_read_unchecked(&rsp->expedited_stoppedcpus),
85169 + atomic_long_read_unchecked(&rsp->expedited_done_tries),
85170 + atomic_long_read_unchecked(&rsp->expedited_done_lost),
85171 + atomic_long_read_unchecked(&rsp->expedited_done_exit));
85172 return 0;
85173 }
85174
85175 diff --git a/kernel/resource.c b/kernel/resource.c
85176 index 3f285dc..5755f62 100644
85177 --- a/kernel/resource.c
85178 +++ b/kernel/resource.c
85179 @@ -152,8 +152,18 @@ static const struct file_operations proc_iomem_operations = {
85180
85181 static int __init ioresources_init(void)
85182 {
85183 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
85184 +#ifdef CONFIG_GRKERNSEC_PROC_USER
85185 + proc_create("ioports", S_IRUSR, NULL, &proc_ioports_operations);
85186 + proc_create("iomem", S_IRUSR, NULL, &proc_iomem_operations);
85187 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
85188 + proc_create("ioports", S_IRUSR | S_IRGRP, NULL, &proc_ioports_operations);
85189 + proc_create("iomem", S_IRUSR | S_IRGRP, NULL, &proc_iomem_operations);
85190 +#endif
85191 +#else
85192 proc_create("ioports", 0, NULL, &proc_ioports_operations);
85193 proc_create("iomem", 0, NULL, &proc_iomem_operations);
85194 +#endif
85195 return 0;
85196 }
85197 __initcall(ioresources_init);
85198 diff --git a/kernel/rtmutex-tester.c b/kernel/rtmutex-tester.c
85199 index 1d96dd0..994ff19 100644
85200 --- a/kernel/rtmutex-tester.c
85201 +++ b/kernel/rtmutex-tester.c
85202 @@ -22,7 +22,7 @@
85203 #define MAX_RT_TEST_MUTEXES 8
85204
85205 static spinlock_t rttest_lock;
85206 -static atomic_t rttest_event;
85207 +static atomic_unchecked_t rttest_event;
85208
85209 struct test_thread_data {
85210 int opcode;
85211 @@ -63,7 +63,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
85212
85213 case RTTEST_LOCKCONT:
85214 td->mutexes[td->opdata] = 1;
85215 - td->event = atomic_add_return(1, &rttest_event);
85216 + td->event = atomic_add_return_unchecked(1, &rttest_event);
85217 return 0;
85218
85219 case RTTEST_RESET:
85220 @@ -76,7 +76,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
85221 return 0;
85222
85223 case RTTEST_RESETEVENT:
85224 - atomic_set(&rttest_event, 0);
85225 + atomic_set_unchecked(&rttest_event, 0);
85226 return 0;
85227
85228 default:
85229 @@ -93,9 +93,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
85230 return ret;
85231
85232 td->mutexes[id] = 1;
85233 - td->event = atomic_add_return(1, &rttest_event);
85234 + td->event = atomic_add_return_unchecked(1, &rttest_event);
85235 rt_mutex_lock(&mutexes[id]);
85236 - td->event = atomic_add_return(1, &rttest_event);
85237 + td->event = atomic_add_return_unchecked(1, &rttest_event);
85238 td->mutexes[id] = 4;
85239 return 0;
85240
85241 @@ -106,9 +106,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
85242 return ret;
85243
85244 td->mutexes[id] = 1;
85245 - td->event = atomic_add_return(1, &rttest_event);
85246 + td->event = atomic_add_return_unchecked(1, &rttest_event);
85247 ret = rt_mutex_lock_interruptible(&mutexes[id], 0);
85248 - td->event = atomic_add_return(1, &rttest_event);
85249 + td->event = atomic_add_return_unchecked(1, &rttest_event);
85250 td->mutexes[id] = ret ? 0 : 4;
85251 return ret ? -EINTR : 0;
85252
85253 @@ -117,9 +117,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
85254 if (id < 0 || id >= MAX_RT_TEST_MUTEXES || td->mutexes[id] != 4)
85255 return ret;
85256
85257 - td->event = atomic_add_return(1, &rttest_event);
85258 + td->event = atomic_add_return_unchecked(1, &rttest_event);
85259 rt_mutex_unlock(&mutexes[id]);
85260 - td->event = atomic_add_return(1, &rttest_event);
85261 + td->event = atomic_add_return_unchecked(1, &rttest_event);
85262 td->mutexes[id] = 0;
85263 return 0;
85264
85265 @@ -166,7 +166,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
85266 break;
85267
85268 td->mutexes[dat] = 2;
85269 - td->event = atomic_add_return(1, &rttest_event);
85270 + td->event = atomic_add_return_unchecked(1, &rttest_event);
85271 break;
85272
85273 default:
85274 @@ -186,7 +186,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
85275 return;
85276
85277 td->mutexes[dat] = 3;
85278 - td->event = atomic_add_return(1, &rttest_event);
85279 + td->event = atomic_add_return_unchecked(1, &rttest_event);
85280 break;
85281
85282 case RTTEST_LOCKNOWAIT:
85283 @@ -198,7 +198,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
85284 return;
85285
85286 td->mutexes[dat] = 1;
85287 - td->event = atomic_add_return(1, &rttest_event);
85288 + td->event = atomic_add_return_unchecked(1, &rttest_event);
85289 return;
85290
85291 default:
85292 diff --git a/kernel/sched/auto_group.c b/kernel/sched/auto_group.c
85293 index 4a07353..66b5291 100644
85294 --- a/kernel/sched/auto_group.c
85295 +++ b/kernel/sched/auto_group.c
85296 @@ -11,7 +11,7 @@
85297
85298 unsigned int __read_mostly sysctl_sched_autogroup_enabled = 1;
85299 static struct autogroup autogroup_default;
85300 -static atomic_t autogroup_seq_nr;
85301 +static atomic_unchecked_t autogroup_seq_nr;
85302
85303 void __init autogroup_init(struct task_struct *init_task)
85304 {
85305 @@ -79,7 +79,7 @@ static inline struct autogroup *autogroup_create(void)
85306
85307 kref_init(&ag->kref);
85308 init_rwsem(&ag->lock);
85309 - ag->id = atomic_inc_return(&autogroup_seq_nr);
85310 + ag->id = atomic_inc_return_unchecked(&autogroup_seq_nr);
85311 ag->tg = tg;
85312 #ifdef CONFIG_RT_GROUP_SCHED
85313 /*
85314 diff --git a/kernel/sched/core.c b/kernel/sched/core.c
85315 index 5ac63c9..d912786 100644
85316 --- a/kernel/sched/core.c
85317 +++ b/kernel/sched/core.c
85318 @@ -2868,7 +2868,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible);
85319 * Return: -ERESTARTSYS if interrupted, 0 if timed out, positive (at least 1,
85320 * or number of jiffies left till timeout) if completed.
85321 */
85322 -long __sched
85323 +long __sched __intentional_overflow(-1)
85324 wait_for_completion_interruptible_timeout(struct completion *x,
85325 unsigned long timeout)
85326 {
85327 @@ -2885,7 +2885,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible_timeout);
85328 *
85329 * Return: -ERESTARTSYS if interrupted, 0 if completed.
85330 */
85331 -int __sched wait_for_completion_killable(struct completion *x)
85332 +int __sched __intentional_overflow(-1) wait_for_completion_killable(struct completion *x)
85333 {
85334 long t = wait_for_common(x, MAX_SCHEDULE_TIMEOUT, TASK_KILLABLE);
85335 if (t == -ERESTARTSYS)
85336 @@ -2906,7 +2906,7 @@ EXPORT_SYMBOL(wait_for_completion_killable);
85337 * Return: -ERESTARTSYS if interrupted, 0 if timed out, positive (at least 1,
85338 * or number of jiffies left till timeout) if completed.
85339 */
85340 -long __sched
85341 +long __sched __intentional_overflow(-1)
85342 wait_for_completion_killable_timeout(struct completion *x,
85343 unsigned long timeout)
85344 {
85345 @@ -3132,6 +3132,8 @@ int can_nice(const struct task_struct *p, const int nice)
85346 /* convert nice value [19,-20] to rlimit style value [1,40] */
85347 int nice_rlim = 20 - nice;
85348
85349 + gr_learn_resource(p, RLIMIT_NICE, nice_rlim, 1);
85350 +
85351 return (nice_rlim <= task_rlimit(p, RLIMIT_NICE) ||
85352 capable(CAP_SYS_NICE));
85353 }
85354 @@ -3165,7 +3167,8 @@ SYSCALL_DEFINE1(nice, int, increment)
85355 if (nice > 19)
85356 nice = 19;
85357
85358 - if (increment < 0 && !can_nice(current, nice))
85359 + if (increment < 0 && (!can_nice(current, nice) ||
85360 + gr_handle_chroot_nice()))
85361 return -EPERM;
85362
85363 retval = security_task_setnice(current, nice);
85364 @@ -3327,6 +3330,7 @@ recheck:
85365 unsigned long rlim_rtprio =
85366 task_rlimit(p, RLIMIT_RTPRIO);
85367
85368 + gr_learn_resource(p, RLIMIT_RTPRIO, param->sched_priority, 1);
85369 /* can't set/change the rt policy */
85370 if (policy != p->policy && !rlim_rtprio)
85371 return -EPERM;
85372 @@ -4456,7 +4460,7 @@ static void migrate_tasks(unsigned int dead_cpu)
85373
85374 #if defined(CONFIG_SCHED_DEBUG) && defined(CONFIG_SYSCTL)
85375
85376 -static struct ctl_table sd_ctl_dir[] = {
85377 +static ctl_table_no_const sd_ctl_dir[] __read_only = {
85378 {
85379 .procname = "sched_domain",
85380 .mode = 0555,
85381 @@ -4473,17 +4477,17 @@ static struct ctl_table sd_ctl_root[] = {
85382 {}
85383 };
85384
85385 -static struct ctl_table *sd_alloc_ctl_entry(int n)
85386 +static ctl_table_no_const *sd_alloc_ctl_entry(int n)
85387 {
85388 - struct ctl_table *entry =
85389 + ctl_table_no_const *entry =
85390 kcalloc(n, sizeof(struct ctl_table), GFP_KERNEL);
85391
85392 return entry;
85393 }
85394
85395 -static void sd_free_ctl_entry(struct ctl_table **tablep)
85396 +static void sd_free_ctl_entry(ctl_table_no_const *tablep)
85397 {
85398 - struct ctl_table *entry;
85399 + ctl_table_no_const *entry;
85400
85401 /*
85402 * In the intermediate directories, both the child directory and
85403 @@ -4491,22 +4495,25 @@ static void sd_free_ctl_entry(struct ctl_table **tablep)
85404 * will always be set. In the lowest directory the names are
85405 * static strings and all have proc handlers.
85406 */
85407 - for (entry = *tablep; entry->mode; entry++) {
85408 - if (entry->child)
85409 - sd_free_ctl_entry(&entry->child);
85410 + for (entry = tablep; entry->mode; entry++) {
85411 + if (entry->child) {
85412 + sd_free_ctl_entry(entry->child);
85413 + pax_open_kernel();
85414 + entry->child = NULL;
85415 + pax_close_kernel();
85416 + }
85417 if (entry->proc_handler == NULL)
85418 kfree(entry->procname);
85419 }
85420
85421 - kfree(*tablep);
85422 - *tablep = NULL;
85423 + kfree(tablep);
85424 }
85425
85426 static int min_load_idx = 0;
85427 static int max_load_idx = CPU_LOAD_IDX_MAX-1;
85428
85429 static void
85430 -set_table_entry(struct ctl_table *entry,
85431 +set_table_entry(ctl_table_no_const *entry,
85432 const char *procname, void *data, int maxlen,
85433 umode_t mode, proc_handler *proc_handler,
85434 bool load_idx)
85435 @@ -4526,7 +4533,7 @@ set_table_entry(struct ctl_table *entry,
85436 static struct ctl_table *
85437 sd_alloc_ctl_domain_table(struct sched_domain *sd)
85438 {
85439 - struct ctl_table *table = sd_alloc_ctl_entry(13);
85440 + ctl_table_no_const *table = sd_alloc_ctl_entry(13);
85441
85442 if (table == NULL)
85443 return NULL;
85444 @@ -4561,9 +4568,9 @@ sd_alloc_ctl_domain_table(struct sched_domain *sd)
85445 return table;
85446 }
85447
85448 -static struct ctl_table *sd_alloc_ctl_cpu_table(int cpu)
85449 +static ctl_table_no_const *sd_alloc_ctl_cpu_table(int cpu)
85450 {
85451 - struct ctl_table *entry, *table;
85452 + ctl_table_no_const *entry, *table;
85453 struct sched_domain *sd;
85454 int domain_num = 0, i;
85455 char buf[32];
85456 @@ -4590,11 +4597,13 @@ static struct ctl_table_header *sd_sysctl_header;
85457 static void register_sched_domain_sysctl(void)
85458 {
85459 int i, cpu_num = num_possible_cpus();
85460 - struct ctl_table *entry = sd_alloc_ctl_entry(cpu_num + 1);
85461 + ctl_table_no_const *entry = sd_alloc_ctl_entry(cpu_num + 1);
85462 char buf[32];
85463
85464 WARN_ON(sd_ctl_dir[0].child);
85465 + pax_open_kernel();
85466 sd_ctl_dir[0].child = entry;
85467 + pax_close_kernel();
85468
85469 if (entry == NULL)
85470 return;
85471 @@ -4617,8 +4626,12 @@ static void unregister_sched_domain_sysctl(void)
85472 if (sd_sysctl_header)
85473 unregister_sysctl_table(sd_sysctl_header);
85474 sd_sysctl_header = NULL;
85475 - if (sd_ctl_dir[0].child)
85476 - sd_free_ctl_entry(&sd_ctl_dir[0].child);
85477 + if (sd_ctl_dir[0].child) {
85478 + sd_free_ctl_entry(sd_ctl_dir[0].child);
85479 + pax_open_kernel();
85480 + sd_ctl_dir[0].child = NULL;
85481 + pax_close_kernel();
85482 + }
85483 }
85484 #else
85485 static void register_sched_domain_sysctl(void)
85486 diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
85487 index 513fc2f..906a851 100644
85488 --- a/kernel/sched/fair.c
85489 +++ b/kernel/sched/fair.c
85490 @@ -869,7 +869,7 @@ void task_numa_fault(int node, int pages, bool migrated)
85491
85492 static void reset_ptenuma_scan(struct task_struct *p)
85493 {
85494 - ACCESS_ONCE(p->mm->numa_scan_seq)++;
85495 + ACCESS_ONCE_RW(p->mm->numa_scan_seq)++;
85496 p->mm->numa_scan_offset = 0;
85497 }
85498
85499 @@ -5840,7 +5840,7 @@ static void nohz_idle_balance(int this_cpu, enum cpu_idle_type idle) { }
85500 * run_rebalance_domains is triggered when needed from the scheduler tick.
85501 * Also triggered for nohz idle balancing (with nohz_balancing_kick set).
85502 */
85503 -static void run_rebalance_domains(struct softirq_action *h)
85504 +static __latent_entropy void run_rebalance_domains(void)
85505 {
85506 int this_cpu = smp_processor_id();
85507 struct rq *this_rq = cpu_rq(this_cpu);
85508 diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
85509 index b3c5653..a4d192a 100644
85510 --- a/kernel/sched/sched.h
85511 +++ b/kernel/sched/sched.h
85512 @@ -1004,7 +1004,7 @@ struct sched_class {
85513 #ifdef CONFIG_FAIR_GROUP_SCHED
85514 void (*task_move_group) (struct task_struct *p, int on_rq);
85515 #endif
85516 -};
85517 +} __do_const;
85518
85519 #define sched_class_highest (&stop_sched_class)
85520 #define for_each_class(class) \
85521 diff --git a/kernel/signal.c b/kernel/signal.c
85522 index ded28b9..6886c08 100644
85523 --- a/kernel/signal.c
85524 +++ b/kernel/signal.c
85525 @@ -51,12 +51,12 @@ static struct kmem_cache *sigqueue_cachep;
85526
85527 int print_fatal_signals __read_mostly;
85528
85529 -static void __user *sig_handler(struct task_struct *t, int sig)
85530 +static __sighandler_t sig_handler(struct task_struct *t, int sig)
85531 {
85532 return t->sighand->action[sig - 1].sa.sa_handler;
85533 }
85534
85535 -static int sig_handler_ignored(void __user *handler, int sig)
85536 +static int sig_handler_ignored(__sighandler_t handler, int sig)
85537 {
85538 /* Is it explicitly or implicitly ignored? */
85539 return handler == SIG_IGN ||
85540 @@ -65,7 +65,7 @@ static int sig_handler_ignored(void __user *handler, int sig)
85541
85542 static int sig_task_ignored(struct task_struct *t, int sig, bool force)
85543 {
85544 - void __user *handler;
85545 + __sighandler_t handler;
85546
85547 handler = sig_handler(t, sig);
85548
85549 @@ -369,6 +369,9 @@ __sigqueue_alloc(int sig, struct task_struct *t, gfp_t flags, int override_rlimi
85550 atomic_inc(&user->sigpending);
85551 rcu_read_unlock();
85552
85553 + if (!override_rlimit)
85554 + gr_learn_resource(t, RLIMIT_SIGPENDING, atomic_read(&user->sigpending), 1);
85555 +
85556 if (override_rlimit ||
85557 atomic_read(&user->sigpending) <=
85558 task_rlimit(t, RLIMIT_SIGPENDING)) {
85559 @@ -496,7 +499,7 @@ flush_signal_handlers(struct task_struct *t, int force_default)
85560
85561 int unhandled_signal(struct task_struct *tsk, int sig)
85562 {
85563 - void __user *handler = tsk->sighand->action[sig-1].sa.sa_handler;
85564 + __sighandler_t handler = tsk->sighand->action[sig-1].sa.sa_handler;
85565 if (is_global_init(tsk))
85566 return 1;
85567 if (handler != SIG_IGN && handler != SIG_DFL)
85568 @@ -816,6 +819,13 @@ static int check_kill_permission(int sig, struct siginfo *info,
85569 }
85570 }
85571
85572 + /* allow glibc communication via tgkill to other threads in our
85573 + thread group */
85574 + if ((info == SEND_SIG_NOINFO || info->si_code != SI_TKILL ||
85575 + sig != (SIGRTMIN+1) || task_tgid_vnr(t) != info->si_pid)
85576 + && gr_handle_signal(t, sig))
85577 + return -EPERM;
85578 +
85579 return security_task_kill(t, info, sig, 0);
85580 }
85581
85582 @@ -1199,7 +1209,7 @@ __group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
85583 return send_signal(sig, info, p, 1);
85584 }
85585
85586 -static int
85587 +int
85588 specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t)
85589 {
85590 return send_signal(sig, info, t, 0);
85591 @@ -1236,6 +1246,7 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
85592 unsigned long int flags;
85593 int ret, blocked, ignored;
85594 struct k_sigaction *action;
85595 + int is_unhandled = 0;
85596
85597 spin_lock_irqsave(&t->sighand->siglock, flags);
85598 action = &t->sighand->action[sig-1];
85599 @@ -1250,9 +1261,18 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
85600 }
85601 if (action->sa.sa_handler == SIG_DFL)
85602 t->signal->flags &= ~SIGNAL_UNKILLABLE;
85603 + if (action->sa.sa_handler == SIG_IGN || action->sa.sa_handler == SIG_DFL)
85604 + is_unhandled = 1;
85605 ret = specific_send_sig_info(sig, info, t);
85606 spin_unlock_irqrestore(&t->sighand->siglock, flags);
85607
85608 + /* only deal with unhandled signals, java etc trigger SIGSEGV during
85609 + normal operation */
85610 + if (is_unhandled) {
85611 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, t);
85612 + gr_handle_crash(t, sig);
85613 + }
85614 +
85615 return ret;
85616 }
85617
85618 @@ -1319,8 +1339,11 @@ int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
85619 ret = check_kill_permission(sig, info, p);
85620 rcu_read_unlock();
85621
85622 - if (!ret && sig)
85623 + if (!ret && sig) {
85624 ret = do_send_sig_info(sig, info, p, true);
85625 + if (!ret)
85626 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, p);
85627 + }
85628
85629 return ret;
85630 }
85631 @@ -2926,7 +2949,15 @@ do_send_specific(pid_t tgid, pid_t pid, int sig, struct siginfo *info)
85632 int error = -ESRCH;
85633
85634 rcu_read_lock();
85635 - p = find_task_by_vpid(pid);
85636 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
85637 + /* allow glibc communication via tgkill to other threads in our
85638 + thread group */
85639 + if (grsec_enable_chroot_findtask && info->si_code == SI_TKILL &&
85640 + sig == (SIGRTMIN+1) && tgid == info->si_pid)
85641 + p = find_task_by_vpid_unrestricted(pid);
85642 + else
85643 +#endif
85644 + p = find_task_by_vpid(pid);
85645 if (p && (tgid <= 0 || task_tgid_vnr(p) == tgid)) {
85646 error = check_kill_permission(sig, info, p);
85647 /*
85648 @@ -3240,8 +3271,8 @@ COMPAT_SYSCALL_DEFINE2(sigaltstack,
85649 }
85650 seg = get_fs();
85651 set_fs(KERNEL_DS);
85652 - ret = do_sigaltstack((stack_t __force __user *) (uss_ptr ? &uss : NULL),
85653 - (stack_t __force __user *) &uoss,
85654 + ret = do_sigaltstack((stack_t __force_user *) (uss_ptr ? &uss : NULL),
85655 + (stack_t __force_user *) &uoss,
85656 compat_user_stack_pointer());
85657 set_fs(seg);
85658 if (ret >= 0 && uoss_ptr) {
85659 diff --git a/kernel/smpboot.c b/kernel/smpboot.c
85660 index eb89e18..a4e6792 100644
85661 --- a/kernel/smpboot.c
85662 +++ b/kernel/smpboot.c
85663 @@ -288,7 +288,7 @@ int smpboot_register_percpu_thread(struct smp_hotplug_thread *plug_thread)
85664 }
85665 smpboot_unpark_thread(plug_thread, cpu);
85666 }
85667 - list_add(&plug_thread->list, &hotplug_threads);
85668 + pax_list_add(&plug_thread->list, &hotplug_threads);
85669 out:
85670 mutex_unlock(&smpboot_threads_lock);
85671 return ret;
85672 @@ -305,7 +305,7 @@ void smpboot_unregister_percpu_thread(struct smp_hotplug_thread *plug_thread)
85673 {
85674 get_online_cpus();
85675 mutex_lock(&smpboot_threads_lock);
85676 - list_del(&plug_thread->list);
85677 + pax_list_del(&plug_thread->list);
85678 smpboot_destroy_threads(plug_thread);
85679 mutex_unlock(&smpboot_threads_lock);
85680 put_online_cpus();
85681 diff --git a/kernel/softirq.c b/kernel/softirq.c
85682 index d7d498d..94fe0f7 100644
85683 --- a/kernel/softirq.c
85684 +++ b/kernel/softirq.c
85685 @@ -53,11 +53,11 @@ irq_cpustat_t irq_stat[NR_CPUS] ____cacheline_aligned;
85686 EXPORT_SYMBOL(irq_stat);
85687 #endif
85688
85689 -static struct softirq_action softirq_vec[NR_SOFTIRQS] __cacheline_aligned_in_smp;
85690 +static struct softirq_action softirq_vec[NR_SOFTIRQS] __read_only __aligned(PAGE_SIZE);
85691
85692 DEFINE_PER_CPU(struct task_struct *, ksoftirqd);
85693
85694 -char *softirq_to_name[NR_SOFTIRQS] = {
85695 +const char * const softirq_to_name[NR_SOFTIRQS] = {
85696 "HI", "TIMER", "NET_TX", "NET_RX", "BLOCK", "BLOCK_IOPOLL",
85697 "TASKLET", "SCHED", "HRTIMER", "RCU"
85698 };
85699 @@ -248,7 +248,7 @@ restart:
85700 kstat_incr_softirqs_this_cpu(vec_nr);
85701
85702 trace_softirq_entry(vec_nr);
85703 - h->action(h);
85704 + h->action();
85705 trace_softirq_exit(vec_nr);
85706 if (unlikely(prev_count != preempt_count())) {
85707 printk(KERN_ERR "huh, entered softirq %u %s %p"
85708 @@ -412,7 +412,7 @@ void __raise_softirq_irqoff(unsigned int nr)
85709 or_softirq_pending(1UL << nr);
85710 }
85711
85712 -void open_softirq(int nr, void (*action)(struct softirq_action *))
85713 +void __init open_softirq(int nr, void (*action)(void))
85714 {
85715 softirq_vec[nr].action = action;
85716 }
85717 @@ -468,7 +468,7 @@ void __tasklet_hi_schedule_first(struct tasklet_struct *t)
85718
85719 EXPORT_SYMBOL(__tasklet_hi_schedule_first);
85720
85721 -static void tasklet_action(struct softirq_action *a)
85722 +static __latent_entropy void tasklet_action(void)
85723 {
85724 struct tasklet_struct *list;
85725
85726 @@ -503,7 +503,7 @@ static void tasklet_action(struct softirq_action *a)
85727 }
85728 }
85729
85730 -static void tasklet_hi_action(struct softirq_action *a)
85731 +static __latent_entropy void tasklet_hi_action(void)
85732 {
85733 struct tasklet_struct *list;
85734
85735 @@ -858,7 +858,7 @@ static struct notifier_block cpu_nfb = {
85736 .notifier_call = cpu_callback
85737 };
85738
85739 -static struct smp_hotplug_thread softirq_threads = {
85740 +static struct smp_hotplug_thread softirq_threads __read_only = {
85741 .store = &ksoftirqd,
85742 .thread_should_run = ksoftirqd_should_run,
85743 .thread_fn = run_ksoftirqd,
85744 diff --git a/kernel/srcu.c b/kernel/srcu.c
85745 index 01d5ccb..cdcbee6 100644
85746 --- a/kernel/srcu.c
85747 +++ b/kernel/srcu.c
85748 @@ -300,9 +300,9 @@ int __srcu_read_lock(struct srcu_struct *sp)
85749
85750 idx = ACCESS_ONCE(sp->completed) & 0x1;
85751 preempt_disable();
85752 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
85753 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
85754 smp_mb(); /* B */ /* Avoid leaking the critical section. */
85755 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
85756 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
85757 preempt_enable();
85758 return idx;
85759 }
85760 diff --git a/kernel/sys.c b/kernel/sys.c
85761 index c18ecca..b3c2dd2 100644
85762 --- a/kernel/sys.c
85763 +++ b/kernel/sys.c
85764 @@ -149,6 +149,12 @@ static int set_one_prio(struct task_struct *p, int niceval, int error)
85765 error = -EACCES;
85766 goto out;
85767 }
85768 +
85769 + if (gr_handle_chroot_setpriority(p, niceval)) {
85770 + error = -EACCES;
85771 + goto out;
85772 + }
85773 +
85774 no_nice = security_task_setnice(p, niceval);
85775 if (no_nice) {
85776 error = no_nice;
85777 @@ -352,6 +358,9 @@ SYSCALL_DEFINE2(setregid, gid_t, rgid, gid_t, egid)
85778 goto error;
85779 }
85780
85781 + if (gr_check_group_change(new->gid, new->egid, INVALID_GID))
85782 + goto error;
85783 +
85784 if (rgid != (gid_t) -1 ||
85785 (egid != (gid_t) -1 && !gid_eq(kegid, old->gid)))
85786 new->sgid = new->egid;
85787 @@ -387,6 +396,10 @@ SYSCALL_DEFINE1(setgid, gid_t, gid)
85788 old = current_cred();
85789
85790 retval = -EPERM;
85791 +
85792 + if (gr_check_group_change(kgid, kgid, kgid))
85793 + goto error;
85794 +
85795 if (ns_capable(old->user_ns, CAP_SETGID))
85796 new->gid = new->egid = new->sgid = new->fsgid = kgid;
85797 else if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->sgid))
85798 @@ -404,7 +417,7 @@ error:
85799 /*
85800 * change the user struct in a credentials set to match the new UID
85801 */
85802 -static int set_user(struct cred *new)
85803 +int set_user(struct cred *new)
85804 {
85805 struct user_struct *new_user;
85806
85807 @@ -484,6 +497,9 @@ SYSCALL_DEFINE2(setreuid, uid_t, ruid, uid_t, euid)
85808 goto error;
85809 }
85810
85811 + if (gr_check_user_change(new->uid, new->euid, INVALID_UID))
85812 + goto error;
85813 +
85814 if (!uid_eq(new->uid, old->uid)) {
85815 retval = set_user(new);
85816 if (retval < 0)
85817 @@ -534,6 +550,12 @@ SYSCALL_DEFINE1(setuid, uid_t, uid)
85818 old = current_cred();
85819
85820 retval = -EPERM;
85821 +
85822 + if (gr_check_crash_uid(kuid))
85823 + goto error;
85824 + if (gr_check_user_change(kuid, kuid, kuid))
85825 + goto error;
85826 +
85827 if (ns_capable(old->user_ns, CAP_SETUID)) {
85828 new->suid = new->uid = kuid;
85829 if (!uid_eq(kuid, old->uid)) {
85830 @@ -603,6 +625,9 @@ SYSCALL_DEFINE3(setresuid, uid_t, ruid, uid_t, euid, uid_t, suid)
85831 goto error;
85832 }
85833
85834 + if (gr_check_user_change(kruid, keuid, INVALID_UID))
85835 + goto error;
85836 +
85837 if (ruid != (uid_t) -1) {
85838 new->uid = kruid;
85839 if (!uid_eq(kruid, old->uid)) {
85840 @@ -685,6 +710,9 @@ SYSCALL_DEFINE3(setresgid, gid_t, rgid, gid_t, egid, gid_t, sgid)
85841 goto error;
85842 }
85843
85844 + if (gr_check_group_change(krgid, kegid, INVALID_GID))
85845 + goto error;
85846 +
85847 if (rgid != (gid_t) -1)
85848 new->gid = krgid;
85849 if (egid != (gid_t) -1)
85850 @@ -746,12 +774,16 @@ SYSCALL_DEFINE1(setfsuid, uid_t, uid)
85851 uid_eq(kuid, old->suid) || uid_eq(kuid, old->fsuid) ||
85852 ns_capable(old->user_ns, CAP_SETUID)) {
85853 if (!uid_eq(kuid, old->fsuid)) {
85854 + if (gr_check_user_change(INVALID_UID, INVALID_UID, kuid))
85855 + goto error;
85856 +
85857 new->fsuid = kuid;
85858 if (security_task_fix_setuid(new, old, LSM_SETID_FS) == 0)
85859 goto change_okay;
85860 }
85861 }
85862
85863 +error:
85864 abort_creds(new);
85865 return old_fsuid;
85866
85867 @@ -784,12 +816,16 @@ SYSCALL_DEFINE1(setfsgid, gid_t, gid)
85868 if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->egid) ||
85869 gid_eq(kgid, old->sgid) || gid_eq(kgid, old->fsgid) ||
85870 ns_capable(old->user_ns, CAP_SETGID)) {
85871 + if (gr_check_group_change(INVALID_GID, INVALID_GID, kgid))
85872 + goto error;
85873 +
85874 if (!gid_eq(kgid, old->fsgid)) {
85875 new->fsgid = kgid;
85876 goto change_okay;
85877 }
85878 }
85879
85880 +error:
85881 abort_creds(new);
85882 return old_fsgid;
85883
85884 @@ -1169,19 +1205,19 @@ SYSCALL_DEFINE1(olduname, struct oldold_utsname __user *, name)
85885 return -EFAULT;
85886
85887 down_read(&uts_sem);
85888 - error = __copy_to_user(&name->sysname, &utsname()->sysname,
85889 + error = __copy_to_user(name->sysname, &utsname()->sysname,
85890 __OLD_UTS_LEN);
85891 error |= __put_user(0, name->sysname + __OLD_UTS_LEN);
85892 - error |= __copy_to_user(&name->nodename, &utsname()->nodename,
85893 + error |= __copy_to_user(name->nodename, &utsname()->nodename,
85894 __OLD_UTS_LEN);
85895 error |= __put_user(0, name->nodename + __OLD_UTS_LEN);
85896 - error |= __copy_to_user(&name->release, &utsname()->release,
85897 + error |= __copy_to_user(name->release, &utsname()->release,
85898 __OLD_UTS_LEN);
85899 error |= __put_user(0, name->release + __OLD_UTS_LEN);
85900 - error |= __copy_to_user(&name->version, &utsname()->version,
85901 + error |= __copy_to_user(name->version, &utsname()->version,
85902 __OLD_UTS_LEN);
85903 error |= __put_user(0, name->version + __OLD_UTS_LEN);
85904 - error |= __copy_to_user(&name->machine, &utsname()->machine,
85905 + error |= __copy_to_user(name->machine, &utsname()->machine,
85906 __OLD_UTS_LEN);
85907 error |= __put_user(0, name->machine + __OLD_UTS_LEN);
85908 up_read(&uts_sem);
85909 @@ -1383,6 +1419,13 @@ int do_prlimit(struct task_struct *tsk, unsigned int resource,
85910 */
85911 new_rlim->rlim_cur = 1;
85912 }
85913 + /* Handle the case where a fork and setuid occur and then RLIMIT_NPROC
85914 + is changed to a lower value. Since tasks can be created by the same
85915 + user in between this limit change and an execve by this task, force
85916 + a recheck only for this task by setting PF_NPROC_EXCEEDED
85917 + */
85918 + if (resource == RLIMIT_NPROC && tsk->real_cred->user != INIT_USER)
85919 + tsk->flags |= PF_NPROC_EXCEEDED;
85920 }
85921 if (!retval) {
85922 if (old_rlim)
85923 diff --git a/kernel/sysctl.c b/kernel/sysctl.c
85924 index b2f06f3..e6354ab 100644
85925 --- a/kernel/sysctl.c
85926 +++ b/kernel/sysctl.c
85927 @@ -93,7 +93,6 @@
85928
85929
85930 #if defined(CONFIG_SYSCTL)
85931 -
85932 /* External variables not in a header file. */
85933 extern int sysctl_overcommit_memory;
85934 extern int sysctl_overcommit_ratio;
85935 @@ -119,17 +118,18 @@ extern int blk_iopoll_enabled;
85936
85937 /* Constants used for minimum and maximum */
85938 #ifdef CONFIG_LOCKUP_DETECTOR
85939 -static int sixty = 60;
85940 +static int sixty __read_only = 60;
85941 #endif
85942
85943 -static int zero;
85944 -static int __maybe_unused one = 1;
85945 -static int __maybe_unused two = 2;
85946 -static int __maybe_unused three = 3;
85947 -static unsigned long one_ul = 1;
85948 -static int one_hundred = 100;
85949 +static int neg_one __read_only = -1;
85950 +static int zero __read_only = 0;
85951 +static int __maybe_unused one __read_only = 1;
85952 +static int __maybe_unused two __read_only = 2;
85953 +static int __maybe_unused three __read_only = 3;
85954 +static unsigned long one_ul __read_only = 1;
85955 +static int one_hundred __read_only = 100;
85956 #ifdef CONFIG_PRINTK
85957 -static int ten_thousand = 10000;
85958 +static int ten_thousand __read_only = 10000;
85959 #endif
85960
85961 /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
85962 @@ -176,10 +176,8 @@ static int proc_taint(struct ctl_table *table, int write,
85963 void __user *buffer, size_t *lenp, loff_t *ppos);
85964 #endif
85965
85966 -#ifdef CONFIG_PRINTK
85967 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
85968 void __user *buffer, size_t *lenp, loff_t *ppos);
85969 -#endif
85970
85971 static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
85972 void __user *buffer, size_t *lenp, loff_t *ppos);
85973 @@ -210,6 +208,8 @@ static int sysrq_sysctl_handler(ctl_table *table, int write,
85974
85975 #endif
85976
85977 +extern struct ctl_table grsecurity_table[];
85978 +
85979 static struct ctl_table kern_table[];
85980 static struct ctl_table vm_table[];
85981 static struct ctl_table fs_table[];
85982 @@ -224,6 +224,20 @@ extern struct ctl_table epoll_table[];
85983 int sysctl_legacy_va_layout;
85984 #endif
85985
85986 +#ifdef CONFIG_PAX_SOFTMODE
85987 +static ctl_table pax_table[] = {
85988 + {
85989 + .procname = "softmode",
85990 + .data = &pax_softmode,
85991 + .maxlen = sizeof(unsigned int),
85992 + .mode = 0600,
85993 + .proc_handler = &proc_dointvec,
85994 + },
85995 +
85996 + { }
85997 +};
85998 +#endif
85999 +
86000 /* The default sysctl tables: */
86001
86002 static struct ctl_table sysctl_base_table[] = {
86003 @@ -272,6 +286,22 @@ static int max_extfrag_threshold = 1000;
86004 #endif
86005
86006 static struct ctl_table kern_table[] = {
86007 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS)
86008 + {
86009 + .procname = "grsecurity",
86010 + .mode = 0500,
86011 + .child = grsecurity_table,
86012 + },
86013 +#endif
86014 +
86015 +#ifdef CONFIG_PAX_SOFTMODE
86016 + {
86017 + .procname = "pax",
86018 + .mode = 0500,
86019 + .child = pax_table,
86020 + },
86021 +#endif
86022 +
86023 {
86024 .procname = "sched_child_runs_first",
86025 .data = &sysctl_sched_child_runs_first,
86026 @@ -613,7 +643,7 @@ static struct ctl_table kern_table[] = {
86027 .data = &modprobe_path,
86028 .maxlen = KMOD_PATH_LEN,
86029 .mode = 0644,
86030 - .proc_handler = proc_dostring,
86031 + .proc_handler = proc_dostring_modpriv,
86032 },
86033 {
86034 .procname = "modules_disabled",
86035 @@ -780,16 +810,20 @@ static struct ctl_table kern_table[] = {
86036 .extra1 = &zero,
86037 .extra2 = &one,
86038 },
86039 +#endif
86040 {
86041 .procname = "kptr_restrict",
86042 .data = &kptr_restrict,
86043 .maxlen = sizeof(int),
86044 .mode = 0644,
86045 .proc_handler = proc_dointvec_minmax_sysadmin,
86046 +#ifdef CONFIG_GRKERNSEC_HIDESYM
86047 + .extra1 = &two,
86048 +#else
86049 .extra1 = &zero,
86050 +#endif
86051 .extra2 = &two,
86052 },
86053 -#endif
86054 {
86055 .procname = "ngroups_max",
86056 .data = &ngroups_max,
86057 @@ -1031,10 +1065,17 @@ static struct ctl_table kern_table[] = {
86058 */
86059 {
86060 .procname = "perf_event_paranoid",
86061 - .data = &sysctl_perf_event_paranoid,
86062 - .maxlen = sizeof(sysctl_perf_event_paranoid),
86063 + .data = &sysctl_perf_event_legitimately_concerned,
86064 + .maxlen = sizeof(sysctl_perf_event_legitimately_concerned),
86065 .mode = 0644,
86066 - .proc_handler = proc_dointvec,
86067 + /* go ahead, be a hero */
86068 + .proc_handler = proc_dointvec_minmax_sysadmin,
86069 + .extra1 = &neg_one,
86070 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
86071 + .extra2 = &three,
86072 +#else
86073 + .extra2 = &two,
86074 +#endif
86075 },
86076 {
86077 .procname = "perf_event_mlock_kb",
86078 @@ -1297,6 +1338,13 @@ static struct ctl_table vm_table[] = {
86079 .proc_handler = proc_dointvec_minmax,
86080 .extra1 = &zero,
86081 },
86082 + {
86083 + .procname = "heap_stack_gap",
86084 + .data = &sysctl_heap_stack_gap,
86085 + .maxlen = sizeof(sysctl_heap_stack_gap),
86086 + .mode = 0644,
86087 + .proc_handler = proc_doulongvec_minmax,
86088 + },
86089 #else
86090 {
86091 .procname = "nr_trim_pages",
86092 @@ -1761,6 +1809,16 @@ int proc_dostring(struct ctl_table *table, int write,
86093 buffer, lenp, ppos);
86094 }
86095
86096 +int proc_dostring_modpriv(struct ctl_table *table, int write,
86097 + void __user *buffer, size_t *lenp, loff_t *ppos)
86098 +{
86099 + if (write && !capable(CAP_SYS_MODULE))
86100 + return -EPERM;
86101 +
86102 + return _proc_do_string(table->data, table->maxlen, write,
86103 + buffer, lenp, ppos);
86104 +}
86105 +
86106 static size_t proc_skip_spaces(char **buf)
86107 {
86108 size_t ret;
86109 @@ -1866,6 +1924,8 @@ static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
86110 len = strlen(tmp);
86111 if (len > *size)
86112 len = *size;
86113 + if (len > sizeof(tmp))
86114 + len = sizeof(tmp);
86115 if (copy_to_user(*buf, tmp, len))
86116 return -EFAULT;
86117 *size -= len;
86118 @@ -2030,7 +2090,7 @@ int proc_dointvec(struct ctl_table *table, int write,
86119 static int proc_taint(struct ctl_table *table, int write,
86120 void __user *buffer, size_t *lenp, loff_t *ppos)
86121 {
86122 - struct ctl_table t;
86123 + ctl_table_no_const t;
86124 unsigned long tmptaint = get_taint();
86125 int err;
86126
86127 @@ -2058,7 +2118,6 @@ static int proc_taint(struct ctl_table *table, int write,
86128 return err;
86129 }
86130
86131 -#ifdef CONFIG_PRINTK
86132 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
86133 void __user *buffer, size_t *lenp, loff_t *ppos)
86134 {
86135 @@ -2067,7 +2126,6 @@ static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
86136
86137 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
86138 }
86139 -#endif
86140
86141 struct do_proc_dointvec_minmax_conv_param {
86142 int *min;
86143 @@ -2214,8 +2272,11 @@ static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int
86144 *i = val;
86145 } else {
86146 val = convdiv * (*i) / convmul;
86147 - if (!first)
86148 + if (!first) {
86149 err = proc_put_char(&buffer, &left, '\t');
86150 + if (err)
86151 + break;
86152 + }
86153 err = proc_put_long(&buffer, &left, val, false);
86154 if (err)
86155 break;
86156 @@ -2611,6 +2672,12 @@ int proc_dostring(struct ctl_table *table, int write,
86157 return -ENOSYS;
86158 }
86159
86160 +int proc_dostring_modpriv(struct ctl_table *table, int write,
86161 + void __user *buffer, size_t *lenp, loff_t *ppos)
86162 +{
86163 + return -ENOSYS;
86164 +}
86165 +
86166 int proc_dointvec(struct ctl_table *table, int write,
86167 void __user *buffer, size_t *lenp, loff_t *ppos)
86168 {
86169 @@ -2667,5 +2734,6 @@ EXPORT_SYMBOL(proc_dointvec_minmax);
86170 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
86171 EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
86172 EXPORT_SYMBOL(proc_dostring);
86173 +EXPORT_SYMBOL(proc_dostring_modpriv);
86174 EXPORT_SYMBOL(proc_doulongvec_minmax);
86175 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
86176 diff --git a/kernel/taskstats.c b/kernel/taskstats.c
86177 index 145bb4d..b2aa969 100644
86178 --- a/kernel/taskstats.c
86179 +++ b/kernel/taskstats.c
86180 @@ -28,9 +28,12 @@
86181 #include <linux/fs.h>
86182 #include <linux/file.h>
86183 #include <linux/pid_namespace.h>
86184 +#include <linux/grsecurity.h>
86185 #include <net/genetlink.h>
86186 #include <linux/atomic.h>
86187
86188 +extern int gr_is_taskstats_denied(int pid);
86189 +
86190 /*
86191 * Maximum length of a cpumask that can be specified in
86192 * the TASKSTATS_CMD_ATTR_REGISTER/DEREGISTER_CPUMASK attribute
86193 @@ -570,6 +573,9 @@ err:
86194
86195 static int taskstats_user_cmd(struct sk_buff *skb, struct genl_info *info)
86196 {
86197 + if (gr_is_taskstats_denied(current->pid))
86198 + return -EACCES;
86199 +
86200 if (info->attrs[TASKSTATS_CMD_ATTR_REGISTER_CPUMASK])
86201 return cmd_attr_register_cpumask(info);
86202 else if (info->attrs[TASKSTATS_CMD_ATTR_DEREGISTER_CPUMASK])
86203 diff --git a/kernel/time.c b/kernel/time.c
86204 index 7c7964c..2a0d412 100644
86205 --- a/kernel/time.c
86206 +++ b/kernel/time.c
86207 @@ -172,6 +172,11 @@ int do_sys_settimeofday(const struct timespec *tv, const struct timezone *tz)
86208 return error;
86209
86210 if (tz) {
86211 + /* we log in do_settimeofday called below, so don't log twice
86212 + */
86213 + if (!tv)
86214 + gr_log_timechange();
86215 +
86216 sys_tz = *tz;
86217 update_vsyscall_tz();
86218 if (firsttime) {
86219 diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
86220 index 88c9c65..7497ebc 100644
86221 --- a/kernel/time/alarmtimer.c
86222 +++ b/kernel/time/alarmtimer.c
86223 @@ -795,7 +795,7 @@ static int __init alarmtimer_init(void)
86224 struct platform_device *pdev;
86225 int error = 0;
86226 int i;
86227 - struct k_clock alarm_clock = {
86228 + static struct k_clock alarm_clock = {
86229 .clock_getres = alarm_clock_getres,
86230 .clock_get = alarm_clock_get,
86231 .timer_create = alarm_timer_create,
86232 diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
86233 index 5cf6c70..ac341b0 100644
86234 --- a/kernel/time/timekeeping.c
86235 +++ b/kernel/time/timekeeping.c
86236 @@ -15,6 +15,7 @@
86237 #include <linux/init.h>
86238 #include <linux/mm.h>
86239 #include <linux/sched.h>
86240 +#include <linux/grsecurity.h>
86241 #include <linux/syscore_ops.h>
86242 #include <linux/clocksource.h>
86243 #include <linux/jiffies.h>
86244 @@ -500,6 +501,8 @@ int do_settimeofday(const struct timespec *tv)
86245 if (!timespec_valid_strict(tv))
86246 return -EINVAL;
86247
86248 + gr_log_timechange();
86249 +
86250 raw_spin_lock_irqsave(&timekeeper_lock, flags);
86251 write_seqcount_begin(&timekeeper_seq);
86252
86253 diff --git a/kernel/time/timer_list.c b/kernel/time/timer_list.c
86254 index 61ed862..3b52c65 100644
86255 --- a/kernel/time/timer_list.c
86256 +++ b/kernel/time/timer_list.c
86257 @@ -45,12 +45,16 @@ DECLARE_PER_CPU(struct hrtimer_cpu_base, hrtimer_bases);
86258
86259 static void print_name_offset(struct seq_file *m, void *sym)
86260 {
86261 +#ifdef CONFIG_GRKERNSEC_HIDESYM
86262 + SEQ_printf(m, "<%p>", NULL);
86263 +#else
86264 char symname[KSYM_NAME_LEN];
86265
86266 if (lookup_symbol_name((unsigned long)sym, symname) < 0)
86267 SEQ_printf(m, "<%pK>", sym);
86268 else
86269 SEQ_printf(m, "%s", symname);
86270 +#endif
86271 }
86272
86273 static void
86274 @@ -119,7 +123,11 @@ next_one:
86275 static void
86276 print_base(struct seq_file *m, struct hrtimer_clock_base *base, u64 now)
86277 {
86278 +#ifdef CONFIG_GRKERNSEC_HIDESYM
86279 + SEQ_printf(m, " .base: %p\n", NULL);
86280 +#else
86281 SEQ_printf(m, " .base: %pK\n", base);
86282 +#endif
86283 SEQ_printf(m, " .index: %d\n",
86284 base->index);
86285 SEQ_printf(m, " .resolution: %Lu nsecs\n",
86286 @@ -362,7 +370,11 @@ static int __init init_timer_list_procfs(void)
86287 {
86288 struct proc_dir_entry *pe;
86289
86290 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
86291 + pe = proc_create("timer_list", 0400, NULL, &timer_list_fops);
86292 +#else
86293 pe = proc_create("timer_list", 0444, NULL, &timer_list_fops);
86294 +#endif
86295 if (!pe)
86296 return -ENOMEM;
86297 return 0;
86298 diff --git a/kernel/time/timer_stats.c b/kernel/time/timer_stats.c
86299 index 0b537f2..40d6c20 100644
86300 --- a/kernel/time/timer_stats.c
86301 +++ b/kernel/time/timer_stats.c
86302 @@ -116,7 +116,7 @@ static ktime_t time_start, time_stop;
86303 static unsigned long nr_entries;
86304 static struct entry entries[MAX_ENTRIES];
86305
86306 -static atomic_t overflow_count;
86307 +static atomic_unchecked_t overflow_count;
86308
86309 /*
86310 * The entries are in a hash-table, for fast lookup:
86311 @@ -140,7 +140,7 @@ static void reset_entries(void)
86312 nr_entries = 0;
86313 memset(entries, 0, sizeof(entries));
86314 memset(tstat_hash_table, 0, sizeof(tstat_hash_table));
86315 - atomic_set(&overflow_count, 0);
86316 + atomic_set_unchecked(&overflow_count, 0);
86317 }
86318
86319 static struct entry *alloc_entry(void)
86320 @@ -261,7 +261,7 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
86321 if (likely(entry))
86322 entry->count++;
86323 else
86324 - atomic_inc(&overflow_count);
86325 + atomic_inc_unchecked(&overflow_count);
86326
86327 out_unlock:
86328 raw_spin_unlock_irqrestore(lock, flags);
86329 @@ -269,12 +269,16 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
86330
86331 static void print_name_offset(struct seq_file *m, unsigned long addr)
86332 {
86333 +#ifdef CONFIG_GRKERNSEC_HIDESYM
86334 + seq_printf(m, "<%p>", NULL);
86335 +#else
86336 char symname[KSYM_NAME_LEN];
86337
86338 if (lookup_symbol_name(addr, symname) < 0)
86339 - seq_printf(m, "<%p>", (void *)addr);
86340 + seq_printf(m, "<%pK>", (void *)addr);
86341 else
86342 seq_printf(m, "%s", symname);
86343 +#endif
86344 }
86345
86346 static int tstats_show(struct seq_file *m, void *v)
86347 @@ -300,9 +304,9 @@ static int tstats_show(struct seq_file *m, void *v)
86348
86349 seq_puts(m, "Timer Stats Version: v0.2\n");
86350 seq_printf(m, "Sample period: %ld.%03ld s\n", period.tv_sec, ms);
86351 - if (atomic_read(&overflow_count))
86352 + if (atomic_read_unchecked(&overflow_count))
86353 seq_printf(m, "Overflow: %d entries\n",
86354 - atomic_read(&overflow_count));
86355 + atomic_read_unchecked(&overflow_count));
86356
86357 for (i = 0; i < nr_entries; i++) {
86358 entry = entries + i;
86359 @@ -417,7 +421,11 @@ static int __init init_tstats_procfs(void)
86360 {
86361 struct proc_dir_entry *pe;
86362
86363 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
86364 + pe = proc_create("timer_stats", 0600, NULL, &tstats_fops);
86365 +#else
86366 pe = proc_create("timer_stats", 0644, NULL, &tstats_fops);
86367 +#endif
86368 if (!pe)
86369 return -ENOMEM;
86370 return 0;
86371 diff --git a/kernel/timer.c b/kernel/timer.c
86372 index 4296d13..0164b04 100644
86373 --- a/kernel/timer.c
86374 +++ b/kernel/timer.c
86375 @@ -1366,7 +1366,7 @@ void update_process_times(int user_tick)
86376 /*
86377 * This function runs timers and the timer-tq in bottom half context.
86378 */
86379 -static void run_timer_softirq(struct softirq_action *h)
86380 +static __latent_entropy void run_timer_softirq(void)
86381 {
86382 struct tvec_base *base = __this_cpu_read(tvec_bases);
86383
86384 @@ -1429,7 +1429,7 @@ static void process_timeout(unsigned long __data)
86385 *
86386 * In all cases the return value is guaranteed to be non-negative.
86387 */
86388 -signed long __sched schedule_timeout(signed long timeout)
86389 +signed long __sched __intentional_overflow(-1) schedule_timeout(signed long timeout)
86390 {
86391 struct timer_list timer;
86392 unsigned long expire;
86393 diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
86394 index b8b8560..75b1a09 100644
86395 --- a/kernel/trace/blktrace.c
86396 +++ b/kernel/trace/blktrace.c
86397 @@ -317,7 +317,7 @@ static ssize_t blk_dropped_read(struct file *filp, char __user *buffer,
86398 struct blk_trace *bt = filp->private_data;
86399 char buf[16];
86400
86401 - snprintf(buf, sizeof(buf), "%u\n", atomic_read(&bt->dropped));
86402 + snprintf(buf, sizeof(buf), "%u\n", atomic_read_unchecked(&bt->dropped));
86403
86404 return simple_read_from_buffer(buffer, count, ppos, buf, strlen(buf));
86405 }
86406 @@ -375,7 +375,7 @@ static int blk_subbuf_start_callback(struct rchan_buf *buf, void *subbuf,
86407 return 1;
86408
86409 bt = buf->chan->private_data;
86410 - atomic_inc(&bt->dropped);
86411 + atomic_inc_unchecked(&bt->dropped);
86412 return 0;
86413 }
86414
86415 @@ -476,7 +476,7 @@ int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
86416
86417 bt->dir = dir;
86418 bt->dev = dev;
86419 - atomic_set(&bt->dropped, 0);
86420 + atomic_set_unchecked(&bt->dropped, 0);
86421
86422 ret = -EIO;
86423 bt->dropped_file = debugfs_create_file("dropped", 0444, dir, bt,
86424 diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
86425 index f3bd09ee..9bb9586 100644
86426 --- a/kernel/trace/ftrace.c
86427 +++ b/kernel/trace/ftrace.c
86428 @@ -1944,12 +1944,17 @@ ftrace_code_disable(struct module *mod, struct dyn_ftrace *rec)
86429 if (unlikely(ftrace_disabled))
86430 return 0;
86431
86432 + ret = ftrace_arch_code_modify_prepare();
86433 + FTRACE_WARN_ON(ret);
86434 + if (ret)
86435 + return 0;
86436 +
86437 ret = ftrace_make_nop(mod, rec, MCOUNT_ADDR);
86438 + FTRACE_WARN_ON(ftrace_arch_code_modify_post_process());
86439 if (ret) {
86440 ftrace_bug(ret, ip);
86441 - return 0;
86442 }
86443 - return 1;
86444 + return ret ? 0 : 1;
86445 }
86446
86447 /*
86448 @@ -4043,8 +4048,10 @@ static int ftrace_process_locs(struct module *mod,
86449 if (!count)
86450 return 0;
86451
86452 + pax_open_kernel();
86453 sort(start, count, sizeof(*start),
86454 ftrace_cmp_ips, ftrace_swap_ips);
86455 + pax_close_kernel();
86456
86457 start_pg = ftrace_allocate_pages(count);
86458 if (!start_pg)
86459 @@ -4766,8 +4773,6 @@ ftrace_enable_sysctl(struct ctl_table *table, int write,
86460 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
86461
86462 static int ftrace_graph_active;
86463 -static struct notifier_block ftrace_suspend_notifier;
86464 -
86465 int ftrace_graph_entry_stub(struct ftrace_graph_ent *trace)
86466 {
86467 return 0;
86468 @@ -4918,6 +4923,10 @@ static struct ftrace_ops fgraph_ops __read_mostly = {
86469 FTRACE_OPS_FL_RECURSION_SAFE,
86470 };
86471
86472 +static struct notifier_block ftrace_suspend_notifier = {
86473 + .notifier_call = ftrace_suspend_notifier_call
86474 +};
86475 +
86476 int register_ftrace_graph(trace_func_graph_ret_t retfunc,
86477 trace_func_graph_ent_t entryfunc)
86478 {
86479 @@ -4931,7 +4940,6 @@ int register_ftrace_graph(trace_func_graph_ret_t retfunc,
86480 goto out;
86481 }
86482
86483 - ftrace_suspend_notifier.notifier_call = ftrace_suspend_notifier_call;
86484 register_pm_notifier(&ftrace_suspend_notifier);
86485
86486 ftrace_graph_active++;
86487 diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
86488 index cc2f66f..05edd54 100644
86489 --- a/kernel/trace/ring_buffer.c
86490 +++ b/kernel/trace/ring_buffer.c
86491 @@ -352,9 +352,9 @@ struct buffer_data_page {
86492 */
86493 struct buffer_page {
86494 struct list_head list; /* list of buffer pages */
86495 - local_t write; /* index for next write */
86496 + local_unchecked_t write; /* index for next write */
86497 unsigned read; /* index for next read */
86498 - local_t entries; /* entries on this page */
86499 + local_unchecked_t entries; /* entries on this page */
86500 unsigned long real_end; /* real end of data */
86501 struct buffer_data_page *page; /* Actual data page */
86502 };
86503 @@ -473,8 +473,8 @@ struct ring_buffer_per_cpu {
86504 unsigned long last_overrun;
86505 local_t entries_bytes;
86506 local_t entries;
86507 - local_t overrun;
86508 - local_t commit_overrun;
86509 + local_unchecked_t overrun;
86510 + local_unchecked_t commit_overrun;
86511 local_t dropped_events;
86512 local_t committing;
86513 local_t commits;
86514 @@ -992,8 +992,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
86515 *
86516 * We add a counter to the write field to denote this.
86517 */
86518 - old_write = local_add_return(RB_WRITE_INTCNT, &next_page->write);
86519 - old_entries = local_add_return(RB_WRITE_INTCNT, &next_page->entries);
86520 + old_write = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->write);
86521 + old_entries = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->entries);
86522
86523 /*
86524 * Just make sure we have seen our old_write and synchronize
86525 @@ -1021,8 +1021,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
86526 * cmpxchg to only update if an interrupt did not already
86527 * do it for us. If the cmpxchg fails, we don't care.
86528 */
86529 - (void)local_cmpxchg(&next_page->write, old_write, val);
86530 - (void)local_cmpxchg(&next_page->entries, old_entries, eval);
86531 + (void)local_cmpxchg_unchecked(&next_page->write, old_write, val);
86532 + (void)local_cmpxchg_unchecked(&next_page->entries, old_entries, eval);
86533
86534 /*
86535 * No need to worry about races with clearing out the commit.
86536 @@ -1386,12 +1386,12 @@ static void rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer);
86537
86538 static inline unsigned long rb_page_entries(struct buffer_page *bpage)
86539 {
86540 - return local_read(&bpage->entries) & RB_WRITE_MASK;
86541 + return local_read_unchecked(&bpage->entries) & RB_WRITE_MASK;
86542 }
86543
86544 static inline unsigned long rb_page_write(struct buffer_page *bpage)
86545 {
86546 - return local_read(&bpage->write) & RB_WRITE_MASK;
86547 + return local_read_unchecked(&bpage->write) & RB_WRITE_MASK;
86548 }
86549
86550 static int
86551 @@ -1486,7 +1486,7 @@ rb_remove_pages(struct ring_buffer_per_cpu *cpu_buffer, unsigned int nr_pages)
86552 * bytes consumed in ring buffer from here.
86553 * Increment overrun to account for the lost events.
86554 */
86555 - local_add(page_entries, &cpu_buffer->overrun);
86556 + local_add_unchecked(page_entries, &cpu_buffer->overrun);
86557 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
86558 }
86559
86560 @@ -2064,7 +2064,7 @@ rb_handle_head_page(struct ring_buffer_per_cpu *cpu_buffer,
86561 * it is our responsibility to update
86562 * the counters.
86563 */
86564 - local_add(entries, &cpu_buffer->overrun);
86565 + local_add_unchecked(entries, &cpu_buffer->overrun);
86566 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
86567
86568 /*
86569 @@ -2214,7 +2214,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
86570 if (tail == BUF_PAGE_SIZE)
86571 tail_page->real_end = 0;
86572
86573 - local_sub(length, &tail_page->write);
86574 + local_sub_unchecked(length, &tail_page->write);
86575 return;
86576 }
86577
86578 @@ -2249,7 +2249,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
86579 rb_event_set_padding(event);
86580
86581 /* Set the write back to the previous setting */
86582 - local_sub(length, &tail_page->write);
86583 + local_sub_unchecked(length, &tail_page->write);
86584 return;
86585 }
86586
86587 @@ -2261,7 +2261,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
86588
86589 /* Set write to end of buffer */
86590 length = (tail + length) - BUF_PAGE_SIZE;
86591 - local_sub(length, &tail_page->write);
86592 + local_sub_unchecked(length, &tail_page->write);
86593 }
86594
86595 /*
86596 @@ -2287,7 +2287,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
86597 * about it.
86598 */
86599 if (unlikely(next_page == commit_page)) {
86600 - local_inc(&cpu_buffer->commit_overrun);
86601 + local_inc_unchecked(&cpu_buffer->commit_overrun);
86602 goto out_reset;
86603 }
86604
86605 @@ -2343,7 +2343,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
86606 cpu_buffer->tail_page) &&
86607 (cpu_buffer->commit_page ==
86608 cpu_buffer->reader_page))) {
86609 - local_inc(&cpu_buffer->commit_overrun);
86610 + local_inc_unchecked(&cpu_buffer->commit_overrun);
86611 goto out_reset;
86612 }
86613 }
86614 @@ -2391,7 +2391,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
86615 length += RB_LEN_TIME_EXTEND;
86616
86617 tail_page = cpu_buffer->tail_page;
86618 - write = local_add_return(length, &tail_page->write);
86619 + write = local_add_return_unchecked(length, &tail_page->write);
86620
86621 /* set write to only the index of the write */
86622 write &= RB_WRITE_MASK;
86623 @@ -2408,7 +2408,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
86624 kmemcheck_annotate_bitfield(event, bitfield);
86625 rb_update_event(cpu_buffer, event, length, add_timestamp, delta);
86626
86627 - local_inc(&tail_page->entries);
86628 + local_inc_unchecked(&tail_page->entries);
86629
86630 /*
86631 * If this is the first commit on the page, then update
86632 @@ -2441,7 +2441,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
86633
86634 if (bpage->page == (void *)addr && rb_page_write(bpage) == old_index) {
86635 unsigned long write_mask =
86636 - local_read(&bpage->write) & ~RB_WRITE_MASK;
86637 + local_read_unchecked(&bpage->write) & ~RB_WRITE_MASK;
86638 unsigned long event_length = rb_event_length(event);
86639 /*
86640 * This is on the tail page. It is possible that
86641 @@ -2451,7 +2451,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
86642 */
86643 old_index += write_mask;
86644 new_index += write_mask;
86645 - index = local_cmpxchg(&bpage->write, old_index, new_index);
86646 + index = local_cmpxchg_unchecked(&bpage->write, old_index, new_index);
86647 if (index == old_index) {
86648 /* update counters */
86649 local_sub(event_length, &cpu_buffer->entries_bytes);
86650 @@ -2843,7 +2843,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
86651
86652 /* Do the likely case first */
86653 if (likely(bpage->page == (void *)addr)) {
86654 - local_dec(&bpage->entries);
86655 + local_dec_unchecked(&bpage->entries);
86656 return;
86657 }
86658
86659 @@ -2855,7 +2855,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
86660 start = bpage;
86661 do {
86662 if (bpage->page == (void *)addr) {
86663 - local_dec(&bpage->entries);
86664 + local_dec_unchecked(&bpage->entries);
86665 return;
86666 }
86667 rb_inc_page(cpu_buffer, &bpage);
86668 @@ -3139,7 +3139,7 @@ static inline unsigned long
86669 rb_num_of_entries(struct ring_buffer_per_cpu *cpu_buffer)
86670 {
86671 return local_read(&cpu_buffer->entries) -
86672 - (local_read(&cpu_buffer->overrun) + cpu_buffer->read);
86673 + (local_read_unchecked(&cpu_buffer->overrun) + cpu_buffer->read);
86674 }
86675
86676 /**
86677 @@ -3228,7 +3228,7 @@ unsigned long ring_buffer_overrun_cpu(struct ring_buffer *buffer, int cpu)
86678 return 0;
86679
86680 cpu_buffer = buffer->buffers[cpu];
86681 - ret = local_read(&cpu_buffer->overrun);
86682 + ret = local_read_unchecked(&cpu_buffer->overrun);
86683
86684 return ret;
86685 }
86686 @@ -3251,7 +3251,7 @@ ring_buffer_commit_overrun_cpu(struct ring_buffer *buffer, int cpu)
86687 return 0;
86688
86689 cpu_buffer = buffer->buffers[cpu];
86690 - ret = local_read(&cpu_buffer->commit_overrun);
86691 + ret = local_read_unchecked(&cpu_buffer->commit_overrun);
86692
86693 return ret;
86694 }
86695 @@ -3336,7 +3336,7 @@ unsigned long ring_buffer_overruns(struct ring_buffer *buffer)
86696 /* if you care about this being correct, lock the buffer */
86697 for_each_buffer_cpu(buffer, cpu) {
86698 cpu_buffer = buffer->buffers[cpu];
86699 - overruns += local_read(&cpu_buffer->overrun);
86700 + overruns += local_read_unchecked(&cpu_buffer->overrun);
86701 }
86702
86703 return overruns;
86704 @@ -3512,8 +3512,8 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
86705 /*
86706 * Reset the reader page to size zero.
86707 */
86708 - local_set(&cpu_buffer->reader_page->write, 0);
86709 - local_set(&cpu_buffer->reader_page->entries, 0);
86710 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
86711 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
86712 local_set(&cpu_buffer->reader_page->page->commit, 0);
86713 cpu_buffer->reader_page->real_end = 0;
86714
86715 @@ -3547,7 +3547,7 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
86716 * want to compare with the last_overrun.
86717 */
86718 smp_mb();
86719 - overwrite = local_read(&(cpu_buffer->overrun));
86720 + overwrite = local_read_unchecked(&(cpu_buffer->overrun));
86721
86722 /*
86723 * Here's the tricky part.
86724 @@ -4117,8 +4117,8 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
86725
86726 cpu_buffer->head_page
86727 = list_entry(cpu_buffer->pages, struct buffer_page, list);
86728 - local_set(&cpu_buffer->head_page->write, 0);
86729 - local_set(&cpu_buffer->head_page->entries, 0);
86730 + local_set_unchecked(&cpu_buffer->head_page->write, 0);
86731 + local_set_unchecked(&cpu_buffer->head_page->entries, 0);
86732 local_set(&cpu_buffer->head_page->page->commit, 0);
86733
86734 cpu_buffer->head_page->read = 0;
86735 @@ -4128,14 +4128,14 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
86736
86737 INIT_LIST_HEAD(&cpu_buffer->reader_page->list);
86738 INIT_LIST_HEAD(&cpu_buffer->new_pages);
86739 - local_set(&cpu_buffer->reader_page->write, 0);
86740 - local_set(&cpu_buffer->reader_page->entries, 0);
86741 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
86742 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
86743 local_set(&cpu_buffer->reader_page->page->commit, 0);
86744 cpu_buffer->reader_page->read = 0;
86745
86746 local_set(&cpu_buffer->entries_bytes, 0);
86747 - local_set(&cpu_buffer->overrun, 0);
86748 - local_set(&cpu_buffer->commit_overrun, 0);
86749 + local_set_unchecked(&cpu_buffer->overrun, 0);
86750 + local_set_unchecked(&cpu_buffer->commit_overrun, 0);
86751 local_set(&cpu_buffer->dropped_events, 0);
86752 local_set(&cpu_buffer->entries, 0);
86753 local_set(&cpu_buffer->committing, 0);
86754 @@ -4540,8 +4540,8 @@ int ring_buffer_read_page(struct ring_buffer *buffer,
86755 rb_init_page(bpage);
86756 bpage = reader->page;
86757 reader->page = *data_page;
86758 - local_set(&reader->write, 0);
86759 - local_set(&reader->entries, 0);
86760 + local_set_unchecked(&reader->write, 0);
86761 + local_set_unchecked(&reader->entries, 0);
86762 reader->read = 0;
86763 *data_page = bpage;
86764
86765 diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
86766 index b778e96..4e84621 100644
86767 --- a/kernel/trace/trace.c
86768 +++ b/kernel/trace/trace.c
86769 @@ -3335,7 +3335,7 @@ int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set)
86770 return 0;
86771 }
86772
86773 -int set_tracer_flag(struct trace_array *tr, unsigned int mask, int enabled)
86774 +int set_tracer_flag(struct trace_array *tr, unsigned long mask, int enabled)
86775 {
86776 /* do nothing if flag is already set */
86777 if (!!(trace_flags & mask) == !!enabled)
86778 diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
86779 index 10c86fb..645ab0a 100644
86780 --- a/kernel/trace/trace.h
86781 +++ b/kernel/trace/trace.h
86782 @@ -1029,7 +1029,7 @@ extern const char *__stop___tracepoint_str[];
86783 void trace_printk_init_buffers(void);
86784 void trace_printk_start_comm(void);
86785 int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set);
86786 -int set_tracer_flag(struct trace_array *tr, unsigned int mask, int enabled);
86787 +int set_tracer_flag(struct trace_array *tr, unsigned long mask, int enabled);
86788
86789 /*
86790 * Normal trace_printk() and friends allocates special buffers
86791 diff --git a/kernel/trace/trace_clock.c b/kernel/trace/trace_clock.c
86792 index 26dc348..8708ca7 100644
86793 --- a/kernel/trace/trace_clock.c
86794 +++ b/kernel/trace/trace_clock.c
86795 @@ -123,7 +123,7 @@ u64 notrace trace_clock_global(void)
86796 return now;
86797 }
86798
86799 -static atomic64_t trace_counter;
86800 +static atomic64_unchecked_t trace_counter;
86801
86802 /*
86803 * trace_clock_counter(): simply an atomic counter.
86804 @@ -132,5 +132,5 @@ static atomic64_t trace_counter;
86805 */
86806 u64 notrace trace_clock_counter(void)
86807 {
86808 - return atomic64_add_return(1, &trace_counter);
86809 + return atomic64_inc_return_unchecked(&trace_counter);
86810 }
86811 diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
86812 index 368a4d5..7b6d1d5 100644
86813 --- a/kernel/trace/trace_events.c
86814 +++ b/kernel/trace/trace_events.c
86815 @@ -1673,7 +1673,6 @@ __trace_early_add_new_event(struct ftrace_event_call *call,
86816 return 0;
86817 }
86818
86819 -struct ftrace_module_file_ops;
86820 static void __add_event_to_tracers(struct ftrace_event_call *call);
86821
86822 /* Add an additional event_call dynamically */
86823 diff --git a/kernel/trace/trace_mmiotrace.c b/kernel/trace/trace_mmiotrace.c
86824 index b3dcfb2..ebee344 100644
86825 --- a/kernel/trace/trace_mmiotrace.c
86826 +++ b/kernel/trace/trace_mmiotrace.c
86827 @@ -24,7 +24,7 @@ struct header_iter {
86828 static struct trace_array *mmio_trace_array;
86829 static bool overrun_detected;
86830 static unsigned long prev_overruns;
86831 -static atomic_t dropped_count;
86832 +static atomic_unchecked_t dropped_count;
86833
86834 static void mmio_reset_data(struct trace_array *tr)
86835 {
86836 @@ -127,7 +127,7 @@ static void mmio_close(struct trace_iterator *iter)
86837
86838 static unsigned long count_overruns(struct trace_iterator *iter)
86839 {
86840 - unsigned long cnt = atomic_xchg(&dropped_count, 0);
86841 + unsigned long cnt = atomic_xchg_unchecked(&dropped_count, 0);
86842 unsigned long over = ring_buffer_overruns(iter->trace_buffer->buffer);
86843
86844 if (over > prev_overruns)
86845 @@ -317,7 +317,7 @@ static void __trace_mmiotrace_rw(struct trace_array *tr,
86846 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_RW,
86847 sizeof(*entry), 0, pc);
86848 if (!event) {
86849 - atomic_inc(&dropped_count);
86850 + atomic_inc_unchecked(&dropped_count);
86851 return;
86852 }
86853 entry = ring_buffer_event_data(event);
86854 @@ -347,7 +347,7 @@ static void __trace_mmiotrace_map(struct trace_array *tr,
86855 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_MAP,
86856 sizeof(*entry), 0, pc);
86857 if (!event) {
86858 - atomic_inc(&dropped_count);
86859 + atomic_inc_unchecked(&dropped_count);
86860 return;
86861 }
86862 entry = ring_buffer_event_data(event);
86863 diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
86864 index 34e7cba..6f9a729 100644
86865 --- a/kernel/trace/trace_output.c
86866 +++ b/kernel/trace/trace_output.c
86867 @@ -294,7 +294,7 @@ int trace_seq_path(struct trace_seq *s, const struct path *path)
86868
86869 p = d_path(path, s->buffer + s->len, PAGE_SIZE - s->len);
86870 if (!IS_ERR(p)) {
86871 - p = mangle_path(s->buffer + s->len, p, "\n");
86872 + p = mangle_path(s->buffer + s->len, p, "\n\\");
86873 if (p) {
86874 s->len = p - s->buffer;
86875 return 1;
86876 @@ -893,14 +893,16 @@ int register_ftrace_event(struct trace_event *event)
86877 goto out;
86878 }
86879
86880 + pax_open_kernel();
86881 if (event->funcs->trace == NULL)
86882 - event->funcs->trace = trace_nop_print;
86883 + *(void **)&event->funcs->trace = trace_nop_print;
86884 if (event->funcs->raw == NULL)
86885 - event->funcs->raw = trace_nop_print;
86886 + *(void **)&event->funcs->raw = trace_nop_print;
86887 if (event->funcs->hex == NULL)
86888 - event->funcs->hex = trace_nop_print;
86889 + *(void **)&event->funcs->hex = trace_nop_print;
86890 if (event->funcs->binary == NULL)
86891 - event->funcs->binary = trace_nop_print;
86892 + *(void **)&event->funcs->binary = trace_nop_print;
86893 + pax_close_kernel();
86894
86895 key = event->type & (EVENT_HASHSIZE - 1);
86896
86897 diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c
86898 index b20428c..4845a10 100644
86899 --- a/kernel/trace/trace_stack.c
86900 +++ b/kernel/trace/trace_stack.c
86901 @@ -68,7 +68,7 @@ check_stack(unsigned long ip, unsigned long *stack)
86902 return;
86903
86904 /* we do not handle interrupt stacks yet */
86905 - if (!object_is_on_stack(stack))
86906 + if (!object_starts_on_stack(stack))
86907 return;
86908
86909 local_irq_save(flags);
86910 diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c
86911 index 13fb113..a6ced3f 100644
86912 --- a/kernel/user_namespace.c
86913 +++ b/kernel/user_namespace.c
86914 @@ -82,6 +82,21 @@ int create_user_ns(struct cred *new)
86915 !kgid_has_mapping(parent_ns, group))
86916 return -EPERM;
86917
86918 +#ifdef CONFIG_GRKERNSEC
86919 + /*
86920 + * This doesn't really inspire confidence:
86921 + * http://marc.info/?l=linux-kernel&m=135543612731939&w=2
86922 + * http://marc.info/?l=linux-kernel&m=135545831607095&w=2
86923 + * Increases kernel attack surface in areas developers
86924 + * previously cared little about ("low importance due
86925 + * to requiring "root" capability")
86926 + * To be removed when this code receives *proper* review
86927 + */
86928 + if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SETUID) ||
86929 + !capable(CAP_SETGID))
86930 + return -EPERM;
86931 +#endif
86932 +
86933 ns = kmem_cache_zalloc(user_ns_cachep, GFP_KERNEL);
86934 if (!ns)
86935 return -ENOMEM;
86936 @@ -860,7 +875,7 @@ static int userns_install(struct nsproxy *nsproxy, void *ns)
86937 if (atomic_read(&current->mm->mm_users) > 1)
86938 return -EINVAL;
86939
86940 - if (current->fs->users != 1)
86941 + if (atomic_read(&current->fs->users) != 1)
86942 return -EINVAL;
86943
86944 if (!ns_capable(user_ns, CAP_SYS_ADMIN))
86945 diff --git a/kernel/utsname_sysctl.c b/kernel/utsname_sysctl.c
86946 index 4f69f9a..7c6f8f8 100644
86947 --- a/kernel/utsname_sysctl.c
86948 +++ b/kernel/utsname_sysctl.c
86949 @@ -47,7 +47,7 @@ static void put_uts(ctl_table *table, int write, void *which)
86950 static int proc_do_uts_string(ctl_table *table, int write,
86951 void __user *buffer, size_t *lenp, loff_t *ppos)
86952 {
86953 - struct ctl_table uts_table;
86954 + ctl_table_no_const uts_table;
86955 int r;
86956 memcpy(&uts_table, table, sizeof(uts_table));
86957 uts_table.data = get_uts(table, write);
86958 diff --git a/kernel/watchdog.c b/kernel/watchdog.c
86959 index 4431610..4265616 100644
86960 --- a/kernel/watchdog.c
86961 +++ b/kernel/watchdog.c
86962 @@ -475,7 +475,7 @@ static int watchdog_nmi_enable(unsigned int cpu) { return 0; }
86963 static void watchdog_nmi_disable(unsigned int cpu) { return; }
86964 #endif /* CONFIG_HARDLOCKUP_DETECTOR */
86965
86966 -static struct smp_hotplug_thread watchdog_threads = {
86967 +static struct smp_hotplug_thread watchdog_threads __read_only = {
86968 .store = &softlockup_watchdog,
86969 .thread_should_run = watchdog_should_run,
86970 .thread_fn = watchdog,
86971 diff --git a/kernel/workqueue.c b/kernel/workqueue.c
86972 index 93c2652..66a1cfd 100644
86973 --- a/kernel/workqueue.c
86974 +++ b/kernel/workqueue.c
86975 @@ -4668,7 +4668,7 @@ static void rebind_workers(struct worker_pool *pool)
86976 WARN_ON_ONCE(!(worker_flags & WORKER_UNBOUND));
86977 worker_flags |= WORKER_REBOUND;
86978 worker_flags &= ~WORKER_UNBOUND;
86979 - ACCESS_ONCE(worker->flags) = worker_flags;
86980 + ACCESS_ONCE_RW(worker->flags) = worker_flags;
86981 }
86982
86983 spin_unlock_irq(&pool->lock);
86984 diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
86985 index 094f315..244a824 100644
86986 --- a/lib/Kconfig.debug
86987 +++ b/lib/Kconfig.debug
86988 @@ -836,7 +836,7 @@ config DEBUG_MUTEXES
86989
86990 config DEBUG_WW_MUTEX_SLOWPATH
86991 bool "Wait/wound mutex debugging: Slowpath testing"
86992 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
86993 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
86994 select DEBUG_LOCK_ALLOC
86995 select DEBUG_SPINLOCK
86996 select DEBUG_MUTEXES
86997 @@ -849,7 +849,7 @@ config DEBUG_WW_MUTEX_SLOWPATH
86998
86999 config DEBUG_LOCK_ALLOC
87000 bool "Lock debugging: detect incorrect freeing of live locks"
87001 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
87002 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
87003 select DEBUG_SPINLOCK
87004 select DEBUG_MUTEXES
87005 select LOCKDEP
87006 @@ -863,7 +863,7 @@ config DEBUG_LOCK_ALLOC
87007
87008 config PROVE_LOCKING
87009 bool "Lock debugging: prove locking correctness"
87010 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
87011 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
87012 select LOCKDEP
87013 select DEBUG_SPINLOCK
87014 select DEBUG_MUTEXES
87015 @@ -914,7 +914,7 @@ config LOCKDEP
87016
87017 config LOCK_STAT
87018 bool "Lock usage statistics"
87019 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
87020 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
87021 select LOCKDEP
87022 select DEBUG_SPINLOCK
87023 select DEBUG_MUTEXES
87024 @@ -1376,6 +1376,7 @@ config LATENCYTOP
87025 depends on DEBUG_KERNEL
87026 depends on STACKTRACE_SUPPORT
87027 depends on PROC_FS
87028 + depends on !GRKERNSEC_HIDESYM
87029 select FRAME_POINTER if !MIPS && !PPC && !S390 && !MICROBLAZE && !ARM_UNWIND && !ARC
87030 select KALLSYMS
87031 select KALLSYMS_ALL
87032 @@ -1392,7 +1393,7 @@ config ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
87033 config DEBUG_STRICT_USER_COPY_CHECKS
87034 bool "Strict user copy size checks"
87035 depends on ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
87036 - depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING
87037 + depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING && !PAX_SIZE_OVERFLOW
87038 help
87039 Enabling this option turns a certain set of sanity checks for user
87040 copy operations into compile time failures.
87041 @@ -1502,7 +1503,7 @@ endmenu # runtime tests
87042
87043 config PROVIDE_OHCI1394_DMA_INIT
87044 bool "Remote debugging over FireWire early on boot"
87045 - depends on PCI && X86
87046 + depends on PCI && X86 && !GRKERNSEC
87047 help
87048 If you want to debug problems which hang or crash the kernel early
87049 on boot and the crashing machine has a FireWire port, you can use
87050 @@ -1531,7 +1532,7 @@ config PROVIDE_OHCI1394_DMA_INIT
87051
87052 config FIREWIRE_OHCI_REMOTE_DMA
87053 bool "Remote debugging over FireWire with firewire-ohci"
87054 - depends on FIREWIRE_OHCI
87055 + depends on FIREWIRE_OHCI && !GRKERNSEC
87056 help
87057 This option lets you use the FireWire bus for remote debugging
87058 with help of the firewire-ohci driver. It enables unfiltered
87059 diff --git a/lib/Makefile b/lib/Makefile
87060 index f3bb2cb..b358ace 100644
87061 --- a/lib/Makefile
87062 +++ b/lib/Makefile
87063 @@ -52,7 +52,7 @@ obj-$(CONFIG_GENERIC_HWEIGHT) += hweight.o
87064
87065 obj-$(CONFIG_BTREE) += btree.o
87066 obj-$(CONFIG_DEBUG_PREEMPT) += smp_processor_id.o
87067 -obj-$(CONFIG_DEBUG_LIST) += list_debug.o
87068 +obj-y += list_debug.o
87069 obj-$(CONFIG_DEBUG_OBJECTS) += debugobjects.o
87070
87071 ifneq ($(CONFIG_HAVE_DEC_LOCK),y)
87072 diff --git a/lib/bitmap.c b/lib/bitmap.c
87073 index 06f7e4f..f3cf2b0 100644
87074 --- a/lib/bitmap.c
87075 +++ b/lib/bitmap.c
87076 @@ -422,7 +422,7 @@ int __bitmap_parse(const char *buf, unsigned int buflen,
87077 {
87078 int c, old_c, totaldigits, ndigits, nchunks, nbits;
87079 u32 chunk;
87080 - const char __user __force *ubuf = (const char __user __force *)buf;
87081 + const char __user *ubuf = (const char __force_user *)buf;
87082
87083 bitmap_zero(maskp, nmaskbits);
87084
87085 @@ -507,7 +507,7 @@ int bitmap_parse_user(const char __user *ubuf,
87086 {
87087 if (!access_ok(VERIFY_READ, ubuf, ulen))
87088 return -EFAULT;
87089 - return __bitmap_parse((const char __force *)ubuf,
87090 + return __bitmap_parse((const char __force_kernel *)ubuf,
87091 ulen, 1, maskp, nmaskbits);
87092
87093 }
87094 @@ -598,7 +598,7 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen,
87095 {
87096 unsigned a, b;
87097 int c, old_c, totaldigits;
87098 - const char __user __force *ubuf = (const char __user __force *)buf;
87099 + const char __user *ubuf = (const char __force_user *)buf;
87100 int exp_digit, in_range;
87101
87102 totaldigits = c = 0;
87103 @@ -698,7 +698,7 @@ int bitmap_parselist_user(const char __user *ubuf,
87104 {
87105 if (!access_ok(VERIFY_READ, ubuf, ulen))
87106 return -EFAULT;
87107 - return __bitmap_parselist((const char __force *)ubuf,
87108 + return __bitmap_parselist((const char __force_kernel *)ubuf,
87109 ulen, 1, maskp, nmaskbits);
87110 }
87111 EXPORT_SYMBOL(bitmap_parselist_user);
87112 diff --git a/lib/bug.c b/lib/bug.c
87113 index 1686034..a9c00c8 100644
87114 --- a/lib/bug.c
87115 +++ b/lib/bug.c
87116 @@ -134,6 +134,8 @@ enum bug_trap_type report_bug(unsigned long bugaddr, struct pt_regs *regs)
87117 return BUG_TRAP_TYPE_NONE;
87118
87119 bug = find_bug(bugaddr);
87120 + if (!bug)
87121 + return BUG_TRAP_TYPE_NONE;
87122
87123 file = NULL;
87124 line = 0;
87125 diff --git a/lib/debugobjects.c b/lib/debugobjects.c
87126 index bf2c8b1..1d00ccf 100644
87127 --- a/lib/debugobjects.c
87128 +++ b/lib/debugobjects.c
87129 @@ -286,7 +286,7 @@ static void debug_object_is_on_stack(void *addr, int onstack)
87130 if (limit > 4)
87131 return;
87132
87133 - is_on_stack = object_is_on_stack(addr);
87134 + is_on_stack = object_starts_on_stack(addr);
87135 if (is_on_stack == onstack)
87136 return;
87137
87138 diff --git a/lib/devres.c b/lib/devres.c
87139 index 8235331..5881053 100644
87140 --- a/lib/devres.c
87141 +++ b/lib/devres.c
87142 @@ -81,7 +81,7 @@ EXPORT_SYMBOL(devm_ioremap_nocache);
87143 void devm_iounmap(struct device *dev, void __iomem *addr)
87144 {
87145 WARN_ON(devres_destroy(dev, devm_ioremap_release, devm_ioremap_match,
87146 - (void *)addr));
87147 + (void __force *)addr));
87148 iounmap(addr);
87149 }
87150 EXPORT_SYMBOL(devm_iounmap);
87151 @@ -224,7 +224,7 @@ void devm_ioport_unmap(struct device *dev, void __iomem *addr)
87152 {
87153 ioport_unmap(addr);
87154 WARN_ON(devres_destroy(dev, devm_ioport_map_release,
87155 - devm_ioport_map_match, (void *)addr));
87156 + devm_ioport_map_match, (void __force *)addr));
87157 }
87158 EXPORT_SYMBOL(devm_ioport_unmap);
87159 #endif /* CONFIG_HAS_IOPORT */
87160 diff --git a/lib/div64.c b/lib/div64.c
87161 index 4382ad7..08aa558 100644
87162 --- a/lib/div64.c
87163 +++ b/lib/div64.c
87164 @@ -59,7 +59,7 @@ uint32_t __attribute__((weak)) __div64_32(uint64_t *n, uint32_t base)
87165 EXPORT_SYMBOL(__div64_32);
87166
87167 #ifndef div_s64_rem
87168 -s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
87169 +s64 __intentional_overflow(-1) div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
87170 {
87171 u64 quotient;
87172
87173 @@ -130,7 +130,7 @@ EXPORT_SYMBOL(div64_u64_rem);
87174 * 'http://www.hackersdelight.org/HDcode/newCode/divDouble.c.txt'
87175 */
87176 #ifndef div64_u64
87177 -u64 div64_u64(u64 dividend, u64 divisor)
87178 +u64 __intentional_overflow(-1) div64_u64(u64 dividend, u64 divisor)
87179 {
87180 u32 high = divisor >> 32;
87181 u64 quot;
87182 diff --git a/lib/dma-debug.c b/lib/dma-debug.c
87183 index d87a17a..ac0d79a 100644
87184 --- a/lib/dma-debug.c
87185 +++ b/lib/dma-debug.c
87186 @@ -768,7 +768,7 @@ static int dma_debug_device_change(struct notifier_block *nb, unsigned long acti
87187
87188 void dma_debug_add_bus(struct bus_type *bus)
87189 {
87190 - struct notifier_block *nb;
87191 + notifier_block_no_const *nb;
87192
87193 if (global_disable)
87194 return;
87195 @@ -945,7 +945,7 @@ static void check_unmap(struct dma_debug_entry *ref)
87196
87197 static void check_for_stack(struct device *dev, void *addr)
87198 {
87199 - if (object_is_on_stack(addr))
87200 + if (object_starts_on_stack(addr))
87201 err_printk(dev, NULL, "DMA-API: device driver maps memory from"
87202 "stack [addr=%p]\n", addr);
87203 }
87204 diff --git a/lib/inflate.c b/lib/inflate.c
87205 index 013a761..c28f3fc 100644
87206 --- a/lib/inflate.c
87207 +++ b/lib/inflate.c
87208 @@ -269,7 +269,7 @@ static void free(void *where)
87209 malloc_ptr = free_mem_ptr;
87210 }
87211 #else
87212 -#define malloc(a) kmalloc(a, GFP_KERNEL)
87213 +#define malloc(a) kmalloc((a), GFP_KERNEL)
87214 #define free(a) kfree(a)
87215 #endif
87216
87217 diff --git a/lib/ioremap.c b/lib/ioremap.c
87218 index 0c9216c..863bd89 100644
87219 --- a/lib/ioremap.c
87220 +++ b/lib/ioremap.c
87221 @@ -38,7 +38,7 @@ static inline int ioremap_pmd_range(pud_t *pud, unsigned long addr,
87222 unsigned long next;
87223
87224 phys_addr -= addr;
87225 - pmd = pmd_alloc(&init_mm, pud, addr);
87226 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
87227 if (!pmd)
87228 return -ENOMEM;
87229 do {
87230 @@ -56,7 +56,7 @@ static inline int ioremap_pud_range(pgd_t *pgd, unsigned long addr,
87231 unsigned long next;
87232
87233 phys_addr -= addr;
87234 - pud = pud_alloc(&init_mm, pgd, addr);
87235 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
87236 if (!pud)
87237 return -ENOMEM;
87238 do {
87239 diff --git a/lib/is_single_threaded.c b/lib/is_single_threaded.c
87240 index bd2bea9..6b3c95e 100644
87241 --- a/lib/is_single_threaded.c
87242 +++ b/lib/is_single_threaded.c
87243 @@ -22,6 +22,9 @@ bool current_is_single_threaded(void)
87244 struct task_struct *p, *t;
87245 bool ret;
87246
87247 + if (!mm)
87248 + return true;
87249 +
87250 if (atomic_read(&task->signal->live) != 1)
87251 return false;
87252
87253 diff --git a/lib/kobject.c b/lib/kobject.c
87254 index 084f7b1..d265b8a 100644
87255 --- a/lib/kobject.c
87256 +++ b/lib/kobject.c
87257 @@ -875,9 +875,9 @@ EXPORT_SYMBOL_GPL(kset_create_and_add);
87258
87259
87260 static DEFINE_SPINLOCK(kobj_ns_type_lock);
87261 -static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES];
87262 +static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES] __read_only;
87263
87264 -int kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
87265 +int __init kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
87266 {
87267 enum kobj_ns_type type = ops->type;
87268 int error;
87269 diff --git a/lib/list_debug.c b/lib/list_debug.c
87270 index c24c2f7..f0296f4 100644
87271 --- a/lib/list_debug.c
87272 +++ b/lib/list_debug.c
87273 @@ -11,7 +11,9 @@
87274 #include <linux/bug.h>
87275 #include <linux/kernel.h>
87276 #include <linux/rculist.h>
87277 +#include <linux/mm.h>
87278
87279 +#ifdef CONFIG_DEBUG_LIST
87280 /*
87281 * Insert a new entry between two known consecutive entries.
87282 *
87283 @@ -19,21 +21,40 @@
87284 * the prev/next entries already!
87285 */
87286
87287 +static bool __list_add_debug(struct list_head *new,
87288 + struct list_head *prev,
87289 + struct list_head *next)
87290 +{
87291 + if (unlikely(next->prev != prev)) {
87292 + printk(KERN_ERR "list_add corruption. next->prev should be "
87293 + "prev (%p), but was %p. (next=%p).\n",
87294 + prev, next->prev, next);
87295 + BUG();
87296 + return false;
87297 + }
87298 + if (unlikely(prev->next != next)) {
87299 + printk(KERN_ERR "list_add corruption. prev->next should be "
87300 + "next (%p), but was %p. (prev=%p).\n",
87301 + next, prev->next, prev);
87302 + BUG();
87303 + return false;
87304 + }
87305 + if (unlikely(new == prev || new == next)) {
87306 + printk(KERN_ERR "list_add double add: new=%p, prev=%p, next=%p.\n",
87307 + new, prev, next);
87308 + BUG();
87309 + return false;
87310 + }
87311 + return true;
87312 +}
87313 +
87314 void __list_add(struct list_head *new,
87315 - struct list_head *prev,
87316 - struct list_head *next)
87317 + struct list_head *prev,
87318 + struct list_head *next)
87319 {
87320 - WARN(next->prev != prev,
87321 - "list_add corruption. next->prev should be "
87322 - "prev (%p), but was %p. (next=%p).\n",
87323 - prev, next->prev, next);
87324 - WARN(prev->next != next,
87325 - "list_add corruption. prev->next should be "
87326 - "next (%p), but was %p. (prev=%p).\n",
87327 - next, prev->next, prev);
87328 - WARN(new == prev || new == next,
87329 - "list_add double add: new=%p, prev=%p, next=%p.\n",
87330 - new, prev, next);
87331 + if (!__list_add_debug(new, prev, next))
87332 + return;
87333 +
87334 next->prev = new;
87335 new->next = next;
87336 new->prev = prev;
87337 @@ -41,28 +62,46 @@ void __list_add(struct list_head *new,
87338 }
87339 EXPORT_SYMBOL(__list_add);
87340
87341 -void __list_del_entry(struct list_head *entry)
87342 +static bool __list_del_entry_debug(struct list_head *entry)
87343 {
87344 struct list_head *prev, *next;
87345
87346 prev = entry->prev;
87347 next = entry->next;
87348
87349 - if (WARN(next == LIST_POISON1,
87350 - "list_del corruption, %p->next is LIST_POISON1 (%p)\n",
87351 - entry, LIST_POISON1) ||
87352 - WARN(prev == LIST_POISON2,
87353 - "list_del corruption, %p->prev is LIST_POISON2 (%p)\n",
87354 - entry, LIST_POISON2) ||
87355 - WARN(prev->next != entry,
87356 - "list_del corruption. prev->next should be %p, "
87357 - "but was %p\n", entry, prev->next) ||
87358 - WARN(next->prev != entry,
87359 - "list_del corruption. next->prev should be %p, "
87360 - "but was %p\n", entry, next->prev))
87361 + if (unlikely(next == LIST_POISON1)) {
87362 + printk(KERN_ERR "list_del corruption, %p->next is LIST_POISON1 (%p)\n",
87363 + entry, LIST_POISON1);
87364 + BUG();
87365 + return false;
87366 + }
87367 + if (unlikely(prev == LIST_POISON2)) {
87368 + printk(KERN_ERR "list_del corruption, %p->prev is LIST_POISON2 (%p)\n",
87369 + entry, LIST_POISON2);
87370 + BUG();
87371 + return false;
87372 + }
87373 + if (unlikely(entry->prev->next != entry)) {
87374 + printk(KERN_ERR "list_del corruption. prev->next should be %p, "
87375 + "but was %p\n", entry, prev->next);
87376 + BUG();
87377 + return false;
87378 + }
87379 + if (unlikely(entry->next->prev != entry)) {
87380 + printk(KERN_ERR "list_del corruption. next->prev should be %p, "
87381 + "but was %p\n", entry, next->prev);
87382 + BUG();
87383 + return false;
87384 + }
87385 + return true;
87386 +}
87387 +
87388 +void __list_del_entry(struct list_head *entry)
87389 +{
87390 + if (!__list_del_entry_debug(entry))
87391 return;
87392
87393 - __list_del(prev, next);
87394 + __list_del(entry->prev, entry->next);
87395 }
87396 EXPORT_SYMBOL(__list_del_entry);
87397
87398 @@ -86,15 +125,85 @@ EXPORT_SYMBOL(list_del);
87399 void __list_add_rcu(struct list_head *new,
87400 struct list_head *prev, struct list_head *next)
87401 {
87402 - WARN(next->prev != prev,
87403 - "list_add_rcu corruption. next->prev should be prev (%p), but was %p. (next=%p).\n",
87404 - prev, next->prev, next);
87405 - WARN(prev->next != next,
87406 - "list_add_rcu corruption. prev->next should be next (%p), but was %p. (prev=%p).\n",
87407 - next, prev->next, prev);
87408 + if (!__list_add_debug(new, prev, next))
87409 + return;
87410 +
87411 new->next = next;
87412 new->prev = prev;
87413 rcu_assign_pointer(list_next_rcu(prev), new);
87414 next->prev = new;
87415 }
87416 EXPORT_SYMBOL(__list_add_rcu);
87417 +#endif
87418 +
87419 +void __pax_list_add(struct list_head *new, struct list_head *prev, struct list_head *next)
87420 +{
87421 +#ifdef CONFIG_DEBUG_LIST
87422 + if (!__list_add_debug(new, prev, next))
87423 + return;
87424 +#endif
87425 +
87426 + pax_open_kernel();
87427 + next->prev = new;
87428 + new->next = next;
87429 + new->prev = prev;
87430 + prev->next = new;
87431 + pax_close_kernel();
87432 +}
87433 +EXPORT_SYMBOL(__pax_list_add);
87434 +
87435 +void pax_list_del(struct list_head *entry)
87436 +{
87437 +#ifdef CONFIG_DEBUG_LIST
87438 + if (!__list_del_entry_debug(entry))
87439 + return;
87440 +#endif
87441 +
87442 + pax_open_kernel();
87443 + __list_del(entry->prev, entry->next);
87444 + entry->next = LIST_POISON1;
87445 + entry->prev = LIST_POISON2;
87446 + pax_close_kernel();
87447 +}
87448 +EXPORT_SYMBOL(pax_list_del);
87449 +
87450 +void pax_list_del_init(struct list_head *entry)
87451 +{
87452 + pax_open_kernel();
87453 + __list_del(entry->prev, entry->next);
87454 + INIT_LIST_HEAD(entry);
87455 + pax_close_kernel();
87456 +}
87457 +EXPORT_SYMBOL(pax_list_del_init);
87458 +
87459 +void __pax_list_add_rcu(struct list_head *new,
87460 + struct list_head *prev, struct list_head *next)
87461 +{
87462 +#ifdef CONFIG_DEBUG_LIST
87463 + if (!__list_add_debug(new, prev, next))
87464 + return;
87465 +#endif
87466 +
87467 + pax_open_kernel();
87468 + new->next = next;
87469 + new->prev = prev;
87470 + rcu_assign_pointer(list_next_rcu(prev), new);
87471 + next->prev = new;
87472 + pax_close_kernel();
87473 +}
87474 +EXPORT_SYMBOL(__pax_list_add_rcu);
87475 +
87476 +void pax_list_del_rcu(struct list_head *entry)
87477 +{
87478 +#ifdef CONFIG_DEBUG_LIST
87479 + if (!__list_del_entry_debug(entry))
87480 + return;
87481 +#endif
87482 +
87483 + pax_open_kernel();
87484 + __list_del(entry->prev, entry->next);
87485 + entry->next = LIST_POISON1;
87486 + entry->prev = LIST_POISON2;
87487 + pax_close_kernel();
87488 +}
87489 +EXPORT_SYMBOL(pax_list_del_rcu);
87490 diff --git a/lib/percpu-refcount.c b/lib/percpu-refcount.c
87491 index 1a53d49..ace934c 100644
87492 --- a/lib/percpu-refcount.c
87493 +++ b/lib/percpu-refcount.c
87494 @@ -29,7 +29,7 @@
87495 * can't hit 0 before we've added up all the percpu refs.
87496 */
87497
87498 -#define PCPU_COUNT_BIAS (1U << 31)
87499 +#define PCPU_COUNT_BIAS (1U << 30)
87500
87501 /**
87502 * percpu_ref_init - initialize a percpu refcount
87503 diff --git a/lib/radix-tree.c b/lib/radix-tree.c
87504 index 7811ed3..f80ca19 100644
87505 --- a/lib/radix-tree.c
87506 +++ b/lib/radix-tree.c
87507 @@ -93,7 +93,7 @@ struct radix_tree_preload {
87508 int nr;
87509 struct radix_tree_node *nodes[RADIX_TREE_PRELOAD_SIZE];
87510 };
87511 -static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads) = { 0, };
87512 +static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads);
87513
87514 static inline void *ptr_to_indirect(void *ptr)
87515 {
87516 diff --git a/lib/strncpy_from_user.c b/lib/strncpy_from_user.c
87517 index bb2b201..46abaf9 100644
87518 --- a/lib/strncpy_from_user.c
87519 +++ b/lib/strncpy_from_user.c
87520 @@ -21,7 +21,7 @@
87521 */
87522 static inline long do_strncpy_from_user(char *dst, const char __user *src, long count, unsigned long max)
87523 {
87524 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
87525 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
87526 long res = 0;
87527
87528 /*
87529 diff --git a/lib/strnlen_user.c b/lib/strnlen_user.c
87530 index a28df52..3d55877 100644
87531 --- a/lib/strnlen_user.c
87532 +++ b/lib/strnlen_user.c
87533 @@ -26,7 +26,7 @@
87534 */
87535 static inline long do_strnlen_user(const char __user *src, unsigned long count, unsigned long max)
87536 {
87537 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
87538 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
87539 long align, res = 0;
87540 unsigned long c;
87541
87542 diff --git a/lib/swiotlb.c b/lib/swiotlb.c
87543 index 4e8686c..3e8c92f 100644
87544 --- a/lib/swiotlb.c
87545 +++ b/lib/swiotlb.c
87546 @@ -664,7 +664,7 @@ EXPORT_SYMBOL(swiotlb_alloc_coherent);
87547
87548 void
87549 swiotlb_free_coherent(struct device *hwdev, size_t size, void *vaddr,
87550 - dma_addr_t dev_addr)
87551 + dma_addr_t dev_addr, struct dma_attrs *attrs)
87552 {
87553 phys_addr_t paddr = dma_to_phys(hwdev, dev_addr);
87554
87555 diff --git a/lib/usercopy.c b/lib/usercopy.c
87556 index 4f5b1dd..7cab418 100644
87557 --- a/lib/usercopy.c
87558 +++ b/lib/usercopy.c
87559 @@ -7,3 +7,9 @@ void copy_from_user_overflow(void)
87560 WARN(1, "Buffer overflow detected!\n");
87561 }
87562 EXPORT_SYMBOL(copy_from_user_overflow);
87563 +
87564 +void copy_to_user_overflow(void)
87565 +{
87566 + WARN(1, "Buffer overflow detected!\n");
87567 +}
87568 +EXPORT_SYMBOL(copy_to_user_overflow);
87569 diff --git a/lib/vsprintf.c b/lib/vsprintf.c
87570 index d76555c..62d4bfe 100644
87571 --- a/lib/vsprintf.c
87572 +++ b/lib/vsprintf.c
87573 @@ -16,6 +16,9 @@
87574 * - scnprintf and vscnprintf
87575 */
87576
87577 +#ifdef CONFIG_GRKERNSEC_HIDESYM
87578 +#define __INCLUDED_BY_HIDESYM 1
87579 +#endif
87580 #include <stdarg.h>
87581 #include <linux/module.h> /* for KSYM_SYMBOL_LEN */
87582 #include <linux/types.h>
87583 @@ -1155,7 +1158,11 @@ char *netdev_feature_string(char *buf, char *end, const u8 *addr,
87584 return number(buf, end, *(const netdev_features_t *)addr, spec);
87585 }
87586
87587 +#ifdef CONFIG_GRKERNSEC_HIDESYM
87588 +int kptr_restrict __read_mostly = 2;
87589 +#else
87590 int kptr_restrict __read_mostly;
87591 +#endif
87592
87593 /*
87594 * Show a '%p' thing. A kernel extension is that the '%p' is followed
87595 @@ -1168,6 +1175,7 @@ int kptr_restrict __read_mostly;
87596 * - 'f' For simple symbolic function names without offset
87597 * - 'S' For symbolic direct pointers with offset
87598 * - 's' For symbolic direct pointers without offset
87599 + * - 'A' For symbolic direct pointers with offset approved for use with GRKERNSEC_HIDESYM
87600 * - '[FfSs]R' as above with __builtin_extract_return_addr() translation
87601 * - 'B' For backtraced symbolic direct pointers with offset
87602 * - 'R' For decoded struct resource, e.g., [mem 0x0-0x1f 64bit pref]
87603 @@ -1232,12 +1240,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
87604
87605 if (!ptr && *fmt != 'K') {
87606 /*
87607 - * Print (null) with the same width as a pointer so it makes
87608 + * Print (nil) with the same width as a pointer so it makes
87609 * tabular output look nice.
87610 */
87611 if (spec.field_width == -1)
87612 spec.field_width = default_width;
87613 - return string(buf, end, "(null)", spec);
87614 + return string(buf, end, "(nil)", spec);
87615 }
87616
87617 switch (*fmt) {
87618 @@ -1247,6 +1255,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
87619 /* Fallthrough */
87620 case 'S':
87621 case 's':
87622 +#ifdef CONFIG_GRKERNSEC_HIDESYM
87623 + break;
87624 +#else
87625 + return symbol_string(buf, end, ptr, spec, fmt);
87626 +#endif
87627 + case 'A':
87628 case 'B':
87629 return symbol_string(buf, end, ptr, spec, fmt);
87630 case 'R':
87631 @@ -1302,6 +1316,8 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
87632 va_end(va);
87633 return buf;
87634 }
87635 + case 'P':
87636 + break;
87637 case 'K':
87638 /*
87639 * %pK cannot be used in IRQ context because its test
87640 @@ -1363,6 +1379,21 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
87641 ((const struct file *)ptr)->f_path.dentry,
87642 spec, fmt);
87643 }
87644 +
87645 +#ifdef CONFIG_GRKERNSEC_HIDESYM
87646 + /* 'P' = approved pointers to copy to userland,
87647 + as in the /proc/kallsyms case, as we make it display nothing
87648 + for non-root users, and the real contents for root users
87649 + Also ignore 'K' pointers, since we force their NULLing for non-root users
87650 + above
87651 + */
87652 + if ((unsigned long)ptr > TASK_SIZE && *fmt != 'P' && *fmt != 'K' && is_usercopy_object(buf)) {
87653 + printk(KERN_ALERT "grsec: kernel infoleak detected! Please report this log to spender@grsecurity.net.\n");
87654 + dump_stack();
87655 + ptr = NULL;
87656 + }
87657 +#endif
87658 +
87659 spec.flags |= SMALL;
87660 if (spec.field_width == -1) {
87661 spec.field_width = default_width;
87662 @@ -2086,11 +2117,11 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
87663 typeof(type) value; \
87664 if (sizeof(type) == 8) { \
87665 args = PTR_ALIGN(args, sizeof(u32)); \
87666 - *(u32 *)&value = *(u32 *)args; \
87667 - *((u32 *)&value + 1) = *(u32 *)(args + 4); \
87668 + *(u32 *)&value = *(const u32 *)args; \
87669 + *((u32 *)&value + 1) = *(const u32 *)(args + 4); \
87670 } else { \
87671 args = PTR_ALIGN(args, sizeof(type)); \
87672 - value = *(typeof(type) *)args; \
87673 + value = *(const typeof(type) *)args; \
87674 } \
87675 args += sizeof(type); \
87676 value; \
87677 @@ -2153,7 +2184,7 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
87678 case FORMAT_TYPE_STR: {
87679 const char *str_arg = args;
87680 args += strlen(str_arg) + 1;
87681 - str = string(str, end, (char *)str_arg, spec);
87682 + str = string(str, end, str_arg, spec);
87683 break;
87684 }
87685
87686 diff --git a/localversion-grsec b/localversion-grsec
87687 new file mode 100644
87688 index 0000000..7cd6065
87689 --- /dev/null
87690 +++ b/localversion-grsec
87691 @@ -0,0 +1 @@
87692 +-grsec
87693 diff --git a/mm/Kconfig b/mm/Kconfig
87694 index 394838f..0e5f816 100644
87695 --- a/mm/Kconfig
87696 +++ b/mm/Kconfig
87697 @@ -317,10 +317,11 @@ config KSM
87698 root has set /sys/kernel/mm/ksm/run to 1 (if CONFIG_SYSFS is set).
87699
87700 config DEFAULT_MMAP_MIN_ADDR
87701 - int "Low address space to protect from user allocation"
87702 + int "Low address space to protect from user allocation"
87703 depends on MMU
87704 - default 4096
87705 - help
87706 + default 32768 if ALPHA || ARM || PARISC || SPARC32
87707 + default 65536
87708 + help
87709 This is the portion of low virtual memory which should be protected
87710 from userspace allocation. Keeping a user from writing to low pages
87711 can help reduce the impact of kernel NULL pointer bugs.
87712 @@ -351,7 +352,7 @@ config MEMORY_FAILURE
87713
87714 config HWPOISON_INJECT
87715 tristate "HWPoison pages injector"
87716 - depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS
87717 + depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS && !GRKERNSEC
87718 select PROC_PAGE_MONITOR
87719
87720 config NOMMU_INITIAL_TRIM_EXCESS
87721 diff --git a/mm/backing-dev.c b/mm/backing-dev.c
87722 index ce682f7..1fb54f9 100644
87723 --- a/mm/backing-dev.c
87724 +++ b/mm/backing-dev.c
87725 @@ -12,7 +12,7 @@
87726 #include <linux/device.h>
87727 #include <trace/events/writeback.h>
87728
87729 -static atomic_long_t bdi_seq = ATOMIC_LONG_INIT(0);
87730 +static atomic_long_unchecked_t bdi_seq = ATOMIC_LONG_INIT(0);
87731
87732 struct backing_dev_info default_backing_dev_info = {
87733 .name = "default",
87734 @@ -525,7 +525,7 @@ int bdi_setup_and_register(struct backing_dev_info *bdi, char *name,
87735 return err;
87736
87737 err = bdi_register(bdi, NULL, "%.28s-%ld", name,
87738 - atomic_long_inc_return(&bdi_seq));
87739 + atomic_long_inc_return_unchecked(&bdi_seq));
87740 if (err) {
87741 bdi_destroy(bdi);
87742 return err;
87743 diff --git a/mm/filemap.c b/mm/filemap.c
87744 index ae4846f..b0acebe 100644
87745 --- a/mm/filemap.c
87746 +++ b/mm/filemap.c
87747 @@ -1768,7 +1768,7 @@ int generic_file_mmap(struct file * file, struct vm_area_struct * vma)
87748 struct address_space *mapping = file->f_mapping;
87749
87750 if (!mapping->a_ops->readpage)
87751 - return -ENOEXEC;
87752 + return -ENODEV;
87753 file_accessed(file);
87754 vma->vm_ops = &generic_file_vm_ops;
87755 return 0;
87756 @@ -1950,7 +1950,7 @@ static size_t __iovec_copy_from_user_inatomic(char *vaddr,
87757
87758 while (bytes) {
87759 char __user *buf = iov->iov_base + base;
87760 - int copy = min(bytes, iov->iov_len - base);
87761 + size_t copy = min(bytes, iov->iov_len - base);
87762
87763 base = 0;
87764 left = __copy_from_user_inatomic(vaddr, buf, copy);
87765 @@ -1979,7 +1979,7 @@ size_t iov_iter_copy_from_user_atomic(struct page *page,
87766 BUG_ON(!in_atomic());
87767 kaddr = kmap_atomic(page);
87768 if (likely(i->nr_segs == 1)) {
87769 - int left;
87770 + size_t left;
87771 char __user *buf = i->iov->iov_base + i->iov_offset;
87772 left = __copy_from_user_inatomic(kaddr + offset, buf, bytes);
87773 copied = bytes - left;
87774 @@ -2007,7 +2007,7 @@ size_t iov_iter_copy_from_user(struct page *page,
87775
87776 kaddr = kmap(page);
87777 if (likely(i->nr_segs == 1)) {
87778 - int left;
87779 + size_t left;
87780 char __user *buf = i->iov->iov_base + i->iov_offset;
87781 left = __copy_from_user(kaddr + offset, buf, bytes);
87782 copied = bytes - left;
87783 @@ -2037,7 +2037,7 @@ void iov_iter_advance(struct iov_iter *i, size_t bytes)
87784 * zero-length segments (without overruning the iovec).
87785 */
87786 while (bytes || unlikely(i->count && !iov->iov_len)) {
87787 - int copy;
87788 + size_t copy;
87789
87790 copy = min(bytes, iov->iov_len - base);
87791 BUG_ON(!i->count || i->count < copy);
87792 @@ -2108,6 +2108,7 @@ inline int generic_write_checks(struct file *file, loff_t *pos, size_t *count, i
87793 *pos = i_size_read(inode);
87794
87795 if (limit != RLIM_INFINITY) {
87796 + gr_learn_resource(current, RLIMIT_FSIZE,*pos, 0);
87797 if (*pos >= limit) {
87798 send_sig(SIGXFSZ, current, 0);
87799 return -EFBIG;
87800 diff --git a/mm/fremap.c b/mm/fremap.c
87801 index 5bff081..bfa6e93 100644
87802 --- a/mm/fremap.c
87803 +++ b/mm/fremap.c
87804 @@ -163,6 +163,11 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
87805 retry:
87806 vma = find_vma(mm, start);
87807
87808 +#ifdef CONFIG_PAX_SEGMEXEC
87809 + if (vma && (mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_MAYEXEC))
87810 + goto out;
87811 +#endif
87812 +
87813 /*
87814 * Make sure the vma is shared, that it supports prefaulting,
87815 * and that the remapped range is valid and fully within
87816 @@ -208,9 +213,10 @@ get_write_lock:
87817 if (mapping_cap_account_dirty(mapping)) {
87818 unsigned long addr;
87819 struct file *file = get_file(vma->vm_file);
87820 + /* mmap_region may free vma; grab the info now */
87821 + vm_flags = ACCESS_ONCE(vma->vm_flags);
87822
87823 - addr = mmap_region(file, start, size,
87824 - vma->vm_flags, pgoff);
87825 + addr = mmap_region(file, start, size, vm_flags, pgoff);
87826 fput(file);
87827 if (IS_ERR_VALUE(addr)) {
87828 err = addr;
87829 @@ -218,7 +224,7 @@ get_write_lock:
87830 BUG_ON(addr != start);
87831 err = 0;
87832 }
87833 - goto out;
87834 + goto out_freed;
87835 }
87836 mutex_lock(&mapping->i_mmap_mutex);
87837 flush_dcache_mmap_lock(mapping);
87838 @@ -253,6 +259,7 @@ get_write_lock:
87839 out:
87840 if (vma)
87841 vm_flags = vma->vm_flags;
87842 +out_freed:
87843 if (likely(!has_write_lock))
87844 up_read(&mm->mmap_sem);
87845 else
87846 diff --git a/mm/highmem.c b/mm/highmem.c
87847 index b32b70c..e512eb0 100644
87848 --- a/mm/highmem.c
87849 +++ b/mm/highmem.c
87850 @@ -138,8 +138,9 @@ static void flush_all_zero_pkmaps(void)
87851 * So no dangers, even with speculative execution.
87852 */
87853 page = pte_page(pkmap_page_table[i]);
87854 + pax_open_kernel();
87855 pte_clear(&init_mm, PKMAP_ADDR(i), &pkmap_page_table[i]);
87856 -
87857 + pax_close_kernel();
87858 set_page_address(page, NULL);
87859 need_flush = 1;
87860 }
87861 @@ -198,9 +199,11 @@ start:
87862 }
87863 }
87864 vaddr = PKMAP_ADDR(last_pkmap_nr);
87865 +
87866 + pax_open_kernel();
87867 set_pte_at(&init_mm, vaddr,
87868 &(pkmap_page_table[last_pkmap_nr]), mk_pte(page, kmap_prot));
87869 -
87870 + pax_close_kernel();
87871 pkmap_count[last_pkmap_nr] = 1;
87872 set_page_address(page, (void *)vaddr);
87873
87874 diff --git a/mm/hugetlb.c b/mm/hugetlb.c
87875 index 0b7656e..d21cefc 100644
87876 --- a/mm/hugetlb.c
87877 +++ b/mm/hugetlb.c
87878 @@ -2094,15 +2094,17 @@ static int hugetlb_sysctl_handler_common(bool obey_mempolicy,
87879 struct hstate *h = &default_hstate;
87880 unsigned long tmp;
87881 int ret;
87882 + ctl_table_no_const hugetlb_table;
87883
87884 tmp = h->max_huge_pages;
87885
87886 if (write && h->order >= MAX_ORDER)
87887 return -EINVAL;
87888
87889 - table->data = &tmp;
87890 - table->maxlen = sizeof(unsigned long);
87891 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
87892 + hugetlb_table = *table;
87893 + hugetlb_table.data = &tmp;
87894 + hugetlb_table.maxlen = sizeof(unsigned long);
87895 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
87896 if (ret)
87897 goto out;
87898
87899 @@ -2147,15 +2149,17 @@ int hugetlb_overcommit_handler(struct ctl_table *table, int write,
87900 struct hstate *h = &default_hstate;
87901 unsigned long tmp;
87902 int ret;
87903 + ctl_table_no_const hugetlb_table;
87904
87905 tmp = h->nr_overcommit_huge_pages;
87906
87907 if (write && h->order >= MAX_ORDER)
87908 return -EINVAL;
87909
87910 - table->data = &tmp;
87911 - table->maxlen = sizeof(unsigned long);
87912 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
87913 + hugetlb_table = *table;
87914 + hugetlb_table.data = &tmp;
87915 + hugetlb_table.maxlen = sizeof(unsigned long);
87916 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
87917 if (ret)
87918 goto out;
87919
87920 @@ -2605,6 +2609,27 @@ static int unmap_ref_private(struct mm_struct *mm, struct vm_area_struct *vma,
87921 return 1;
87922 }
87923
87924 +#ifdef CONFIG_PAX_SEGMEXEC
87925 +static void pax_mirror_huge_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m)
87926 +{
87927 + struct mm_struct *mm = vma->vm_mm;
87928 + struct vm_area_struct *vma_m;
87929 + unsigned long address_m;
87930 + pte_t *ptep_m;
87931 +
87932 + vma_m = pax_find_mirror_vma(vma);
87933 + if (!vma_m)
87934 + return;
87935 +
87936 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
87937 + address_m = address + SEGMEXEC_TASK_SIZE;
87938 + ptep_m = huge_pte_offset(mm, address_m & HPAGE_MASK);
87939 + get_page(page_m);
87940 + hugepage_add_anon_rmap(page_m, vma_m, address_m);
87941 + set_huge_pte_at(mm, address_m, ptep_m, make_huge_pte(vma_m, page_m, 0));
87942 +}
87943 +#endif
87944 +
87945 /*
87946 * Hugetlb_cow() should be called with page lock of the original hugepage held.
87947 * Called with hugetlb_instantiation_mutex held and pte_page locked so we
87948 @@ -2721,6 +2746,11 @@ retry_avoidcopy:
87949 make_huge_pte(vma, new_page, 1));
87950 page_remove_rmap(old_page);
87951 hugepage_add_new_anon_rmap(new_page, vma, address);
87952 +
87953 +#ifdef CONFIG_PAX_SEGMEXEC
87954 + pax_mirror_huge_pte(vma, address, new_page);
87955 +#endif
87956 +
87957 /* Make the old page be freed below */
87958 new_page = old_page;
87959 }
87960 @@ -2883,6 +2913,10 @@ retry:
87961 && (vma->vm_flags & VM_SHARED)));
87962 set_huge_pte_at(mm, address, ptep, new_pte);
87963
87964 +#ifdef CONFIG_PAX_SEGMEXEC
87965 + pax_mirror_huge_pte(vma, address, page);
87966 +#endif
87967 +
87968 if ((flags & FAULT_FLAG_WRITE) && !(vma->vm_flags & VM_SHARED)) {
87969 /* Optimization, do the COW without a second fault */
87970 ret = hugetlb_cow(mm, vma, address, ptep, new_pte, page);
87971 @@ -2912,6 +2946,10 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
87972 static DEFINE_MUTEX(hugetlb_instantiation_mutex);
87973 struct hstate *h = hstate_vma(vma);
87974
87975 +#ifdef CONFIG_PAX_SEGMEXEC
87976 + struct vm_area_struct *vma_m;
87977 +#endif
87978 +
87979 address &= huge_page_mask(h);
87980
87981 ptep = huge_pte_offset(mm, address);
87982 @@ -2925,6 +2963,26 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
87983 VM_FAULT_SET_HINDEX(hstate_index(h));
87984 }
87985
87986 +#ifdef CONFIG_PAX_SEGMEXEC
87987 + vma_m = pax_find_mirror_vma(vma);
87988 + if (vma_m) {
87989 + unsigned long address_m;
87990 +
87991 + if (vma->vm_start > vma_m->vm_start) {
87992 + address_m = address;
87993 + address -= SEGMEXEC_TASK_SIZE;
87994 + vma = vma_m;
87995 + h = hstate_vma(vma);
87996 + } else
87997 + address_m = address + SEGMEXEC_TASK_SIZE;
87998 +
87999 + if (!huge_pte_alloc(mm, address_m, huge_page_size(h)))
88000 + return VM_FAULT_OOM;
88001 + address_m &= HPAGE_MASK;
88002 + unmap_hugepage_range(vma, address_m, address_m + HPAGE_SIZE, NULL);
88003 + }
88004 +#endif
88005 +
88006 ptep = huge_pte_alloc(mm, address, huge_page_size(h));
88007 if (!ptep)
88008 return VM_FAULT_OOM;
88009 diff --git a/mm/internal.h b/mm/internal.h
88010 index 684f7aa..9eb9edc 100644
88011 --- a/mm/internal.h
88012 +++ b/mm/internal.h
88013 @@ -97,6 +97,7 @@ extern pmd_t *mm_find_pmd(struct mm_struct *mm, unsigned long address);
88014 * in mm/page_alloc.c
88015 */
88016 extern void __free_pages_bootmem(struct page *page, unsigned int order);
88017 +extern void free_compound_page(struct page *page);
88018 extern void prep_compound_page(struct page *page, unsigned long order);
88019 #ifdef CONFIG_MEMORY_FAILURE
88020 extern bool is_free_buddy_page(struct page *page);
88021 @@ -352,7 +353,7 @@ extern u32 hwpoison_filter_enable;
88022
88023 extern unsigned long vm_mmap_pgoff(struct file *, unsigned long,
88024 unsigned long, unsigned long,
88025 - unsigned long, unsigned long);
88026 + unsigned long, unsigned long) __intentional_overflow(-1);
88027
88028 extern void set_pageblock_order(void);
88029 unsigned long reclaim_clean_pages_from_list(struct zone *zone,
88030 diff --git a/mm/kmemleak.c b/mm/kmemleak.c
88031 index e126b0e..e986018 100644
88032 --- a/mm/kmemleak.c
88033 +++ b/mm/kmemleak.c
88034 @@ -363,7 +363,7 @@ static void print_unreferenced(struct seq_file *seq,
88035
88036 for (i = 0; i < object->trace_len; i++) {
88037 void *ptr = (void *)object->trace[i];
88038 - seq_printf(seq, " [<%p>] %pS\n", ptr, ptr);
88039 + seq_printf(seq, " [<%pP>] %pA\n", ptr, ptr);
88040 }
88041 }
88042
88043 @@ -1851,7 +1851,7 @@ static int __init kmemleak_late_init(void)
88044 return -ENOMEM;
88045 }
88046
88047 - dentry = debugfs_create_file("kmemleak", S_IRUGO, NULL, NULL,
88048 + dentry = debugfs_create_file("kmemleak", S_IRUSR, NULL, NULL,
88049 &kmemleak_fops);
88050 if (!dentry)
88051 pr_warning("Failed to create the debugfs kmemleak file\n");
88052 diff --git a/mm/maccess.c b/mm/maccess.c
88053 index d53adf9..03a24bf 100644
88054 --- a/mm/maccess.c
88055 +++ b/mm/maccess.c
88056 @@ -26,7 +26,7 @@ long __probe_kernel_read(void *dst, const void *src, size_t size)
88057 set_fs(KERNEL_DS);
88058 pagefault_disable();
88059 ret = __copy_from_user_inatomic(dst,
88060 - (__force const void __user *)src, size);
88061 + (const void __force_user *)src, size);
88062 pagefault_enable();
88063 set_fs(old_fs);
88064
88065 @@ -53,7 +53,7 @@ long __probe_kernel_write(void *dst, const void *src, size_t size)
88066
88067 set_fs(KERNEL_DS);
88068 pagefault_disable();
88069 - ret = __copy_to_user_inatomic((__force void __user *)dst, src, size);
88070 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
88071 pagefault_enable();
88072 set_fs(old_fs);
88073
88074 diff --git a/mm/madvise.c b/mm/madvise.c
88075 index 539eeb9..e24a987 100644
88076 --- a/mm/madvise.c
88077 +++ b/mm/madvise.c
88078 @@ -51,6 +51,10 @@ static long madvise_behavior(struct vm_area_struct *vma,
88079 pgoff_t pgoff;
88080 unsigned long new_flags = vma->vm_flags;
88081
88082 +#ifdef CONFIG_PAX_SEGMEXEC
88083 + struct vm_area_struct *vma_m;
88084 +#endif
88085 +
88086 switch (behavior) {
88087 case MADV_NORMAL:
88088 new_flags = new_flags & ~VM_RAND_READ & ~VM_SEQ_READ;
88089 @@ -126,6 +130,13 @@ success:
88090 /*
88091 * vm_flags is protected by the mmap_sem held in write mode.
88092 */
88093 +
88094 +#ifdef CONFIG_PAX_SEGMEXEC
88095 + vma_m = pax_find_mirror_vma(vma);
88096 + if (vma_m)
88097 + vma_m->vm_flags = new_flags & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT);
88098 +#endif
88099 +
88100 vma->vm_flags = new_flags;
88101
88102 out:
88103 @@ -274,6 +285,11 @@ static long madvise_dontneed(struct vm_area_struct *vma,
88104 struct vm_area_struct **prev,
88105 unsigned long start, unsigned long end)
88106 {
88107 +
88108 +#ifdef CONFIG_PAX_SEGMEXEC
88109 + struct vm_area_struct *vma_m;
88110 +#endif
88111 +
88112 *prev = vma;
88113 if (vma->vm_flags & (VM_LOCKED|VM_HUGETLB|VM_PFNMAP))
88114 return -EINVAL;
88115 @@ -286,6 +302,21 @@ static long madvise_dontneed(struct vm_area_struct *vma,
88116 zap_page_range(vma, start, end - start, &details);
88117 } else
88118 zap_page_range(vma, start, end - start, NULL);
88119 +
88120 +#ifdef CONFIG_PAX_SEGMEXEC
88121 + vma_m = pax_find_mirror_vma(vma);
88122 + if (vma_m) {
88123 + if (unlikely(vma->vm_flags & VM_NONLINEAR)) {
88124 + struct zap_details details = {
88125 + .nonlinear_vma = vma_m,
88126 + .last_index = ULONG_MAX,
88127 + };
88128 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, &details);
88129 + } else
88130 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, NULL);
88131 + }
88132 +#endif
88133 +
88134 return 0;
88135 }
88136
88137 @@ -491,6 +522,16 @@ SYSCALL_DEFINE3(madvise, unsigned long, start, size_t, len_in, int, behavior)
88138 if (end < start)
88139 return error;
88140
88141 +#ifdef CONFIG_PAX_SEGMEXEC
88142 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
88143 + if (end > SEGMEXEC_TASK_SIZE)
88144 + return error;
88145 + } else
88146 +#endif
88147 +
88148 + if (end > TASK_SIZE)
88149 + return error;
88150 +
88151 error = 0;
88152 if (end == start)
88153 return error;
88154 diff --git a/mm/memory-failure.c b/mm/memory-failure.c
88155 index bf3351b..aea800d 100644
88156 --- a/mm/memory-failure.c
88157 +++ b/mm/memory-failure.c
88158 @@ -61,7 +61,7 @@ int sysctl_memory_failure_early_kill __read_mostly = 0;
88159
88160 int sysctl_memory_failure_recovery __read_mostly = 1;
88161
88162 -atomic_long_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0);
88163 +atomic_long_unchecked_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0);
88164
88165 #if defined(CONFIG_HWPOISON_INJECT) || defined(CONFIG_HWPOISON_INJECT_MODULE)
88166
88167 @@ -202,7 +202,7 @@ static int kill_proc(struct task_struct *t, unsigned long addr, int trapno,
88168 pfn, t->comm, t->pid);
88169 si.si_signo = SIGBUS;
88170 si.si_errno = 0;
88171 - si.si_addr = (void *)addr;
88172 + si.si_addr = (void __user *)addr;
88173 #ifdef __ARCH_SI_TRAPNO
88174 si.si_trapno = trapno;
88175 #endif
88176 @@ -762,7 +762,7 @@ static struct page_state {
88177 unsigned long res;
88178 char *msg;
88179 int (*action)(struct page *p, unsigned long pfn);
88180 -} error_states[] = {
88181 +} __do_const error_states[] = {
88182 { reserved, reserved, "reserved kernel", me_kernel },
88183 /*
88184 * free pages are specially detected outside this table:
88185 @@ -1053,7 +1053,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
88186 nr_pages = 1 << compound_order(hpage);
88187 else /* normal page or thp */
88188 nr_pages = 1;
88189 - atomic_long_add(nr_pages, &num_poisoned_pages);
88190 + atomic_long_add_unchecked(nr_pages, &num_poisoned_pages);
88191
88192 /*
88193 * We need/can do nothing about count=0 pages.
88194 @@ -1083,7 +1083,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
88195 if (!PageHWPoison(hpage)
88196 || (hwpoison_filter(p) && TestClearPageHWPoison(p))
88197 || (p != hpage && TestSetPageHWPoison(hpage))) {
88198 - atomic_long_sub(nr_pages, &num_poisoned_pages);
88199 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
88200 return 0;
88201 }
88202 set_page_hwpoison_huge_page(hpage);
88203 @@ -1152,7 +1152,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
88204 }
88205 if (hwpoison_filter(p)) {
88206 if (TestClearPageHWPoison(p))
88207 - atomic_long_sub(nr_pages, &num_poisoned_pages);
88208 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
88209 unlock_page(hpage);
88210 put_page(hpage);
88211 return 0;
88212 @@ -1370,7 +1370,7 @@ int unpoison_memory(unsigned long pfn)
88213 return 0;
88214 }
88215 if (TestClearPageHWPoison(p))
88216 - atomic_long_dec(&num_poisoned_pages);
88217 + atomic_long_dec_unchecked(&num_poisoned_pages);
88218 pr_info("MCE: Software-unpoisoned free page %#lx\n", pfn);
88219 return 0;
88220 }
88221 @@ -1384,7 +1384,7 @@ int unpoison_memory(unsigned long pfn)
88222 */
88223 if (TestClearPageHWPoison(page)) {
88224 pr_info("MCE: Software-unpoisoned page %#lx\n", pfn);
88225 - atomic_long_sub(nr_pages, &num_poisoned_pages);
88226 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
88227 freeit = 1;
88228 if (PageHuge(page))
88229 clear_page_hwpoison_huge_page(page);
88230 @@ -1521,7 +1521,7 @@ static int soft_offline_huge_page(struct page *page, int flags)
88231 } else {
88232 set_page_hwpoison_huge_page(hpage);
88233 dequeue_hwpoisoned_huge_page(hpage);
88234 - atomic_long_add(1 << compound_order(hpage),
88235 + atomic_long_add_unchecked(1 << compound_order(hpage),
88236 &num_poisoned_pages);
88237 }
88238 return ret;
88239 @@ -1560,7 +1560,7 @@ static int __soft_offline_page(struct page *page, int flags)
88240 put_page(page);
88241 pr_info("soft_offline: %#lx: invalidated\n", pfn);
88242 SetPageHWPoison(page);
88243 - atomic_long_inc(&num_poisoned_pages);
88244 + atomic_long_inc_unchecked(&num_poisoned_pages);
88245 return 0;
88246 }
88247
88248 @@ -1605,7 +1605,7 @@ static int __soft_offline_page(struct page *page, int flags)
88249 if (!is_free_buddy_page(page))
88250 pr_info("soft offline: %#lx: page leaked\n",
88251 pfn);
88252 - atomic_long_inc(&num_poisoned_pages);
88253 + atomic_long_inc_unchecked(&num_poisoned_pages);
88254 }
88255 } else {
88256 pr_info("soft offline: %#lx: isolation failed: %d, page count %d, type %lx\n",
88257 @@ -1666,11 +1666,11 @@ int soft_offline_page(struct page *page, int flags)
88258 if (PageHuge(page)) {
88259 set_page_hwpoison_huge_page(hpage);
88260 dequeue_hwpoisoned_huge_page(hpage);
88261 - atomic_long_add(1 << compound_order(hpage),
88262 + atomic_long_add_unchecked(1 << compound_order(hpage),
88263 &num_poisoned_pages);
88264 } else {
88265 SetPageHWPoison(page);
88266 - atomic_long_inc(&num_poisoned_pages);
88267 + atomic_long_inc_unchecked(&num_poisoned_pages);
88268 }
88269 }
88270 unset:
88271 diff --git a/mm/memory.c b/mm/memory.c
88272 index d176154..cd1b387 100644
88273 --- a/mm/memory.c
88274 +++ b/mm/memory.c
88275 @@ -402,6 +402,7 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
88276 free_pte_range(tlb, pmd, addr);
88277 } while (pmd++, addr = next, addr != end);
88278
88279 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_PER_CPU_PGD)
88280 start &= PUD_MASK;
88281 if (start < floor)
88282 return;
88283 @@ -416,6 +417,8 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
88284 pmd = pmd_offset(pud, start);
88285 pud_clear(pud);
88286 pmd_free_tlb(tlb, pmd, start);
88287 +#endif
88288 +
88289 }
88290
88291 static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
88292 @@ -435,6 +438,7 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
88293 free_pmd_range(tlb, pud, addr, next, floor, ceiling);
88294 } while (pud++, addr = next, addr != end);
88295
88296 +#if !defined(CONFIG_X86_64) || !defined(CONFIG_PAX_PER_CPU_PGD)
88297 start &= PGDIR_MASK;
88298 if (start < floor)
88299 return;
88300 @@ -449,6 +453,8 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
88301 pud = pud_offset(pgd, start);
88302 pgd_clear(pgd);
88303 pud_free_tlb(tlb, pud, start);
88304 +#endif
88305 +
88306 }
88307
88308 /*
88309 @@ -1636,12 +1642,6 @@ no_page_table:
88310 return page;
88311 }
88312
88313 -static inline int stack_guard_page(struct vm_area_struct *vma, unsigned long addr)
88314 -{
88315 - return stack_guard_page_start(vma, addr) ||
88316 - stack_guard_page_end(vma, addr+PAGE_SIZE);
88317 -}
88318 -
88319 /**
88320 * __get_user_pages() - pin user pages in memory
88321 * @tsk: task_struct of target task
88322 @@ -1728,10 +1728,10 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
88323
88324 i = 0;
88325
88326 - do {
88327 + while (nr_pages) {
88328 struct vm_area_struct *vma;
88329
88330 - vma = find_extend_vma(mm, start);
88331 + vma = find_vma(mm, start);
88332 if (!vma && in_gate_area(mm, start)) {
88333 unsigned long pg = start & PAGE_MASK;
88334 pgd_t *pgd;
88335 @@ -1780,7 +1780,7 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
88336 goto next_page;
88337 }
88338
88339 - if (!vma ||
88340 + if (!vma || start < vma->vm_start ||
88341 (vma->vm_flags & (VM_IO | VM_PFNMAP)) ||
88342 !(vm_flags & vma->vm_flags))
88343 return i ? : -EFAULT;
88344 @@ -1809,11 +1809,6 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
88345 int ret;
88346 unsigned int fault_flags = 0;
88347
88348 - /* For mlock, just skip the stack guard page. */
88349 - if (foll_flags & FOLL_MLOCK) {
88350 - if (stack_guard_page(vma, start))
88351 - goto next_page;
88352 - }
88353 if (foll_flags & FOLL_WRITE)
88354 fault_flags |= FAULT_FLAG_WRITE;
88355 if (nonblocking)
88356 @@ -1893,7 +1888,7 @@ next_page:
88357 start += page_increm * PAGE_SIZE;
88358 nr_pages -= page_increm;
88359 } while (nr_pages && start < vma->vm_end);
88360 - } while (nr_pages);
88361 + }
88362 return i;
88363 }
88364 EXPORT_SYMBOL(__get_user_pages);
88365 @@ -2100,6 +2095,10 @@ static int insert_page(struct vm_area_struct *vma, unsigned long addr,
88366 page_add_file_rmap(page);
88367 set_pte_at(mm, addr, pte, mk_pte(page, prot));
88368
88369 +#ifdef CONFIG_PAX_SEGMEXEC
88370 + pax_mirror_file_pte(vma, addr, page, ptl);
88371 +#endif
88372 +
88373 retval = 0;
88374 pte_unmap_unlock(pte, ptl);
88375 return retval;
88376 @@ -2144,9 +2143,21 @@ int vm_insert_page(struct vm_area_struct *vma, unsigned long addr,
88377 if (!page_count(page))
88378 return -EINVAL;
88379 if (!(vma->vm_flags & VM_MIXEDMAP)) {
88380 +
88381 +#ifdef CONFIG_PAX_SEGMEXEC
88382 + struct vm_area_struct *vma_m;
88383 +#endif
88384 +
88385 BUG_ON(down_read_trylock(&vma->vm_mm->mmap_sem));
88386 BUG_ON(vma->vm_flags & VM_PFNMAP);
88387 vma->vm_flags |= VM_MIXEDMAP;
88388 +
88389 +#ifdef CONFIG_PAX_SEGMEXEC
88390 + vma_m = pax_find_mirror_vma(vma);
88391 + if (vma_m)
88392 + vma_m->vm_flags |= VM_MIXEDMAP;
88393 +#endif
88394 +
88395 }
88396 return insert_page(vma, addr, page, vma->vm_page_prot);
88397 }
88398 @@ -2229,6 +2240,7 @@ int vm_insert_mixed(struct vm_area_struct *vma, unsigned long addr,
88399 unsigned long pfn)
88400 {
88401 BUG_ON(!(vma->vm_flags & VM_MIXEDMAP));
88402 + BUG_ON(vma->vm_mirror);
88403
88404 if (addr < vma->vm_start || addr >= vma->vm_end)
88405 return -EFAULT;
88406 @@ -2476,7 +2488,9 @@ static int apply_to_pmd_range(struct mm_struct *mm, pud_t *pud,
88407
88408 BUG_ON(pud_huge(*pud));
88409
88410 - pmd = pmd_alloc(mm, pud, addr);
88411 + pmd = (mm == &init_mm) ?
88412 + pmd_alloc_kernel(mm, pud, addr) :
88413 + pmd_alloc(mm, pud, addr);
88414 if (!pmd)
88415 return -ENOMEM;
88416 do {
88417 @@ -2496,7 +2510,9 @@ static int apply_to_pud_range(struct mm_struct *mm, pgd_t *pgd,
88418 unsigned long next;
88419 int err;
88420
88421 - pud = pud_alloc(mm, pgd, addr);
88422 + pud = (mm == &init_mm) ?
88423 + pud_alloc_kernel(mm, pgd, addr) :
88424 + pud_alloc(mm, pgd, addr);
88425 if (!pud)
88426 return -ENOMEM;
88427 do {
88428 @@ -2584,6 +2600,186 @@ static inline void cow_user_page(struct page *dst, struct page *src, unsigned lo
88429 copy_user_highpage(dst, src, va, vma);
88430 }
88431
88432 +#ifdef CONFIG_PAX_SEGMEXEC
88433 +static void pax_unmap_mirror_pte(struct vm_area_struct *vma, unsigned long address, pmd_t *pmd)
88434 +{
88435 + struct mm_struct *mm = vma->vm_mm;
88436 + spinlock_t *ptl;
88437 + pte_t *pte, entry;
88438 +
88439 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
88440 + entry = *pte;
88441 + if (!pte_present(entry)) {
88442 + if (!pte_none(entry)) {
88443 + BUG_ON(pte_file(entry));
88444 + free_swap_and_cache(pte_to_swp_entry(entry));
88445 + pte_clear_not_present_full(mm, address, pte, 0);
88446 + }
88447 + } else {
88448 + struct page *page;
88449 +
88450 + flush_cache_page(vma, address, pte_pfn(entry));
88451 + entry = ptep_clear_flush(vma, address, pte);
88452 + BUG_ON(pte_dirty(entry));
88453 + page = vm_normal_page(vma, address, entry);
88454 + if (page) {
88455 + update_hiwater_rss(mm);
88456 + if (PageAnon(page))
88457 + dec_mm_counter_fast(mm, MM_ANONPAGES);
88458 + else
88459 + dec_mm_counter_fast(mm, MM_FILEPAGES);
88460 + page_remove_rmap(page);
88461 + page_cache_release(page);
88462 + }
88463 + }
88464 + pte_unmap_unlock(pte, ptl);
88465 +}
88466 +
88467 +/* PaX: if vma is mirrored, synchronize the mirror's PTE
88468 + *
88469 + * the ptl of the lower mapped page is held on entry and is not released on exit
88470 + * or inside to ensure atomic changes to the PTE states (swapout, mremap, munmap, etc)
88471 + */
88472 +static void pax_mirror_anon_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
88473 +{
88474 + struct mm_struct *mm = vma->vm_mm;
88475 + unsigned long address_m;
88476 + spinlock_t *ptl_m;
88477 + struct vm_area_struct *vma_m;
88478 + pmd_t *pmd_m;
88479 + pte_t *pte_m, entry_m;
88480 +
88481 + BUG_ON(!page_m || !PageAnon(page_m));
88482 +
88483 + vma_m = pax_find_mirror_vma(vma);
88484 + if (!vma_m)
88485 + return;
88486 +
88487 + BUG_ON(!PageLocked(page_m));
88488 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
88489 + address_m = address + SEGMEXEC_TASK_SIZE;
88490 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
88491 + pte_m = pte_offset_map(pmd_m, address_m);
88492 + ptl_m = pte_lockptr(mm, pmd_m);
88493 + if (ptl != ptl_m) {
88494 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
88495 + if (!pte_none(*pte_m))
88496 + goto out;
88497 + }
88498 +
88499 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
88500 + page_cache_get(page_m);
88501 + page_add_anon_rmap(page_m, vma_m, address_m);
88502 + inc_mm_counter_fast(mm, MM_ANONPAGES);
88503 + set_pte_at(mm, address_m, pte_m, entry_m);
88504 + update_mmu_cache(vma_m, address_m, pte_m);
88505 +out:
88506 + if (ptl != ptl_m)
88507 + spin_unlock(ptl_m);
88508 + pte_unmap(pte_m);
88509 + unlock_page(page_m);
88510 +}
88511 +
88512 +void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
88513 +{
88514 + struct mm_struct *mm = vma->vm_mm;
88515 + unsigned long address_m;
88516 + spinlock_t *ptl_m;
88517 + struct vm_area_struct *vma_m;
88518 + pmd_t *pmd_m;
88519 + pte_t *pte_m, entry_m;
88520 +
88521 + BUG_ON(!page_m || PageAnon(page_m));
88522 +
88523 + vma_m = pax_find_mirror_vma(vma);
88524 + if (!vma_m)
88525 + return;
88526 +
88527 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
88528 + address_m = address + SEGMEXEC_TASK_SIZE;
88529 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
88530 + pte_m = pte_offset_map(pmd_m, address_m);
88531 + ptl_m = pte_lockptr(mm, pmd_m);
88532 + if (ptl != ptl_m) {
88533 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
88534 + if (!pte_none(*pte_m))
88535 + goto out;
88536 + }
88537 +
88538 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
88539 + page_cache_get(page_m);
88540 + page_add_file_rmap(page_m);
88541 + inc_mm_counter_fast(mm, MM_FILEPAGES);
88542 + set_pte_at(mm, address_m, pte_m, entry_m);
88543 + update_mmu_cache(vma_m, address_m, pte_m);
88544 +out:
88545 + if (ptl != ptl_m)
88546 + spin_unlock(ptl_m);
88547 + pte_unmap(pte_m);
88548 +}
88549 +
88550 +static void pax_mirror_pfn_pte(struct vm_area_struct *vma, unsigned long address, unsigned long pfn_m, spinlock_t *ptl)
88551 +{
88552 + struct mm_struct *mm = vma->vm_mm;
88553 + unsigned long address_m;
88554 + spinlock_t *ptl_m;
88555 + struct vm_area_struct *vma_m;
88556 + pmd_t *pmd_m;
88557 + pte_t *pte_m, entry_m;
88558 +
88559 + vma_m = pax_find_mirror_vma(vma);
88560 + if (!vma_m)
88561 + return;
88562 +
88563 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
88564 + address_m = address + SEGMEXEC_TASK_SIZE;
88565 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
88566 + pte_m = pte_offset_map(pmd_m, address_m);
88567 + ptl_m = pte_lockptr(mm, pmd_m);
88568 + if (ptl != ptl_m) {
88569 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
88570 + if (!pte_none(*pte_m))
88571 + goto out;
88572 + }
88573 +
88574 + entry_m = pfn_pte(pfn_m, vma_m->vm_page_prot);
88575 + set_pte_at(mm, address_m, pte_m, entry_m);
88576 +out:
88577 + if (ptl != ptl_m)
88578 + spin_unlock(ptl_m);
88579 + pte_unmap(pte_m);
88580 +}
88581 +
88582 +static void pax_mirror_pte(struct vm_area_struct *vma, unsigned long address, pte_t *pte, pmd_t *pmd, spinlock_t *ptl)
88583 +{
88584 + struct page *page_m;
88585 + pte_t entry;
88586 +
88587 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC))
88588 + goto out;
88589 +
88590 + entry = *pte;
88591 + page_m = vm_normal_page(vma, address, entry);
88592 + if (!page_m)
88593 + pax_mirror_pfn_pte(vma, address, pte_pfn(entry), ptl);
88594 + else if (PageAnon(page_m)) {
88595 + if (pax_find_mirror_vma(vma)) {
88596 + pte_unmap_unlock(pte, ptl);
88597 + lock_page(page_m);
88598 + pte = pte_offset_map_lock(vma->vm_mm, pmd, address, &ptl);
88599 + if (pte_same(entry, *pte))
88600 + pax_mirror_anon_pte(vma, address, page_m, ptl);
88601 + else
88602 + unlock_page(page_m);
88603 + }
88604 + } else
88605 + pax_mirror_file_pte(vma, address, page_m, ptl);
88606 +
88607 +out:
88608 + pte_unmap_unlock(pte, ptl);
88609 +}
88610 +#endif
88611 +
88612 /*
88613 * This routine handles present pages, when users try to write
88614 * to a shared page. It is done by copying the page to a new address
88615 @@ -2800,6 +2996,12 @@ gotten:
88616 */
88617 page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
88618 if (likely(pte_same(*page_table, orig_pte))) {
88619 +
88620 +#ifdef CONFIG_PAX_SEGMEXEC
88621 + if (pax_find_mirror_vma(vma))
88622 + BUG_ON(!trylock_page(new_page));
88623 +#endif
88624 +
88625 if (old_page) {
88626 if (!PageAnon(old_page)) {
88627 dec_mm_counter_fast(mm, MM_FILEPAGES);
88628 @@ -2851,6 +3053,10 @@ gotten:
88629 page_remove_rmap(old_page);
88630 }
88631
88632 +#ifdef CONFIG_PAX_SEGMEXEC
88633 + pax_mirror_anon_pte(vma, address, new_page, ptl);
88634 +#endif
88635 +
88636 /* Free the old page.. */
88637 new_page = old_page;
88638 ret |= VM_FAULT_WRITE;
88639 @@ -3128,6 +3334,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
88640 swap_free(entry);
88641 if (vm_swap_full() || (vma->vm_flags & VM_LOCKED) || PageMlocked(page))
88642 try_to_free_swap(page);
88643 +
88644 +#ifdef CONFIG_PAX_SEGMEXEC
88645 + if ((flags & FAULT_FLAG_WRITE) || !pax_find_mirror_vma(vma))
88646 +#endif
88647 +
88648 unlock_page(page);
88649 if (page != swapcache) {
88650 /*
88651 @@ -3151,6 +3362,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
88652
88653 /* No need to invalidate - it was non-present before */
88654 update_mmu_cache(vma, address, page_table);
88655 +
88656 +#ifdef CONFIG_PAX_SEGMEXEC
88657 + pax_mirror_anon_pte(vma, address, page, ptl);
88658 +#endif
88659 +
88660 unlock:
88661 pte_unmap_unlock(page_table, ptl);
88662 out:
88663 @@ -3170,40 +3386,6 @@ out_release:
88664 }
88665
88666 /*
88667 - * This is like a special single-page "expand_{down|up}wards()",
88668 - * except we must first make sure that 'address{-|+}PAGE_SIZE'
88669 - * doesn't hit another vma.
88670 - */
88671 -static inline int check_stack_guard_page(struct vm_area_struct *vma, unsigned long address)
88672 -{
88673 - address &= PAGE_MASK;
88674 - if ((vma->vm_flags & VM_GROWSDOWN) && address == vma->vm_start) {
88675 - struct vm_area_struct *prev = vma->vm_prev;
88676 -
88677 - /*
88678 - * Is there a mapping abutting this one below?
88679 - *
88680 - * That's only ok if it's the same stack mapping
88681 - * that has gotten split..
88682 - */
88683 - if (prev && prev->vm_end == address)
88684 - return prev->vm_flags & VM_GROWSDOWN ? 0 : -ENOMEM;
88685 -
88686 - expand_downwards(vma, address - PAGE_SIZE);
88687 - }
88688 - if ((vma->vm_flags & VM_GROWSUP) && address + PAGE_SIZE == vma->vm_end) {
88689 - struct vm_area_struct *next = vma->vm_next;
88690 -
88691 - /* As VM_GROWSDOWN but s/below/above/ */
88692 - if (next && next->vm_start == address + PAGE_SIZE)
88693 - return next->vm_flags & VM_GROWSUP ? 0 : -ENOMEM;
88694 -
88695 - expand_upwards(vma, address + PAGE_SIZE);
88696 - }
88697 - return 0;
88698 -}
88699 -
88700 -/*
88701 * We enter with non-exclusive mmap_sem (to exclude vma changes,
88702 * but allow concurrent faults), and pte mapped but not yet locked.
88703 * We return with mmap_sem still held, but pte unmapped and unlocked.
88704 @@ -3212,27 +3394,23 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
88705 unsigned long address, pte_t *page_table, pmd_t *pmd,
88706 unsigned int flags)
88707 {
88708 - struct page *page;
88709 + struct page *page = NULL;
88710 spinlock_t *ptl;
88711 pte_t entry;
88712
88713 - pte_unmap(page_table);
88714 -
88715 - /* Check if we need to add a guard page to the stack */
88716 - if (check_stack_guard_page(vma, address) < 0)
88717 - return VM_FAULT_SIGBUS;
88718 -
88719 - /* Use the zero-page for reads */
88720 if (!(flags & FAULT_FLAG_WRITE)) {
88721 entry = pte_mkspecial(pfn_pte(my_zero_pfn(address),
88722 vma->vm_page_prot));
88723 - page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
88724 + ptl = pte_lockptr(mm, pmd);
88725 + spin_lock(ptl);
88726 if (!pte_none(*page_table))
88727 goto unlock;
88728 goto setpte;
88729 }
88730
88731 /* Allocate our own private page. */
88732 + pte_unmap(page_table);
88733 +
88734 if (unlikely(anon_vma_prepare(vma)))
88735 goto oom;
88736 page = alloc_zeroed_user_highpage_movable(vma, address);
88737 @@ -3256,6 +3434,11 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
88738 if (!pte_none(*page_table))
88739 goto release;
88740
88741 +#ifdef CONFIG_PAX_SEGMEXEC
88742 + if (pax_find_mirror_vma(vma))
88743 + BUG_ON(!trylock_page(page));
88744 +#endif
88745 +
88746 inc_mm_counter_fast(mm, MM_ANONPAGES);
88747 page_add_new_anon_rmap(page, vma, address);
88748 setpte:
88749 @@ -3263,6 +3446,12 @@ setpte:
88750
88751 /* No need to invalidate - it was non-present before */
88752 update_mmu_cache(vma, address, page_table);
88753 +
88754 +#ifdef CONFIG_PAX_SEGMEXEC
88755 + if (page)
88756 + pax_mirror_anon_pte(vma, address, page, ptl);
88757 +#endif
88758 +
88759 unlock:
88760 pte_unmap_unlock(page_table, ptl);
88761 return 0;
88762 @@ -3406,6 +3595,12 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
88763 */
88764 /* Only go through if we didn't race with anybody else... */
88765 if (likely(pte_same(*page_table, orig_pte))) {
88766 +
88767 +#ifdef CONFIG_PAX_SEGMEXEC
88768 + if (anon && pax_find_mirror_vma(vma))
88769 + BUG_ON(!trylock_page(page));
88770 +#endif
88771 +
88772 flush_icache_page(vma, page);
88773 entry = mk_pte(page, vma->vm_page_prot);
88774 if (flags & FAULT_FLAG_WRITE)
88775 @@ -3427,6 +3622,14 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
88776
88777 /* no need to invalidate: a not-present page won't be cached */
88778 update_mmu_cache(vma, address, page_table);
88779 +
88780 +#ifdef CONFIG_PAX_SEGMEXEC
88781 + if (anon)
88782 + pax_mirror_anon_pte(vma, address, page, ptl);
88783 + else
88784 + pax_mirror_file_pte(vma, address, page, ptl);
88785 +#endif
88786 +
88787 } else {
88788 if (cow_page)
88789 mem_cgroup_uncharge_page(cow_page);
88790 @@ -3737,6 +3940,12 @@ static int handle_pte_fault(struct mm_struct *mm,
88791 if (flags & FAULT_FLAG_WRITE)
88792 flush_tlb_fix_spurious_fault(vma, address);
88793 }
88794 +
88795 +#ifdef CONFIG_PAX_SEGMEXEC
88796 + pax_mirror_pte(vma, address, pte, pmd, ptl);
88797 + return 0;
88798 +#endif
88799 +
88800 unlock:
88801 pte_unmap_unlock(pte, ptl);
88802 return 0;
88803 @@ -3753,9 +3962,41 @@ static int __handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
88804 pmd_t *pmd;
88805 pte_t *pte;
88806
88807 +#ifdef CONFIG_PAX_SEGMEXEC
88808 + struct vm_area_struct *vma_m;
88809 +#endif
88810 +
88811 if (unlikely(is_vm_hugetlb_page(vma)))
88812 return hugetlb_fault(mm, vma, address, flags);
88813
88814 +#ifdef CONFIG_PAX_SEGMEXEC
88815 + vma_m = pax_find_mirror_vma(vma);
88816 + if (vma_m) {
88817 + unsigned long address_m;
88818 + pgd_t *pgd_m;
88819 + pud_t *pud_m;
88820 + pmd_t *pmd_m;
88821 +
88822 + if (vma->vm_start > vma_m->vm_start) {
88823 + address_m = address;
88824 + address -= SEGMEXEC_TASK_SIZE;
88825 + vma = vma_m;
88826 + } else
88827 + address_m = address + SEGMEXEC_TASK_SIZE;
88828 +
88829 + pgd_m = pgd_offset(mm, address_m);
88830 + pud_m = pud_alloc(mm, pgd_m, address_m);
88831 + if (!pud_m)
88832 + return VM_FAULT_OOM;
88833 + pmd_m = pmd_alloc(mm, pud_m, address_m);
88834 + if (!pmd_m)
88835 + return VM_FAULT_OOM;
88836 + if (!pmd_present(*pmd_m) && __pte_alloc(mm, vma_m, pmd_m, address_m))
88837 + return VM_FAULT_OOM;
88838 + pax_unmap_mirror_pte(vma_m, address_m, pmd_m);
88839 + }
88840 +#endif
88841 +
88842 retry:
88843 pgd = pgd_offset(mm, address);
88844 pud = pud_alloc(mm, pgd, address);
88845 @@ -3894,6 +4135,23 @@ int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
88846 spin_unlock(&mm->page_table_lock);
88847 return 0;
88848 }
88849 +
88850 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
88851 +{
88852 + pud_t *new = pud_alloc_one(mm, address);
88853 + if (!new)
88854 + return -ENOMEM;
88855 +
88856 + smp_wmb(); /* See comment in __pte_alloc */
88857 +
88858 + spin_lock(&mm->page_table_lock);
88859 + if (pgd_present(*pgd)) /* Another has populated it */
88860 + pud_free(mm, new);
88861 + else
88862 + pgd_populate_kernel(mm, pgd, new);
88863 + spin_unlock(&mm->page_table_lock);
88864 + return 0;
88865 +}
88866 #endif /* __PAGETABLE_PUD_FOLDED */
88867
88868 #ifndef __PAGETABLE_PMD_FOLDED
88869 @@ -3924,6 +4182,30 @@ int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
88870 spin_unlock(&mm->page_table_lock);
88871 return 0;
88872 }
88873 +
88874 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
88875 +{
88876 + pmd_t *new = pmd_alloc_one(mm, address);
88877 + if (!new)
88878 + return -ENOMEM;
88879 +
88880 + smp_wmb(); /* See comment in __pte_alloc */
88881 +
88882 + spin_lock(&mm->page_table_lock);
88883 +#ifndef __ARCH_HAS_4LEVEL_HACK
88884 + if (pud_present(*pud)) /* Another has populated it */
88885 + pmd_free(mm, new);
88886 + else
88887 + pud_populate_kernel(mm, pud, new);
88888 +#else
88889 + if (pgd_present(*pud)) /* Another has populated it */
88890 + pmd_free(mm, new);
88891 + else
88892 + pgd_populate_kernel(mm, pud, new);
88893 +#endif /* __ARCH_HAS_4LEVEL_HACK */
88894 + spin_unlock(&mm->page_table_lock);
88895 + return 0;
88896 +}
88897 #endif /* __PAGETABLE_PMD_FOLDED */
88898
88899 #if !defined(__HAVE_ARCH_GATE_AREA)
88900 @@ -3937,7 +4219,7 @@ static int __init gate_vma_init(void)
88901 gate_vma.vm_start = FIXADDR_USER_START;
88902 gate_vma.vm_end = FIXADDR_USER_END;
88903 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
88904 - gate_vma.vm_page_prot = __P101;
88905 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
88906
88907 return 0;
88908 }
88909 @@ -4071,8 +4353,8 @@ out:
88910 return ret;
88911 }
88912
88913 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
88914 - void *buf, int len, int write)
88915 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
88916 + void *buf, size_t len, int write)
88917 {
88918 resource_size_t phys_addr;
88919 unsigned long prot = 0;
88920 @@ -4098,8 +4380,8 @@ EXPORT_SYMBOL_GPL(generic_access_phys);
88921 * Access another process' address space as given in mm. If non-NULL, use the
88922 * given task for page fault accounting.
88923 */
88924 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
88925 - unsigned long addr, void *buf, int len, int write)
88926 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
88927 + unsigned long addr, void *buf, size_t len, int write)
88928 {
88929 struct vm_area_struct *vma;
88930 void *old_buf = buf;
88931 @@ -4107,7 +4389,7 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
88932 down_read(&mm->mmap_sem);
88933 /* ignore errors, just check how much was successfully transferred */
88934 while (len) {
88935 - int bytes, ret, offset;
88936 + ssize_t bytes, ret, offset;
88937 void *maddr;
88938 struct page *page = NULL;
88939
88940 @@ -4166,8 +4448,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
88941 *
88942 * The caller must hold a reference on @mm.
88943 */
88944 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
88945 - void *buf, int len, int write)
88946 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
88947 + void *buf, size_t len, int write)
88948 {
88949 return __access_remote_vm(NULL, mm, addr, buf, len, write);
88950 }
88951 @@ -4177,11 +4459,11 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
88952 * Source/target buffer must be kernel space,
88953 * Do not walk the page table directly, use get_user_pages
88954 */
88955 -int access_process_vm(struct task_struct *tsk, unsigned long addr,
88956 - void *buf, int len, int write)
88957 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr,
88958 + void *buf, size_t len, int write)
88959 {
88960 struct mm_struct *mm;
88961 - int ret;
88962 + ssize_t ret;
88963
88964 mm = get_task_mm(tsk);
88965 if (!mm)
88966 diff --git a/mm/mempolicy.c b/mm/mempolicy.c
88967 index 0472964..7d5a0ea 100644
88968 --- a/mm/mempolicy.c
88969 +++ b/mm/mempolicy.c
88970 @@ -746,6 +746,10 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
88971 unsigned long vmstart;
88972 unsigned long vmend;
88973
88974 +#ifdef CONFIG_PAX_SEGMEXEC
88975 + struct vm_area_struct *vma_m;
88976 +#endif
88977 +
88978 vma = find_vma(mm, start);
88979 if (!vma || vma->vm_start > start)
88980 return -EFAULT;
88981 @@ -789,6 +793,16 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
88982 err = vma_replace_policy(vma, new_pol);
88983 if (err)
88984 goto out;
88985 +
88986 +#ifdef CONFIG_PAX_SEGMEXEC
88987 + vma_m = pax_find_mirror_vma(vma);
88988 + if (vma_m) {
88989 + err = vma_replace_policy(vma_m, new_pol);
88990 + if (err)
88991 + goto out;
88992 + }
88993 +#endif
88994 +
88995 }
88996
88997 out:
88998 @@ -1252,6 +1266,17 @@ static long do_mbind(unsigned long start, unsigned long len,
88999
89000 if (end < start)
89001 return -EINVAL;
89002 +
89003 +#ifdef CONFIG_PAX_SEGMEXEC
89004 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
89005 + if (end > SEGMEXEC_TASK_SIZE)
89006 + return -EINVAL;
89007 + } else
89008 +#endif
89009 +
89010 + if (end > TASK_SIZE)
89011 + return -EINVAL;
89012 +
89013 if (end == start)
89014 return 0;
89015
89016 @@ -1480,8 +1505,7 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
89017 */
89018 tcred = __task_cred(task);
89019 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
89020 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
89021 - !capable(CAP_SYS_NICE)) {
89022 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
89023 rcu_read_unlock();
89024 err = -EPERM;
89025 goto out_put;
89026 @@ -1512,6 +1536,15 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
89027 goto out;
89028 }
89029
89030 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
89031 + if (mm != current->mm &&
89032 + (mm->pax_flags & MF_PAX_RANDMMAP || mm->pax_flags & MF_PAX_SEGMEXEC)) {
89033 + mmput(mm);
89034 + err = -EPERM;
89035 + goto out;
89036 + }
89037 +#endif
89038 +
89039 err = do_migrate_pages(mm, old, new,
89040 capable(CAP_SYS_NICE) ? MPOL_MF_MOVE_ALL : MPOL_MF_MOVE);
89041
89042 diff --git a/mm/migrate.c b/mm/migrate.c
89043 index c046927..6996b40 100644
89044 --- a/mm/migrate.c
89045 +++ b/mm/migrate.c
89046 @@ -1404,8 +1404,7 @@ SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages,
89047 */
89048 tcred = __task_cred(task);
89049 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
89050 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
89051 - !capable(CAP_SYS_NICE)) {
89052 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
89053 rcu_read_unlock();
89054 err = -EPERM;
89055 goto out;
89056 diff --git a/mm/mlock.c b/mm/mlock.c
89057 index d480cd6..0f98458 100644
89058 --- a/mm/mlock.c
89059 +++ b/mm/mlock.c
89060 @@ -14,6 +14,7 @@
89061 #include <linux/pagevec.h>
89062 #include <linux/mempolicy.h>
89063 #include <linux/syscalls.h>
89064 +#include <linux/security.h>
89065 #include <linux/sched.h>
89066 #include <linux/export.h>
89067 #include <linux/rmap.h>
89068 @@ -568,7 +569,7 @@ static int do_mlock(unsigned long start, size_t len, int on)
89069 {
89070 unsigned long nstart, end, tmp;
89071 struct vm_area_struct * vma, * prev;
89072 - int error;
89073 + int error = 0;
89074
89075 VM_BUG_ON(start & ~PAGE_MASK);
89076 VM_BUG_ON(len != PAGE_ALIGN(len));
89077 @@ -577,6 +578,9 @@ static int do_mlock(unsigned long start, size_t len, int on)
89078 return -EINVAL;
89079 if (end == start)
89080 return 0;
89081 + if (end > TASK_SIZE)
89082 + return -EINVAL;
89083 +
89084 vma = find_vma(current->mm, start);
89085 if (!vma || vma->vm_start > start)
89086 return -ENOMEM;
89087 @@ -588,6 +592,11 @@ static int do_mlock(unsigned long start, size_t len, int on)
89088 for (nstart = start ; ; ) {
89089 vm_flags_t newflags;
89090
89091 +#ifdef CONFIG_PAX_SEGMEXEC
89092 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
89093 + break;
89094 +#endif
89095 +
89096 /* Here we know that vma->vm_start <= nstart < vma->vm_end. */
89097
89098 newflags = vma->vm_flags & ~VM_LOCKED;
89099 @@ -700,6 +709,7 @@ SYSCALL_DEFINE2(mlock, unsigned long, start, size_t, len)
89100 lock_limit >>= PAGE_SHIFT;
89101
89102 /* check against resource limits */
89103 + gr_learn_resource(current, RLIMIT_MEMLOCK, (current->mm->locked_vm << PAGE_SHIFT) + len, 1);
89104 if ((locked <= lock_limit) || capable(CAP_IPC_LOCK))
89105 error = do_mlock(start, len, 1);
89106 up_write(&current->mm->mmap_sem);
89107 @@ -734,6 +744,11 @@ static int do_mlockall(int flags)
89108 for (vma = current->mm->mmap; vma ; vma = prev->vm_next) {
89109 vm_flags_t newflags;
89110
89111 +#ifdef CONFIG_PAX_SEGMEXEC
89112 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
89113 + break;
89114 +#endif
89115 +
89116 newflags = vma->vm_flags & ~VM_LOCKED;
89117 if (flags & MCL_CURRENT)
89118 newflags |= VM_LOCKED;
89119 @@ -767,6 +782,7 @@ SYSCALL_DEFINE1(mlockall, int, flags)
89120 lock_limit >>= PAGE_SHIFT;
89121
89122 ret = -ENOMEM;
89123 + gr_learn_resource(current, RLIMIT_MEMLOCK, current->mm->total_vm << PAGE_SHIFT, 1);
89124 if (!(flags & MCL_CURRENT) || (current->mm->total_vm <= lock_limit) ||
89125 capable(CAP_IPC_LOCK))
89126 ret = do_mlockall(flags);
89127 diff --git a/mm/mmap.c b/mm/mmap.c
89128 index 362e5f1..8968e02 100644
89129 --- a/mm/mmap.c
89130 +++ b/mm/mmap.c
89131 @@ -36,6 +36,7 @@
89132 #include <linux/sched/sysctl.h>
89133 #include <linux/notifier.h>
89134 #include <linux/memory.h>
89135 +#include <linux/random.h>
89136
89137 #include <asm/uaccess.h>
89138 #include <asm/cacheflush.h>
89139 @@ -52,6 +53,16 @@
89140 #define arch_rebalance_pgtables(addr, len) (addr)
89141 #endif
89142
89143 +static inline void verify_mm_writelocked(struct mm_struct *mm)
89144 +{
89145 +#if defined(CONFIG_DEBUG_VM) || defined(CONFIG_PAX)
89146 + if (unlikely(down_read_trylock(&mm->mmap_sem))) {
89147 + up_read(&mm->mmap_sem);
89148 + BUG();
89149 + }
89150 +#endif
89151 +}
89152 +
89153 static void unmap_region(struct mm_struct *mm,
89154 struct vm_area_struct *vma, struct vm_area_struct *prev,
89155 unsigned long start, unsigned long end);
89156 @@ -71,16 +82,25 @@ static void unmap_region(struct mm_struct *mm,
89157 * x: (no) no x: (no) yes x: (no) yes x: (yes) yes
89158 *
89159 */
89160 -pgprot_t protection_map[16] = {
89161 +pgprot_t protection_map[16] __read_only = {
89162 __P000, __P001, __P010, __P011, __P100, __P101, __P110, __P111,
89163 __S000, __S001, __S010, __S011, __S100, __S101, __S110, __S111
89164 };
89165
89166 -pgprot_t vm_get_page_prot(unsigned long vm_flags)
89167 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
89168 {
89169 - return __pgprot(pgprot_val(protection_map[vm_flags &
89170 + pgprot_t prot = __pgprot(pgprot_val(protection_map[vm_flags &
89171 (VM_READ|VM_WRITE|VM_EXEC|VM_SHARED)]) |
89172 pgprot_val(arch_vm_get_page_prot(vm_flags)));
89173 +
89174 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
89175 + if (!(__supported_pte_mask & _PAGE_NX) &&
89176 + (vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC &&
89177 + (vm_flags & (VM_READ | VM_WRITE)))
89178 + prot = __pgprot(pte_val(pte_exprotect(__pte(pgprot_val(prot)))));
89179 +#endif
89180 +
89181 + return prot;
89182 }
89183 EXPORT_SYMBOL(vm_get_page_prot);
89184
89185 @@ -89,6 +109,7 @@ int sysctl_overcommit_ratio __read_mostly = 50; /* default is 50% */
89186 int sysctl_max_map_count __read_mostly = DEFAULT_MAX_MAP_COUNT;
89187 unsigned long sysctl_user_reserve_kbytes __read_mostly = 1UL << 17; /* 128MB */
89188 unsigned long sysctl_admin_reserve_kbytes __read_mostly = 1UL << 13; /* 8MB */
89189 +unsigned long sysctl_heap_stack_gap __read_mostly = 64*1024;
89190 /*
89191 * Make sure vm_committed_as in one cacheline and not cacheline shared with
89192 * other variables. It can be updated by several CPUs frequently.
89193 @@ -247,6 +268,7 @@ static struct vm_area_struct *remove_vma(struct vm_area_struct *vma)
89194 struct vm_area_struct *next = vma->vm_next;
89195
89196 might_sleep();
89197 + BUG_ON(vma->vm_mirror);
89198 if (vma->vm_ops && vma->vm_ops->close)
89199 vma->vm_ops->close(vma);
89200 if (vma->vm_file)
89201 @@ -291,6 +313,7 @@ SYSCALL_DEFINE1(brk, unsigned long, brk)
89202 * not page aligned -Ram Gupta
89203 */
89204 rlim = rlimit(RLIMIT_DATA);
89205 + gr_learn_resource(current, RLIMIT_DATA, (brk - mm->start_brk) + (mm->end_data - mm->start_data), 1);
89206 if (rlim < RLIM_INFINITY && (brk - mm->start_brk) +
89207 (mm->end_data - mm->start_data) > rlim)
89208 goto out;
89209 @@ -933,6 +956,12 @@ static int
89210 can_vma_merge_before(struct vm_area_struct *vma, unsigned long vm_flags,
89211 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
89212 {
89213 +
89214 +#ifdef CONFIG_PAX_SEGMEXEC
89215 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_start == SEGMEXEC_TASK_SIZE)
89216 + return 0;
89217 +#endif
89218 +
89219 if (is_mergeable_vma(vma, file, vm_flags) &&
89220 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
89221 if (vma->vm_pgoff == vm_pgoff)
89222 @@ -952,6 +981,12 @@ static int
89223 can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
89224 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
89225 {
89226 +
89227 +#ifdef CONFIG_PAX_SEGMEXEC
89228 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end == SEGMEXEC_TASK_SIZE)
89229 + return 0;
89230 +#endif
89231 +
89232 if (is_mergeable_vma(vma, file, vm_flags) &&
89233 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
89234 pgoff_t vm_pglen;
89235 @@ -994,13 +1029,20 @@ can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
89236 struct vm_area_struct *vma_merge(struct mm_struct *mm,
89237 struct vm_area_struct *prev, unsigned long addr,
89238 unsigned long end, unsigned long vm_flags,
89239 - struct anon_vma *anon_vma, struct file *file,
89240 + struct anon_vma *anon_vma, struct file *file,
89241 pgoff_t pgoff, struct mempolicy *policy)
89242 {
89243 pgoff_t pglen = (end - addr) >> PAGE_SHIFT;
89244 struct vm_area_struct *area, *next;
89245 int err;
89246
89247 +#ifdef CONFIG_PAX_SEGMEXEC
89248 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE, end_m = end + SEGMEXEC_TASK_SIZE;
89249 + struct vm_area_struct *area_m = NULL, *next_m = NULL, *prev_m = NULL;
89250 +
89251 + BUG_ON((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE < end);
89252 +#endif
89253 +
89254 /*
89255 * We later require that vma->vm_flags == vm_flags,
89256 * so this tests vma->vm_flags & VM_SPECIAL, too.
89257 @@ -1016,6 +1058,15 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
89258 if (next && next->vm_end == end) /* cases 6, 7, 8 */
89259 next = next->vm_next;
89260
89261 +#ifdef CONFIG_PAX_SEGMEXEC
89262 + if (prev)
89263 + prev_m = pax_find_mirror_vma(prev);
89264 + if (area)
89265 + area_m = pax_find_mirror_vma(area);
89266 + if (next)
89267 + next_m = pax_find_mirror_vma(next);
89268 +#endif
89269 +
89270 /*
89271 * Can it merge with the predecessor?
89272 */
89273 @@ -1035,9 +1086,24 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
89274 /* cases 1, 6 */
89275 err = vma_adjust(prev, prev->vm_start,
89276 next->vm_end, prev->vm_pgoff, NULL);
89277 - } else /* cases 2, 5, 7 */
89278 +
89279 +#ifdef CONFIG_PAX_SEGMEXEC
89280 + if (!err && prev_m)
89281 + err = vma_adjust(prev_m, prev_m->vm_start,
89282 + next_m->vm_end, prev_m->vm_pgoff, NULL);
89283 +#endif
89284 +
89285 + } else { /* cases 2, 5, 7 */
89286 err = vma_adjust(prev, prev->vm_start,
89287 end, prev->vm_pgoff, NULL);
89288 +
89289 +#ifdef CONFIG_PAX_SEGMEXEC
89290 + if (!err && prev_m)
89291 + err = vma_adjust(prev_m, prev_m->vm_start,
89292 + end_m, prev_m->vm_pgoff, NULL);
89293 +#endif
89294 +
89295 + }
89296 if (err)
89297 return NULL;
89298 khugepaged_enter_vma_merge(prev);
89299 @@ -1051,12 +1117,27 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
89300 mpol_equal(policy, vma_policy(next)) &&
89301 can_vma_merge_before(next, vm_flags,
89302 anon_vma, file, pgoff+pglen)) {
89303 - if (prev && addr < prev->vm_end) /* case 4 */
89304 + if (prev && addr < prev->vm_end) { /* case 4 */
89305 err = vma_adjust(prev, prev->vm_start,
89306 addr, prev->vm_pgoff, NULL);
89307 - else /* cases 3, 8 */
89308 +
89309 +#ifdef CONFIG_PAX_SEGMEXEC
89310 + if (!err && prev_m)
89311 + err = vma_adjust(prev_m, prev_m->vm_start,
89312 + addr_m, prev_m->vm_pgoff, NULL);
89313 +#endif
89314 +
89315 + } else { /* cases 3, 8 */
89316 err = vma_adjust(area, addr, next->vm_end,
89317 next->vm_pgoff - pglen, NULL);
89318 +
89319 +#ifdef CONFIG_PAX_SEGMEXEC
89320 + if (!err && area_m)
89321 + err = vma_adjust(area_m, addr_m, next_m->vm_end,
89322 + next_m->vm_pgoff - pglen, NULL);
89323 +#endif
89324 +
89325 + }
89326 if (err)
89327 return NULL;
89328 khugepaged_enter_vma_merge(area);
89329 @@ -1165,8 +1246,10 @@ none:
89330 void vm_stat_account(struct mm_struct *mm, unsigned long flags,
89331 struct file *file, long pages)
89332 {
89333 - const unsigned long stack_flags
89334 - = VM_STACK_FLAGS & (VM_GROWSUP|VM_GROWSDOWN);
89335 +
89336 +#ifdef CONFIG_PAX_RANDMMAP
89337 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
89338 +#endif
89339
89340 mm->total_vm += pages;
89341
89342 @@ -1174,7 +1257,7 @@ void vm_stat_account(struct mm_struct *mm, unsigned long flags,
89343 mm->shared_vm += pages;
89344 if ((flags & (VM_EXEC|VM_WRITE)) == VM_EXEC)
89345 mm->exec_vm += pages;
89346 - } else if (flags & stack_flags)
89347 + } else if (flags & (VM_GROWSUP|VM_GROWSDOWN))
89348 mm->stack_vm += pages;
89349 }
89350 #endif /* CONFIG_PROC_FS */
89351 @@ -1212,7 +1295,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
89352 * (the exception is when the underlying filesystem is noexec
89353 * mounted, in which case we dont add PROT_EXEC.)
89354 */
89355 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
89356 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
89357 if (!(file && (file->f_path.mnt->mnt_flags & MNT_NOEXEC)))
89358 prot |= PROT_EXEC;
89359
89360 @@ -1238,7 +1321,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
89361 /* Obtain the address to map to. we verify (or select) it and ensure
89362 * that it represents a valid section of the address space.
89363 */
89364 - addr = get_unmapped_area(file, addr, len, pgoff, flags);
89365 + addr = get_unmapped_area(file, addr, len, pgoff, flags | ((prot & PROT_EXEC) ? MAP_EXECUTABLE : 0));
89366 if (addr & ~PAGE_MASK)
89367 return addr;
89368
89369 @@ -1249,6 +1332,43 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
89370 vm_flags = calc_vm_prot_bits(prot) | calc_vm_flag_bits(flags) |
89371 mm->def_flags | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC;
89372
89373 +#ifdef CONFIG_PAX_MPROTECT
89374 + if (mm->pax_flags & MF_PAX_MPROTECT) {
89375 +
89376 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
89377 + if (file && !pgoff && (vm_flags & VM_EXEC) && mm->binfmt &&
89378 + mm->binfmt->handle_mmap)
89379 + mm->binfmt->handle_mmap(file);
89380 +#endif
89381 +
89382 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
89383 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC)) {
89384 + gr_log_rwxmmap(file);
89385 +
89386 +#ifdef CONFIG_PAX_EMUPLT
89387 + vm_flags &= ~VM_EXEC;
89388 +#else
89389 + return -EPERM;
89390 +#endif
89391 +
89392 + }
89393 +
89394 + if (!(vm_flags & VM_EXEC))
89395 + vm_flags &= ~VM_MAYEXEC;
89396 +#else
89397 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
89398 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
89399 +#endif
89400 + else
89401 + vm_flags &= ~VM_MAYWRITE;
89402 + }
89403 +#endif
89404 +
89405 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
89406 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && file)
89407 + vm_flags &= ~VM_PAGEEXEC;
89408 +#endif
89409 +
89410 if (flags & MAP_LOCKED)
89411 if (!can_do_mlock())
89412 return -EPERM;
89413 @@ -1260,6 +1380,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
89414 locked += mm->locked_vm;
89415 lock_limit = rlimit(RLIMIT_MEMLOCK);
89416 lock_limit >>= PAGE_SHIFT;
89417 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
89418 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
89419 return -EAGAIN;
89420 }
89421 @@ -1344,6 +1465,9 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
89422 vm_flags |= VM_NORESERVE;
89423 }
89424
89425 + if (!gr_acl_handle_mmap(file, prot))
89426 + return -EACCES;
89427 +
89428 addr = mmap_region(file, addr, len, vm_flags, pgoff);
89429 if (!IS_ERR_VALUE(addr) &&
89430 ((vm_flags & VM_LOCKED) ||
89431 @@ -1437,7 +1561,7 @@ int vma_wants_writenotify(struct vm_area_struct *vma)
89432 vm_flags_t vm_flags = vma->vm_flags;
89433
89434 /* If it was private or non-writable, the write bit is already clear */
89435 - if ((vm_flags & (VM_WRITE|VM_SHARED)) != ((VM_WRITE|VM_SHARED)))
89436 + if ((vm_flags & (VM_WRITE|VM_SHARED)) != (VM_WRITE|VM_SHARED))
89437 return 0;
89438
89439 /* The backer wishes to know when pages are first written to? */
89440 @@ -1483,7 +1607,22 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
89441 struct rb_node **rb_link, *rb_parent;
89442 unsigned long charged = 0;
89443
89444 +#ifdef CONFIG_PAX_SEGMEXEC
89445 + struct vm_area_struct *vma_m = NULL;
89446 +#endif
89447 +
89448 + /*
89449 + * mm->mmap_sem is required to protect against another thread
89450 + * changing the mappings in case we sleep.
89451 + */
89452 + verify_mm_writelocked(mm);
89453 +
89454 /* Check against address space limit. */
89455 +
89456 +#ifdef CONFIG_PAX_RANDMMAP
89457 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (vm_flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
89458 +#endif
89459 +
89460 if (!may_expand_vm(mm, len >> PAGE_SHIFT)) {
89461 unsigned long nr_pages;
89462
89463 @@ -1502,11 +1641,10 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
89464
89465 /* Clear old maps */
89466 error = -ENOMEM;
89467 -munmap_back:
89468 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
89469 if (do_munmap(mm, addr, len))
89470 return -ENOMEM;
89471 - goto munmap_back;
89472 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
89473 }
89474
89475 /*
89476 @@ -1537,6 +1675,16 @@ munmap_back:
89477 goto unacct_error;
89478 }
89479
89480 +#ifdef CONFIG_PAX_SEGMEXEC
89481 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vm_flags & VM_EXEC)) {
89482 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
89483 + if (!vma_m) {
89484 + error = -ENOMEM;
89485 + goto free_vma;
89486 + }
89487 + }
89488 +#endif
89489 +
89490 vma->vm_mm = mm;
89491 vma->vm_start = addr;
89492 vma->vm_end = addr + len;
89493 @@ -1556,6 +1704,13 @@ munmap_back:
89494 if (error)
89495 goto unmap_and_free_vma;
89496
89497 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
89498 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && !(vma->vm_flags & VM_SPECIAL)) {
89499 + vma->vm_flags |= VM_PAGEEXEC;
89500 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
89501 + }
89502 +#endif
89503 +
89504 /* Can addr have changed??
89505 *
89506 * Answer: Yes, several device drivers can do it in their
89507 @@ -1589,6 +1744,12 @@ munmap_back:
89508 }
89509
89510 vma_link(mm, vma, prev, rb_link, rb_parent);
89511 +
89512 +#ifdef CONFIG_PAX_SEGMEXEC
89513 + if (vma_m)
89514 + BUG_ON(pax_mirror_vma(vma_m, vma));
89515 +#endif
89516 +
89517 /* Once vma denies write, undo our temporary denial count */
89518 if (vm_flags & VM_DENYWRITE)
89519 allow_write_access(file);
89520 @@ -1597,6 +1758,7 @@ out:
89521 perf_event_mmap(vma);
89522
89523 vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
89524 + track_exec_limit(mm, addr, addr + len, vm_flags);
89525 if (vm_flags & VM_LOCKED) {
89526 if (!((vm_flags & VM_SPECIAL) || is_vm_hugetlb_page(vma) ||
89527 vma == get_gate_vma(current->mm)))
89528 @@ -1629,6 +1791,12 @@ unmap_and_free_vma:
89529 unmap_region(mm, vma, prev, vma->vm_start, vma->vm_end);
89530 charged = 0;
89531 free_vma:
89532 +
89533 +#ifdef CONFIG_PAX_SEGMEXEC
89534 + if (vma_m)
89535 + kmem_cache_free(vm_area_cachep, vma_m);
89536 +#endif
89537 +
89538 kmem_cache_free(vm_area_cachep, vma);
89539 unacct_error:
89540 if (charged)
89541 @@ -1636,7 +1804,63 @@ unacct_error:
89542 return error;
89543 }
89544
89545 -unsigned long unmapped_area(struct vm_unmapped_area_info *info)
89546 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
89547 +unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
89548 +{
89549 + if ((mm->pax_flags & MF_PAX_RANDMMAP) && !filp && (flags & MAP_STACK))
89550 + return ((prandom_u32() & 0xFF) + 1) << PAGE_SHIFT;
89551 +
89552 + return 0;
89553 +}
89554 +#endif
89555 +
89556 +bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset)
89557 +{
89558 + if (!vma) {
89559 +#ifdef CONFIG_STACK_GROWSUP
89560 + if (addr > sysctl_heap_stack_gap)
89561 + vma = find_vma(current->mm, addr - sysctl_heap_stack_gap);
89562 + else
89563 + vma = find_vma(current->mm, 0);
89564 + if (vma && (vma->vm_flags & VM_GROWSUP))
89565 + return false;
89566 +#endif
89567 + return true;
89568 + }
89569 +
89570 + if (addr + len > vma->vm_start)
89571 + return false;
89572 +
89573 + if (vma->vm_flags & VM_GROWSDOWN)
89574 + return sysctl_heap_stack_gap <= vma->vm_start - addr - len;
89575 +#ifdef CONFIG_STACK_GROWSUP
89576 + else if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP))
89577 + return addr - vma->vm_prev->vm_end >= sysctl_heap_stack_gap;
89578 +#endif
89579 + else if (offset)
89580 + return offset <= vma->vm_start - addr - len;
89581 +
89582 + return true;
89583 +}
89584 +
89585 +unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset)
89586 +{
89587 + if (vma->vm_start < len)
89588 + return -ENOMEM;
89589 +
89590 + if (!(vma->vm_flags & VM_GROWSDOWN)) {
89591 + if (offset <= vma->vm_start - len)
89592 + return vma->vm_start - len - offset;
89593 + else
89594 + return -ENOMEM;
89595 + }
89596 +
89597 + if (sysctl_heap_stack_gap <= vma->vm_start - len)
89598 + return vma->vm_start - len - sysctl_heap_stack_gap;
89599 + return -ENOMEM;
89600 +}
89601 +
89602 +unsigned long unmapped_area(const struct vm_unmapped_area_info *info)
89603 {
89604 /*
89605 * We implement the search by looking for an rbtree node that
89606 @@ -1684,11 +1908,29 @@ unsigned long unmapped_area(struct vm_unmapped_area_info *info)
89607 }
89608 }
89609
89610 - gap_start = vma->vm_prev ? vma->vm_prev->vm_end : 0;
89611 + gap_start = vma->vm_prev ? vma->vm_prev->vm_end: 0;
89612 check_current:
89613 /* Check if current node has a suitable gap */
89614 if (gap_start > high_limit)
89615 return -ENOMEM;
89616 +
89617 + if (gap_end - gap_start > info->threadstack_offset)
89618 + gap_start += info->threadstack_offset;
89619 + else
89620 + gap_start = gap_end;
89621 +
89622 + if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP)) {
89623 + if (gap_end - gap_start > sysctl_heap_stack_gap)
89624 + gap_start += sysctl_heap_stack_gap;
89625 + else
89626 + gap_start = gap_end;
89627 + }
89628 + if (vma->vm_flags & VM_GROWSDOWN) {
89629 + if (gap_end - gap_start > sysctl_heap_stack_gap)
89630 + gap_end -= sysctl_heap_stack_gap;
89631 + else
89632 + gap_end = gap_start;
89633 + }
89634 if (gap_end >= low_limit && gap_end - gap_start >= length)
89635 goto found;
89636
89637 @@ -1738,7 +1980,7 @@ found:
89638 return gap_start;
89639 }
89640
89641 -unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info)
89642 +unsigned long unmapped_area_topdown(const struct vm_unmapped_area_info *info)
89643 {
89644 struct mm_struct *mm = current->mm;
89645 struct vm_area_struct *vma;
89646 @@ -1792,6 +2034,24 @@ check_current:
89647 gap_end = vma->vm_start;
89648 if (gap_end < low_limit)
89649 return -ENOMEM;
89650 +
89651 + if (gap_end - gap_start > info->threadstack_offset)
89652 + gap_end -= info->threadstack_offset;
89653 + else
89654 + gap_end = gap_start;
89655 +
89656 + if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP)) {
89657 + if (gap_end - gap_start > sysctl_heap_stack_gap)
89658 + gap_start += sysctl_heap_stack_gap;
89659 + else
89660 + gap_start = gap_end;
89661 + }
89662 + if (vma->vm_flags & VM_GROWSDOWN) {
89663 + if (gap_end - gap_start > sysctl_heap_stack_gap)
89664 + gap_end -= sysctl_heap_stack_gap;
89665 + else
89666 + gap_end = gap_start;
89667 + }
89668 if (gap_start <= high_limit && gap_end - gap_start >= length)
89669 goto found;
89670
89671 @@ -1855,6 +2115,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
89672 struct mm_struct *mm = current->mm;
89673 struct vm_area_struct *vma;
89674 struct vm_unmapped_area_info info;
89675 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
89676
89677 if (len > TASK_SIZE - mmap_min_addr)
89678 return -ENOMEM;
89679 @@ -1862,19 +2123,30 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
89680 if (flags & MAP_FIXED)
89681 return addr;
89682
89683 +#ifdef CONFIG_PAX_RANDMMAP
89684 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
89685 +#endif
89686 +
89687 if (addr) {
89688 addr = PAGE_ALIGN(addr);
89689 vma = find_vma(mm, addr);
89690 if (TASK_SIZE - len >= addr && addr >= mmap_min_addr &&
89691 - (!vma || addr + len <= vma->vm_start))
89692 + check_heap_stack_gap(vma, addr, len, offset))
89693 return addr;
89694 }
89695
89696 info.flags = 0;
89697 info.length = len;
89698 info.low_limit = TASK_UNMAPPED_BASE;
89699 +
89700 +#ifdef CONFIG_PAX_RANDMMAP
89701 + if (mm->pax_flags & MF_PAX_RANDMMAP)
89702 + info.low_limit += mm->delta_mmap;
89703 +#endif
89704 +
89705 info.high_limit = TASK_SIZE;
89706 info.align_mask = 0;
89707 + info.threadstack_offset = offset;
89708 return vm_unmapped_area(&info);
89709 }
89710 #endif
89711 @@ -1893,6 +2165,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
89712 struct mm_struct *mm = current->mm;
89713 unsigned long addr = addr0;
89714 struct vm_unmapped_area_info info;
89715 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
89716
89717 /* requested length too big for entire address space */
89718 if (len > TASK_SIZE - mmap_min_addr)
89719 @@ -1901,12 +2174,16 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
89720 if (flags & MAP_FIXED)
89721 return addr;
89722
89723 +#ifdef CONFIG_PAX_RANDMMAP
89724 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
89725 +#endif
89726 +
89727 /* requesting a specific address */
89728 if (addr) {
89729 addr = PAGE_ALIGN(addr);
89730 vma = find_vma(mm, addr);
89731 if (TASK_SIZE - len >= addr && addr >= mmap_min_addr &&
89732 - (!vma || addr + len <= vma->vm_start))
89733 + check_heap_stack_gap(vma, addr, len, offset))
89734 return addr;
89735 }
89736
89737 @@ -1915,6 +2192,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
89738 info.low_limit = max(PAGE_SIZE, mmap_min_addr);
89739 info.high_limit = mm->mmap_base;
89740 info.align_mask = 0;
89741 + info.threadstack_offset = offset;
89742 addr = vm_unmapped_area(&info);
89743
89744 /*
89745 @@ -1927,6 +2205,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
89746 VM_BUG_ON(addr != -ENOMEM);
89747 info.flags = 0;
89748 info.low_limit = TASK_UNMAPPED_BASE;
89749 +
89750 +#ifdef CONFIG_PAX_RANDMMAP
89751 + if (mm->pax_flags & MF_PAX_RANDMMAP)
89752 + info.low_limit += mm->delta_mmap;
89753 +#endif
89754 +
89755 info.high_limit = TASK_SIZE;
89756 addr = vm_unmapped_area(&info);
89757 }
89758 @@ -2028,6 +2312,28 @@ find_vma_prev(struct mm_struct *mm, unsigned long addr,
89759 return vma;
89760 }
89761
89762 +#ifdef CONFIG_PAX_SEGMEXEC
89763 +struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma)
89764 +{
89765 + struct vm_area_struct *vma_m;
89766 +
89767 + BUG_ON(!vma || vma->vm_start >= vma->vm_end);
89768 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC)) {
89769 + BUG_ON(vma->vm_mirror);
89770 + return NULL;
89771 + }
89772 + BUG_ON(vma->vm_start < SEGMEXEC_TASK_SIZE && SEGMEXEC_TASK_SIZE < vma->vm_end);
89773 + vma_m = vma->vm_mirror;
89774 + BUG_ON(!vma_m || vma_m->vm_mirror != vma);
89775 + BUG_ON(vma->vm_file != vma_m->vm_file);
89776 + BUG_ON(vma->vm_end - vma->vm_start != vma_m->vm_end - vma_m->vm_start);
89777 + BUG_ON(vma->vm_pgoff != vma_m->vm_pgoff);
89778 + BUG_ON(vma->anon_vma != vma_m->anon_vma && vma->anon_vma->root != vma_m->anon_vma->root);
89779 + BUG_ON((vma->vm_flags ^ vma_m->vm_flags) & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED));
89780 + return vma_m;
89781 +}
89782 +#endif
89783 +
89784 /*
89785 * Verify that the stack growth is acceptable and
89786 * update accounting. This is shared with both the
89787 @@ -2044,6 +2350,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
89788 return -ENOMEM;
89789
89790 /* Stack limit test */
89791 + gr_learn_resource(current, RLIMIT_STACK, size, 1);
89792 if (size > ACCESS_ONCE(rlim[RLIMIT_STACK].rlim_cur))
89793 return -ENOMEM;
89794
89795 @@ -2054,6 +2361,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
89796 locked = mm->locked_vm + grow;
89797 limit = ACCESS_ONCE(rlim[RLIMIT_MEMLOCK].rlim_cur);
89798 limit >>= PAGE_SHIFT;
89799 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
89800 if (locked > limit && !capable(CAP_IPC_LOCK))
89801 return -ENOMEM;
89802 }
89803 @@ -2083,37 +2391,48 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
89804 * PA-RISC uses this for its stack; IA64 for its Register Backing Store.
89805 * vma is the last one with address > vma->vm_end. Have to extend vma.
89806 */
89807 +#ifndef CONFIG_IA64
89808 +static
89809 +#endif
89810 int expand_upwards(struct vm_area_struct *vma, unsigned long address)
89811 {
89812 int error;
89813 + bool locknext;
89814
89815 if (!(vma->vm_flags & VM_GROWSUP))
89816 return -EFAULT;
89817
89818 + /* Also guard against wrapping around to address 0. */
89819 + if (address < PAGE_ALIGN(address+1))
89820 + address = PAGE_ALIGN(address+1);
89821 + else
89822 + return -ENOMEM;
89823 +
89824 /*
89825 * We must make sure the anon_vma is allocated
89826 * so that the anon_vma locking is not a noop.
89827 */
89828 if (unlikely(anon_vma_prepare(vma)))
89829 return -ENOMEM;
89830 + locknext = vma->vm_next && (vma->vm_next->vm_flags & VM_GROWSDOWN);
89831 + if (locknext && anon_vma_prepare(vma->vm_next))
89832 + return -ENOMEM;
89833 vma_lock_anon_vma(vma);
89834 + if (locknext)
89835 + vma_lock_anon_vma(vma->vm_next);
89836
89837 /*
89838 * vma->vm_start/vm_end cannot change under us because the caller
89839 * is required to hold the mmap_sem in read mode. We need the
89840 - * anon_vma lock to serialize against concurrent expand_stacks.
89841 - * Also guard against wrapping around to address 0.
89842 + * anon_vma locks to serialize against concurrent expand_stacks
89843 + * and expand_upwards.
89844 */
89845 - if (address < PAGE_ALIGN(address+4))
89846 - address = PAGE_ALIGN(address+4);
89847 - else {
89848 - vma_unlock_anon_vma(vma);
89849 - return -ENOMEM;
89850 - }
89851 error = 0;
89852
89853 /* Somebody else might have raced and expanded it already */
89854 - if (address > vma->vm_end) {
89855 + 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)
89856 + error = -ENOMEM;
89857 + else if (address > vma->vm_end && (!locknext || vma->vm_next->vm_start >= address)) {
89858 unsigned long size, grow;
89859
89860 size = address - vma->vm_start;
89861 @@ -2148,6 +2467,8 @@ int expand_upwards(struct vm_area_struct *vma, unsigned long address)
89862 }
89863 }
89864 }
89865 + if (locknext)
89866 + vma_unlock_anon_vma(vma->vm_next);
89867 vma_unlock_anon_vma(vma);
89868 khugepaged_enter_vma_merge(vma);
89869 validate_mm(vma->vm_mm);
89870 @@ -2162,6 +2483,8 @@ int expand_downwards(struct vm_area_struct *vma,
89871 unsigned long address)
89872 {
89873 int error;
89874 + bool lockprev = false;
89875 + struct vm_area_struct *prev;
89876
89877 /*
89878 * We must make sure the anon_vma is allocated
89879 @@ -2175,6 +2498,15 @@ int expand_downwards(struct vm_area_struct *vma,
89880 if (error)
89881 return error;
89882
89883 + prev = vma->vm_prev;
89884 +#if defined(CONFIG_STACK_GROWSUP) || defined(CONFIG_IA64)
89885 + lockprev = prev && (prev->vm_flags & VM_GROWSUP);
89886 +#endif
89887 + if (lockprev && anon_vma_prepare(prev))
89888 + return -ENOMEM;
89889 + if (lockprev)
89890 + vma_lock_anon_vma(prev);
89891 +
89892 vma_lock_anon_vma(vma);
89893
89894 /*
89895 @@ -2184,9 +2516,17 @@ int expand_downwards(struct vm_area_struct *vma,
89896 */
89897
89898 /* Somebody else might have raced and expanded it already */
89899 - if (address < vma->vm_start) {
89900 + if (prev && (prev->vm_flags & (VM_READ | VM_WRITE | VM_EXEC)) && address - prev->vm_end < sysctl_heap_stack_gap)
89901 + error = -ENOMEM;
89902 + else if (address < vma->vm_start && (!lockprev || prev->vm_end <= address)) {
89903 unsigned long size, grow;
89904
89905 +#ifdef CONFIG_PAX_SEGMEXEC
89906 + struct vm_area_struct *vma_m;
89907 +
89908 + vma_m = pax_find_mirror_vma(vma);
89909 +#endif
89910 +
89911 size = vma->vm_end - address;
89912 grow = (vma->vm_start - address) >> PAGE_SHIFT;
89913
89914 @@ -2211,13 +2551,27 @@ int expand_downwards(struct vm_area_struct *vma,
89915 vma->vm_pgoff -= grow;
89916 anon_vma_interval_tree_post_update_vma(vma);
89917 vma_gap_update(vma);
89918 +
89919 +#ifdef CONFIG_PAX_SEGMEXEC
89920 + if (vma_m) {
89921 + anon_vma_interval_tree_pre_update_vma(vma_m);
89922 + vma_m->vm_start -= grow << PAGE_SHIFT;
89923 + vma_m->vm_pgoff -= grow;
89924 + anon_vma_interval_tree_post_update_vma(vma_m);
89925 + vma_gap_update(vma_m);
89926 + }
89927 +#endif
89928 +
89929 spin_unlock(&vma->vm_mm->page_table_lock);
89930
89931 + track_exec_limit(vma->vm_mm, vma->vm_start, vma->vm_end, vma->vm_flags);
89932 perf_event_mmap(vma);
89933 }
89934 }
89935 }
89936 vma_unlock_anon_vma(vma);
89937 + if (lockprev)
89938 + vma_unlock_anon_vma(prev);
89939 khugepaged_enter_vma_merge(vma);
89940 validate_mm(vma->vm_mm);
89941 return error;
89942 @@ -2315,6 +2669,13 @@ static void remove_vma_list(struct mm_struct *mm, struct vm_area_struct *vma)
89943 do {
89944 long nrpages = vma_pages(vma);
89945
89946 +#ifdef CONFIG_PAX_SEGMEXEC
89947 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE)) {
89948 + vma = remove_vma(vma);
89949 + continue;
89950 + }
89951 +#endif
89952 +
89953 if (vma->vm_flags & VM_ACCOUNT)
89954 nr_accounted += nrpages;
89955 vm_stat_account(mm, vma->vm_flags, vma->vm_file, -nrpages);
89956 @@ -2359,6 +2720,16 @@ detach_vmas_to_be_unmapped(struct mm_struct *mm, struct vm_area_struct *vma,
89957 insertion_point = (prev ? &prev->vm_next : &mm->mmap);
89958 vma->vm_prev = NULL;
89959 do {
89960 +
89961 +#ifdef CONFIG_PAX_SEGMEXEC
89962 + if (vma->vm_mirror) {
89963 + BUG_ON(!vma->vm_mirror->vm_mirror || vma->vm_mirror->vm_mirror != vma);
89964 + vma->vm_mirror->vm_mirror = NULL;
89965 + vma->vm_mirror->vm_flags &= ~VM_EXEC;
89966 + vma->vm_mirror = NULL;
89967 + }
89968 +#endif
89969 +
89970 vma_rb_erase(vma, &mm->mm_rb);
89971 mm->map_count--;
89972 tail_vma = vma;
89973 @@ -2384,14 +2755,33 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
89974 struct vm_area_struct *new;
89975 int err = -ENOMEM;
89976
89977 +#ifdef CONFIG_PAX_SEGMEXEC
89978 + struct vm_area_struct *vma_m, *new_m = NULL;
89979 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE;
89980 +#endif
89981 +
89982 if (is_vm_hugetlb_page(vma) && (addr &
89983 ~(huge_page_mask(hstate_vma(vma)))))
89984 return -EINVAL;
89985
89986 +#ifdef CONFIG_PAX_SEGMEXEC
89987 + vma_m = pax_find_mirror_vma(vma);
89988 +#endif
89989 +
89990 new = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
89991 if (!new)
89992 goto out_err;
89993
89994 +#ifdef CONFIG_PAX_SEGMEXEC
89995 + if (vma_m) {
89996 + new_m = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
89997 + if (!new_m) {
89998 + kmem_cache_free(vm_area_cachep, new);
89999 + goto out_err;
90000 + }
90001 + }
90002 +#endif
90003 +
90004 /* most fields are the same, copy all, and then fixup */
90005 *new = *vma;
90006
90007 @@ -2404,6 +2794,22 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
90008 new->vm_pgoff += ((addr - vma->vm_start) >> PAGE_SHIFT);
90009 }
90010
90011 +#ifdef CONFIG_PAX_SEGMEXEC
90012 + if (vma_m) {
90013 + *new_m = *vma_m;
90014 + INIT_LIST_HEAD(&new_m->anon_vma_chain);
90015 + new_m->vm_mirror = new;
90016 + new->vm_mirror = new_m;
90017 +
90018 + if (new_below)
90019 + new_m->vm_end = addr_m;
90020 + else {
90021 + new_m->vm_start = addr_m;
90022 + new_m->vm_pgoff += ((addr_m - vma_m->vm_start) >> PAGE_SHIFT);
90023 + }
90024 + }
90025 +#endif
90026 +
90027 err = vma_dup_policy(vma, new);
90028 if (err)
90029 goto out_free_vma;
90030 @@ -2423,6 +2829,38 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
90031 else
90032 err = vma_adjust(vma, vma->vm_start, addr, vma->vm_pgoff, new);
90033
90034 +#ifdef CONFIG_PAX_SEGMEXEC
90035 + if (!err && vma_m) {
90036 + struct mempolicy *pol = vma_policy(new);
90037 +
90038 + if (anon_vma_clone(new_m, vma_m))
90039 + goto out_free_mpol;
90040 +
90041 + mpol_get(pol);
90042 + set_vma_policy(new_m, pol);
90043 +
90044 + if (new_m->vm_file)
90045 + get_file(new_m->vm_file);
90046 +
90047 + if (new_m->vm_ops && new_m->vm_ops->open)
90048 + new_m->vm_ops->open(new_m);
90049 +
90050 + if (new_below)
90051 + err = vma_adjust(vma_m, addr_m, vma_m->vm_end, vma_m->vm_pgoff +
90052 + ((addr_m - new_m->vm_start) >> PAGE_SHIFT), new_m);
90053 + else
90054 + err = vma_adjust(vma_m, vma_m->vm_start, addr_m, vma_m->vm_pgoff, new_m);
90055 +
90056 + if (err) {
90057 + if (new_m->vm_ops && new_m->vm_ops->close)
90058 + new_m->vm_ops->close(new_m);
90059 + if (new_m->vm_file)
90060 + fput(new_m->vm_file);
90061 + mpol_put(pol);
90062 + }
90063 + }
90064 +#endif
90065 +
90066 /* Success. */
90067 if (!err)
90068 return 0;
90069 @@ -2432,10 +2870,18 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
90070 new->vm_ops->close(new);
90071 if (new->vm_file)
90072 fput(new->vm_file);
90073 - unlink_anon_vmas(new);
90074 out_free_mpol:
90075 mpol_put(vma_policy(new));
90076 out_free_vma:
90077 +
90078 +#ifdef CONFIG_PAX_SEGMEXEC
90079 + if (new_m) {
90080 + unlink_anon_vmas(new_m);
90081 + kmem_cache_free(vm_area_cachep, new_m);
90082 + }
90083 +#endif
90084 +
90085 + unlink_anon_vmas(new);
90086 kmem_cache_free(vm_area_cachep, new);
90087 out_err:
90088 return err;
90089 @@ -2448,6 +2894,15 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
90090 int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
90091 unsigned long addr, int new_below)
90092 {
90093 +
90094 +#ifdef CONFIG_PAX_SEGMEXEC
90095 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
90096 + BUG_ON(vma->vm_end > SEGMEXEC_TASK_SIZE);
90097 + if (mm->map_count >= sysctl_max_map_count-1)
90098 + return -ENOMEM;
90099 + } else
90100 +#endif
90101 +
90102 if (mm->map_count >= sysctl_max_map_count)
90103 return -ENOMEM;
90104
90105 @@ -2459,11 +2914,30 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
90106 * work. This now handles partial unmappings.
90107 * Jeremy Fitzhardinge <jeremy@goop.org>
90108 */
90109 +#ifdef CONFIG_PAX_SEGMEXEC
90110 int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
90111 {
90112 + int ret = __do_munmap(mm, start, len);
90113 + if (ret || !(mm->pax_flags & MF_PAX_SEGMEXEC))
90114 + return ret;
90115 +
90116 + return __do_munmap(mm, start + SEGMEXEC_TASK_SIZE, len);
90117 +}
90118 +
90119 +int __do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
90120 +#else
90121 +int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
90122 +#endif
90123 +{
90124 unsigned long end;
90125 struct vm_area_struct *vma, *prev, *last;
90126
90127 + /*
90128 + * mm->mmap_sem is required to protect against another thread
90129 + * changing the mappings in case we sleep.
90130 + */
90131 + verify_mm_writelocked(mm);
90132 +
90133 if ((start & ~PAGE_MASK) || start > TASK_SIZE || len > TASK_SIZE-start)
90134 return -EINVAL;
90135
90136 @@ -2538,6 +3012,8 @@ int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
90137 /* Fix up all other VM information */
90138 remove_vma_list(mm, vma);
90139
90140 + track_exec_limit(mm, start, end, 0UL);
90141 +
90142 return 0;
90143 }
90144
90145 @@ -2546,6 +3022,13 @@ int vm_munmap(unsigned long start, size_t len)
90146 int ret;
90147 struct mm_struct *mm = current->mm;
90148
90149 +
90150 +#ifdef CONFIG_PAX_SEGMEXEC
90151 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) &&
90152 + (len > SEGMEXEC_TASK_SIZE || start > SEGMEXEC_TASK_SIZE-len))
90153 + return -EINVAL;
90154 +#endif
90155 +
90156 down_write(&mm->mmap_sem);
90157 ret = do_munmap(mm, start, len);
90158 up_write(&mm->mmap_sem);
90159 @@ -2559,16 +3042,6 @@ SYSCALL_DEFINE2(munmap, unsigned long, addr, size_t, len)
90160 return vm_munmap(addr, len);
90161 }
90162
90163 -static inline void verify_mm_writelocked(struct mm_struct *mm)
90164 -{
90165 -#ifdef CONFIG_DEBUG_VM
90166 - if (unlikely(down_read_trylock(&mm->mmap_sem))) {
90167 - WARN_ON(1);
90168 - up_read(&mm->mmap_sem);
90169 - }
90170 -#endif
90171 -}
90172 -
90173 /*
90174 * this is really a simplified "do_mmap". it only handles
90175 * anonymous maps. eventually we may be able to do some
90176 @@ -2582,6 +3055,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
90177 struct rb_node ** rb_link, * rb_parent;
90178 pgoff_t pgoff = addr >> PAGE_SHIFT;
90179 int error;
90180 + unsigned long charged;
90181
90182 len = PAGE_ALIGN(len);
90183 if (!len)
90184 @@ -2589,16 +3063,30 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
90185
90186 flags = VM_DATA_DEFAULT_FLAGS | VM_ACCOUNT | mm->def_flags;
90187
90188 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
90189 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
90190 + flags &= ~VM_EXEC;
90191 +
90192 +#ifdef CONFIG_PAX_MPROTECT
90193 + if (mm->pax_flags & MF_PAX_MPROTECT)
90194 + flags &= ~VM_MAYEXEC;
90195 +#endif
90196 +
90197 + }
90198 +#endif
90199 +
90200 error = get_unmapped_area(NULL, addr, len, 0, MAP_FIXED);
90201 if (error & ~PAGE_MASK)
90202 return error;
90203
90204 + charged = len >> PAGE_SHIFT;
90205 +
90206 /*
90207 * mlock MCL_FUTURE?
90208 */
90209 if (mm->def_flags & VM_LOCKED) {
90210 unsigned long locked, lock_limit;
90211 - locked = len >> PAGE_SHIFT;
90212 + locked = charged;
90213 locked += mm->locked_vm;
90214 lock_limit = rlimit(RLIMIT_MEMLOCK);
90215 lock_limit >>= PAGE_SHIFT;
90216 @@ -2615,21 +3103,20 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
90217 /*
90218 * Clear old maps. this also does some error checking for us
90219 */
90220 - munmap_back:
90221 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
90222 if (do_munmap(mm, addr, len))
90223 return -ENOMEM;
90224 - goto munmap_back;
90225 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
90226 }
90227
90228 /* Check against address space limits *after* clearing old maps... */
90229 - if (!may_expand_vm(mm, len >> PAGE_SHIFT))
90230 + if (!may_expand_vm(mm, charged))
90231 return -ENOMEM;
90232
90233 if (mm->map_count > sysctl_max_map_count)
90234 return -ENOMEM;
90235
90236 - if (security_vm_enough_memory_mm(mm, len >> PAGE_SHIFT))
90237 + if (security_vm_enough_memory_mm(mm, charged))
90238 return -ENOMEM;
90239
90240 /* Can we just expand an old private anonymous mapping? */
90241 @@ -2643,7 +3130,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
90242 */
90243 vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
90244 if (!vma) {
90245 - vm_unacct_memory(len >> PAGE_SHIFT);
90246 + vm_unacct_memory(charged);
90247 return -ENOMEM;
90248 }
90249
90250 @@ -2657,10 +3144,11 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
90251 vma_link(mm, vma, prev, rb_link, rb_parent);
90252 out:
90253 perf_event_mmap(vma);
90254 - mm->total_vm += len >> PAGE_SHIFT;
90255 + mm->total_vm += charged;
90256 if (flags & VM_LOCKED)
90257 - mm->locked_vm += (len >> PAGE_SHIFT);
90258 + mm->locked_vm += charged;
90259 vma->vm_flags |= VM_SOFTDIRTY;
90260 + track_exec_limit(mm, addr, addr + len, flags);
90261 return addr;
90262 }
90263
90264 @@ -2722,6 +3210,7 @@ void exit_mmap(struct mm_struct *mm)
90265 while (vma) {
90266 if (vma->vm_flags & VM_ACCOUNT)
90267 nr_accounted += vma_pages(vma);
90268 + vma->vm_mirror = NULL;
90269 vma = remove_vma(vma);
90270 }
90271 vm_unacct_memory(nr_accounted);
90272 @@ -2738,6 +3227,13 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
90273 struct vm_area_struct *prev;
90274 struct rb_node **rb_link, *rb_parent;
90275
90276 +#ifdef CONFIG_PAX_SEGMEXEC
90277 + struct vm_area_struct *vma_m = NULL;
90278 +#endif
90279 +
90280 + if (security_mmap_addr(vma->vm_start))
90281 + return -EPERM;
90282 +
90283 /*
90284 * The vm_pgoff of a purely anonymous vma should be irrelevant
90285 * until its first write fault, when page's anon_vma and index
90286 @@ -2761,7 +3257,21 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
90287 security_vm_enough_memory_mm(mm, vma_pages(vma)))
90288 return -ENOMEM;
90289
90290 +#ifdef CONFIG_PAX_SEGMEXEC
90291 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_EXEC)) {
90292 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
90293 + if (!vma_m)
90294 + return -ENOMEM;
90295 + }
90296 +#endif
90297 +
90298 vma_link(mm, vma, prev, rb_link, rb_parent);
90299 +
90300 +#ifdef CONFIG_PAX_SEGMEXEC
90301 + if (vma_m)
90302 + BUG_ON(pax_mirror_vma(vma_m, vma));
90303 +#endif
90304 +
90305 return 0;
90306 }
90307
90308 @@ -2780,6 +3290,8 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
90309 struct rb_node **rb_link, *rb_parent;
90310 bool faulted_in_anon_vma = true;
90311
90312 + BUG_ON(vma->vm_mirror);
90313 +
90314 /*
90315 * If anonymous vma has not yet been faulted, update new pgoff
90316 * to match new location, to increase its chance of merging.
90317 @@ -2844,6 +3356,39 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
90318 return NULL;
90319 }
90320
90321 +#ifdef CONFIG_PAX_SEGMEXEC
90322 +long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma)
90323 +{
90324 + struct vm_area_struct *prev_m;
90325 + struct rb_node **rb_link_m, *rb_parent_m;
90326 + struct mempolicy *pol_m;
90327 +
90328 + BUG_ON(!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC));
90329 + BUG_ON(vma->vm_mirror || vma_m->vm_mirror);
90330 + BUG_ON(!mpol_equal(vma_policy(vma), vma_policy(vma_m)));
90331 + *vma_m = *vma;
90332 + INIT_LIST_HEAD(&vma_m->anon_vma_chain);
90333 + if (anon_vma_clone(vma_m, vma))
90334 + return -ENOMEM;
90335 + pol_m = vma_policy(vma_m);
90336 + mpol_get(pol_m);
90337 + set_vma_policy(vma_m, pol_m);
90338 + vma_m->vm_start += SEGMEXEC_TASK_SIZE;
90339 + vma_m->vm_end += SEGMEXEC_TASK_SIZE;
90340 + vma_m->vm_flags &= ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED);
90341 + vma_m->vm_page_prot = vm_get_page_prot(vma_m->vm_flags);
90342 + if (vma_m->vm_file)
90343 + get_file(vma_m->vm_file);
90344 + if (vma_m->vm_ops && vma_m->vm_ops->open)
90345 + vma_m->vm_ops->open(vma_m);
90346 + BUG_ON(find_vma_links(vma->vm_mm, vma_m->vm_start, vma_m->vm_end, &prev_m, &rb_link_m, &rb_parent_m));
90347 + vma_link(vma->vm_mm, vma_m, prev_m, rb_link_m, rb_parent_m);
90348 + vma_m->vm_mirror = vma;
90349 + vma->vm_mirror = vma_m;
90350 + return 0;
90351 +}
90352 +#endif
90353 +
90354 /*
90355 * Return true if the calling process may expand its vm space by the passed
90356 * number of pages
90357 @@ -2855,6 +3400,7 @@ int may_expand_vm(struct mm_struct *mm, unsigned long npages)
90358
90359 lim = rlimit(RLIMIT_AS) >> PAGE_SHIFT;
90360
90361 + gr_learn_resource(current, RLIMIT_AS, (cur + npages) << PAGE_SHIFT, 1);
90362 if (cur + npages > lim)
90363 return 0;
90364 return 1;
90365 @@ -2925,6 +3471,22 @@ int install_special_mapping(struct mm_struct *mm,
90366 vma->vm_start = addr;
90367 vma->vm_end = addr + len;
90368
90369 +#ifdef CONFIG_PAX_MPROTECT
90370 + if (mm->pax_flags & MF_PAX_MPROTECT) {
90371 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
90372 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC))
90373 + return -EPERM;
90374 + if (!(vm_flags & VM_EXEC))
90375 + vm_flags &= ~VM_MAYEXEC;
90376 +#else
90377 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
90378 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
90379 +#endif
90380 + else
90381 + vm_flags &= ~VM_MAYWRITE;
90382 + }
90383 +#endif
90384 +
90385 vma->vm_flags = vm_flags | mm->def_flags | VM_DONTEXPAND | VM_SOFTDIRTY;
90386 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
90387
90388 diff --git a/mm/mprotect.c b/mm/mprotect.c
90389 index 6c3f56f..b2340b0 100644
90390 --- a/mm/mprotect.c
90391 +++ b/mm/mprotect.c
90392 @@ -23,10 +23,18 @@
90393 #include <linux/mmu_notifier.h>
90394 #include <linux/migrate.h>
90395 #include <linux/perf_event.h>
90396 +#include <linux/sched/sysctl.h>
90397 +
90398 +#ifdef CONFIG_PAX_MPROTECT
90399 +#include <linux/elf.h>
90400 +#include <linux/binfmts.h>
90401 +#endif
90402 +
90403 #include <asm/uaccess.h>
90404 #include <asm/pgtable.h>
90405 #include <asm/cacheflush.h>
90406 #include <asm/tlbflush.h>
90407 +#include <asm/mmu_context.h>
90408
90409 #ifndef pgprot_modify
90410 static inline pgprot_t pgprot_modify(pgprot_t oldprot, pgprot_t newprot)
90411 @@ -241,6 +249,48 @@ unsigned long change_protection(struct vm_area_struct *vma, unsigned long start,
90412 return pages;
90413 }
90414
90415 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
90416 +/* called while holding the mmap semaphor for writing except stack expansion */
90417 +void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot)
90418 +{
90419 + unsigned long oldlimit, newlimit = 0UL;
90420 +
90421 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || (__supported_pte_mask & _PAGE_NX))
90422 + return;
90423 +
90424 + spin_lock(&mm->page_table_lock);
90425 + oldlimit = mm->context.user_cs_limit;
90426 + if ((prot & VM_EXEC) && oldlimit < end)
90427 + /* USER_CS limit moved up */
90428 + newlimit = end;
90429 + else if (!(prot & VM_EXEC) && start < oldlimit && oldlimit <= end)
90430 + /* USER_CS limit moved down */
90431 + newlimit = start;
90432 +
90433 + if (newlimit) {
90434 + mm->context.user_cs_limit = newlimit;
90435 +
90436 +#ifdef CONFIG_SMP
90437 + wmb();
90438 + cpus_clear(mm->context.cpu_user_cs_mask);
90439 + cpu_set(smp_processor_id(), mm->context.cpu_user_cs_mask);
90440 +#endif
90441 +
90442 + set_user_cs(mm->context.user_cs_base, mm->context.user_cs_limit, smp_processor_id());
90443 + }
90444 + spin_unlock(&mm->page_table_lock);
90445 + if (newlimit == end) {
90446 + struct vm_area_struct *vma = find_vma(mm, oldlimit);
90447 +
90448 + for (; vma && vma->vm_start < end; vma = vma->vm_next)
90449 + if (is_vm_hugetlb_page(vma))
90450 + hugetlb_change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot);
90451 + else
90452 + change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot, vma_wants_writenotify(vma), 0);
90453 + }
90454 +}
90455 +#endif
90456 +
90457 int
90458 mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
90459 unsigned long start, unsigned long end, unsigned long newflags)
90460 @@ -253,11 +303,29 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
90461 int error;
90462 int dirty_accountable = 0;
90463
90464 +#ifdef CONFIG_PAX_SEGMEXEC
90465 + struct vm_area_struct *vma_m = NULL;
90466 + unsigned long start_m, end_m;
90467 +
90468 + start_m = start + SEGMEXEC_TASK_SIZE;
90469 + end_m = end + SEGMEXEC_TASK_SIZE;
90470 +#endif
90471 +
90472 if (newflags == oldflags) {
90473 *pprev = vma;
90474 return 0;
90475 }
90476
90477 + if (newflags & (VM_READ | VM_WRITE | VM_EXEC)) {
90478 + struct vm_area_struct *prev = vma->vm_prev, *next = vma->vm_next;
90479 +
90480 + if (next && (next->vm_flags & VM_GROWSDOWN) && sysctl_heap_stack_gap > next->vm_start - end)
90481 + return -ENOMEM;
90482 +
90483 + if (prev && (prev->vm_flags & VM_GROWSUP) && sysctl_heap_stack_gap > start - prev->vm_end)
90484 + return -ENOMEM;
90485 + }
90486 +
90487 /*
90488 * If we make a private mapping writable we increase our commit;
90489 * but (without finer accounting) cannot reduce our commit if we
90490 @@ -274,6 +342,42 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
90491 }
90492 }
90493
90494 +#ifdef CONFIG_PAX_SEGMEXEC
90495 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && ((oldflags ^ newflags) & VM_EXEC)) {
90496 + if (start != vma->vm_start) {
90497 + error = split_vma(mm, vma, start, 1);
90498 + if (error)
90499 + goto fail;
90500 + BUG_ON(!*pprev || (*pprev)->vm_next == vma);
90501 + *pprev = (*pprev)->vm_next;
90502 + }
90503 +
90504 + if (end != vma->vm_end) {
90505 + error = split_vma(mm, vma, end, 0);
90506 + if (error)
90507 + goto fail;
90508 + }
90509 +
90510 + if (pax_find_mirror_vma(vma)) {
90511 + error = __do_munmap(mm, start_m, end_m - start_m);
90512 + if (error)
90513 + goto fail;
90514 + } else {
90515 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
90516 + if (!vma_m) {
90517 + error = -ENOMEM;
90518 + goto fail;
90519 + }
90520 + vma->vm_flags = newflags;
90521 + error = pax_mirror_vma(vma_m, vma);
90522 + if (error) {
90523 + vma->vm_flags = oldflags;
90524 + goto fail;
90525 + }
90526 + }
90527 + }
90528 +#endif
90529 +
90530 /*
90531 * First try to merge with previous and/or next vma.
90532 */
90533 @@ -304,9 +408,21 @@ success:
90534 * vm_flags and vm_page_prot are protected by the mmap_sem
90535 * held in write mode.
90536 */
90537 +
90538 +#ifdef CONFIG_PAX_SEGMEXEC
90539 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (newflags & VM_EXEC) && ((vma->vm_flags ^ newflags) & VM_READ))
90540 + pax_find_mirror_vma(vma)->vm_flags ^= VM_READ;
90541 +#endif
90542 +
90543 vma->vm_flags = newflags;
90544 +
90545 +#ifdef CONFIG_PAX_MPROTECT
90546 + if (mm->binfmt && mm->binfmt->handle_mprotect)
90547 + mm->binfmt->handle_mprotect(vma, newflags);
90548 +#endif
90549 +
90550 vma->vm_page_prot = pgprot_modify(vma->vm_page_prot,
90551 - vm_get_page_prot(newflags));
90552 + vm_get_page_prot(vma->vm_flags));
90553
90554 if (vma_wants_writenotify(vma)) {
90555 vma->vm_page_prot = vm_get_page_prot(newflags & ~VM_SHARED);
90556 @@ -345,6 +461,17 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
90557 end = start + len;
90558 if (end <= start)
90559 return -ENOMEM;
90560 +
90561 +#ifdef CONFIG_PAX_SEGMEXEC
90562 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
90563 + if (end > SEGMEXEC_TASK_SIZE)
90564 + return -EINVAL;
90565 + } else
90566 +#endif
90567 +
90568 + if (end > TASK_SIZE)
90569 + return -EINVAL;
90570 +
90571 if (!arch_validate_prot(prot))
90572 return -EINVAL;
90573
90574 @@ -352,7 +479,7 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
90575 /*
90576 * Does the application expect PROT_READ to imply PROT_EXEC:
90577 */
90578 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
90579 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
90580 prot |= PROT_EXEC;
90581
90582 vm_flags = calc_vm_prot_bits(prot);
90583 @@ -384,6 +511,11 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
90584 if (start > vma->vm_start)
90585 prev = vma;
90586
90587 +#ifdef CONFIG_PAX_MPROTECT
90588 + if (current->mm->binfmt && current->mm->binfmt->handle_mprotect)
90589 + current->mm->binfmt->handle_mprotect(vma, vm_flags);
90590 +#endif
90591 +
90592 for (nstart = start ; ; ) {
90593 unsigned long newflags;
90594
90595 @@ -394,6 +526,14 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
90596
90597 /* newflags >> 4 shift VM_MAY% in place of VM_% */
90598 if ((newflags & ~(newflags >> 4)) & (VM_READ | VM_WRITE | VM_EXEC)) {
90599 + if (prot & (PROT_WRITE | PROT_EXEC))
90600 + gr_log_rwxmprotect(vma);
90601 +
90602 + error = -EACCES;
90603 + goto out;
90604 + }
90605 +
90606 + if (!gr_acl_handle_mprotect(vma->vm_file, prot)) {
90607 error = -EACCES;
90608 goto out;
90609 }
90610 @@ -408,6 +548,9 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
90611 error = mprotect_fixup(vma, &prev, nstart, tmp, newflags);
90612 if (error)
90613 goto out;
90614 +
90615 + track_exec_limit(current->mm, nstart, tmp, vm_flags);
90616 +
90617 nstart = tmp;
90618
90619 if (nstart < prev->vm_end)
90620 diff --git a/mm/mremap.c b/mm/mremap.c
90621 index 0843feb..4f5b2e6 100644
90622 --- a/mm/mremap.c
90623 +++ b/mm/mremap.c
90624 @@ -144,6 +144,12 @@ static void move_ptes(struct vm_area_struct *vma, pmd_t *old_pmd,
90625 continue;
90626 pte = ptep_get_and_clear(mm, old_addr, old_pte);
90627 pte = move_pte(pte, new_vma->vm_page_prot, old_addr, new_addr);
90628 +
90629 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
90630 + if (!(__supported_pte_mask & _PAGE_NX) && pte_present(pte) && (new_vma->vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC)
90631 + pte = pte_exprotect(pte);
90632 +#endif
90633 +
90634 pte = move_soft_dirty_pte(pte);
90635 set_pte_at(mm, new_addr, new_pte, pte);
90636 }
90637 @@ -337,6 +343,11 @@ static struct vm_area_struct *vma_to_resize(unsigned long addr,
90638 if (is_vm_hugetlb_page(vma))
90639 goto Einval;
90640
90641 +#ifdef CONFIG_PAX_SEGMEXEC
90642 + if (pax_find_mirror_vma(vma))
90643 + goto Einval;
90644 +#endif
90645 +
90646 /* We can't remap across vm area boundaries */
90647 if (old_len > vma->vm_end - addr)
90648 goto Efault;
90649 @@ -392,20 +403,25 @@ static unsigned long mremap_to(unsigned long addr, unsigned long old_len,
90650 unsigned long ret = -EINVAL;
90651 unsigned long charged = 0;
90652 unsigned long map_flags;
90653 + unsigned long pax_task_size = TASK_SIZE;
90654
90655 if (new_addr & ~PAGE_MASK)
90656 goto out;
90657
90658 - if (new_len > TASK_SIZE || new_addr > TASK_SIZE - new_len)
90659 +#ifdef CONFIG_PAX_SEGMEXEC
90660 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
90661 + pax_task_size = SEGMEXEC_TASK_SIZE;
90662 +#endif
90663 +
90664 + pax_task_size -= PAGE_SIZE;
90665 +
90666 + if (new_len > TASK_SIZE || new_addr > pax_task_size - new_len)
90667 goto out;
90668
90669 /* Check if the location we're moving into overlaps the
90670 * old location at all, and fail if it does.
90671 */
90672 - if ((new_addr <= addr) && (new_addr+new_len) > addr)
90673 - goto out;
90674 -
90675 - if ((addr <= new_addr) && (addr+old_len) > new_addr)
90676 + if (addr + old_len > new_addr && new_addr + new_len > addr)
90677 goto out;
90678
90679 ret = do_munmap(mm, new_addr, new_len);
90680 @@ -474,6 +490,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
90681 unsigned long ret = -EINVAL;
90682 unsigned long charged = 0;
90683 bool locked = false;
90684 + unsigned long pax_task_size = TASK_SIZE;
90685
90686 if (flags & ~(MREMAP_FIXED | MREMAP_MAYMOVE))
90687 return ret;
90688 @@ -495,6 +512,17 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
90689 if (!new_len)
90690 return ret;
90691
90692 +#ifdef CONFIG_PAX_SEGMEXEC
90693 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
90694 + pax_task_size = SEGMEXEC_TASK_SIZE;
90695 +#endif
90696 +
90697 + pax_task_size -= PAGE_SIZE;
90698 +
90699 + if (new_len > pax_task_size || addr > pax_task_size-new_len ||
90700 + old_len > pax_task_size || addr > pax_task_size-old_len)
90701 + return ret;
90702 +
90703 down_write(&current->mm->mmap_sem);
90704
90705 if (flags & MREMAP_FIXED) {
90706 @@ -545,6 +573,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
90707 new_addr = addr;
90708 }
90709 ret = addr;
90710 + track_exec_limit(vma->vm_mm, vma->vm_start, addr + new_len, vma->vm_flags);
90711 goto out;
90712 }
90713 }
90714 @@ -568,7 +597,12 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
90715 goto out;
90716 }
90717
90718 + map_flags = vma->vm_flags;
90719 ret = move_vma(vma, addr, old_len, new_len, new_addr, &locked);
90720 + if (!(ret & ~PAGE_MASK)) {
90721 + track_exec_limit(current->mm, addr, addr + old_len, 0UL);
90722 + track_exec_limit(current->mm, new_addr, new_addr + new_len, map_flags);
90723 + }
90724 }
90725 out:
90726 if (ret & ~PAGE_MASK)
90727 diff --git a/mm/nommu.c b/mm/nommu.c
90728 index ecd1f15..77039bd 100644
90729 --- a/mm/nommu.c
90730 +++ b/mm/nommu.c
90731 @@ -64,7 +64,6 @@ int sysctl_max_map_count = DEFAULT_MAX_MAP_COUNT;
90732 int sysctl_nr_trim_pages = CONFIG_NOMMU_INITIAL_TRIM_EXCESS;
90733 unsigned long sysctl_user_reserve_kbytes __read_mostly = 1UL << 17; /* 128MB */
90734 unsigned long sysctl_admin_reserve_kbytes __read_mostly = 1UL << 13; /* 8MB */
90735 -int heap_stack_gap = 0;
90736
90737 atomic_long_t mmap_pages_allocated;
90738
90739 @@ -844,15 +843,6 @@ struct vm_area_struct *find_vma(struct mm_struct *mm, unsigned long addr)
90740 EXPORT_SYMBOL(find_vma);
90741
90742 /*
90743 - * find a VMA
90744 - * - we don't extend stack VMAs under NOMMU conditions
90745 - */
90746 -struct vm_area_struct *find_extend_vma(struct mm_struct *mm, unsigned long addr)
90747 -{
90748 - return find_vma(mm, addr);
90749 -}
90750 -
90751 -/*
90752 * expand a stack to a given address
90753 * - not supported under NOMMU conditions
90754 */
90755 @@ -1563,6 +1553,7 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
90756
90757 /* most fields are the same, copy all, and then fixup */
90758 *new = *vma;
90759 + INIT_LIST_HEAD(&new->anon_vma_chain);
90760 *region = *vma->vm_region;
90761 new->vm_region = region;
90762
90763 @@ -1993,8 +1984,8 @@ int generic_file_remap_pages(struct vm_area_struct *vma, unsigned long addr,
90764 }
90765 EXPORT_SYMBOL(generic_file_remap_pages);
90766
90767 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
90768 - unsigned long addr, void *buf, int len, int write)
90769 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
90770 + unsigned long addr, void *buf, size_t len, int write)
90771 {
90772 struct vm_area_struct *vma;
90773
90774 @@ -2035,8 +2026,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
90775 *
90776 * The caller must hold a reference on @mm.
90777 */
90778 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
90779 - void *buf, int len, int write)
90780 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
90781 + void *buf, size_t len, int write)
90782 {
90783 return __access_remote_vm(NULL, mm, addr, buf, len, write);
90784 }
90785 @@ -2045,7 +2036,7 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
90786 * Access another process' address space.
90787 * - source/target buffer must be kernel space
90788 */
90789 -int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write)
90790 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write)
90791 {
90792 struct mm_struct *mm;
90793
90794 diff --git a/mm/page-writeback.c b/mm/page-writeback.c
90795 index 6380758..4064aec 100644
90796 --- a/mm/page-writeback.c
90797 +++ b/mm/page-writeback.c
90798 @@ -690,7 +690,7 @@ static inline long long pos_ratio_polynom(unsigned long setpoint,
90799 * card's bdi_dirty may rush to many times higher than bdi_setpoint.
90800 * - the bdi dirty thresh drops quickly due to change of JBOD workload
90801 */
90802 -static unsigned long bdi_position_ratio(struct backing_dev_info *bdi,
90803 +static unsigned long __intentional_overflow(-1) bdi_position_ratio(struct backing_dev_info *bdi,
90804 unsigned long thresh,
90805 unsigned long bg_thresh,
90806 unsigned long dirty,
90807 diff --git a/mm/page_alloc.c b/mm/page_alloc.c
90808 index dd886fa..7686339 100644
90809 --- a/mm/page_alloc.c
90810 +++ b/mm/page_alloc.c
90811 @@ -61,6 +61,7 @@
90812 #include <linux/page-debug-flags.h>
90813 #include <linux/hugetlb.h>
90814 #include <linux/sched/rt.h>
90815 +#include <linux/random.h>
90816
90817 #include <asm/sections.h>
90818 #include <asm/tlbflush.h>
90819 @@ -354,7 +355,7 @@ out:
90820 * This usage means that zero-order pages may not be compound.
90821 */
90822
90823 -static void free_compound_page(struct page *page)
90824 +void free_compound_page(struct page *page)
90825 {
90826 __free_pages_ok(page, compound_order(page));
90827 }
90828 @@ -712,6 +713,10 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
90829 int i;
90830 int bad = 0;
90831
90832 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
90833 + unsigned long index = 1UL << order;
90834 +#endif
90835 +
90836 trace_mm_page_free(page, order);
90837 kmemcheck_free_shadow(page, order);
90838
90839 @@ -728,6 +733,12 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
90840 debug_check_no_obj_freed(page_address(page),
90841 PAGE_SIZE << order);
90842 }
90843 +
90844 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
90845 + for (; index; --index)
90846 + sanitize_highpage(page + index - 1);
90847 +#endif
90848 +
90849 arch_free_page(page, order);
90850 kernel_map_pages(page, 1 << order, 0);
90851
90852 @@ -750,6 +761,20 @@ static void __free_pages_ok(struct page *page, unsigned int order)
90853 local_irq_restore(flags);
90854 }
90855
90856 +#ifdef CONFIG_PAX_LATENT_ENTROPY
90857 +bool __meminitdata extra_latent_entropy;
90858 +
90859 +static int __init setup_pax_extra_latent_entropy(char *str)
90860 +{
90861 + extra_latent_entropy = true;
90862 + return 0;
90863 +}
90864 +early_param("pax_extra_latent_entropy", setup_pax_extra_latent_entropy);
90865 +
90866 +volatile u64 latent_entropy __latent_entropy;
90867 +EXPORT_SYMBOL(latent_entropy);
90868 +#endif
90869 +
90870 void __init __free_pages_bootmem(struct page *page, unsigned int order)
90871 {
90872 unsigned int nr_pages = 1 << order;
90873 @@ -765,6 +790,19 @@ void __init __free_pages_bootmem(struct page *page, unsigned int order)
90874 __ClearPageReserved(p);
90875 set_page_count(p, 0);
90876
90877 +#ifdef CONFIG_PAX_LATENT_ENTROPY
90878 + if (extra_latent_entropy && !PageHighMem(page) && page_to_pfn(page) < 0x100000) {
90879 + u64 hash = 0;
90880 + size_t index, end = PAGE_SIZE * nr_pages / sizeof hash;
90881 + const u64 *data = lowmem_page_address(page);
90882 +
90883 + for (index = 0; index < end; index++)
90884 + hash ^= hash + data[index];
90885 + latent_entropy ^= hash;
90886 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
90887 + }
90888 +#endif
90889 +
90890 page_zone(page)->managed_pages += nr_pages;
90891 set_page_refcounted(page);
90892 __free_pages(page, order);
90893 @@ -870,8 +908,10 @@ static int prep_new_page(struct page *page, int order, gfp_t gfp_flags)
90894 arch_alloc_page(page, order);
90895 kernel_map_pages(page, 1 << order, 1);
90896
90897 +#ifndef CONFIG_PAX_MEMORY_SANITIZE
90898 if (gfp_flags & __GFP_ZERO)
90899 prep_zero_page(page, order, gfp_flags);
90900 +#endif
90901
90902 if (order && (gfp_flags & __GFP_COMP))
90903 prep_compound_page(page, order);
90904 diff --git a/mm/page_io.c b/mm/page_io.c
90905 index 8c79a47..a689e0d 100644
90906 --- a/mm/page_io.c
90907 +++ b/mm/page_io.c
90908 @@ -260,7 +260,7 @@ int __swap_writepage(struct page *page, struct writeback_control *wbc,
90909 struct file *swap_file = sis->swap_file;
90910 struct address_space *mapping = swap_file->f_mapping;
90911 struct iovec iov = {
90912 - .iov_base = kmap(page),
90913 + .iov_base = (void __force_user *)kmap(page),
90914 .iov_len = PAGE_SIZE,
90915 };
90916
90917 diff --git a/mm/percpu.c b/mm/percpu.c
90918 index 8c8e08f..73a5cda 100644
90919 --- a/mm/percpu.c
90920 +++ b/mm/percpu.c
90921 @@ -122,7 +122,7 @@ static unsigned int pcpu_low_unit_cpu __read_mostly;
90922 static unsigned int pcpu_high_unit_cpu __read_mostly;
90923
90924 /* the address of the first chunk which starts with the kernel static area */
90925 -void *pcpu_base_addr __read_mostly;
90926 +void *pcpu_base_addr __read_only;
90927 EXPORT_SYMBOL_GPL(pcpu_base_addr);
90928
90929 static const int *pcpu_unit_map __read_mostly; /* cpu -> unit */
90930 diff --git a/mm/process_vm_access.c b/mm/process_vm_access.c
90931 index fd26d04..0cea1b0 100644
90932 --- a/mm/process_vm_access.c
90933 +++ b/mm/process_vm_access.c
90934 @@ -13,6 +13,7 @@
90935 #include <linux/uio.h>
90936 #include <linux/sched.h>
90937 #include <linux/highmem.h>
90938 +#include <linux/security.h>
90939 #include <linux/ptrace.h>
90940 #include <linux/slab.h>
90941 #include <linux/syscalls.h>
90942 @@ -258,19 +259,19 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
90943 size_t iov_l_curr_offset = 0;
90944 ssize_t iov_len;
90945
90946 + return -ENOSYS; // PaX: until properly audited
90947 +
90948 /*
90949 * Work out how many pages of struct pages we're going to need
90950 * when eventually calling get_user_pages
90951 */
90952 for (i = 0; i < riovcnt; i++) {
90953 iov_len = rvec[i].iov_len;
90954 - if (iov_len > 0) {
90955 - nr_pages_iov = ((unsigned long)rvec[i].iov_base
90956 - + iov_len)
90957 - / PAGE_SIZE - (unsigned long)rvec[i].iov_base
90958 - / PAGE_SIZE + 1;
90959 - nr_pages = max(nr_pages, nr_pages_iov);
90960 - }
90961 + if (iov_len <= 0)
90962 + continue;
90963 + nr_pages_iov = ((unsigned long)rvec[i].iov_base + iov_len) / PAGE_SIZE -
90964 + (unsigned long)rvec[i].iov_base / PAGE_SIZE + 1;
90965 + nr_pages = max(nr_pages, nr_pages_iov);
90966 }
90967
90968 if (nr_pages == 0)
90969 @@ -298,6 +299,11 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
90970 goto free_proc_pages;
90971 }
90972
90973 + if (gr_handle_ptrace(task, vm_write ? PTRACE_POKETEXT : PTRACE_ATTACH)) {
90974 + rc = -EPERM;
90975 + goto put_task_struct;
90976 + }
90977 +
90978 mm = mm_access(task, PTRACE_MODE_ATTACH);
90979 if (!mm || IS_ERR(mm)) {
90980 rc = IS_ERR(mm) ? PTR_ERR(mm) : -ESRCH;
90981 diff --git a/mm/rmap.c b/mm/rmap.c
90982 index fd3ee7a..3613079 100644
90983 --- a/mm/rmap.c
90984 +++ b/mm/rmap.c
90985 @@ -163,6 +163,10 @@ int anon_vma_prepare(struct vm_area_struct *vma)
90986 struct anon_vma *anon_vma = vma->anon_vma;
90987 struct anon_vma_chain *avc;
90988
90989 +#ifdef CONFIG_PAX_SEGMEXEC
90990 + struct anon_vma_chain *avc_m = NULL;
90991 +#endif
90992 +
90993 might_sleep();
90994 if (unlikely(!anon_vma)) {
90995 struct mm_struct *mm = vma->vm_mm;
90996 @@ -172,6 +176,12 @@ int anon_vma_prepare(struct vm_area_struct *vma)
90997 if (!avc)
90998 goto out_enomem;
90999
91000 +#ifdef CONFIG_PAX_SEGMEXEC
91001 + avc_m = anon_vma_chain_alloc(GFP_KERNEL);
91002 + if (!avc_m)
91003 + goto out_enomem_free_avc;
91004 +#endif
91005 +
91006 anon_vma = find_mergeable_anon_vma(vma);
91007 allocated = NULL;
91008 if (!anon_vma) {
91009 @@ -185,6 +195,18 @@ int anon_vma_prepare(struct vm_area_struct *vma)
91010 /* page_table_lock to protect against threads */
91011 spin_lock(&mm->page_table_lock);
91012 if (likely(!vma->anon_vma)) {
91013 +
91014 +#ifdef CONFIG_PAX_SEGMEXEC
91015 + struct vm_area_struct *vma_m = pax_find_mirror_vma(vma);
91016 +
91017 + if (vma_m) {
91018 + BUG_ON(vma_m->anon_vma);
91019 + vma_m->anon_vma = anon_vma;
91020 + anon_vma_chain_link(vma_m, avc_m, anon_vma);
91021 + avc_m = NULL;
91022 + }
91023 +#endif
91024 +
91025 vma->anon_vma = anon_vma;
91026 anon_vma_chain_link(vma, avc, anon_vma);
91027 allocated = NULL;
91028 @@ -195,12 +217,24 @@ int anon_vma_prepare(struct vm_area_struct *vma)
91029
91030 if (unlikely(allocated))
91031 put_anon_vma(allocated);
91032 +
91033 +#ifdef CONFIG_PAX_SEGMEXEC
91034 + if (unlikely(avc_m))
91035 + anon_vma_chain_free(avc_m);
91036 +#endif
91037 +
91038 if (unlikely(avc))
91039 anon_vma_chain_free(avc);
91040 }
91041 return 0;
91042
91043 out_enomem_free_avc:
91044 +
91045 +#ifdef CONFIG_PAX_SEGMEXEC
91046 + if (avc_m)
91047 + anon_vma_chain_free(avc_m);
91048 +#endif
91049 +
91050 anon_vma_chain_free(avc);
91051 out_enomem:
91052 return -ENOMEM;
91053 @@ -236,7 +270,7 @@ static inline void unlock_anon_vma_root(struct anon_vma *root)
91054 * Attach the anon_vmas from src to dst.
91055 * Returns 0 on success, -ENOMEM on failure.
91056 */
91057 -int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
91058 +int anon_vma_clone(struct vm_area_struct *dst, const struct vm_area_struct *src)
91059 {
91060 struct anon_vma_chain *avc, *pavc;
91061 struct anon_vma *root = NULL;
91062 @@ -269,7 +303,7 @@ int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
91063 * the corresponding VMA in the parent process is attached to.
91064 * Returns 0 on success, non-zero on failure.
91065 */
91066 -int anon_vma_fork(struct vm_area_struct *vma, struct vm_area_struct *pvma)
91067 +int anon_vma_fork(struct vm_area_struct *vma, const struct vm_area_struct *pvma)
91068 {
91069 struct anon_vma_chain *avc;
91070 struct anon_vma *anon_vma;
91071 @@ -373,8 +407,10 @@ static void anon_vma_ctor(void *data)
91072 void __init anon_vma_init(void)
91073 {
91074 anon_vma_cachep = kmem_cache_create("anon_vma", sizeof(struct anon_vma),
91075 - 0, SLAB_DESTROY_BY_RCU|SLAB_PANIC, anon_vma_ctor);
91076 - anon_vma_chain_cachep = KMEM_CACHE(anon_vma_chain, SLAB_PANIC);
91077 + 0, SLAB_DESTROY_BY_RCU|SLAB_PANIC|SLAB_NO_SANITIZE,
91078 + anon_vma_ctor);
91079 + anon_vma_chain_cachep = KMEM_CACHE(anon_vma_chain,
91080 + SLAB_PANIC|SLAB_NO_SANITIZE);
91081 }
91082
91083 /*
91084 diff --git a/mm/shmem.c b/mm/shmem.c
91085 index 8297623..6b9dfe9 100644
91086 --- a/mm/shmem.c
91087 +++ b/mm/shmem.c
91088 @@ -33,7 +33,7 @@
91089 #include <linux/swap.h>
91090 #include <linux/aio.h>
91091
91092 -static struct vfsmount *shm_mnt;
91093 +struct vfsmount *shm_mnt;
91094
91095 #ifdef CONFIG_SHMEM
91096 /*
91097 @@ -77,7 +77,7 @@ static struct vfsmount *shm_mnt;
91098 #define BOGO_DIRENT_SIZE 20
91099
91100 /* Symlink up to this size is kmalloc'ed instead of using a swappable page */
91101 -#define SHORT_SYMLINK_LEN 128
91102 +#define SHORT_SYMLINK_LEN 64
91103
91104 /*
91105 * shmem_fallocate and shmem_writepage communicate via inode->i_private
91106 @@ -2232,6 +2232,11 @@ static const struct xattr_handler *shmem_xattr_handlers[] = {
91107 static int shmem_xattr_validate(const char *name)
91108 {
91109 struct { const char *prefix; size_t len; } arr[] = {
91110 +
91111 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
91112 + { XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN},
91113 +#endif
91114 +
91115 { XATTR_SECURITY_PREFIX, XATTR_SECURITY_PREFIX_LEN },
91116 { XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN }
91117 };
91118 @@ -2287,6 +2292,15 @@ static int shmem_setxattr(struct dentry *dentry, const char *name,
91119 if (err)
91120 return err;
91121
91122 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
91123 + if (!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN)) {
91124 + if (strcmp(name, XATTR_NAME_PAX_FLAGS))
91125 + return -EOPNOTSUPP;
91126 + if (size > 8)
91127 + return -EINVAL;
91128 + }
91129 +#endif
91130 +
91131 return simple_xattr_set(&info->xattrs, name, value, size, flags);
91132 }
91133
91134 @@ -2599,8 +2613,7 @@ int shmem_fill_super(struct super_block *sb, void *data, int silent)
91135 int err = -ENOMEM;
91136
91137 /* Round up to L1_CACHE_BYTES to resist false sharing */
91138 - sbinfo = kzalloc(max((int)sizeof(struct shmem_sb_info),
91139 - L1_CACHE_BYTES), GFP_KERNEL);
91140 + sbinfo = kzalloc(max(sizeof(struct shmem_sb_info), L1_CACHE_BYTES), GFP_KERNEL);
91141 if (!sbinfo)
91142 return -ENOMEM;
91143
91144 diff --git a/mm/slab.c b/mm/slab.c
91145 index 2580db0..0523956 100644
91146 --- a/mm/slab.c
91147 +++ b/mm/slab.c
91148 @@ -366,10 +366,12 @@ static void kmem_cache_node_init(struct kmem_cache_node *parent)
91149 if ((x)->max_freeable < i) \
91150 (x)->max_freeable = i; \
91151 } while (0)
91152 -#define STATS_INC_ALLOCHIT(x) atomic_inc(&(x)->allochit)
91153 -#define STATS_INC_ALLOCMISS(x) atomic_inc(&(x)->allocmiss)
91154 -#define STATS_INC_FREEHIT(x) atomic_inc(&(x)->freehit)
91155 -#define STATS_INC_FREEMISS(x) atomic_inc(&(x)->freemiss)
91156 +#define STATS_INC_ALLOCHIT(x) atomic_inc_unchecked(&(x)->allochit)
91157 +#define STATS_INC_ALLOCMISS(x) atomic_inc_unchecked(&(x)->allocmiss)
91158 +#define STATS_INC_FREEHIT(x) atomic_inc_unchecked(&(x)->freehit)
91159 +#define STATS_INC_FREEMISS(x) atomic_inc_unchecked(&(x)->freemiss)
91160 +#define STATS_INC_SANITIZED(x) atomic_inc_unchecked(&(x)->sanitized)
91161 +#define STATS_INC_NOT_SANITIZED(x) atomic_inc_unchecked(&(x)->not_sanitized)
91162 #else
91163 #define STATS_INC_ACTIVE(x) do { } while (0)
91164 #define STATS_DEC_ACTIVE(x) do { } while (0)
91165 @@ -386,6 +388,8 @@ static void kmem_cache_node_init(struct kmem_cache_node *parent)
91166 #define STATS_INC_ALLOCMISS(x) do { } while (0)
91167 #define STATS_INC_FREEHIT(x) do { } while (0)
91168 #define STATS_INC_FREEMISS(x) do { } while (0)
91169 +#define STATS_INC_SANITIZED(x) do { } while (0)
91170 +#define STATS_INC_NOT_SANITIZED(x) do { } while (0)
91171 #endif
91172
91173 #if DEBUG
91174 @@ -477,7 +481,7 @@ static inline void *index_to_obj(struct kmem_cache *cache, struct slab *slab,
91175 * reciprocal_divide(offset, cache->reciprocal_buffer_size)
91176 */
91177 static inline unsigned int obj_to_index(const struct kmem_cache *cache,
91178 - const struct slab *slab, void *obj)
91179 + const struct slab *slab, const void *obj)
91180 {
91181 u32 offset = (obj - slab->s_mem);
91182 return reciprocal_divide(offset, cache->reciprocal_buffer_size);
91183 @@ -1571,12 +1575,12 @@ void __init kmem_cache_init(void)
91184 */
91185
91186 kmalloc_caches[INDEX_AC] = create_kmalloc_cache("kmalloc-ac",
91187 - kmalloc_size(INDEX_AC), ARCH_KMALLOC_FLAGS);
91188 + kmalloc_size(INDEX_AC), SLAB_USERCOPY | ARCH_KMALLOC_FLAGS);
91189
91190 if (INDEX_AC != INDEX_NODE)
91191 kmalloc_caches[INDEX_NODE] =
91192 create_kmalloc_cache("kmalloc-node",
91193 - kmalloc_size(INDEX_NODE), ARCH_KMALLOC_FLAGS);
91194 + kmalloc_size(INDEX_NODE), SLAB_USERCOPY | ARCH_KMALLOC_FLAGS);
91195
91196 slab_early_init = 0;
91197
91198 @@ -3577,6 +3581,21 @@ static inline void __cache_free(struct kmem_cache *cachep, void *objp,
91199 struct array_cache *ac = cpu_cache_get(cachep);
91200
91201 check_irq_off();
91202 +
91203 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
91204 + if (pax_sanitize_slab) {
91205 + if (!(cachep->flags & (SLAB_POISON | SLAB_NO_SANITIZE))) {
91206 + memset(objp, PAX_MEMORY_SANITIZE_VALUE, cachep->object_size);
91207 +
91208 + if (cachep->ctor)
91209 + cachep->ctor(objp);
91210 +
91211 + STATS_INC_SANITIZED(cachep);
91212 + } else
91213 + STATS_INC_NOT_SANITIZED(cachep);
91214 + }
91215 +#endif
91216 +
91217 kmemleak_free_recursive(objp, cachep->flags);
91218 objp = cache_free_debugcheck(cachep, objp, caller);
91219
91220 @@ -3805,6 +3824,7 @@ void kfree(const void *objp)
91221
91222 if (unlikely(ZERO_OR_NULL_PTR(objp)))
91223 return;
91224 + VM_BUG_ON(!virt_addr_valid(objp));
91225 local_irq_save(flags);
91226 kfree_debugcheck(objp);
91227 c = virt_to_cache(objp);
91228 @@ -4246,14 +4266,22 @@ void slabinfo_show_stats(struct seq_file *m, struct kmem_cache *cachep)
91229 }
91230 /* cpu stats */
91231 {
91232 - unsigned long allochit = atomic_read(&cachep->allochit);
91233 - unsigned long allocmiss = atomic_read(&cachep->allocmiss);
91234 - unsigned long freehit = atomic_read(&cachep->freehit);
91235 - unsigned long freemiss = atomic_read(&cachep->freemiss);
91236 + unsigned long allochit = atomic_read_unchecked(&cachep->allochit);
91237 + unsigned long allocmiss = atomic_read_unchecked(&cachep->allocmiss);
91238 + unsigned long freehit = atomic_read_unchecked(&cachep->freehit);
91239 + unsigned long freemiss = atomic_read_unchecked(&cachep->freemiss);
91240
91241 seq_printf(m, " : cpustat %6lu %6lu %6lu %6lu",
91242 allochit, allocmiss, freehit, freemiss);
91243 }
91244 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
91245 + {
91246 + unsigned long sanitized = atomic_read_unchecked(&cachep->sanitized);
91247 + unsigned long not_sanitized = atomic_read_unchecked(&cachep->not_sanitized);
91248 +
91249 + seq_printf(m, " : pax %6lu %6lu", sanitized, not_sanitized);
91250 + }
91251 +#endif
91252 #endif
91253 }
91254
91255 @@ -4471,13 +4499,71 @@ static const struct file_operations proc_slabstats_operations = {
91256 static int __init slab_proc_init(void)
91257 {
91258 #ifdef CONFIG_DEBUG_SLAB_LEAK
91259 - proc_create("slab_allocators", 0, NULL, &proc_slabstats_operations);
91260 + proc_create("slab_allocators", S_IRUSR, NULL, &proc_slabstats_operations);
91261 #endif
91262 return 0;
91263 }
91264 module_init(slab_proc_init);
91265 #endif
91266
91267 +bool is_usercopy_object(const void *ptr)
91268 +{
91269 + struct page *page;
91270 + struct kmem_cache *cachep;
91271 +
91272 + if (ZERO_OR_NULL_PTR(ptr))
91273 + return false;
91274 +
91275 + if (!slab_is_available())
91276 + return false;
91277 +
91278 + if (!virt_addr_valid(ptr))
91279 + return false;
91280 +
91281 + page = virt_to_head_page(ptr);
91282 +
91283 + if (!PageSlab(page))
91284 + return false;
91285 +
91286 + cachep = page->slab_cache;
91287 + return cachep->flags & SLAB_USERCOPY;
91288 +}
91289 +
91290 +#ifdef CONFIG_PAX_USERCOPY
91291 +const char *check_heap_object(const void *ptr, unsigned long n)
91292 +{
91293 + struct page *page;
91294 + struct kmem_cache *cachep;
91295 + struct slab *slabp;
91296 + unsigned int objnr;
91297 + unsigned long offset;
91298 +
91299 + if (ZERO_OR_NULL_PTR(ptr))
91300 + return "<null>";
91301 +
91302 + if (!virt_addr_valid(ptr))
91303 + return NULL;
91304 +
91305 + page = virt_to_head_page(ptr);
91306 +
91307 + if (!PageSlab(page))
91308 + return NULL;
91309 +
91310 + cachep = page->slab_cache;
91311 + if (!(cachep->flags & SLAB_USERCOPY))
91312 + return cachep->name;
91313 +
91314 + slabp = page->slab_page;
91315 + objnr = obj_to_index(cachep, slabp, ptr);
91316 + BUG_ON(objnr >= cachep->num);
91317 + offset = ptr - index_to_obj(cachep, slabp, objnr) - obj_offset(cachep);
91318 + if (offset <= cachep->object_size && n <= cachep->object_size - offset)
91319 + return NULL;
91320 +
91321 + return cachep->name;
91322 +}
91323 +#endif
91324 +
91325 /**
91326 * ksize - get the actual amount of memory allocated for a given object
91327 * @objp: Pointer to the object
91328 diff --git a/mm/slab.h b/mm/slab.h
91329 index a535033..2f98fe5 100644
91330 --- a/mm/slab.h
91331 +++ b/mm/slab.h
91332 @@ -32,6 +32,15 @@ extern struct list_head slab_caches;
91333 /* The slab cache that manages slab cache information */
91334 extern struct kmem_cache *kmem_cache;
91335
91336 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
91337 +#ifdef CONFIG_X86_64
91338 +#define PAX_MEMORY_SANITIZE_VALUE '\xfe'
91339 +#else
91340 +#define PAX_MEMORY_SANITIZE_VALUE '\xff'
91341 +#endif
91342 +extern bool pax_sanitize_slab;
91343 +#endif
91344 +
91345 unsigned long calculate_alignment(unsigned long flags,
91346 unsigned long align, unsigned long size);
91347
91348 @@ -67,7 +76,8 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
91349
91350 /* Legal flag mask for kmem_cache_create(), for various configurations */
91351 #define SLAB_CORE_FLAGS (SLAB_HWCACHE_ALIGN | SLAB_CACHE_DMA | SLAB_PANIC | \
91352 - SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS )
91353 + SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS | \
91354 + SLAB_USERCOPY | SLAB_NO_SANITIZE)
91355
91356 #if defined(CONFIG_DEBUG_SLAB)
91357 #define SLAB_DEBUG_FLAGS (SLAB_RED_ZONE | SLAB_POISON | SLAB_STORE_USER)
91358 @@ -231,6 +241,9 @@ static inline struct kmem_cache *cache_from_obj(struct kmem_cache *s, void *x)
91359 return s;
91360
91361 page = virt_to_head_page(x);
91362 +
91363 + BUG_ON(!PageSlab(page));
91364 +
91365 cachep = page->slab_cache;
91366 if (slab_equal_or_root(cachep, s))
91367 return cachep;
91368 diff --git a/mm/slab_common.c b/mm/slab_common.c
91369 index e2e98af..3b1a163 100644
91370 --- a/mm/slab_common.c
91371 +++ b/mm/slab_common.c
91372 @@ -23,11 +23,22 @@
91373
91374 #include "slab.h"
91375
91376 -enum slab_state slab_state;
91377 +enum slab_state slab_state __read_only;
91378 LIST_HEAD(slab_caches);
91379 DEFINE_MUTEX(slab_mutex);
91380 struct kmem_cache *kmem_cache;
91381
91382 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
91383 +bool pax_sanitize_slab __read_only = true;
91384 +static int __init pax_sanitize_slab_setup(char *str)
91385 +{
91386 + pax_sanitize_slab = !!simple_strtol(str, NULL, 0);
91387 + printk("%sabled PaX slab sanitization\n", pax_sanitize_slab ? "En" : "Dis");
91388 + return 1;
91389 +}
91390 +__setup("pax_sanitize_slab=", pax_sanitize_slab_setup);
91391 +#endif
91392 +
91393 #ifdef CONFIG_DEBUG_VM
91394 static int kmem_cache_sanity_check(struct mem_cgroup *memcg, const char *name,
91395 size_t size)
91396 @@ -212,7 +223,7 @@ kmem_cache_create_memcg(struct mem_cgroup *memcg, const char *name, size_t size,
91397
91398 err = __kmem_cache_create(s, flags);
91399 if (!err) {
91400 - s->refcount = 1;
91401 + atomic_set(&s->refcount, 1);
91402 list_add(&s->list, &slab_caches);
91403 memcg_cache_list_add(memcg, s);
91404 } else {
91405 @@ -258,8 +269,7 @@ void kmem_cache_destroy(struct kmem_cache *s)
91406
91407 get_online_cpus();
91408 mutex_lock(&slab_mutex);
91409 - s->refcount--;
91410 - if (!s->refcount) {
91411 + if (atomic_dec_and_test(&s->refcount)) {
91412 list_del(&s->list);
91413
91414 if (!__kmem_cache_shutdown(s)) {
91415 @@ -305,7 +315,7 @@ void __init create_boot_cache(struct kmem_cache *s, const char *name, size_t siz
91416 panic("Creation of kmalloc slab %s size=%zu failed. Reason %d\n",
91417 name, size, err);
91418
91419 - s->refcount = -1; /* Exempt from merging for now */
91420 + atomic_set(&s->refcount, -1); /* Exempt from merging for now */
91421 }
91422
91423 struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
91424 @@ -318,7 +328,7 @@ struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
91425
91426 create_boot_cache(s, name, size, flags);
91427 list_add(&s->list, &slab_caches);
91428 - s->refcount = 1;
91429 + atomic_set(&s->refcount, 1);
91430 return s;
91431 }
91432
91433 @@ -330,6 +340,11 @@ struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
91434 EXPORT_SYMBOL(kmalloc_dma_caches);
91435 #endif
91436
91437 +#ifdef CONFIG_PAX_USERCOPY_SLABS
91438 +struct kmem_cache *kmalloc_usercopy_caches[KMALLOC_SHIFT_HIGH + 1];
91439 +EXPORT_SYMBOL(kmalloc_usercopy_caches);
91440 +#endif
91441 +
91442 /*
91443 * Conversion table for small slabs sizes / 8 to the index in the
91444 * kmalloc array. This is necessary for slabs < 192 since we have non power
91445 @@ -394,6 +409,13 @@ struct kmem_cache *kmalloc_slab(size_t size, gfp_t flags)
91446 return kmalloc_dma_caches[index];
91447
91448 #endif
91449 +
91450 +#ifdef CONFIG_PAX_USERCOPY_SLABS
91451 + if (unlikely((flags & GFP_USERCOPY)))
91452 + return kmalloc_usercopy_caches[index];
91453 +
91454 +#endif
91455 +
91456 return kmalloc_caches[index];
91457 }
91458
91459 @@ -450,7 +472,7 @@ void __init create_kmalloc_caches(unsigned long flags)
91460 for (i = KMALLOC_SHIFT_LOW; i <= KMALLOC_SHIFT_HIGH; i++) {
91461 if (!kmalloc_caches[i]) {
91462 kmalloc_caches[i] = create_kmalloc_cache(NULL,
91463 - 1 << i, flags);
91464 + 1 << i, SLAB_USERCOPY | flags);
91465 }
91466
91467 /*
91468 @@ -459,10 +481,10 @@ void __init create_kmalloc_caches(unsigned long flags)
91469 * earlier power of two caches
91470 */
91471 if (KMALLOC_MIN_SIZE <= 32 && !kmalloc_caches[1] && i == 6)
91472 - kmalloc_caches[1] = create_kmalloc_cache(NULL, 96, flags);
91473 + kmalloc_caches[1] = create_kmalloc_cache(NULL, 96, SLAB_USERCOPY | flags);
91474
91475 if (KMALLOC_MIN_SIZE <= 64 && !kmalloc_caches[2] && i == 7)
91476 - kmalloc_caches[2] = create_kmalloc_cache(NULL, 192, flags);
91477 + kmalloc_caches[2] = create_kmalloc_cache(NULL, 192, SLAB_USERCOPY | flags);
91478 }
91479
91480 /* Kmalloc array is now usable */
91481 @@ -495,6 +517,23 @@ void __init create_kmalloc_caches(unsigned long flags)
91482 }
91483 }
91484 #endif
91485 +
91486 +#ifdef CONFIG_PAX_USERCOPY_SLABS
91487 + for (i = 0; i <= KMALLOC_SHIFT_HIGH; i++) {
91488 + struct kmem_cache *s = kmalloc_caches[i];
91489 +
91490 + if (s) {
91491 + int size = kmalloc_size(i);
91492 + char *n = kasprintf(GFP_NOWAIT,
91493 + "usercopy-kmalloc-%d", size);
91494 +
91495 + BUG_ON(!n);
91496 + kmalloc_usercopy_caches[i] = create_kmalloc_cache(n,
91497 + size, SLAB_USERCOPY | flags);
91498 + }
91499 + }
91500 +#endif
91501 +
91502 }
91503 #endif /* !CONFIG_SLOB */
91504
91505 @@ -535,6 +574,9 @@ void print_slabinfo_header(struct seq_file *m)
91506 seq_puts(m, " : globalstat <listallocs> <maxobjs> <grown> <reaped> "
91507 "<error> <maxfreeable> <nodeallocs> <remotefrees> <alienoverflow>");
91508 seq_puts(m, " : cpustat <allochit> <allocmiss> <freehit> <freemiss>");
91509 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
91510 + seq_puts(m, " : pax <sanitized> <not_sanitized>");
91511 +#endif
91512 #endif
91513 seq_putc(m, '\n');
91514 }
91515 diff --git a/mm/slob.c b/mm/slob.c
91516 index 4bf8809..98a6914 100644
91517 --- a/mm/slob.c
91518 +++ b/mm/slob.c
91519 @@ -157,7 +157,7 @@ static void set_slob(slob_t *s, slobidx_t size, slob_t *next)
91520 /*
91521 * Return the size of a slob block.
91522 */
91523 -static slobidx_t slob_units(slob_t *s)
91524 +static slobidx_t slob_units(const slob_t *s)
91525 {
91526 if (s->units > 0)
91527 return s->units;
91528 @@ -167,7 +167,7 @@ static slobidx_t slob_units(slob_t *s)
91529 /*
91530 * Return the next free slob block pointer after this one.
91531 */
91532 -static slob_t *slob_next(slob_t *s)
91533 +static slob_t *slob_next(const slob_t *s)
91534 {
91535 slob_t *base = (slob_t *)((unsigned long)s & PAGE_MASK);
91536 slobidx_t next;
91537 @@ -182,14 +182,14 @@ static slob_t *slob_next(slob_t *s)
91538 /*
91539 * Returns true if s is the last free block in its page.
91540 */
91541 -static int slob_last(slob_t *s)
91542 +static int slob_last(const slob_t *s)
91543 {
91544 return !((unsigned long)slob_next(s) & ~PAGE_MASK);
91545 }
91546
91547 -static void *slob_new_pages(gfp_t gfp, int order, int node)
91548 +static struct page *slob_new_pages(gfp_t gfp, unsigned int order, int node)
91549 {
91550 - void *page;
91551 + struct page *page;
91552
91553 #ifdef CONFIG_NUMA
91554 if (node != NUMA_NO_NODE)
91555 @@ -201,14 +201,18 @@ static void *slob_new_pages(gfp_t gfp, int order, int node)
91556 if (!page)
91557 return NULL;
91558
91559 - return page_address(page);
91560 + __SetPageSlab(page);
91561 + return page;
91562 }
91563
91564 -static void slob_free_pages(void *b, int order)
91565 +static void slob_free_pages(struct page *sp, int order)
91566 {
91567 if (current->reclaim_state)
91568 current->reclaim_state->reclaimed_slab += 1 << order;
91569 - free_pages((unsigned long)b, order);
91570 + __ClearPageSlab(sp);
91571 + page_mapcount_reset(sp);
91572 + sp->private = 0;
91573 + __free_pages(sp, order);
91574 }
91575
91576 /*
91577 @@ -313,15 +317,15 @@ static void *slob_alloc(size_t size, gfp_t gfp, int align, int node)
91578
91579 /* Not enough space: must allocate a new page */
91580 if (!b) {
91581 - b = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
91582 - if (!b)
91583 + sp = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
91584 + if (!sp)
91585 return NULL;
91586 - sp = virt_to_page(b);
91587 - __SetPageSlab(sp);
91588 + b = page_address(sp);
91589
91590 spin_lock_irqsave(&slob_lock, flags);
91591 sp->units = SLOB_UNITS(PAGE_SIZE);
91592 sp->freelist = b;
91593 + sp->private = 0;
91594 INIT_LIST_HEAD(&sp->list);
91595 set_slob(b, SLOB_UNITS(PAGE_SIZE), b + SLOB_UNITS(PAGE_SIZE));
91596 set_slob_page_free(sp, slob_list);
91597 @@ -359,12 +363,15 @@ static void slob_free(void *block, int size)
91598 if (slob_page_free(sp))
91599 clear_slob_page_free(sp);
91600 spin_unlock_irqrestore(&slob_lock, flags);
91601 - __ClearPageSlab(sp);
91602 - page_mapcount_reset(sp);
91603 - slob_free_pages(b, 0);
91604 + slob_free_pages(sp, 0);
91605 return;
91606 }
91607
91608 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
91609 + if (pax_sanitize_slab)
91610 + memset(block, PAX_MEMORY_SANITIZE_VALUE, size);
91611 +#endif
91612 +
91613 if (!slob_page_free(sp)) {
91614 /* This slob page is about to become partially free. Easy! */
91615 sp->units = units;
91616 @@ -424,11 +431,10 @@ out:
91617 */
91618
91619 static __always_inline void *
91620 -__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
91621 +__do_kmalloc_node_align(size_t size, gfp_t gfp, int node, unsigned long caller, int align)
91622 {
91623 - unsigned int *m;
91624 - int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
91625 - void *ret;
91626 + slob_t *m;
91627 + void *ret = NULL;
91628
91629 gfp &= gfp_allowed_mask;
91630
91631 @@ -442,23 +448,41 @@ __do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
91632
91633 if (!m)
91634 return NULL;
91635 - *m = size;
91636 + BUILD_BUG_ON(ARCH_KMALLOC_MINALIGN < 2 * SLOB_UNIT);
91637 + BUILD_BUG_ON(ARCH_SLAB_MINALIGN < 2 * SLOB_UNIT);
91638 + m[0].units = size;
91639 + m[1].units = align;
91640 ret = (void *)m + align;
91641
91642 trace_kmalloc_node(caller, ret,
91643 size, size + align, gfp, node);
91644 } else {
91645 unsigned int order = get_order(size);
91646 + struct page *page;
91647
91648 if (likely(order))
91649 gfp |= __GFP_COMP;
91650 - ret = slob_new_pages(gfp, order, node);
91651 + page = slob_new_pages(gfp, order, node);
91652 + if (page) {
91653 + ret = page_address(page);
91654 + page->private = size;
91655 + }
91656
91657 trace_kmalloc_node(caller, ret,
91658 size, PAGE_SIZE << order, gfp, node);
91659 }
91660
91661 - kmemleak_alloc(ret, size, 1, gfp);
91662 + return ret;
91663 +}
91664 +
91665 +static __always_inline void *
91666 +__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
91667 +{
91668 + int align = max(ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
91669 + void *ret = __do_kmalloc_node_align(size, gfp, node, caller, align);
91670 +
91671 + if (!ZERO_OR_NULL_PTR(ret))
91672 + kmemleak_alloc(ret, size, 1, gfp);
91673 return ret;
91674 }
91675
91676 @@ -493,34 +517,112 @@ void kfree(const void *block)
91677 return;
91678 kmemleak_free(block);
91679
91680 + VM_BUG_ON(!virt_addr_valid(block));
91681 sp = virt_to_page(block);
91682 - if (PageSlab(sp)) {
91683 + VM_BUG_ON(!PageSlab(sp));
91684 + if (!sp->private) {
91685 int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
91686 - unsigned int *m = (unsigned int *)(block - align);
91687 - slob_free(m, *m + align);
91688 - } else
91689 + slob_t *m = (slob_t *)(block - align);
91690 + slob_free(m, m[0].units + align);
91691 + } else {
91692 + __ClearPageSlab(sp);
91693 + page_mapcount_reset(sp);
91694 + sp->private = 0;
91695 __free_pages(sp, compound_order(sp));
91696 + }
91697 }
91698 EXPORT_SYMBOL(kfree);
91699
91700 +bool is_usercopy_object(const void *ptr)
91701 +{
91702 + if (!slab_is_available())
91703 + return false;
91704 +
91705 + // PAX: TODO
91706 +
91707 + return false;
91708 +}
91709 +
91710 +#ifdef CONFIG_PAX_USERCOPY
91711 +const char *check_heap_object(const void *ptr, unsigned long n)
91712 +{
91713 + struct page *page;
91714 + const slob_t *free;
91715 + const void *base;
91716 + unsigned long flags;
91717 +
91718 + if (ZERO_OR_NULL_PTR(ptr))
91719 + return "<null>";
91720 +
91721 + if (!virt_addr_valid(ptr))
91722 + return NULL;
91723 +
91724 + page = virt_to_head_page(ptr);
91725 + if (!PageSlab(page))
91726 + return NULL;
91727 +
91728 + if (page->private) {
91729 + base = page;
91730 + if (base <= ptr && n <= page->private - (ptr - base))
91731 + return NULL;
91732 + return "<slob>";
91733 + }
91734 +
91735 + /* some tricky double walking to find the chunk */
91736 + spin_lock_irqsave(&slob_lock, flags);
91737 + base = (void *)((unsigned long)ptr & PAGE_MASK);
91738 + free = page->freelist;
91739 +
91740 + while (!slob_last(free) && (void *)free <= ptr) {
91741 + base = free + slob_units(free);
91742 + free = slob_next(free);
91743 + }
91744 +
91745 + while (base < (void *)free) {
91746 + slobidx_t m = ((slob_t *)base)[0].units, align = ((slob_t *)base)[1].units;
91747 + int size = SLOB_UNIT * SLOB_UNITS(m + align);
91748 + int offset;
91749 +
91750 + if (ptr < base + align)
91751 + break;
91752 +
91753 + offset = ptr - base - align;
91754 + if (offset >= m) {
91755 + base += size;
91756 + continue;
91757 + }
91758 +
91759 + if (n > m - offset)
91760 + break;
91761 +
91762 + spin_unlock_irqrestore(&slob_lock, flags);
91763 + return NULL;
91764 + }
91765 +
91766 + spin_unlock_irqrestore(&slob_lock, flags);
91767 + return "<slob>";
91768 +}
91769 +#endif
91770 +
91771 /* can't use ksize for kmem_cache_alloc memory, only kmalloc */
91772 size_t ksize(const void *block)
91773 {
91774 struct page *sp;
91775 int align;
91776 - unsigned int *m;
91777 + slob_t *m;
91778
91779 BUG_ON(!block);
91780 if (unlikely(block == ZERO_SIZE_PTR))
91781 return 0;
91782
91783 sp = virt_to_page(block);
91784 - if (unlikely(!PageSlab(sp)))
91785 - return PAGE_SIZE << compound_order(sp);
91786 + VM_BUG_ON(!PageSlab(sp));
91787 + if (sp->private)
91788 + return sp->private;
91789
91790 align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
91791 - m = (unsigned int *)(block - align);
91792 - return SLOB_UNITS(*m) * SLOB_UNIT;
91793 + m = (slob_t *)(block - align);
91794 + return SLOB_UNITS(m[0].units) * SLOB_UNIT;
91795 }
91796 EXPORT_SYMBOL(ksize);
91797
91798 @@ -536,23 +638,33 @@ int __kmem_cache_create(struct kmem_cache *c, unsigned long flags)
91799
91800 void *slob_alloc_node(struct kmem_cache *c, gfp_t flags, int node)
91801 {
91802 - void *b;
91803 + void *b = NULL;
91804
91805 flags &= gfp_allowed_mask;
91806
91807 lockdep_trace_alloc(flags);
91808
91809 +#ifdef CONFIG_PAX_USERCOPY_SLABS
91810 + b = __do_kmalloc_node_align(c->size, flags, node, _RET_IP_, c->align);
91811 +#else
91812 if (c->size < PAGE_SIZE) {
91813 b = slob_alloc(c->size, flags, c->align, node);
91814 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
91815 SLOB_UNITS(c->size) * SLOB_UNIT,
91816 flags, node);
91817 } else {
91818 - b = slob_new_pages(flags, get_order(c->size), node);
91819 + struct page *sp;
91820 +
91821 + sp = slob_new_pages(flags, get_order(c->size), node);
91822 + if (sp) {
91823 + b = page_address(sp);
91824 + sp->private = c->size;
91825 + }
91826 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
91827 PAGE_SIZE << get_order(c->size),
91828 flags, node);
91829 }
91830 +#endif
91831
91832 if (b && c->ctor)
91833 c->ctor(b);
91834 @@ -584,10 +696,14 @@ EXPORT_SYMBOL(kmem_cache_alloc_node);
91835
91836 static void __kmem_cache_free(void *b, int size)
91837 {
91838 - if (size < PAGE_SIZE)
91839 + struct page *sp;
91840 +
91841 + sp = virt_to_page(b);
91842 + BUG_ON(!PageSlab(sp));
91843 + if (!sp->private)
91844 slob_free(b, size);
91845 else
91846 - slob_free_pages(b, get_order(size));
91847 + slob_free_pages(sp, get_order(size));
91848 }
91849
91850 static void kmem_rcu_free(struct rcu_head *head)
91851 @@ -600,17 +716,31 @@ static void kmem_rcu_free(struct rcu_head *head)
91852
91853 void kmem_cache_free(struct kmem_cache *c, void *b)
91854 {
91855 + int size = c->size;
91856 +
91857 +#ifdef CONFIG_PAX_USERCOPY_SLABS
91858 + if (size + c->align < PAGE_SIZE) {
91859 + size += c->align;
91860 + b -= c->align;
91861 + }
91862 +#endif
91863 +
91864 kmemleak_free_recursive(b, c->flags);
91865 if (unlikely(c->flags & SLAB_DESTROY_BY_RCU)) {
91866 struct slob_rcu *slob_rcu;
91867 - slob_rcu = b + (c->size - sizeof(struct slob_rcu));
91868 - slob_rcu->size = c->size;
91869 + slob_rcu = b + (size - sizeof(struct slob_rcu));
91870 + slob_rcu->size = size;
91871 call_rcu(&slob_rcu->head, kmem_rcu_free);
91872 } else {
91873 - __kmem_cache_free(b, c->size);
91874 + __kmem_cache_free(b, size);
91875 }
91876
91877 +#ifdef CONFIG_PAX_USERCOPY_SLABS
91878 + trace_kfree(_RET_IP_, b);
91879 +#else
91880 trace_kmem_cache_free(_RET_IP_, b);
91881 +#endif
91882 +
91883 }
91884 EXPORT_SYMBOL(kmem_cache_free);
91885
91886 diff --git a/mm/slub.c b/mm/slub.c
91887 index 96f2169..9111a59 100644
91888 --- a/mm/slub.c
91889 +++ b/mm/slub.c
91890 @@ -207,7 +207,7 @@ struct track {
91891
91892 enum track_item { TRACK_ALLOC, TRACK_FREE };
91893
91894 -#ifdef CONFIG_SYSFS
91895 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
91896 static int sysfs_slab_add(struct kmem_cache *);
91897 static int sysfs_slab_alias(struct kmem_cache *, const char *);
91898 static void sysfs_slab_remove(struct kmem_cache *);
91899 @@ -530,7 +530,7 @@ static void print_track(const char *s, struct track *t)
91900 if (!t->addr)
91901 return;
91902
91903 - printk(KERN_ERR "INFO: %s in %pS age=%lu cpu=%u pid=%d\n",
91904 + printk(KERN_ERR "INFO: %s in %pA age=%lu cpu=%u pid=%d\n",
91905 s, (void *)t->addr, jiffies - t->when, t->cpu, t->pid);
91906 #ifdef CONFIG_STACKTRACE
91907 {
91908 @@ -2616,6 +2616,14 @@ static __always_inline void slab_free(struct kmem_cache *s,
91909
91910 slab_free_hook(s, x);
91911
91912 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
91913 + if (pax_sanitize_slab && !(s->flags & SLAB_NO_SANITIZE)) {
91914 + memset(x, PAX_MEMORY_SANITIZE_VALUE, s->object_size);
91915 + if (s->ctor)
91916 + s->ctor(x);
91917 + }
91918 +#endif
91919 +
91920 redo:
91921 /*
91922 * Determine the currently cpus per cpu slab.
91923 @@ -2683,7 +2691,7 @@ static int slub_min_objects;
91924 * Merge control. If this is set then no merging of slab caches will occur.
91925 * (Could be removed. This was introduced to pacify the merge skeptics.)
91926 */
91927 -static int slub_nomerge;
91928 +static int slub_nomerge = 1;
91929
91930 /*
91931 * Calculate the order of allocation given an slab object size.
91932 @@ -2960,6 +2968,9 @@ static int calculate_sizes(struct kmem_cache *s, int forced_order)
91933 s->inuse = size;
91934
91935 if (((flags & (SLAB_DESTROY_BY_RCU | SLAB_POISON)) ||
91936 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
91937 + (pax_sanitize_slab && !(flags & SLAB_NO_SANITIZE)) ||
91938 +#endif
91939 s->ctor)) {
91940 /*
91941 * Relocate free pointer after the object if it is not
91942 @@ -3305,6 +3316,59 @@ void *__kmalloc_node(size_t size, gfp_t flags, int node)
91943 EXPORT_SYMBOL(__kmalloc_node);
91944 #endif
91945
91946 +bool is_usercopy_object(const void *ptr)
91947 +{
91948 + struct page *page;
91949 + struct kmem_cache *s;
91950 +
91951 + if (ZERO_OR_NULL_PTR(ptr))
91952 + return false;
91953 +
91954 + if (!slab_is_available())
91955 + return false;
91956 +
91957 + if (!virt_addr_valid(ptr))
91958 + return false;
91959 +
91960 + page = virt_to_head_page(ptr);
91961 +
91962 + if (!PageSlab(page))
91963 + return false;
91964 +
91965 + s = page->slab_cache;
91966 + return s->flags & SLAB_USERCOPY;
91967 +}
91968 +
91969 +#ifdef CONFIG_PAX_USERCOPY
91970 +const char *check_heap_object(const void *ptr, unsigned long n)
91971 +{
91972 + struct page *page;
91973 + struct kmem_cache *s;
91974 + unsigned long offset;
91975 +
91976 + if (ZERO_OR_NULL_PTR(ptr))
91977 + return "<null>";
91978 +
91979 + if (!virt_addr_valid(ptr))
91980 + return NULL;
91981 +
91982 + page = virt_to_head_page(ptr);
91983 +
91984 + if (!PageSlab(page))
91985 + return NULL;
91986 +
91987 + s = page->slab_cache;
91988 + if (!(s->flags & SLAB_USERCOPY))
91989 + return s->name;
91990 +
91991 + offset = (ptr - page_address(page)) % s->size;
91992 + if (offset <= s->object_size && n <= s->object_size - offset)
91993 + return NULL;
91994 +
91995 + return s->name;
91996 +}
91997 +#endif
91998 +
91999 size_t ksize(const void *object)
92000 {
92001 struct page *page;
92002 @@ -3333,6 +3397,7 @@ void kfree(const void *x)
92003 if (unlikely(ZERO_OR_NULL_PTR(x)))
92004 return;
92005
92006 + VM_BUG_ON(!virt_addr_valid(x));
92007 page = virt_to_head_page(x);
92008 if (unlikely(!PageSlab(page))) {
92009 BUG_ON(!PageCompound(page));
92010 @@ -3638,7 +3703,7 @@ static int slab_unmergeable(struct kmem_cache *s)
92011 /*
92012 * We may have set a slab to be unmergeable during bootstrap.
92013 */
92014 - if (s->refcount < 0)
92015 + if (atomic_read(&s->refcount) < 0)
92016 return 1;
92017
92018 return 0;
92019 @@ -3696,7 +3761,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
92020
92021 s = find_mergeable(memcg, size, align, flags, name, ctor);
92022 if (s) {
92023 - s->refcount++;
92024 + atomic_inc(&s->refcount);
92025 /*
92026 * Adjust the object sizes so that we clear
92027 * the complete object on kzalloc.
92028 @@ -3705,7 +3770,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
92029 s->inuse = max_t(int, s->inuse, ALIGN(size, sizeof(void *)));
92030
92031 if (sysfs_slab_alias(s, name)) {
92032 - s->refcount--;
92033 + atomic_dec(&s->refcount);
92034 s = NULL;
92035 }
92036 }
92037 @@ -3825,7 +3890,7 @@ void *__kmalloc_node_track_caller(size_t size, gfp_t gfpflags,
92038 }
92039 #endif
92040
92041 -#ifdef CONFIG_SYSFS
92042 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
92043 static int count_inuse(struct page *page)
92044 {
92045 return page->inuse;
92046 @@ -4214,12 +4279,12 @@ static void resiliency_test(void)
92047 validate_slab_cache(kmalloc_caches[9]);
92048 }
92049 #else
92050 -#ifdef CONFIG_SYSFS
92051 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
92052 static void resiliency_test(void) {};
92053 #endif
92054 #endif
92055
92056 -#ifdef CONFIG_SYSFS
92057 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
92058 enum slab_stat_type {
92059 SL_ALL, /* All slabs */
92060 SL_PARTIAL, /* Only partially allocated slabs */
92061 @@ -4459,7 +4524,7 @@ SLAB_ATTR_RO(ctor);
92062
92063 static ssize_t aliases_show(struct kmem_cache *s, char *buf)
92064 {
92065 - return sprintf(buf, "%d\n", s->refcount - 1);
92066 + return sprintf(buf, "%d\n", atomic_read(&s->refcount) - 1);
92067 }
92068 SLAB_ATTR_RO(aliases);
92069
92070 @@ -4547,6 +4612,14 @@ static ssize_t cache_dma_show(struct kmem_cache *s, char *buf)
92071 SLAB_ATTR_RO(cache_dma);
92072 #endif
92073
92074 +#ifdef CONFIG_PAX_USERCOPY_SLABS
92075 +static ssize_t usercopy_show(struct kmem_cache *s, char *buf)
92076 +{
92077 + return sprintf(buf, "%d\n", !!(s->flags & SLAB_USERCOPY));
92078 +}
92079 +SLAB_ATTR_RO(usercopy);
92080 +#endif
92081 +
92082 static ssize_t destroy_by_rcu_show(struct kmem_cache *s, char *buf)
92083 {
92084 return sprintf(buf, "%d\n", !!(s->flags & SLAB_DESTROY_BY_RCU));
92085 @@ -4881,6 +4954,9 @@ static struct attribute *slab_attrs[] = {
92086 #ifdef CONFIG_ZONE_DMA
92087 &cache_dma_attr.attr,
92088 #endif
92089 +#ifdef CONFIG_PAX_USERCOPY_SLABS
92090 + &usercopy_attr.attr,
92091 +#endif
92092 #ifdef CONFIG_NUMA
92093 &remote_node_defrag_ratio_attr.attr,
92094 #endif
92095 @@ -5113,6 +5189,7 @@ static char *create_unique_id(struct kmem_cache *s)
92096 return name;
92097 }
92098
92099 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
92100 static int sysfs_slab_add(struct kmem_cache *s)
92101 {
92102 int err;
92103 @@ -5136,7 +5213,7 @@ static int sysfs_slab_add(struct kmem_cache *s)
92104 }
92105
92106 s->kobj.kset = slab_kset;
92107 - err = kobject_init_and_add(&s->kobj, &slab_ktype, NULL, name);
92108 + err = kobject_init_and_add(&s->kobj, &slab_ktype, NULL, "%s", name);
92109 if (err) {
92110 kobject_put(&s->kobj);
92111 return err;
92112 @@ -5170,6 +5247,7 @@ static void sysfs_slab_remove(struct kmem_cache *s)
92113 kobject_del(&s->kobj);
92114 kobject_put(&s->kobj);
92115 }
92116 +#endif
92117
92118 /*
92119 * Need to buffer aliases during bootup until sysfs becomes
92120 @@ -5183,6 +5261,7 @@ struct saved_alias {
92121
92122 static struct saved_alias *alias_list;
92123
92124 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
92125 static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
92126 {
92127 struct saved_alias *al;
92128 @@ -5205,6 +5284,7 @@ static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
92129 alias_list = al;
92130 return 0;
92131 }
92132 +#endif
92133
92134 static int __init slab_sysfs_init(void)
92135 {
92136 diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c
92137 index 27eeab3..7c3f7f2 100644
92138 --- a/mm/sparse-vmemmap.c
92139 +++ b/mm/sparse-vmemmap.c
92140 @@ -130,7 +130,7 @@ pud_t * __meminit vmemmap_pud_populate(pgd_t *pgd, unsigned long addr, int node)
92141 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
92142 if (!p)
92143 return NULL;
92144 - pud_populate(&init_mm, pud, p);
92145 + pud_populate_kernel(&init_mm, pud, p);
92146 }
92147 return pud;
92148 }
92149 @@ -142,7 +142,7 @@ pgd_t * __meminit vmemmap_pgd_populate(unsigned long addr, int node)
92150 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
92151 if (!p)
92152 return NULL;
92153 - pgd_populate(&init_mm, pgd, p);
92154 + pgd_populate_kernel(&init_mm, pgd, p);
92155 }
92156 return pgd;
92157 }
92158 diff --git a/mm/sparse.c b/mm/sparse.c
92159 index 4ac1d7e..bbfcb1f 100644
92160 --- a/mm/sparse.c
92161 +++ b/mm/sparse.c
92162 @@ -745,7 +745,7 @@ static void clear_hwpoisoned_pages(struct page *memmap, int nr_pages)
92163
92164 for (i = 0; i < PAGES_PER_SECTION; i++) {
92165 if (PageHWPoison(&memmap[i])) {
92166 - atomic_long_sub(1, &num_poisoned_pages);
92167 + atomic_long_sub_unchecked(1, &num_poisoned_pages);
92168 ClearPageHWPoison(&memmap[i]);
92169 }
92170 }
92171 diff --git a/mm/swap.c b/mm/swap.c
92172 index 759c3ca..7c1a5b4 100644
92173 --- a/mm/swap.c
92174 +++ b/mm/swap.c
92175 @@ -77,6 +77,8 @@ static void __put_compound_page(struct page *page)
92176
92177 __page_cache_release(page);
92178 dtor = get_compound_page_dtor(page);
92179 + if (!PageHuge(page))
92180 + BUG_ON(dtor != free_compound_page);
92181 (*dtor)(page);
92182 }
92183
92184 diff --git a/mm/swapfile.c b/mm/swapfile.c
92185 index de7c904..c84bf11 100644
92186 --- a/mm/swapfile.c
92187 +++ b/mm/swapfile.c
92188 @@ -66,7 +66,7 @@ static DEFINE_MUTEX(swapon_mutex);
92189
92190 static DECLARE_WAIT_QUEUE_HEAD(proc_poll_wait);
92191 /* Activity counter to indicate that a swapon or swapoff has occurred */
92192 -static atomic_t proc_poll_event = ATOMIC_INIT(0);
92193 +static atomic_unchecked_t proc_poll_event = ATOMIC_INIT(0);
92194
92195 static inline unsigned char swap_count(unsigned char ent)
92196 {
92197 @@ -1949,7 +1949,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
92198 }
92199 filp_close(swap_file, NULL);
92200 err = 0;
92201 - atomic_inc(&proc_poll_event);
92202 + atomic_inc_unchecked(&proc_poll_event);
92203 wake_up_interruptible(&proc_poll_wait);
92204
92205 out_dput:
92206 @@ -1966,8 +1966,8 @@ static unsigned swaps_poll(struct file *file, poll_table *wait)
92207
92208 poll_wait(file, &proc_poll_wait, wait);
92209
92210 - if (seq->poll_event != atomic_read(&proc_poll_event)) {
92211 - seq->poll_event = atomic_read(&proc_poll_event);
92212 + if (seq->poll_event != atomic_read_unchecked(&proc_poll_event)) {
92213 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
92214 return POLLIN | POLLRDNORM | POLLERR | POLLPRI;
92215 }
92216
92217 @@ -2065,7 +2065,7 @@ static int swaps_open(struct inode *inode, struct file *file)
92218 return ret;
92219
92220 seq = file->private_data;
92221 - seq->poll_event = atomic_read(&proc_poll_event);
92222 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
92223 return 0;
92224 }
92225
92226 @@ -2524,7 +2524,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
92227 (frontswap_map) ? "FS" : "");
92228
92229 mutex_unlock(&swapon_mutex);
92230 - atomic_inc(&proc_poll_event);
92231 + atomic_inc_unchecked(&proc_poll_event);
92232 wake_up_interruptible(&proc_poll_wait);
92233
92234 if (S_ISREG(inode->i_mode))
92235 diff --git a/mm/util.c b/mm/util.c
92236 index eaf63fc2..32b2629 100644
92237 --- a/mm/util.c
92238 +++ b/mm/util.c
92239 @@ -294,6 +294,12 @@ done:
92240 void arch_pick_mmap_layout(struct mm_struct *mm)
92241 {
92242 mm->mmap_base = TASK_UNMAPPED_BASE;
92243 +
92244 +#ifdef CONFIG_PAX_RANDMMAP
92245 + if (mm->pax_flags & MF_PAX_RANDMMAP)
92246 + mm->mmap_base += mm->delta_mmap;
92247 +#endif
92248 +
92249 mm->get_unmapped_area = arch_get_unmapped_area;
92250 }
92251 #endif
92252 diff --git a/mm/vmalloc.c b/mm/vmalloc.c
92253 index 1074543..136dbe0 100644
92254 --- a/mm/vmalloc.c
92255 +++ b/mm/vmalloc.c
92256 @@ -59,8 +59,19 @@ static void vunmap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end)
92257
92258 pte = pte_offset_kernel(pmd, addr);
92259 do {
92260 - pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
92261 - WARN_ON(!pte_none(ptent) && !pte_present(ptent));
92262 +
92263 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
92264 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr < (unsigned long)MODULES_EXEC_END) {
92265 + BUG_ON(!pte_exec(*pte));
92266 + set_pte_at(&init_mm, addr, pte, pfn_pte(__pa(addr) >> PAGE_SHIFT, PAGE_KERNEL_EXEC));
92267 + continue;
92268 + }
92269 +#endif
92270 +
92271 + {
92272 + pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
92273 + WARN_ON(!pte_none(ptent) && !pte_present(ptent));
92274 + }
92275 } while (pte++, addr += PAGE_SIZE, addr != end);
92276 }
92277
92278 @@ -120,16 +131,29 @@ static int vmap_pte_range(pmd_t *pmd, unsigned long addr,
92279 pte = pte_alloc_kernel(pmd, addr);
92280 if (!pte)
92281 return -ENOMEM;
92282 +
92283 + pax_open_kernel();
92284 do {
92285 struct page *page = pages[*nr];
92286
92287 - if (WARN_ON(!pte_none(*pte)))
92288 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
92289 + if (pgprot_val(prot) & _PAGE_NX)
92290 +#endif
92291 +
92292 + if (!pte_none(*pte)) {
92293 + pax_close_kernel();
92294 + WARN_ON(1);
92295 return -EBUSY;
92296 - if (WARN_ON(!page))
92297 + }
92298 + if (!page) {
92299 + pax_close_kernel();
92300 + WARN_ON(1);
92301 return -ENOMEM;
92302 + }
92303 set_pte_at(&init_mm, addr, pte, mk_pte(page, prot));
92304 (*nr)++;
92305 } while (pte++, addr += PAGE_SIZE, addr != end);
92306 + pax_close_kernel();
92307 return 0;
92308 }
92309
92310 @@ -139,7 +163,7 @@ static int vmap_pmd_range(pud_t *pud, unsigned long addr,
92311 pmd_t *pmd;
92312 unsigned long next;
92313
92314 - pmd = pmd_alloc(&init_mm, pud, addr);
92315 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
92316 if (!pmd)
92317 return -ENOMEM;
92318 do {
92319 @@ -156,7 +180,7 @@ static int vmap_pud_range(pgd_t *pgd, unsigned long addr,
92320 pud_t *pud;
92321 unsigned long next;
92322
92323 - pud = pud_alloc(&init_mm, pgd, addr);
92324 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
92325 if (!pud)
92326 return -ENOMEM;
92327 do {
92328 @@ -216,6 +240,12 @@ int is_vmalloc_or_module_addr(const void *x)
92329 if (addr >= MODULES_VADDR && addr < MODULES_END)
92330 return 1;
92331 #endif
92332 +
92333 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
92334 + if (x >= (const void *)MODULES_EXEC_VADDR && x < (const void *)MODULES_EXEC_END)
92335 + return 1;
92336 +#endif
92337 +
92338 return is_vmalloc_addr(x);
92339 }
92340
92341 @@ -236,8 +266,14 @@ struct page *vmalloc_to_page(const void *vmalloc_addr)
92342
92343 if (!pgd_none(*pgd)) {
92344 pud_t *pud = pud_offset(pgd, addr);
92345 +#ifdef CONFIG_X86
92346 + if (!pud_large(*pud))
92347 +#endif
92348 if (!pud_none(*pud)) {
92349 pmd_t *pmd = pmd_offset(pud, addr);
92350 +#ifdef CONFIG_X86
92351 + if (!pmd_large(*pmd))
92352 +#endif
92353 if (!pmd_none(*pmd)) {
92354 pte_t *ptep, pte;
92355
92356 @@ -1303,6 +1339,16 @@ static struct vm_struct *__get_vm_area_node(unsigned long size,
92357 struct vm_struct *area;
92358
92359 BUG_ON(in_interrupt());
92360 +
92361 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
92362 + if (flags & VM_KERNEXEC) {
92363 + if (start != VMALLOC_START || end != VMALLOC_END)
92364 + return NULL;
92365 + start = (unsigned long)MODULES_EXEC_VADDR;
92366 + end = (unsigned long)MODULES_EXEC_END;
92367 + }
92368 +#endif
92369 +
92370 if (flags & VM_IOREMAP)
92371 align = 1ul << clamp(fls(size), PAGE_SHIFT, IOREMAP_MAX_ORDER);
92372
92373 @@ -1528,6 +1574,11 @@ void *vmap(struct page **pages, unsigned int count,
92374 if (count > totalram_pages)
92375 return NULL;
92376
92377 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
92378 + if (!(pgprot_val(prot) & _PAGE_NX))
92379 + flags |= VM_KERNEXEC;
92380 +#endif
92381 +
92382 area = get_vm_area_caller((count << PAGE_SHIFT), flags,
92383 __builtin_return_address(0));
92384 if (!area)
92385 @@ -1629,6 +1680,13 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align,
92386 if (!size || (size >> PAGE_SHIFT) > totalram_pages)
92387 goto fail;
92388
92389 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
92390 + if (!(pgprot_val(prot) & _PAGE_NX))
92391 + area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNINITIALIZED | VM_KERNEXEC,
92392 + VMALLOC_START, VMALLOC_END, node, gfp_mask, caller);
92393 + else
92394 +#endif
92395 +
92396 area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNINITIALIZED,
92397 start, end, node, gfp_mask, caller);
92398 if (!area)
92399 @@ -1805,10 +1863,9 @@ EXPORT_SYMBOL(vzalloc_node);
92400 * For tight control over page level allocator and protection flags
92401 * use __vmalloc() instead.
92402 */
92403 -
92404 void *vmalloc_exec(unsigned long size)
92405 {
92406 - return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
92407 + return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, PAGE_KERNEL_EXEC,
92408 NUMA_NO_NODE, __builtin_return_address(0));
92409 }
92410
92411 @@ -2115,6 +2172,8 @@ int remap_vmalloc_range_partial(struct vm_area_struct *vma, unsigned long uaddr,
92412 {
92413 struct vm_struct *area;
92414
92415 + BUG_ON(vma->vm_mirror);
92416 +
92417 size = PAGE_ALIGN(size);
92418
92419 if (!PAGE_ALIGNED(uaddr) || !PAGE_ALIGNED(kaddr))
92420 @@ -2600,7 +2659,11 @@ static int s_show(struct seq_file *m, void *p)
92421 v->addr, v->addr + v->size, v->size);
92422
92423 if (v->caller)
92424 +#ifdef CONFIG_GRKERNSEC_HIDESYM
92425 + seq_printf(m, " %pK", v->caller);
92426 +#else
92427 seq_printf(m, " %pS", v->caller);
92428 +#endif
92429
92430 if (v->nr_pages)
92431 seq_printf(m, " pages=%d", v->nr_pages);
92432 diff --git a/mm/vmstat.c b/mm/vmstat.c
92433 index 5a442a7..5eb281e 100644
92434 --- a/mm/vmstat.c
92435 +++ b/mm/vmstat.c
92436 @@ -79,7 +79,7 @@ void vm_events_fold_cpu(int cpu)
92437 *
92438 * vm_stat contains the global counters
92439 */
92440 -atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
92441 +atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
92442 EXPORT_SYMBOL(vm_stat);
92443
92444 #ifdef CONFIG_SMP
92445 @@ -423,7 +423,7 @@ static inline void fold_diff(int *diff)
92446
92447 for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++)
92448 if (diff[i])
92449 - atomic_long_add(diff[i], &vm_stat[i]);
92450 + atomic_long_add_unchecked(diff[i], &vm_stat[i]);
92451 }
92452
92453 /*
92454 @@ -455,7 +455,7 @@ static void refresh_cpu_vm_stats(void)
92455 v = this_cpu_xchg(p->vm_stat_diff[i], 0);
92456 if (v) {
92457
92458 - atomic_long_add(v, &zone->vm_stat[i]);
92459 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
92460 global_diff[i] += v;
92461 #ifdef CONFIG_NUMA
92462 /* 3 seconds idle till flush */
92463 @@ -517,7 +517,7 @@ void cpu_vm_stats_fold(int cpu)
92464
92465 v = p->vm_stat_diff[i];
92466 p->vm_stat_diff[i] = 0;
92467 - atomic_long_add(v, &zone->vm_stat[i]);
92468 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
92469 global_diff[i] += v;
92470 }
92471 }
92472 @@ -537,8 +537,8 @@ void drain_zonestat(struct zone *zone, struct per_cpu_pageset *pset)
92473 if (pset->vm_stat_diff[i]) {
92474 int v = pset->vm_stat_diff[i];
92475 pset->vm_stat_diff[i] = 0;
92476 - atomic_long_add(v, &zone->vm_stat[i]);
92477 - atomic_long_add(v, &vm_stat[i]);
92478 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
92479 + atomic_long_add_unchecked(v, &vm_stat[i]);
92480 }
92481 }
92482 #endif
92483 @@ -1281,10 +1281,20 @@ static int __init setup_vmstat(void)
92484 start_cpu_timer(cpu);
92485 #endif
92486 #ifdef CONFIG_PROC_FS
92487 - proc_create("buddyinfo", S_IRUGO, NULL, &fragmentation_file_operations);
92488 - proc_create("pagetypeinfo", S_IRUGO, NULL, &pagetypeinfo_file_ops);
92489 - proc_create("vmstat", S_IRUGO, NULL, &proc_vmstat_file_operations);
92490 - proc_create("zoneinfo", S_IRUGO, NULL, &proc_zoneinfo_file_operations);
92491 + {
92492 + mode_t gr_mode = S_IRUGO;
92493 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
92494 + gr_mode = S_IRUSR;
92495 +#endif
92496 + proc_create("buddyinfo", gr_mode, NULL, &fragmentation_file_operations);
92497 + proc_create("pagetypeinfo", gr_mode, NULL, &pagetypeinfo_file_ops);
92498 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
92499 + proc_create("vmstat", gr_mode | S_IRGRP, NULL, &proc_vmstat_file_operations);
92500 +#else
92501 + proc_create("vmstat", gr_mode, NULL, &proc_vmstat_file_operations);
92502 +#endif
92503 + proc_create("zoneinfo", gr_mode, NULL, &proc_zoneinfo_file_operations);
92504 + }
92505 #endif
92506 return 0;
92507 }
92508 diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
92509 index 61fc573..b5e47d0 100644
92510 --- a/net/8021q/vlan.c
92511 +++ b/net/8021q/vlan.c
92512 @@ -472,7 +472,7 @@ out:
92513 return NOTIFY_DONE;
92514 }
92515
92516 -static struct notifier_block vlan_notifier_block __read_mostly = {
92517 +static struct notifier_block vlan_notifier_block = {
92518 .notifier_call = vlan_device_event,
92519 };
92520
92521 @@ -547,8 +547,7 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg)
92522 err = -EPERM;
92523 if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
92524 break;
92525 - if ((args.u.name_type >= 0) &&
92526 - (args.u.name_type < VLAN_NAME_TYPE_HIGHEST)) {
92527 + if (args.u.name_type < VLAN_NAME_TYPE_HIGHEST) {
92528 struct vlan_net *vn;
92529
92530 vn = net_generic(net, vlan_net_id);
92531 diff --git a/net/9p/mod.c b/net/9p/mod.c
92532 index 6ab36ae..6f1841b 100644
92533 --- a/net/9p/mod.c
92534 +++ b/net/9p/mod.c
92535 @@ -84,7 +84,7 @@ static LIST_HEAD(v9fs_trans_list);
92536 void v9fs_register_trans(struct p9_trans_module *m)
92537 {
92538 spin_lock(&v9fs_trans_lock);
92539 - list_add_tail(&m->list, &v9fs_trans_list);
92540 + pax_list_add_tail((struct list_head *)&m->list, &v9fs_trans_list);
92541 spin_unlock(&v9fs_trans_lock);
92542 }
92543 EXPORT_SYMBOL(v9fs_register_trans);
92544 @@ -97,7 +97,7 @@ EXPORT_SYMBOL(v9fs_register_trans);
92545 void v9fs_unregister_trans(struct p9_trans_module *m)
92546 {
92547 spin_lock(&v9fs_trans_lock);
92548 - list_del_init(&m->list);
92549 + pax_list_del_init((struct list_head *)&m->list);
92550 spin_unlock(&v9fs_trans_lock);
92551 }
92552 EXPORT_SYMBOL(v9fs_unregister_trans);
92553 diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c
92554 index 3ffda1b..fceac96 100644
92555 --- a/net/9p/trans_fd.c
92556 +++ b/net/9p/trans_fd.c
92557 @@ -432,7 +432,7 @@ static int p9_fd_write(struct p9_client *client, void *v, int len)
92558 oldfs = get_fs();
92559 set_fs(get_ds());
92560 /* The cast to a user pointer is valid due to the set_fs() */
92561 - ret = vfs_write(ts->wr, (__force void __user *)v, len, &ts->wr->f_pos);
92562 + ret = vfs_write(ts->wr, (void __force_user *)v, len, &ts->wr->f_pos);
92563 set_fs(oldfs);
92564
92565 if (ret <= 0 && ret != -ERESTARTSYS && ret != -EAGAIN)
92566 diff --git a/net/atm/atm_misc.c b/net/atm/atm_misc.c
92567 index 876fbe8..8bbea9f 100644
92568 --- a/net/atm/atm_misc.c
92569 +++ b/net/atm/atm_misc.c
92570 @@ -17,7 +17,7 @@ int atm_charge(struct atm_vcc *vcc, int truesize)
92571 if (atomic_read(&sk_atm(vcc)->sk_rmem_alloc) <= sk_atm(vcc)->sk_rcvbuf)
92572 return 1;
92573 atm_return(vcc, truesize);
92574 - atomic_inc(&vcc->stats->rx_drop);
92575 + atomic_inc_unchecked(&vcc->stats->rx_drop);
92576 return 0;
92577 }
92578 EXPORT_SYMBOL(atm_charge);
92579 @@ -39,7 +39,7 @@ struct sk_buff *atm_alloc_charge(struct atm_vcc *vcc, int pdu_size,
92580 }
92581 }
92582 atm_return(vcc, guess);
92583 - atomic_inc(&vcc->stats->rx_drop);
92584 + atomic_inc_unchecked(&vcc->stats->rx_drop);
92585 return NULL;
92586 }
92587 EXPORT_SYMBOL(atm_alloc_charge);
92588 @@ -86,7 +86,7 @@ EXPORT_SYMBOL(atm_pcr_goal);
92589
92590 void sonet_copy_stats(struct k_sonet_stats *from, struct sonet_stats *to)
92591 {
92592 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
92593 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
92594 __SONET_ITEMS
92595 #undef __HANDLE_ITEM
92596 }
92597 @@ -94,7 +94,7 @@ EXPORT_SYMBOL(sonet_copy_stats);
92598
92599 void sonet_subtract_stats(struct k_sonet_stats *from, struct sonet_stats *to)
92600 {
92601 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
92602 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i,&from->i)
92603 __SONET_ITEMS
92604 #undef __HANDLE_ITEM
92605 }
92606 diff --git a/net/atm/lec.h b/net/atm/lec.h
92607 index 4149db1..f2ab682 100644
92608 --- a/net/atm/lec.h
92609 +++ b/net/atm/lec.h
92610 @@ -48,7 +48,7 @@ struct lane2_ops {
92611 const u8 *tlvs, u32 sizeoftlvs);
92612 void (*associate_indicator) (struct net_device *dev, const u8 *mac_addr,
92613 const u8 *tlvs, u32 sizeoftlvs);
92614 -};
92615 +} __no_const;
92616
92617 /*
92618 * ATM LAN Emulation supports both LLC & Dix Ethernet EtherType
92619 diff --git a/net/atm/proc.c b/net/atm/proc.c
92620 index bbb6461..cf04016 100644
92621 --- a/net/atm/proc.c
92622 +++ b/net/atm/proc.c
92623 @@ -45,9 +45,9 @@ static void add_stats(struct seq_file *seq, const char *aal,
92624 const struct k_atm_aal_stats *stats)
92625 {
92626 seq_printf(seq, "%s ( %d %d %d %d %d )", aal,
92627 - atomic_read(&stats->tx), atomic_read(&stats->tx_err),
92628 - atomic_read(&stats->rx), atomic_read(&stats->rx_err),
92629 - atomic_read(&stats->rx_drop));
92630 + atomic_read_unchecked(&stats->tx),atomic_read_unchecked(&stats->tx_err),
92631 + atomic_read_unchecked(&stats->rx),atomic_read_unchecked(&stats->rx_err),
92632 + atomic_read_unchecked(&stats->rx_drop));
92633 }
92634
92635 static void atm_dev_info(struct seq_file *seq, const struct atm_dev *dev)
92636 diff --git a/net/atm/resources.c b/net/atm/resources.c
92637 index 0447d5d..3cf4728 100644
92638 --- a/net/atm/resources.c
92639 +++ b/net/atm/resources.c
92640 @@ -160,7 +160,7 @@ EXPORT_SYMBOL(atm_dev_deregister);
92641 static void copy_aal_stats(struct k_atm_aal_stats *from,
92642 struct atm_aal_stats *to)
92643 {
92644 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
92645 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
92646 __AAL_STAT_ITEMS
92647 #undef __HANDLE_ITEM
92648 }
92649 @@ -168,7 +168,7 @@ static void copy_aal_stats(struct k_atm_aal_stats *from,
92650 static void subtract_aal_stats(struct k_atm_aal_stats *from,
92651 struct atm_aal_stats *to)
92652 {
92653 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
92654 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i, &from->i)
92655 __AAL_STAT_ITEMS
92656 #undef __HANDLE_ITEM
92657 }
92658 diff --git a/net/ax25/sysctl_net_ax25.c b/net/ax25/sysctl_net_ax25.c
92659 index 919a5ce..cc6b444 100644
92660 --- a/net/ax25/sysctl_net_ax25.c
92661 +++ b/net/ax25/sysctl_net_ax25.c
92662 @@ -152,7 +152,7 @@ int ax25_register_dev_sysctl(ax25_dev *ax25_dev)
92663 {
92664 char path[sizeof("net/ax25/") + IFNAMSIZ];
92665 int k;
92666 - struct ctl_table *table;
92667 + ctl_table_no_const *table;
92668
92669 table = kmemdup(ax25_param_table, sizeof(ax25_param_table), GFP_KERNEL);
92670 if (!table)
92671 diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
92672 index 0a8a80c..f7e89aa 100644
92673 --- a/net/batman-adv/bat_iv_ogm.c
92674 +++ b/net/batman-adv/bat_iv_ogm.c
92675 @@ -121,7 +121,7 @@ static int batadv_iv_ogm_iface_enable(struct batadv_hard_iface *hard_iface)
92676
92677 /* randomize initial seqno to avoid collision */
92678 get_random_bytes(&random_seqno, sizeof(random_seqno));
92679 - atomic_set(&hard_iface->bat_iv.ogm_seqno, random_seqno);
92680 + atomic_set_unchecked(&hard_iface->bat_iv.ogm_seqno, random_seqno);
92681
92682 hard_iface->bat_iv.ogm_buff_len = BATADV_OGM_HLEN;
92683 ogm_buff = kmalloc(hard_iface->bat_iv.ogm_buff_len, GFP_ATOMIC);
92684 @@ -703,9 +703,9 @@ static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface)
92685 batadv_ogm_packet = (struct batadv_ogm_packet *)(*ogm_buff);
92686
92687 /* change sequence number to network order */
92688 - seqno = (uint32_t)atomic_read(&hard_iface->bat_iv.ogm_seqno);
92689 + seqno = (uint32_t)atomic_read_unchecked(&hard_iface->bat_iv.ogm_seqno);
92690 batadv_ogm_packet->seqno = htonl(seqno);
92691 - atomic_inc(&hard_iface->bat_iv.ogm_seqno);
92692 + atomic_inc_unchecked(&hard_iface->bat_iv.ogm_seqno);
92693
92694 batadv_ogm_packet->ttvn = atomic_read(&bat_priv->tt.vn);
92695 batadv_ogm_packet->tt_crc = htons(bat_priv->tt.local_crc);
92696 @@ -1111,7 +1111,7 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
92697 return;
92698
92699 /* could be changed by schedule_own_packet() */
92700 - if_incoming_seqno = atomic_read(&if_incoming->bat_iv.ogm_seqno);
92701 + if_incoming_seqno = atomic_read_unchecked(&if_incoming->bat_iv.ogm_seqno);
92702
92703 if (batadv_ogm_packet->flags & BATADV_DIRECTLINK)
92704 has_directlink_flag = 1;
92705 diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
92706 index c478e6b..469fd2f 100644
92707 --- a/net/batman-adv/hard-interface.c
92708 +++ b/net/batman-adv/hard-interface.c
92709 @@ -453,7 +453,7 @@ int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface,
92710 hard_iface->batman_adv_ptype.dev = hard_iface->net_dev;
92711 dev_add_pack(&hard_iface->batman_adv_ptype);
92712
92713 - atomic_set(&hard_iface->frag_seqno, 1);
92714 + atomic_set_unchecked(&hard_iface->frag_seqno, 1);
92715 batadv_info(hard_iface->soft_iface, "Adding interface: %s\n",
92716 hard_iface->net_dev->name);
92717
92718 diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
92719 index 813db4e..847edac 100644
92720 --- a/net/batman-adv/soft-interface.c
92721 +++ b/net/batman-adv/soft-interface.c
92722 @@ -263,7 +263,7 @@ static int batadv_interface_tx(struct sk_buff *skb,
92723 primary_if->net_dev->dev_addr, ETH_ALEN);
92724
92725 /* set broadcast sequence number */
92726 - seqno = atomic_inc_return(&bat_priv->bcast_seqno);
92727 + seqno = atomic_inc_return_unchecked(&bat_priv->bcast_seqno);
92728 bcast_packet->seqno = htonl(seqno);
92729
92730 batadv_add_bcast_packet_to_list(bat_priv, skb, brd_delay);
92731 @@ -483,7 +483,7 @@ static int batadv_softif_init_late(struct net_device *dev)
92732 atomic_set(&bat_priv->batman_queue_left, BATADV_BATMAN_QUEUE_LEN);
92733
92734 atomic_set(&bat_priv->mesh_state, BATADV_MESH_INACTIVE);
92735 - atomic_set(&bat_priv->bcast_seqno, 1);
92736 + atomic_set_unchecked(&bat_priv->bcast_seqno, 1);
92737 atomic_set(&bat_priv->tt.vn, 0);
92738 atomic_set(&bat_priv->tt.local_changes, 0);
92739 atomic_set(&bat_priv->tt.ogm_append_cnt, 0);
92740 diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
92741 index b2c94e1..3d47e07 100644
92742 --- a/net/batman-adv/types.h
92743 +++ b/net/batman-adv/types.h
92744 @@ -51,7 +51,7 @@
92745 struct batadv_hard_iface_bat_iv {
92746 unsigned char *ogm_buff;
92747 int ogm_buff_len;
92748 - atomic_t ogm_seqno;
92749 + atomic_unchecked_t ogm_seqno;
92750 };
92751
92752 /**
92753 @@ -76,7 +76,7 @@ struct batadv_hard_iface {
92754 int16_t if_num;
92755 char if_status;
92756 struct net_device *net_dev;
92757 - atomic_t frag_seqno;
92758 + atomic_unchecked_t frag_seqno;
92759 uint8_t num_bcasts;
92760 struct kobject *hardif_obj;
92761 atomic_t refcount;
92762 @@ -560,7 +560,7 @@ struct batadv_priv {
92763 #ifdef CONFIG_BATMAN_ADV_DEBUG
92764 atomic_t log_level;
92765 #endif
92766 - atomic_t bcast_seqno;
92767 + atomic_unchecked_t bcast_seqno;
92768 atomic_t bcast_queue_left;
92769 atomic_t batman_queue_left;
92770 char num_ifaces;
92771 diff --git a/net/batman-adv/unicast.c b/net/batman-adv/unicast.c
92772 index 48b31d3..62a0bcb 100644
92773 --- a/net/batman-adv/unicast.c
92774 +++ b/net/batman-adv/unicast.c
92775 @@ -272,7 +272,7 @@ int batadv_frag_send_skb(struct sk_buff *skb, struct batadv_priv *bat_priv,
92776 frag1->flags = BATADV_UNI_FRAG_HEAD | large_tail;
92777 frag2->flags = large_tail;
92778
92779 - seqno = atomic_add_return(2, &hard_iface->frag_seqno);
92780 + seqno = atomic_add_return_unchecked(2, &hard_iface->frag_seqno);
92781 frag1->seqno = htons(seqno - 1);
92782 frag2->seqno = htons(seqno);
92783
92784 diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
92785 index fa4bf66..e92948f 100644
92786 --- a/net/bluetooth/hci_sock.c
92787 +++ b/net/bluetooth/hci_sock.c
92788 @@ -932,7 +932,7 @@ static int hci_sock_setsockopt(struct socket *sock, int level, int optname,
92789 uf.event_mask[1] = *((u32 *) f->event_mask + 1);
92790 }
92791
92792 - len = min_t(unsigned int, len, sizeof(uf));
92793 + len = min((size_t)len, sizeof(uf));
92794 if (copy_from_user(&uf, optval, len)) {
92795 err = -EFAULT;
92796 break;
92797 diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
92798 index 63fa111..b166ec6 100644
92799 --- a/net/bluetooth/l2cap_core.c
92800 +++ b/net/bluetooth/l2cap_core.c
92801 @@ -3511,8 +3511,10 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len,
92802 break;
92803
92804 case L2CAP_CONF_RFC:
92805 - if (olen == sizeof(rfc))
92806 - memcpy(&rfc, (void *)val, olen);
92807 + if (olen != sizeof(rfc))
92808 + break;
92809 +
92810 + memcpy(&rfc, (void *)val, olen);
92811
92812 if (test_bit(CONF_STATE2_DEVICE, &chan->conf_state) &&
92813 rfc.mode != chan->mode)
92814 diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
92815 index 0098af8..fb5a31f 100644
92816 --- a/net/bluetooth/l2cap_sock.c
92817 +++ b/net/bluetooth/l2cap_sock.c
92818 @@ -485,7 +485,8 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
92819 struct sock *sk = sock->sk;
92820 struct l2cap_chan *chan = l2cap_pi(sk)->chan;
92821 struct l2cap_options opts;
92822 - int len, err = 0;
92823 + int err = 0;
92824 + size_t len = optlen;
92825 u32 opt;
92826
92827 BT_DBG("sk %p", sk);
92828 @@ -507,7 +508,7 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
92829 opts.max_tx = chan->max_tx;
92830 opts.txwin_size = chan->tx_win;
92831
92832 - len = min_t(unsigned int, sizeof(opts), optlen);
92833 + len = min(sizeof(opts), len);
92834 if (copy_from_user((char *) &opts, optval, len)) {
92835 err = -EFAULT;
92836 break;
92837 @@ -587,7 +588,8 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
92838 struct bt_security sec;
92839 struct bt_power pwr;
92840 struct l2cap_conn *conn;
92841 - int len, err = 0;
92842 + int err = 0;
92843 + size_t len = optlen;
92844 u32 opt;
92845
92846 BT_DBG("sk %p", sk);
92847 @@ -610,7 +612,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
92848
92849 sec.level = BT_SECURITY_LOW;
92850
92851 - len = min_t(unsigned int, sizeof(sec), optlen);
92852 + len = min(sizeof(sec), len);
92853 if (copy_from_user((char *) &sec, optval, len)) {
92854 err = -EFAULT;
92855 break;
92856 @@ -707,7 +709,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
92857
92858 pwr.force_active = BT_POWER_FORCE_ACTIVE_ON;
92859
92860 - len = min_t(unsigned int, sizeof(pwr), optlen);
92861 + len = min(sizeof(pwr), len);
92862 if (copy_from_user((char *) &pwr, optval, len)) {
92863 err = -EFAULT;
92864 break;
92865 diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
92866 index c1c6028..17e8dcc 100644
92867 --- a/net/bluetooth/rfcomm/sock.c
92868 +++ b/net/bluetooth/rfcomm/sock.c
92869 @@ -665,7 +665,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
92870 struct sock *sk = sock->sk;
92871 struct bt_security sec;
92872 int err = 0;
92873 - size_t len;
92874 + size_t len = optlen;
92875 u32 opt;
92876
92877 BT_DBG("sk %p", sk);
92878 @@ -687,7 +687,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
92879
92880 sec.level = BT_SECURITY_LOW;
92881
92882 - len = min_t(unsigned int, sizeof(sec), optlen);
92883 + len = min(sizeof(sec), len);
92884 if (copy_from_user((char *) &sec, optval, len)) {
92885 err = -EFAULT;
92886 break;
92887 diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
92888 index 84fcf9f..e389b27 100644
92889 --- a/net/bluetooth/rfcomm/tty.c
92890 +++ b/net/bluetooth/rfcomm/tty.c
92891 @@ -684,7 +684,7 @@ static int rfcomm_tty_open(struct tty_struct *tty, struct file *filp)
92892 BT_DBG("tty %p id %d", tty, tty->index);
92893
92894 BT_DBG("dev %p dst %pMR channel %d opened %d", dev, &dev->dst,
92895 - dev->channel, dev->port.count);
92896 + dev->channel, atomic_read(&dev->port.count));
92897
92898 err = tty_port_open(&dev->port, tty, filp);
92899 if (err)
92900 @@ -707,7 +707,7 @@ static void rfcomm_tty_close(struct tty_struct *tty, struct file *filp)
92901 struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data;
92902
92903 BT_DBG("tty %p dev %p dlc %p opened %d", tty, dev, dev->dlc,
92904 - dev->port.count);
92905 + atomic_read(&dev->port.count));
92906
92907 tty_port_close(&dev->port, tty, filp);
92908 }
92909 diff --git a/net/bridge/netfilter/ebt_ulog.c b/net/bridge/netfilter/ebt_ulog.c
92910 index 5180938..7c470c3 100644
92911 --- a/net/bridge/netfilter/ebt_ulog.c
92912 +++ b/net/bridge/netfilter/ebt_ulog.c
92913 @@ -181,6 +181,7 @@ static void ebt_ulog_packet(struct net *net, unsigned int hooknr,
92914 ub->qlen++;
92915
92916 pm = nlmsg_data(nlh);
92917 + memset(pm, 0, sizeof(*pm));
92918
92919 /* Fill in the ulog data */
92920 pm->version = EBT_ULOG_VERSION;
92921 @@ -193,8 +194,6 @@ static void ebt_ulog_packet(struct net *net, unsigned int hooknr,
92922 pm->hook = hooknr;
92923 if (uloginfo->prefix != NULL)
92924 strcpy(pm->prefix, uloginfo->prefix);
92925 - else
92926 - *(pm->prefix) = '\0';
92927
92928 if (in) {
92929 strcpy(pm->physindev, in->name);
92930 @@ -204,16 +203,14 @@ static void ebt_ulog_packet(struct net *net, unsigned int hooknr,
92931 strcpy(pm->indev, br_port_get_rcu(in)->br->dev->name);
92932 else
92933 strcpy(pm->indev, in->name);
92934 - } else
92935 - pm->indev[0] = pm->physindev[0] = '\0';
92936 + }
92937
92938 if (out) {
92939 /* If out exists, then out is a bridge port */
92940 strcpy(pm->physoutdev, out->name);
92941 /* rcu_read_lock()ed by nf_hook_slow */
92942 strcpy(pm->outdev, br_port_get_rcu(out)->br->dev->name);
92943 - } else
92944 - pm->outdev[0] = pm->physoutdev[0] = '\0';
92945 + }
92946
92947 if (skb_copy_bits(skb, -ETH_HLEN, pm->data, copy_len) < 0)
92948 BUG();
92949 diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
92950 index ac78024..161a80c 100644
92951 --- a/net/bridge/netfilter/ebtables.c
92952 +++ b/net/bridge/netfilter/ebtables.c
92953 @@ -1525,7 +1525,7 @@ static int do_ebt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
92954 tmp.valid_hooks = t->table->valid_hooks;
92955 }
92956 mutex_unlock(&ebt_mutex);
92957 - if (copy_to_user(user, &tmp, *len) != 0){
92958 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0){
92959 BUGPRINT("c2u Didn't work\n");
92960 ret = -EFAULT;
92961 break;
92962 @@ -2331,7 +2331,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
92963 goto out;
92964 tmp.valid_hooks = t->valid_hooks;
92965
92966 - if (copy_to_user(user, &tmp, *len) != 0) {
92967 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
92968 ret = -EFAULT;
92969 break;
92970 }
92971 @@ -2342,7 +2342,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
92972 tmp.entries_size = t->table->entries_size;
92973 tmp.valid_hooks = t->table->valid_hooks;
92974
92975 - if (copy_to_user(user, &tmp, *len) != 0) {
92976 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
92977 ret = -EFAULT;
92978 break;
92979 }
92980 diff --git a/net/caif/cfctrl.c b/net/caif/cfctrl.c
92981 index 0f45522..dab651f 100644
92982 --- a/net/caif/cfctrl.c
92983 +++ b/net/caif/cfctrl.c
92984 @@ -10,6 +10,7 @@
92985 #include <linux/spinlock.h>
92986 #include <linux/slab.h>
92987 #include <linux/pkt_sched.h>
92988 +#include <linux/sched.h>
92989 #include <net/caif/caif_layer.h>
92990 #include <net/caif/cfpkt.h>
92991 #include <net/caif/cfctrl.h>
92992 @@ -43,8 +44,8 @@ struct cflayer *cfctrl_create(void)
92993 memset(&dev_info, 0, sizeof(dev_info));
92994 dev_info.id = 0xff;
92995 cfsrvl_init(&this->serv, 0, &dev_info, false);
92996 - atomic_set(&this->req_seq_no, 1);
92997 - atomic_set(&this->rsp_seq_no, 1);
92998 + atomic_set_unchecked(&this->req_seq_no, 1);
92999 + atomic_set_unchecked(&this->rsp_seq_no, 1);
93000 this->serv.layer.receive = cfctrl_recv;
93001 sprintf(this->serv.layer.name, "ctrl");
93002 this->serv.layer.ctrlcmd = cfctrl_ctrlcmd;
93003 @@ -130,8 +131,8 @@ static void cfctrl_insert_req(struct cfctrl *ctrl,
93004 struct cfctrl_request_info *req)
93005 {
93006 spin_lock_bh(&ctrl->info_list_lock);
93007 - atomic_inc(&ctrl->req_seq_no);
93008 - req->sequence_no = atomic_read(&ctrl->req_seq_no);
93009 + atomic_inc_unchecked(&ctrl->req_seq_no);
93010 + req->sequence_no = atomic_read_unchecked(&ctrl->req_seq_no);
93011 list_add_tail(&req->list, &ctrl->list);
93012 spin_unlock_bh(&ctrl->info_list_lock);
93013 }
93014 @@ -149,7 +150,7 @@ static struct cfctrl_request_info *cfctrl_remove_req(struct cfctrl *ctrl,
93015 if (p != first)
93016 pr_warn("Requests are not received in order\n");
93017
93018 - atomic_set(&ctrl->rsp_seq_no,
93019 + atomic_set_unchecked(&ctrl->rsp_seq_no,
93020 p->sequence_no);
93021 list_del(&p->list);
93022 goto out;
93023 diff --git a/net/can/af_can.c b/net/can/af_can.c
93024 index 3ab8dd2..b9aef13 100644
93025 --- a/net/can/af_can.c
93026 +++ b/net/can/af_can.c
93027 @@ -862,7 +862,7 @@ static const struct net_proto_family can_family_ops = {
93028 };
93029
93030 /* notifier block for netdevice event */
93031 -static struct notifier_block can_netdev_notifier __read_mostly = {
93032 +static struct notifier_block can_netdev_notifier = {
93033 .notifier_call = can_notifier,
93034 };
93035
93036 diff --git a/net/can/gw.c b/net/can/gw.c
93037 index 3f9b0f3..fc6d4fa 100644
93038 --- a/net/can/gw.c
93039 +++ b/net/can/gw.c
93040 @@ -80,7 +80,6 @@ MODULE_PARM_DESC(max_hops,
93041 "default: " __stringify(CGW_DEFAULT_HOPS) ")");
93042
93043 static HLIST_HEAD(cgw_list);
93044 -static struct notifier_block notifier;
93045
93046 static struct kmem_cache *cgw_cache __read_mostly;
93047
93048 @@ -954,6 +953,10 @@ static int cgw_remove_job(struct sk_buff *skb, struct nlmsghdr *nlh)
93049 return err;
93050 }
93051
93052 +static struct notifier_block notifier = {
93053 + .notifier_call = cgw_notifier
93054 +};
93055 +
93056 static __init int cgw_module_init(void)
93057 {
93058 /* sanitize given module parameter */
93059 @@ -969,7 +972,6 @@ static __init int cgw_module_init(void)
93060 return -ENOMEM;
93061
93062 /* set notifier */
93063 - notifier.notifier_call = cgw_notifier;
93064 register_netdevice_notifier(&notifier);
93065
93066 if (__rtnl_register(PF_CAN, RTM_GETROUTE, NULL, cgw_dump_jobs, NULL)) {
93067 diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
93068 index 4a5df7b..9ad1f1d 100644
93069 --- a/net/ceph/messenger.c
93070 +++ b/net/ceph/messenger.c
93071 @@ -186,7 +186,7 @@ static void con_fault(struct ceph_connection *con);
93072 #define MAX_ADDR_STR_LEN 64 /* 54 is enough */
93073
93074 static char addr_str[ADDR_STR_COUNT][MAX_ADDR_STR_LEN];
93075 -static atomic_t addr_str_seq = ATOMIC_INIT(0);
93076 +static atomic_unchecked_t addr_str_seq = ATOMIC_INIT(0);
93077
93078 static struct page *zero_page; /* used in certain error cases */
93079
93080 @@ -197,7 +197,7 @@ const char *ceph_pr_addr(const struct sockaddr_storage *ss)
93081 struct sockaddr_in *in4 = (struct sockaddr_in *) ss;
93082 struct sockaddr_in6 *in6 = (struct sockaddr_in6 *) ss;
93083
93084 - i = atomic_inc_return(&addr_str_seq) & ADDR_STR_COUNT_MASK;
93085 + i = atomic_inc_return_unchecked(&addr_str_seq) & ADDR_STR_COUNT_MASK;
93086 s = addr_str[i];
93087
93088 switch (ss->ss_family) {
93089 diff --git a/net/compat.c b/net/compat.c
93090 index dd32e34..6066f87 100644
93091 --- a/net/compat.c
93092 +++ b/net/compat.c
93093 @@ -73,9 +73,9 @@ int get_compat_msghdr(struct msghdr *kmsg, struct compat_msghdr __user *umsg)
93094 return -EFAULT;
93095 if (kmsg->msg_namelen > sizeof(struct sockaddr_storage))
93096 kmsg->msg_namelen = sizeof(struct sockaddr_storage);
93097 - kmsg->msg_name = compat_ptr(tmp1);
93098 - kmsg->msg_iov = compat_ptr(tmp2);
93099 - kmsg->msg_control = compat_ptr(tmp3);
93100 + kmsg->msg_name = (void __force_kernel *)compat_ptr(tmp1);
93101 + kmsg->msg_iov = (void __force_kernel *)compat_ptr(tmp2);
93102 + kmsg->msg_control = (void __force_kernel *)compat_ptr(tmp3);
93103 return 0;
93104 }
93105
93106 @@ -87,7 +87,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
93107
93108 if (kern_msg->msg_namelen) {
93109 if (mode == VERIFY_READ) {
93110 - int err = move_addr_to_kernel(kern_msg->msg_name,
93111 + int err = move_addr_to_kernel((void __force_user *)kern_msg->msg_name,
93112 kern_msg->msg_namelen,
93113 kern_address);
93114 if (err < 0)
93115 @@ -99,7 +99,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
93116 kern_msg->msg_name = NULL;
93117
93118 tot_len = iov_from_user_compat_to_kern(kern_iov,
93119 - (struct compat_iovec __user *)kern_msg->msg_iov,
93120 + (struct compat_iovec __force_user *)kern_msg->msg_iov,
93121 kern_msg->msg_iovlen);
93122 if (tot_len >= 0)
93123 kern_msg->msg_iov = kern_iov;
93124 @@ -119,20 +119,20 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
93125
93126 #define CMSG_COMPAT_FIRSTHDR(msg) \
93127 (((msg)->msg_controllen) >= sizeof(struct compat_cmsghdr) ? \
93128 - (struct compat_cmsghdr __user *)((msg)->msg_control) : \
93129 + (struct compat_cmsghdr __force_user *)((msg)->msg_control) : \
93130 (struct compat_cmsghdr __user *)NULL)
93131
93132 #define CMSG_COMPAT_OK(ucmlen, ucmsg, mhdr) \
93133 ((ucmlen) >= sizeof(struct compat_cmsghdr) && \
93134 (ucmlen) <= (unsigned long) \
93135 ((mhdr)->msg_controllen - \
93136 - ((char *)(ucmsg) - (char *)(mhdr)->msg_control)))
93137 + ((char __force_kernel *)(ucmsg) - (char *)(mhdr)->msg_control)))
93138
93139 static inline struct compat_cmsghdr __user *cmsg_compat_nxthdr(struct msghdr *msg,
93140 struct compat_cmsghdr __user *cmsg, int cmsg_len)
93141 {
93142 char __user *ptr = (char __user *)cmsg + CMSG_COMPAT_ALIGN(cmsg_len);
93143 - if ((unsigned long)(ptr + 1 - (char __user *)msg->msg_control) >
93144 + if ((unsigned long)(ptr + 1 - (char __force_user *)msg->msg_control) >
93145 msg->msg_controllen)
93146 return NULL;
93147 return (struct compat_cmsghdr __user *)ptr;
93148 @@ -222,7 +222,7 @@ Efault:
93149
93150 int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *data)
93151 {
93152 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
93153 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
93154 struct compat_cmsghdr cmhdr;
93155 struct compat_timeval ctv;
93156 struct compat_timespec cts[3];
93157 @@ -278,7 +278,7 @@ int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *dat
93158
93159 void scm_detach_fds_compat(struct msghdr *kmsg, struct scm_cookie *scm)
93160 {
93161 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
93162 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
93163 int fdmax = (kmsg->msg_controllen - sizeof(struct compat_cmsghdr)) / sizeof(int);
93164 int fdnum = scm->fp->count;
93165 struct file **fp = scm->fp->fp;
93166 @@ -366,7 +366,7 @@ static int do_set_sock_timeout(struct socket *sock, int level,
93167 return -EFAULT;
93168 old_fs = get_fs();
93169 set_fs(KERNEL_DS);
93170 - err = sock_setsockopt(sock, level, optname, (char *)&ktime, sizeof(ktime));
93171 + err = sock_setsockopt(sock, level, optname, (char __force_user *)&ktime, sizeof(ktime));
93172 set_fs(old_fs);
93173
93174 return err;
93175 @@ -427,7 +427,7 @@ static int do_get_sock_timeout(struct socket *sock, int level, int optname,
93176 len = sizeof(ktime);
93177 old_fs = get_fs();
93178 set_fs(KERNEL_DS);
93179 - err = sock_getsockopt(sock, level, optname, (char *) &ktime, &len);
93180 + err = sock_getsockopt(sock, level, optname, (char __force_user *) &ktime, (int __force_user *)&len);
93181 set_fs(old_fs);
93182
93183 if (!err) {
93184 @@ -570,7 +570,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
93185 case MCAST_JOIN_GROUP:
93186 case MCAST_LEAVE_GROUP:
93187 {
93188 - struct compat_group_req __user *gr32 = (void *)optval;
93189 + struct compat_group_req __user *gr32 = (void __user *)optval;
93190 struct group_req __user *kgr =
93191 compat_alloc_user_space(sizeof(struct group_req));
93192 u32 interface;
93193 @@ -591,7 +591,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
93194 case MCAST_BLOCK_SOURCE:
93195 case MCAST_UNBLOCK_SOURCE:
93196 {
93197 - struct compat_group_source_req __user *gsr32 = (void *)optval;
93198 + struct compat_group_source_req __user *gsr32 = (void __user *)optval;
93199 struct group_source_req __user *kgsr = compat_alloc_user_space(
93200 sizeof(struct group_source_req));
93201 u32 interface;
93202 @@ -612,7 +612,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
93203 }
93204 case MCAST_MSFILTER:
93205 {
93206 - struct compat_group_filter __user *gf32 = (void *)optval;
93207 + struct compat_group_filter __user *gf32 = (void __user *)optval;
93208 struct group_filter __user *kgf;
93209 u32 interface, fmode, numsrc;
93210
93211 @@ -650,7 +650,7 @@ int compat_mc_getsockopt(struct sock *sock, int level, int optname,
93212 char __user *optval, int __user *optlen,
93213 int (*getsockopt)(struct sock *, int, int, char __user *, int __user *))
93214 {
93215 - struct compat_group_filter __user *gf32 = (void *)optval;
93216 + struct compat_group_filter __user *gf32 = (void __user *)optval;
93217 struct group_filter __user *kgf;
93218 int __user *koptlen;
93219 u32 interface, fmode, numsrc;
93220 @@ -808,7 +808,7 @@ asmlinkage long compat_sys_socketcall(int call, u32 __user *args)
93221
93222 if (call < SYS_SOCKET || call > SYS_SENDMMSG)
93223 return -EINVAL;
93224 - if (copy_from_user(a, args, nas[call]))
93225 + if (nas[call] > sizeof a || copy_from_user(a, args, nas[call]))
93226 return -EFAULT;
93227 a0 = a[0];
93228 a1 = a[1];
93229 diff --git a/net/core/datagram.c b/net/core/datagram.c
93230 index af814e7..3d761de 100644
93231 --- a/net/core/datagram.c
93232 +++ b/net/core/datagram.c
93233 @@ -301,7 +301,7 @@ int skb_kill_datagram(struct sock *sk, struct sk_buff *skb, unsigned int flags)
93234 }
93235
93236 kfree_skb(skb);
93237 - atomic_inc(&sk->sk_drops);
93238 + atomic_inc_unchecked(&sk->sk_drops);
93239 sk_mem_reclaim_partial(sk);
93240
93241 return err;
93242 diff --git a/net/core/dev.c b/net/core/dev.c
93243 index 3d13874..6e78dc7 100644
93244 --- a/net/core/dev.c
93245 +++ b/net/core/dev.c
93246 @@ -1680,14 +1680,14 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
93247 {
93248 if (skb_shinfo(skb)->tx_flags & SKBTX_DEV_ZEROCOPY) {
93249 if (skb_copy_ubufs(skb, GFP_ATOMIC)) {
93250 - atomic_long_inc(&dev->rx_dropped);
93251 + atomic_long_inc_unchecked(&dev->rx_dropped);
93252 kfree_skb(skb);
93253 return NET_RX_DROP;
93254 }
93255 }
93256
93257 if (unlikely(!is_skb_forwardable(dev, skb))) {
93258 - atomic_long_inc(&dev->rx_dropped);
93259 + atomic_long_inc_unchecked(&dev->rx_dropped);
93260 kfree_skb(skb);
93261 return NET_RX_DROP;
93262 }
93263 @@ -2428,7 +2428,7 @@ static int illegal_highdma(struct net_device *dev, struct sk_buff *skb)
93264
93265 struct dev_gso_cb {
93266 void (*destructor)(struct sk_buff *skb);
93267 -};
93268 +} __no_const;
93269
93270 #define DEV_GSO_CB(skb) ((struct dev_gso_cb *)(skb)->cb)
93271
93272 @@ -3203,7 +3203,7 @@ enqueue:
93273
93274 local_irq_restore(flags);
93275
93276 - atomic_long_inc(&skb->dev->rx_dropped);
93277 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
93278 kfree_skb(skb);
93279 return NET_RX_DROP;
93280 }
93281 @@ -3275,7 +3275,7 @@ int netif_rx_ni(struct sk_buff *skb)
93282 }
93283 EXPORT_SYMBOL(netif_rx_ni);
93284
93285 -static void net_tx_action(struct softirq_action *h)
93286 +static __latent_entropy void net_tx_action(void)
93287 {
93288 struct softnet_data *sd = &__get_cpu_var(softnet_data);
93289
93290 @@ -3609,7 +3609,7 @@ ncls:
93291 ret = pt_prev->func(skb, skb->dev, pt_prev, orig_dev);
93292 } else {
93293 drop:
93294 - atomic_long_inc(&skb->dev->rx_dropped);
93295 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
93296 kfree_skb(skb);
93297 /* Jamal, now you will not able to escape explaining
93298 * me how you were going to use this. :-)
93299 @@ -4269,7 +4269,7 @@ void netif_napi_del(struct napi_struct *napi)
93300 }
93301 EXPORT_SYMBOL(netif_napi_del);
93302
93303 -static void net_rx_action(struct softirq_action *h)
93304 +static __latent_entropy void net_rx_action(void)
93305 {
93306 struct softnet_data *sd = &__get_cpu_var(softnet_data);
93307 unsigned long time_limit = jiffies + 2;
93308 @@ -5973,7 +5973,7 @@ struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev,
93309 } else {
93310 netdev_stats_to_stats64(storage, &dev->stats);
93311 }
93312 - storage->rx_dropped += atomic_long_read(&dev->rx_dropped);
93313 + storage->rx_dropped += atomic_long_read_unchecked(&dev->rx_dropped);
93314 return storage;
93315 }
93316 EXPORT_SYMBOL(dev_get_stats);
93317 diff --git a/net/core/dev_ioctl.c b/net/core/dev_ioctl.c
93318 index 5b7d0e1..cb960fc 100644
93319 --- a/net/core/dev_ioctl.c
93320 +++ b/net/core/dev_ioctl.c
93321 @@ -365,9 +365,13 @@ void dev_load(struct net *net, const char *name)
93322 if (no_module && capable(CAP_NET_ADMIN))
93323 no_module = request_module("netdev-%s", name);
93324 if (no_module && capable(CAP_SYS_MODULE)) {
93325 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
93326 + ___request_module(true, "grsec_modharden_netdev", "%s", name);
93327 +#else
93328 if (!request_module("%s", name))
93329 pr_warn("Loading kernel module for a network device with CAP_SYS_MODULE (deprecated). Use CAP_NET_ADMIN and alias netdev-%s instead.\n",
93330 name);
93331 +#endif
93332 }
93333 }
93334 EXPORT_SYMBOL(dev_load);
93335 diff --git a/net/core/flow.c b/net/core/flow.c
93336 index dfa602c..3103d88 100644
93337 --- a/net/core/flow.c
93338 +++ b/net/core/flow.c
93339 @@ -61,7 +61,7 @@ struct flow_cache {
93340 struct timer_list rnd_timer;
93341 };
93342
93343 -atomic_t flow_cache_genid = ATOMIC_INIT(0);
93344 +atomic_unchecked_t flow_cache_genid = ATOMIC_INIT(0);
93345 EXPORT_SYMBOL(flow_cache_genid);
93346 static struct flow_cache flow_cache_global;
93347 static struct kmem_cache *flow_cachep __read_mostly;
93348 @@ -86,7 +86,7 @@ static void flow_cache_new_hashrnd(unsigned long arg)
93349
93350 static int flow_entry_valid(struct flow_cache_entry *fle)
93351 {
93352 - if (atomic_read(&flow_cache_genid) != fle->genid)
93353 + if (atomic_read_unchecked(&flow_cache_genid) != fle->genid)
93354 return 0;
93355 if (fle->object && !fle->object->ops->check(fle->object))
93356 return 0;
93357 @@ -258,7 +258,7 @@ flow_cache_lookup(struct net *net, const struct flowi *key, u16 family, u8 dir,
93358 hlist_add_head(&fle->u.hlist, &fcp->hash_table[hash]);
93359 fcp->hash_count++;
93360 }
93361 - } else if (likely(fle->genid == atomic_read(&flow_cache_genid))) {
93362 + } else if (likely(fle->genid == atomic_read_unchecked(&flow_cache_genid))) {
93363 flo = fle->object;
93364 if (!flo)
93365 goto ret_object;
93366 @@ -279,7 +279,7 @@ nocache:
93367 }
93368 flo = resolver(net, key, family, dir, flo, ctx);
93369 if (fle) {
93370 - fle->genid = atomic_read(&flow_cache_genid);
93371 + fle->genid = atomic_read_unchecked(&flow_cache_genid);
93372 if (!IS_ERR(flo))
93373 fle->object = flo;
93374 else
93375 diff --git a/net/core/iovec.c b/net/core/iovec.c
93376 index 7d84ea1..55385ae 100644
93377 --- a/net/core/iovec.c
93378 +++ b/net/core/iovec.c
93379 @@ -42,7 +42,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
93380 if (m->msg_namelen) {
93381 if (mode == VERIFY_READ) {
93382 void __user *namep;
93383 - namep = (void __user __force *) m->msg_name;
93384 + namep = (void __force_user *) m->msg_name;
93385 err = move_addr_to_kernel(namep, m->msg_namelen,
93386 address);
93387 if (err < 0)
93388 @@ -55,7 +55,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
93389 }
93390
93391 size = m->msg_iovlen * sizeof(struct iovec);
93392 - if (copy_from_user(iov, (void __user __force *) m->msg_iov, size))
93393 + if (copy_from_user(iov, (void __force_user *) m->msg_iov, size))
93394 return -EFAULT;
93395
93396 m->msg_iov = iov;
93397 diff --git a/net/core/neighbour.c b/net/core/neighbour.c
93398 index 6072610..7374c18 100644
93399 --- a/net/core/neighbour.c
93400 +++ b/net/core/neighbour.c
93401 @@ -2774,7 +2774,7 @@ static int proc_unres_qlen(struct ctl_table *ctl, int write,
93402 void __user *buffer, size_t *lenp, loff_t *ppos)
93403 {
93404 int size, ret;
93405 - struct ctl_table tmp = *ctl;
93406 + ctl_table_no_const tmp = *ctl;
93407
93408 tmp.extra1 = &zero;
93409 tmp.extra2 = &unres_qlen_max;
93410 diff --git a/net/core/net-procfs.c b/net/core/net-procfs.c
93411 index 2bf8329..7960607 100644
93412 --- a/net/core/net-procfs.c
93413 +++ b/net/core/net-procfs.c
93414 @@ -283,8 +283,13 @@ static int ptype_seq_show(struct seq_file *seq, void *v)
93415 else
93416 seq_printf(seq, "%04x", ntohs(pt->type));
93417
93418 +#ifdef CONFIG_GRKERNSEC_HIDESYM
93419 + seq_printf(seq, " %-8s %pf\n",
93420 + pt->dev ? pt->dev->name : "", NULL);
93421 +#else
93422 seq_printf(seq, " %-8s %pf\n",
93423 pt->dev ? pt->dev->name : "", pt->func);
93424 +#endif
93425 }
93426
93427 return 0;
93428 diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
93429 index d954b56..b0a0f7a 100644
93430 --- a/net/core/net-sysfs.c
93431 +++ b/net/core/net-sysfs.c
93432 @@ -1356,7 +1356,7 @@ void netdev_class_remove_file(struct class_attribute *class_attr)
93433 }
93434 EXPORT_SYMBOL(netdev_class_remove_file);
93435
93436 -int netdev_kobject_init(void)
93437 +int __init netdev_kobject_init(void)
93438 {
93439 kobj_ns_type_register(&net_ns_type_operations);
93440 return class_register(&net_class);
93441 diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
93442 index 81d3a9a..a0bd7a8 100644
93443 --- a/net/core/net_namespace.c
93444 +++ b/net/core/net_namespace.c
93445 @@ -443,7 +443,7 @@ static int __register_pernet_operations(struct list_head *list,
93446 int error;
93447 LIST_HEAD(net_exit_list);
93448
93449 - list_add_tail(&ops->list, list);
93450 + pax_list_add_tail((struct list_head *)&ops->list, list);
93451 if (ops->init || (ops->id && ops->size)) {
93452 for_each_net(net) {
93453 error = ops_init(ops, net);
93454 @@ -456,7 +456,7 @@ static int __register_pernet_operations(struct list_head *list,
93455
93456 out_undo:
93457 /* If I have an error cleanup all namespaces I initialized */
93458 - list_del(&ops->list);
93459 + pax_list_del((struct list_head *)&ops->list);
93460 ops_exit_list(ops, &net_exit_list);
93461 ops_free_list(ops, &net_exit_list);
93462 return error;
93463 @@ -467,7 +467,7 @@ static void __unregister_pernet_operations(struct pernet_operations *ops)
93464 struct net *net;
93465 LIST_HEAD(net_exit_list);
93466
93467 - list_del(&ops->list);
93468 + pax_list_del((struct list_head *)&ops->list);
93469 for_each_net(net)
93470 list_add_tail(&net->exit_list, &net_exit_list);
93471 ops_exit_list(ops, &net_exit_list);
93472 @@ -601,7 +601,7 @@ int register_pernet_device(struct pernet_operations *ops)
93473 mutex_lock(&net_mutex);
93474 error = register_pernet_operations(&pernet_list, ops);
93475 if (!error && (first_device == &pernet_list))
93476 - first_device = &ops->list;
93477 + first_device = (struct list_head *)&ops->list;
93478 mutex_unlock(&net_mutex);
93479 return error;
93480 }
93481 diff --git a/net/core/netpoll.c b/net/core/netpoll.c
93482 index fc75c9e..8c8e9be 100644
93483 --- a/net/core/netpoll.c
93484 +++ b/net/core/netpoll.c
93485 @@ -428,7 +428,7 @@ void netpoll_send_udp(struct netpoll *np, const char *msg, int len)
93486 struct udphdr *udph;
93487 struct iphdr *iph;
93488 struct ethhdr *eth;
93489 - static atomic_t ip_ident;
93490 + static atomic_unchecked_t ip_ident;
93491 struct ipv6hdr *ip6h;
93492
93493 udp_len = len + sizeof(*udph);
93494 @@ -499,7 +499,7 @@ void netpoll_send_udp(struct netpoll *np, const char *msg, int len)
93495 put_unaligned(0x45, (unsigned char *)iph);
93496 iph->tos = 0;
93497 put_unaligned(htons(ip_len), &(iph->tot_len));
93498 - iph->id = htons(atomic_inc_return(&ip_ident));
93499 + iph->id = htons(atomic_inc_return_unchecked(&ip_ident));
93500 iph->frag_off = 0;
93501 iph->ttl = 64;
93502 iph->protocol = IPPROTO_UDP;
93503 diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
93504 index 2a0e21d..6ad7642 100644
93505 --- a/net/core/rtnetlink.c
93506 +++ b/net/core/rtnetlink.c
93507 @@ -58,7 +58,7 @@ struct rtnl_link {
93508 rtnl_doit_func doit;
93509 rtnl_dumpit_func dumpit;
93510 rtnl_calcit_func calcit;
93511 -};
93512 +} __no_const;
93513
93514 static DEFINE_MUTEX(rtnl_mutex);
93515
93516 @@ -299,10 +299,13 @@ int __rtnl_link_register(struct rtnl_link_ops *ops)
93517 if (rtnl_link_ops_get(ops->kind))
93518 return -EEXIST;
93519
93520 - if (!ops->dellink)
93521 - ops->dellink = unregister_netdevice_queue;
93522 + if (!ops->dellink) {
93523 + pax_open_kernel();
93524 + *(void **)&ops->dellink = unregister_netdevice_queue;
93525 + pax_close_kernel();
93526 + }
93527
93528 - list_add_tail(&ops->list, &link_ops);
93529 + pax_list_add_tail((struct list_head *)&ops->list, &link_ops);
93530 return 0;
93531 }
93532 EXPORT_SYMBOL_GPL(__rtnl_link_register);
93533 @@ -349,7 +352,7 @@ void __rtnl_link_unregister(struct rtnl_link_ops *ops)
93534 for_each_net(net) {
93535 __rtnl_kill_links(net, ops);
93536 }
93537 - list_del(&ops->list);
93538 + pax_list_del((struct list_head *)&ops->list);
93539 }
93540 EXPORT_SYMBOL_GPL(__rtnl_link_unregister);
93541
93542 diff --git a/net/core/scm.c b/net/core/scm.c
93543 index b442e7e..6f5b5a2 100644
93544 --- a/net/core/scm.c
93545 +++ b/net/core/scm.c
93546 @@ -210,7 +210,7 @@ EXPORT_SYMBOL(__scm_send);
93547 int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
93548 {
93549 struct cmsghdr __user *cm
93550 - = (__force struct cmsghdr __user *)msg->msg_control;
93551 + = (struct cmsghdr __force_user *)msg->msg_control;
93552 struct cmsghdr cmhdr;
93553 int cmlen = CMSG_LEN(len);
93554 int err;
93555 @@ -233,7 +233,7 @@ int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
93556 err = -EFAULT;
93557 if (copy_to_user(cm, &cmhdr, sizeof cmhdr))
93558 goto out;
93559 - if (copy_to_user(CMSG_DATA(cm), data, cmlen - sizeof(struct cmsghdr)))
93560 + if (copy_to_user((void __force_user *)CMSG_DATA((void __force_kernel *)cm), data, cmlen - sizeof(struct cmsghdr)))
93561 goto out;
93562 cmlen = CMSG_SPACE(len);
93563 if (msg->msg_controllen < cmlen)
93564 @@ -249,7 +249,7 @@ EXPORT_SYMBOL(put_cmsg);
93565 void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
93566 {
93567 struct cmsghdr __user *cm
93568 - = (__force struct cmsghdr __user*)msg->msg_control;
93569 + = (struct cmsghdr __force_user *)msg->msg_control;
93570
93571 int fdmax = 0;
93572 int fdnum = scm->fp->count;
93573 @@ -269,7 +269,7 @@ void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
93574 if (fdnum < fdmax)
93575 fdmax = fdnum;
93576
93577 - for (i=0, cmfptr=(__force int __user *)CMSG_DATA(cm); i<fdmax;
93578 + for (i=0, cmfptr=(int __force_user *)CMSG_DATA((void __force_kernel *)cm); i<fdmax;
93579 i++, cmfptr++)
93580 {
93581 struct socket *sock;
93582 diff --git a/net/core/skbuff.c b/net/core/skbuff.c
93583 index c28c7fe..a399a6d 100644
93584 --- a/net/core/skbuff.c
93585 +++ b/net/core/skbuff.c
93586 @@ -3104,13 +3104,15 @@ void __init skb_init(void)
93587 skbuff_head_cache = kmem_cache_create("skbuff_head_cache",
93588 sizeof(struct sk_buff),
93589 0,
93590 - SLAB_HWCACHE_ALIGN|SLAB_PANIC,
93591 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|
93592 + SLAB_NO_SANITIZE,
93593 NULL);
93594 skbuff_fclone_cache = kmem_cache_create("skbuff_fclone_cache",
93595 (2*sizeof(struct sk_buff)) +
93596 sizeof(atomic_t),
93597 0,
93598 - SLAB_HWCACHE_ALIGN|SLAB_PANIC,
93599 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|
93600 + SLAB_NO_SANITIZE,
93601 NULL);
93602 }
93603
93604 @@ -3541,6 +3543,7 @@ void skb_scrub_packet(struct sk_buff *skb, bool xnet)
93605 skb->tstamp.tv64 = 0;
93606 skb->pkt_type = PACKET_HOST;
93607 skb->skb_iif = 0;
93608 + skb->local_df = 0;
93609 skb_dst_drop(skb);
93610 skb->mark = 0;
93611 secpath_reset(skb);
93612 diff --git a/net/core/sock.c b/net/core/sock.c
93613 index 0b39e7a..5e9f91e 100644
93614 --- a/net/core/sock.c
93615 +++ b/net/core/sock.c
93616 @@ -393,7 +393,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
93617 struct sk_buff_head *list = &sk->sk_receive_queue;
93618
93619 if (atomic_read(&sk->sk_rmem_alloc) >= sk->sk_rcvbuf) {
93620 - atomic_inc(&sk->sk_drops);
93621 + atomic_inc_unchecked(&sk->sk_drops);
93622 trace_sock_rcvqueue_full(sk, skb);
93623 return -ENOMEM;
93624 }
93625 @@ -403,7 +403,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
93626 return err;
93627
93628 if (!sk_rmem_schedule(sk, skb, skb->truesize)) {
93629 - atomic_inc(&sk->sk_drops);
93630 + atomic_inc_unchecked(&sk->sk_drops);
93631 return -ENOBUFS;
93632 }
93633
93634 @@ -423,7 +423,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
93635 skb_dst_force(skb);
93636
93637 spin_lock_irqsave(&list->lock, flags);
93638 - skb->dropcount = atomic_read(&sk->sk_drops);
93639 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
93640 __skb_queue_tail(list, skb);
93641 spin_unlock_irqrestore(&list->lock, flags);
93642
93643 @@ -443,7 +443,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
93644 skb->dev = NULL;
93645
93646 if (sk_rcvqueues_full(sk, skb, sk->sk_rcvbuf)) {
93647 - atomic_inc(&sk->sk_drops);
93648 + atomic_inc_unchecked(&sk->sk_drops);
93649 goto discard_and_relse;
93650 }
93651 if (nested)
93652 @@ -461,7 +461,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
93653 mutex_release(&sk->sk_lock.dep_map, 1, _RET_IP_);
93654 } else if (sk_add_backlog(sk, skb, sk->sk_rcvbuf)) {
93655 bh_unlock_sock(sk);
93656 - atomic_inc(&sk->sk_drops);
93657 + atomic_inc_unchecked(&sk->sk_drops);
93658 goto discard_and_relse;
93659 }
93660
93661 @@ -949,12 +949,12 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
93662 struct timeval tm;
93663 } v;
93664
93665 - int lv = sizeof(int);
93666 - int len;
93667 + unsigned int lv = sizeof(int);
93668 + unsigned int len;
93669
93670 if (get_user(len, optlen))
93671 return -EFAULT;
93672 - if (len < 0)
93673 + if (len > INT_MAX)
93674 return -EINVAL;
93675
93676 memset(&v, 0, sizeof(v));
93677 @@ -1106,11 +1106,11 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
93678
93679 case SO_PEERNAME:
93680 {
93681 - char address[128];
93682 + char address[_K_SS_MAXSIZE];
93683
93684 if (sock->ops->getname(sock, (struct sockaddr *)address, &lv, 2))
93685 return -ENOTCONN;
93686 - if (lv < len)
93687 + if (lv < len || sizeof address < len)
93688 return -EINVAL;
93689 if (copy_to_user(optval, address, len))
93690 return -EFAULT;
93691 @@ -1183,7 +1183,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
93692
93693 if (len > lv)
93694 len = lv;
93695 - if (copy_to_user(optval, &v, len))
93696 + if (len > sizeof(v) || copy_to_user(optval, &v, len))
93697 return -EFAULT;
93698 lenout:
93699 if (put_user(len, optlen))
93700 @@ -2326,7 +2326,7 @@ void sock_init_data(struct socket *sock, struct sock *sk)
93701 */
93702 smp_wmb();
93703 atomic_set(&sk->sk_refcnt, 1);
93704 - atomic_set(&sk->sk_drops, 0);
93705 + atomic_set_unchecked(&sk->sk_drops, 0);
93706 }
93707 EXPORT_SYMBOL(sock_init_data);
93708
93709 @@ -2451,6 +2451,7 @@ void sock_enable_timestamp(struct sock *sk, int flag)
93710 int sock_recv_errqueue(struct sock *sk, struct msghdr *msg, int len,
93711 int level, int type)
93712 {
93713 + struct sock_extended_err ee;
93714 struct sock_exterr_skb *serr;
93715 struct sk_buff *skb, *skb2;
93716 int copied, err;
93717 @@ -2472,7 +2473,8 @@ int sock_recv_errqueue(struct sock *sk, struct msghdr *msg, int len,
93718 sock_recv_timestamp(msg, sk, skb);
93719
93720 serr = SKB_EXT_ERR(skb);
93721 - put_cmsg(msg, level, type, sizeof(serr->ee), &serr->ee);
93722 + ee = serr->ee;
93723 + put_cmsg(msg, level, type, sizeof ee, &ee);
93724
93725 msg->msg_flags |= MSG_ERRQUEUE;
93726 err = copied;
93727 diff --git a/net/core/sock_diag.c b/net/core/sock_diag.c
93728 index a0e9cf6..ef7f9ed 100644
93729 --- a/net/core/sock_diag.c
93730 +++ b/net/core/sock_diag.c
93731 @@ -9,26 +9,33 @@
93732 #include <linux/inet_diag.h>
93733 #include <linux/sock_diag.h>
93734
93735 -static const struct sock_diag_handler *sock_diag_handlers[AF_MAX];
93736 +static const struct sock_diag_handler *sock_diag_handlers[AF_MAX] __read_only;
93737 static int (*inet_rcv_compat)(struct sk_buff *skb, struct nlmsghdr *nlh);
93738 static DEFINE_MUTEX(sock_diag_table_mutex);
93739
93740 int sock_diag_check_cookie(void *sk, __u32 *cookie)
93741 {
93742 +#ifndef CONFIG_GRKERNSEC_HIDESYM
93743 if ((cookie[0] != INET_DIAG_NOCOOKIE ||
93744 cookie[1] != INET_DIAG_NOCOOKIE) &&
93745 ((u32)(unsigned long)sk != cookie[0] ||
93746 (u32)((((unsigned long)sk) >> 31) >> 1) != cookie[1]))
93747 return -ESTALE;
93748 else
93749 +#endif
93750 return 0;
93751 }
93752 EXPORT_SYMBOL_GPL(sock_diag_check_cookie);
93753
93754 void sock_diag_save_cookie(void *sk, __u32 *cookie)
93755 {
93756 +#ifdef CONFIG_GRKERNSEC_HIDESYM
93757 + cookie[0] = 0;
93758 + cookie[1] = 0;
93759 +#else
93760 cookie[0] = (u32)(unsigned long)sk;
93761 cookie[1] = (u32)(((unsigned long)sk >> 31) >> 1);
93762 +#endif
93763 }
93764 EXPORT_SYMBOL_GPL(sock_diag_save_cookie);
93765
93766 @@ -113,8 +120,11 @@ int sock_diag_register(const struct sock_diag_handler *hndl)
93767 mutex_lock(&sock_diag_table_mutex);
93768 if (sock_diag_handlers[hndl->family])
93769 err = -EBUSY;
93770 - else
93771 + else {
93772 + pax_open_kernel();
93773 sock_diag_handlers[hndl->family] = hndl;
93774 + pax_close_kernel();
93775 + }
93776 mutex_unlock(&sock_diag_table_mutex);
93777
93778 return err;
93779 @@ -130,7 +140,9 @@ void sock_diag_unregister(const struct sock_diag_handler *hnld)
93780
93781 mutex_lock(&sock_diag_table_mutex);
93782 BUG_ON(sock_diag_handlers[family] != hnld);
93783 + pax_open_kernel();
93784 sock_diag_handlers[family] = NULL;
93785 + pax_close_kernel();
93786 mutex_unlock(&sock_diag_table_mutex);
93787 }
93788 EXPORT_SYMBOL_GPL(sock_diag_unregister);
93789 diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
93790 index cca4441..5e616de 100644
93791 --- a/net/core/sysctl_net_core.c
93792 +++ b/net/core/sysctl_net_core.c
93793 @@ -32,7 +32,7 @@ static int rps_sock_flow_sysctl(struct ctl_table *table, int write,
93794 {
93795 unsigned int orig_size, size;
93796 int ret, i;
93797 - struct ctl_table tmp = {
93798 + ctl_table_no_const tmp = {
93799 .data = &size,
93800 .maxlen = sizeof(size),
93801 .mode = table->mode
93802 @@ -199,7 +199,7 @@ static int set_default_qdisc(struct ctl_table *table, int write,
93803 void __user *buffer, size_t *lenp, loff_t *ppos)
93804 {
93805 char id[IFNAMSIZ];
93806 - struct ctl_table tbl = {
93807 + ctl_table_no_const tbl = {
93808 .data = id,
93809 .maxlen = IFNAMSIZ,
93810 };
93811 @@ -378,13 +378,12 @@ static struct ctl_table netns_core_table[] = {
93812
93813 static __net_init int sysctl_core_net_init(struct net *net)
93814 {
93815 - struct ctl_table *tbl;
93816 + ctl_table_no_const *tbl = NULL;
93817
93818 net->core.sysctl_somaxconn = SOMAXCONN;
93819
93820 - tbl = netns_core_table;
93821 if (!net_eq(net, &init_net)) {
93822 - tbl = kmemdup(tbl, sizeof(netns_core_table), GFP_KERNEL);
93823 + tbl = kmemdup(netns_core_table, sizeof(netns_core_table), GFP_KERNEL);
93824 if (tbl == NULL)
93825 goto err_dup;
93826
93827 @@ -394,17 +393,16 @@ static __net_init int sysctl_core_net_init(struct net *net)
93828 if (net->user_ns != &init_user_ns) {
93829 tbl[0].procname = NULL;
93830 }
93831 - }
93832 -
93833 - net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
93834 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
93835 + } else
93836 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", netns_core_table);
93837 if (net->core.sysctl_hdr == NULL)
93838 goto err_reg;
93839
93840 return 0;
93841
93842 err_reg:
93843 - if (tbl != netns_core_table)
93844 - kfree(tbl);
93845 + kfree(tbl);
93846 err_dup:
93847 return -ENOMEM;
93848 }
93849 @@ -419,7 +417,7 @@ static __net_exit void sysctl_core_net_exit(struct net *net)
93850 kfree(tbl);
93851 }
93852
93853 -static __net_initdata struct pernet_operations sysctl_core_ops = {
93854 +static __net_initconst struct pernet_operations sysctl_core_ops = {
93855 .init = sysctl_core_net_init,
93856 .exit = sysctl_core_net_exit,
93857 };
93858 diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c
93859 index dd4d506..fb2fb87 100644
93860 --- a/net/decnet/af_decnet.c
93861 +++ b/net/decnet/af_decnet.c
93862 @@ -465,6 +465,7 @@ static struct proto dn_proto = {
93863 .sysctl_rmem = sysctl_decnet_rmem,
93864 .max_header = DN_MAX_NSP_DATA_HEADER + 64,
93865 .obj_size = sizeof(struct dn_sock),
93866 + .slab_flags = SLAB_USERCOPY,
93867 };
93868
93869 static struct sock *dn_alloc_sock(struct net *net, struct socket *sock, gfp_t gfp)
93870 diff --git a/net/decnet/sysctl_net_decnet.c b/net/decnet/sysctl_net_decnet.c
93871 index 5325b54..a0d4d69 100644
93872 --- a/net/decnet/sysctl_net_decnet.c
93873 +++ b/net/decnet/sysctl_net_decnet.c
93874 @@ -174,7 +174,7 @@ static int dn_node_address_handler(struct ctl_table *table, int write,
93875
93876 if (len > *lenp) len = *lenp;
93877
93878 - if (copy_to_user(buffer, addr, len))
93879 + if (len > sizeof addr || copy_to_user(buffer, addr, len))
93880 return -EFAULT;
93881
93882 *lenp = len;
93883 @@ -237,7 +237,7 @@ static int dn_def_dev_handler(struct ctl_table *table, int write,
93884
93885 if (len > *lenp) len = *lenp;
93886
93887 - if (copy_to_user(buffer, devname, len))
93888 + if (len > sizeof devname || copy_to_user(buffer, devname, len))
93889 return -EFAULT;
93890
93891 *lenp = len;
93892 diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c
93893 index 008f337..b03b8c9 100644
93894 --- a/net/ieee802154/6lowpan.c
93895 +++ b/net/ieee802154/6lowpan.c
93896 @@ -548,7 +548,7 @@ static int lowpan_header_create(struct sk_buff *skb,
93897 hc06_ptr += 3;
93898 } else {
93899 /* compress nothing */
93900 - memcpy(hc06_ptr, &hdr, 4);
93901 + memcpy(hc06_ptr, hdr, 4);
93902 /* replace the top byte with new ECN | DSCP format */
93903 *hc06_ptr = tmp;
93904 hc06_ptr += 4;
93905 diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
93906 index cfeb85c..385989a 100644
93907 --- a/net/ipv4/af_inet.c
93908 +++ b/net/ipv4/af_inet.c
93909 @@ -1675,13 +1675,9 @@ static int __init inet_init(void)
93910
93911 BUILD_BUG_ON(sizeof(struct inet_skb_parm) > FIELD_SIZEOF(struct sk_buff, cb));
93912
93913 - sysctl_local_reserved_ports = kzalloc(65536 / 8, GFP_KERNEL);
93914 - if (!sysctl_local_reserved_ports)
93915 - goto out;
93916 -
93917 rc = proto_register(&tcp_prot, 1);
93918 if (rc)
93919 - goto out_free_reserved_ports;
93920 + goto out;
93921
93922 rc = proto_register(&udp_prot, 1);
93923 if (rc)
93924 @@ -1790,8 +1786,6 @@ out_unregister_udp_proto:
93925 proto_unregister(&udp_prot);
93926 out_unregister_tcp_proto:
93927 proto_unregister(&tcp_prot);
93928 -out_free_reserved_ports:
93929 - kfree(sysctl_local_reserved_ports);
93930 goto out;
93931 }
93932
93933 diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
93934 index a1b5bcb..62ec5c6 100644
93935 --- a/net/ipv4/devinet.c
93936 +++ b/net/ipv4/devinet.c
93937 @@ -1533,7 +1533,7 @@ static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
93938 idx = 0;
93939 head = &net->dev_index_head[h];
93940 rcu_read_lock();
93941 - cb->seq = atomic_read(&net->ipv4.dev_addr_genid) ^
93942 + cb->seq = atomic_read_unchecked(&net->ipv4.dev_addr_genid) ^
93943 net->dev_base_seq;
93944 hlist_for_each_entry_rcu(dev, head, index_hlist) {
93945 if (idx < s_idx)
93946 @@ -1844,7 +1844,7 @@ static int inet_netconf_dump_devconf(struct sk_buff *skb,
93947 idx = 0;
93948 head = &net->dev_index_head[h];
93949 rcu_read_lock();
93950 - cb->seq = atomic_read(&net->ipv4.dev_addr_genid) ^
93951 + cb->seq = atomic_read_unchecked(&net->ipv4.dev_addr_genid) ^
93952 net->dev_base_seq;
93953 hlist_for_each_entry_rcu(dev, head, index_hlist) {
93954 if (idx < s_idx)
93955 @@ -2069,7 +2069,7 @@ static int ipv4_doint_and_flush(struct ctl_table *ctl, int write,
93956 #define DEVINET_SYSCTL_FLUSHING_ENTRY(attr, name) \
93957 DEVINET_SYSCTL_COMPLEX_ENTRY(attr, name, ipv4_doint_and_flush)
93958
93959 -static struct devinet_sysctl_table {
93960 +static const struct devinet_sysctl_table {
93961 struct ctl_table_header *sysctl_header;
93962 struct ctl_table devinet_vars[__IPV4_DEVCONF_MAX];
93963 } devinet_sysctl = {
93964 @@ -2191,7 +2191,7 @@ static __net_init int devinet_init_net(struct net *net)
93965 int err;
93966 struct ipv4_devconf *all, *dflt;
93967 #ifdef CONFIG_SYSCTL
93968 - struct ctl_table *tbl = ctl_forward_entry;
93969 + ctl_table_no_const *tbl = NULL;
93970 struct ctl_table_header *forw_hdr;
93971 #endif
93972
93973 @@ -2209,7 +2209,7 @@ static __net_init int devinet_init_net(struct net *net)
93974 goto err_alloc_dflt;
93975
93976 #ifdef CONFIG_SYSCTL
93977 - tbl = kmemdup(tbl, sizeof(ctl_forward_entry), GFP_KERNEL);
93978 + tbl = kmemdup(ctl_forward_entry, sizeof(ctl_forward_entry), GFP_KERNEL);
93979 if (tbl == NULL)
93980 goto err_alloc_ctl;
93981
93982 @@ -2229,7 +2229,10 @@ static __net_init int devinet_init_net(struct net *net)
93983 goto err_reg_dflt;
93984
93985 err = -ENOMEM;
93986 - forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
93987 + if (!net_eq(net, &init_net))
93988 + forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
93989 + else
93990 + forw_hdr = register_net_sysctl(net, "net/ipv4", ctl_forward_entry);
93991 if (forw_hdr == NULL)
93992 goto err_reg_ctl;
93993 net->ipv4.forw_hdr = forw_hdr;
93994 @@ -2245,8 +2248,7 @@ err_reg_ctl:
93995 err_reg_dflt:
93996 __devinet_sysctl_unregister(all);
93997 err_reg_all:
93998 - if (tbl != ctl_forward_entry)
93999 - kfree(tbl);
94000 + kfree(tbl);
94001 err_alloc_ctl:
94002 #endif
94003 if (dflt != &ipv4_devconf_dflt)
94004 diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
94005 index b3f627a..b0f3e99 100644
94006 --- a/net/ipv4/fib_frontend.c
94007 +++ b/net/ipv4/fib_frontend.c
94008 @@ -1017,12 +1017,12 @@ static int fib_inetaddr_event(struct notifier_block *this, unsigned long event,
94009 #ifdef CONFIG_IP_ROUTE_MULTIPATH
94010 fib_sync_up(dev);
94011 #endif
94012 - atomic_inc(&net->ipv4.dev_addr_genid);
94013 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
94014 rt_cache_flush(dev_net(dev));
94015 break;
94016 case NETDEV_DOWN:
94017 fib_del_ifaddr(ifa, NULL);
94018 - atomic_inc(&net->ipv4.dev_addr_genid);
94019 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
94020 if (ifa->ifa_dev->ifa_list == NULL) {
94021 /* Last address was deleted from this interface.
94022 * Disable IP.
94023 @@ -1058,7 +1058,7 @@ static int fib_netdev_event(struct notifier_block *this, unsigned long event, vo
94024 #ifdef CONFIG_IP_ROUTE_MULTIPATH
94025 fib_sync_up(dev);
94026 #endif
94027 - atomic_inc(&net->ipv4.dev_addr_genid);
94028 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
94029 rt_cache_flush(net);
94030 break;
94031 case NETDEV_DOWN:
94032 diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
94033 index d5dbca5..6251d5f 100644
94034 --- a/net/ipv4/fib_semantics.c
94035 +++ b/net/ipv4/fib_semantics.c
94036 @@ -766,7 +766,7 @@ __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh)
94037 nh->nh_saddr = inet_select_addr(nh->nh_dev,
94038 nh->nh_gw,
94039 nh->nh_parent->fib_scope);
94040 - nh->nh_saddr_genid = atomic_read(&net->ipv4.dev_addr_genid);
94041 + nh->nh_saddr_genid = atomic_read_unchecked(&net->ipv4.dev_addr_genid);
94042
94043 return nh->nh_saddr;
94044 }
94045 diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
94046 index 6acb541..9ea617d 100644
94047 --- a/net/ipv4/inet_connection_sock.c
94048 +++ b/net/ipv4/inet_connection_sock.c
94049 @@ -37,7 +37,7 @@ struct local_ports sysctl_local_ports __read_mostly = {
94050 .range = { 32768, 61000 },
94051 };
94052
94053 -unsigned long *sysctl_local_reserved_ports;
94054 +unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
94055 EXPORT_SYMBOL(sysctl_local_reserved_ports);
94056
94057 void inet_get_local_port_range(int *low, int *high)
94058 diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
94059 index 96da9c7..b956690 100644
94060 --- a/net/ipv4/inet_hashtables.c
94061 +++ b/net/ipv4/inet_hashtables.c
94062 @@ -18,12 +18,15 @@
94063 #include <linux/sched.h>
94064 #include <linux/slab.h>
94065 #include <linux/wait.h>
94066 +#include <linux/security.h>
94067
94068 #include <net/inet_connection_sock.h>
94069 #include <net/inet_hashtables.h>
94070 #include <net/secure_seq.h>
94071 #include <net/ip.h>
94072
94073 +extern void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet);
94074 +
94075 /*
94076 * Allocate and initialize a new local port bind bucket.
94077 * The bindhash mutex for snum's hash chain must be held here.
94078 @@ -554,6 +557,8 @@ ok:
94079 twrefcnt += inet_twsk_bind_unhash(tw, hinfo);
94080 spin_unlock(&head->lock);
94081
94082 + gr_update_task_in_ip_table(current, inet_sk(sk));
94083 +
94084 if (tw) {
94085 inet_twsk_deschedule(tw, death_row);
94086 while (twrefcnt) {
94087 diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c
94088 index 33d5537..da337a4 100644
94089 --- a/net/ipv4/inetpeer.c
94090 +++ b/net/ipv4/inetpeer.c
94091 @@ -503,8 +503,8 @@ relookup:
94092 if (p) {
94093 p->daddr = *daddr;
94094 atomic_set(&p->refcnt, 1);
94095 - atomic_set(&p->rid, 0);
94096 - atomic_set(&p->ip_id_count,
94097 + atomic_set_unchecked(&p->rid, 0);
94098 + atomic_set_unchecked(&p->ip_id_count,
94099 (daddr->family == AF_INET) ?
94100 secure_ip_id(daddr->addr.a4) :
94101 secure_ipv6_id(daddr->addr.a6));
94102 diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
94103 index b66910a..cfe416e 100644
94104 --- a/net/ipv4/ip_fragment.c
94105 +++ b/net/ipv4/ip_fragment.c
94106 @@ -282,7 +282,7 @@ static inline int ip_frag_too_far(struct ipq *qp)
94107 return 0;
94108
94109 start = qp->rid;
94110 - end = atomic_inc_return(&peer->rid);
94111 + end = atomic_inc_return_unchecked(&peer->rid);
94112 qp->rid = end;
94113
94114 rc = qp->q.fragments && (end - start) > max;
94115 @@ -759,12 +759,11 @@ static struct ctl_table ip4_frags_ctl_table[] = {
94116
94117 static int __net_init ip4_frags_ns_ctl_register(struct net *net)
94118 {
94119 - struct ctl_table *table;
94120 + ctl_table_no_const *table = NULL;
94121 struct ctl_table_header *hdr;
94122
94123 - table = ip4_frags_ns_ctl_table;
94124 if (!net_eq(net, &init_net)) {
94125 - table = kmemdup(table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
94126 + table = kmemdup(ip4_frags_ns_ctl_table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
94127 if (table == NULL)
94128 goto err_alloc;
94129
94130 @@ -775,9 +774,10 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
94131 /* Don't export sysctls to unprivileged users */
94132 if (net->user_ns != &init_user_ns)
94133 table[0].procname = NULL;
94134 - }
94135 + hdr = register_net_sysctl(net, "net/ipv4", table);
94136 + } else
94137 + hdr = register_net_sysctl(net, "net/ipv4", ip4_frags_ns_ctl_table);
94138
94139 - hdr = register_net_sysctl(net, "net/ipv4", table);
94140 if (hdr == NULL)
94141 goto err_reg;
94142
94143 @@ -785,8 +785,7 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
94144 return 0;
94145
94146 err_reg:
94147 - if (!net_eq(net, &init_net))
94148 - kfree(table);
94149 + kfree(table);
94150 err_alloc:
94151 return -ENOMEM;
94152 }
94153 diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
94154 index d7aea4c..a8ee872 100644
94155 --- a/net/ipv4/ip_gre.c
94156 +++ b/net/ipv4/ip_gre.c
94157 @@ -115,7 +115,7 @@ static bool log_ecn_error = true;
94158 module_param(log_ecn_error, bool, 0644);
94159 MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
94160
94161 -static struct rtnl_link_ops ipgre_link_ops __read_mostly;
94162 +static struct rtnl_link_ops ipgre_link_ops;
94163 static int ipgre_tunnel_init(struct net_device *dev);
94164
94165 static int ipgre_net_id __read_mostly;
94166 @@ -731,7 +731,7 @@ static const struct nla_policy ipgre_policy[IFLA_GRE_MAX + 1] = {
94167 [IFLA_GRE_PMTUDISC] = { .type = NLA_U8 },
94168 };
94169
94170 -static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
94171 +static struct rtnl_link_ops ipgre_link_ops = {
94172 .kind = "gre",
94173 .maxtype = IFLA_GRE_MAX,
94174 .policy = ipgre_policy,
94175 @@ -745,7 +745,7 @@ static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
94176 .fill_info = ipgre_fill_info,
94177 };
94178
94179 -static struct rtnl_link_ops ipgre_tap_ops __read_mostly = {
94180 +static struct rtnl_link_ops ipgre_tap_ops = {
94181 .kind = "gretap",
94182 .maxtype = IFLA_GRE_MAX,
94183 .policy = ipgre_policy,
94184 diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
94185 index 23e6ab0..be67a57 100644
94186 --- a/net/ipv4/ip_sockglue.c
94187 +++ b/net/ipv4/ip_sockglue.c
94188 @@ -1153,7 +1153,8 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
94189 len = min_t(unsigned int, len, opt->optlen);
94190 if (put_user(len, optlen))
94191 return -EFAULT;
94192 - if (copy_to_user(optval, opt->__data, len))
94193 + if ((len > (sizeof(optbuf) - sizeof(struct ip_options))) ||
94194 + copy_to_user(optval, opt->__data, len))
94195 return -EFAULT;
94196 return 0;
94197 }
94198 @@ -1284,7 +1285,7 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
94199 if (sk->sk_type != SOCK_STREAM)
94200 return -ENOPROTOOPT;
94201
94202 - msg.msg_control = optval;
94203 + msg.msg_control = (void __force_kernel *)optval;
94204 msg.msg_controllen = len;
94205 msg.msg_flags = flags;
94206
94207 diff --git a/net/ipv4/ip_vti.c b/net/ipv4/ip_vti.c
94208 index 26847e1..75d2d2f 100644
94209 --- a/net/ipv4/ip_vti.c
94210 +++ b/net/ipv4/ip_vti.c
94211 @@ -44,7 +44,7 @@
94212 #include <net/net_namespace.h>
94213 #include <net/netns/generic.h>
94214
94215 -static struct rtnl_link_ops vti_link_ops __read_mostly;
94216 +static struct rtnl_link_ops vti_link_ops;
94217
94218 static int vti_net_id __read_mostly;
94219 static int vti_tunnel_init(struct net_device *dev);
94220 @@ -425,7 +425,7 @@ static const struct nla_policy vti_policy[IFLA_VTI_MAX + 1] = {
94221 [IFLA_VTI_REMOTE] = { .len = FIELD_SIZEOF(struct iphdr, daddr) },
94222 };
94223
94224 -static struct rtnl_link_ops vti_link_ops __read_mostly = {
94225 +static struct rtnl_link_ops vti_link_ops = {
94226 .kind = "vti",
94227 .maxtype = IFLA_VTI_MAX,
94228 .policy = vti_policy,
94229 diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
94230 index efa1138..20dbba0 100644
94231 --- a/net/ipv4/ipconfig.c
94232 +++ b/net/ipv4/ipconfig.c
94233 @@ -334,7 +334,7 @@ static int __init ic_devinet_ioctl(unsigned int cmd, struct ifreq *arg)
94234
94235 mm_segment_t oldfs = get_fs();
94236 set_fs(get_ds());
94237 - res = devinet_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
94238 + res = devinet_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
94239 set_fs(oldfs);
94240 return res;
94241 }
94242 @@ -345,7 +345,7 @@ static int __init ic_dev_ioctl(unsigned int cmd, struct ifreq *arg)
94243
94244 mm_segment_t oldfs = get_fs();
94245 set_fs(get_ds());
94246 - res = dev_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
94247 + res = dev_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
94248 set_fs(oldfs);
94249 return res;
94250 }
94251 @@ -356,7 +356,7 @@ static int __init ic_route_ioctl(unsigned int cmd, struct rtentry *arg)
94252
94253 mm_segment_t oldfs = get_fs();
94254 set_fs(get_ds());
94255 - res = ip_rt_ioctl(&init_net, cmd, (void __user *) arg);
94256 + res = ip_rt_ioctl(&init_net, cmd, (void __force_user *) arg);
94257 set_fs(oldfs);
94258 return res;
94259 }
94260 diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c
94261 index 7f80fb4..b0328f6 100644
94262 --- a/net/ipv4/ipip.c
94263 +++ b/net/ipv4/ipip.c
94264 @@ -124,7 +124,7 @@ MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
94265 static int ipip_net_id __read_mostly;
94266
94267 static int ipip_tunnel_init(struct net_device *dev);
94268 -static struct rtnl_link_ops ipip_link_ops __read_mostly;
94269 +static struct rtnl_link_ops ipip_link_ops;
94270
94271 static int ipip_err(struct sk_buff *skb, u32 info)
94272 {
94273 @@ -408,7 +408,7 @@ static const struct nla_policy ipip_policy[IFLA_IPTUN_MAX + 1] = {
94274 [IFLA_IPTUN_PMTUDISC] = { .type = NLA_U8 },
94275 };
94276
94277 -static struct rtnl_link_ops ipip_link_ops __read_mostly = {
94278 +static struct rtnl_link_ops ipip_link_ops = {
94279 .kind = "ipip",
94280 .maxtype = IFLA_IPTUN_MAX,
94281 .policy = ipip_policy,
94282 diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
94283 index 85a4f21..1beb1f5 100644
94284 --- a/net/ipv4/netfilter/arp_tables.c
94285 +++ b/net/ipv4/netfilter/arp_tables.c
94286 @@ -880,14 +880,14 @@ static int compat_table_info(const struct xt_table_info *info,
94287 #endif
94288
94289 static int get_info(struct net *net, void __user *user,
94290 - const int *len, int compat)
94291 + int len, int compat)
94292 {
94293 char name[XT_TABLE_MAXNAMELEN];
94294 struct xt_table *t;
94295 int ret;
94296
94297 - if (*len != sizeof(struct arpt_getinfo)) {
94298 - duprintf("length %u != %Zu\n", *len,
94299 + if (len != sizeof(struct arpt_getinfo)) {
94300 + duprintf("length %u != %Zu\n", len,
94301 sizeof(struct arpt_getinfo));
94302 return -EINVAL;
94303 }
94304 @@ -924,7 +924,7 @@ static int get_info(struct net *net, void __user *user,
94305 info.size = private->size;
94306 strcpy(info.name, name);
94307
94308 - if (copy_to_user(user, &info, *len) != 0)
94309 + if (copy_to_user(user, &info, len) != 0)
94310 ret = -EFAULT;
94311 else
94312 ret = 0;
94313 @@ -1683,7 +1683,7 @@ static int compat_do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user,
94314
94315 switch (cmd) {
94316 case ARPT_SO_GET_INFO:
94317 - ret = get_info(sock_net(sk), user, len, 1);
94318 + ret = get_info(sock_net(sk), user, *len, 1);
94319 break;
94320 case ARPT_SO_GET_ENTRIES:
94321 ret = compat_get_entries(sock_net(sk), user, len);
94322 @@ -1728,7 +1728,7 @@ static int do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len
94323
94324 switch (cmd) {
94325 case ARPT_SO_GET_INFO:
94326 - ret = get_info(sock_net(sk), user, len, 0);
94327 + ret = get_info(sock_net(sk), user, *len, 0);
94328 break;
94329
94330 case ARPT_SO_GET_ENTRIES:
94331 diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
94332 index d23118d..6ad7277 100644
94333 --- a/net/ipv4/netfilter/ip_tables.c
94334 +++ b/net/ipv4/netfilter/ip_tables.c
94335 @@ -1068,14 +1068,14 @@ static int compat_table_info(const struct xt_table_info *info,
94336 #endif
94337
94338 static int get_info(struct net *net, void __user *user,
94339 - const int *len, int compat)
94340 + int len, int compat)
94341 {
94342 char name[XT_TABLE_MAXNAMELEN];
94343 struct xt_table *t;
94344 int ret;
94345
94346 - if (*len != sizeof(struct ipt_getinfo)) {
94347 - duprintf("length %u != %zu\n", *len,
94348 + if (len != sizeof(struct ipt_getinfo)) {
94349 + duprintf("length %u != %zu\n", len,
94350 sizeof(struct ipt_getinfo));
94351 return -EINVAL;
94352 }
94353 @@ -1112,7 +1112,7 @@ static int get_info(struct net *net, void __user *user,
94354 info.size = private->size;
94355 strcpy(info.name, name);
94356
94357 - if (copy_to_user(user, &info, *len) != 0)
94358 + if (copy_to_user(user, &info, len) != 0)
94359 ret = -EFAULT;
94360 else
94361 ret = 0;
94362 @@ -1966,7 +1966,7 @@ compat_do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
94363
94364 switch (cmd) {
94365 case IPT_SO_GET_INFO:
94366 - ret = get_info(sock_net(sk), user, len, 1);
94367 + ret = get_info(sock_net(sk), user, *len, 1);
94368 break;
94369 case IPT_SO_GET_ENTRIES:
94370 ret = compat_get_entries(sock_net(sk), user, len);
94371 @@ -2013,7 +2013,7 @@ do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
94372
94373 switch (cmd) {
94374 case IPT_SO_GET_INFO:
94375 - ret = get_info(sock_net(sk), user, len, 0);
94376 + ret = get_info(sock_net(sk), user, *len, 0);
94377 break;
94378
94379 case IPT_SO_GET_ENTRIES:
94380 diff --git a/net/ipv4/netfilter/ipt_ULOG.c b/net/ipv4/netfilter/ipt_ULOG.c
94381 index cbc2215..9cb993c 100644
94382 --- a/net/ipv4/netfilter/ipt_ULOG.c
94383 +++ b/net/ipv4/netfilter/ipt_ULOG.c
94384 @@ -220,6 +220,7 @@ static void ipt_ulog_packet(struct net *net,
94385 ub->qlen++;
94386
94387 pm = nlmsg_data(nlh);
94388 + memset(pm, 0, sizeof(*pm));
94389
94390 /* We might not have a timestamp, get one */
94391 if (skb->tstamp.tv64 == 0)
94392 @@ -238,8 +239,6 @@ static void ipt_ulog_packet(struct net *net,
94393 }
94394 else if (loginfo->prefix[0] != '\0')
94395 strncpy(pm->prefix, loginfo->prefix, sizeof(pm->prefix));
94396 - else
94397 - *(pm->prefix) = '\0';
94398
94399 if (in && in->hard_header_len > 0 &&
94400 skb->mac_header != skb->network_header &&
94401 @@ -251,13 +250,9 @@ static void ipt_ulog_packet(struct net *net,
94402
94403 if (in)
94404 strncpy(pm->indev_name, in->name, sizeof(pm->indev_name));
94405 - else
94406 - pm->indev_name[0] = '\0';
94407
94408 if (out)
94409 strncpy(pm->outdev_name, out->name, sizeof(pm->outdev_name));
94410 - else
94411 - pm->outdev_name[0] = '\0';
94412
94413 /* copy_len <= skb->len, so can't fail. */
94414 if (skb_copy_bits(skb, 0, pm->payload, copy_len) < 0)
94415 diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
94416 index c482f7c..2784262 100644
94417 --- a/net/ipv4/ping.c
94418 +++ b/net/ipv4/ping.c
94419 @@ -55,7 +55,7 @@
94420
94421
94422 struct ping_table ping_table;
94423 -struct pingv6_ops pingv6_ops;
94424 +struct pingv6_ops *pingv6_ops;
94425 EXPORT_SYMBOL_GPL(pingv6_ops);
94426
94427 static u16 ping_port_rover;
94428 @@ -335,7 +335,7 @@ static int ping_check_bind_addr(struct sock *sk, struct inet_sock *isk,
94429 return -ENODEV;
94430 }
94431 }
94432 - has_addr = pingv6_ops.ipv6_chk_addr(net, &addr->sin6_addr, dev,
94433 + has_addr = pingv6_ops->ipv6_chk_addr(net, &addr->sin6_addr, dev,
94434 scoped);
94435 rcu_read_unlock();
94436
94437 @@ -541,7 +541,7 @@ void ping_err(struct sk_buff *skb, int offset, u32 info)
94438 }
94439 #if IS_ENABLED(CONFIG_IPV6)
94440 } else if (skb->protocol == htons(ETH_P_IPV6)) {
94441 - harderr = pingv6_ops.icmpv6_err_convert(type, code, &err);
94442 + harderr = pingv6_ops->icmpv6_err_convert(type, code, &err);
94443 #endif
94444 }
94445
94446 @@ -559,7 +559,7 @@ void ping_err(struct sk_buff *skb, int offset, u32 info)
94447 info, (u8 *)icmph);
94448 #if IS_ENABLED(CONFIG_IPV6)
94449 } else if (family == AF_INET6) {
94450 - pingv6_ops.ipv6_icmp_error(sk, skb, err, 0,
94451 + pingv6_ops->ipv6_icmp_error(sk, skb, err, 0,
94452 info, (u8 *)icmph);
94453 #endif
94454 }
94455 @@ -841,7 +841,7 @@ int ping_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
94456 return ip_recv_error(sk, msg, len, addr_len);
94457 #if IS_ENABLED(CONFIG_IPV6)
94458 } else if (family == AF_INET6) {
94459 - return pingv6_ops.ipv6_recv_error(sk, msg, len,
94460 + return pingv6_ops->ipv6_recv_error(sk, msg, len,
94461 addr_len);
94462 #endif
94463 }
94464 @@ -900,7 +900,7 @@ int ping_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
94465 }
94466
94467 if (inet6_sk(sk)->rxopt.all)
94468 - pingv6_ops.ip6_datagram_recv_ctl(sk, msg, skb);
94469 + pingv6_ops->ip6_datagram_recv_ctl(sk, msg, skb);
94470 #endif
94471 } else {
94472 BUG();
94473 @@ -1090,7 +1090,7 @@ static void ping_v4_format_sock(struct sock *sp, struct seq_file *f,
94474 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
94475 0, sock_i_ino(sp),
94476 atomic_read(&sp->sk_refcnt), sp,
94477 - atomic_read(&sp->sk_drops), len);
94478 + atomic_read_unchecked(&sp->sk_drops), len);
94479 }
94480
94481 static int ping_v4_seq_show(struct seq_file *seq, void *v)
94482 diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
94483 index 7d3db78..9fd511d 100644
94484 --- a/net/ipv4/raw.c
94485 +++ b/net/ipv4/raw.c
94486 @@ -311,7 +311,7 @@ static int raw_rcv_skb(struct sock *sk, struct sk_buff *skb)
94487 int raw_rcv(struct sock *sk, struct sk_buff *skb)
94488 {
94489 if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb)) {
94490 - atomic_inc(&sk->sk_drops);
94491 + atomic_inc_unchecked(&sk->sk_drops);
94492 kfree_skb(skb);
94493 return NET_RX_DROP;
94494 }
94495 @@ -746,16 +746,20 @@ static int raw_init(struct sock *sk)
94496
94497 static int raw_seticmpfilter(struct sock *sk, char __user *optval, int optlen)
94498 {
94499 + struct icmp_filter filter;
94500 +
94501 if (optlen > sizeof(struct icmp_filter))
94502 optlen = sizeof(struct icmp_filter);
94503 - if (copy_from_user(&raw_sk(sk)->filter, optval, optlen))
94504 + if (copy_from_user(&filter, optval, optlen))
94505 return -EFAULT;
94506 + raw_sk(sk)->filter = filter;
94507 return 0;
94508 }
94509
94510 static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *optlen)
94511 {
94512 int len, ret = -EFAULT;
94513 + struct icmp_filter filter;
94514
94515 if (get_user(len, optlen))
94516 goto out;
94517 @@ -765,8 +769,8 @@ static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *o
94518 if (len > sizeof(struct icmp_filter))
94519 len = sizeof(struct icmp_filter);
94520 ret = -EFAULT;
94521 - if (put_user(len, optlen) ||
94522 - copy_to_user(optval, &raw_sk(sk)->filter, len))
94523 + filter = raw_sk(sk)->filter;
94524 + if (put_user(len, optlen) || len > sizeof filter || copy_to_user(optval, &filter, len))
94525 goto out;
94526 ret = 0;
94527 out: return ret;
94528 @@ -995,7 +999,7 @@ static void raw_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
94529 0, 0L, 0,
94530 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),
94531 0, sock_i_ino(sp),
94532 - atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
94533 + atomic_read(&sp->sk_refcnt), sp, atomic_read_unchecked(&sp->sk_drops));
94534 }
94535
94536 static int raw_seq_show(struct seq_file *seq, void *v)
94537 diff --git a/net/ipv4/route.c b/net/ipv4/route.c
94538 index 62290b5..f0d944f 100644
94539 --- a/net/ipv4/route.c
94540 +++ b/net/ipv4/route.c
94541 @@ -2617,34 +2617,34 @@ static struct ctl_table ipv4_route_flush_table[] = {
94542 .maxlen = sizeof(int),
94543 .mode = 0200,
94544 .proc_handler = ipv4_sysctl_rtcache_flush,
94545 + .extra1 = &init_net,
94546 },
94547 { },
94548 };
94549
94550 static __net_init int sysctl_route_net_init(struct net *net)
94551 {
94552 - struct ctl_table *tbl;
94553 + ctl_table_no_const *tbl = NULL;
94554
94555 - tbl = ipv4_route_flush_table;
94556 if (!net_eq(net, &init_net)) {
94557 - tbl = kmemdup(tbl, sizeof(ipv4_route_flush_table), GFP_KERNEL);
94558 + tbl = kmemdup(ipv4_route_flush_table, sizeof(ipv4_route_flush_table), GFP_KERNEL);
94559 if (tbl == NULL)
94560 goto err_dup;
94561
94562 /* Don't export sysctls to unprivileged users */
94563 if (net->user_ns != &init_user_ns)
94564 tbl[0].procname = NULL;
94565 - }
94566 - tbl[0].extra1 = net;
94567 + tbl[0].extra1 = net;
94568 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
94569 + } else
94570 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", ipv4_route_flush_table);
94571
94572 - net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
94573 if (net->ipv4.route_hdr == NULL)
94574 goto err_reg;
94575 return 0;
94576
94577 err_reg:
94578 - if (tbl != ipv4_route_flush_table)
94579 - kfree(tbl);
94580 + kfree(tbl);
94581 err_dup:
94582 return -ENOMEM;
94583 }
94584 @@ -2667,8 +2667,8 @@ static __net_initdata struct pernet_operations sysctl_route_ops = {
94585
94586 static __net_init int rt_genid_init(struct net *net)
94587 {
94588 - atomic_set(&net->ipv4.rt_genid, 0);
94589 - atomic_set(&net->fnhe_genid, 0);
94590 + atomic_set_unchecked(&net->ipv4.rt_genid, 0);
94591 + atomic_set_unchecked(&net->fnhe_genid, 0);
94592 get_random_bytes(&net->ipv4.dev_addr_genid,
94593 sizeof(net->ipv4.dev_addr_genid));
94594 return 0;
94595 diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
94596 index 540279f..9855b16 100644
94597 --- a/net/ipv4/sysctl_net_ipv4.c
94598 +++ b/net/ipv4/sysctl_net_ipv4.c
94599 @@ -58,7 +58,7 @@ static int ipv4_local_port_range(struct ctl_table *table, int write,
94600 {
94601 int ret;
94602 int range[2];
94603 - struct ctl_table tmp = {
94604 + ctl_table_no_const tmp = {
94605 .data = &range,
94606 .maxlen = sizeof(range),
94607 .mode = table->mode,
94608 @@ -111,7 +111,7 @@ static int ipv4_ping_group_range(struct ctl_table *table, int write,
94609 int ret;
94610 gid_t urange[2];
94611 kgid_t low, high;
94612 - struct ctl_table tmp = {
94613 + ctl_table_no_const tmp = {
94614 .data = &urange,
94615 .maxlen = sizeof(urange),
94616 .mode = table->mode,
94617 @@ -142,7 +142,7 @@ static int proc_tcp_congestion_control(struct ctl_table *ctl, int write,
94618 void __user *buffer, size_t *lenp, loff_t *ppos)
94619 {
94620 char val[TCP_CA_NAME_MAX];
94621 - struct ctl_table tbl = {
94622 + ctl_table_no_const tbl = {
94623 .data = val,
94624 .maxlen = TCP_CA_NAME_MAX,
94625 };
94626 @@ -161,7 +161,7 @@ static int proc_tcp_available_congestion_control(struct ctl_table *ctl,
94627 void __user *buffer, size_t *lenp,
94628 loff_t *ppos)
94629 {
94630 - struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX, };
94631 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX, };
94632 int ret;
94633
94634 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
94635 @@ -178,7 +178,7 @@ static int proc_allowed_congestion_control(struct ctl_table *ctl,
94636 void __user *buffer, size_t *lenp,
94637 loff_t *ppos)
94638 {
94639 - struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX };
94640 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX };
94641 int ret;
94642
94643 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
94644 @@ -204,15 +204,17 @@ static int ipv4_tcp_mem(struct ctl_table *ctl, int write,
94645 struct mem_cgroup *memcg;
94646 #endif
94647
94648 - struct ctl_table tmp = {
94649 + ctl_table_no_const tmp = {
94650 .data = &vec,
94651 .maxlen = sizeof(vec),
94652 .mode = ctl->mode,
94653 };
94654
94655 if (!write) {
94656 - ctl->data = &net->ipv4.sysctl_tcp_mem;
94657 - return proc_doulongvec_minmax(ctl, write, buffer, lenp, ppos);
94658 + ctl_table_no_const tcp_mem = *ctl;
94659 +
94660 + tcp_mem.data = &net->ipv4.sysctl_tcp_mem;
94661 + return proc_doulongvec_minmax(&tcp_mem, write, buffer, lenp, ppos);
94662 }
94663
94664 ret = proc_doulongvec_minmax(&tmp, write, buffer, lenp, ppos);
94665 @@ -240,7 +242,7 @@ static int proc_tcp_fastopen_key(struct ctl_table *ctl, int write,
94666 void __user *buffer, size_t *lenp,
94667 loff_t *ppos)
94668 {
94669 - struct ctl_table tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
94670 + ctl_table_no_const tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
94671 struct tcp_fastopen_context *ctxt;
94672 int ret;
94673 u32 user_key[4]; /* 16 bytes, matching TCP_FASTOPEN_KEY_LENGTH */
94674 @@ -483,7 +485,7 @@ static struct ctl_table ipv4_table[] = {
94675 },
94676 {
94677 .procname = "ip_local_reserved_ports",
94678 - .data = NULL, /* initialized in sysctl_ipv4_init */
94679 + .data = sysctl_local_reserved_ports,
94680 .maxlen = 65536,
94681 .mode = 0644,
94682 .proc_handler = proc_do_large_bitmap,
94683 @@ -864,11 +866,10 @@ static struct ctl_table ipv4_net_table[] = {
94684
94685 static __net_init int ipv4_sysctl_init_net(struct net *net)
94686 {
94687 - struct ctl_table *table;
94688 + ctl_table_no_const *table = NULL;
94689
94690 - table = ipv4_net_table;
94691 if (!net_eq(net, &init_net)) {
94692 - table = kmemdup(table, sizeof(ipv4_net_table), GFP_KERNEL);
94693 + table = kmemdup(ipv4_net_table, sizeof(ipv4_net_table), GFP_KERNEL);
94694 if (table == NULL)
94695 goto err_alloc;
94696
94697 @@ -903,15 +904,17 @@ static __net_init int ipv4_sysctl_init_net(struct net *net)
94698
94699 tcp_init_mem(net);
94700
94701 - net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
94702 + if (!net_eq(net, &init_net))
94703 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
94704 + else
94705 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", ipv4_net_table);
94706 if (net->ipv4.ipv4_hdr == NULL)
94707 goto err_reg;
94708
94709 return 0;
94710
94711 err_reg:
94712 - if (!net_eq(net, &init_net))
94713 - kfree(table);
94714 + kfree(table);
94715 err_alloc:
94716 return -ENOMEM;
94717 }
94718 @@ -933,16 +936,6 @@ static __net_initdata struct pernet_operations ipv4_sysctl_ops = {
94719 static __init int sysctl_ipv4_init(void)
94720 {
94721 struct ctl_table_header *hdr;
94722 - struct ctl_table *i;
94723 -
94724 - for (i = ipv4_table; i->procname; i++) {
94725 - if (strcmp(i->procname, "ip_local_reserved_ports") == 0) {
94726 - i->data = sysctl_local_reserved_ports;
94727 - break;
94728 - }
94729 - }
94730 - if (!i->procname)
94731 - return -EINVAL;
94732
94733 hdr = register_net_sysctl(&init_net, "net/ipv4", ipv4_table);
94734 if (hdr == NULL)
94735 diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
94736 index 068c8fb..a755c52 100644
94737 --- a/net/ipv4/tcp_input.c
94738 +++ b/net/ipv4/tcp_input.c
94739 @@ -4435,7 +4435,7 @@ static struct sk_buff *tcp_collapse_one(struct sock *sk, struct sk_buff *skb,
94740 * simplifies code)
94741 */
94742 static void
94743 -tcp_collapse(struct sock *sk, struct sk_buff_head *list,
94744 +__intentional_overflow(5,6) tcp_collapse(struct sock *sk, struct sk_buff_head *list,
94745 struct sk_buff *head, struct sk_buff *tail,
94746 u32 start, u32 end)
94747 {
94748 @@ -5520,6 +5520,7 @@ discard:
94749 tcp_paws_reject(&tp->rx_opt, 0))
94750 goto discard_and_undo;
94751
94752 +#ifndef CONFIG_GRKERNSEC_NO_SIMULT_CONNECT
94753 if (th->syn) {
94754 /* We see SYN without ACK. It is attempt of
94755 * simultaneous connect with crossed SYNs.
94756 @@ -5570,6 +5571,7 @@ discard:
94757 goto discard;
94758 #endif
94759 }
94760 +#endif
94761 /* "fifth, if neither of the SYN or RST bits is set then
94762 * drop the segment and return."
94763 */
94764 @@ -5616,7 +5618,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
94765 goto discard;
94766
94767 if (th->syn) {
94768 - if (th->fin)
94769 + if (th->fin || th->urg || th->psh)
94770 goto discard;
94771 if (icsk->icsk_af_ops->conn_request(sk, skb) < 0)
94772 return 1;
94773 diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
94774 index 5031f68..91569e2 100644
94775 --- a/net/ipv4/tcp_ipv4.c
94776 +++ b/net/ipv4/tcp_ipv4.c
94777 @@ -91,6 +91,10 @@ int sysctl_tcp_low_latency __read_mostly;
94778 EXPORT_SYMBOL(sysctl_tcp_low_latency);
94779
94780
94781 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94782 +extern int grsec_enable_blackhole;
94783 +#endif
94784 +
94785 #ifdef CONFIG_TCP_MD5SIG
94786 static int tcp_v4_md5_hash_hdr(char *md5_hash, const struct tcp_md5sig_key *key,
94787 __be32 daddr, __be32 saddr, const struct tcphdr *th);
94788 @@ -1829,6 +1833,9 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb)
94789 return 0;
94790
94791 reset:
94792 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94793 + if (!grsec_enable_blackhole)
94794 +#endif
94795 tcp_v4_send_reset(rsk, skb);
94796 discard:
94797 kfree_skb(skb);
94798 @@ -1974,12 +1981,19 @@ int tcp_v4_rcv(struct sk_buff *skb)
94799 TCP_SKB_CB(skb)->sacked = 0;
94800
94801 sk = __inet_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
94802 - if (!sk)
94803 + if (!sk) {
94804 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94805 + ret = 1;
94806 +#endif
94807 goto no_tcp_socket;
94808 -
94809 + }
94810 process:
94811 - if (sk->sk_state == TCP_TIME_WAIT)
94812 + if (sk->sk_state == TCP_TIME_WAIT) {
94813 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94814 + ret = 2;
94815 +#endif
94816 goto do_time_wait;
94817 + }
94818
94819 if (unlikely(iph->ttl < inet_sk(sk)->min_ttl)) {
94820 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
94821 @@ -2033,6 +2047,10 @@ csum_error:
94822 bad_packet:
94823 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
94824 } else {
94825 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94826 + if (!grsec_enable_blackhole || (ret == 1 &&
94827 + (skb->dev->flags & IFF_LOOPBACK)))
94828 +#endif
94829 tcp_v4_send_reset(NULL, skb);
94830 }
94831
94832 diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
94833 index 58a3e69..7f0626e 100644
94834 --- a/net/ipv4/tcp_minisocks.c
94835 +++ b/net/ipv4/tcp_minisocks.c
94836 @@ -27,6 +27,10 @@
94837 #include <net/inet_common.h>
94838 #include <net/xfrm.h>
94839
94840 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94841 +extern int grsec_enable_blackhole;
94842 +#endif
94843 +
94844 int sysctl_tcp_syncookies __read_mostly = 1;
94845 EXPORT_SYMBOL(sysctl_tcp_syncookies);
94846
94847 @@ -711,7 +715,10 @@ embryonic_reset:
94848 * avoid becoming vulnerable to outside attack aiming at
94849 * resetting legit local connections.
94850 */
94851 - req->rsk_ops->send_reset(sk, skb);
94852 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94853 + if (!grsec_enable_blackhole)
94854 +#endif
94855 + req->rsk_ops->send_reset(sk, skb);
94856 } else if (fastopen) { /* received a valid RST pkt */
94857 reqsk_fastopen_remove(sk, req, true);
94858 tcp_reset(sk);
94859 diff --git a/net/ipv4/tcp_probe.c b/net/ipv4/tcp_probe.c
94860 index 611beab..c4b6e1d 100644
94861 --- a/net/ipv4/tcp_probe.c
94862 +++ b/net/ipv4/tcp_probe.c
94863 @@ -245,7 +245,7 @@ static ssize_t tcpprobe_read(struct file *file, char __user *buf,
94864 if (cnt + width >= len)
94865 break;
94866
94867 - if (copy_to_user(buf + cnt, tbuf, width))
94868 + if (width > sizeof tbuf || copy_to_user(buf + cnt, tbuf, width))
94869 return -EFAULT;
94870 cnt += width;
94871 }
94872 diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
94873 index 4b85e6f..22f9ac9 100644
94874 --- a/net/ipv4/tcp_timer.c
94875 +++ b/net/ipv4/tcp_timer.c
94876 @@ -22,6 +22,10 @@
94877 #include <linux/gfp.h>
94878 #include <net/tcp.h>
94879
94880 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94881 +extern int grsec_lastack_retries;
94882 +#endif
94883 +
94884 int sysctl_tcp_syn_retries __read_mostly = TCP_SYN_RETRIES;
94885 int sysctl_tcp_synack_retries __read_mostly = TCP_SYNACK_RETRIES;
94886 int sysctl_tcp_keepalive_time __read_mostly = TCP_KEEPALIVE_TIME;
94887 @@ -185,6 +189,13 @@ static int tcp_write_timeout(struct sock *sk)
94888 }
94889 }
94890
94891 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94892 + if ((sk->sk_state == TCP_LAST_ACK) &&
94893 + (grsec_lastack_retries > 0) &&
94894 + (grsec_lastack_retries < retry_until))
94895 + retry_until = grsec_lastack_retries;
94896 +#endif
94897 +
94898 if (retransmits_timed_out(sk, retry_until,
94899 syn_set ? 0 : icsk->icsk_user_timeout, syn_set)) {
94900 /* Has it gone just too far? */
94901 diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
94902 index 5e2c2f1..6473c22 100644
94903 --- a/net/ipv4/udp.c
94904 +++ b/net/ipv4/udp.c
94905 @@ -87,6 +87,7 @@
94906 #include <linux/types.h>
94907 #include <linux/fcntl.h>
94908 #include <linux/module.h>
94909 +#include <linux/security.h>
94910 #include <linux/socket.h>
94911 #include <linux/sockios.h>
94912 #include <linux/igmp.h>
94913 @@ -112,6 +113,10 @@
94914 #include <net/busy_poll.h>
94915 #include "udp_impl.h"
94916
94917 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94918 +extern int grsec_enable_blackhole;
94919 +#endif
94920 +
94921 struct udp_table udp_table __read_mostly;
94922 EXPORT_SYMBOL(udp_table);
94923
94924 @@ -595,6 +600,9 @@ found:
94925 return s;
94926 }
94927
94928 +extern int gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb);
94929 +extern int gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr);
94930 +
94931 /*
94932 * This routine is called by the ICMP module when it gets some
94933 * sort of error condition. If err < 0 then the socket should
94934 @@ -892,9 +900,18 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
94935 dport = usin->sin_port;
94936 if (dport == 0)
94937 return -EINVAL;
94938 +
94939 + err = gr_search_udp_sendmsg(sk, usin);
94940 + if (err)
94941 + return err;
94942 } else {
94943 if (sk->sk_state != TCP_ESTABLISHED)
94944 return -EDESTADDRREQ;
94945 +
94946 + err = gr_search_udp_sendmsg(sk, NULL);
94947 + if (err)
94948 + return err;
94949 +
94950 daddr = inet->inet_daddr;
94951 dport = inet->inet_dport;
94952 /* Open fast path for connected socket.
94953 @@ -1141,7 +1158,7 @@ static unsigned int first_packet_length(struct sock *sk)
94954 IS_UDPLITE(sk));
94955 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
94956 IS_UDPLITE(sk));
94957 - atomic_inc(&sk->sk_drops);
94958 + atomic_inc_unchecked(&sk->sk_drops);
94959 __skb_unlink(skb, rcvq);
94960 __skb_queue_tail(&list_kill, skb);
94961 }
94962 @@ -1221,6 +1238,10 @@ try_again:
94963 if (!skb)
94964 goto out;
94965
94966 + err = gr_search_udp_recvmsg(sk, skb);
94967 + if (err)
94968 + goto out_free;
94969 +
94970 ulen = skb->len - sizeof(struct udphdr);
94971 copied = len;
94972 if (copied > ulen)
94973 @@ -1254,7 +1275,7 @@ try_again:
94974 if (unlikely(err)) {
94975 trace_kfree_skb(skb, udp_recvmsg);
94976 if (!peeked) {
94977 - atomic_inc(&sk->sk_drops);
94978 + atomic_inc_unchecked(&sk->sk_drops);
94979 UDP_INC_STATS_USER(sock_net(sk),
94980 UDP_MIB_INERRORS, is_udplite);
94981 }
94982 @@ -1542,7 +1563,7 @@ csum_error:
94983 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_CSUMERRORS, is_udplite);
94984 drop:
94985 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
94986 - atomic_inc(&sk->sk_drops);
94987 + atomic_inc_unchecked(&sk->sk_drops);
94988 kfree_skb(skb);
94989 return -1;
94990 }
94991 @@ -1561,7 +1582,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
94992 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
94993
94994 if (!skb1) {
94995 - atomic_inc(&sk->sk_drops);
94996 + atomic_inc_unchecked(&sk->sk_drops);
94997 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
94998 IS_UDPLITE(sk));
94999 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
95000 @@ -1733,6 +1754,9 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
95001 goto csum_error;
95002
95003 UDP_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
95004 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
95005 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
95006 +#endif
95007 icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0);
95008
95009 /*
95010 @@ -2165,7 +2189,7 @@ static void udp4_format_sock(struct sock *sp, struct seq_file *f,
95011 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
95012 0, sock_i_ino(sp),
95013 atomic_read(&sp->sk_refcnt), sp,
95014 - atomic_read(&sp->sk_drops), len);
95015 + atomic_read_unchecked(&sp->sk_drops), len);
95016 }
95017
95018 int udp4_seq_show(struct seq_file *seq, void *v)
95019 diff --git a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c
95020 index adf9983..8e45d0a 100644
95021 --- a/net/ipv4/xfrm4_policy.c
95022 +++ b/net/ipv4/xfrm4_policy.c
95023 @@ -186,11 +186,11 @@ _decode_session4(struct sk_buff *skb, struct flowi *fl, int reverse)
95024 fl4->flowi4_tos = iph->tos;
95025 }
95026
95027 -static inline int xfrm4_garbage_collect(struct dst_ops *ops)
95028 +static int xfrm4_garbage_collect(struct dst_ops *ops)
95029 {
95030 struct net *net = container_of(ops, struct net, xfrm.xfrm4_dst_ops);
95031
95032 - xfrm4_policy_afinfo.garbage_collect(net);
95033 + xfrm_garbage_collect_deferred(net);
95034 return (dst_entries_get_slow(ops) > ops->gc_thresh * 2);
95035 }
95036
95037 @@ -269,19 +269,18 @@ static struct ctl_table xfrm4_policy_table[] = {
95038
95039 static int __net_init xfrm4_net_init(struct net *net)
95040 {
95041 - struct ctl_table *table;
95042 + ctl_table_no_const *table = NULL;
95043 struct ctl_table_header *hdr;
95044
95045 - table = xfrm4_policy_table;
95046 if (!net_eq(net, &init_net)) {
95047 - table = kmemdup(table, sizeof(xfrm4_policy_table), GFP_KERNEL);
95048 + table = kmemdup(xfrm4_policy_table, sizeof(xfrm4_policy_table), GFP_KERNEL);
95049 if (!table)
95050 goto err_alloc;
95051
95052 table[0].data = &net->xfrm.xfrm4_dst_ops.gc_thresh;
95053 - }
95054 -
95055 - hdr = register_net_sysctl(net, "net/ipv4", table);
95056 + hdr = register_net_sysctl(net, "net/ipv4", table);
95057 + } else
95058 + hdr = register_net_sysctl(net, "net/ipv4", xfrm4_policy_table);
95059 if (!hdr)
95060 goto err_reg;
95061
95062 @@ -289,8 +288,7 @@ static int __net_init xfrm4_net_init(struct net *net)
95063 return 0;
95064
95065 err_reg:
95066 - if (!net_eq(net, &init_net))
95067 - kfree(table);
95068 + kfree(table);
95069 err_alloc:
95070 return -ENOMEM;
95071 }
95072 diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
95073 index cd3fb30..b7dfef7 100644
95074 --- a/net/ipv6/addrconf.c
95075 +++ b/net/ipv6/addrconf.c
95076 @@ -586,7 +586,7 @@ static int inet6_netconf_dump_devconf(struct sk_buff *skb,
95077 idx = 0;
95078 head = &net->dev_index_head[h];
95079 rcu_read_lock();
95080 - cb->seq = atomic_read(&net->ipv6.dev_addr_genid) ^
95081 + cb->seq = atomic_read_unchecked(&net->ipv6.dev_addr_genid) ^
95082 net->dev_base_seq;
95083 hlist_for_each_entry_rcu(dev, head, index_hlist) {
95084 if (idx < s_idx)
95085 @@ -2364,7 +2364,7 @@ int addrconf_set_dstaddr(struct net *net, void __user *arg)
95086 p.iph.ihl = 5;
95087 p.iph.protocol = IPPROTO_IPV6;
95088 p.iph.ttl = 64;
95089 - ifr.ifr_ifru.ifru_data = (__force void __user *)&p;
95090 + ifr.ifr_ifru.ifru_data = (void __force_user *)&p;
95091
95092 if (ops->ndo_do_ioctl) {
95093 mm_segment_t oldfs = get_fs();
95094 @@ -3977,7 +3977,7 @@ static int inet6_dump_addr(struct sk_buff *skb, struct netlink_callback *cb,
95095 s_ip_idx = ip_idx = cb->args[2];
95096
95097 rcu_read_lock();
95098 - cb->seq = atomic_read(&net->ipv6.dev_addr_genid) ^ net->dev_base_seq;
95099 + cb->seq = atomic_read_unchecked(&net->ipv6.dev_addr_genid) ^ net->dev_base_seq;
95100 for (h = s_h; h < NETDEV_HASHENTRIES; h++, s_idx = 0) {
95101 idx = 0;
95102 head = &net->dev_index_head[h];
95103 @@ -4603,7 +4603,7 @@ static void __ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
95104 dst_free(&ifp->rt->dst);
95105 break;
95106 }
95107 - atomic_inc(&net->ipv6.dev_addr_genid);
95108 + atomic_inc_unchecked(&net->ipv6.dev_addr_genid);
95109 rt_genid_bump_ipv6(net);
95110 }
95111
95112 @@ -4624,7 +4624,7 @@ int addrconf_sysctl_forward(struct ctl_table *ctl, int write,
95113 int *valp = ctl->data;
95114 int val = *valp;
95115 loff_t pos = *ppos;
95116 - struct ctl_table lctl;
95117 + ctl_table_no_const lctl;
95118 int ret;
95119
95120 /*
95121 @@ -4709,7 +4709,7 @@ int addrconf_sysctl_disable(struct ctl_table *ctl, int write,
95122 int *valp = ctl->data;
95123 int val = *valp;
95124 loff_t pos = *ppos;
95125 - struct ctl_table lctl;
95126 + ctl_table_no_const lctl;
95127 int ret;
95128
95129 /*
95130 diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
95131 index 8132b44..b8eca70 100644
95132 --- a/net/ipv6/af_inet6.c
95133 +++ b/net/ipv6/af_inet6.c
95134 @@ -767,7 +767,7 @@ static int __net_init inet6_net_init(struct net *net)
95135
95136 net->ipv6.sysctl.bindv6only = 0;
95137 net->ipv6.sysctl.icmpv6_time = 1*HZ;
95138 - atomic_set(&net->ipv6.rt_genid, 0);
95139 + atomic_set_unchecked(&net->ipv6.rt_genid, 0);
95140
95141 err = ipv6_init_mibs(net);
95142 if (err)
95143 diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c
95144 index c66c6df..f375d3c 100644
95145 --- a/net/ipv6/datagram.c
95146 +++ b/net/ipv6/datagram.c
95147 @@ -908,5 +908,5 @@ void ip6_dgram_sock_seq_show(struct seq_file *seq, struct sock *sp,
95148 0,
95149 sock_i_ino(sp),
95150 atomic_read(&sp->sk_refcnt), sp,
95151 - atomic_read(&sp->sk_drops));
95152 + atomic_read_unchecked(&sp->sk_drops));
95153 }
95154 diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
95155 index eef8d94..cfa1852 100644
95156 --- a/net/ipv6/icmp.c
95157 +++ b/net/ipv6/icmp.c
95158 @@ -997,7 +997,7 @@ struct ctl_table ipv6_icmp_table_template[] = {
95159
95160 struct ctl_table * __net_init ipv6_icmp_sysctl_init(struct net *net)
95161 {
95162 - struct ctl_table *table;
95163 + ctl_table_no_const *table;
95164
95165 table = kmemdup(ipv6_icmp_table_template,
95166 sizeof(ipv6_icmp_table_template),
95167 diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
95168 index bf4a9a0..e5f6ac5 100644
95169 --- a/net/ipv6/ip6_gre.c
95170 +++ b/net/ipv6/ip6_gre.c
95171 @@ -74,7 +74,7 @@ struct ip6gre_net {
95172 struct net_device *fb_tunnel_dev;
95173 };
95174
95175 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly;
95176 +static struct rtnl_link_ops ip6gre_link_ops;
95177 static int ip6gre_tunnel_init(struct net_device *dev);
95178 static void ip6gre_tunnel_setup(struct net_device *dev);
95179 static void ip6gre_tunnel_link(struct ip6gre_net *ign, struct ip6_tnl *t);
95180 @@ -1286,7 +1286,7 @@ static void ip6gre_fb_tunnel_init(struct net_device *dev)
95181 }
95182
95183
95184 -static struct inet6_protocol ip6gre_protocol __read_mostly = {
95185 +static struct inet6_protocol ip6gre_protocol = {
95186 .handler = ip6gre_rcv,
95187 .err_handler = ip6gre_err,
95188 .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,
95189 @@ -1622,7 +1622,7 @@ static const struct nla_policy ip6gre_policy[IFLA_GRE_MAX + 1] = {
95190 [IFLA_GRE_FLAGS] = { .type = NLA_U32 },
95191 };
95192
95193 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
95194 +static struct rtnl_link_ops ip6gre_link_ops = {
95195 .kind = "ip6gre",
95196 .maxtype = IFLA_GRE_MAX,
95197 .policy = ip6gre_policy,
95198 @@ -1635,7 +1635,7 @@ static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
95199 .fill_info = ip6gre_fill_info,
95200 };
95201
95202 -static struct rtnl_link_ops ip6gre_tap_ops __read_mostly = {
95203 +static struct rtnl_link_ops ip6gre_tap_ops = {
95204 .kind = "ip6gretap",
95205 .maxtype = IFLA_GRE_MAX,
95206 .policy = ip6gre_policy,
95207 diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
95208 index c1e11b5..568e633 100644
95209 --- a/net/ipv6/ip6_tunnel.c
95210 +++ b/net/ipv6/ip6_tunnel.c
95211 @@ -89,7 +89,7 @@ static u32 HASH(const struct in6_addr *addr1, const struct in6_addr *addr2)
95212
95213 static int ip6_tnl_dev_init(struct net_device *dev);
95214 static void ip6_tnl_dev_setup(struct net_device *dev);
95215 -static struct rtnl_link_ops ip6_link_ops __read_mostly;
95216 +static struct rtnl_link_ops ip6_link_ops;
95217
95218 static int ip6_tnl_net_id __read_mostly;
95219 struct ip6_tnl_net {
95220 @@ -1699,7 +1699,7 @@ static const struct nla_policy ip6_tnl_policy[IFLA_IPTUN_MAX + 1] = {
95221 [IFLA_IPTUN_PROTO] = { .type = NLA_U8 },
95222 };
95223
95224 -static struct rtnl_link_ops ip6_link_ops __read_mostly = {
95225 +static struct rtnl_link_ops ip6_link_ops = {
95226 .kind = "ip6tnl",
95227 .maxtype = IFLA_IPTUN_MAX,
95228 .policy = ip6_tnl_policy,
95229 diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
95230 index d1e2e8e..51c19ae 100644
95231 --- a/net/ipv6/ipv6_sockglue.c
95232 +++ b/net/ipv6/ipv6_sockglue.c
95233 @@ -991,7 +991,7 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
95234 if (sk->sk_type != SOCK_STREAM)
95235 return -ENOPROTOOPT;
95236
95237 - msg.msg_control = optval;
95238 + msg.msg_control = (void __force_kernel *)optval;
95239 msg.msg_controllen = len;
95240 msg.msg_flags = flags;
95241
95242 diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
95243 index 44400c2..8e11f52 100644
95244 --- a/net/ipv6/netfilter/ip6_tables.c
95245 +++ b/net/ipv6/netfilter/ip6_tables.c
95246 @@ -1078,14 +1078,14 @@ static int compat_table_info(const struct xt_table_info *info,
95247 #endif
95248
95249 static int get_info(struct net *net, void __user *user,
95250 - const int *len, int compat)
95251 + int len, int compat)
95252 {
95253 char name[XT_TABLE_MAXNAMELEN];
95254 struct xt_table *t;
95255 int ret;
95256
95257 - if (*len != sizeof(struct ip6t_getinfo)) {
95258 - duprintf("length %u != %zu\n", *len,
95259 + if (len != sizeof(struct ip6t_getinfo)) {
95260 + duprintf("length %u != %zu\n", len,
95261 sizeof(struct ip6t_getinfo));
95262 return -EINVAL;
95263 }
95264 @@ -1122,7 +1122,7 @@ static int get_info(struct net *net, void __user *user,
95265 info.size = private->size;
95266 strcpy(info.name, name);
95267
95268 - if (copy_to_user(user, &info, *len) != 0)
95269 + if (copy_to_user(user, &info, len) != 0)
95270 ret = -EFAULT;
95271 else
95272 ret = 0;
95273 @@ -1976,7 +1976,7 @@ compat_do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
95274
95275 switch (cmd) {
95276 case IP6T_SO_GET_INFO:
95277 - ret = get_info(sock_net(sk), user, len, 1);
95278 + ret = get_info(sock_net(sk), user, *len, 1);
95279 break;
95280 case IP6T_SO_GET_ENTRIES:
95281 ret = compat_get_entries(sock_net(sk), user, len);
95282 @@ -2023,7 +2023,7 @@ do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
95283
95284 switch (cmd) {
95285 case IP6T_SO_GET_INFO:
95286 - ret = get_info(sock_net(sk), user, len, 0);
95287 + ret = get_info(sock_net(sk), user, *len, 0);
95288 break;
95289
95290 case IP6T_SO_GET_ENTRIES:
95291 diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c
95292 index 253566a..9fa50c7 100644
95293 --- a/net/ipv6/netfilter/nf_conntrack_reasm.c
95294 +++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
95295 @@ -90,12 +90,11 @@ static struct ctl_table nf_ct_frag6_sysctl_table[] = {
95296
95297 static int nf_ct_frag6_sysctl_register(struct net *net)
95298 {
95299 - struct ctl_table *table;
95300 + ctl_table_no_const *table = NULL;
95301 struct ctl_table_header *hdr;
95302
95303 - table = nf_ct_frag6_sysctl_table;
95304 if (!net_eq(net, &init_net)) {
95305 - table = kmemdup(table, sizeof(nf_ct_frag6_sysctl_table),
95306 + table = kmemdup(nf_ct_frag6_sysctl_table, sizeof(nf_ct_frag6_sysctl_table),
95307 GFP_KERNEL);
95308 if (table == NULL)
95309 goto err_alloc;
95310 @@ -103,9 +102,9 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
95311 table[0].data = &net->nf_frag.frags.timeout;
95312 table[1].data = &net->nf_frag.frags.low_thresh;
95313 table[2].data = &net->nf_frag.frags.high_thresh;
95314 - }
95315 -
95316 - hdr = register_net_sysctl(net, "net/netfilter", table);
95317 + hdr = register_net_sysctl(net, "net/netfilter", table);
95318 + } else
95319 + hdr = register_net_sysctl(net, "net/netfilter", nf_ct_frag6_sysctl_table);
95320 if (hdr == NULL)
95321 goto err_reg;
95322
95323 @@ -113,8 +112,7 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
95324 return 0;
95325
95326 err_reg:
95327 - if (!net_eq(net, &init_net))
95328 - kfree(table);
95329 + kfree(table);
95330 err_alloc:
95331 return -ENOMEM;
95332 }
95333 diff --git a/net/ipv6/output_core.c b/net/ipv6/output_core.c
95334 index 827f795..7e28e82 100644
95335 --- a/net/ipv6/output_core.c
95336 +++ b/net/ipv6/output_core.c
95337 @@ -9,8 +9,8 @@
95338
95339 void ipv6_select_ident(struct frag_hdr *fhdr, struct rt6_info *rt)
95340 {
95341 - static atomic_t ipv6_fragmentation_id;
95342 - int old, new;
95343 + static atomic_unchecked_t ipv6_fragmentation_id;
95344 + int id;
95345
95346 #if IS_ENABLED(CONFIG_IPV6)
95347 if (rt && !(rt->dst.flags & DST_NOPEER)) {
95348 @@ -26,13 +26,10 @@ void ipv6_select_ident(struct frag_hdr *fhdr, struct rt6_info *rt)
95349 }
95350 }
95351 #endif
95352 - do {
95353 - old = atomic_read(&ipv6_fragmentation_id);
95354 - new = old + 1;
95355 - if (!new)
95356 - new = 1;
95357 - } while (atomic_cmpxchg(&ipv6_fragmentation_id, old, new) != old);
95358 - fhdr->identification = htonl(new);
95359 + id = atomic_inc_return_unchecked(&ipv6_fragmentation_id);
95360 + if (!id)
95361 + id = atomic_inc_return_unchecked(&ipv6_fragmentation_id);
95362 + fhdr->identification = htonl(id);
95363 }
95364 EXPORT_SYMBOL(ipv6_select_ident);
95365
95366 diff --git a/net/ipv6/ping.c b/net/ipv6/ping.c
95367 index 7856e96..75ebc7f 100644
95368 --- a/net/ipv6/ping.c
95369 +++ b/net/ipv6/ping.c
95370 @@ -246,6 +246,22 @@ static struct pernet_operations ping_v6_net_ops = {
95371 };
95372 #endif
95373
95374 +static struct pingv6_ops real_pingv6_ops = {
95375 + .ipv6_recv_error = ipv6_recv_error,
95376 + .ip6_datagram_recv_ctl = ip6_datagram_recv_ctl,
95377 + .icmpv6_err_convert = icmpv6_err_convert,
95378 + .ipv6_icmp_error = ipv6_icmp_error,
95379 + .ipv6_chk_addr = ipv6_chk_addr,
95380 +};
95381 +
95382 +static struct pingv6_ops dummy_pingv6_ops = {
95383 + .ipv6_recv_error = dummy_ipv6_recv_error,
95384 + .ip6_datagram_recv_ctl = dummy_ip6_datagram_recv_ctl,
95385 + .icmpv6_err_convert = dummy_icmpv6_err_convert,
95386 + .ipv6_icmp_error = dummy_ipv6_icmp_error,
95387 + .ipv6_chk_addr = dummy_ipv6_chk_addr,
95388 +};
95389 +
95390 int __init pingv6_init(void)
95391 {
95392 #ifdef CONFIG_PROC_FS
95393 @@ -253,11 +269,7 @@ int __init pingv6_init(void)
95394 if (ret)
95395 return ret;
95396 #endif
95397 - pingv6_ops.ipv6_recv_error = ipv6_recv_error;
95398 - pingv6_ops.ip6_datagram_recv_ctl = ip6_datagram_recv_ctl;
95399 - pingv6_ops.icmpv6_err_convert = icmpv6_err_convert;
95400 - pingv6_ops.ipv6_icmp_error = ipv6_icmp_error;
95401 - pingv6_ops.ipv6_chk_addr = ipv6_chk_addr;
95402 + pingv6_ops = &real_pingv6_ops;
95403 return inet6_register_protosw(&pingv6_protosw);
95404 }
95405
95406 @@ -266,11 +278,7 @@ int __init pingv6_init(void)
95407 */
95408 void pingv6_exit(void)
95409 {
95410 - pingv6_ops.ipv6_recv_error = dummy_ipv6_recv_error;
95411 - pingv6_ops.ip6_datagram_recv_ctl = dummy_ip6_datagram_recv_ctl;
95412 - pingv6_ops.icmpv6_err_convert = dummy_icmpv6_err_convert;
95413 - pingv6_ops.ipv6_icmp_error = dummy_ipv6_icmp_error;
95414 - pingv6_ops.ipv6_chk_addr = dummy_ipv6_chk_addr;
95415 + pingv6_ops = &dummy_pingv6_ops;
95416 #ifdef CONFIG_PROC_FS
95417 unregister_pernet_subsys(&ping_v6_net_ops);
95418 #endif
95419 diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
95420 index 430067c..4adf088 100644
95421 --- a/net/ipv6/raw.c
95422 +++ b/net/ipv6/raw.c
95423 @@ -385,7 +385,7 @@ static inline int rawv6_rcv_skb(struct sock *sk, struct sk_buff *skb)
95424 {
95425 if ((raw6_sk(sk)->checksum || rcu_access_pointer(sk->sk_filter)) &&
95426 skb_checksum_complete(skb)) {
95427 - atomic_inc(&sk->sk_drops);
95428 + atomic_inc_unchecked(&sk->sk_drops);
95429 kfree_skb(skb);
95430 return NET_RX_DROP;
95431 }
95432 @@ -413,7 +413,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
95433 struct raw6_sock *rp = raw6_sk(sk);
95434
95435 if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) {
95436 - atomic_inc(&sk->sk_drops);
95437 + atomic_inc_unchecked(&sk->sk_drops);
95438 kfree_skb(skb);
95439 return NET_RX_DROP;
95440 }
95441 @@ -437,7 +437,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
95442
95443 if (inet->hdrincl) {
95444 if (skb_checksum_complete(skb)) {
95445 - atomic_inc(&sk->sk_drops);
95446 + atomic_inc_unchecked(&sk->sk_drops);
95447 kfree_skb(skb);
95448 return NET_RX_DROP;
95449 }
95450 @@ -607,7 +607,7 @@ out:
95451 return err;
95452 }
95453
95454 -static int rawv6_send_hdrinc(struct sock *sk, void *from, int length,
95455 +static int rawv6_send_hdrinc(struct sock *sk, void *from, unsigned int length,
95456 struct flowi6 *fl6, struct dst_entry **dstp,
95457 unsigned int flags)
95458 {
95459 @@ -920,12 +920,15 @@ do_confirm:
95460 static int rawv6_seticmpfilter(struct sock *sk, int level, int optname,
95461 char __user *optval, int optlen)
95462 {
95463 + struct icmp6_filter filter;
95464 +
95465 switch (optname) {
95466 case ICMPV6_FILTER:
95467 if (optlen > sizeof(struct icmp6_filter))
95468 optlen = sizeof(struct icmp6_filter);
95469 - if (copy_from_user(&raw6_sk(sk)->filter, optval, optlen))
95470 + if (copy_from_user(&filter, optval, optlen))
95471 return -EFAULT;
95472 + raw6_sk(sk)->filter = filter;
95473 return 0;
95474 default:
95475 return -ENOPROTOOPT;
95476 @@ -938,6 +941,7 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
95477 char __user *optval, int __user *optlen)
95478 {
95479 int len;
95480 + struct icmp6_filter filter;
95481
95482 switch (optname) {
95483 case ICMPV6_FILTER:
95484 @@ -949,7 +953,8 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
95485 len = sizeof(struct icmp6_filter);
95486 if (put_user(len, optlen))
95487 return -EFAULT;
95488 - if (copy_to_user(optval, &raw6_sk(sk)->filter, len))
95489 + filter = raw6_sk(sk)->filter;
95490 + if (len > sizeof filter || copy_to_user(optval, &filter, len))
95491 return -EFAULT;
95492 return 0;
95493 default:
95494 diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
95495 index 1aeb473..bea761c 100644
95496 --- a/net/ipv6/reassembly.c
95497 +++ b/net/ipv6/reassembly.c
95498 @@ -626,12 +626,11 @@ static struct ctl_table ip6_frags_ctl_table[] = {
95499
95500 static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
95501 {
95502 - struct ctl_table *table;
95503 + ctl_table_no_const *table = NULL;
95504 struct ctl_table_header *hdr;
95505
95506 - table = ip6_frags_ns_ctl_table;
95507 if (!net_eq(net, &init_net)) {
95508 - table = kmemdup(table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
95509 + table = kmemdup(ip6_frags_ns_ctl_table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
95510 if (table == NULL)
95511 goto err_alloc;
95512
95513 @@ -642,9 +641,10 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
95514 /* Don't export sysctls to unprivileged users */
95515 if (net->user_ns != &init_user_ns)
95516 table[0].procname = NULL;
95517 - }
95518 + hdr = register_net_sysctl(net, "net/ipv6", table);
95519 + } else
95520 + hdr = register_net_sysctl(net, "net/ipv6", ip6_frags_ns_ctl_table);
95521
95522 - hdr = register_net_sysctl(net, "net/ipv6", table);
95523 if (hdr == NULL)
95524 goto err_reg;
95525
95526 @@ -652,8 +652,7 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
95527 return 0;
95528
95529 err_reg:
95530 - if (!net_eq(net, &init_net))
95531 - kfree(table);
95532 + kfree(table);
95533 err_alloc:
95534 return -ENOMEM;
95535 }
95536 diff --git a/net/ipv6/route.c b/net/ipv6/route.c
95537 index 77308af..36ed509 100644
95538 --- a/net/ipv6/route.c
95539 +++ b/net/ipv6/route.c
95540 @@ -3009,7 +3009,7 @@ struct ctl_table ipv6_route_table_template[] = {
95541
95542 struct ctl_table * __net_init ipv6_route_sysctl_init(struct net *net)
95543 {
95544 - struct ctl_table *table;
95545 + ctl_table_no_const *table;
95546
95547 table = kmemdup(ipv6_route_table_template,
95548 sizeof(ipv6_route_table_template),
95549 diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
95550 index b433884..3875266 100644
95551 --- a/net/ipv6/sit.c
95552 +++ b/net/ipv6/sit.c
95553 @@ -74,7 +74,7 @@ static void ipip6_tunnel_setup(struct net_device *dev);
95554 static void ipip6_dev_free(struct net_device *dev);
95555 static bool check_6rd(struct ip_tunnel *tunnel, const struct in6_addr *v6dst,
95556 __be32 *v4dst);
95557 -static struct rtnl_link_ops sit_link_ops __read_mostly;
95558 +static struct rtnl_link_ops sit_link_ops;
95559
95560 static int sit_net_id __read_mostly;
95561 struct sit_net {
95562 @@ -1603,7 +1603,7 @@ static void ipip6_dellink(struct net_device *dev, struct list_head *head)
95563 unregister_netdevice_queue(dev, head);
95564 }
95565
95566 -static struct rtnl_link_ops sit_link_ops __read_mostly = {
95567 +static struct rtnl_link_ops sit_link_ops = {
95568 .kind = "sit",
95569 .maxtype = IFLA_IPTUN_MAX,
95570 .policy = ipip6_policy,
95571 diff --git a/net/ipv6/sysctl_net_ipv6.c b/net/ipv6/sysctl_net_ipv6.c
95572 index 107b2f1..72741a9 100644
95573 --- a/net/ipv6/sysctl_net_ipv6.c
95574 +++ b/net/ipv6/sysctl_net_ipv6.c
95575 @@ -40,7 +40,7 @@ static struct ctl_table ipv6_rotable[] = {
95576
95577 static int __net_init ipv6_sysctl_net_init(struct net *net)
95578 {
95579 - struct ctl_table *ipv6_table;
95580 + ctl_table_no_const *ipv6_table;
95581 struct ctl_table *ipv6_route_table;
95582 struct ctl_table *ipv6_icmp_table;
95583 int err;
95584 diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
95585 index 5c71501..7e8d5d3 100644
95586 --- a/net/ipv6/tcp_ipv6.c
95587 +++ b/net/ipv6/tcp_ipv6.c
95588 @@ -104,6 +104,10 @@ static void inet6_sk_rx_dst_set(struct sock *sk, const struct sk_buff *skb)
95589 inet6_sk(sk)->rx_dst_cookie = rt->rt6i_node->fn_sernum;
95590 }
95591
95592 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
95593 +extern int grsec_enable_blackhole;
95594 +#endif
95595 +
95596 static void tcp_v6_hash(struct sock *sk)
95597 {
95598 if (sk->sk_state != TCP_CLOSE) {
95599 @@ -1397,6 +1401,9 @@ static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
95600 return 0;
95601
95602 reset:
95603 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
95604 + if (!grsec_enable_blackhole)
95605 +#endif
95606 tcp_v6_send_reset(sk, skb);
95607 discard:
95608 if (opt_skb)
95609 @@ -1479,12 +1486,20 @@ static int tcp_v6_rcv(struct sk_buff *skb)
95610 TCP_SKB_CB(skb)->sacked = 0;
95611
95612 sk = __inet6_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
95613 - if (!sk)
95614 + if (!sk) {
95615 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
95616 + ret = 1;
95617 +#endif
95618 goto no_tcp_socket;
95619 + }
95620
95621 process:
95622 - if (sk->sk_state == TCP_TIME_WAIT)
95623 + if (sk->sk_state == TCP_TIME_WAIT) {
95624 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
95625 + ret = 2;
95626 +#endif
95627 goto do_time_wait;
95628 + }
95629
95630 if (hdr->hop_limit < inet6_sk(sk)->min_hopcount) {
95631 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
95632 @@ -1536,6 +1551,10 @@ csum_error:
95633 bad_packet:
95634 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
95635 } else {
95636 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
95637 + if (!grsec_enable_blackhole || (ret == 1 &&
95638 + (skb->dev->flags & IFF_LOOPBACK)))
95639 +#endif
95640 tcp_v6_send_reset(NULL, skb);
95641 }
95642
95643 diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
95644 index 3d2758d..626c422 100644
95645 --- a/net/ipv6/udp.c
95646 +++ b/net/ipv6/udp.c
95647 @@ -53,6 +53,10 @@
95648 #include <trace/events/skb.h>
95649 #include "udp_impl.h"
95650
95651 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
95652 +extern int grsec_enable_blackhole;
95653 +#endif
95654 +
95655 int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
95656 {
95657 const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
95658 @@ -417,7 +421,7 @@ try_again:
95659 if (unlikely(err)) {
95660 trace_kfree_skb(skb, udpv6_recvmsg);
95661 if (!peeked) {
95662 - atomic_inc(&sk->sk_drops);
95663 + atomic_inc_unchecked(&sk->sk_drops);
95664 if (is_udp4)
95665 UDP_INC_STATS_USER(sock_net(sk),
95666 UDP_MIB_INERRORS,
95667 @@ -665,7 +669,7 @@ csum_error:
95668 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_CSUMERRORS, is_udplite);
95669 drop:
95670 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
95671 - atomic_inc(&sk->sk_drops);
95672 + atomic_inc_unchecked(&sk->sk_drops);
95673 kfree_skb(skb);
95674 return -1;
95675 }
95676 @@ -723,7 +727,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
95677 if (likely(skb1 == NULL))
95678 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
95679 if (!skb1) {
95680 - atomic_inc(&sk->sk_drops);
95681 + atomic_inc_unchecked(&sk->sk_drops);
95682 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
95683 IS_UDPLITE(sk));
95684 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
95685 @@ -863,6 +867,9 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
95686 goto csum_error;
95687
95688 UDP6_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
95689 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
95690 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
95691 +#endif
95692 icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_PORT_UNREACH, 0);
95693
95694 kfree_skb(skb);
95695 diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c
95696 index 550b195..6acea83 100644
95697 --- a/net/ipv6/xfrm6_policy.c
95698 +++ b/net/ipv6/xfrm6_policy.c
95699 @@ -212,11 +212,11 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl, int reverse)
95700 }
95701 }
95702
95703 -static inline int xfrm6_garbage_collect(struct dst_ops *ops)
95704 +static int xfrm6_garbage_collect(struct dst_ops *ops)
95705 {
95706 struct net *net = container_of(ops, struct net, xfrm.xfrm6_dst_ops);
95707
95708 - xfrm6_policy_afinfo.garbage_collect(net);
95709 + xfrm_garbage_collect_deferred(net);
95710 return dst_entries_get_fast(ops) > ops->gc_thresh * 2;
95711 }
95712
95713 @@ -329,19 +329,19 @@ static struct ctl_table xfrm6_policy_table[] = {
95714
95715 static int __net_init xfrm6_net_init(struct net *net)
95716 {
95717 - struct ctl_table *table;
95718 + ctl_table_no_const *table = NULL;
95719 struct ctl_table_header *hdr;
95720
95721 - table = xfrm6_policy_table;
95722 if (!net_eq(net, &init_net)) {
95723 - table = kmemdup(table, sizeof(xfrm6_policy_table), GFP_KERNEL);
95724 + table = kmemdup(xfrm6_policy_table, sizeof(xfrm6_policy_table), GFP_KERNEL);
95725 if (!table)
95726 goto err_alloc;
95727
95728 table[0].data = &net->xfrm.xfrm6_dst_ops.gc_thresh;
95729 - }
95730 + hdr = register_net_sysctl(net, "net/ipv6", table);
95731 + } else
95732 + hdr = register_net_sysctl(net, "net/ipv6", xfrm6_policy_table);
95733
95734 - hdr = register_net_sysctl(net, "net/ipv6", table);
95735 if (!hdr)
95736 goto err_reg;
95737
95738 @@ -349,8 +349,7 @@ static int __net_init xfrm6_net_init(struct net *net)
95739 return 0;
95740
95741 err_reg:
95742 - if (!net_eq(net, &init_net))
95743 - kfree(table);
95744 + kfree(table);
95745 err_alloc:
95746 return -ENOMEM;
95747 }
95748 diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c
95749 index 41ac7938..75e3bb1 100644
95750 --- a/net/irda/ircomm/ircomm_tty.c
95751 +++ b/net/irda/ircomm/ircomm_tty.c
95752 @@ -319,11 +319,11 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
95753 add_wait_queue(&port->open_wait, &wait);
95754
95755 IRDA_DEBUG(2, "%s(%d):block_til_ready before block on %s open_count=%d\n",
95756 - __FILE__, __LINE__, tty->driver->name, port->count);
95757 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
95758
95759 spin_lock_irqsave(&port->lock, flags);
95760 if (!tty_hung_up_p(filp))
95761 - port->count--;
95762 + atomic_dec(&port->count);
95763 port->blocked_open++;
95764 spin_unlock_irqrestore(&port->lock, flags);
95765
95766 @@ -358,7 +358,7 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
95767 }
95768
95769 IRDA_DEBUG(1, "%s(%d):block_til_ready blocking on %s open_count=%d\n",
95770 - __FILE__, __LINE__, tty->driver->name, port->count);
95771 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
95772
95773 schedule();
95774 }
95775 @@ -368,12 +368,12 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
95776
95777 spin_lock_irqsave(&port->lock, flags);
95778 if (!tty_hung_up_p(filp))
95779 - port->count++;
95780 + atomic_inc(&port->count);
95781 port->blocked_open--;
95782 spin_unlock_irqrestore(&port->lock, flags);
95783
95784 IRDA_DEBUG(1, "%s(%d):block_til_ready after blocking on %s open_count=%d\n",
95785 - __FILE__, __LINE__, tty->driver->name, port->count);
95786 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
95787
95788 if (!retval)
95789 port->flags |= ASYNC_NORMAL_ACTIVE;
95790 @@ -447,12 +447,12 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
95791
95792 /* ++ is not atomic, so this should be protected - Jean II */
95793 spin_lock_irqsave(&self->port.lock, flags);
95794 - self->port.count++;
95795 + atomic_inc(&self->port.count);
95796 spin_unlock_irqrestore(&self->port.lock, flags);
95797 tty_port_tty_set(&self->port, tty);
95798
95799 IRDA_DEBUG(1, "%s(), %s%d, count = %d\n", __func__ , tty->driver->name,
95800 - self->line, self->port.count);
95801 + self->line, atomic_read(&self->port.count));
95802
95803 /* Not really used by us, but lets do it anyway */
95804 self->port.low_latency = (self->port.flags & ASYNC_LOW_LATENCY) ? 1 : 0;
95805 @@ -989,7 +989,7 @@ static void ircomm_tty_hangup(struct tty_struct *tty)
95806 tty_kref_put(port->tty);
95807 }
95808 port->tty = NULL;
95809 - port->count = 0;
95810 + atomic_set(&port->count, 0);
95811 spin_unlock_irqrestore(&port->lock, flags);
95812
95813 wake_up_interruptible(&port->open_wait);
95814 @@ -1346,7 +1346,7 @@ static void ircomm_tty_line_info(struct ircomm_tty_cb *self, struct seq_file *m)
95815 seq_putc(m, '\n');
95816
95817 seq_printf(m, "Role: %s\n", self->client ? "client" : "server");
95818 - seq_printf(m, "Open count: %d\n", self->port.count);
95819 + seq_printf(m, "Open count: %d\n", atomic_read(&self->port.count));
95820 seq_printf(m, "Max data size: %d\n", self->max_data_size);
95821 seq_printf(m, "Max header size: %d\n", self->max_header_size);
95822
95823 diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
95824 index c4b7218..3e83259 100644
95825 --- a/net/iucv/af_iucv.c
95826 +++ b/net/iucv/af_iucv.c
95827 @@ -773,10 +773,10 @@ static int iucv_sock_autobind(struct sock *sk)
95828
95829 write_lock_bh(&iucv_sk_list.lock);
95830
95831 - sprintf(name, "%08x", atomic_inc_return(&iucv_sk_list.autobind_name));
95832 + sprintf(name, "%08x", atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
95833 while (__iucv_get_sock_by_name(name)) {
95834 sprintf(name, "%08x",
95835 - atomic_inc_return(&iucv_sk_list.autobind_name));
95836 + atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
95837 }
95838
95839 write_unlock_bh(&iucv_sk_list.lock);
95840 diff --git a/net/iucv/iucv.c b/net/iucv/iucv.c
95841 index cd5b8ec..f205e6b 100644
95842 --- a/net/iucv/iucv.c
95843 +++ b/net/iucv/iucv.c
95844 @@ -690,7 +690,7 @@ static int iucv_cpu_notify(struct notifier_block *self,
95845 return NOTIFY_OK;
95846 }
95847
95848 -static struct notifier_block __refdata iucv_cpu_notifier = {
95849 +static struct notifier_block iucv_cpu_notifier = {
95850 .notifier_call = iucv_cpu_notify,
95851 };
95852
95853 diff --git a/net/key/af_key.c b/net/key/af_key.c
95854 index 545f047..9757a9d 100644
95855 --- a/net/key/af_key.c
95856 +++ b/net/key/af_key.c
95857 @@ -3041,10 +3041,10 @@ static int pfkey_send_policy_notify(struct xfrm_policy *xp, int dir, const struc
95858 static u32 get_acqseq(void)
95859 {
95860 u32 res;
95861 - static atomic_t acqseq;
95862 + static atomic_unchecked_t acqseq;
95863
95864 do {
95865 - res = atomic_inc_return(&acqseq);
95866 + res = atomic_inc_return_unchecked(&acqseq);
95867 } while (!res);
95868 return res;
95869 }
95870 diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
95871 index 9903ee5..18978be 100644
95872 --- a/net/mac80211/cfg.c
95873 +++ b/net/mac80211/cfg.c
95874 @@ -826,7 +826,7 @@ static int ieee80211_set_monitor_channel(struct wiphy *wiphy,
95875 ret = ieee80211_vif_use_channel(sdata, chandef,
95876 IEEE80211_CHANCTX_EXCLUSIVE);
95877 }
95878 - } else if (local->open_count == local->monitors) {
95879 + } else if (local_read(&local->open_count) == local->monitors) {
95880 local->_oper_chandef = *chandef;
95881 ieee80211_hw_config(local, 0);
95882 }
95883 @@ -3124,7 +3124,7 @@ static void ieee80211_mgmt_frame_register(struct wiphy *wiphy,
95884 else
95885 local->probe_req_reg--;
95886
95887 - if (!local->open_count)
95888 + if (!local_read(&local->open_count))
95889 break;
95890
95891 ieee80211_queue_work(&local->hw, &local->reconfig_filter);
95892 @@ -3587,8 +3587,8 @@ static int ieee80211_cfg_get_channel(struct wiphy *wiphy,
95893 if (chanctx_conf) {
95894 *chandef = chanctx_conf->def;
95895 ret = 0;
95896 - } else if (local->open_count > 0 &&
95897 - local->open_count == local->monitors &&
95898 + } else if (local_read(&local->open_count) > 0 &&
95899 + local_read(&local->open_count) == local->monitors &&
95900 sdata->vif.type == NL80211_IFTYPE_MONITOR) {
95901 if (local->use_chanctx)
95902 *chandef = local->monitor_chandef;
95903 diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
95904 index 611abfc..8c2c7e4 100644
95905 --- a/net/mac80211/ieee80211_i.h
95906 +++ b/net/mac80211/ieee80211_i.h
95907 @@ -28,6 +28,7 @@
95908 #include <net/ieee80211_radiotap.h>
95909 #include <net/cfg80211.h>
95910 #include <net/mac80211.h>
95911 +#include <asm/local.h>
95912 #include "key.h"
95913 #include "sta_info.h"
95914 #include "debug.h"
95915 @@ -945,7 +946,7 @@ struct ieee80211_local {
95916 /* also used to protect ampdu_ac_queue and amdpu_ac_stop_refcnt */
95917 spinlock_t queue_stop_reason_lock;
95918
95919 - int open_count;
95920 + local_t open_count;
95921 int monitors, cooked_mntrs;
95922 /* number of interfaces with corresponding FIF_ flags */
95923 int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss, fif_pspoll,
95924 diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
95925 index fcecd63..a404454 100644
95926 --- a/net/mac80211/iface.c
95927 +++ b/net/mac80211/iface.c
95928 @@ -519,7 +519,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
95929 break;
95930 }
95931
95932 - if (local->open_count == 0) {
95933 + if (local_read(&local->open_count) == 0) {
95934 res = drv_start(local);
95935 if (res)
95936 goto err_del_bss;
95937 @@ -566,7 +566,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
95938 res = drv_add_interface(local, sdata);
95939 if (res)
95940 goto err_stop;
95941 - } else if (local->monitors == 0 && local->open_count == 0) {
95942 + } else if (local->monitors == 0 && local_read(&local->open_count) == 0) {
95943 res = ieee80211_add_virtual_monitor(local);
95944 if (res)
95945 goto err_stop;
95946 @@ -675,7 +675,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
95947 atomic_inc(&local->iff_promiscs);
95948
95949 if (coming_up)
95950 - local->open_count++;
95951 + local_inc(&local->open_count);
95952
95953 if (hw_reconf_flags)
95954 ieee80211_hw_config(local, hw_reconf_flags);
95955 @@ -713,7 +713,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
95956 err_del_interface:
95957 drv_remove_interface(local, sdata);
95958 err_stop:
95959 - if (!local->open_count)
95960 + if (!local_read(&local->open_count))
95961 drv_stop(local);
95962 err_del_bss:
95963 sdata->bss = NULL;
95964 @@ -852,7 +852,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
95965 }
95966
95967 if (going_down)
95968 - local->open_count--;
95969 + local_dec(&local->open_count);
95970
95971 switch (sdata->vif.type) {
95972 case NL80211_IFTYPE_AP_VLAN:
95973 @@ -919,7 +919,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
95974 }
95975 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
95976
95977 - if (local->open_count == 0)
95978 + if (local_read(&local->open_count) == 0)
95979 ieee80211_clear_tx_pending(local);
95980
95981 /*
95982 @@ -959,7 +959,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
95983
95984 ieee80211_recalc_ps(local, -1);
95985
95986 - if (local->open_count == 0) {
95987 + if (local_read(&local->open_count) == 0) {
95988 ieee80211_stop_device(local);
95989
95990 /* no reconfiguring after stop! */
95991 @@ -970,7 +970,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
95992 ieee80211_configure_filter(local);
95993 ieee80211_hw_config(local, hw_reconf_flags);
95994
95995 - if (local->monitors == local->open_count)
95996 + if (local->monitors == local_read(&local->open_count))
95997 ieee80211_add_virtual_monitor(local);
95998 }
95999
96000 diff --git a/net/mac80211/main.c b/net/mac80211/main.c
96001 index e765f77..dfd72e7 100644
96002 --- a/net/mac80211/main.c
96003 +++ b/net/mac80211/main.c
96004 @@ -172,7 +172,7 @@ int ieee80211_hw_config(struct ieee80211_local *local, u32 changed)
96005 changed &= ~(IEEE80211_CONF_CHANGE_CHANNEL |
96006 IEEE80211_CONF_CHANGE_POWER);
96007
96008 - if (changed && local->open_count) {
96009 + if (changed && local_read(&local->open_count)) {
96010 ret = drv_config(local, changed);
96011 /*
96012 * Goal:
96013 diff --git a/net/mac80211/pm.c b/net/mac80211/pm.c
96014 index 3401262..d5cd68d 100644
96015 --- a/net/mac80211/pm.c
96016 +++ b/net/mac80211/pm.c
96017 @@ -12,7 +12,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
96018 struct ieee80211_sub_if_data *sdata;
96019 struct sta_info *sta;
96020
96021 - if (!local->open_count)
96022 + if (!local_read(&local->open_count))
96023 goto suspend;
96024
96025 ieee80211_scan_cancel(local);
96026 @@ -59,7 +59,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
96027 cancel_work_sync(&local->dynamic_ps_enable_work);
96028 del_timer_sync(&local->dynamic_ps_timer);
96029
96030 - local->wowlan = wowlan && local->open_count;
96031 + local->wowlan = wowlan && local_read(&local->open_count);
96032 if (local->wowlan) {
96033 int err = drv_suspend(local, wowlan);
96034 if (err < 0) {
96035 @@ -116,7 +116,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
96036 WARN_ON(!list_empty(&local->chanctx_list));
96037
96038 /* stop hardware - this must stop RX */
96039 - if (local->open_count)
96040 + if (local_read(&local->open_count))
96041 ieee80211_stop_device(local);
96042
96043 suspend:
96044 diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c
96045 index e126605..73d2c39 100644
96046 --- a/net/mac80211/rate.c
96047 +++ b/net/mac80211/rate.c
96048 @@ -725,7 +725,7 @@ int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local,
96049
96050 ASSERT_RTNL();
96051
96052 - if (local->open_count)
96053 + if (local_read(&local->open_count))
96054 return -EBUSY;
96055
96056 if (local->hw.flags & IEEE80211_HW_HAS_RATE_CONTROL) {
96057 diff --git a/net/mac80211/rc80211_pid_debugfs.c b/net/mac80211/rc80211_pid_debugfs.c
96058 index c97a065..ff61928 100644
96059 --- a/net/mac80211/rc80211_pid_debugfs.c
96060 +++ b/net/mac80211/rc80211_pid_debugfs.c
96061 @@ -193,7 +193,7 @@ static ssize_t rate_control_pid_events_read(struct file *file, char __user *buf,
96062
96063 spin_unlock_irqrestore(&events->lock, status);
96064
96065 - if (copy_to_user(buf, pb, p))
96066 + if (p > sizeof(pb) || copy_to_user(buf, pb, p))
96067 return -EFAULT;
96068
96069 return p;
96070 diff --git a/net/mac80211/util.c b/net/mac80211/util.c
96071 index 69e4ef5..e8e4b92 100644
96072 --- a/net/mac80211/util.c
96073 +++ b/net/mac80211/util.c
96074 @@ -1470,7 +1470,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
96075 }
96076 #endif
96077 /* everything else happens only if HW was up & running */
96078 - if (!local->open_count)
96079 + if (!local_read(&local->open_count))
96080 goto wake_up;
96081
96082 /*
96083 @@ -1695,7 +1695,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
96084 local->in_reconfig = false;
96085 barrier();
96086
96087 - if (local->monitors == local->open_count && local->monitors > 0)
96088 + if (local->monitors == local_read(&local->open_count) && local->monitors > 0)
96089 ieee80211_add_virtual_monitor(local);
96090
96091 /*
96092 diff --git a/net/netfilter/Kconfig b/net/netfilter/Kconfig
96093 index 6e839b6..002a233 100644
96094 --- a/net/netfilter/Kconfig
96095 +++ b/net/netfilter/Kconfig
96096 @@ -950,6 +950,16 @@ config NETFILTER_XT_MATCH_ESP
96097
96098 To compile it as a module, choose M here. If unsure, say N.
96099
96100 +config NETFILTER_XT_MATCH_GRADM
96101 + tristate '"gradm" match support'
96102 + depends on NETFILTER_XTABLES && NETFILTER_ADVANCED
96103 + depends on GRKERNSEC && !GRKERNSEC_NO_RBAC
96104 + ---help---
96105 + The gradm match allows to match on grsecurity RBAC being enabled.
96106 + It is useful when iptables rules are applied early on bootup to
96107 + prevent connections to the machine (except from a trusted host)
96108 + while the RBAC system is disabled.
96109 +
96110 config NETFILTER_XT_MATCH_HASHLIMIT
96111 tristate '"hashlimit" match support'
96112 depends on (IP6_NF_IPTABLES || IP6_NF_IPTABLES=n)
96113 diff --git a/net/netfilter/Makefile b/net/netfilter/Makefile
96114 index c3a0a12..90b587f 100644
96115 --- a/net/netfilter/Makefile
96116 +++ b/net/netfilter/Makefile
96117 @@ -112,6 +112,7 @@ obj-$(CONFIG_NETFILTER_XT_MATCH_DEVGROUP) += xt_devgroup.o
96118 obj-$(CONFIG_NETFILTER_XT_MATCH_DSCP) += xt_dscp.o
96119 obj-$(CONFIG_NETFILTER_XT_MATCH_ECN) += xt_ecn.o
96120 obj-$(CONFIG_NETFILTER_XT_MATCH_ESP) += xt_esp.o
96121 +obj-$(CONFIG_NETFILTER_XT_MATCH_GRADM) += xt_gradm.o
96122 obj-$(CONFIG_NETFILTER_XT_MATCH_HASHLIMIT) += xt_hashlimit.o
96123 obj-$(CONFIG_NETFILTER_XT_MATCH_HELPER) += xt_helper.o
96124 obj-$(CONFIG_NETFILTER_XT_MATCH_HL) += xt_hl.o
96125 diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c
96126 index f2e30fb..f131862 100644
96127 --- a/net/netfilter/ipset/ip_set_core.c
96128 +++ b/net/netfilter/ipset/ip_set_core.c
96129 @@ -1819,7 +1819,7 @@ done:
96130 return ret;
96131 }
96132
96133 -static struct nf_sockopt_ops so_set __read_mostly = {
96134 +static struct nf_sockopt_ops so_set = {
96135 .pf = PF_INET,
96136 .get_optmin = SO_IP_SET,
96137 .get_optmax = SO_IP_SET + 1,
96138 diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c
96139 index 4c8e5c0..5a79b4d 100644
96140 --- a/net/netfilter/ipvs/ip_vs_conn.c
96141 +++ b/net/netfilter/ipvs/ip_vs_conn.c
96142 @@ -556,7 +556,7 @@ ip_vs_bind_dest(struct ip_vs_conn *cp, struct ip_vs_dest *dest)
96143 /* Increase the refcnt counter of the dest */
96144 ip_vs_dest_hold(dest);
96145
96146 - conn_flags = atomic_read(&dest->conn_flags);
96147 + conn_flags = atomic_read_unchecked(&dest->conn_flags);
96148 if (cp->protocol != IPPROTO_UDP)
96149 conn_flags &= ~IP_VS_CONN_F_ONE_PACKET;
96150 flags = cp->flags;
96151 @@ -900,7 +900,7 @@ ip_vs_conn_new(const struct ip_vs_conn_param *p,
96152
96153 cp->control = NULL;
96154 atomic_set(&cp->n_control, 0);
96155 - atomic_set(&cp->in_pkts, 0);
96156 + atomic_set_unchecked(&cp->in_pkts, 0);
96157
96158 cp->packet_xmit = NULL;
96159 cp->app = NULL;
96160 @@ -1188,7 +1188,7 @@ static inline int todrop_entry(struct ip_vs_conn *cp)
96161
96162 /* Don't drop the entry if its number of incoming packets is not
96163 located in [0, 8] */
96164 - i = atomic_read(&cp->in_pkts);
96165 + i = atomic_read_unchecked(&cp->in_pkts);
96166 if (i > 8 || i < 0) return 0;
96167
96168 if (!todrop_rate[i]) return 0;
96169 diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
96170 index 3581736..c0453e9 100644
96171 --- a/net/netfilter/ipvs/ip_vs_core.c
96172 +++ b/net/netfilter/ipvs/ip_vs_core.c
96173 @@ -567,7 +567,7 @@ int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb,
96174 ret = cp->packet_xmit(skb, cp, pd->pp, iph);
96175 /* do not touch skb anymore */
96176
96177 - atomic_inc(&cp->in_pkts);
96178 + atomic_inc_unchecked(&cp->in_pkts);
96179 ip_vs_conn_put(cp);
96180 return ret;
96181 }
96182 @@ -1706,7 +1706,7 @@ ip_vs_in(unsigned int hooknum, struct sk_buff *skb, int af)
96183 if (cp->flags & IP_VS_CONN_F_ONE_PACKET)
96184 pkts = sysctl_sync_threshold(ipvs);
96185 else
96186 - pkts = atomic_add_return(1, &cp->in_pkts);
96187 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
96188
96189 if (ipvs->sync_state & IP_VS_STATE_MASTER)
96190 ip_vs_sync_conn(net, cp, pkts);
96191 diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
96192 index a3df9bd..895ae09 100644
96193 --- a/net/netfilter/ipvs/ip_vs_ctl.c
96194 +++ b/net/netfilter/ipvs/ip_vs_ctl.c
96195 @@ -794,7 +794,7 @@ __ip_vs_update_dest(struct ip_vs_service *svc, struct ip_vs_dest *dest,
96196 */
96197 ip_vs_rs_hash(ipvs, dest);
96198 }
96199 - atomic_set(&dest->conn_flags, conn_flags);
96200 + atomic_set_unchecked(&dest->conn_flags, conn_flags);
96201
96202 /* bind the service */
96203 old_svc = rcu_dereference_protected(dest->svc, 1);
96204 @@ -1641,7 +1641,7 @@ proc_do_sync_ports(struct ctl_table *table, int write,
96205 * align with netns init in ip_vs_control_net_init()
96206 */
96207
96208 -static struct ctl_table vs_vars[] = {
96209 +static ctl_table_no_const vs_vars[] __read_only = {
96210 {
96211 .procname = "amemthresh",
96212 .maxlen = sizeof(int),
96213 @@ -2062,7 +2062,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
96214 " %-7s %-6d %-10d %-10d\n",
96215 &dest->addr.in6,
96216 ntohs(dest->port),
96217 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
96218 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
96219 atomic_read(&dest->weight),
96220 atomic_read(&dest->activeconns),
96221 atomic_read(&dest->inactconns));
96222 @@ -2073,7 +2073,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
96223 "%-7s %-6d %-10d %-10d\n",
96224 ntohl(dest->addr.ip),
96225 ntohs(dest->port),
96226 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
96227 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
96228 atomic_read(&dest->weight),
96229 atomic_read(&dest->activeconns),
96230 atomic_read(&dest->inactconns));
96231 @@ -2551,7 +2551,7 @@ __ip_vs_get_dest_entries(struct net *net, const struct ip_vs_get_dests *get,
96232
96233 entry.addr = dest->addr.ip;
96234 entry.port = dest->port;
96235 - entry.conn_flags = atomic_read(&dest->conn_flags);
96236 + entry.conn_flags = atomic_read_unchecked(&dest->conn_flags);
96237 entry.weight = atomic_read(&dest->weight);
96238 entry.u_threshold = dest->u_threshold;
96239 entry.l_threshold = dest->l_threshold;
96240 @@ -3094,7 +3094,7 @@ static int ip_vs_genl_fill_dest(struct sk_buff *skb, struct ip_vs_dest *dest)
96241 if (nla_put(skb, IPVS_DEST_ATTR_ADDR, sizeof(dest->addr), &dest->addr) ||
96242 nla_put_be16(skb, IPVS_DEST_ATTR_PORT, dest->port) ||
96243 nla_put_u32(skb, IPVS_DEST_ATTR_FWD_METHOD,
96244 - (atomic_read(&dest->conn_flags) &
96245 + (atomic_read_unchecked(&dest->conn_flags) &
96246 IP_VS_CONN_F_FWD_MASK)) ||
96247 nla_put_u32(skb, IPVS_DEST_ATTR_WEIGHT,
96248 atomic_read(&dest->weight)) ||
96249 @@ -3684,7 +3684,7 @@ static int __net_init ip_vs_control_net_init_sysctl(struct net *net)
96250 {
96251 int idx;
96252 struct netns_ipvs *ipvs = net_ipvs(net);
96253 - struct ctl_table *tbl;
96254 + ctl_table_no_const *tbl;
96255
96256 atomic_set(&ipvs->dropentry, 0);
96257 spin_lock_init(&ipvs->dropentry_lock);
96258 diff --git a/net/netfilter/ipvs/ip_vs_lblc.c b/net/netfilter/ipvs/ip_vs_lblc.c
96259 index eff13c9..c1aab3e 100644
96260 --- a/net/netfilter/ipvs/ip_vs_lblc.c
96261 +++ b/net/netfilter/ipvs/ip_vs_lblc.c
96262 @@ -118,7 +118,7 @@ struct ip_vs_lblc_table {
96263 * IPVS LBLC sysctl table
96264 */
96265 #ifdef CONFIG_SYSCTL
96266 -static struct ctl_table vs_vars_table[] = {
96267 +static ctl_table_no_const vs_vars_table[] __read_only = {
96268 {
96269 .procname = "lblc_expiration",
96270 .data = NULL,
96271 diff --git a/net/netfilter/ipvs/ip_vs_lblcr.c b/net/netfilter/ipvs/ip_vs_lblcr.c
96272 index 0b85500..8513fa5 100644
96273 --- a/net/netfilter/ipvs/ip_vs_lblcr.c
96274 +++ b/net/netfilter/ipvs/ip_vs_lblcr.c
96275 @@ -289,7 +289,7 @@ struct ip_vs_lblcr_table {
96276 * IPVS LBLCR sysctl table
96277 */
96278
96279 -static struct ctl_table vs_vars_table[] = {
96280 +static ctl_table_no_const vs_vars_table[] __read_only = {
96281 {
96282 .procname = "lblcr_expiration",
96283 .data = NULL,
96284 diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c
96285 index f448471..995f131 100644
96286 --- a/net/netfilter/ipvs/ip_vs_sync.c
96287 +++ b/net/netfilter/ipvs/ip_vs_sync.c
96288 @@ -609,7 +609,7 @@ static void ip_vs_sync_conn_v0(struct net *net, struct ip_vs_conn *cp,
96289 cp = cp->control;
96290 if (cp) {
96291 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
96292 - pkts = atomic_add_return(1, &cp->in_pkts);
96293 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
96294 else
96295 pkts = sysctl_sync_threshold(ipvs);
96296 ip_vs_sync_conn(net, cp->control, pkts);
96297 @@ -771,7 +771,7 @@ control:
96298 if (!cp)
96299 return;
96300 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
96301 - pkts = atomic_add_return(1, &cp->in_pkts);
96302 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
96303 else
96304 pkts = sysctl_sync_threshold(ipvs);
96305 goto sloop;
96306 @@ -895,7 +895,7 @@ static void ip_vs_proc_conn(struct net *net, struct ip_vs_conn_param *param,
96307
96308 if (opt)
96309 memcpy(&cp->in_seq, opt, sizeof(*opt));
96310 - atomic_set(&cp->in_pkts, sysctl_sync_threshold(ipvs));
96311 + atomic_set_unchecked(&cp->in_pkts, sysctl_sync_threshold(ipvs));
96312 cp->state = state;
96313 cp->old_state = cp->state;
96314 /*
96315 diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c
96316 index c47444e..b0961c6 100644
96317 --- a/net/netfilter/ipvs/ip_vs_xmit.c
96318 +++ b/net/netfilter/ipvs/ip_vs_xmit.c
96319 @@ -1102,7 +1102,7 @@ ip_vs_icmp_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
96320 else
96321 rc = NF_ACCEPT;
96322 /* do not touch skb anymore */
96323 - atomic_inc(&cp->in_pkts);
96324 + atomic_inc_unchecked(&cp->in_pkts);
96325 goto out;
96326 }
96327
96328 @@ -1194,7 +1194,7 @@ ip_vs_icmp_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
96329 else
96330 rc = NF_ACCEPT;
96331 /* do not touch skb anymore */
96332 - atomic_inc(&cp->in_pkts);
96333 + atomic_inc_unchecked(&cp->in_pkts);
96334 goto out;
96335 }
96336
96337 diff --git a/net/netfilter/nf_conntrack_acct.c b/net/netfilter/nf_conntrack_acct.c
96338 index 2d3030a..7ba1c0a 100644
96339 --- a/net/netfilter/nf_conntrack_acct.c
96340 +++ b/net/netfilter/nf_conntrack_acct.c
96341 @@ -60,7 +60,7 @@ static struct nf_ct_ext_type acct_extend __read_mostly = {
96342 #ifdef CONFIG_SYSCTL
96343 static int nf_conntrack_acct_init_sysctl(struct net *net)
96344 {
96345 - struct ctl_table *table;
96346 + ctl_table_no_const *table;
96347
96348 table = kmemdup(acct_sysctl_table, sizeof(acct_sysctl_table),
96349 GFP_KERNEL);
96350 diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
96351 index 5d892fe..d2fc9d8 100644
96352 --- a/net/netfilter/nf_conntrack_core.c
96353 +++ b/net/netfilter/nf_conntrack_core.c
96354 @@ -1600,6 +1600,10 @@ void nf_conntrack_init_end(void)
96355 #define DYING_NULLS_VAL ((1<<30)+1)
96356 #define TEMPLATE_NULLS_VAL ((1<<30)+2)
96357
96358 +#ifdef CONFIG_GRKERNSEC_HIDESYM
96359 +static atomic_unchecked_t conntrack_cache_id = ATOMIC_INIT(0);
96360 +#endif
96361 +
96362 int nf_conntrack_init_net(struct net *net)
96363 {
96364 int ret;
96365 @@ -1614,7 +1618,11 @@ int nf_conntrack_init_net(struct net *net)
96366 goto err_stat;
96367 }
96368
96369 +#ifdef CONFIG_GRKERNSEC_HIDESYM
96370 + net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%08lx", atomic_inc_return_unchecked(&conntrack_cache_id));
96371 +#else
96372 net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%p", net);
96373 +#endif
96374 if (!net->ct.slabname) {
96375 ret = -ENOMEM;
96376 goto err_slabname;
96377 diff --git a/net/netfilter/nf_conntrack_ecache.c b/net/netfilter/nf_conntrack_ecache.c
96378 index 1df1761..ce8b88a 100644
96379 --- a/net/netfilter/nf_conntrack_ecache.c
96380 +++ b/net/netfilter/nf_conntrack_ecache.c
96381 @@ -188,7 +188,7 @@ static struct nf_ct_ext_type event_extend __read_mostly = {
96382 #ifdef CONFIG_SYSCTL
96383 static int nf_conntrack_event_init_sysctl(struct net *net)
96384 {
96385 - struct ctl_table *table;
96386 + ctl_table_no_const *table;
96387
96388 table = kmemdup(event_sysctl_table, sizeof(event_sysctl_table),
96389 GFP_KERNEL);
96390 diff --git a/net/netfilter/nf_conntrack_helper.c b/net/netfilter/nf_conntrack_helper.c
96391 index 974a2a4..52cc6ff 100644
96392 --- a/net/netfilter/nf_conntrack_helper.c
96393 +++ b/net/netfilter/nf_conntrack_helper.c
96394 @@ -57,7 +57,7 @@ static struct ctl_table helper_sysctl_table[] = {
96395
96396 static int nf_conntrack_helper_init_sysctl(struct net *net)
96397 {
96398 - struct ctl_table *table;
96399 + ctl_table_no_const *table;
96400
96401 table = kmemdup(helper_sysctl_table, sizeof(helper_sysctl_table),
96402 GFP_KERNEL);
96403 diff --git a/net/netfilter/nf_conntrack_proto.c b/net/netfilter/nf_conntrack_proto.c
96404 index ce30041..3861b5d 100644
96405 --- a/net/netfilter/nf_conntrack_proto.c
96406 +++ b/net/netfilter/nf_conntrack_proto.c
96407 @@ -52,7 +52,7 @@ nf_ct_register_sysctl(struct net *net,
96408
96409 static void
96410 nf_ct_unregister_sysctl(struct ctl_table_header **header,
96411 - struct ctl_table **table,
96412 + ctl_table_no_const **table,
96413 unsigned int users)
96414 {
96415 if (users > 0)
96416 diff --git a/net/netfilter/nf_conntrack_proto_dccp.c b/net/netfilter/nf_conntrack_proto_dccp.c
96417 index a99b6c3..cb372f9 100644
96418 --- a/net/netfilter/nf_conntrack_proto_dccp.c
96419 +++ b/net/netfilter/nf_conntrack_proto_dccp.c
96420 @@ -428,7 +428,7 @@ static bool dccp_new(struct nf_conn *ct, const struct sk_buff *skb,
96421 const char *msg;
96422 u_int8_t state;
96423
96424 - dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &dh);
96425 + dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &_dh);
96426 BUG_ON(dh == NULL);
96427
96428 state = dccp_state_table[CT_DCCP_ROLE_CLIENT][dh->dccph_type][CT_DCCP_NONE];
96429 @@ -457,7 +457,7 @@ static bool dccp_new(struct nf_conn *ct, const struct sk_buff *skb,
96430 out_invalid:
96431 if (LOG_INVALID(net, IPPROTO_DCCP))
96432 nf_log_packet(net, nf_ct_l3num(ct), 0, skb, NULL, NULL,
96433 - NULL, msg);
96434 + NULL, "%s", msg);
96435 return false;
96436 }
96437
96438 @@ -486,7 +486,7 @@ static int dccp_packet(struct nf_conn *ct, const struct sk_buff *skb,
96439 u_int8_t type, old_state, new_state;
96440 enum ct_dccp_roles role;
96441
96442 - dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &dh);
96443 + dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &_dh);
96444 BUG_ON(dh == NULL);
96445 type = dh->dccph_type;
96446
96447 @@ -577,7 +577,7 @@ static int dccp_error(struct net *net, struct nf_conn *tmpl,
96448 unsigned int cscov;
96449 const char *msg;
96450
96451 - dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &dh);
96452 + dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &_dh);
96453 if (dh == NULL) {
96454 msg = "nf_ct_dccp: short packet ";
96455 goto out_invalid;
96456 @@ -614,7 +614,7 @@ static int dccp_error(struct net *net, struct nf_conn *tmpl,
96457
96458 out_invalid:
96459 if (LOG_INVALID(net, IPPROTO_DCCP))
96460 - nf_log_packet(net, pf, 0, skb, NULL, NULL, NULL, msg);
96461 + nf_log_packet(net, pf, 0, skb, NULL, NULL, NULL, "%s", msg);
96462 return -NF_ACCEPT;
96463 }
96464
96465 diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
96466 index f641751..d3c5b51 100644
96467 --- a/net/netfilter/nf_conntrack_standalone.c
96468 +++ b/net/netfilter/nf_conntrack_standalone.c
96469 @@ -471,7 +471,7 @@ static struct ctl_table nf_ct_netfilter_table[] = {
96470
96471 static int nf_conntrack_standalone_init_sysctl(struct net *net)
96472 {
96473 - struct ctl_table *table;
96474 + ctl_table_no_const *table;
96475
96476 table = kmemdup(nf_ct_sysctl_table, sizeof(nf_ct_sysctl_table),
96477 GFP_KERNEL);
96478 diff --git a/net/netfilter/nf_conntrack_timestamp.c b/net/netfilter/nf_conntrack_timestamp.c
96479 index 902fb0a..87f7fdb 100644
96480 --- a/net/netfilter/nf_conntrack_timestamp.c
96481 +++ b/net/netfilter/nf_conntrack_timestamp.c
96482 @@ -42,7 +42,7 @@ static struct nf_ct_ext_type tstamp_extend __read_mostly = {
96483 #ifdef CONFIG_SYSCTL
96484 static int nf_conntrack_tstamp_init_sysctl(struct net *net)
96485 {
96486 - struct ctl_table *table;
96487 + ctl_table_no_const *table;
96488
96489 table = kmemdup(tstamp_sysctl_table, sizeof(tstamp_sysctl_table),
96490 GFP_KERNEL);
96491 diff --git a/net/netfilter/nf_log.c b/net/netfilter/nf_log.c
96492 index 85296d4..8becdec 100644
96493 --- a/net/netfilter/nf_log.c
96494 +++ b/net/netfilter/nf_log.c
96495 @@ -243,7 +243,7 @@ static const struct file_operations nflog_file_ops = {
96496
96497 #ifdef CONFIG_SYSCTL
96498 static char nf_log_sysctl_fnames[NFPROTO_NUMPROTO-NFPROTO_UNSPEC][3];
96499 -static struct ctl_table nf_log_sysctl_table[NFPROTO_NUMPROTO+1];
96500 +static ctl_table_no_const nf_log_sysctl_table[NFPROTO_NUMPROTO+1] __read_only;
96501
96502 static int nf_log_proc_dostring(struct ctl_table *table, int write,
96503 void __user *buffer, size_t *lenp, loff_t *ppos)
96504 @@ -274,14 +274,16 @@ static int nf_log_proc_dostring(struct ctl_table *table, int write,
96505 rcu_assign_pointer(net->nf.nf_loggers[tindex], logger);
96506 mutex_unlock(&nf_log_mutex);
96507 } else {
96508 + ctl_table_no_const nf_log_table = *table;
96509 +
96510 mutex_lock(&nf_log_mutex);
96511 logger = rcu_dereference_protected(net->nf.nf_loggers[tindex],
96512 lockdep_is_held(&nf_log_mutex));
96513 if (!logger)
96514 - table->data = "NONE";
96515 + nf_log_table.data = "NONE";
96516 else
96517 - table->data = logger->name;
96518 - r = proc_dostring(table, write, buffer, lenp, ppos);
96519 + nf_log_table.data = logger->name;
96520 + r = proc_dostring(&nf_log_table, write, buffer, lenp, ppos);
96521 mutex_unlock(&nf_log_mutex);
96522 }
96523
96524 diff --git a/net/netfilter/nf_sockopt.c b/net/netfilter/nf_sockopt.c
96525 index f042ae5..30ea486 100644
96526 --- a/net/netfilter/nf_sockopt.c
96527 +++ b/net/netfilter/nf_sockopt.c
96528 @@ -45,7 +45,7 @@ int nf_register_sockopt(struct nf_sockopt_ops *reg)
96529 }
96530 }
96531
96532 - list_add(&reg->list, &nf_sockopts);
96533 + pax_list_add((struct list_head *)&reg->list, &nf_sockopts);
96534 out:
96535 mutex_unlock(&nf_sockopt_mutex);
96536 return ret;
96537 @@ -55,7 +55,7 @@ EXPORT_SYMBOL(nf_register_sockopt);
96538 void nf_unregister_sockopt(struct nf_sockopt_ops *reg)
96539 {
96540 mutex_lock(&nf_sockopt_mutex);
96541 - list_del(&reg->list);
96542 + pax_list_del((struct list_head *)&reg->list);
96543 mutex_unlock(&nf_sockopt_mutex);
96544 }
96545 EXPORT_SYMBOL(nf_unregister_sockopt);
96546 diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
96547 index d92cc31..e46f350 100644
96548 --- a/net/netfilter/nfnetlink_log.c
96549 +++ b/net/netfilter/nfnetlink_log.c
96550 @@ -82,7 +82,7 @@ static int nfnl_log_net_id __read_mostly;
96551 struct nfnl_log_net {
96552 spinlock_t instances_lock;
96553 struct hlist_head instance_table[INSTANCE_BUCKETS];
96554 - atomic_t global_seq;
96555 + atomic_unchecked_t global_seq;
96556 };
96557
96558 static struct nfnl_log_net *nfnl_log_pernet(struct net *net)
96559 @@ -563,7 +563,7 @@ __build_packet_message(struct nfnl_log_net *log,
96560 /* global sequence number */
96561 if ((inst->flags & NFULNL_CFG_F_SEQ_GLOBAL) &&
96562 nla_put_be32(inst->skb, NFULA_SEQ_GLOBAL,
96563 - htonl(atomic_inc_return(&log->global_seq))))
96564 + htonl(atomic_inc_return_unchecked(&log->global_seq))))
96565 goto nla_put_failure;
96566
96567 if (data_len) {
96568 diff --git a/net/netfilter/xt_gradm.c b/net/netfilter/xt_gradm.c
96569 new file mode 100644
96570 index 0000000..c566332
96571 --- /dev/null
96572 +++ b/net/netfilter/xt_gradm.c
96573 @@ -0,0 +1,51 @@
96574 +/*
96575 + * gradm match for netfilter
96576 + * Copyright © Zbigniew Krzystolik, 2010
96577 + *
96578 + * This program is free software; you can redistribute it and/or modify
96579 + * it under the terms of the GNU General Public License; either version
96580 + * 2 or 3 as published by the Free Software Foundation.
96581 + */
96582 +#include <linux/module.h>
96583 +#include <linux/moduleparam.h>
96584 +#include <linux/skbuff.h>
96585 +#include <linux/netfilter/x_tables.h>
96586 +#include <linux/grsecurity.h>
96587 +#include <linux/netfilter/xt_gradm.h>
96588 +
96589 +static bool
96590 +gradm_mt(const struct sk_buff *skb, struct xt_action_param *par)
96591 +{
96592 + const struct xt_gradm_mtinfo *info = par->matchinfo;
96593 + bool retval = false;
96594 + if (gr_acl_is_enabled())
96595 + retval = true;
96596 + return retval ^ info->invflags;
96597 +}
96598 +
96599 +static struct xt_match gradm_mt_reg __read_mostly = {
96600 + .name = "gradm",
96601 + .revision = 0,
96602 + .family = NFPROTO_UNSPEC,
96603 + .match = gradm_mt,
96604 + .matchsize = XT_ALIGN(sizeof(struct xt_gradm_mtinfo)),
96605 + .me = THIS_MODULE,
96606 +};
96607 +
96608 +static int __init gradm_mt_init(void)
96609 +{
96610 + return xt_register_match(&gradm_mt_reg);
96611 +}
96612 +
96613 +static void __exit gradm_mt_exit(void)
96614 +{
96615 + xt_unregister_match(&gradm_mt_reg);
96616 +}
96617 +
96618 +module_init(gradm_mt_init);
96619 +module_exit(gradm_mt_exit);
96620 +MODULE_AUTHOR("Zbigniew Krzystolik <zbyniu@destrukcja.pl>");
96621 +MODULE_DESCRIPTION("Xtables: Grsecurity RBAC match");
96622 +MODULE_LICENSE("GPL");
96623 +MODULE_ALIAS("ipt_gradm");
96624 +MODULE_ALIAS("ip6t_gradm");
96625 diff --git a/net/netfilter/xt_statistic.c b/net/netfilter/xt_statistic.c
96626 index 4fe4fb4..87a89e5 100644
96627 --- a/net/netfilter/xt_statistic.c
96628 +++ b/net/netfilter/xt_statistic.c
96629 @@ -19,7 +19,7 @@
96630 #include <linux/module.h>
96631
96632 struct xt_statistic_priv {
96633 - atomic_t count;
96634 + atomic_unchecked_t count;
96635 } ____cacheline_aligned_in_smp;
96636
96637 MODULE_LICENSE("GPL");
96638 @@ -42,9 +42,9 @@ statistic_mt(const struct sk_buff *skb, struct xt_action_param *par)
96639 break;
96640 case XT_STATISTIC_MODE_NTH:
96641 do {
96642 - oval = atomic_read(&info->master->count);
96643 + oval = atomic_read_unchecked(&info->master->count);
96644 nval = (oval == info->u.nth.every) ? 0 : oval + 1;
96645 - } while (atomic_cmpxchg(&info->master->count, oval, nval) != oval);
96646 + } while (atomic_cmpxchg_unchecked(&info->master->count, oval, nval) != oval);
96647 if (nval == 0)
96648 ret = !ret;
96649 break;
96650 @@ -64,7 +64,7 @@ static int statistic_mt_check(const struct xt_mtchk_param *par)
96651 info->master = kzalloc(sizeof(*info->master), GFP_KERNEL);
96652 if (info->master == NULL)
96653 return -ENOMEM;
96654 - atomic_set(&info->master->count, info->u.nth.count);
96655 + atomic_set_unchecked(&info->master->count, info->u.nth.count);
96656
96657 return 0;
96658 }
96659 diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
96660 index 6135635..5bdc54a 100644
96661 --- a/net/netlink/af_netlink.c
96662 +++ b/net/netlink/af_netlink.c
96663 @@ -249,7 +249,7 @@ static void netlink_overrun(struct sock *sk)
96664 sk->sk_error_report(sk);
96665 }
96666 }
96667 - atomic_inc(&sk->sk_drops);
96668 + atomic_inc_unchecked(&sk->sk_drops);
96669 }
96670
96671 static void netlink_rcv_wake(struct sock *sk)
96672 @@ -2940,7 +2940,7 @@ static int netlink_seq_show(struct seq_file *seq, void *v)
96673 sk_wmem_alloc_get(s),
96674 nlk->cb_running,
96675 atomic_read(&s->sk_refcnt),
96676 - atomic_read(&s->sk_drops),
96677 + atomic_read_unchecked(&s->sk_drops),
96678 sock_i_ino(s)
96679 );
96680
96681 diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
96682 index 0c741ce..f8c8ca7 100644
96683 --- a/net/netlink/genetlink.c
96684 +++ b/net/netlink/genetlink.c
96685 @@ -310,18 +310,20 @@ int genl_register_ops(struct genl_family *family, struct genl_ops *ops)
96686 goto errout;
96687 }
96688
96689 + pax_open_kernel();
96690 if (ops->dumpit)
96691 - ops->flags |= GENL_CMD_CAP_DUMP;
96692 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DUMP;
96693 if (ops->doit)
96694 - ops->flags |= GENL_CMD_CAP_DO;
96695 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DO;
96696 if (ops->policy)
96697 - ops->flags |= GENL_CMD_CAP_HASPOL;
96698 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_HASPOL;
96699 + pax_close_kernel();
96700
96701 genl_lock_all();
96702 - list_add_tail(&ops->ops_list, &family->ops_list);
96703 + pax_list_add_tail((struct list_head *)&ops->ops_list, &family->ops_list);
96704 genl_unlock_all();
96705
96706 - genl_ctrl_event(CTRL_CMD_NEWOPS, ops);
96707 + genl_ctrl_event(CTRL_CMD_NEWOPS, (void *)ops);
96708 err = 0;
96709 errout:
96710 return err;
96711 @@ -351,9 +353,9 @@ int genl_unregister_ops(struct genl_family *family, struct genl_ops *ops)
96712 genl_lock_all();
96713 list_for_each_entry(rc, &family->ops_list, ops_list) {
96714 if (rc == ops) {
96715 - list_del(&ops->ops_list);
96716 + pax_list_del((struct list_head *)&ops->ops_list);
96717 genl_unlock_all();
96718 - genl_ctrl_event(CTRL_CMD_DELOPS, ops);
96719 + genl_ctrl_event(CTRL_CMD_DELOPS, (void *)ops);
96720 return 0;
96721 }
96722 }
96723 diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c
96724 index 53c19a3..b0ac04a 100644
96725 --- a/net/netrom/af_netrom.c
96726 +++ b/net/netrom/af_netrom.c
96727 @@ -850,7 +850,6 @@ static int nr_getname(struct socket *sock, struct sockaddr *uaddr,
96728 *uaddr_len = sizeof(struct full_sockaddr_ax25);
96729 } else {
96730 sax->fsa_ax25.sax25_family = AF_NETROM;
96731 - sax->fsa_ax25.sax25_ndigis = 0;
96732 sax->fsa_ax25.sax25_call = nr->source_addr;
96733 *uaddr_len = sizeof(struct sockaddr_ax25);
96734 }
96735 diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
96736 index ba2548b..1a4e98e 100644
96737 --- a/net/packet/af_packet.c
96738 +++ b/net/packet/af_packet.c
96739 @@ -1699,7 +1699,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
96740
96741 spin_lock(&sk->sk_receive_queue.lock);
96742 po->stats.stats1.tp_packets++;
96743 - skb->dropcount = atomic_read(&sk->sk_drops);
96744 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
96745 __skb_queue_tail(&sk->sk_receive_queue, skb);
96746 spin_unlock(&sk->sk_receive_queue.lock);
96747 sk->sk_data_ready(sk, skb->len);
96748 @@ -1708,7 +1708,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
96749 drop_n_acct:
96750 spin_lock(&sk->sk_receive_queue.lock);
96751 po->stats.stats1.tp_drops++;
96752 - atomic_inc(&sk->sk_drops);
96753 + atomic_inc_unchecked(&sk->sk_drops);
96754 spin_unlock(&sk->sk_receive_queue.lock);
96755
96756 drop_n_restore:
96757 @@ -3261,7 +3261,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
96758 case PACKET_HDRLEN:
96759 if (len > sizeof(int))
96760 len = sizeof(int);
96761 - if (copy_from_user(&val, optval, len))
96762 + if (len > sizeof(val) || copy_from_user(&val, optval, len))
96763 return -EFAULT;
96764 switch (val) {
96765 case TPACKET_V1:
96766 @@ -3304,7 +3304,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
96767 len = lv;
96768 if (put_user(len, optlen))
96769 return -EFAULT;
96770 - if (copy_to_user(optval, data, len))
96771 + if (len > sizeof(st) || copy_to_user(optval, data, len))
96772 return -EFAULT;
96773 return 0;
96774 }
96775 diff --git a/net/phonet/pep.c b/net/phonet/pep.c
96776 index e774117..900b8b7 100644
96777 --- a/net/phonet/pep.c
96778 +++ b/net/phonet/pep.c
96779 @@ -388,7 +388,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
96780
96781 case PNS_PEP_CTRL_REQ:
96782 if (skb_queue_len(&pn->ctrlreq_queue) >= PNPIPE_CTRLREQ_MAX) {
96783 - atomic_inc(&sk->sk_drops);
96784 + atomic_inc_unchecked(&sk->sk_drops);
96785 break;
96786 }
96787 __skb_pull(skb, 4);
96788 @@ -409,7 +409,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
96789 }
96790
96791 if (pn->rx_credits == 0) {
96792 - atomic_inc(&sk->sk_drops);
96793 + atomic_inc_unchecked(&sk->sk_drops);
96794 err = -ENOBUFS;
96795 break;
96796 }
96797 @@ -580,7 +580,7 @@ static int pipe_handler_do_rcv(struct sock *sk, struct sk_buff *skb)
96798 }
96799
96800 if (pn->rx_credits == 0) {
96801 - atomic_inc(&sk->sk_drops);
96802 + atomic_inc_unchecked(&sk->sk_drops);
96803 err = NET_RX_DROP;
96804 break;
96805 }
96806 diff --git a/net/phonet/socket.c b/net/phonet/socket.c
96807 index 77e38f7..f4ef5c3 100644
96808 --- a/net/phonet/socket.c
96809 +++ b/net/phonet/socket.c
96810 @@ -612,7 +612,7 @@ static int pn_sock_seq_show(struct seq_file *seq, void *v)
96811 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sk)),
96812 sock_i_ino(sk),
96813 atomic_read(&sk->sk_refcnt), sk,
96814 - atomic_read(&sk->sk_drops), &len);
96815 + atomic_read_unchecked(&sk->sk_drops), &len);
96816 }
96817 seq_printf(seq, "%*s\n", 127 - len, "");
96818 return 0;
96819 diff --git a/net/phonet/sysctl.c b/net/phonet/sysctl.c
96820 index c02a8c4..3c5b600 100644
96821 --- a/net/phonet/sysctl.c
96822 +++ b/net/phonet/sysctl.c
96823 @@ -67,7 +67,7 @@ static int proc_local_port_range(struct ctl_table *table, int write,
96824 {
96825 int ret;
96826 int range[2] = {local_port_range[0], local_port_range[1]};
96827 - struct ctl_table tmp = {
96828 + ctl_table_no_const tmp = {
96829 .data = &range,
96830 .maxlen = sizeof(range),
96831 .mode = table->mode,
96832 diff --git a/net/rds/cong.c b/net/rds/cong.c
96833 index e5b65ac..f3b6fb7 100644
96834 --- a/net/rds/cong.c
96835 +++ b/net/rds/cong.c
96836 @@ -78,7 +78,7 @@
96837 * finds that the saved generation number is smaller than the global generation
96838 * number, it wakes up the process.
96839 */
96840 -static atomic_t rds_cong_generation = ATOMIC_INIT(0);
96841 +static atomic_unchecked_t rds_cong_generation = ATOMIC_INIT(0);
96842
96843 /*
96844 * Congestion monitoring
96845 @@ -233,7 +233,7 @@ void rds_cong_map_updated(struct rds_cong_map *map, uint64_t portmask)
96846 rdsdebug("waking map %p for %pI4\n",
96847 map, &map->m_addr);
96848 rds_stats_inc(s_cong_update_received);
96849 - atomic_inc(&rds_cong_generation);
96850 + atomic_inc_unchecked(&rds_cong_generation);
96851 if (waitqueue_active(&map->m_waitq))
96852 wake_up(&map->m_waitq);
96853 if (waitqueue_active(&rds_poll_waitq))
96854 @@ -259,7 +259,7 @@ EXPORT_SYMBOL_GPL(rds_cong_map_updated);
96855
96856 int rds_cong_updated_since(unsigned long *recent)
96857 {
96858 - unsigned long gen = atomic_read(&rds_cong_generation);
96859 + unsigned long gen = atomic_read_unchecked(&rds_cong_generation);
96860
96861 if (likely(*recent == gen))
96862 return 0;
96863 diff --git a/net/rds/ib.h b/net/rds/ib.h
96864 index 7280ab8..e04f4ea 100644
96865 --- a/net/rds/ib.h
96866 +++ b/net/rds/ib.h
96867 @@ -128,7 +128,7 @@ struct rds_ib_connection {
96868 /* sending acks */
96869 unsigned long i_ack_flags;
96870 #ifdef KERNEL_HAS_ATOMIC64
96871 - atomic64_t i_ack_next; /* next ACK to send */
96872 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
96873 #else
96874 spinlock_t i_ack_lock; /* protect i_ack_next */
96875 u64 i_ack_next; /* next ACK to send */
96876 diff --git a/net/rds/ib_cm.c b/net/rds/ib_cm.c
96877 index 31b74f5..dc1fbfa 100644
96878 --- a/net/rds/ib_cm.c
96879 +++ b/net/rds/ib_cm.c
96880 @@ -717,7 +717,7 @@ void rds_ib_conn_shutdown(struct rds_connection *conn)
96881 /* Clear the ACK state */
96882 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
96883 #ifdef KERNEL_HAS_ATOMIC64
96884 - atomic64_set(&ic->i_ack_next, 0);
96885 + atomic64_set_unchecked(&ic->i_ack_next, 0);
96886 #else
96887 ic->i_ack_next = 0;
96888 #endif
96889 diff --git a/net/rds/ib_recv.c b/net/rds/ib_recv.c
96890 index 8eb9501..0c386ff 100644
96891 --- a/net/rds/ib_recv.c
96892 +++ b/net/rds/ib_recv.c
96893 @@ -597,7 +597,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
96894 static void rds_ib_set_ack(struct rds_ib_connection *ic, u64 seq,
96895 int ack_required)
96896 {
96897 - atomic64_set(&ic->i_ack_next, seq);
96898 + atomic64_set_unchecked(&ic->i_ack_next, seq);
96899 if (ack_required) {
96900 smp_mb__before_clear_bit();
96901 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
96902 @@ -609,7 +609,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
96903 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
96904 smp_mb__after_clear_bit();
96905
96906 - return atomic64_read(&ic->i_ack_next);
96907 + return atomic64_read_unchecked(&ic->i_ack_next);
96908 }
96909 #endif
96910
96911 diff --git a/net/rds/iw.h b/net/rds/iw.h
96912 index 04ce3b1..48119a6 100644
96913 --- a/net/rds/iw.h
96914 +++ b/net/rds/iw.h
96915 @@ -134,7 +134,7 @@ struct rds_iw_connection {
96916 /* sending acks */
96917 unsigned long i_ack_flags;
96918 #ifdef KERNEL_HAS_ATOMIC64
96919 - atomic64_t i_ack_next; /* next ACK to send */
96920 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
96921 #else
96922 spinlock_t i_ack_lock; /* protect i_ack_next */
96923 u64 i_ack_next; /* next ACK to send */
96924 diff --git a/net/rds/iw_cm.c b/net/rds/iw_cm.c
96925 index a91e1db..cf3053f 100644
96926 --- a/net/rds/iw_cm.c
96927 +++ b/net/rds/iw_cm.c
96928 @@ -663,7 +663,7 @@ void rds_iw_conn_shutdown(struct rds_connection *conn)
96929 /* Clear the ACK state */
96930 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
96931 #ifdef KERNEL_HAS_ATOMIC64
96932 - atomic64_set(&ic->i_ack_next, 0);
96933 + atomic64_set_unchecked(&ic->i_ack_next, 0);
96934 #else
96935 ic->i_ack_next = 0;
96936 #endif
96937 diff --git a/net/rds/iw_recv.c b/net/rds/iw_recv.c
96938 index 4503335..db566b4 100644
96939 --- a/net/rds/iw_recv.c
96940 +++ b/net/rds/iw_recv.c
96941 @@ -427,7 +427,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
96942 static void rds_iw_set_ack(struct rds_iw_connection *ic, u64 seq,
96943 int ack_required)
96944 {
96945 - atomic64_set(&ic->i_ack_next, seq);
96946 + atomic64_set_unchecked(&ic->i_ack_next, seq);
96947 if (ack_required) {
96948 smp_mb__before_clear_bit();
96949 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
96950 @@ -439,7 +439,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
96951 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
96952 smp_mb__after_clear_bit();
96953
96954 - return atomic64_read(&ic->i_ack_next);
96955 + return atomic64_read_unchecked(&ic->i_ack_next);
96956 }
96957 #endif
96958
96959 diff --git a/net/rds/rds.h b/net/rds/rds.h
96960 index ec1d731..90a3a8d 100644
96961 --- a/net/rds/rds.h
96962 +++ b/net/rds/rds.h
96963 @@ -449,7 +449,7 @@ struct rds_transport {
96964 void (*sync_mr)(void *trans_private, int direction);
96965 void (*free_mr)(void *trans_private, int invalidate);
96966 void (*flush_mrs)(void);
96967 -};
96968 +} __do_const;
96969
96970 struct rds_sock {
96971 struct sock rs_sk;
96972 diff --git a/net/rds/tcp.c b/net/rds/tcp.c
96973 index edac9ef..16bcb98 100644
96974 --- a/net/rds/tcp.c
96975 +++ b/net/rds/tcp.c
96976 @@ -59,7 +59,7 @@ void rds_tcp_nonagle(struct socket *sock)
96977 int val = 1;
96978
96979 set_fs(KERNEL_DS);
96980 - sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __user *)&val,
96981 + sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __force_user *)&val,
96982 sizeof(val));
96983 set_fs(oldfs);
96984 }
96985 diff --git a/net/rds/tcp_send.c b/net/rds/tcp_send.c
96986 index 81cf5a4..b5826ff 100644
96987 --- a/net/rds/tcp_send.c
96988 +++ b/net/rds/tcp_send.c
96989 @@ -43,7 +43,7 @@ static void rds_tcp_cork(struct socket *sock, int val)
96990
96991 oldfs = get_fs();
96992 set_fs(KERNEL_DS);
96993 - sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __user *)&val,
96994 + sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __force_user *)&val,
96995 sizeof(val));
96996 set_fs(oldfs);
96997 }
96998 diff --git a/net/rxrpc/af_rxrpc.c b/net/rxrpc/af_rxrpc.c
96999 index e61aa60..f07cc89 100644
97000 --- a/net/rxrpc/af_rxrpc.c
97001 +++ b/net/rxrpc/af_rxrpc.c
97002 @@ -40,7 +40,7 @@ static const struct proto_ops rxrpc_rpc_ops;
97003 __be32 rxrpc_epoch;
97004
97005 /* current debugging ID */
97006 -atomic_t rxrpc_debug_id;
97007 +atomic_unchecked_t rxrpc_debug_id;
97008
97009 /* count of skbs currently in use */
97010 atomic_t rxrpc_n_skbs;
97011 diff --git a/net/rxrpc/ar-ack.c b/net/rxrpc/ar-ack.c
97012 index e4d9cbc..b229649 100644
97013 --- a/net/rxrpc/ar-ack.c
97014 +++ b/net/rxrpc/ar-ack.c
97015 @@ -175,7 +175,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
97016
97017 _enter("{%d,%d,%d,%d},",
97018 call->acks_hard, call->acks_unacked,
97019 - atomic_read(&call->sequence),
97020 + atomic_read_unchecked(&call->sequence),
97021 CIRC_CNT(call->acks_head, call->acks_tail, call->acks_winsz));
97022
97023 stop = 0;
97024 @@ -199,7 +199,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
97025
97026 /* each Tx packet has a new serial number */
97027 sp->hdr.serial =
97028 - htonl(atomic_inc_return(&call->conn->serial));
97029 + htonl(atomic_inc_return_unchecked(&call->conn->serial));
97030
97031 hdr = (struct rxrpc_header *) txb->head;
97032 hdr->serial = sp->hdr.serial;
97033 @@ -403,7 +403,7 @@ static void rxrpc_rotate_tx_window(struct rxrpc_call *call, u32 hard)
97034 */
97035 static void rxrpc_clear_tx_window(struct rxrpc_call *call)
97036 {
97037 - rxrpc_rotate_tx_window(call, atomic_read(&call->sequence));
97038 + rxrpc_rotate_tx_window(call, atomic_read_unchecked(&call->sequence));
97039 }
97040
97041 /*
97042 @@ -629,7 +629,7 @@ process_further:
97043
97044 latest = ntohl(sp->hdr.serial);
97045 hard = ntohl(ack.firstPacket);
97046 - tx = atomic_read(&call->sequence);
97047 + tx = atomic_read_unchecked(&call->sequence);
97048
97049 _proto("Rx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
97050 latest,
97051 @@ -1161,7 +1161,7 @@ void rxrpc_process_call(struct work_struct *work)
97052 goto maybe_reschedule;
97053
97054 send_ACK_with_skew:
97055 - ack.maxSkew = htons(atomic_read(&call->conn->hi_serial) -
97056 + ack.maxSkew = htons(atomic_read_unchecked(&call->conn->hi_serial) -
97057 ntohl(ack.serial));
97058 send_ACK:
97059 mtu = call->conn->trans->peer->if_mtu;
97060 @@ -1173,7 +1173,7 @@ send_ACK:
97061 ackinfo.rxMTU = htonl(5692);
97062 ackinfo.jumbo_max = htonl(4);
97063
97064 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
97065 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
97066 _proto("Tx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
97067 ntohl(hdr.serial),
97068 ntohs(ack.maxSkew),
97069 @@ -1191,7 +1191,7 @@ send_ACK:
97070 send_message:
97071 _debug("send message");
97072
97073 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
97074 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
97075 _proto("Tx %s %%%u", rxrpc_pkts[hdr.type], ntohl(hdr.serial));
97076 send_message_2:
97077
97078 diff --git a/net/rxrpc/ar-call.c b/net/rxrpc/ar-call.c
97079 index a3bbb36..3341fb9 100644
97080 --- a/net/rxrpc/ar-call.c
97081 +++ b/net/rxrpc/ar-call.c
97082 @@ -83,7 +83,7 @@ static struct rxrpc_call *rxrpc_alloc_call(gfp_t gfp)
97083 spin_lock_init(&call->lock);
97084 rwlock_init(&call->state_lock);
97085 atomic_set(&call->usage, 1);
97086 - call->debug_id = atomic_inc_return(&rxrpc_debug_id);
97087 + call->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
97088 call->state = RXRPC_CALL_CLIENT_SEND_REQUEST;
97089
97090 memset(&call->sock_node, 0xed, sizeof(call->sock_node));
97091 diff --git a/net/rxrpc/ar-connection.c b/net/rxrpc/ar-connection.c
97092 index 4106ca9..a338d7a 100644
97093 --- a/net/rxrpc/ar-connection.c
97094 +++ b/net/rxrpc/ar-connection.c
97095 @@ -206,7 +206,7 @@ static struct rxrpc_connection *rxrpc_alloc_connection(gfp_t gfp)
97096 rwlock_init(&conn->lock);
97097 spin_lock_init(&conn->state_lock);
97098 atomic_set(&conn->usage, 1);
97099 - conn->debug_id = atomic_inc_return(&rxrpc_debug_id);
97100 + conn->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
97101 conn->avail_calls = RXRPC_MAXCALLS;
97102 conn->size_align = 4;
97103 conn->header_size = sizeof(struct rxrpc_header);
97104 diff --git a/net/rxrpc/ar-connevent.c b/net/rxrpc/ar-connevent.c
97105 index e7ed43a..6afa140 100644
97106 --- a/net/rxrpc/ar-connevent.c
97107 +++ b/net/rxrpc/ar-connevent.c
97108 @@ -109,7 +109,7 @@ static int rxrpc_abort_connection(struct rxrpc_connection *conn,
97109
97110 len = iov[0].iov_len + iov[1].iov_len;
97111
97112 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
97113 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
97114 _proto("Tx CONN ABORT %%%u { %d }", ntohl(hdr.serial), abort_code);
97115
97116 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
97117 diff --git a/net/rxrpc/ar-input.c b/net/rxrpc/ar-input.c
97118 index 529572f..c758ca7 100644
97119 --- a/net/rxrpc/ar-input.c
97120 +++ b/net/rxrpc/ar-input.c
97121 @@ -340,9 +340,9 @@ void rxrpc_fast_process_packet(struct rxrpc_call *call, struct sk_buff *skb)
97122 /* track the latest serial number on this connection for ACK packet
97123 * information */
97124 serial = ntohl(sp->hdr.serial);
97125 - hi_serial = atomic_read(&call->conn->hi_serial);
97126 + hi_serial = atomic_read_unchecked(&call->conn->hi_serial);
97127 while (serial > hi_serial)
97128 - hi_serial = atomic_cmpxchg(&call->conn->hi_serial, hi_serial,
97129 + hi_serial = atomic_cmpxchg_unchecked(&call->conn->hi_serial, hi_serial,
97130 serial);
97131
97132 /* request ACK generation for any ACK or DATA packet that requests
97133 diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h
97134 index a693aca..81e7293 100644
97135 --- a/net/rxrpc/ar-internal.h
97136 +++ b/net/rxrpc/ar-internal.h
97137 @@ -272,8 +272,8 @@ struct rxrpc_connection {
97138 int error; /* error code for local abort */
97139 int debug_id; /* debug ID for printks */
97140 unsigned int call_counter; /* call ID counter */
97141 - atomic_t serial; /* packet serial number counter */
97142 - atomic_t hi_serial; /* highest serial number received */
97143 + atomic_unchecked_t serial; /* packet serial number counter */
97144 + atomic_unchecked_t hi_serial; /* highest serial number received */
97145 u8 avail_calls; /* number of calls available */
97146 u8 size_align; /* data size alignment (for security) */
97147 u8 header_size; /* rxrpc + security header size */
97148 @@ -346,7 +346,7 @@ struct rxrpc_call {
97149 spinlock_t lock;
97150 rwlock_t state_lock; /* lock for state transition */
97151 atomic_t usage;
97152 - atomic_t sequence; /* Tx data packet sequence counter */
97153 + atomic_unchecked_t sequence; /* Tx data packet sequence counter */
97154 u32 abort_code; /* local/remote abort code */
97155 enum { /* current state of call */
97156 RXRPC_CALL_CLIENT_SEND_REQUEST, /* - client sending request phase */
97157 @@ -420,7 +420,7 @@ static inline void rxrpc_abort_call(struct rxrpc_call *call, u32 abort_code)
97158 */
97159 extern atomic_t rxrpc_n_skbs;
97160 extern __be32 rxrpc_epoch;
97161 -extern atomic_t rxrpc_debug_id;
97162 +extern atomic_unchecked_t rxrpc_debug_id;
97163 extern struct workqueue_struct *rxrpc_workqueue;
97164
97165 /*
97166 diff --git a/net/rxrpc/ar-local.c b/net/rxrpc/ar-local.c
97167 index 87f7135..74d3703 100644
97168 --- a/net/rxrpc/ar-local.c
97169 +++ b/net/rxrpc/ar-local.c
97170 @@ -45,7 +45,7 @@ struct rxrpc_local *rxrpc_alloc_local(struct sockaddr_rxrpc *srx)
97171 spin_lock_init(&local->lock);
97172 rwlock_init(&local->services_lock);
97173 atomic_set(&local->usage, 1);
97174 - local->debug_id = atomic_inc_return(&rxrpc_debug_id);
97175 + local->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
97176 memcpy(&local->srx, srx, sizeof(*srx));
97177 }
97178
97179 diff --git a/net/rxrpc/ar-output.c b/net/rxrpc/ar-output.c
97180 index e1ac183..b43e10e 100644
97181 --- a/net/rxrpc/ar-output.c
97182 +++ b/net/rxrpc/ar-output.c
97183 @@ -682,9 +682,9 @@ static int rxrpc_send_data(struct kiocb *iocb,
97184 sp->hdr.cid = call->cid;
97185 sp->hdr.callNumber = call->call_id;
97186 sp->hdr.seq =
97187 - htonl(atomic_inc_return(&call->sequence));
97188 + htonl(atomic_inc_return_unchecked(&call->sequence));
97189 sp->hdr.serial =
97190 - htonl(atomic_inc_return(&conn->serial));
97191 + htonl(atomic_inc_return_unchecked(&conn->serial));
97192 sp->hdr.type = RXRPC_PACKET_TYPE_DATA;
97193 sp->hdr.userStatus = 0;
97194 sp->hdr.securityIndex = conn->security_ix;
97195 diff --git a/net/rxrpc/ar-peer.c b/net/rxrpc/ar-peer.c
97196 index bebaa43..2644591 100644
97197 --- a/net/rxrpc/ar-peer.c
97198 +++ b/net/rxrpc/ar-peer.c
97199 @@ -72,7 +72,7 @@ static struct rxrpc_peer *rxrpc_alloc_peer(struct sockaddr_rxrpc *srx,
97200 INIT_LIST_HEAD(&peer->error_targets);
97201 spin_lock_init(&peer->lock);
97202 atomic_set(&peer->usage, 1);
97203 - peer->debug_id = atomic_inc_return(&rxrpc_debug_id);
97204 + peer->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
97205 memcpy(&peer->srx, srx, sizeof(*srx));
97206
97207 rxrpc_assess_MTU_size(peer);
97208 diff --git a/net/rxrpc/ar-proc.c b/net/rxrpc/ar-proc.c
97209 index 38047f7..9f48511 100644
97210 --- a/net/rxrpc/ar-proc.c
97211 +++ b/net/rxrpc/ar-proc.c
97212 @@ -164,8 +164,8 @@ static int rxrpc_connection_seq_show(struct seq_file *seq, void *v)
97213 atomic_read(&conn->usage),
97214 rxrpc_conn_states[conn->state],
97215 key_serial(conn->key),
97216 - atomic_read(&conn->serial),
97217 - atomic_read(&conn->hi_serial));
97218 + atomic_read_unchecked(&conn->serial),
97219 + atomic_read_unchecked(&conn->hi_serial));
97220
97221 return 0;
97222 }
97223 diff --git a/net/rxrpc/ar-transport.c b/net/rxrpc/ar-transport.c
97224 index 92df566..87ec1bf 100644
97225 --- a/net/rxrpc/ar-transport.c
97226 +++ b/net/rxrpc/ar-transport.c
97227 @@ -47,7 +47,7 @@ static struct rxrpc_transport *rxrpc_alloc_transport(struct rxrpc_local *local,
97228 spin_lock_init(&trans->client_lock);
97229 rwlock_init(&trans->conn_lock);
97230 atomic_set(&trans->usage, 1);
97231 - trans->debug_id = atomic_inc_return(&rxrpc_debug_id);
97232 + trans->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
97233
97234 if (peer->srx.transport.family == AF_INET) {
97235 switch (peer->srx.transport_type) {
97236 diff --git a/net/rxrpc/rxkad.c b/net/rxrpc/rxkad.c
97237 index f226709..0e735a8 100644
97238 --- a/net/rxrpc/rxkad.c
97239 +++ b/net/rxrpc/rxkad.c
97240 @@ -610,7 +610,7 @@ static int rxkad_issue_challenge(struct rxrpc_connection *conn)
97241
97242 len = iov[0].iov_len + iov[1].iov_len;
97243
97244 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
97245 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
97246 _proto("Tx CHALLENGE %%%u", ntohl(hdr.serial));
97247
97248 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
97249 @@ -660,7 +660,7 @@ static int rxkad_send_response(struct rxrpc_connection *conn,
97250
97251 len = iov[0].iov_len + iov[1].iov_len + iov[2].iov_len;
97252
97253 - hdr->serial = htonl(atomic_inc_return(&conn->serial));
97254 + hdr->serial = htonl(atomic_inc_return_unchecked(&conn->serial));
97255 _proto("Tx RESPONSE %%%u", ntohl(hdr->serial));
97256
97257 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 3, len);
97258 diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
97259 index e7b2d4f..bb1efd0 100644
97260 --- a/net/sctp/ipv6.c
97261 +++ b/net/sctp/ipv6.c
97262 @@ -962,7 +962,7 @@ static const struct inet6_protocol sctpv6_protocol = {
97263 .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_FINAL,
97264 };
97265
97266 -static struct sctp_af sctp_af_inet6 = {
97267 +static struct sctp_af sctp_af_inet6 __read_only = {
97268 .sa_family = AF_INET6,
97269 .sctp_xmit = sctp_v6_xmit,
97270 .setsockopt = ipv6_setsockopt,
97271 @@ -994,7 +994,7 @@ static struct sctp_af sctp_af_inet6 = {
97272 #endif
97273 };
97274
97275 -static struct sctp_pf sctp_pf_inet6 = {
97276 +static struct sctp_pf sctp_pf_inet6 __read_only = {
97277 .event_msgname = sctp_inet6_event_msgname,
97278 .skb_msgname = sctp_inet6_skb_msgname,
97279 .af_supported = sctp_inet6_af_supported,
97280 @@ -1019,7 +1019,7 @@ void sctp_v6_pf_init(void)
97281
97282 void sctp_v6_pf_exit(void)
97283 {
97284 - list_del(&sctp_af_inet6.list);
97285 + pax_list_del(&sctp_af_inet6.list);
97286 }
97287
97288 /* Initialize IPv6 support and register with socket layer. */
97289 diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
97290 index 5e17092..19be1d4 100644
97291 --- a/net/sctp/protocol.c
97292 +++ b/net/sctp/protocol.c
97293 @@ -832,8 +832,10 @@ int sctp_register_af(struct sctp_af *af)
97294 return 0;
97295 }
97296
97297 + pax_open_kernel();
97298 INIT_LIST_HEAD(&af->list);
97299 - list_add_tail(&af->list, &sctp_address_families);
97300 + pax_close_kernel();
97301 + pax_list_add_tail(&af->list, &sctp_address_families);
97302 return 1;
97303 }
97304
97305 @@ -963,7 +965,7 @@ static inline int sctp_v4_xmit(struct sk_buff *skb,
97306
97307 static struct sctp_af sctp_af_inet;
97308
97309 -static struct sctp_pf sctp_pf_inet = {
97310 +static struct sctp_pf sctp_pf_inet __read_only = {
97311 .event_msgname = sctp_inet_event_msgname,
97312 .skb_msgname = sctp_inet_skb_msgname,
97313 .af_supported = sctp_inet_af_supported,
97314 @@ -1034,7 +1036,7 @@ static const struct net_protocol sctp_protocol = {
97315 };
97316
97317 /* IPv4 address related functions. */
97318 -static struct sctp_af sctp_af_inet = {
97319 +static struct sctp_af sctp_af_inet __read_only = {
97320 .sa_family = AF_INET,
97321 .sctp_xmit = sctp_v4_xmit,
97322 .setsockopt = ip_setsockopt,
97323 @@ -1119,7 +1121,7 @@ static void sctp_v4_pf_init(void)
97324
97325 static void sctp_v4_pf_exit(void)
97326 {
97327 - list_del(&sctp_af_inet.list);
97328 + pax_list_del(&sctp_af_inet.list);
97329 }
97330
97331 static int sctp_v4_protosw_init(void)
97332 diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c
97333 index 1a6eef3..17e898f 100644
97334 --- a/net/sctp/sm_sideeffect.c
97335 +++ b/net/sctp/sm_sideeffect.c
97336 @@ -440,7 +440,7 @@ static void sctp_generate_sack_event(unsigned long data)
97337 sctp_generate_timeout_event(asoc, SCTP_EVENT_TIMEOUT_SACK);
97338 }
97339
97340 -sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
97341 +sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
97342 NULL,
97343 sctp_generate_t1_cookie_event,
97344 sctp_generate_t1_init_event,
97345 diff --git a/net/sctp/socket.c b/net/sctp/socket.c
97346 index 911b71b..90ade0a 100644
97347 --- a/net/sctp/socket.c
97348 +++ b/net/sctp/socket.c
97349 @@ -2153,11 +2153,13 @@ static int sctp_setsockopt_events(struct sock *sk, char __user *optval,
97350 {
97351 struct sctp_association *asoc;
97352 struct sctp_ulpevent *event;
97353 + struct sctp_event_subscribe subscribe;
97354
97355 if (optlen > sizeof(struct sctp_event_subscribe))
97356 return -EINVAL;
97357 - if (copy_from_user(&sctp_sk(sk)->subscribe, optval, optlen))
97358 + if (copy_from_user(&subscribe, optval, optlen))
97359 return -EFAULT;
97360 + sctp_sk(sk)->subscribe = subscribe;
97361
97362 /*
97363 * At the time when a user app subscribes to SCTP_SENDER_DRY_EVENT,
97364 @@ -4213,13 +4215,16 @@ static int sctp_getsockopt_disable_fragments(struct sock *sk, int len,
97365 static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
97366 int __user *optlen)
97367 {
97368 + struct sctp_event_subscribe subscribe;
97369 +
97370 if (len <= 0)
97371 return -EINVAL;
97372 if (len > sizeof(struct sctp_event_subscribe))
97373 len = sizeof(struct sctp_event_subscribe);
97374 if (put_user(len, optlen))
97375 return -EFAULT;
97376 - if (copy_to_user(optval, &sctp_sk(sk)->subscribe, len))
97377 + subscribe = sctp_sk(sk)->subscribe;
97378 + if (copy_to_user(optval, &subscribe, len))
97379 return -EFAULT;
97380 return 0;
97381 }
97382 @@ -4237,6 +4242,8 @@ static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
97383 */
97384 static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optval, int __user *optlen)
97385 {
97386 + __u32 autoclose;
97387 +
97388 /* Applicable to UDP-style socket only */
97389 if (sctp_style(sk, TCP))
97390 return -EOPNOTSUPP;
97391 @@ -4245,7 +4252,8 @@ static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optv
97392 len = sizeof(int);
97393 if (put_user(len, optlen))
97394 return -EFAULT;
97395 - if (copy_to_user(optval, &sctp_sk(sk)->autoclose, sizeof(int)))
97396 + autoclose = sctp_sk(sk)->autoclose;
97397 + if (copy_to_user(optval, &autoclose, sizeof(int)))
97398 return -EFAULT;
97399 return 0;
97400 }
97401 @@ -4617,12 +4625,15 @@ static int sctp_getsockopt_delayed_ack(struct sock *sk, int len,
97402 */
97403 static int sctp_getsockopt_initmsg(struct sock *sk, int len, char __user *optval, int __user *optlen)
97404 {
97405 + struct sctp_initmsg initmsg;
97406 +
97407 if (len < sizeof(struct sctp_initmsg))
97408 return -EINVAL;
97409 len = sizeof(struct sctp_initmsg);
97410 if (put_user(len, optlen))
97411 return -EFAULT;
97412 - if (copy_to_user(optval, &sctp_sk(sk)->initmsg, len))
97413 + initmsg = sctp_sk(sk)->initmsg;
97414 + if (copy_to_user(optval, &initmsg, len))
97415 return -EFAULT;
97416 return 0;
97417 }
97418 @@ -4663,6 +4674,8 @@ static int sctp_getsockopt_peer_addrs(struct sock *sk, int len,
97419 addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len;
97420 if (space_left < addrlen)
97421 return -ENOMEM;
97422 + if (addrlen > sizeof(temp) || addrlen < 0)
97423 + return -EFAULT;
97424 if (copy_to_user(to, &temp, addrlen))
97425 return -EFAULT;
97426 to += addrlen;
97427 diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c
97428 index 6b36561..4f21064 100644
97429 --- a/net/sctp/sysctl.c
97430 +++ b/net/sctp/sysctl.c
97431 @@ -301,7 +301,7 @@ static int proc_sctp_do_hmac_alg(struct ctl_table *ctl,
97432 {
97433 struct net *net = current->nsproxy->net_ns;
97434 char tmp[8];
97435 - struct ctl_table tbl;
97436 + ctl_table_no_const tbl;
97437 int ret;
97438 int changed = 0;
97439 char *none = "none";
97440 @@ -344,7 +344,7 @@ static int proc_sctp_do_hmac_alg(struct ctl_table *ctl,
97441
97442 int sctp_sysctl_net_register(struct net *net)
97443 {
97444 - struct ctl_table *table;
97445 + ctl_table_no_const *table;
97446 int i;
97447
97448 table = kmemdup(sctp_net_table, sizeof(sctp_net_table), GFP_KERNEL);
97449 diff --git a/net/socket.c b/net/socket.c
97450 index e83c416..9169305 100644
97451 --- a/net/socket.c
97452 +++ b/net/socket.c
97453 @@ -88,6 +88,7 @@
97454 #include <linux/magic.h>
97455 #include <linux/slab.h>
97456 #include <linux/xattr.h>
97457 +#include <linux/in.h>
97458
97459 #include <asm/uaccess.h>
97460 #include <asm/unistd.h>
97461 @@ -111,6 +112,8 @@ unsigned int sysctl_net_busy_read __read_mostly;
97462 unsigned int sysctl_net_busy_poll __read_mostly;
97463 #endif
97464
97465 +#include <linux/grsock.h>
97466 +
97467 static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
97468 static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov,
97469 unsigned long nr_segs, loff_t pos);
97470 @@ -162,7 +165,7 @@ static const struct file_operations socket_file_ops = {
97471 */
97472
97473 static DEFINE_SPINLOCK(net_family_lock);
97474 -static const struct net_proto_family __rcu *net_families[NPROTO] __read_mostly;
97475 +const struct net_proto_family __rcu *net_families[NPROTO] __read_mostly;
97476
97477 /*
97478 * Statistics counters of the socket lists
97479 @@ -328,7 +331,7 @@ static struct dentry *sockfs_mount(struct file_system_type *fs_type,
97480 &sockfs_dentry_operations, SOCKFS_MAGIC);
97481 }
97482
97483 -static struct vfsmount *sock_mnt __read_mostly;
97484 +struct vfsmount *sock_mnt __read_mostly;
97485
97486 static struct file_system_type sock_fs_type = {
97487 .name = "sockfs",
97488 @@ -1255,6 +1258,8 @@ int __sock_create(struct net *net, int family, int type, int protocol,
97489 return -EAFNOSUPPORT;
97490 if (type < 0 || type >= SOCK_MAX)
97491 return -EINVAL;
97492 + if (protocol < 0)
97493 + return -EINVAL;
97494
97495 /* Compatibility.
97496
97497 @@ -1275,6 +1280,20 @@ int __sock_create(struct net *net, int family, int type, int protocol,
97498 if (err)
97499 return err;
97500
97501 + if(!kern && !gr_search_socket(family, type, protocol)) {
97502 + if (rcu_access_pointer(net_families[family]) == NULL)
97503 + return -EAFNOSUPPORT;
97504 + else
97505 + return -EACCES;
97506 + }
97507 +
97508 + if (!kern && gr_handle_sock_all(family, type, protocol)) {
97509 + if (rcu_access_pointer(net_families[family]) == NULL)
97510 + return -EAFNOSUPPORT;
97511 + else
97512 + return -EACCES;
97513 + }
97514 +
97515 /*
97516 * Allocate the socket and allow the family to set things up. if
97517 * the protocol is 0, the family is instructed to select an appropriate
97518 @@ -1513,6 +1532,14 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
97519 if (sock) {
97520 err = move_addr_to_kernel(umyaddr, addrlen, &address);
97521 if (err >= 0) {
97522 + if (gr_handle_sock_server((struct sockaddr *)&address)) {
97523 + err = -EACCES;
97524 + goto error;
97525 + }
97526 + err = gr_search_bind(sock, (struct sockaddr_in *)&address);
97527 + if (err)
97528 + goto error;
97529 +
97530 err = security_socket_bind(sock,
97531 (struct sockaddr *)&address,
97532 addrlen);
97533 @@ -1521,6 +1548,7 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
97534 (struct sockaddr *)
97535 &address, addrlen);
97536 }
97537 +error:
97538 fput_light(sock->file, fput_needed);
97539 }
97540 return err;
97541 @@ -1544,10 +1572,20 @@ SYSCALL_DEFINE2(listen, int, fd, int, backlog)
97542 if ((unsigned int)backlog > somaxconn)
97543 backlog = somaxconn;
97544
97545 + if (gr_handle_sock_server_other(sock->sk)) {
97546 + err = -EPERM;
97547 + goto error;
97548 + }
97549 +
97550 + err = gr_search_listen(sock);
97551 + if (err)
97552 + goto error;
97553 +
97554 err = security_socket_listen(sock, backlog);
97555 if (!err)
97556 err = sock->ops->listen(sock, backlog);
97557
97558 +error:
97559 fput_light(sock->file, fput_needed);
97560 }
97561 return err;
97562 @@ -1591,6 +1629,18 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
97563 newsock->type = sock->type;
97564 newsock->ops = sock->ops;
97565
97566 + if (gr_handle_sock_server_other(sock->sk)) {
97567 + err = -EPERM;
97568 + sock_release(newsock);
97569 + goto out_put;
97570 + }
97571 +
97572 + err = gr_search_accept(sock);
97573 + if (err) {
97574 + sock_release(newsock);
97575 + goto out_put;
97576 + }
97577 +
97578 /*
97579 * We don't need try_module_get here, as the listening socket (sock)
97580 * has the protocol module (sock->ops->owner) held.
97581 @@ -1636,6 +1686,8 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
97582 fd_install(newfd, newfile);
97583 err = newfd;
97584
97585 + gr_attach_curr_ip(newsock->sk);
97586 +
97587 out_put:
97588 fput_light(sock->file, fput_needed);
97589 out:
97590 @@ -1668,6 +1720,7 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
97591 int, addrlen)
97592 {
97593 struct socket *sock;
97594 + struct sockaddr *sck;
97595 struct sockaddr_storage address;
97596 int err, fput_needed;
97597
97598 @@ -1678,6 +1731,17 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
97599 if (err < 0)
97600 goto out_put;
97601
97602 + sck = (struct sockaddr *)&address;
97603 +
97604 + if (gr_handle_sock_client(sck)) {
97605 + err = -EACCES;
97606 + goto out_put;
97607 + }
97608 +
97609 + err = gr_search_connect(sock, (struct sockaddr_in *)sck);
97610 + if (err)
97611 + goto out_put;
97612 +
97613 err =
97614 security_socket_connect(sock, (struct sockaddr *)&address, addrlen);
97615 if (err)
97616 @@ -1759,6 +1823,8 @@ SYSCALL_DEFINE3(getpeername, int, fd, struct sockaddr __user *, usockaddr,
97617 * the protocol.
97618 */
97619
97620 +asmlinkage long sys_sendto(int, void *, size_t, unsigned, struct sockaddr *, int);
97621 +
97622 SYSCALL_DEFINE6(sendto, int, fd, void __user *, buff, size_t, len,
97623 unsigned int, flags, struct sockaddr __user *, addr,
97624 int, addr_len)
97625 @@ -1825,7 +1891,7 @@ SYSCALL_DEFINE6(recvfrom, int, fd, void __user *, ubuf, size_t, size,
97626 struct socket *sock;
97627 struct iovec iov;
97628 struct msghdr msg;
97629 - struct sockaddr_storage address;
97630 + struct sockaddr_storage address = { };
97631 int err, err2;
97632 int fput_needed;
97633
97634 @@ -2047,7 +2113,7 @@ static int ___sys_sendmsg(struct socket *sock, struct msghdr __user *msg,
97635 * checking falls down on this.
97636 */
97637 if (copy_from_user(ctl_buf,
97638 - (void __user __force *)msg_sys->msg_control,
97639 + (void __force_user *)msg_sys->msg_control,
97640 ctl_len))
97641 goto out_freectl;
97642 msg_sys->msg_control = ctl_buf;
97643 @@ -2198,7 +2264,7 @@ static int ___sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
97644 int err, total_len, len;
97645
97646 /* kernel mode address */
97647 - struct sockaddr_storage addr;
97648 + struct sockaddr_storage addr = { };
97649
97650 /* user mode address pointers */
97651 struct sockaddr __user *uaddr;
97652 @@ -2227,7 +2293,7 @@ static int ___sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
97653 /* Save the user-mode address (verify_iovec will change the
97654 * kernel msghdr to use the kernel address space)
97655 */
97656 - uaddr = (__force void __user *)msg_sys->msg_name;
97657 + uaddr = (void __force_user *)msg_sys->msg_name;
97658 uaddr_len = COMPAT_NAMELEN(msg);
97659 if (MSG_CMSG_COMPAT & flags)
97660 err = verify_compat_iovec(msg_sys, iov, &addr, VERIFY_WRITE);
97661 @@ -2985,7 +3051,7 @@ static int bond_ioctl(struct net *net, unsigned int cmd,
97662 old_fs = get_fs();
97663 set_fs(KERNEL_DS);
97664 err = dev_ioctl(net, cmd,
97665 - (struct ifreq __user __force *) &kifr);
97666 + (struct ifreq __force_user *) &kifr);
97667 set_fs(old_fs);
97668
97669 return err;
97670 @@ -3094,7 +3160,7 @@ static int compat_sioc_ifmap(struct net *net, unsigned int cmd,
97671
97672 old_fs = get_fs();
97673 set_fs(KERNEL_DS);
97674 - err = dev_ioctl(net, cmd, (void __user __force *)&ifr);
97675 + err = dev_ioctl(net, cmd, (void __force_user *)&ifr);
97676 set_fs(old_fs);
97677
97678 if (cmd == SIOCGIFMAP && !err) {
97679 @@ -3199,7 +3265,7 @@ static int routing_ioctl(struct net *net, struct socket *sock,
97680 ret |= get_user(rtdev, &(ur4->rt_dev));
97681 if (rtdev) {
97682 ret |= copy_from_user(devname, compat_ptr(rtdev), 15);
97683 - r4.rt_dev = (char __user __force *)devname;
97684 + r4.rt_dev = (char __force_user *)devname;
97685 devname[15] = 0;
97686 } else
97687 r4.rt_dev = NULL;
97688 @@ -3425,8 +3491,8 @@ int kernel_getsockopt(struct socket *sock, int level, int optname,
97689 int __user *uoptlen;
97690 int err;
97691
97692 - uoptval = (char __user __force *) optval;
97693 - uoptlen = (int __user __force *) optlen;
97694 + uoptval = (char __force_user *) optval;
97695 + uoptlen = (int __force_user *) optlen;
97696
97697 set_fs(KERNEL_DS);
97698 if (level == SOL_SOCKET)
97699 @@ -3446,7 +3512,7 @@ int kernel_setsockopt(struct socket *sock, int level, int optname,
97700 char __user *uoptval;
97701 int err;
97702
97703 - uoptval = (char __user __force *) optval;
97704 + uoptval = (char __force_user *) optval;
97705
97706 set_fs(KERNEL_DS);
97707 if (level == SOL_SOCKET)
97708 diff --git a/net/sunrpc/auth_gss/svcauth_gss.c b/net/sunrpc/auth_gss/svcauth_gss.c
97709 index 09fb638..2e6a5c5 100644
97710 --- a/net/sunrpc/auth_gss/svcauth_gss.c
97711 +++ b/net/sunrpc/auth_gss/svcauth_gss.c
97712 @@ -1140,7 +1140,7 @@ static int gss_proxy_save_rsc(struct cache_detail *cd,
97713 uint64_t *handle)
97714 {
97715 struct rsc rsci, *rscp = NULL;
97716 - static atomic64_t ctxhctr;
97717 + static atomic64_unchecked_t ctxhctr = ATOMIC64_INIT(0);
97718 long long ctxh;
97719 struct gss_api_mech *gm = NULL;
97720 time_t expiry;
97721 @@ -1151,7 +1151,7 @@ static int gss_proxy_save_rsc(struct cache_detail *cd,
97722 status = -ENOMEM;
97723 /* the handle needs to be just a unique id,
97724 * use a static counter */
97725 - ctxh = atomic64_inc_return(&ctxhctr);
97726 + ctxh = atomic64_inc_return_unchecked(&ctxhctr);
97727
97728 /* make a copy for the caller */
97729 *handle = ctxh;
97730 diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
97731 index 941d19f..c85ff07 100644
97732 --- a/net/sunrpc/clnt.c
97733 +++ b/net/sunrpc/clnt.c
97734 @@ -1319,7 +1319,9 @@ call_start(struct rpc_task *task)
97735 (RPC_IS_ASYNC(task) ? "async" : "sync"));
97736
97737 /* Increment call count */
97738 - task->tk_msg.rpc_proc->p_count++;
97739 + pax_open_kernel();
97740 + (*(unsigned int *)&task->tk_msg.rpc_proc->p_count)++;
97741 + pax_close_kernel();
97742 clnt->cl_stats->rpccnt++;
97743 task->tk_action = call_reserve;
97744 }
97745 diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
97746 index ff3cc4b..7612a9e 100644
97747 --- a/net/sunrpc/sched.c
97748 +++ b/net/sunrpc/sched.c
97749 @@ -261,9 +261,9 @@ static int rpc_wait_bit_killable(void *word)
97750 #if defined(RPC_DEBUG) || defined(RPC_TRACEPOINTS)
97751 static void rpc_task_set_debuginfo(struct rpc_task *task)
97752 {
97753 - static atomic_t rpc_pid;
97754 + static atomic_unchecked_t rpc_pid;
97755
97756 - task->tk_pid = atomic_inc_return(&rpc_pid);
97757 + task->tk_pid = atomic_inc_return_unchecked(&rpc_pid);
97758 }
97759 #else
97760 static inline void rpc_task_set_debuginfo(struct rpc_task *task)
97761 diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
97762 index b974571..678ed90 100644
97763 --- a/net/sunrpc/svc.c
97764 +++ b/net/sunrpc/svc.c
97765 @@ -1160,7 +1160,9 @@ svc_process_common(struct svc_rqst *rqstp, struct kvec *argv, struct kvec *resv)
97766 svc_putnl(resv, RPC_SUCCESS);
97767
97768 /* Bump per-procedure stats counter */
97769 - procp->pc_count++;
97770 + pax_open_kernel();
97771 + (*(unsigned int *)&procp->pc_count)++;
97772 + pax_close_kernel();
97773
97774 /* Initialize storage for argp and resp */
97775 memset(rqstp->rq_argp, 0, procp->pc_argsize);
97776 diff --git a/net/sunrpc/svcauth_unix.c b/net/sunrpc/svcauth_unix.c
97777 index 621ca7b..59421dd 100644
97778 --- a/net/sunrpc/svcauth_unix.c
97779 +++ b/net/sunrpc/svcauth_unix.c
97780 @@ -414,7 +414,7 @@ struct unix_gid {
97781 struct group_info *gi;
97782 };
97783
97784 -static int unix_gid_hash(kuid_t uid)
97785 +static int __intentional_overflow(-1) unix_gid_hash(kuid_t uid)
97786 {
97787 return hash_long(from_kuid(&init_user_ns, uid), GID_HASHBITS);
97788 }
97789 @@ -470,7 +470,7 @@ static void unix_gid_request(struct cache_detail *cd,
97790 (*bpp)[-1] = '\n';
97791 }
97792
97793 -static struct unix_gid *unix_gid_lookup(struct cache_detail *cd, kuid_t uid);
97794 +static struct unix_gid * __intentional_overflow(-1) unix_gid_lookup(struct cache_detail *cd, kuid_t uid);
97795
97796 static int unix_gid_parse(struct cache_detail *cd,
97797 char *mesg, int mlen)
97798 diff --git a/net/sunrpc/xprtrdma/svc_rdma.c b/net/sunrpc/xprtrdma/svc_rdma.c
97799 index c1b6270..05089c1 100644
97800 --- a/net/sunrpc/xprtrdma/svc_rdma.c
97801 +++ b/net/sunrpc/xprtrdma/svc_rdma.c
97802 @@ -62,15 +62,15 @@ unsigned int svcrdma_max_req_size = RPCRDMA_MAX_REQ_SIZE;
97803 static unsigned int min_max_inline = 4096;
97804 static unsigned int max_max_inline = 65536;
97805
97806 -atomic_t rdma_stat_recv;
97807 -atomic_t rdma_stat_read;
97808 -atomic_t rdma_stat_write;
97809 -atomic_t rdma_stat_sq_starve;
97810 -atomic_t rdma_stat_rq_starve;
97811 -atomic_t rdma_stat_rq_poll;
97812 -atomic_t rdma_stat_rq_prod;
97813 -atomic_t rdma_stat_sq_poll;
97814 -atomic_t rdma_stat_sq_prod;
97815 +atomic_unchecked_t rdma_stat_recv;
97816 +atomic_unchecked_t rdma_stat_read;
97817 +atomic_unchecked_t rdma_stat_write;
97818 +atomic_unchecked_t rdma_stat_sq_starve;
97819 +atomic_unchecked_t rdma_stat_rq_starve;
97820 +atomic_unchecked_t rdma_stat_rq_poll;
97821 +atomic_unchecked_t rdma_stat_rq_prod;
97822 +atomic_unchecked_t rdma_stat_sq_poll;
97823 +atomic_unchecked_t rdma_stat_sq_prod;
97824
97825 /* Temporary NFS request map and context caches */
97826 struct kmem_cache *svc_rdma_map_cachep;
97827 @@ -110,7 +110,7 @@ static int read_reset_stat(struct ctl_table *table, int write,
97828 len -= *ppos;
97829 if (len > *lenp)
97830 len = *lenp;
97831 - if (len && copy_to_user(buffer, str_buf, len))
97832 + if (len > sizeof str_buf || (len && copy_to_user(buffer, str_buf, len)))
97833 return -EFAULT;
97834 *lenp = len;
97835 *ppos += len;
97836 @@ -151,63 +151,63 @@ static struct ctl_table svcrdma_parm_table[] = {
97837 {
97838 .procname = "rdma_stat_read",
97839 .data = &rdma_stat_read,
97840 - .maxlen = sizeof(atomic_t),
97841 + .maxlen = sizeof(atomic_unchecked_t),
97842 .mode = 0644,
97843 .proc_handler = read_reset_stat,
97844 },
97845 {
97846 .procname = "rdma_stat_recv",
97847 .data = &rdma_stat_recv,
97848 - .maxlen = sizeof(atomic_t),
97849 + .maxlen = sizeof(atomic_unchecked_t),
97850 .mode = 0644,
97851 .proc_handler = read_reset_stat,
97852 },
97853 {
97854 .procname = "rdma_stat_write",
97855 .data = &rdma_stat_write,
97856 - .maxlen = sizeof(atomic_t),
97857 + .maxlen = sizeof(atomic_unchecked_t),
97858 .mode = 0644,
97859 .proc_handler = read_reset_stat,
97860 },
97861 {
97862 .procname = "rdma_stat_sq_starve",
97863 .data = &rdma_stat_sq_starve,
97864 - .maxlen = sizeof(atomic_t),
97865 + .maxlen = sizeof(atomic_unchecked_t),
97866 .mode = 0644,
97867 .proc_handler = read_reset_stat,
97868 },
97869 {
97870 .procname = "rdma_stat_rq_starve",
97871 .data = &rdma_stat_rq_starve,
97872 - .maxlen = sizeof(atomic_t),
97873 + .maxlen = sizeof(atomic_unchecked_t),
97874 .mode = 0644,
97875 .proc_handler = read_reset_stat,
97876 },
97877 {
97878 .procname = "rdma_stat_rq_poll",
97879 .data = &rdma_stat_rq_poll,
97880 - .maxlen = sizeof(atomic_t),
97881 + .maxlen = sizeof(atomic_unchecked_t),
97882 .mode = 0644,
97883 .proc_handler = read_reset_stat,
97884 },
97885 {
97886 .procname = "rdma_stat_rq_prod",
97887 .data = &rdma_stat_rq_prod,
97888 - .maxlen = sizeof(atomic_t),
97889 + .maxlen = sizeof(atomic_unchecked_t),
97890 .mode = 0644,
97891 .proc_handler = read_reset_stat,
97892 },
97893 {
97894 .procname = "rdma_stat_sq_poll",
97895 .data = &rdma_stat_sq_poll,
97896 - .maxlen = sizeof(atomic_t),
97897 + .maxlen = sizeof(atomic_unchecked_t),
97898 .mode = 0644,
97899 .proc_handler = read_reset_stat,
97900 },
97901 {
97902 .procname = "rdma_stat_sq_prod",
97903 .data = &rdma_stat_sq_prod,
97904 - .maxlen = sizeof(atomic_t),
97905 + .maxlen = sizeof(atomic_unchecked_t),
97906 .mode = 0644,
97907 .proc_handler = read_reset_stat,
97908 },
97909 diff --git a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
97910 index 0ce7552..d074459 100644
97911 --- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
97912 +++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
97913 @@ -501,7 +501,7 @@ next_sge:
97914 svc_rdma_put_context(ctxt, 0);
97915 goto out;
97916 }
97917 - atomic_inc(&rdma_stat_read);
97918 + atomic_inc_unchecked(&rdma_stat_read);
97919
97920 if (read_wr.num_sge < chl_map->ch[ch_no].count) {
97921 chl_map->ch[ch_no].count -= read_wr.num_sge;
97922 @@ -611,7 +611,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
97923 dto_q);
97924 list_del_init(&ctxt->dto_q);
97925 } else {
97926 - atomic_inc(&rdma_stat_rq_starve);
97927 + atomic_inc_unchecked(&rdma_stat_rq_starve);
97928 clear_bit(XPT_DATA, &xprt->xpt_flags);
97929 ctxt = NULL;
97930 }
97931 @@ -631,7 +631,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
97932 dprintk("svcrdma: processing ctxt=%p on xprt=%p, rqstp=%p, status=%d\n",
97933 ctxt, rdma_xprt, rqstp, ctxt->wc_status);
97934 BUG_ON(ctxt->wc_status != IB_WC_SUCCESS);
97935 - atomic_inc(&rdma_stat_recv);
97936 + atomic_inc_unchecked(&rdma_stat_recv);
97937
97938 /* Build up the XDR from the receive buffers. */
97939 rdma_build_arg_xdr(rqstp, ctxt, ctxt->byte_len);
97940 diff --git a/net/sunrpc/xprtrdma/svc_rdma_sendto.c b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
97941 index c1d124d..acfc59e 100644
97942 --- a/net/sunrpc/xprtrdma/svc_rdma_sendto.c
97943 +++ b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
97944 @@ -362,7 +362,7 @@ static int send_write(struct svcxprt_rdma *xprt, struct svc_rqst *rqstp,
97945 write_wr.wr.rdma.remote_addr = to;
97946
97947 /* Post It */
97948 - atomic_inc(&rdma_stat_write);
97949 + atomic_inc_unchecked(&rdma_stat_write);
97950 if (svc_rdma_send(xprt, &write_wr))
97951 goto err;
97952 return 0;
97953 diff --git a/net/sunrpc/xprtrdma/svc_rdma_transport.c b/net/sunrpc/xprtrdma/svc_rdma_transport.c
97954 index 62e4f9b..dd3f2d7 100644
97955 --- a/net/sunrpc/xprtrdma/svc_rdma_transport.c
97956 +++ b/net/sunrpc/xprtrdma/svc_rdma_transport.c
97957 @@ -292,7 +292,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
97958 return;
97959
97960 ib_req_notify_cq(xprt->sc_rq_cq, IB_CQ_NEXT_COMP);
97961 - atomic_inc(&rdma_stat_rq_poll);
97962 + atomic_inc_unchecked(&rdma_stat_rq_poll);
97963
97964 while ((ret = ib_poll_cq(xprt->sc_rq_cq, 1, &wc)) > 0) {
97965 ctxt = (struct svc_rdma_op_ctxt *)(unsigned long)wc.wr_id;
97966 @@ -314,7 +314,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
97967 }
97968
97969 if (ctxt)
97970 - atomic_inc(&rdma_stat_rq_prod);
97971 + atomic_inc_unchecked(&rdma_stat_rq_prod);
97972
97973 set_bit(XPT_DATA, &xprt->sc_xprt.xpt_flags);
97974 /*
97975 @@ -386,7 +386,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
97976 return;
97977
97978 ib_req_notify_cq(xprt->sc_sq_cq, IB_CQ_NEXT_COMP);
97979 - atomic_inc(&rdma_stat_sq_poll);
97980 + atomic_inc_unchecked(&rdma_stat_sq_poll);
97981 while ((ret = ib_poll_cq(cq, 1, &wc)) > 0) {
97982 if (wc.status != IB_WC_SUCCESS)
97983 /* Close the transport */
97984 @@ -404,7 +404,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
97985 }
97986
97987 if (ctxt)
97988 - atomic_inc(&rdma_stat_sq_prod);
97989 + atomic_inc_unchecked(&rdma_stat_sq_prod);
97990 }
97991
97992 static void sq_comp_handler(struct ib_cq *cq, void *cq_context)
97993 @@ -1262,7 +1262,7 @@ int svc_rdma_send(struct svcxprt_rdma *xprt, struct ib_send_wr *wr)
97994 spin_lock_bh(&xprt->sc_lock);
97995 if (xprt->sc_sq_depth < atomic_read(&xprt->sc_sq_count) + wr_count) {
97996 spin_unlock_bh(&xprt->sc_lock);
97997 - atomic_inc(&rdma_stat_sq_starve);
97998 + atomic_inc_unchecked(&rdma_stat_sq_starve);
97999
98000 /* See if we can opportunistically reap SQ WR to make room */
98001 sq_cq_reap(xprt);
98002 diff --git a/net/sysctl_net.c b/net/sysctl_net.c
98003 index e7000be..e3b0ba7 100644
98004 --- a/net/sysctl_net.c
98005 +++ b/net/sysctl_net.c
98006 @@ -46,7 +46,7 @@ static int net_ctl_permissions(struct ctl_table_header *head,
98007 kgid_t root_gid = make_kgid(net->user_ns, 0);
98008
98009 /* Allow network administrator to have same access as root. */
98010 - if (ns_capable(net->user_ns, CAP_NET_ADMIN) ||
98011 + if (ns_capable_nolog(net->user_ns, CAP_NET_ADMIN) ||
98012 uid_eq(root_uid, current_euid())) {
98013 int mode = (table->mode >> 6) & 7;
98014 return (mode << 6) | (mode << 3) | mode;
98015 diff --git a/net/tipc/link.c b/net/tipc/link.c
98016 index 0cc3d90..cc42021 100644
98017 --- a/net/tipc/link.c
98018 +++ b/net/tipc/link.c
98019 @@ -1165,7 +1165,7 @@ static int link_send_sections_long(struct tipc_port *sender,
98020 struct tipc_msg fragm_hdr;
98021 struct sk_buff *buf, *buf_chain, *prev;
98022 u32 fragm_crs, fragm_rest, hsz, sect_rest;
98023 - const unchar *sect_crs;
98024 + const unchar __user *sect_crs;
98025 int curr_sect;
98026 u32 fragm_no;
98027 int res = 0;
98028 @@ -1207,7 +1207,7 @@ again:
98029
98030 if (!sect_rest) {
98031 sect_rest = msg_sect[++curr_sect].iov_len;
98032 - sect_crs = (const unchar *)msg_sect[curr_sect].iov_base;
98033 + sect_crs = (const unchar __user *)msg_sect[curr_sect].iov_base;
98034 }
98035
98036 if (sect_rest < fragm_rest)
98037 diff --git a/net/tipc/msg.c b/net/tipc/msg.c
98038 index ced60e2..54eab6c 100644
98039 --- a/net/tipc/msg.c
98040 +++ b/net/tipc/msg.c
98041 @@ -93,7 +93,7 @@ int tipc_msg_build(struct tipc_msg *hdr, struct iovec const *msg_sect,
98042 skb_copy_to_linear_data(*buf, hdr, hsz);
98043 for (res = 1, cnt = 0; res && (cnt < num_sect); cnt++) {
98044 skb_copy_to_linear_data_offset(*buf, pos,
98045 - msg_sect[cnt].iov_base,
98046 + (const void __force_kernel *)msg_sect[cnt].iov_base,
98047 msg_sect[cnt].iov_len);
98048 pos += msg_sect[cnt].iov_len;
98049 }
98050 diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c
98051 index d38bb45..4fd6ac6 100644
98052 --- a/net/tipc/subscr.c
98053 +++ b/net/tipc/subscr.c
98054 @@ -98,7 +98,7 @@ static void subscr_send_event(struct tipc_subscription *sub, u32 found_lower,
98055 struct kvec msg_sect;
98056 int ret;
98057
98058 - msg_sect.iov_base = (void *)&sub->evt;
98059 + msg_sect.iov_base = (void __force_user *)&sub->evt;
98060 msg_sect.iov_len = sizeof(struct tipc_event);
98061
98062 sub->evt.event = htohl(event, sub->swap);
98063 diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
98064 index 01625cc..d486b64 100644
98065 --- a/net/unix/af_unix.c
98066 +++ b/net/unix/af_unix.c
98067 @@ -784,6 +784,12 @@ static struct sock *unix_find_other(struct net *net,
98068 err = -ECONNREFUSED;
98069 if (!S_ISSOCK(inode->i_mode))
98070 goto put_fail;
98071 +
98072 + if (!gr_acl_handle_unix(path.dentry, path.mnt)) {
98073 + err = -EACCES;
98074 + goto put_fail;
98075 + }
98076 +
98077 u = unix_find_socket_byinode(inode);
98078 if (!u)
98079 goto put_fail;
98080 @@ -804,6 +810,13 @@ static struct sock *unix_find_other(struct net *net,
98081 if (u) {
98082 struct dentry *dentry;
98083 dentry = unix_sk(u)->path.dentry;
98084 +
98085 + if (!gr_handle_chroot_unix(pid_vnr(u->sk_peer_pid))) {
98086 + err = -EPERM;
98087 + sock_put(u);
98088 + goto fail;
98089 + }
98090 +
98091 if (dentry)
98092 touch_atime(&unix_sk(u)->path);
98093 } else
98094 @@ -837,12 +850,18 @@ static int unix_mknod(const char *sun_path, umode_t mode, struct path *res)
98095 */
98096 err = security_path_mknod(&path, dentry, mode, 0);
98097 if (!err) {
98098 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
98099 + err = -EACCES;
98100 + goto out;
98101 + }
98102 err = vfs_mknod(path.dentry->d_inode, dentry, mode, 0);
98103 if (!err) {
98104 res->mnt = mntget(path.mnt);
98105 res->dentry = dget(dentry);
98106 + gr_handle_create(dentry, path.mnt);
98107 }
98108 }
98109 +out:
98110 done_path_create(&path, dentry);
98111 return err;
98112 }
98113 @@ -2328,9 +2347,13 @@ static int unix_seq_show(struct seq_file *seq, void *v)
98114 seq_puts(seq, "Num RefCount Protocol Flags Type St "
98115 "Inode Path\n");
98116 else {
98117 - struct sock *s = v;
98118 + struct sock *s = v, *peer;
98119 struct unix_sock *u = unix_sk(s);
98120 unix_state_lock(s);
98121 + peer = unix_peer(s);
98122 + unix_state_unlock(s);
98123 +
98124 + unix_state_double_lock(s, peer);
98125
98126 seq_printf(seq, "%pK: %08X %08X %08X %04X %02X %5lu",
98127 s,
98128 @@ -2357,8 +2380,10 @@ static int unix_seq_show(struct seq_file *seq, void *v)
98129 }
98130 for ( ; i < len; i++)
98131 seq_putc(seq, u->addr->name->sun_path[i]);
98132 - }
98133 - unix_state_unlock(s);
98134 + } else if (peer)
98135 + seq_printf(seq, " P%lu", sock_i_ino(peer));
98136 +
98137 + unix_state_double_unlock(s, peer);
98138 seq_putc(seq, '\n');
98139 }
98140
98141 diff --git a/net/unix/sysctl_net_unix.c b/net/unix/sysctl_net_unix.c
98142 index b3d5150..ff3a837 100644
98143 --- a/net/unix/sysctl_net_unix.c
98144 +++ b/net/unix/sysctl_net_unix.c
98145 @@ -28,7 +28,7 @@ static struct ctl_table unix_table[] = {
98146
98147 int __net_init unix_sysctl_register(struct net *net)
98148 {
98149 - struct ctl_table *table;
98150 + ctl_table_no_const *table;
98151
98152 table = kmemdup(unix_table, sizeof(unix_table), GFP_KERNEL);
98153 if (table == NULL)
98154 diff --git a/net/wireless/wext-core.c b/net/wireless/wext-core.c
98155 index c8717c1..08539f5 100644
98156 --- a/net/wireless/wext-core.c
98157 +++ b/net/wireless/wext-core.c
98158 @@ -748,8 +748,7 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
98159 */
98160
98161 /* Support for very large requests */
98162 - if ((descr->flags & IW_DESCR_FLAG_NOMAX) &&
98163 - (user_length > descr->max_tokens)) {
98164 + if (user_length > descr->max_tokens) {
98165 /* Allow userspace to GET more than max so
98166 * we can support any size GET requests.
98167 * There is still a limit : -ENOMEM.
98168 @@ -788,22 +787,6 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
98169 }
98170 }
98171
98172 - if (IW_IS_GET(cmd) && !(descr->flags & IW_DESCR_FLAG_NOMAX)) {
98173 - /*
98174 - * If this is a GET, but not NOMAX, it means that the extra
98175 - * data is not bounded by userspace, but by max_tokens. Thus
98176 - * set the length to max_tokens. This matches the extra data
98177 - * allocation.
98178 - * The driver should fill it with the number of tokens it
98179 - * provided, and it may check iwp->length rather than having
98180 - * knowledge of max_tokens. If the driver doesn't change the
98181 - * iwp->length, this ioctl just copies back max_token tokens
98182 - * filled with zeroes. Hopefully the driver isn't claiming
98183 - * them to be valid data.
98184 - */
98185 - iwp->length = descr->max_tokens;
98186 - }
98187 -
98188 err = handler(dev, info, (union iwreq_data *) iwp, extra);
98189
98190 iwp->length += essid_compat;
98191 diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
98192 index 76e1873..4a12664 100644
98193 --- a/net/xfrm/xfrm_policy.c
98194 +++ b/net/xfrm/xfrm_policy.c
98195 @@ -332,7 +332,7 @@ static void xfrm_policy_kill(struct xfrm_policy *policy)
98196 {
98197 policy->walk.dead = 1;
98198
98199 - atomic_inc(&policy->genid);
98200 + atomic_inc_unchecked(&policy->genid);
98201
98202 if (del_timer(&policy->polq.hold_timer))
98203 xfrm_pol_put(policy);
98204 @@ -660,7 +660,7 @@ int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl)
98205 hlist_add_head(&policy->bydst, chain);
98206 xfrm_pol_hold(policy);
98207 net->xfrm.policy_count[dir]++;
98208 - atomic_inc(&flow_cache_genid);
98209 + atomic_inc_unchecked(&flow_cache_genid);
98210
98211 /* After previous checking, family can either be AF_INET or AF_INET6 */
98212 if (policy->family == AF_INET)
98213 @@ -1636,7 +1636,7 @@ free_dst:
98214 goto out;
98215 }
98216
98217 -static int inline
98218 +static inline int
98219 xfrm_dst_alloc_copy(void **target, const void *src, int size)
98220 {
98221 if (!*target) {
98222 @@ -1648,7 +1648,7 @@ xfrm_dst_alloc_copy(void **target, const void *src, int size)
98223 return 0;
98224 }
98225
98226 -static int inline
98227 +static inline int
98228 xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
98229 {
98230 #ifdef CONFIG_XFRM_SUB_POLICY
98231 @@ -1660,7 +1660,7 @@ xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
98232 #endif
98233 }
98234
98235 -static int inline
98236 +static inline int
98237 xfrm_dst_update_origin(struct dst_entry *dst, const struct flowi *fl)
98238 {
98239 #ifdef CONFIG_XFRM_SUB_POLICY
98240 @@ -1754,7 +1754,7 @@ xfrm_resolve_and_create_bundle(struct xfrm_policy **pols, int num_pols,
98241
98242 xdst->num_pols = num_pols;
98243 memcpy(xdst->pols, pols, sizeof(struct xfrm_policy*) * num_pols);
98244 - xdst->policy_genid = atomic_read(&pols[0]->genid);
98245 + xdst->policy_genid = atomic_read_unchecked(&pols[0]->genid);
98246
98247 return xdst;
98248 }
98249 @@ -2575,11 +2575,12 @@ void xfrm_garbage_collect(struct net *net)
98250 }
98251 EXPORT_SYMBOL(xfrm_garbage_collect);
98252
98253 -static void xfrm_garbage_collect_deferred(struct net *net)
98254 +void xfrm_garbage_collect_deferred(struct net *net)
98255 {
98256 flow_cache_flush_deferred();
98257 __xfrm_garbage_collect(net);
98258 }
98259 +EXPORT_SYMBOL(xfrm_garbage_collect_deferred);
98260
98261 static void xfrm_init_pmtu(struct dst_entry *dst)
98262 {
98263 @@ -2629,7 +2630,7 @@ static int xfrm_bundle_ok(struct xfrm_dst *first)
98264 if (xdst->xfrm_genid != dst->xfrm->genid)
98265 return 0;
98266 if (xdst->num_pols > 0 &&
98267 - xdst->policy_genid != atomic_read(&xdst->pols[0]->genid))
98268 + xdst->policy_genid != atomic_read_unchecked(&xdst->pols[0]->genid))
98269 return 0;
98270
98271 mtu = dst_mtu(dst->child);
98272 @@ -2717,8 +2718,6 @@ int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo)
98273 dst_ops->link_failure = xfrm_link_failure;
98274 if (likely(dst_ops->neigh_lookup == NULL))
98275 dst_ops->neigh_lookup = xfrm_neigh_lookup;
98276 - if (likely(afinfo->garbage_collect == NULL))
98277 - afinfo->garbage_collect = xfrm_garbage_collect_deferred;
98278 rcu_assign_pointer(xfrm_policy_afinfo[afinfo->family], afinfo);
98279 }
98280 spin_unlock(&xfrm_policy_afinfo_lock);
98281 @@ -2772,7 +2771,6 @@ int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo)
98282 dst_ops->check = NULL;
98283 dst_ops->negative_advice = NULL;
98284 dst_ops->link_failure = NULL;
98285 - afinfo->garbage_collect = NULL;
98286 }
98287 return err;
98288 }
98289 @@ -3155,7 +3153,7 @@ static int xfrm_policy_migrate(struct xfrm_policy *pol,
98290 sizeof(pol->xfrm_vec[i].saddr));
98291 pol->xfrm_vec[i].encap_family = mp->new_family;
98292 /* flush bundles */
98293 - atomic_inc(&pol->genid);
98294 + atomic_inc_unchecked(&pol->genid);
98295 }
98296 }
98297
98298 diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
98299 index b9c3f9e..4767526 100644
98300 --- a/net/xfrm/xfrm_state.c
98301 +++ b/net/xfrm/xfrm_state.c
98302 @@ -174,12 +174,14 @@ int xfrm_register_type(const struct xfrm_type *type, unsigned short family)
98303
98304 if (unlikely(afinfo == NULL))
98305 return -EAFNOSUPPORT;
98306 - typemap = afinfo->type_map;
98307 + typemap = (const struct xfrm_type **)afinfo->type_map;
98308 spin_lock_bh(&xfrm_type_lock);
98309
98310 - if (likely(typemap[type->proto] == NULL))
98311 + if (likely(typemap[type->proto] == NULL)) {
98312 + pax_open_kernel();
98313 typemap[type->proto] = type;
98314 - else
98315 + pax_close_kernel();
98316 + } else
98317 err = -EEXIST;
98318 spin_unlock_bh(&xfrm_type_lock);
98319 xfrm_state_put_afinfo(afinfo);
98320 @@ -195,13 +197,16 @@ int xfrm_unregister_type(const struct xfrm_type *type, unsigned short family)
98321
98322 if (unlikely(afinfo == NULL))
98323 return -EAFNOSUPPORT;
98324 - typemap = afinfo->type_map;
98325 + typemap = (const struct xfrm_type **)afinfo->type_map;
98326 spin_lock_bh(&xfrm_type_lock);
98327
98328 if (unlikely(typemap[type->proto] != type))
98329 err = -ENOENT;
98330 - else
98331 + else {
98332 + pax_open_kernel();
98333 typemap[type->proto] = NULL;
98334 + pax_close_kernel();
98335 + }
98336 spin_unlock_bh(&xfrm_type_lock);
98337 xfrm_state_put_afinfo(afinfo);
98338 return err;
98339 @@ -211,7 +216,6 @@ EXPORT_SYMBOL(xfrm_unregister_type);
98340 static const struct xfrm_type *xfrm_get_type(u8 proto, unsigned short family)
98341 {
98342 struct xfrm_state_afinfo *afinfo;
98343 - const struct xfrm_type **typemap;
98344 const struct xfrm_type *type;
98345 int modload_attempted = 0;
98346
98347 @@ -219,9 +223,8 @@ retry:
98348 afinfo = xfrm_state_get_afinfo(family);
98349 if (unlikely(afinfo == NULL))
98350 return NULL;
98351 - typemap = afinfo->type_map;
98352
98353 - type = typemap[proto];
98354 + type = afinfo->type_map[proto];
98355 if (unlikely(type && !try_module_get(type->owner)))
98356 type = NULL;
98357 if (!type && !modload_attempted) {
98358 @@ -255,7 +258,7 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
98359 return -EAFNOSUPPORT;
98360
98361 err = -EEXIST;
98362 - modemap = afinfo->mode_map;
98363 + modemap = (struct xfrm_mode **)afinfo->mode_map;
98364 spin_lock_bh(&xfrm_mode_lock);
98365 if (modemap[mode->encap])
98366 goto out;
98367 @@ -264,8 +267,10 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
98368 if (!try_module_get(afinfo->owner))
98369 goto out;
98370
98371 - mode->afinfo = afinfo;
98372 + pax_open_kernel();
98373 + *(const void **)&mode->afinfo = afinfo;
98374 modemap[mode->encap] = mode;
98375 + pax_close_kernel();
98376 err = 0;
98377
98378 out:
98379 @@ -289,10 +294,12 @@ int xfrm_unregister_mode(struct xfrm_mode *mode, int family)
98380 return -EAFNOSUPPORT;
98381
98382 err = -ENOENT;
98383 - modemap = afinfo->mode_map;
98384 + modemap = (struct xfrm_mode **)afinfo->mode_map;
98385 spin_lock_bh(&xfrm_mode_lock);
98386 if (likely(modemap[mode->encap] == mode)) {
98387 + pax_open_kernel();
98388 modemap[mode->encap] = NULL;
98389 + pax_close_kernel();
98390 module_put(mode->afinfo->owner);
98391 err = 0;
98392 }
98393 @@ -1486,10 +1493,10 @@ EXPORT_SYMBOL(xfrm_find_acq_byseq);
98394 u32 xfrm_get_acqseq(void)
98395 {
98396 u32 res;
98397 - static atomic_t acqseq;
98398 + static atomic_unchecked_t acqseq;
98399
98400 do {
98401 - res = atomic_inc_return(&acqseq);
98402 + res = atomic_inc_return_unchecked(&acqseq);
98403 } while (!res);
98404
98405 return res;
98406 diff --git a/net/xfrm/xfrm_sysctl.c b/net/xfrm/xfrm_sysctl.c
98407 index 05a6e3d..6716ec9 100644
98408 --- a/net/xfrm/xfrm_sysctl.c
98409 +++ b/net/xfrm/xfrm_sysctl.c
98410 @@ -42,7 +42,7 @@ static struct ctl_table xfrm_table[] = {
98411
98412 int __net_init xfrm_sysctl_init(struct net *net)
98413 {
98414 - struct ctl_table *table;
98415 + ctl_table_no_const *table;
98416
98417 __xfrm_sysctl_init(net);
98418
98419 diff --git a/scripts/Makefile.build b/scripts/Makefile.build
98420 index d5d859c..781cbcb 100644
98421 --- a/scripts/Makefile.build
98422 +++ b/scripts/Makefile.build
98423 @@ -111,7 +111,7 @@ endif
98424 endif
98425
98426 # Do not include host rules unless needed
98427 -ifneq ($(hostprogs-y)$(hostprogs-m),)
98428 +ifneq ($(hostprogs-y)$(hostprogs-m)$(hostlibs-y)$(hostlibs-m)$(hostcxxlibs-y)$(hostcxxlibs-m),)
98429 include scripts/Makefile.host
98430 endif
98431
98432 diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean
98433 index 686cb0d..9d653bf 100644
98434 --- a/scripts/Makefile.clean
98435 +++ b/scripts/Makefile.clean
98436 @@ -43,7 +43,8 @@ subdir-ymn := $(addprefix $(obj)/,$(subdir-ymn))
98437 __clean-files := $(extra-y) $(always) \
98438 $(targets) $(clean-files) \
98439 $(host-progs) \
98440 - $(hostprogs-y) $(hostprogs-m) $(hostprogs-)
98441 + $(hostprogs-y) $(hostprogs-m) $(hostprogs-) \
98442 + $(hostlibs-y) $(hostlibs-m) $(hostlibs-)
98443
98444 __clean-files := $(filter-out $(no-clean-files), $(__clean-files))
98445
98446 diff --git a/scripts/Makefile.host b/scripts/Makefile.host
98447 index 1ac414f..38575f7 100644
98448 --- a/scripts/Makefile.host
98449 +++ b/scripts/Makefile.host
98450 @@ -31,6 +31,8 @@
98451 # Note: Shared libraries consisting of C++ files are not supported
98452
98453 __hostprogs := $(sort $(hostprogs-y) $(hostprogs-m))
98454 +__hostlibs := $(sort $(hostlibs-y) $(hostlibs-m))
98455 +__hostcxxlibs := $(sort $(hostcxxlibs-y) $(hostcxxlibs-m))
98456
98457 # C code
98458 # Executables compiled from a single .c file
98459 @@ -54,11 +56,15 @@ host-cxxobjs := $(sort $(foreach m,$(host-cxxmulti),$($(m)-cxxobjs)))
98460 # Shared libaries (only .c supported)
98461 # Shared libraries (.so) - all .so files referenced in "xxx-objs"
98462 host-cshlib := $(sort $(filter %.so, $(host-cobjs)))
98463 +host-cshlib += $(sort $(filter %.so, $(__hostlibs)))
98464 +host-cxxshlib := $(sort $(filter %.so, $(__hostcxxlibs)))
98465 # Remove .so files from "xxx-objs"
98466 host-cobjs := $(filter-out %.so,$(host-cobjs))
98467 +host-cxxobjs := $(filter-out %.so,$(host-cxxobjs))
98468
98469 -#Object (.o) files used by the shared libaries
98470 +# Object (.o) files used by the shared libaries
98471 host-cshobjs := $(sort $(foreach m,$(host-cshlib),$($(m:.so=-objs))))
98472 +host-cxxshobjs := $(sort $(foreach m,$(host-cxxshlib),$($(m:.so=-objs))))
98473
98474 # output directory for programs/.o files
98475 # hostprogs-y := tools/build may have been specified. Retrieve directory
98476 @@ -82,7 +88,9 @@ host-cobjs := $(addprefix $(obj)/,$(host-cobjs))
98477 host-cxxmulti := $(addprefix $(obj)/,$(host-cxxmulti))
98478 host-cxxobjs := $(addprefix $(obj)/,$(host-cxxobjs))
98479 host-cshlib := $(addprefix $(obj)/,$(host-cshlib))
98480 +host-cxxshlib := $(addprefix $(obj)/,$(host-cxxshlib))
98481 host-cshobjs := $(addprefix $(obj)/,$(host-cshobjs))
98482 +host-cxxshobjs := $(addprefix $(obj)/,$(host-cxxshobjs))
98483 host-objdirs := $(addprefix $(obj)/,$(host-objdirs))
98484
98485 obj-dirs += $(host-objdirs)
98486 @@ -156,6 +164,13 @@ quiet_cmd_host-cshobjs = HOSTCC -fPIC $@
98487 $(host-cshobjs): $(obj)/%.o: $(src)/%.c FORCE
98488 $(call if_changed_dep,host-cshobjs)
98489
98490 +# Compile .c file, create position independent .o file
98491 +# host-cxxshobjs -> .o
98492 +quiet_cmd_host-cxxshobjs = HOSTCXX -fPIC $@
98493 + cmd_host-cxxshobjs = $(HOSTCXX) $(hostcxx_flags) -fPIC -c -o $@ $<
98494 +$(host-cxxshobjs): $(obj)/%.o: $(src)/%.c FORCE
98495 + $(call if_changed_dep,host-cxxshobjs)
98496 +
98497 # Link a shared library, based on position independent .o files
98498 # *.o -> .so shared library (host-cshlib)
98499 quiet_cmd_host-cshlib = HOSTLLD -shared $@
98500 @@ -165,6 +180,15 @@ quiet_cmd_host-cshlib = HOSTLLD -shared $@
98501 $(host-cshlib): $(obj)/%: $(host-cshobjs) FORCE
98502 $(call if_changed,host-cshlib)
98503
98504 +# Link a shared library, based on position independent .o files
98505 +# *.o -> .so shared library (host-cxxshlib)
98506 +quiet_cmd_host-cxxshlib = HOSTLLD -shared $@
98507 + cmd_host-cxxshlib = $(HOSTCXX) $(HOSTLDFLAGS) -shared -o $@ \
98508 + $(addprefix $(obj)/,$($(@F:.so=-objs))) \
98509 + $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F))
98510 +$(host-cxxshlib): $(obj)/%: $(host-cxxshobjs) FORCE
98511 + $(call if_changed,host-cxxshlib)
98512 +
98513 targets += $(host-csingle) $(host-cmulti) $(host-cobjs)\
98514 - $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs)
98515 + $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs) $(host-cxxshlib) $(host-cxxshobjs)
98516
98517 diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
98518 index 078fe1d..fbdb363 100644
98519 --- a/scripts/basic/fixdep.c
98520 +++ b/scripts/basic/fixdep.c
98521 @@ -161,7 +161,7 @@ static unsigned int strhash(const char *str, unsigned int sz)
98522 /*
98523 * Lookup a value in the configuration string.
98524 */
98525 -static int is_defined_config(const char *name, int len, unsigned int hash)
98526 +static int is_defined_config(const char *name, unsigned int len, unsigned int hash)
98527 {
98528 struct item *aux;
98529
98530 @@ -211,10 +211,10 @@ static void clear_config(void)
98531 /*
98532 * Record the use of a CONFIG_* word.
98533 */
98534 -static void use_config(const char *m, int slen)
98535 +static void use_config(const char *m, unsigned int slen)
98536 {
98537 unsigned int hash = strhash(m, slen);
98538 - int c, i;
98539 + unsigned int c, i;
98540
98541 if (is_defined_config(m, slen, hash))
98542 return;
98543 @@ -235,9 +235,9 @@ static void use_config(const char *m, int slen)
98544
98545 static void parse_config_file(const char *map, size_t len)
98546 {
98547 - const int *end = (const int *) (map + len);
98548 + const unsigned int *end = (const unsigned int *) (map + len);
98549 /* start at +1, so that p can never be < map */
98550 - const int *m = (const int *) map + 1;
98551 + const unsigned int *m = (const unsigned int *) map + 1;
98552 const char *p, *q;
98553
98554 for (; m < end; m++) {
98555 @@ -435,7 +435,7 @@ static void print_deps(void)
98556 static void traps(void)
98557 {
98558 static char test[] __attribute__((aligned(sizeof(int)))) = "CONF";
98559 - int *p = (int *)test;
98560 + unsigned int *p = (unsigned int *)test;
98561
98562 if (*p != INT_CONF) {
98563 fprintf(stderr, "fixdep: sizeof(int) != 4 or wrong endianness? %#x\n",
98564 diff --git a/scripts/gcc-plugin.sh b/scripts/gcc-plugin.sh
98565 new file mode 100644
98566 index 0000000..5e0222d
98567 --- /dev/null
98568 +++ b/scripts/gcc-plugin.sh
98569 @@ -0,0 +1,17 @@
98570 +#!/bin/bash
98571 +plugincc=`$1 -E -shared - -o /dev/null -I\`$3 -print-file-name=plugin\`/include 2>&1 <<EOF
98572 +#include "gcc-plugin.h"
98573 +#include "tree.h"
98574 +#include "tm.h"
98575 +#include "rtl.h"
98576 +#ifdef ENABLE_BUILD_WITH_CXX
98577 +#warning $2
98578 +#else
98579 +#warning $1
98580 +#endif
98581 +EOF`
98582 +if [ $? -eq 0 ]
98583 +then
98584 + [[ "$plugincc" =~ "$1" ]] && echo "$1"
98585 + [[ "$plugincc" =~ "$2" ]] && echo "$2"
98586 +fi
98587 diff --git a/scripts/headers_install.sh b/scripts/headers_install.sh
98588 index 5de5660..d3deb89 100644
98589 --- a/scripts/headers_install.sh
98590 +++ b/scripts/headers_install.sh
98591 @@ -32,6 +32,7 @@ do
98592 FILE="$(basename "$i")"
98593 sed -r \
98594 -e 's/([ \t(])(__user|__force|__iomem)[ \t]/\1/g' \
98595 + -e 's/__intentional_overflow\([- \t,0-9]*\)//g' \
98596 -e 's/__attribute_const__([ \t]|$)/\1/g' \
98597 -e 's@^#include <linux/compiler.h>@@' \
98598 -e 's/(^|[^a-zA-Z0-9])__packed([^a-zA-Z0-9_]|$)/\1__attribute__((packed))\2/g' \
98599 diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
98600 index 32b10f5..64eeb30 100644
98601 --- a/scripts/link-vmlinux.sh
98602 +++ b/scripts/link-vmlinux.sh
98603 @@ -82,7 +82,9 @@ kallsyms()
98604 kallsymopt="${kallsymopt} --all-symbols"
98605 fi
98606
98607 - kallsymopt="${kallsymopt} --page-offset=$CONFIG_PAGE_OFFSET"
98608 + if [ -z "${CONFIG_X86_32}" ] || [ -z "${CONFIG_PAX_KERNEXEC}" ]; then
98609 + kallsymopt="${kallsymopt} --page-offset=$CONFIG_PAGE_OFFSET"
98610 + fi
98611
98612 local aflags="${KBUILD_AFLAGS} ${KBUILD_AFLAGS_KERNEL} \
98613 ${NOSTDINC_FLAGS} ${LINUXINCLUDE} ${KBUILD_CPPFLAGS}"
98614 @@ -160,7 +162,7 @@ else
98615 fi;
98616
98617 # final build of init/
98618 -${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init
98619 +${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init GCC_PLUGINS_CFLAGS="${GCC_PLUGINS_CFLAGS}" GCC_PLUGINS_AFLAGS="${GCC_PLUGINS_AFLAGS}"
98620
98621 kallsymso=""
98622 kallsyms_vmlinux=""
98623 diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
98624 index 2370863..212fbca 100644
98625 --- a/scripts/mod/file2alias.c
98626 +++ b/scripts/mod/file2alias.c
98627 @@ -142,7 +142,7 @@ static void device_id_check(const char *modname, const char *device_id,
98628 unsigned long size, unsigned long id_size,
98629 void *symval)
98630 {
98631 - int i;
98632 + unsigned int i;
98633
98634 if (size % id_size || size < id_size) {
98635 fatal("%s: sizeof(struct %s_device_id)=%lu is not a modulo "
98636 @@ -170,7 +170,7 @@ static void device_id_check(const char *modname, const char *device_id,
98637 /* USB is special because the bcdDevice can be matched against a numeric range */
98638 /* Looks like "usb:vNpNdNdcNdscNdpNicNiscNipNinN" */
98639 static void do_usb_entry(void *symval,
98640 - unsigned int bcdDevice_initial, int bcdDevice_initial_digits,
98641 + unsigned int bcdDevice_initial, unsigned int bcdDevice_initial_digits,
98642 unsigned char range_lo, unsigned char range_hi,
98643 unsigned char max, struct module *mod)
98644 {
98645 @@ -280,7 +280,7 @@ static void do_usb_entry_multi(void *symval, struct module *mod)
98646 {
98647 unsigned int devlo, devhi;
98648 unsigned char chi, clo, max;
98649 - int ndigits;
98650 + unsigned int ndigits;
98651
98652 DEF_FIELD(symval, usb_device_id, match_flags);
98653 DEF_FIELD(symval, usb_device_id, idVendor);
98654 @@ -533,7 +533,7 @@ static void do_pnp_device_entry(void *symval, unsigned long size,
98655 for (i = 0; i < count; i++) {
98656 DEF_FIELD_ADDR(symval + i*id_size, pnp_device_id, id);
98657 char acpi_id[sizeof(*id)];
98658 - int j;
98659 + unsigned int j;
98660
98661 buf_printf(&mod->dev_table_buf,
98662 "MODULE_ALIAS(\"pnp:d%s*\");\n", *id);
98663 @@ -562,7 +562,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
98664
98665 for (j = 0; j < PNP_MAX_DEVICES; j++) {
98666 const char *id = (char *)(*devs)[j].id;
98667 - int i2, j2;
98668 + unsigned int i2, j2;
98669 int dup = 0;
98670
98671 if (!id[0])
98672 @@ -588,7 +588,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
98673 /* add an individual alias for every device entry */
98674 if (!dup) {
98675 char acpi_id[PNP_ID_LEN];
98676 - int k;
98677 + unsigned int k;
98678
98679 buf_printf(&mod->dev_table_buf,
98680 "MODULE_ALIAS(\"pnp:d%s*\");\n", id);
98681 @@ -940,7 +940,7 @@ static void dmi_ascii_filter(char *d, const char *s)
98682 static int do_dmi_entry(const char *filename, void *symval,
98683 char *alias)
98684 {
98685 - int i, j;
98686 + unsigned int i, j;
98687 DEF_FIELD_ADDR(symval, dmi_system_id, matches);
98688 sprintf(alias, "dmi*");
98689
98690 diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
98691 index 8247979..815ec76 100644
98692 --- a/scripts/mod/modpost.c
98693 +++ b/scripts/mod/modpost.c
98694 @@ -931,6 +931,7 @@ enum mismatch {
98695 ANY_INIT_TO_ANY_EXIT,
98696 ANY_EXIT_TO_ANY_INIT,
98697 EXPORT_TO_INIT_EXIT,
98698 + DATA_TO_TEXT
98699 };
98700
98701 struct sectioncheck {
98702 @@ -1017,6 +1018,12 @@ const struct sectioncheck sectioncheck[] = {
98703 .tosec = { INIT_SECTIONS, EXIT_SECTIONS, NULL },
98704 .mismatch = EXPORT_TO_INIT_EXIT,
98705 .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
98706 +},
98707 +/* Do not reference code from writable data */
98708 +{
98709 + .fromsec = { DATA_SECTIONS, NULL },
98710 + .tosec = { TEXT_SECTIONS, NULL },
98711 + .mismatch = DATA_TO_TEXT
98712 }
98713 };
98714
98715 @@ -1137,10 +1144,10 @@ static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf64_Sword addr,
98716 continue;
98717 if (ELF_ST_TYPE(sym->st_info) == STT_SECTION)
98718 continue;
98719 - if (sym->st_value == addr)
98720 - return sym;
98721 /* Find a symbol nearby - addr are maybe negative */
98722 d = sym->st_value - addr;
98723 + if (d == 0)
98724 + return sym;
98725 if (d < 0)
98726 d = addr - sym->st_value;
98727 if (d < distance) {
98728 @@ -1418,6 +1425,14 @@ static void report_sec_mismatch(const char *modname,
98729 tosym, prl_to, prl_to, tosym);
98730 free(prl_to);
98731 break;
98732 + case DATA_TO_TEXT:
98733 +#if 0
98734 + fprintf(stderr,
98735 + "The %s %s:%s references\n"
98736 + "the %s %s:%s%s\n",
98737 + from, fromsec, fromsym, to, tosec, tosym, to_p);
98738 +#endif
98739 + break;
98740 }
98741 fprintf(stderr, "\n");
98742 }
98743 @@ -1652,7 +1667,7 @@ static void section_rel(const char *modname, struct elf_info *elf,
98744 static void check_sec_ref(struct module *mod, const char *modname,
98745 struct elf_info *elf)
98746 {
98747 - int i;
98748 + unsigned int i;
98749 Elf_Shdr *sechdrs = elf->sechdrs;
98750
98751 /* Walk through all sections */
98752 @@ -1771,7 +1786,7 @@ void __attribute__((format(printf, 2, 3))) buf_printf(struct buffer *buf,
98753 va_end(ap);
98754 }
98755
98756 -void buf_write(struct buffer *buf, const char *s, int len)
98757 +void buf_write(struct buffer *buf, const char *s, unsigned int len)
98758 {
98759 if (buf->size - buf->pos < len) {
98760 buf->size += len + SZ;
98761 @@ -1990,7 +2005,7 @@ static void write_if_changed(struct buffer *b, const char *fname)
98762 if (fstat(fileno(file), &st) < 0)
98763 goto close_write;
98764
98765 - if (st.st_size != b->pos)
98766 + if (st.st_size != (off_t)b->pos)
98767 goto close_write;
98768
98769 tmp = NOFAIL(malloc(b->pos));
98770 diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h
98771 index 51207e4..f7d603d 100644
98772 --- a/scripts/mod/modpost.h
98773 +++ b/scripts/mod/modpost.h
98774 @@ -92,15 +92,15 @@ void *do_nofail(void *ptr, const char *expr);
98775
98776 struct buffer {
98777 char *p;
98778 - int pos;
98779 - int size;
98780 + unsigned int pos;
98781 + unsigned int size;
98782 };
98783
98784 void __attribute__((format(printf, 2, 3)))
98785 buf_printf(struct buffer *buf, const char *fmt, ...);
98786
98787 void
98788 -buf_write(struct buffer *buf, const char *s, int len);
98789 +buf_write(struct buffer *buf, const char *s, unsigned int len);
98790
98791 struct module {
98792 struct module *next;
98793 diff --git a/scripts/mod/sumversion.c b/scripts/mod/sumversion.c
98794 index 9dfcd6d..099068e 100644
98795 --- a/scripts/mod/sumversion.c
98796 +++ b/scripts/mod/sumversion.c
98797 @@ -470,7 +470,7 @@ static void write_version(const char *filename, const char *sum,
98798 goto out;
98799 }
98800
98801 - if (write(fd, sum, strlen(sum)+1) != strlen(sum)+1) {
98802 + if (write(fd, sum, strlen(sum)+1) != (ssize_t)strlen(sum)+1) {
98803 warn("writing sum in %s failed: %s\n",
98804 filename, strerror(errno));
98805 goto out;
98806 diff --git a/scripts/module-common.lds b/scripts/module-common.lds
98807 index 0865b3e..7235dd4 100644
98808 --- a/scripts/module-common.lds
98809 +++ b/scripts/module-common.lds
98810 @@ -6,6 +6,10 @@
98811 SECTIONS {
98812 /DISCARD/ : { *(.discard) }
98813
98814 + .rodata : {
98815 + *(.rodata) *(.rodata.*)
98816 + *(.data..read_only)
98817 + }
98818 __ksymtab : { *(SORT(___ksymtab+*)) }
98819 __ksymtab_gpl : { *(SORT(___ksymtab_gpl+*)) }
98820 __ksymtab_unused : { *(SORT(___ksymtab_unused+*)) }
98821 diff --git a/scripts/package/builddeb b/scripts/package/builddeb
98822 index 90e521f..e9eaf8f 100644
98823 --- a/scripts/package/builddeb
98824 +++ b/scripts/package/builddeb
98825 @@ -281,6 +281,7 @@ fi
98826 (cd $srctree; find . -name Makefile\* -o -name Kconfig\* -o -name \*.pl > "$objtree/debian/hdrsrcfiles")
98827 (cd $srctree; find arch/$SRCARCH/include include scripts -type f >> "$objtree/debian/hdrsrcfiles")
98828 (cd $objtree; find arch/$SRCARCH/include Module.symvers include scripts -type f >> "$objtree/debian/hdrobjfiles")
98829 +(cd $objtree; find tools/gcc -name \*.so >> "$objtree/debian/hdrobjfiles")
98830 destdir=$kernel_headers_dir/usr/src/linux-headers-$version
98831 mkdir -p "$destdir"
98832 (cd $srctree; tar -c -f - -T "$objtree/debian/hdrsrcfiles") | (cd $destdir; tar -xf -)
98833 diff --git a/scripts/pnmtologo.c b/scripts/pnmtologo.c
98834 index 68bb4ef..2f419e1 100644
98835 --- a/scripts/pnmtologo.c
98836 +++ b/scripts/pnmtologo.c
98837 @@ -244,14 +244,14 @@ static void write_header(void)
98838 fprintf(out, " * Linux logo %s\n", logoname);
98839 fputs(" */\n\n", out);
98840 fputs("#include <linux/linux_logo.h>\n\n", out);
98841 - fprintf(out, "static unsigned char %s_data[] __initdata = {\n",
98842 + fprintf(out, "static unsigned char %s_data[] = {\n",
98843 logoname);
98844 }
98845
98846 static void write_footer(void)
98847 {
98848 fputs("\n};\n\n", out);
98849 - fprintf(out, "const struct linux_logo %s __initconst = {\n", logoname);
98850 + fprintf(out, "const struct linux_logo %s = {\n", logoname);
98851 fprintf(out, "\t.type\t\t= %s,\n", logo_types[logo_type]);
98852 fprintf(out, "\t.width\t\t= %d,\n", logo_width);
98853 fprintf(out, "\t.height\t\t= %d,\n", logo_height);
98854 @@ -381,7 +381,7 @@ static void write_logo_clut224(void)
98855 fputs("\n};\n\n", out);
98856
98857 /* write logo clut */
98858 - fprintf(out, "static unsigned char %s_clut[] __initdata = {\n",
98859 + fprintf(out, "static unsigned char %s_clut[] = {\n",
98860 logoname);
98861 write_hex_cnt = 0;
98862 for (i = 0; i < logo_clutsize; i++) {
98863 diff --git a/scripts/sortextable.h b/scripts/sortextable.h
98864 index f5eb43d..1814de8 100644
98865 --- a/scripts/sortextable.h
98866 +++ b/scripts/sortextable.h
98867 @@ -106,9 +106,9 @@ do_func(Elf_Ehdr *ehdr, char const *const fname, table_sort_t custom_sort)
98868 const char *secstrtab;
98869 const char *strtab;
98870 char *extab_image;
98871 - int extab_index = 0;
98872 - int i;
98873 - int idx;
98874 + unsigned int extab_index = 0;
98875 + unsigned int i;
98876 + unsigned int idx;
98877
98878 shdr = (Elf_Shdr *)((char *)ehdr + _r(&ehdr->e_shoff));
98879 shstrtab_sec = shdr + r2(&ehdr->e_shstrndx);
98880 diff --git a/security/Kconfig b/security/Kconfig
98881 index e9c6ac7..031a726 100644
98882 --- a/security/Kconfig
98883 +++ b/security/Kconfig
98884 @@ -4,6 +4,960 @@
98885
98886 menu "Security options"
98887
98888 +menu "Grsecurity"
98889 +
98890 + config ARCH_TRACK_EXEC_LIMIT
98891 + bool
98892 +
98893 + config PAX_KERNEXEC_PLUGIN
98894 + bool
98895 +
98896 + config PAX_PER_CPU_PGD
98897 + bool
98898 +
98899 + config TASK_SIZE_MAX_SHIFT
98900 + int
98901 + depends on X86_64
98902 + default 47 if !PAX_PER_CPU_PGD
98903 + default 42 if PAX_PER_CPU_PGD
98904 +
98905 + config PAX_ENABLE_PAE
98906 + bool
98907 + default y if (X86_32 && (MPENTIUM4 || MK8 || MPSC || MCORE2 || MATOM))
98908 +
98909 + config PAX_USERCOPY_SLABS
98910 + bool
98911 +
98912 +config GRKERNSEC
98913 + bool "Grsecurity"
98914 + select CRYPTO
98915 + select CRYPTO_SHA256
98916 + select PROC_FS
98917 + select STOP_MACHINE
98918 + select TTY
98919 + select DEBUG_LIST
98920 + help
98921 + If you say Y here, you will be able to configure many features
98922 + that will enhance the security of your system. It is highly
98923 + recommended that you say Y here and read through the help
98924 + for each option so that you fully understand the features and
98925 + can evaluate their usefulness for your machine.
98926 +
98927 +choice
98928 + prompt "Configuration Method"
98929 + depends on GRKERNSEC
98930 + default GRKERNSEC_CONFIG_CUSTOM
98931 + help
98932 +
98933 +config GRKERNSEC_CONFIG_AUTO
98934 + bool "Automatic"
98935 + help
98936 + If you choose this configuration method, you'll be able to answer a small
98937 + number of simple questions about how you plan to use this kernel.
98938 + The settings of grsecurity and PaX will be automatically configured for
98939 + the highest commonly-used settings within the provided constraints.
98940 +
98941 + If you require additional configuration, custom changes can still be made
98942 + from the "custom configuration" menu.
98943 +
98944 +config GRKERNSEC_CONFIG_CUSTOM
98945 + bool "Custom"
98946 + help
98947 + If you choose this configuration method, you'll be able to configure all
98948 + grsecurity and PaX settings manually. Via this method, no options are
98949 + automatically enabled.
98950 +
98951 +endchoice
98952 +
98953 +choice
98954 + prompt "Usage Type"
98955 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
98956 + default GRKERNSEC_CONFIG_SERVER
98957 + help
98958 +
98959 +config GRKERNSEC_CONFIG_SERVER
98960 + bool "Server"
98961 + help
98962 + Choose this option if you plan to use this kernel on a server.
98963 +
98964 +config GRKERNSEC_CONFIG_DESKTOP
98965 + bool "Desktop"
98966 + help
98967 + Choose this option if you plan to use this kernel on a desktop.
98968 +
98969 +endchoice
98970 +
98971 +choice
98972 + prompt "Virtualization Type"
98973 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO)
98974 + default GRKERNSEC_CONFIG_VIRT_NONE
98975 + help
98976 +
98977 +config GRKERNSEC_CONFIG_VIRT_NONE
98978 + bool "None"
98979 + help
98980 + Choose this option if this kernel will be run on bare metal.
98981 +
98982 +config GRKERNSEC_CONFIG_VIRT_GUEST
98983 + bool "Guest"
98984 + help
98985 + Choose this option if this kernel will be run as a VM guest.
98986 +
98987 +config GRKERNSEC_CONFIG_VIRT_HOST
98988 + bool "Host"
98989 + help
98990 + Choose this option if this kernel will be run as a VM host.
98991 +
98992 +endchoice
98993 +
98994 +choice
98995 + prompt "Virtualization Hardware"
98996 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
98997 + help
98998 +
98999 +config GRKERNSEC_CONFIG_VIRT_EPT
99000 + bool "EPT/RVI Processor Support"
99001 + depends on X86
99002 + help
99003 + Choose this option if your CPU supports the EPT or RVI features of 2nd-gen
99004 + hardware virtualization. This allows for additional kernel hardening protections
99005 + to operate without additional performance impact.
99006 +
99007 + To see if your Intel processor supports EPT, see:
99008 + http://ark.intel.com/Products/VirtualizationTechnology
99009 + (Most Core i3/5/7 support EPT)
99010 +
99011 + To see if your AMD processor supports RVI, see:
99012 + http://support.amd.com/us/kbarticles/Pages/GPU120AMDRVICPUsHyperVWin8.aspx
99013 +
99014 +config GRKERNSEC_CONFIG_VIRT_SOFT
99015 + bool "First-gen/No Hardware Virtualization"
99016 + help
99017 + Choose this option if you use an Atom/Pentium/Core 2 processor that either doesn't
99018 + support hardware virtualization or doesn't support the EPT/RVI extensions.
99019 +
99020 +endchoice
99021 +
99022 +choice
99023 + prompt "Virtualization Software"
99024 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
99025 + help
99026 +
99027 +config GRKERNSEC_CONFIG_VIRT_XEN
99028 + bool "Xen"
99029 + help
99030 + Choose this option if this kernel is running as a Xen guest or host.
99031 +
99032 +config GRKERNSEC_CONFIG_VIRT_VMWARE
99033 + bool "VMWare"
99034 + help
99035 + Choose this option if this kernel is running as a VMWare guest or host.
99036 +
99037 +config GRKERNSEC_CONFIG_VIRT_KVM
99038 + bool "KVM"
99039 + help
99040 + Choose this option if this kernel is running as a KVM guest or host.
99041 +
99042 +config GRKERNSEC_CONFIG_VIRT_VIRTUALBOX
99043 + bool "VirtualBox"
99044 + help
99045 + Choose this option if this kernel is running as a VirtualBox guest or host.
99046 +
99047 +endchoice
99048 +
99049 +choice
99050 + prompt "Required Priorities"
99051 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
99052 + default GRKERNSEC_CONFIG_PRIORITY_PERF
99053 + help
99054 +
99055 +config GRKERNSEC_CONFIG_PRIORITY_PERF
99056 + bool "Performance"
99057 + help
99058 + Choose this option if performance is of highest priority for this deployment
99059 + of grsecurity. Features like UDEREF on a 64bit kernel, kernel stack clearing,
99060 + clearing of structures intended for userland, and freed memory sanitizing will
99061 + be disabled.
99062 +
99063 +config GRKERNSEC_CONFIG_PRIORITY_SECURITY
99064 + bool "Security"
99065 + help
99066 + Choose this option if security is of highest priority for this deployment of
99067 + grsecurity. UDEREF, kernel stack clearing, clearing of structures intended
99068 + for userland, and freed memory sanitizing will be enabled for this kernel.
99069 + In a worst-case scenario, these features can introduce a 20% performance hit
99070 + (UDEREF on x64 contributing half of this hit).
99071 +
99072 +endchoice
99073 +
99074 +menu "Default Special Groups"
99075 +depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
99076 +
99077 +config GRKERNSEC_PROC_GID
99078 + int "GID exempted from /proc restrictions"
99079 + default 1001
99080 + help
99081 + Setting this GID determines which group will be exempted from
99082 + grsecurity's /proc restrictions, allowing users of the specified
99083 + group to view network statistics and the existence of other users'
99084 + processes on the system. This GID may also be chosen at boot time
99085 + via "grsec_proc_gid=" on the kernel commandline.
99086 +
99087 +config GRKERNSEC_TPE_UNTRUSTED_GID
99088 + int "GID for TPE-untrusted users"
99089 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
99090 + default 1005
99091 + help
99092 + Setting this GID determines which group untrusted users should
99093 + be added to. These users will be placed under grsecurity's Trusted Path
99094 + Execution mechanism, preventing them from executing their own binaries.
99095 + The users will only be able to execute binaries in directories owned and
99096 + writable only by the root user. If the sysctl option is enabled, a sysctl
99097 + option with name "tpe_gid" is created.
99098 +
99099 +config GRKERNSEC_TPE_TRUSTED_GID
99100 + int "GID for TPE-trusted users"
99101 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
99102 + default 1005
99103 + help
99104 + Setting this GID determines what group TPE restrictions will be
99105 + *disabled* for. If the sysctl option is enabled, a sysctl option
99106 + with name "tpe_gid" is created.
99107 +
99108 +config GRKERNSEC_SYMLINKOWN_GID
99109 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
99110 + depends on GRKERNSEC_CONFIG_SERVER
99111 + default 1006
99112 + help
99113 + Setting this GID determines what group kernel-enforced
99114 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
99115 + is enabled, a sysctl option with name "symlinkown_gid" is created.
99116 +
99117 +
99118 +endmenu
99119 +
99120 +menu "Customize Configuration"
99121 +depends on GRKERNSEC
99122 +
99123 +menu "PaX"
99124 +
99125 +config PAX
99126 + bool "Enable various PaX features"
99127 + default y if GRKERNSEC_CONFIG_AUTO
99128 + depends on GRKERNSEC && (ALPHA || ARM || AVR32 || IA64 || MIPS || PARISC || PPC || SPARC || X86)
99129 + help
99130 + This allows you to enable various PaX features. PaX adds
99131 + intrusion prevention mechanisms to the kernel that reduce
99132 + the risks posed by exploitable memory corruption bugs.
99133 +
99134 +menu "PaX Control"
99135 + depends on PAX
99136 +
99137 +config PAX_SOFTMODE
99138 + bool 'Support soft mode'
99139 + help
99140 + Enabling this option will allow you to run PaX in soft mode, that
99141 + is, PaX features will not be enforced by default, only on executables
99142 + marked explicitly. You must also enable PT_PAX_FLAGS or XATTR_PAX_FLAGS
99143 + support as they are the only way to mark executables for soft mode use.
99144 +
99145 + Soft mode can be activated by using the "pax_softmode=1" kernel command
99146 + line option on boot. Furthermore you can control various PaX features
99147 + at runtime via the entries in /proc/sys/kernel/pax.
99148 +
99149 +config PAX_EI_PAX
99150 + bool 'Use legacy ELF header marking'
99151 + default y if GRKERNSEC_CONFIG_AUTO
99152 + help
99153 + Enabling this option will allow you to control PaX features on
99154 + a per executable basis via the 'chpax' utility available at
99155 + http://pax.grsecurity.net/. The control flags will be read from
99156 + an otherwise reserved part of the ELF header. This marking has
99157 + numerous drawbacks (no support for soft-mode, toolchain does not
99158 + know about the non-standard use of the ELF header) therefore it
99159 + has been deprecated in favour of PT_PAX_FLAGS and XATTR_PAX_FLAGS
99160 + support.
99161 +
99162 + Note that if you enable PT_PAX_FLAGS or XATTR_PAX_FLAGS marking
99163 + support as well, they will override the legacy EI_PAX marks.
99164 +
99165 + If you enable none of the marking options then all applications
99166 + will run with PaX enabled on them by default.
99167 +
99168 +config PAX_PT_PAX_FLAGS
99169 + bool 'Use ELF program header marking'
99170 + default y if GRKERNSEC_CONFIG_AUTO
99171 + help
99172 + Enabling this option will allow you to control PaX features on
99173 + a per executable basis via the 'paxctl' utility available at
99174 + http://pax.grsecurity.net/. The control flags will be read from
99175 + a PaX specific ELF program header (PT_PAX_FLAGS). This marking
99176 + has the benefits of supporting both soft mode and being fully
99177 + integrated into the toolchain (the binutils patch is available
99178 + from http://pax.grsecurity.net).
99179 +
99180 + Note that if you enable the legacy EI_PAX marking support as well,
99181 + the EI_PAX marks will be overridden by the PT_PAX_FLAGS marks.
99182 +
99183 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
99184 + must make sure that the marks are the same if a binary has both marks.
99185 +
99186 + If you enable none of the marking options then all applications
99187 + will run with PaX enabled on them by default.
99188 +
99189 +config PAX_XATTR_PAX_FLAGS
99190 + bool 'Use filesystem extended attributes marking'
99191 + default y if GRKERNSEC_CONFIG_AUTO
99192 + select CIFS_XATTR if CIFS
99193 + select EXT2_FS_XATTR if EXT2_FS
99194 + select EXT3_FS_XATTR if EXT3_FS
99195 + select EXT4_FS_XATTR if EXT4_FS
99196 + select JFFS2_FS_XATTR if JFFS2_FS
99197 + select REISERFS_FS_XATTR if REISERFS_FS
99198 + select SQUASHFS_XATTR if SQUASHFS
99199 + select TMPFS_XATTR if TMPFS
99200 + select UBIFS_FS_XATTR if UBIFS_FS
99201 + help
99202 + Enabling this option will allow you to control PaX features on
99203 + a per executable basis via the 'setfattr' utility. The control
99204 + flags will be read from the user.pax.flags extended attribute of
99205 + the file. This marking has the benefit of supporting binary-only
99206 + applications that self-check themselves (e.g., skype) and would
99207 + not tolerate chpax/paxctl changes. The main drawback is that
99208 + extended attributes are not supported by some filesystems (e.g.,
99209 + isofs, udf, vfat) so copying files through such filesystems will
99210 + lose the extended attributes and these PaX markings.
99211 +
99212 + Note that if you enable the legacy EI_PAX marking support as well,
99213 + the EI_PAX marks will be overridden by the XATTR_PAX_FLAGS marks.
99214 +
99215 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
99216 + must make sure that the marks are the same if a binary has both marks.
99217 +
99218 + If you enable none of the marking options then all applications
99219 + will run with PaX enabled on them by default.
99220 +
99221 +choice
99222 + prompt 'MAC system integration'
99223 + default PAX_HAVE_ACL_FLAGS
99224 + help
99225 + Mandatory Access Control systems have the option of controlling
99226 + PaX flags on a per executable basis, choose the method supported
99227 + by your particular system.
99228 +
99229 + - "none": if your MAC system does not interact with PaX,
99230 + - "direct": if your MAC system defines pax_set_initial_flags() itself,
99231 + - "hook": if your MAC system uses the pax_set_initial_flags_func callback.
99232 +
99233 + NOTE: this option is for developers/integrators only.
99234 +
99235 + config PAX_NO_ACL_FLAGS
99236 + bool 'none'
99237 +
99238 + config PAX_HAVE_ACL_FLAGS
99239 + bool 'direct'
99240 +
99241 + config PAX_HOOK_ACL_FLAGS
99242 + bool 'hook'
99243 +endchoice
99244 +
99245 +endmenu
99246 +
99247 +menu "Non-executable pages"
99248 + depends on PAX
99249 +
99250 +config PAX_NOEXEC
99251 + bool "Enforce non-executable pages"
99252 + default y if GRKERNSEC_CONFIG_AUTO
99253 + depends on ALPHA || (ARM && (CPU_V6 || CPU_V6K || CPU_V7)) || IA64 || MIPS || PARISC || PPC || S390 || SPARC || X86
99254 + help
99255 + By design some architectures do not allow for protecting memory
99256 + pages against execution or even if they do, Linux does not make
99257 + use of this feature. In practice this means that if a page is
99258 + readable (such as the stack or heap) it is also executable.
99259 +
99260 + There is a well known exploit technique that makes use of this
99261 + fact and a common programming mistake where an attacker can
99262 + introduce code of his choice somewhere in the attacked program's
99263 + memory (typically the stack or the heap) and then execute it.
99264 +
99265 + If the attacked program was running with different (typically
99266 + higher) privileges than that of the attacker, then he can elevate
99267 + his own privilege level (e.g. get a root shell, write to files for
99268 + which he does not have write access to, etc).
99269 +
99270 + Enabling this option will let you choose from various features
99271 + that prevent the injection and execution of 'foreign' code in
99272 + a program.
99273 +
99274 + This will also break programs that rely on the old behaviour and
99275 + expect that dynamically allocated memory via the malloc() family
99276 + of functions is executable (which it is not). Notable examples
99277 + are the XFree86 4.x server, the java runtime and wine.
99278 +
99279 +config PAX_PAGEEXEC
99280 + bool "Paging based non-executable pages"
99281 + default y if GRKERNSEC_CONFIG_AUTO
99282 + 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)
99283 + select ARCH_TRACK_EXEC_LIMIT if X86_32
99284 + help
99285 + This implementation is based on the paging feature of the CPU.
99286 + On i386 without hardware non-executable bit support there is a
99287 + variable but usually low performance impact, however on Intel's
99288 + P4 core based CPUs it is very high so you should not enable this
99289 + for kernels meant to be used on such CPUs.
99290 +
99291 + On alpha, avr32, ia64, parisc, sparc, sparc64, x86_64 and i386
99292 + with hardware non-executable bit support there is no performance
99293 + impact, on ppc the impact is negligible.
99294 +
99295 + Note that several architectures require various emulations due to
99296 + badly designed userland ABIs, this will cause a performance impact
99297 + but will disappear as soon as userland is fixed. For example, ppc
99298 + userland MUST have been built with secure-plt by a recent toolchain.
99299 +
99300 +config PAX_SEGMEXEC
99301 + bool "Segmentation based non-executable pages"
99302 + default y if GRKERNSEC_CONFIG_AUTO
99303 + depends on PAX_NOEXEC && X86_32
99304 + help
99305 + This implementation is based on the segmentation feature of the
99306 + CPU and has a very small performance impact, however applications
99307 + will be limited to a 1.5 GB address space instead of the normal
99308 + 3 GB.
99309 +
99310 +config PAX_EMUTRAMP
99311 + bool "Emulate trampolines" if (PAX_PAGEEXEC || PAX_SEGMEXEC) && (PARISC || X86)
99312 + default y if PARISC
99313 + help
99314 + There are some programs and libraries that for one reason or
99315 + another attempt to execute special small code snippets from
99316 + non-executable memory pages. Most notable examples are the
99317 + signal handler return code generated by the kernel itself and
99318 + the GCC trampolines.
99319 +
99320 + If you enabled CONFIG_PAX_PAGEEXEC or CONFIG_PAX_SEGMEXEC then
99321 + such programs will no longer work under your kernel.
99322 +
99323 + As a remedy you can say Y here and use the 'chpax' or 'paxctl'
99324 + utilities to enable trampoline emulation for the affected programs
99325 + yet still have the protection provided by the non-executable pages.
99326 +
99327 + On parisc you MUST enable this option and EMUSIGRT as well, otherwise
99328 + your system will not even boot.
99329 +
99330 + Alternatively you can say N here and use the 'chpax' or 'paxctl'
99331 + utilities to disable CONFIG_PAX_PAGEEXEC and CONFIG_PAX_SEGMEXEC
99332 + for the affected files.
99333 +
99334 + NOTE: enabling this feature *may* open up a loophole in the
99335 + protection provided by non-executable pages that an attacker
99336 + could abuse. Therefore the best solution is to not have any
99337 + files on your system that would require this option. This can
99338 + be achieved by not using libc5 (which relies on the kernel
99339 + signal handler return code) and not using or rewriting programs
99340 + that make use of the nested function implementation of GCC.
99341 + Skilled users can just fix GCC itself so that it implements
99342 + nested function calls in a way that does not interfere with PaX.
99343 +
99344 +config PAX_EMUSIGRT
99345 + bool "Automatically emulate sigreturn trampolines"
99346 + depends on PAX_EMUTRAMP && PARISC
99347 + default y
99348 + help
99349 + Enabling this option will have the kernel automatically detect
99350 + and emulate signal return trampolines executing on the stack
99351 + that would otherwise lead to task termination.
99352 +
99353 + This solution is intended as a temporary one for users with
99354 + legacy versions of libc (libc5, glibc 2.0, uClibc before 0.9.17,
99355 + Modula-3 runtime, etc) or executables linked to such, basically
99356 + everything that does not specify its own SA_RESTORER function in
99357 + normal executable memory like glibc 2.1+ does.
99358 +
99359 + On parisc you MUST enable this option, otherwise your system will
99360 + not even boot.
99361 +
99362 + NOTE: this feature cannot be disabled on a per executable basis
99363 + and since it *does* open up a loophole in the protection provided
99364 + by non-executable pages, the best solution is to not have any
99365 + files on your system that would require this option.
99366 +
99367 +config PAX_MPROTECT
99368 + bool "Restrict mprotect()"
99369 + default y if GRKERNSEC_CONFIG_AUTO
99370 + depends on (PAX_PAGEEXEC || PAX_SEGMEXEC)
99371 + help
99372 + Enabling this option will prevent programs from
99373 + - changing the executable status of memory pages that were
99374 + not originally created as executable,
99375 + - making read-only executable pages writable again,
99376 + - creating executable pages from anonymous memory,
99377 + - making read-only-after-relocations (RELRO) data pages writable again.
99378 +
99379 + You should say Y here to complete the protection provided by
99380 + the enforcement of non-executable pages.
99381 +
99382 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
99383 + this feature on a per file basis.
99384 +
99385 +config PAX_MPROTECT_COMPAT
99386 + bool "Use legacy/compat protection demoting (read help)"
99387 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
99388 + depends on PAX_MPROTECT
99389 + help
99390 + The current implementation of PAX_MPROTECT denies RWX allocations/mprotects
99391 + by sending the proper error code to the application. For some broken
99392 + userland, this can cause problems with Python or other applications. The
99393 + current implementation however allows for applications like clamav to
99394 + detect if JIT compilation/execution is allowed and to fall back gracefully
99395 + to an interpreter-based mode if it does not. While we encourage everyone
99396 + to use the current implementation as-is and push upstream to fix broken
99397 + userland (note that the RWX logging option can assist with this), in some
99398 + environments this may not be possible. Having to disable MPROTECT
99399 + completely on certain binaries reduces the security benefit of PaX,
99400 + so this option is provided for those environments to revert to the old
99401 + behavior.
99402 +
99403 +config PAX_ELFRELOCS
99404 + bool "Allow ELF text relocations (read help)"
99405 + depends on PAX_MPROTECT
99406 + default n
99407 + help
99408 + Non-executable pages and mprotect() restrictions are effective
99409 + in preventing the introduction of new executable code into an
99410 + attacked task's address space. There remain only two venues
99411 + for this kind of attack: if the attacker can execute already
99412 + existing code in the attacked task then he can either have it
99413 + create and mmap() a file containing his code or have it mmap()
99414 + an already existing ELF library that does not have position
99415 + independent code in it and use mprotect() on it to make it
99416 + writable and copy his code there. While protecting against
99417 + the former approach is beyond PaX, the latter can be prevented
99418 + by having only PIC ELF libraries on one's system (which do not
99419 + need to relocate their code). If you are sure this is your case,
99420 + as is the case with all modern Linux distributions, then leave
99421 + this option disabled. You should say 'n' here.
99422 +
99423 +config PAX_ETEXECRELOCS
99424 + bool "Allow ELF ET_EXEC text relocations"
99425 + depends on PAX_MPROTECT && (ALPHA || IA64 || PARISC)
99426 + select PAX_ELFRELOCS
99427 + default y
99428 + help
99429 + On some architectures there are incorrectly created applications
99430 + that require text relocations and would not work without enabling
99431 + this option. If you are an alpha, ia64 or parisc user, you should
99432 + enable this option and disable it once you have made sure that
99433 + none of your applications need it.
99434 +
99435 +config PAX_EMUPLT
99436 + bool "Automatically emulate ELF PLT"
99437 + depends on PAX_MPROTECT && (ALPHA || PARISC || SPARC)
99438 + default y
99439 + help
99440 + Enabling this option will have the kernel automatically detect
99441 + and emulate the Procedure Linkage Table entries in ELF files.
99442 + On some architectures such entries are in writable memory, and
99443 + become non-executable leading to task termination. Therefore
99444 + it is mandatory that you enable this option on alpha, parisc,
99445 + sparc and sparc64, otherwise your system would not even boot.
99446 +
99447 + NOTE: this feature *does* open up a loophole in the protection
99448 + provided by the non-executable pages, therefore the proper
99449 + solution is to modify the toolchain to produce a PLT that does
99450 + not need to be writable.
99451 +
99452 +config PAX_DLRESOLVE
99453 + bool 'Emulate old glibc resolver stub'
99454 + depends on PAX_EMUPLT && SPARC
99455 + default n
99456 + help
99457 + This option is needed if userland has an old glibc (before 2.4)
99458 + that puts a 'save' instruction into the runtime generated resolver
99459 + stub that needs special emulation.
99460 +
99461 +config PAX_KERNEXEC
99462 + bool "Enforce non-executable kernel pages"
99463 + 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))
99464 + depends on (X86 || (ARM && (CPU_V6 || CPU_V6K || CPU_V7) && !(ARM_LPAE && MODULES))) && !XEN
99465 + select PAX_PER_CPU_PGD if X86_64 || (X86_32 && X86_PAE)
99466 + select PAX_KERNEXEC_PLUGIN if X86_64
99467 + help
99468 + This is the kernel land equivalent of PAGEEXEC and MPROTECT,
99469 + that is, enabling this option will make it harder to inject
99470 + and execute 'foreign' code in kernel memory itself.
99471 +
99472 +choice
99473 + prompt "Return Address Instrumentation Method"
99474 + default PAX_KERNEXEC_PLUGIN_METHOD_BTS
99475 + depends on PAX_KERNEXEC_PLUGIN
99476 + help
99477 + Select the method used to instrument function pointer dereferences.
99478 + Note that binary modules cannot be instrumented by this approach.
99479 +
99480 + Note that the implementation requires a gcc with plugin support,
99481 + i.e., gcc 4.5 or newer. You may need to install the supporting
99482 + headers explicitly in addition to the normal gcc package.
99483 +
99484 + config PAX_KERNEXEC_PLUGIN_METHOD_BTS
99485 + bool "bts"
99486 + help
99487 + This method is compatible with binary only modules but has
99488 + a higher runtime overhead.
99489 +
99490 + config PAX_KERNEXEC_PLUGIN_METHOD_OR
99491 + bool "or"
99492 + depends on !PARAVIRT
99493 + help
99494 + This method is incompatible with binary only modules but has
99495 + a lower runtime overhead.
99496 +endchoice
99497 +
99498 +config PAX_KERNEXEC_PLUGIN_METHOD
99499 + string
99500 + default "bts" if PAX_KERNEXEC_PLUGIN_METHOD_BTS
99501 + default "or" if PAX_KERNEXEC_PLUGIN_METHOD_OR
99502 + default ""
99503 +
99504 +config PAX_KERNEXEC_MODULE_TEXT
99505 + int "Minimum amount of memory reserved for module code"
99506 + default "4" if (!GRKERNSEC_CONFIG_AUTO || GRKERNSEC_CONFIG_SERVER)
99507 + default "12" if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
99508 + depends on PAX_KERNEXEC && X86_32
99509 + help
99510 + Due to implementation details the kernel must reserve a fixed
99511 + amount of memory for runtime allocated code (such as modules)
99512 + at compile time that cannot be changed at runtime. Here you
99513 + can specify the minimum amount in MB that will be reserved.
99514 + Due to the same implementation details this size will always
99515 + be rounded up to the next 2/4 MB boundary (depends on PAE) so
99516 + the actually available memory for runtime allocated code will
99517 + usually be more than this minimum.
99518 +
99519 + The default 4 MB should be enough for most users but if you have
99520 + an excessive number of modules (e.g., most distribution configs
99521 + compile many drivers as modules) or use huge modules such as
99522 + nvidia's kernel driver, you will need to adjust this amount.
99523 + A good rule of thumb is to look at your currently loaded kernel
99524 + modules and add up their sizes.
99525 +
99526 +endmenu
99527 +
99528 +menu "Address Space Layout Randomization"
99529 + depends on PAX
99530 +
99531 +config PAX_ASLR
99532 + bool "Address Space Layout Randomization"
99533 + default y if GRKERNSEC_CONFIG_AUTO
99534 + help
99535 + Many if not most exploit techniques rely on the knowledge of
99536 + certain addresses in the attacked program. The following options
99537 + will allow the kernel to apply a certain amount of randomization
99538 + to specific parts of the program thereby forcing an attacker to
99539 + guess them in most cases. Any failed guess will most likely crash
99540 + the attacked program which allows the kernel to detect such attempts
99541 + and react on them. PaX itself provides no reaction mechanisms,
99542 + instead it is strongly encouraged that you make use of Nergal's
99543 + segvguard (ftp://ftp.pl.openwall.com/misc/segvguard/) or grsecurity's
99544 + (http://www.grsecurity.net/) built-in crash detection features or
99545 + develop one yourself.
99546 +
99547 + By saying Y here you can choose to randomize the following areas:
99548 + - top of the task's kernel stack
99549 + - top of the task's userland stack
99550 + - base address for mmap() requests that do not specify one
99551 + (this includes all libraries)
99552 + - base address of the main executable
99553 +
99554 + It is strongly recommended to say Y here as address space layout
99555 + randomization has negligible impact on performance yet it provides
99556 + a very effective protection.
99557 +
99558 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
99559 + this feature on a per file basis.
99560 +
99561 +config PAX_RANDKSTACK
99562 + bool "Randomize kernel stack base"
99563 + default y if GRKERNSEC_CONFIG_AUTO && !(GRKERNSEC_CONFIG_VIRT_HOST && GRKERNSEC_CONFIG_VIRT_VIRTUALBOX)
99564 + depends on X86_TSC && X86
99565 + help
99566 + By saying Y here the kernel will randomize every task's kernel
99567 + stack on every system call. This will not only force an attacker
99568 + to guess it but also prevent him from making use of possible
99569 + leaked information about it.
99570 +
99571 + Since the kernel stack is a rather scarce resource, randomization
99572 + may cause unexpected stack overflows, therefore you should very
99573 + carefully test your system. Note that once enabled in the kernel
99574 + configuration, this feature cannot be disabled on a per file basis.
99575 +
99576 +config PAX_RANDUSTACK
99577 + bool "Randomize user stack base"
99578 + default y if GRKERNSEC_CONFIG_AUTO
99579 + depends on PAX_ASLR
99580 + help
99581 + By saying Y here the kernel will randomize every task's userland
99582 + stack. The randomization is done in two steps where the second
99583 + one may apply a big amount of shift to the top of the stack and
99584 + cause problems for programs that want to use lots of memory (more
99585 + than 2.5 GB if SEGMEXEC is not active, or 1.25 GB when it is).
99586 + For this reason the second step can be controlled by 'chpax' or
99587 + 'paxctl' on a per file basis.
99588 +
99589 +config PAX_RANDMMAP
99590 + bool "Randomize mmap() base"
99591 + default y if GRKERNSEC_CONFIG_AUTO
99592 + depends on PAX_ASLR
99593 + help
99594 + By saying Y here the kernel will use a randomized base address for
99595 + mmap() requests that do not specify one themselves. As a result
99596 + all dynamically loaded libraries will appear at random addresses
99597 + and therefore be harder to exploit by a technique where an attacker
99598 + attempts to execute library code for his purposes (e.g. spawn a
99599 + shell from an exploited program that is running at an elevated
99600 + privilege level).
99601 +
99602 + Furthermore, if a program is relinked as a dynamic ELF file, its
99603 + base address will be randomized as well, completing the full
99604 + randomization of the address space layout. Attacking such programs
99605 + becomes a guess game. You can find an example of doing this at
99606 + http://pax.grsecurity.net/et_dyn.tar.gz and practical samples at
99607 + http://www.grsecurity.net/grsec-gcc-specs.tar.gz .
99608 +
99609 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control this
99610 + feature on a per file basis.
99611 +
99612 +endmenu
99613 +
99614 +menu "Miscellaneous hardening features"
99615 +
99616 +config PAX_MEMORY_SANITIZE
99617 + bool "Sanitize all freed memory"
99618 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
99619 + depends on !HIBERNATION
99620 + help
99621 + By saying Y here the kernel will erase memory pages and slab objects
99622 + as soon as they are freed. This in turn reduces the lifetime of data
99623 + stored in them, making it less likely that sensitive information such
99624 + as passwords, cryptographic secrets, etc stay in memory for too long.
99625 +
99626 + This is especially useful for programs whose runtime is short, long
99627 + lived processes and the kernel itself benefit from this as long as
99628 + they ensure timely freeing of memory that may hold sensitive
99629 + information.
99630 +
99631 + A nice side effect of the sanitization of slab objects is the
99632 + reduction of possible info leaks caused by padding bytes within the
99633 + leaky structures. Use-after-free bugs for structures containing
99634 + pointers can also be detected as dereferencing the sanitized pointer
99635 + will generate an access violation.
99636 +
99637 + The tradeoff is performance impact, on a single CPU system kernel
99638 + compilation sees a 3% slowdown, other systems and workloads may vary
99639 + and you are advised to test this feature on your expected workload
99640 + before deploying it.
99641 +
99642 + To reduce the performance penalty by sanitizing pages only, albeit
99643 + limiting the effectiveness of this feature at the same time, slab
99644 + sanitization can be disabled with the kernel commandline parameter
99645 + "pax_sanitize_slab=0".
99646 +
99647 + Note that this feature does not protect data stored in live pages,
99648 + e.g., process memory swapped to disk may stay there for a long time.
99649 +
99650 +config PAX_MEMORY_STACKLEAK
99651 + bool "Sanitize kernel stack"
99652 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
99653 + depends on X86
99654 + help
99655 + By saying Y here the kernel will erase the kernel stack before it
99656 + returns from a system call. This in turn reduces the information
99657 + that a kernel stack leak bug can reveal.
99658 +
99659 + Note that such a bug can still leak information that was put on
99660 + the stack by the current system call (the one eventually triggering
99661 + the bug) but traces of earlier system calls on the kernel stack
99662 + cannot leak anymore.
99663 +
99664 + The tradeoff is performance impact: on a single CPU system kernel
99665 + compilation sees a 1% slowdown, other systems and workloads may vary
99666 + and you are advised to test this feature on your expected workload
99667 + before deploying it.
99668 +
99669 + Note that the full feature requires a gcc with plugin support,
99670 + i.e., gcc 4.5 or newer. You may need to install the supporting
99671 + headers explicitly in addition to the normal gcc package. Using
99672 + older gcc versions means that functions with large enough stack
99673 + frames may leave uninitialized memory behind that may be exposed
99674 + to a later syscall leaking the stack.
99675 +
99676 +config PAX_MEMORY_STRUCTLEAK
99677 + bool "Forcibly initialize local variables copied to userland"
99678 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
99679 + help
99680 + By saying Y here the kernel will zero initialize some local
99681 + variables that are going to be copied to userland. This in
99682 + turn prevents unintended information leakage from the kernel
99683 + stack should later code forget to explicitly set all parts of
99684 + the copied variable.
99685 +
99686 + The tradeoff is less performance impact than PAX_MEMORY_STACKLEAK
99687 + at a much smaller coverage.
99688 +
99689 + Note that the implementation requires a gcc with plugin support,
99690 + i.e., gcc 4.5 or newer. You may need to install the supporting
99691 + headers explicitly in addition to the normal gcc package.
99692 +
99693 +config PAX_MEMORY_UDEREF
99694 + bool "Prevent invalid userland pointer dereference"
99695 + default y if GRKERNSEC_CONFIG_AUTO && !(X86_64 && GRKERNSEC_CONFIG_PRIORITY_PERF) && (GRKERNSEC_CONFIG_VIRT_NONE || GRKERNSEC_CONFIG_VIRT_EPT)
99696 + depends on (X86 || (ARM && (CPU_V6 || CPU_V6K || CPU_V7) && !ARM_LPAE)) && !UML_X86 && !XEN
99697 + select PAX_PER_CPU_PGD if X86_64
99698 + help
99699 + By saying Y here the kernel will be prevented from dereferencing
99700 + userland pointers in contexts where the kernel expects only kernel
99701 + pointers. This is both a useful runtime debugging feature and a
99702 + security measure that prevents exploiting a class of kernel bugs.
99703 +
99704 + The tradeoff is that some virtualization solutions may experience
99705 + a huge slowdown and therefore you should not enable this feature
99706 + for kernels meant to run in such environments. Whether a given VM
99707 + solution is affected or not is best determined by simply trying it
99708 + out, the performance impact will be obvious right on boot as this
99709 + mechanism engages from very early on. A good rule of thumb is that
99710 + VMs running on CPUs without hardware virtualization support (i.e.,
99711 + the majority of IA-32 CPUs) will likely experience the slowdown.
99712 +
99713 + On X86_64 the kernel will make use of PCID support when available
99714 + (Intel's Westmere, Sandy Bridge, etc) for better security (default)
99715 + or performance impact. Pass pax_weakuderef on the kernel command
99716 + line to choose the latter.
99717 +
99718 +config PAX_REFCOUNT
99719 + bool "Prevent various kernel object reference counter overflows"
99720 + default y if GRKERNSEC_CONFIG_AUTO
99721 + depends on GRKERNSEC && ((ARM && (CPU_V6 || CPU_V6K || CPU_V7)) || MIPS || SPARC64 || X86)
99722 + help
99723 + By saying Y here the kernel will detect and prevent overflowing
99724 + various (but not all) kinds of object reference counters. Such
99725 + overflows can normally occur due to bugs only and are often, if
99726 + not always, exploitable.
99727 +
99728 + The tradeoff is that data structures protected by an overflowed
99729 + refcount will never be freed and therefore will leak memory. Note
99730 + that this leak also happens even without this protection but in
99731 + that case the overflow can eventually trigger the freeing of the
99732 + data structure while it is still being used elsewhere, resulting
99733 + in the exploitable situation that this feature prevents.
99734 +
99735 + Since this has a negligible performance impact, you should enable
99736 + this feature.
99737 +
99738 +config PAX_CONSTIFY_PLUGIN
99739 + bool "Automatically constify eligible structures"
99740 + default y
99741 + depends on !UML && PAX_KERNEXEC
99742 + help
99743 + By saying Y here the compiler will automatically constify a class
99744 + of types that contain only function pointers. This reduces the
99745 + kernel's attack surface and also produces a better memory layout.
99746 +
99747 + Note that the implementation requires a gcc with plugin support,
99748 + i.e., gcc 4.5 or newer. You may need to install the supporting
99749 + headers explicitly in addition to the normal gcc package.
99750 +
99751 + Note that if some code really has to modify constified variables
99752 + then the source code will have to be patched to allow it. Examples
99753 + can be found in PaX itself (the no_const attribute) and for some
99754 + out-of-tree modules at http://www.grsecurity.net/~paxguy1/ .
99755 +
99756 +config PAX_USERCOPY
99757 + bool "Harden heap object copies between kernel and userland"
99758 + default y if GRKERNSEC_CONFIG_AUTO
99759 + depends on ARM || IA64 || PPC || SPARC || X86
99760 + depends on GRKERNSEC && (SLAB || SLUB || SLOB)
99761 + select PAX_USERCOPY_SLABS
99762 + help
99763 + By saying Y here the kernel will enforce the size of heap objects
99764 + when they are copied in either direction between the kernel and
99765 + userland, even if only a part of the heap object is copied.
99766 +
99767 + Specifically, this checking prevents information leaking from the
99768 + kernel heap during kernel to userland copies (if the kernel heap
99769 + object is otherwise fully initialized) and prevents kernel heap
99770 + overflows during userland to kernel copies.
99771 +
99772 + Note that the current implementation provides the strictest bounds
99773 + checks for the SLUB allocator.
99774 +
99775 + Enabling this option also enables per-slab cache protection against
99776 + data in a given cache being copied into/out of via userland
99777 + accessors. Though the whitelist of regions will be reduced over
99778 + time, it notably protects important data structures like task structs.
99779 +
99780 + If frame pointers are enabled on x86, this option will also restrict
99781 + copies into and out of the kernel stack to local variables within a
99782 + single frame.
99783 +
99784 + Since this has a negligible performance impact, you should enable
99785 + this feature.
99786 +
99787 +config PAX_USERCOPY_DEBUG
99788 + bool
99789 + depends on X86 && PAX_USERCOPY
99790 + default n
99791 +
99792 +config PAX_SIZE_OVERFLOW
99793 + bool "Prevent various integer overflows in function size parameters"
99794 + default y if GRKERNSEC_CONFIG_AUTO
99795 + depends on X86
99796 + help
99797 + By saying Y here the kernel recomputes expressions of function
99798 + arguments marked by a size_overflow attribute with double integer
99799 + precision (DImode/TImode for 32/64 bit integer types).
99800 +
99801 + The recomputed argument is checked against TYPE_MAX and an event
99802 + is logged on overflow and the triggering process is killed.
99803 +
99804 + Homepage: http://www.grsecurity.net/~ephox/overflow_plugin/
99805 +
99806 + Note that the implementation requires a gcc with plugin support,
99807 + i.e., gcc 4.5 or newer. You may need to install the supporting
99808 + headers explicitly in addition to the normal gcc package.
99809 +
99810 +config PAX_LATENT_ENTROPY
99811 + bool "Generate some entropy during boot and runtime"
99812 + default y if GRKERNSEC_CONFIG_AUTO
99813 + help
99814 + By saying Y here the kernel will instrument some kernel code to
99815 + extract some entropy from both original and artificially created
99816 + program state. This will help especially embedded systems where
99817 + there is little 'natural' source of entropy normally. The cost
99818 + is some slowdown of the boot process and fork and irq processing.
99819 +
99820 + When pax_extra_latent_entropy is passed on the kernel command line,
99821 + entropy will be extracted from up to the first 4GB of RAM while the
99822 + runtime memory allocator is being initialized. This costs even more
99823 + slowdown of the boot process.
99824 +
99825 + Note that the implementation requires a gcc with plugin support,
99826 + i.e., gcc 4.5 or newer. You may need to install the supporting
99827 + headers explicitly in addition to the normal gcc package.
99828 +
99829 + Note that entropy extracted this way is not cryptographically
99830 + secure!
99831 +
99832 +endmenu
99833 +
99834 +endmenu
99835 +
99836 +source grsecurity/Kconfig
99837 +
99838 +endmenu
99839 +
99840 +endmenu
99841 +
99842 source security/keys/Kconfig
99843
99844 config SECURITY_DMESG_RESTRICT
99845 @@ -103,7 +1057,7 @@ config INTEL_TXT
99846 config LSM_MMAP_MIN_ADDR
99847 int "Low address space for LSM to protect from user allocation"
99848 depends on SECURITY && SECURITY_SELINUX
99849 - default 32768 if ARM
99850 + default 32768 if ALPHA || ARM || PARISC || SPARC32
99851 default 65536
99852 help
99853 This is the portion of low virtual memory which should be protected
99854 diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c
99855 index fb99e18..b3e0bbb 100644
99856 --- a/security/apparmor/lsm.c
99857 +++ b/security/apparmor/lsm.c
99858 @@ -615,7 +615,7 @@ static int apparmor_task_setrlimit(struct task_struct *task,
99859 return error;
99860 }
99861
99862 -static struct security_operations apparmor_ops = {
99863 +static struct security_operations apparmor_ops __read_only = {
99864 .name = "apparmor",
99865
99866 .ptrace_access_check = apparmor_ptrace_access_check,
99867 diff --git a/security/commoncap.c b/security/commoncap.c
99868 index b9d613e..f68305c 100644
99869 --- a/security/commoncap.c
99870 +++ b/security/commoncap.c
99871 @@ -424,6 +424,32 @@ int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data
99872 return 0;
99873 }
99874
99875 +/* returns:
99876 + 1 for suid privilege
99877 + 2 for sgid privilege
99878 + 3 for fscap privilege
99879 +*/
99880 +int is_privileged_binary(const struct dentry *dentry)
99881 +{
99882 + struct cpu_vfs_cap_data capdata;
99883 + struct inode *inode = dentry->d_inode;
99884 +
99885 + if (!inode || S_ISDIR(inode->i_mode))
99886 + return 0;
99887 +
99888 + if (inode->i_mode & S_ISUID)
99889 + return 1;
99890 + if ((inode->i_mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))
99891 + return 2;
99892 +
99893 + if (!get_vfs_caps_from_disk(dentry, &capdata)) {
99894 + if (!cap_isclear(capdata.inheritable) || !cap_isclear(capdata.permitted))
99895 + return 3;
99896 + }
99897 +
99898 + return 0;
99899 +}
99900 +
99901 /*
99902 * Attempt to get the on-exec apply capability sets for an executable file from
99903 * its xattrs and, if present, apply them to the proposed credentials being
99904 @@ -592,6 +618,9 @@ int cap_bprm_secureexec(struct linux_binprm *bprm)
99905 const struct cred *cred = current_cred();
99906 kuid_t root_uid = make_kuid(cred->user_ns, 0);
99907
99908 + if (gr_acl_enable_at_secure())
99909 + return 1;
99910 +
99911 if (!uid_eq(cred->uid, root_uid)) {
99912 if (bprm->cap_effective)
99913 return 1;
99914 diff --git a/security/integrity/ima/ima.h b/security/integrity/ima/ima.h
99915 index b3dd616..4bb17f3 100644
99916 --- a/security/integrity/ima/ima.h
99917 +++ b/security/integrity/ima/ima.h
99918 @@ -83,8 +83,8 @@ int ima_init_crypto(void);
99919 extern spinlock_t ima_queue_lock;
99920
99921 struct ima_h_table {
99922 - atomic_long_t len; /* number of stored measurements in the list */
99923 - atomic_long_t violations;
99924 + atomic_long_unchecked_t len; /* number of stored measurements in the list */
99925 + atomic_long_unchecked_t violations;
99926 struct hlist_head queue[IMA_MEASURE_HTABLE_SIZE];
99927 };
99928 extern struct ima_h_table ima_htable;
99929 diff --git a/security/integrity/ima/ima_api.c b/security/integrity/ima/ima_api.c
99930 index 1c03e8f1..398a941 100644
99931 --- a/security/integrity/ima/ima_api.c
99932 +++ b/security/integrity/ima/ima_api.c
99933 @@ -79,7 +79,7 @@ void ima_add_violation(struct inode *inode, const unsigned char *filename,
99934 int result;
99935
99936 /* can overflow, only indicator */
99937 - atomic_long_inc(&ima_htable.violations);
99938 + atomic_long_inc_unchecked(&ima_htable.violations);
99939
99940 entry = kmalloc(sizeof(*entry), GFP_KERNEL);
99941 if (!entry) {
99942 diff --git a/security/integrity/ima/ima_fs.c b/security/integrity/ima/ima_fs.c
99943 index 38477c9..87a60c7 100644
99944 --- a/security/integrity/ima/ima_fs.c
99945 +++ b/security/integrity/ima/ima_fs.c
99946 @@ -28,12 +28,12 @@
99947 static int valid_policy = 1;
99948 #define TMPBUFLEN 12
99949 static ssize_t ima_show_htable_value(char __user *buf, size_t count,
99950 - loff_t *ppos, atomic_long_t *val)
99951 + loff_t *ppos, atomic_long_unchecked_t *val)
99952 {
99953 char tmpbuf[TMPBUFLEN];
99954 ssize_t len;
99955
99956 - len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read(val));
99957 + len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read_unchecked(val));
99958 return simple_read_from_buffer(buf, count, ppos, tmpbuf, len);
99959 }
99960
99961 diff --git a/security/integrity/ima/ima_queue.c b/security/integrity/ima/ima_queue.c
99962 index ff63fe0..809cd96 100644
99963 --- a/security/integrity/ima/ima_queue.c
99964 +++ b/security/integrity/ima/ima_queue.c
99965 @@ -80,7 +80,7 @@ static int ima_add_digest_entry(struct ima_template_entry *entry)
99966 INIT_LIST_HEAD(&qe->later);
99967 list_add_tail_rcu(&qe->later, &ima_measurements);
99968
99969 - atomic_long_inc(&ima_htable.len);
99970 + atomic_long_inc_unchecked(&ima_htable.len);
99971 key = ima_hash_key(entry->digest);
99972 hlist_add_head_rcu(&qe->hnext, &ima_htable.queue[key]);
99973 return 0;
99974 diff --git a/security/keys/compat.c b/security/keys/compat.c
99975 index d65fa7f..cbfe366 100644
99976 --- a/security/keys/compat.c
99977 +++ b/security/keys/compat.c
99978 @@ -44,7 +44,7 @@ static long compat_keyctl_instantiate_key_iov(
99979 if (ret == 0)
99980 goto no_payload_free;
99981
99982 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
99983 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
99984 err:
99985 if (iov != iovstack)
99986 kfree(iov);
99987 diff --git a/security/keys/internal.h b/security/keys/internal.h
99988 index d4f1468..cc52f92 100644
99989 --- a/security/keys/internal.h
99990 +++ b/security/keys/internal.h
99991 @@ -242,7 +242,7 @@ extern long keyctl_instantiate_key_iov(key_serial_t,
99992 extern long keyctl_invalidate_key(key_serial_t);
99993
99994 extern long keyctl_instantiate_key_common(key_serial_t,
99995 - const struct iovec *,
99996 + const struct iovec __user *,
99997 unsigned, size_t, key_serial_t);
99998
99999 /*
100000 diff --git a/security/keys/key.c b/security/keys/key.c
100001 index 8fb7c7b..ba3610d 100644
100002 --- a/security/keys/key.c
100003 +++ b/security/keys/key.c
100004 @@ -284,7 +284,7 @@ struct key *key_alloc(struct key_type *type, const char *desc,
100005
100006 atomic_set(&key->usage, 1);
100007 init_rwsem(&key->sem);
100008 - lockdep_set_class(&key->sem, &type->lock_class);
100009 + lockdep_set_class(&key->sem, (struct lock_class_key *)&type->lock_class);
100010 key->type = type;
100011 key->user = user;
100012 key->quotalen = quotalen;
100013 @@ -1032,7 +1032,9 @@ int register_key_type(struct key_type *ktype)
100014 struct key_type *p;
100015 int ret;
100016
100017 - memset(&ktype->lock_class, 0, sizeof(ktype->lock_class));
100018 + pax_open_kernel();
100019 + memset((void *)&ktype->lock_class, 0, sizeof(ktype->lock_class));
100020 + pax_close_kernel();
100021
100022 ret = -EEXIST;
100023 down_write(&key_types_sem);
100024 @@ -1044,7 +1046,7 @@ int register_key_type(struct key_type *ktype)
100025 }
100026
100027 /* store the type */
100028 - list_add(&ktype->link, &key_types_list);
100029 + pax_list_add((struct list_head *)&ktype->link, &key_types_list);
100030
100031 pr_notice("Key type %s registered\n", ktype->name);
100032 ret = 0;
100033 @@ -1066,7 +1068,7 @@ EXPORT_SYMBOL(register_key_type);
100034 void unregister_key_type(struct key_type *ktype)
100035 {
100036 down_write(&key_types_sem);
100037 - list_del_init(&ktype->link);
100038 + pax_list_del_init((struct list_head *)&ktype->link);
100039 downgrade_write(&key_types_sem);
100040 key_gc_keytype(ktype);
100041 pr_notice("Key type %s unregistered\n", ktype->name);
100042 @@ -1084,10 +1086,10 @@ void __init key_init(void)
100043 0, SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
100044
100045 /* add the special key types */
100046 - list_add_tail(&key_type_keyring.link, &key_types_list);
100047 - list_add_tail(&key_type_dead.link, &key_types_list);
100048 - list_add_tail(&key_type_user.link, &key_types_list);
100049 - list_add_tail(&key_type_logon.link, &key_types_list);
100050 + pax_list_add_tail((struct list_head *)&key_type_keyring.link, &key_types_list);
100051 + pax_list_add_tail((struct list_head *)&key_type_dead.link, &key_types_list);
100052 + pax_list_add_tail((struct list_head *)&key_type_user.link, &key_types_list);
100053 + pax_list_add_tail((struct list_head *)&key_type_logon.link, &key_types_list);
100054
100055 /* record the root user tracking */
100056 rb_link_node(&root_key_user.node,
100057 diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c
100058 index 33cfd27..842fc5a 100644
100059 --- a/security/keys/keyctl.c
100060 +++ b/security/keys/keyctl.c
100061 @@ -987,7 +987,7 @@ static int keyctl_change_reqkey_auth(struct key *key)
100062 /*
100063 * Copy the iovec data from userspace
100064 */
100065 -static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
100066 +static long copy_from_user_iovec(void *buffer, const struct iovec __user *iov,
100067 unsigned ioc)
100068 {
100069 for (; ioc > 0; ioc--) {
100070 @@ -1009,7 +1009,7 @@ static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
100071 * If successful, 0 will be returned.
100072 */
100073 long keyctl_instantiate_key_common(key_serial_t id,
100074 - const struct iovec *payload_iov,
100075 + const struct iovec __user *payload_iov,
100076 unsigned ioc,
100077 size_t plen,
100078 key_serial_t ringid)
100079 @@ -1104,7 +1104,7 @@ long keyctl_instantiate_key(key_serial_t id,
100080 [0].iov_len = plen
100081 };
100082
100083 - return keyctl_instantiate_key_common(id, iov, 1, plen, ringid);
100084 + return keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, 1, plen, ringid);
100085 }
100086
100087 return keyctl_instantiate_key_common(id, NULL, 0, 0, ringid);
100088 @@ -1137,7 +1137,7 @@ long keyctl_instantiate_key_iov(key_serial_t id,
100089 if (ret == 0)
100090 goto no_payload_free;
100091
100092 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
100093 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
100094 err:
100095 if (iov != iovstack)
100096 kfree(iov);
100097 diff --git a/security/keys/keyring.c b/security/keys/keyring.c
100098 index 6ece7f2..ecdb55c 100644
100099 --- a/security/keys/keyring.c
100100 +++ b/security/keys/keyring.c
100101 @@ -227,16 +227,16 @@ static long keyring_read(const struct key *keyring,
100102 ret = -EFAULT;
100103
100104 for (loop = 0; loop < klist->nkeys; loop++) {
100105 + key_serial_t serial;
100106 key = rcu_deref_link_locked(klist, loop,
100107 keyring);
100108 + serial = key->serial;
100109
100110 tmp = sizeof(key_serial_t);
100111 if (tmp > buflen)
100112 tmp = buflen;
100113
100114 - if (copy_to_user(buffer,
100115 - &key->serial,
100116 - tmp) != 0)
100117 + if (copy_to_user(buffer, &serial, tmp))
100118 goto error;
100119
100120 buflen -= tmp;
100121 diff --git a/security/min_addr.c b/security/min_addr.c
100122 index f728728..6457a0c 100644
100123 --- a/security/min_addr.c
100124 +++ b/security/min_addr.c
100125 @@ -14,6 +14,7 @@ unsigned long dac_mmap_min_addr = CONFIG_DEFAULT_MMAP_MIN_ADDR;
100126 */
100127 static void update_mmap_min_addr(void)
100128 {
100129 +#ifndef SPARC
100130 #ifdef CONFIG_LSM_MMAP_MIN_ADDR
100131 if (dac_mmap_min_addr > CONFIG_LSM_MMAP_MIN_ADDR)
100132 mmap_min_addr = dac_mmap_min_addr;
100133 @@ -22,6 +23,7 @@ static void update_mmap_min_addr(void)
100134 #else
100135 mmap_min_addr = dac_mmap_min_addr;
100136 #endif
100137 +#endif
100138 }
100139
100140 /*
100141 diff --git a/security/security.c b/security/security.c
100142 index 4dc31f4..eabcf41 100644
100143 --- a/security/security.c
100144 +++ b/security/security.c
100145 @@ -33,8 +33,8 @@
100146 static __initdata char chosen_lsm[SECURITY_NAME_MAX + 1] =
100147 CONFIG_DEFAULT_SECURITY;
100148
100149 -static struct security_operations *security_ops;
100150 -static struct security_operations default_security_ops = {
100151 +struct security_operations *security_ops __read_only;
100152 +struct security_operations default_security_ops __read_only = {
100153 .name = "default",
100154 };
100155
100156 @@ -73,11 +73,6 @@ int __init security_init(void)
100157 return 0;
100158 }
100159
100160 -void reset_security_ops(void)
100161 -{
100162 - security_ops = &default_security_ops;
100163 -}
100164 -
100165 /* Save user chosen LSM */
100166 static int __init choose_lsm(char *str)
100167 {
100168 diff --git a/security/selinux/avc.c b/security/selinux/avc.c
100169 index fc3e662..7844c60 100644
100170 --- a/security/selinux/avc.c
100171 +++ b/security/selinux/avc.c
100172 @@ -59,7 +59,7 @@ struct avc_node {
100173 struct avc_cache {
100174 struct hlist_head slots[AVC_CACHE_SLOTS]; /* head for avc_node->list */
100175 spinlock_t slots_lock[AVC_CACHE_SLOTS]; /* lock for writes */
100176 - atomic_t lru_hint; /* LRU hint for reclaim scan */
100177 + atomic_unchecked_t lru_hint; /* LRU hint for reclaim scan */
100178 atomic_t active_nodes;
100179 u32 latest_notif; /* latest revocation notification */
100180 };
100181 @@ -167,7 +167,7 @@ void __init avc_init(void)
100182 spin_lock_init(&avc_cache.slots_lock[i]);
100183 }
100184 atomic_set(&avc_cache.active_nodes, 0);
100185 - atomic_set(&avc_cache.lru_hint, 0);
100186 + atomic_set_unchecked(&avc_cache.lru_hint, 0);
100187
100188 avc_node_cachep = kmem_cache_create("avc_node", sizeof(struct avc_node),
100189 0, SLAB_PANIC, NULL);
100190 @@ -242,7 +242,7 @@ static inline int avc_reclaim_node(void)
100191 spinlock_t *lock;
100192
100193 for (try = 0, ecx = 0; try < AVC_CACHE_SLOTS; try++) {
100194 - hvalue = atomic_inc_return(&avc_cache.lru_hint) & (AVC_CACHE_SLOTS - 1);
100195 + hvalue = atomic_inc_return_unchecked(&avc_cache.lru_hint) & (AVC_CACHE_SLOTS - 1);
100196 head = &avc_cache.slots[hvalue];
100197 lock = &avc_cache.slots_lock[hvalue];
100198
100199 diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
100200 index d9a78fd..5038314 100644
100201 --- a/security/selinux/hooks.c
100202 +++ b/security/selinux/hooks.c
100203 @@ -5662,7 +5662,7 @@ static int selinux_key_getsecurity(struct key *key, char **_buffer)
100204
100205 #endif
100206
100207 -static struct security_operations selinux_ops = {
100208 +static struct security_operations selinux_ops __read_only = {
100209 .name = "selinux",
100210
100211 .ptrace_access_check = selinux_ptrace_access_check,
100212 @@ -6014,6 +6014,9 @@ static void selinux_nf_ip_exit(void)
100213 #ifdef CONFIG_SECURITY_SELINUX_DISABLE
100214 static int selinux_disabled;
100215
100216 +extern struct security_operations *security_ops;
100217 +extern struct security_operations default_security_ops;
100218 +
100219 int selinux_disable(void)
100220 {
100221 if (ss_initialized) {
100222 @@ -6031,7 +6034,9 @@ int selinux_disable(void)
100223 selinux_disabled = 1;
100224 selinux_enabled = 0;
100225
100226 - reset_security_ops();
100227 + pax_open_kernel();
100228 + security_ops = &default_security_ops;
100229 + pax_close_kernel();
100230
100231 /* Try to destroy the avc node cache */
100232 avc_disable();
100233 diff --git a/security/selinux/include/xfrm.h b/security/selinux/include/xfrm.h
100234 index 6713f04..c57ecef 100644
100235 --- a/security/selinux/include/xfrm.h
100236 +++ b/security/selinux/include/xfrm.h
100237 @@ -52,7 +52,7 @@ static inline void selinux_xfrm_notify_policyload(void)
100238 {
100239 struct net *net;
100240
100241 - atomic_inc(&flow_cache_genid);
100242 + atomic_inc_unchecked(&flow_cache_genid);
100243 rtnl_lock();
100244 for_each_net(net)
100245 rt_genid_bump_all(net);
100246 diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
100247 index 8825375..97a623b 100644
100248 --- a/security/smack/smack_lsm.c
100249 +++ b/security/smack/smack_lsm.c
100250 @@ -3726,7 +3726,7 @@ static int smack_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen)
100251 return 0;
100252 }
100253
100254 -struct security_operations smack_ops = {
100255 +struct security_operations smack_ops __read_only = {
100256 .name = "smack",
100257
100258 .ptrace_access_check = smack_ptrace_access_check,
100259 diff --git a/security/tomoyo/mount.c b/security/tomoyo/mount.c
100260 index 390c646..f2f8db3 100644
100261 --- a/security/tomoyo/mount.c
100262 +++ b/security/tomoyo/mount.c
100263 @@ -118,6 +118,10 @@ static int tomoyo_mount_acl(struct tomoyo_request_info *r,
100264 type == tomoyo_mounts[TOMOYO_MOUNT_MOVE]) {
100265 need_dev = -1; /* dev_name is a directory */
100266 } else {
100267 + if (!capable(CAP_SYS_ADMIN)) {
100268 + error = -EPERM;
100269 + goto out;
100270 + }
100271 fstype = get_fs_type(type);
100272 if (!fstype) {
100273 error = -ENODEV;
100274 diff --git a/security/tomoyo/tomoyo.c b/security/tomoyo/tomoyo.c
100275 index f0b756e..b129202 100644
100276 --- a/security/tomoyo/tomoyo.c
100277 +++ b/security/tomoyo/tomoyo.c
100278 @@ -503,7 +503,7 @@ static int tomoyo_socket_sendmsg(struct socket *sock, struct msghdr *msg,
100279 * tomoyo_security_ops is a "struct security_operations" which is used for
100280 * registering TOMOYO.
100281 */
100282 -static struct security_operations tomoyo_security_ops = {
100283 +static struct security_operations tomoyo_security_ops __read_only = {
100284 .name = "tomoyo",
100285 .cred_alloc_blank = tomoyo_cred_alloc_blank,
100286 .cred_prepare = tomoyo_cred_prepare,
100287 diff --git a/security/yama/Kconfig b/security/yama/Kconfig
100288 index 20ef514..4182bed 100644
100289 --- a/security/yama/Kconfig
100290 +++ b/security/yama/Kconfig
100291 @@ -1,6 +1,6 @@
100292 config SECURITY_YAMA
100293 bool "Yama support"
100294 - depends on SECURITY
100295 + depends on SECURITY && !GRKERNSEC
100296 select SECURITYFS
100297 select SECURITY_PATH
100298 default n
100299 diff --git a/security/yama/yama_lsm.c b/security/yama/yama_lsm.c
100300 index 13c88fbc..f8c115e 100644
100301 --- a/security/yama/yama_lsm.c
100302 +++ b/security/yama/yama_lsm.c
100303 @@ -365,7 +365,7 @@ int yama_ptrace_traceme(struct task_struct *parent)
100304 }
100305
100306 #ifndef CONFIG_SECURITY_YAMA_STACKED
100307 -static struct security_operations yama_ops = {
100308 +static struct security_operations yama_ops __read_only = {
100309 .name = "yama",
100310
100311 .ptrace_access_check = yama_ptrace_access_check,
100312 @@ -376,28 +376,24 @@ static struct security_operations yama_ops = {
100313 #endif
100314
100315 #ifdef CONFIG_SYSCTL
100316 +static int zero __read_only;
100317 +static int max_scope __read_only = YAMA_SCOPE_NO_ATTACH;
100318 +
100319 static int yama_dointvec_minmax(struct ctl_table *table, int write,
100320 void __user *buffer, size_t *lenp, loff_t *ppos)
100321 {
100322 - int rc;
100323 + ctl_table_no_const yama_table;
100324
100325 if (write && !capable(CAP_SYS_PTRACE))
100326 return -EPERM;
100327
100328 - rc = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
100329 - if (rc)
100330 - return rc;
100331 -
100332 + yama_table = *table;
100333 /* Lock the max value if it ever gets set. */
100334 - if (write && *(int *)table->data == *(int *)table->extra2)
100335 - table->extra1 = table->extra2;
100336 -
100337 - return rc;
100338 + if (ptrace_scope == max_scope)
100339 + yama_table.extra1 = &max_scope;
100340 + return proc_dointvec_minmax(&yama_table, write, buffer, lenp, ppos);
100341 }
100342
100343 -static int zero;
100344 -static int max_scope = YAMA_SCOPE_NO_ATTACH;
100345 -
100346 struct ctl_path yama_sysctl_path[] = {
100347 { .procname = "kernel", },
100348 { .procname = "yama", },
100349 diff --git a/sound/aoa/codecs/onyx.c b/sound/aoa/codecs/onyx.c
100350 index 4cedc69..e59d8a3 100644
100351 --- a/sound/aoa/codecs/onyx.c
100352 +++ b/sound/aoa/codecs/onyx.c
100353 @@ -54,7 +54,7 @@ struct onyx {
100354 spdif_locked:1,
100355 analog_locked:1,
100356 original_mute:2;
100357 - int open_count;
100358 + local_t open_count;
100359 struct codec_info *codec_info;
100360
100361 /* mutex serializes concurrent access to the device
100362 @@ -753,7 +753,7 @@ static int onyx_open(struct codec_info_item *cii,
100363 struct onyx *onyx = cii->codec_data;
100364
100365 mutex_lock(&onyx->mutex);
100366 - onyx->open_count++;
100367 + local_inc(&onyx->open_count);
100368 mutex_unlock(&onyx->mutex);
100369
100370 return 0;
100371 @@ -765,8 +765,7 @@ static int onyx_close(struct codec_info_item *cii,
100372 struct onyx *onyx = cii->codec_data;
100373
100374 mutex_lock(&onyx->mutex);
100375 - onyx->open_count--;
100376 - if (!onyx->open_count)
100377 + if (local_dec_and_test(&onyx->open_count))
100378 onyx->spdif_locked = onyx->analog_locked = 0;
100379 mutex_unlock(&onyx->mutex);
100380
100381 diff --git a/sound/aoa/codecs/onyx.h b/sound/aoa/codecs/onyx.h
100382 index ffd2025..df062c9 100644
100383 --- a/sound/aoa/codecs/onyx.h
100384 +++ b/sound/aoa/codecs/onyx.h
100385 @@ -11,6 +11,7 @@
100386 #include <linux/i2c.h>
100387 #include <asm/pmac_low_i2c.h>
100388 #include <asm/prom.h>
100389 +#include <asm/local.h>
100390
100391 /* PCM3052 register definitions */
100392
100393 diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
100394 index 4c1cc51..16040040 100644
100395 --- a/sound/core/oss/pcm_oss.c
100396 +++ b/sound/core/oss/pcm_oss.c
100397 @@ -1189,10 +1189,10 @@ snd_pcm_sframes_t snd_pcm_oss_write3(struct snd_pcm_substream *substream, const
100398 if (in_kernel) {
100399 mm_segment_t fs;
100400 fs = snd_enter_user();
100401 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
100402 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
100403 snd_leave_user(fs);
100404 } else {
100405 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
100406 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
100407 }
100408 if (ret != -EPIPE && ret != -ESTRPIPE)
100409 break;
100410 @@ -1234,10 +1234,10 @@ snd_pcm_sframes_t snd_pcm_oss_read3(struct snd_pcm_substream *substream, char *p
100411 if (in_kernel) {
100412 mm_segment_t fs;
100413 fs = snd_enter_user();
100414 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
100415 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
100416 snd_leave_user(fs);
100417 } else {
100418 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
100419 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
100420 }
100421 if (ret == -EPIPE) {
100422 if (runtime->status->state == SNDRV_PCM_STATE_DRAINING) {
100423 @@ -1337,7 +1337,7 @@ static ssize_t snd_pcm_oss_write2(struct snd_pcm_substream *substream, const cha
100424 struct snd_pcm_plugin_channel *channels;
100425 size_t oss_frame_bytes = (runtime->oss.plugin_first->src_width * runtime->oss.plugin_first->src_format.channels) / 8;
100426 if (!in_kernel) {
100427 - if (copy_from_user(runtime->oss.buffer, (const char __force __user *)buf, bytes))
100428 + if (copy_from_user(runtime->oss.buffer, (const char __force_user *)buf, bytes))
100429 return -EFAULT;
100430 buf = runtime->oss.buffer;
100431 }
100432 @@ -1407,7 +1407,7 @@ static ssize_t snd_pcm_oss_write1(struct snd_pcm_substream *substream, const cha
100433 }
100434 } else {
100435 tmp = snd_pcm_oss_write2(substream,
100436 - (const char __force *)buf,
100437 + (const char __force_kernel *)buf,
100438 runtime->oss.period_bytes, 0);
100439 if (tmp <= 0)
100440 goto err;
100441 @@ -1433,7 +1433,7 @@ static ssize_t snd_pcm_oss_read2(struct snd_pcm_substream *substream, char *buf,
100442 struct snd_pcm_runtime *runtime = substream->runtime;
100443 snd_pcm_sframes_t frames, frames1;
100444 #ifdef CONFIG_SND_PCM_OSS_PLUGINS
100445 - char __user *final_dst = (char __force __user *)buf;
100446 + char __user *final_dst = (char __force_user *)buf;
100447 if (runtime->oss.plugin_first) {
100448 struct snd_pcm_plugin_channel *channels;
100449 size_t oss_frame_bytes = (runtime->oss.plugin_last->dst_width * runtime->oss.plugin_last->dst_format.channels) / 8;
100450 @@ -1495,7 +1495,7 @@ static ssize_t snd_pcm_oss_read1(struct snd_pcm_substream *substream, char __use
100451 xfer += tmp;
100452 runtime->oss.buffer_used -= tmp;
100453 } else {
100454 - tmp = snd_pcm_oss_read2(substream, (char __force *)buf,
100455 + tmp = snd_pcm_oss_read2(substream, (char __force_kernel *)buf,
100456 runtime->oss.period_bytes, 0);
100457 if (tmp <= 0)
100458 goto err;
100459 @@ -1663,7 +1663,7 @@ static int snd_pcm_oss_sync(struct snd_pcm_oss_file *pcm_oss_file)
100460 size1);
100461 size1 /= runtime->channels; /* frames */
100462 fs = snd_enter_user();
100463 - snd_pcm_lib_write(substream, (void __force __user *)runtime->oss.buffer, size1);
100464 + snd_pcm_lib_write(substream, (void __force_user *)runtime->oss.buffer, size1);
100465 snd_leave_user(fs);
100466 }
100467 } else if (runtime->access == SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) {
100468 diff --git a/sound/core/pcm_compat.c b/sound/core/pcm_compat.c
100469 index af49721..e85058e 100644
100470 --- a/sound/core/pcm_compat.c
100471 +++ b/sound/core/pcm_compat.c
100472 @@ -31,7 +31,7 @@ static int snd_pcm_ioctl_delay_compat(struct snd_pcm_substream *substream,
100473 int err;
100474
100475 fs = snd_enter_user();
100476 - err = snd_pcm_delay(substream, &delay);
100477 + err = snd_pcm_delay(substream, (snd_pcm_sframes_t __force_user *)&delay);
100478 snd_leave_user(fs);
100479 if (err < 0)
100480 return err;
100481 diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
100482 index a68d4c6..72af3cf 100644
100483 --- a/sound/core/pcm_native.c
100484 +++ b/sound/core/pcm_native.c
100485 @@ -2809,11 +2809,11 @@ int snd_pcm_kernel_ioctl(struct snd_pcm_substream *substream,
100486 switch (substream->stream) {
100487 case SNDRV_PCM_STREAM_PLAYBACK:
100488 result = snd_pcm_playback_ioctl1(NULL, substream, cmd,
100489 - (void __user *)arg);
100490 + (void __force_user *)arg);
100491 break;
100492 case SNDRV_PCM_STREAM_CAPTURE:
100493 result = snd_pcm_capture_ioctl1(NULL, substream, cmd,
100494 - (void __user *)arg);
100495 + (void __force_user *)arg);
100496 break;
100497 default:
100498 result = -EINVAL;
100499 diff --git a/sound/core/seq/seq_device.c b/sound/core/seq/seq_device.c
100500 index 040c60e..989a19a 100644
100501 --- a/sound/core/seq/seq_device.c
100502 +++ b/sound/core/seq/seq_device.c
100503 @@ -64,7 +64,7 @@ struct ops_list {
100504 int argsize; /* argument size */
100505
100506 /* operators */
100507 - struct snd_seq_dev_ops ops;
100508 + struct snd_seq_dev_ops *ops;
100509
100510 /* registered devices */
100511 struct list_head dev_list; /* list of devices */
100512 @@ -333,7 +333,7 @@ int snd_seq_device_register_driver(char *id, struct snd_seq_dev_ops *entry,
100513
100514 mutex_lock(&ops->reg_mutex);
100515 /* copy driver operators */
100516 - ops->ops = *entry;
100517 + ops->ops = entry;
100518 ops->driver |= DRIVER_LOADED;
100519 ops->argsize = argsize;
100520
100521 @@ -463,7 +463,7 @@ static int init_device(struct snd_seq_device *dev, struct ops_list *ops)
100522 dev->name, ops->id, ops->argsize, dev->argsize);
100523 return -EINVAL;
100524 }
100525 - if (ops->ops.init_device(dev) >= 0) {
100526 + if (ops->ops->init_device(dev) >= 0) {
100527 dev->status = SNDRV_SEQ_DEVICE_REGISTERED;
100528 ops->num_init_devices++;
100529 } else {
100530 @@ -490,7 +490,7 @@ static int free_device(struct snd_seq_device *dev, struct ops_list *ops)
100531 dev->name, ops->id, ops->argsize, dev->argsize);
100532 return -EINVAL;
100533 }
100534 - if ((result = ops->ops.free_device(dev)) >= 0 || result == -ENXIO) {
100535 + if ((result = ops->ops->free_device(dev)) >= 0 || result == -ENXIO) {
100536 dev->status = SNDRV_SEQ_DEVICE_FREE;
100537 dev->driver_data = NULL;
100538 ops->num_init_devices--;
100539 diff --git a/sound/core/sound.c b/sound/core/sound.c
100540 index f002bd9..c462985 100644
100541 --- a/sound/core/sound.c
100542 +++ b/sound/core/sound.c
100543 @@ -86,7 +86,7 @@ static void snd_request_other(int minor)
100544 case SNDRV_MINOR_TIMER: str = "snd-timer"; break;
100545 default: return;
100546 }
100547 - request_module(str);
100548 + request_module("%s", str);
100549 }
100550
100551 #endif /* modular kernel */
100552 diff --git a/sound/drivers/mts64.c b/sound/drivers/mts64.c
100553 index 4e0dd22..7a1f32c 100644
100554 --- a/sound/drivers/mts64.c
100555 +++ b/sound/drivers/mts64.c
100556 @@ -29,6 +29,7 @@
100557 #include <sound/initval.h>
100558 #include <sound/rawmidi.h>
100559 #include <sound/control.h>
100560 +#include <asm/local.h>
100561
100562 #define CARD_NAME "Miditerminal 4140"
100563 #define DRIVER_NAME "MTS64"
100564 @@ -67,7 +68,7 @@ struct mts64 {
100565 struct pardevice *pardev;
100566 int pardev_claimed;
100567
100568 - int open_count;
100569 + local_t open_count;
100570 int current_midi_output_port;
100571 int current_midi_input_port;
100572 u8 mode[MTS64_NUM_INPUT_PORTS];
100573 @@ -697,7 +698,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
100574 {
100575 struct mts64 *mts = substream->rmidi->private_data;
100576
100577 - if (mts->open_count == 0) {
100578 + if (local_read(&mts->open_count) == 0) {
100579 /* We don't need a spinlock here, because this is just called
100580 if the device has not been opened before.
100581 So there aren't any IRQs from the device */
100582 @@ -705,7 +706,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
100583
100584 msleep(50);
100585 }
100586 - ++(mts->open_count);
100587 + local_inc(&mts->open_count);
100588
100589 return 0;
100590 }
100591 @@ -715,8 +716,7 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
100592 struct mts64 *mts = substream->rmidi->private_data;
100593 unsigned long flags;
100594
100595 - --(mts->open_count);
100596 - if (mts->open_count == 0) {
100597 + if (local_dec_return(&mts->open_count) == 0) {
100598 /* We need the spinlock_irqsave here because we can still
100599 have IRQs at this point */
100600 spin_lock_irqsave(&mts->lock, flags);
100601 @@ -725,8 +725,8 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
100602
100603 msleep(500);
100604
100605 - } else if (mts->open_count < 0)
100606 - mts->open_count = 0;
100607 + } else if (local_read(&mts->open_count) < 0)
100608 + local_set(&mts->open_count, 0);
100609
100610 return 0;
100611 }
100612 diff --git a/sound/drivers/opl4/opl4_lib.c b/sound/drivers/opl4/opl4_lib.c
100613 index b953fb4..1999c01 100644
100614 --- a/sound/drivers/opl4/opl4_lib.c
100615 +++ b/sound/drivers/opl4/opl4_lib.c
100616 @@ -29,7 +29,7 @@ MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>");
100617 MODULE_DESCRIPTION("OPL4 driver");
100618 MODULE_LICENSE("GPL");
100619
100620 -static void inline snd_opl4_wait(struct snd_opl4 *opl4)
100621 +static inline void snd_opl4_wait(struct snd_opl4 *opl4)
100622 {
100623 int timeout = 10;
100624 while ((inb(opl4->fm_port) & OPL4_STATUS_BUSY) && --timeout > 0)
100625 diff --git a/sound/drivers/portman2x4.c b/sound/drivers/portman2x4.c
100626 index 991018d..8984740 100644
100627 --- a/sound/drivers/portman2x4.c
100628 +++ b/sound/drivers/portman2x4.c
100629 @@ -48,6 +48,7 @@
100630 #include <sound/initval.h>
100631 #include <sound/rawmidi.h>
100632 #include <sound/control.h>
100633 +#include <asm/local.h>
100634
100635 #define CARD_NAME "Portman 2x4"
100636 #define DRIVER_NAME "portman"
100637 @@ -85,7 +86,7 @@ struct portman {
100638 struct pardevice *pardev;
100639 int pardev_claimed;
100640
100641 - int open_count;
100642 + local_t open_count;
100643 int mode[PORTMAN_NUM_INPUT_PORTS];
100644 struct snd_rawmidi_substream *midi_input[PORTMAN_NUM_INPUT_PORTS];
100645 };
100646 diff --git a/sound/firewire/amdtp.c b/sound/firewire/amdtp.c
100647 index ea995af..f1bfa37 100644
100648 --- a/sound/firewire/amdtp.c
100649 +++ b/sound/firewire/amdtp.c
100650 @@ -389,7 +389,7 @@ static void queue_out_packet(struct amdtp_out_stream *s, unsigned int cycle)
100651 ptr = s->pcm_buffer_pointer + data_blocks;
100652 if (ptr >= pcm->runtime->buffer_size)
100653 ptr -= pcm->runtime->buffer_size;
100654 - ACCESS_ONCE(s->pcm_buffer_pointer) = ptr;
100655 + ACCESS_ONCE_RW(s->pcm_buffer_pointer) = ptr;
100656
100657 s->pcm_period_pointer += data_blocks;
100658 if (s->pcm_period_pointer >= pcm->runtime->period_size) {
100659 @@ -557,7 +557,7 @@ EXPORT_SYMBOL(amdtp_out_stream_pcm_pointer);
100660 */
100661 void amdtp_out_stream_update(struct amdtp_out_stream *s)
100662 {
100663 - ACCESS_ONCE(s->source_node_id_field) =
100664 + ACCESS_ONCE_RW(s->source_node_id_field) =
100665 (fw_parent_device(s->unit)->card->node_id & 0x3f) << 24;
100666 }
100667 EXPORT_SYMBOL(amdtp_out_stream_update);
100668 diff --git a/sound/firewire/amdtp.h b/sound/firewire/amdtp.h
100669 index f6103d6..4843fbf 100644
100670 --- a/sound/firewire/amdtp.h
100671 +++ b/sound/firewire/amdtp.h
100672 @@ -138,7 +138,7 @@ static inline bool amdtp_out_streaming_error(struct amdtp_out_stream *s)
100673 static inline void amdtp_out_stream_pcm_trigger(struct amdtp_out_stream *s,
100674 struct snd_pcm_substream *pcm)
100675 {
100676 - ACCESS_ONCE(s->pcm) = pcm;
100677 + ACCESS_ONCE_RW(s->pcm) = pcm;
100678 }
100679
100680 static inline bool cip_sfc_is_base_44100(enum cip_sfc sfc)
100681 diff --git a/sound/firewire/isight.c b/sound/firewire/isight.c
100682 index 58a5afe..af5bd64 100644
100683 --- a/sound/firewire/isight.c
100684 +++ b/sound/firewire/isight.c
100685 @@ -96,7 +96,7 @@ static void isight_update_pointers(struct isight *isight, unsigned int count)
100686 ptr += count;
100687 if (ptr >= runtime->buffer_size)
100688 ptr -= runtime->buffer_size;
100689 - ACCESS_ONCE(isight->buffer_pointer) = ptr;
100690 + ACCESS_ONCE_RW(isight->buffer_pointer) = ptr;
100691
100692 isight->period_counter += count;
100693 if (isight->period_counter >= runtime->period_size) {
100694 @@ -307,7 +307,7 @@ static int isight_hw_params(struct snd_pcm_substream *substream,
100695 if (err < 0)
100696 return err;
100697
100698 - ACCESS_ONCE(isight->pcm_active) = true;
100699 + ACCESS_ONCE_RW(isight->pcm_active) = true;
100700
100701 return 0;
100702 }
100703 @@ -340,7 +340,7 @@ static int isight_hw_free(struct snd_pcm_substream *substream)
100704 {
100705 struct isight *isight = substream->private_data;
100706
100707 - ACCESS_ONCE(isight->pcm_active) = false;
100708 + ACCESS_ONCE_RW(isight->pcm_active) = false;
100709
100710 mutex_lock(&isight->mutex);
100711 isight_stop_streaming(isight);
100712 @@ -433,10 +433,10 @@ static int isight_trigger(struct snd_pcm_substream *substream, int cmd)
100713
100714 switch (cmd) {
100715 case SNDRV_PCM_TRIGGER_START:
100716 - ACCESS_ONCE(isight->pcm_running) = true;
100717 + ACCESS_ONCE_RW(isight->pcm_running) = true;
100718 break;
100719 case SNDRV_PCM_TRIGGER_STOP:
100720 - ACCESS_ONCE(isight->pcm_running) = false;
100721 + ACCESS_ONCE_RW(isight->pcm_running) = false;
100722 break;
100723 default:
100724 return -EINVAL;
100725 diff --git a/sound/firewire/scs1x.c b/sound/firewire/scs1x.c
100726 index 505fc81..62e569e 100644
100727 --- a/sound/firewire/scs1x.c
100728 +++ b/sound/firewire/scs1x.c
100729 @@ -74,7 +74,7 @@ static void scs_output_trigger(struct snd_rawmidi_substream *stream, int up)
100730 {
100731 struct scs *scs = stream->rmidi->private_data;
100732
100733 - ACCESS_ONCE(scs->output) = up ? stream : NULL;
100734 + ACCESS_ONCE_RW(scs->output) = up ? stream : NULL;
100735 if (up) {
100736 scs->output_idle = false;
100737 tasklet_schedule(&scs->tasklet);
100738 @@ -257,7 +257,7 @@ static void scs_input_trigger(struct snd_rawmidi_substream *stream, int up)
100739 {
100740 struct scs *scs = stream->rmidi->private_data;
100741
100742 - ACCESS_ONCE(scs->input) = up ? stream : NULL;
100743 + ACCESS_ONCE_RW(scs->input) = up ? stream : NULL;
100744 }
100745
100746 static void scs_input_escaped_byte(struct snd_rawmidi_substream *stream,
100747 @@ -469,8 +469,8 @@ static void scs_remove(struct fw_unit *unit)
100748
100749 snd_card_disconnect(scs->card);
100750
100751 - ACCESS_ONCE(scs->output) = NULL;
100752 - ACCESS_ONCE(scs->input) = NULL;
100753 + ACCESS_ONCE_RW(scs->output) = NULL;
100754 + ACCESS_ONCE_RW(scs->input) = NULL;
100755
100756 wait_event(scs->idle_wait, scs->output_idle);
100757
100758 diff --git a/sound/oss/sb_audio.c b/sound/oss/sb_audio.c
100759 index 048439a..3be9f6f 100644
100760 --- a/sound/oss/sb_audio.c
100761 +++ b/sound/oss/sb_audio.c
100762 @@ -904,7 +904,7 @@ sb16_copy_from_user(int dev,
100763 buf16 = (signed short *)(localbuf + localoffs);
100764 while (c)
100765 {
100766 - locallen = (c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
100767 + locallen = ((unsigned)c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
100768 if (copy_from_user(lbuf8,
100769 userbuf+useroffs + p,
100770 locallen))
100771 diff --git a/sound/oss/swarm_cs4297a.c b/sound/oss/swarm_cs4297a.c
100772 index 7d8803a..559f8d0 100644
100773 --- a/sound/oss/swarm_cs4297a.c
100774 +++ b/sound/oss/swarm_cs4297a.c
100775 @@ -2621,7 +2621,6 @@ static int __init cs4297a_init(void)
100776 {
100777 struct cs4297a_state *s;
100778 u32 pwr, id;
100779 - mm_segment_t fs;
100780 int rval;
100781 #ifndef CONFIG_BCM_CS4297A_CSWARM
100782 u64 cfg;
100783 @@ -2711,22 +2710,23 @@ static int __init cs4297a_init(void)
100784 if (!rval) {
100785 char *sb1250_duart_present;
100786
100787 +#if 0
100788 + mm_segment_t fs;
100789 fs = get_fs();
100790 set_fs(KERNEL_DS);
100791 -#if 0
100792 val = SOUND_MASK_LINE;
100793 mixer_ioctl(s, SOUND_MIXER_WRITE_RECSRC, (unsigned long) &val);
100794 for (i = 0; i < ARRAY_SIZE(initvol); i++) {
100795 val = initvol[i].vol;
100796 mixer_ioctl(s, initvol[i].mixch, (unsigned long) &val);
100797 }
100798 + set_fs(fs);
100799 // cs4297a_write_ac97(s, 0x18, 0x0808);
100800 #else
100801 // cs4297a_write_ac97(s, 0x5e, 0x180);
100802 cs4297a_write_ac97(s, 0x02, 0x0808);
100803 cs4297a_write_ac97(s, 0x18, 0x0808);
100804 #endif
100805 - set_fs(fs);
100806
100807 list_add(&s->list, &cs4297a_devs);
100808
100809 diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
100810 index e938a68..2a728ad 100644
100811 --- a/sound/pci/hda/hda_codec.c
100812 +++ b/sound/pci/hda/hda_codec.c
100813 @@ -976,14 +976,10 @@ find_codec_preset(struct hda_codec *codec)
100814 mutex_unlock(&preset_mutex);
100815
100816 if (mod_requested < HDA_MODREQ_MAX_COUNT) {
100817 - char name[32];
100818 if (!mod_requested)
100819 - snprintf(name, sizeof(name), "snd-hda-codec-id:%08x",
100820 - codec->vendor_id);
100821 + request_module("snd-hda-codec-id:%08x", codec->vendor_id);
100822 else
100823 - snprintf(name, sizeof(name), "snd-hda-codec-id:%04x*",
100824 - (codec->vendor_id >> 16) & 0xffff);
100825 - request_module(name);
100826 + request_module("snd-hda-codec-id:%04x*", (codec->vendor_id >> 16) & 0xffff);
100827 mod_requested++;
100828 goto again;
100829 }
100830 diff --git a/sound/pci/ymfpci/ymfpci.h b/sound/pci/ymfpci/ymfpci.h
100831 index 4631a23..001ae57 100644
100832 --- a/sound/pci/ymfpci/ymfpci.h
100833 +++ b/sound/pci/ymfpci/ymfpci.h
100834 @@ -358,7 +358,7 @@ struct snd_ymfpci {
100835 spinlock_t reg_lock;
100836 spinlock_t voice_lock;
100837 wait_queue_head_t interrupt_sleep;
100838 - atomic_t interrupt_sleep_count;
100839 + atomic_unchecked_t interrupt_sleep_count;
100840 struct snd_info_entry *proc_entry;
100841 const struct firmware *dsp_microcode;
100842 const struct firmware *controller_microcode;
100843 diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c
100844 index d591c15..8cb8f94 100644
100845 --- a/sound/pci/ymfpci/ymfpci_main.c
100846 +++ b/sound/pci/ymfpci/ymfpci_main.c
100847 @@ -202,8 +202,8 @@ static void snd_ymfpci_hw_stop(struct snd_ymfpci *chip)
100848 if ((snd_ymfpci_readl(chip, YDSXGR_STATUS) & 2) == 0)
100849 break;
100850 }
100851 - if (atomic_read(&chip->interrupt_sleep_count)) {
100852 - atomic_set(&chip->interrupt_sleep_count, 0);
100853 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
100854 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
100855 wake_up(&chip->interrupt_sleep);
100856 }
100857 __end:
100858 @@ -787,7 +787,7 @@ static void snd_ymfpci_irq_wait(struct snd_ymfpci *chip)
100859 continue;
100860 init_waitqueue_entry(&wait, current);
100861 add_wait_queue(&chip->interrupt_sleep, &wait);
100862 - atomic_inc(&chip->interrupt_sleep_count);
100863 + atomic_inc_unchecked(&chip->interrupt_sleep_count);
100864 schedule_timeout_uninterruptible(msecs_to_jiffies(50));
100865 remove_wait_queue(&chip->interrupt_sleep, &wait);
100866 }
100867 @@ -825,8 +825,8 @@ static irqreturn_t snd_ymfpci_interrupt(int irq, void *dev_id)
100868 snd_ymfpci_writel(chip, YDSXGR_MODE, mode);
100869 spin_unlock(&chip->reg_lock);
100870
100871 - if (atomic_read(&chip->interrupt_sleep_count)) {
100872 - atomic_set(&chip->interrupt_sleep_count, 0);
100873 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
100874 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
100875 wake_up(&chip->interrupt_sleep);
100876 }
100877 }
100878 @@ -2421,7 +2421,7 @@ int snd_ymfpci_create(struct snd_card *card,
100879 spin_lock_init(&chip->reg_lock);
100880 spin_lock_init(&chip->voice_lock);
100881 init_waitqueue_head(&chip->interrupt_sleep);
100882 - atomic_set(&chip->interrupt_sleep_count, 0);
100883 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
100884 chip->card = card;
100885 chip->pci = pci;
100886 chip->irq = -1;
100887 diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
100888 index 6b81d0c..031c056 100644
100889 --- a/sound/soc/fsl/fsl_ssi.c
100890 +++ b/sound/soc/fsl/fsl_ssi.c
100891 @@ -864,7 +864,7 @@ static int fsl_ssi_probe(struct platform_device *pdev)
100892 {
100893 struct fsl_ssi_private *ssi_private;
100894 int ret = 0;
100895 - struct device_attribute *dev_attr = NULL;
100896 + device_attribute_no_const *dev_attr = NULL;
100897 struct device_node *np = pdev->dev.of_node;
100898 const char *p, *sprop;
100899 const uint32_t *iprop;
100900 diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
100901 index 1a38be0..66809d1 100644
100902 --- a/sound/soc/soc-core.c
100903 +++ b/sound/soc/soc-core.c
100904 @@ -2248,8 +2248,10 @@ int snd_soc_set_ac97_ops_of_reset(struct snd_ac97_bus_ops *ops,
100905 if (ret)
100906 return ret;
100907
100908 - ops->warm_reset = snd_soc_ac97_warm_reset;
100909 - ops->reset = snd_soc_ac97_reset;
100910 + pax_open_kernel();
100911 + *(void **)&ops->warm_reset = snd_soc_ac97_warm_reset;
100912 + *(void **)&ops->reset = snd_soc_ac97_reset;
100913 + pax_close_kernel();
100914
100915 snd_ac97_rst_cfg = cfg;
100916 return 0;
100917 diff --git a/tools/gcc/.gitignore b/tools/gcc/.gitignore
100918 new file mode 100644
100919 index 0000000..50f2f2f
100920 --- /dev/null
100921 +++ b/tools/gcc/.gitignore
100922 @@ -0,0 +1 @@
100923 +size_overflow_hash.h
100924 diff --git a/tools/gcc/Makefile b/tools/gcc/Makefile
100925 new file mode 100644
100926 index 0000000..144dbee
100927 --- /dev/null
100928 +++ b/tools/gcc/Makefile
100929 @@ -0,0 +1,45 @@
100930 +#CC := gcc
100931 +#PLUGIN_SOURCE_FILES := pax_plugin.c
100932 +#PLUGIN_OBJECT_FILES := $(patsubst %.c,%.o,$(PLUGIN_SOURCE_FILES))
100933 +GCCPLUGINS_DIR := $(shell $(CC) -print-file-name=plugin)
100934 +#CFLAGS += -I$(GCCPLUGINS_DIR)/include -fPIC -O2 -Wall -W -std=gnu99
100935 +
100936 +ifeq ($(PLUGINCC),$(HOSTCC))
100937 +HOSTLIBS := hostlibs
100938 +HOST_EXTRACFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu99 -ggdb
100939 +else
100940 +HOSTLIBS := hostcxxlibs
100941 +HOST_EXTRACXXFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu++98 -ggdb -Wno-unused-parameter
100942 +endif
100943 +
100944 +$(HOSTLIBS)-$(CONFIG_PAX_CONSTIFY_PLUGIN) := constify_plugin.so
100945 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STACKLEAK) += stackleak_plugin.so
100946 +$(HOSTLIBS)-$(CONFIG_KALLOCSTAT_PLUGIN) += kallocstat_plugin.so
100947 +$(HOSTLIBS)-$(CONFIG_PAX_KERNEXEC_PLUGIN) += kernexec_plugin.so
100948 +$(HOSTLIBS)-$(CONFIG_CHECKER_PLUGIN) += checker_plugin.so
100949 +$(HOSTLIBS)-y += colorize_plugin.so
100950 +$(HOSTLIBS)-$(CONFIG_PAX_SIZE_OVERFLOW) += size_overflow_plugin.so
100951 +$(HOSTLIBS)-$(CONFIG_PAX_LATENT_ENTROPY) += latent_entropy_plugin.so
100952 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STRUCTLEAK) += structleak_plugin.so
100953 +
100954 +always := $($(HOSTLIBS)-y)
100955 +
100956 +constify_plugin-objs := constify_plugin.o
100957 +stackleak_plugin-objs := stackleak_plugin.o
100958 +kallocstat_plugin-objs := kallocstat_plugin.o
100959 +kernexec_plugin-objs := kernexec_plugin.o
100960 +checker_plugin-objs := checker_plugin.o
100961 +colorize_plugin-objs := colorize_plugin.o
100962 +size_overflow_plugin-objs := size_overflow_plugin.o
100963 +latent_entropy_plugin-objs := latent_entropy_plugin.o
100964 +structleak_plugin-objs := structleak_plugin.o
100965 +
100966 +$(obj)/size_overflow_plugin.o: $(objtree)/$(obj)/size_overflow_hash.h
100967 +
100968 +quiet_cmd_build_size_overflow_hash = GENHASH $@
100969 + cmd_build_size_overflow_hash = \
100970 + $(CONFIG_SHELL) $(srctree)/$(src)/generate_size_overflow_hash.sh -d $< -o $@
100971 +$(objtree)/$(obj)/size_overflow_hash.h: $(src)/size_overflow_hash.data FORCE
100972 + $(call if_changed,build_size_overflow_hash)
100973 +
100974 +targets += size_overflow_hash.h
100975 diff --git a/tools/gcc/checker_plugin.c b/tools/gcc/checker_plugin.c
100976 new file mode 100644
100977 index 0000000..22f03c0
100978 --- /dev/null
100979 +++ b/tools/gcc/checker_plugin.c
100980 @@ -0,0 +1,172 @@
100981 +/*
100982 + * Copyright 2011 by the PaX Team <pageexec@freemail.hu>
100983 + * Licensed under the GPL v2
100984 + *
100985 + * Note: the choice of the license means that the compilation process is
100986 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
100987 + * but for the kernel it doesn't matter since it doesn't link against
100988 + * any of the gcc libraries
100989 + *
100990 + * gcc plugin to implement various sparse (source code checker) features
100991 + *
100992 + * TODO:
100993 + * - define separate __iomem, __percpu and __rcu address spaces (lots of code to patch)
100994 + *
100995 + * BUGS:
100996 + * - none known
100997 + */
100998 +#include "gcc-plugin.h"
100999 +#include "config.h"
101000 +#include "system.h"
101001 +#include "coretypes.h"
101002 +#include "tree.h"
101003 +#include "tree-pass.h"
101004 +#include "flags.h"
101005 +#include "intl.h"
101006 +#include "toplev.h"
101007 +#include "plugin.h"
101008 +//#include "expr.h" where are you...
101009 +#include "diagnostic.h"
101010 +#include "plugin-version.h"
101011 +#include "tm.h"
101012 +#include "function.h"
101013 +#include "basic-block.h"
101014 +#include "gimple.h"
101015 +#include "rtl.h"
101016 +#include "emit-rtl.h"
101017 +#include "tree-flow.h"
101018 +#include "target.h"
101019 +
101020 +extern void c_register_addr_space (const char *str, addr_space_t as);
101021 +extern enum machine_mode default_addr_space_pointer_mode (addr_space_t);
101022 +extern enum machine_mode default_addr_space_address_mode (addr_space_t);
101023 +extern bool default_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as);
101024 +extern bool default_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as);
101025 +extern rtx default_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as);
101026 +
101027 +extern void print_gimple_stmt(FILE *, gimple, int, int);
101028 +extern rtx emit_move_insn(rtx x, rtx y);
101029 +
101030 +int plugin_is_GPL_compatible;
101031 +
101032 +static struct plugin_info checker_plugin_info = {
101033 + .version = "201111150100",
101034 + .help = NULL,
101035 +};
101036 +
101037 +#define ADDR_SPACE_KERNEL 0
101038 +#define ADDR_SPACE_FORCE_KERNEL 1
101039 +#define ADDR_SPACE_USER 2
101040 +#define ADDR_SPACE_FORCE_USER 3
101041 +#define ADDR_SPACE_IOMEM 0
101042 +#define ADDR_SPACE_FORCE_IOMEM 0
101043 +#define ADDR_SPACE_PERCPU 0
101044 +#define ADDR_SPACE_FORCE_PERCPU 0
101045 +#define ADDR_SPACE_RCU 0
101046 +#define ADDR_SPACE_FORCE_RCU 0
101047 +
101048 +static enum machine_mode checker_addr_space_pointer_mode(addr_space_t addrspace)
101049 +{
101050 + return default_addr_space_pointer_mode(ADDR_SPACE_GENERIC);
101051 +}
101052 +
101053 +static enum machine_mode checker_addr_space_address_mode(addr_space_t addrspace)
101054 +{
101055 + return default_addr_space_address_mode(ADDR_SPACE_GENERIC);
101056 +}
101057 +
101058 +static bool checker_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as)
101059 +{
101060 + return default_addr_space_valid_pointer_mode(mode, as);
101061 +}
101062 +
101063 +static bool checker_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as)
101064 +{
101065 + return default_addr_space_legitimate_address_p(mode, mem, strict, ADDR_SPACE_GENERIC);
101066 +}
101067 +
101068 +static rtx checker_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as)
101069 +{
101070 + return default_addr_space_legitimize_address(x, oldx, mode, as);
101071 +}
101072 +
101073 +static bool checker_addr_space_subset_p(addr_space_t subset, addr_space_t superset)
101074 +{
101075 + if (subset == ADDR_SPACE_FORCE_KERNEL && superset == ADDR_SPACE_KERNEL)
101076 + return true;
101077 +
101078 + if (subset == ADDR_SPACE_FORCE_USER && superset == ADDR_SPACE_USER)
101079 + return true;
101080 +
101081 + if (subset == ADDR_SPACE_FORCE_IOMEM && superset == ADDR_SPACE_IOMEM)
101082 + return true;
101083 +
101084 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_USER)
101085 + return true;
101086 +
101087 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_IOMEM)
101088 + return true;
101089 +
101090 + if (subset == ADDR_SPACE_USER && superset == ADDR_SPACE_FORCE_KERNEL)
101091 + return true;
101092 +
101093 + if (subset == ADDR_SPACE_IOMEM && superset == ADDR_SPACE_FORCE_KERNEL)
101094 + return true;
101095 +
101096 + return subset == superset;
101097 +}
101098 +
101099 +static rtx checker_addr_space_convert(rtx op, tree from_type, tree to_type)
101100 +{
101101 +// addr_space_t from_as = TYPE_ADDR_SPACE(TREE_TYPE(from_type));
101102 +// addr_space_t to_as = TYPE_ADDR_SPACE(TREE_TYPE(to_type));
101103 +
101104 + return op;
101105 +}
101106 +
101107 +static void register_checker_address_spaces(void *event_data, void *data)
101108 +{
101109 + c_register_addr_space("__kernel", ADDR_SPACE_KERNEL);
101110 + c_register_addr_space("__force_kernel", ADDR_SPACE_FORCE_KERNEL);
101111 + c_register_addr_space("__user", ADDR_SPACE_USER);
101112 + c_register_addr_space("__force_user", ADDR_SPACE_FORCE_USER);
101113 +// c_register_addr_space("__iomem", ADDR_SPACE_IOMEM);
101114 +// c_register_addr_space("__force_iomem", ADDR_SPACE_FORCE_IOMEM);
101115 +// c_register_addr_space("__percpu", ADDR_SPACE_PERCPU);
101116 +// c_register_addr_space("__force_percpu", ADDR_SPACE_FORCE_PERCPU);
101117 +// c_register_addr_space("__rcu", ADDR_SPACE_RCU);
101118 +// c_register_addr_space("__force_rcu", ADDR_SPACE_FORCE_RCU);
101119 +
101120 + targetm.addr_space.pointer_mode = checker_addr_space_pointer_mode;
101121 + targetm.addr_space.address_mode = checker_addr_space_address_mode;
101122 + targetm.addr_space.valid_pointer_mode = checker_addr_space_valid_pointer_mode;
101123 + targetm.addr_space.legitimate_address_p = checker_addr_space_legitimate_address_p;
101124 +// targetm.addr_space.legitimize_address = checker_addr_space_legitimize_address;
101125 + targetm.addr_space.subset_p = checker_addr_space_subset_p;
101126 + targetm.addr_space.convert = checker_addr_space_convert;
101127 +}
101128 +
101129 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
101130 +{
101131 + const char * const plugin_name = plugin_info->base_name;
101132 + const int argc = plugin_info->argc;
101133 + const struct plugin_argument * const argv = plugin_info->argv;
101134 + int i;
101135 +
101136 + if (!plugin_default_version_check(version, &gcc_version)) {
101137 + error(G_("incompatible gcc/plugin versions"));
101138 + return 1;
101139 + }
101140 +
101141 + register_callback(plugin_name, PLUGIN_INFO, NULL, &checker_plugin_info);
101142 +
101143 + for (i = 0; i < argc; ++i)
101144 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
101145 +
101146 + if (TARGET_64BIT == 0)
101147 + return 0;
101148 +
101149 + register_callback(plugin_name, PLUGIN_PRAGMAS, register_checker_address_spaces, NULL);
101150 +
101151 + return 0;
101152 +}
101153 diff --git a/tools/gcc/colorize_plugin.c b/tools/gcc/colorize_plugin.c
101154 new file mode 100644
101155 index 0000000..414fe5e
101156 --- /dev/null
101157 +++ b/tools/gcc/colorize_plugin.c
101158 @@ -0,0 +1,151 @@
101159 +/*
101160 + * Copyright 2012-2013 by PaX Team <pageexec@freemail.hu>
101161 + * Licensed under the GPL v2
101162 + *
101163 + * Note: the choice of the license means that the compilation process is
101164 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
101165 + * but for the kernel it doesn't matter since it doesn't link against
101166 + * any of the gcc libraries
101167 + *
101168 + * gcc plugin to colorize diagnostic output
101169 + *
101170 + */
101171 +
101172 +#include "gcc-plugin.h"
101173 +#include "config.h"
101174 +#include "system.h"
101175 +#include "coretypes.h"
101176 +#include "tree.h"
101177 +#include "tree-pass.h"
101178 +#include "flags.h"
101179 +#include "intl.h"
101180 +#include "toplev.h"
101181 +#include "plugin.h"
101182 +#include "diagnostic.h"
101183 +#include "plugin-version.h"
101184 +#include "tm.h"
101185 +
101186 +int plugin_is_GPL_compatible;
101187 +
101188 +static struct plugin_info colorize_plugin_info = {
101189 + .version = "201302112000",
101190 + .help = NULL,
101191 +};
101192 +
101193 +#define GREEN "\033[32m\033[2m"
101194 +#define LIGHTGREEN "\033[32m\033[1m"
101195 +#define YELLOW "\033[33m\033[2m"
101196 +#define LIGHTYELLOW "\033[33m\033[1m"
101197 +#define RED "\033[31m\033[2m"
101198 +#define LIGHTRED "\033[31m\033[1m"
101199 +#define BLUE "\033[34m\033[2m"
101200 +#define LIGHTBLUE "\033[34m\033[1m"
101201 +#define BRIGHT "\033[m\033[1m"
101202 +#define NORMAL "\033[m"
101203 +
101204 +static diagnostic_starter_fn old_starter;
101205 +static diagnostic_finalizer_fn old_finalizer;
101206 +
101207 +static void start_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
101208 +{
101209 + const char *color;
101210 + char *newprefix;
101211 +
101212 + switch (diagnostic->kind) {
101213 + case DK_NOTE:
101214 + color = LIGHTBLUE;
101215 + break;
101216 +
101217 + case DK_PEDWARN:
101218 + case DK_WARNING:
101219 + color = LIGHTYELLOW;
101220 + break;
101221 +
101222 + case DK_ERROR:
101223 + case DK_FATAL:
101224 + case DK_ICE:
101225 + case DK_PERMERROR:
101226 + case DK_SORRY:
101227 + color = LIGHTRED;
101228 + break;
101229 +
101230 + default:
101231 + color = NORMAL;
101232 + }
101233 +
101234 + old_starter(context, diagnostic);
101235 + if (-1 == asprintf(&newprefix, "%s%s" NORMAL, color, context->printer->prefix))
101236 + return;
101237 + pp_destroy_prefix(context->printer);
101238 + pp_set_prefix(context->printer, newprefix);
101239 +}
101240 +
101241 +static void finalize_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
101242 +{
101243 + old_finalizer(context, diagnostic);
101244 +}
101245 +
101246 +static void colorize_arm(void)
101247 +{
101248 + old_starter = diagnostic_starter(global_dc);
101249 + old_finalizer = diagnostic_finalizer(global_dc);
101250 +
101251 + diagnostic_starter(global_dc) = start_colorize;
101252 + diagnostic_finalizer(global_dc) = finalize_colorize;
101253 +}
101254 +
101255 +static unsigned int execute_colorize_rearm(void)
101256 +{
101257 + if (diagnostic_starter(global_dc) == start_colorize)
101258 + return 0;
101259 +
101260 + colorize_arm();
101261 + return 0;
101262 +}
101263 +
101264 +struct simple_ipa_opt_pass pass_ipa_colorize_rearm = {
101265 + .pass = {
101266 + .type = SIMPLE_IPA_PASS,
101267 + .name = "colorize_rearm",
101268 +#if BUILDING_GCC_VERSION >= 4008
101269 + .optinfo_flags = OPTGROUP_NONE,
101270 +#endif
101271 + .gate = NULL,
101272 + .execute = execute_colorize_rearm,
101273 + .sub = NULL,
101274 + .next = NULL,
101275 + .static_pass_number = 0,
101276 + .tv_id = TV_NONE,
101277 + .properties_required = 0,
101278 + .properties_provided = 0,
101279 + .properties_destroyed = 0,
101280 + .todo_flags_start = 0,
101281 + .todo_flags_finish = 0
101282 + }
101283 +};
101284 +
101285 +static void colorize_start_unit(void *gcc_data, void *user_data)
101286 +{
101287 + colorize_arm();
101288 +}
101289 +
101290 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
101291 +{
101292 + const char * const plugin_name = plugin_info->base_name;
101293 + struct register_pass_info colorize_rearm_pass_info = {
101294 + .pass = &pass_ipa_colorize_rearm.pass,
101295 + .reference_pass_name = "*free_lang_data",
101296 + .ref_pass_instance_number = 1,
101297 + .pos_op = PASS_POS_INSERT_AFTER
101298 + };
101299 +
101300 + if (!plugin_default_version_check(version, &gcc_version)) {
101301 + error(G_("incompatible gcc/plugin versions"));
101302 + return 1;
101303 + }
101304 +
101305 + register_callback(plugin_name, PLUGIN_INFO, NULL, &colorize_plugin_info);
101306 + register_callback(plugin_name, PLUGIN_START_UNIT, &colorize_start_unit, NULL);
101307 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &colorize_rearm_pass_info);
101308 + return 0;
101309 +}
101310 diff --git a/tools/gcc/constify_plugin.c b/tools/gcc/constify_plugin.c
101311 new file mode 100644
101312 index 0000000..ba59e50
101313 --- /dev/null
101314 +++ b/tools/gcc/constify_plugin.c
101315 @@ -0,0 +1,558 @@
101316 +/*
101317 + * Copyright 2011 by Emese Revfy <re.emese@gmail.com>
101318 + * Copyright 2011-2013 by PaX Team <pageexec@freemail.hu>
101319 + * Licensed under the GPL v2, or (at your option) v3
101320 + *
101321 + * This gcc plugin constifies all structures which contain only function pointers or are explicitly marked for constification.
101322 + *
101323 + * Homepage:
101324 + * http://www.grsecurity.net/~ephox/const_plugin/
101325 + *
101326 + * Usage:
101327 + * $ gcc -I`gcc -print-file-name=plugin`/include -fPIC -shared -O2 -o constify_plugin.so constify_plugin.c
101328 + * $ gcc -fplugin=constify_plugin.so test.c -O2
101329 + */
101330 +
101331 +#include "gcc-plugin.h"
101332 +#include "config.h"
101333 +#include "system.h"
101334 +#include "coretypes.h"
101335 +#include "tree.h"
101336 +#include "tree-pass.h"
101337 +#include "flags.h"
101338 +#include "intl.h"
101339 +#include "toplev.h"
101340 +#include "plugin.h"
101341 +#include "diagnostic.h"
101342 +#include "plugin-version.h"
101343 +#include "tm.h"
101344 +#include "function.h"
101345 +#include "basic-block.h"
101346 +#include "gimple.h"
101347 +#include "rtl.h"
101348 +#include "emit-rtl.h"
101349 +#include "tree-flow.h"
101350 +#include "target.h"
101351 +#include "langhooks.h"
101352 +
101353 +// should come from c-tree.h if only it were installed for gcc 4.5...
101354 +#define C_TYPE_FIELDS_READONLY(TYPE) TREE_LANG_FLAG_1(TYPE)
101355 +
101356 +// unused type flag in all versions 4.5-4.8
101357 +#define TYPE_CONSTIFY_VISITED(TYPE) TYPE_LANG_FLAG_4(TYPE)
101358 +
101359 +int plugin_is_GPL_compatible;
101360 +
101361 +static struct plugin_info const_plugin_info = {
101362 + .version = "201312032345",
101363 + .help = "no-constify\tturn off constification\n",
101364 +};
101365 +
101366 +typedef struct {
101367 + bool has_fptr_field;
101368 + bool has_writable_field;
101369 + bool has_do_const_field;
101370 + bool has_no_const_field;
101371 +} constify_info;
101372 +
101373 +static const_tree get_field_type(const_tree field)
101374 +{
101375 + return strip_array_types(TREE_TYPE(field));
101376 +}
101377 +
101378 +static bool is_fptr(const_tree field)
101379 +{
101380 + const_tree ptr = get_field_type(field);
101381 +
101382 + if (TREE_CODE(ptr) != POINTER_TYPE)
101383 + return false;
101384 +
101385 + return TREE_CODE(TREE_TYPE(ptr)) == FUNCTION_TYPE;
101386 +}
101387 +
101388 +/*
101389 + * determine whether the given structure type meets the requirements for automatic constification,
101390 + * including the constification attributes on nested structure types
101391 + */
101392 +static void constifiable(const_tree node, constify_info *cinfo)
101393 +{
101394 + const_tree field;
101395 +
101396 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
101397 +
101398 + // e.g., pointer to structure fields while still constructing the structure type
101399 + if (TYPE_FIELDS(node) == NULL_TREE)
101400 + return;
101401 +
101402 + for (field = TYPE_FIELDS(node); field; field = TREE_CHAIN(field)) {
101403 + const_tree type = get_field_type(field);
101404 + enum tree_code code = TREE_CODE(type);
101405 +
101406 + if (node == type)
101407 + continue;
101408 +
101409 + if (is_fptr(field))
101410 + cinfo->has_fptr_field = true;
101411 + else if (!TREE_READONLY(field))
101412 + cinfo->has_writable_field = true;
101413 +
101414 + if (code == RECORD_TYPE || code == UNION_TYPE) {
101415 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
101416 + cinfo->has_do_const_field = true;
101417 + else if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type)))
101418 + cinfo->has_no_const_field = true;
101419 + else
101420 + constifiable(type, cinfo);
101421 + }
101422 + }
101423 +}
101424 +
101425 +static bool constified(const_tree node)
101426 +{
101427 + constify_info cinfo = {
101428 + .has_fptr_field = false,
101429 + .has_writable_field = false,
101430 + .has_do_const_field = false,
101431 + .has_no_const_field = false
101432 + };
101433 +
101434 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
101435 +
101436 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(node))) {
101437 + gcc_assert(!TYPE_READONLY(node));
101438 + return false;
101439 + }
101440 +
101441 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(node))) {
101442 + gcc_assert(TYPE_READONLY(node));
101443 + return true;
101444 + }
101445 +
101446 + constifiable(node, &cinfo);
101447 + if ((!cinfo.has_fptr_field || cinfo.has_writable_field) && !cinfo.has_do_const_field)
101448 + return false;
101449 +
101450 + return TYPE_READONLY(node);
101451 +}
101452 +
101453 +static void deconstify_tree(tree node);
101454 +
101455 +static void deconstify_type(tree type)
101456 +{
101457 + tree field;
101458 +
101459 + gcc_assert(TREE_CODE(type) == RECORD_TYPE || TREE_CODE(type) == UNION_TYPE);
101460 +
101461 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
101462 + const_tree fieldtype = get_field_type(field);
101463 +
101464 + // special case handling of simple ptr-to-same-array-type members
101465 + if (TREE_CODE(TREE_TYPE(field)) == POINTER_TYPE) {
101466 + const_tree ptrtype = TREE_TYPE(TREE_TYPE(field));
101467 +
101468 + if (TREE_CODE(ptrtype) != RECORD_TYPE && TREE_CODE(ptrtype) != UNION_TYPE)
101469 + continue;
101470 + if (TREE_TYPE(TREE_TYPE(field)) == type)
101471 + continue;
101472 + if (TYPE_MAIN_VARIANT(ptrtype) == TYPE_MAIN_VARIANT(type)) {
101473 + TREE_TYPE(field) = copy_node(TREE_TYPE(field));
101474 + TREE_TYPE(TREE_TYPE(field)) = type;
101475 + }
101476 + continue;
101477 + }
101478 + if (TREE_CODE(fieldtype) != RECORD_TYPE && TREE_CODE(fieldtype) != UNION_TYPE)
101479 + continue;
101480 + if (!constified(fieldtype))
101481 + continue;
101482 +
101483 + deconstify_tree(field);
101484 + TREE_READONLY(field) = 0;
101485 + }
101486 + TYPE_READONLY(type) = 0;
101487 + C_TYPE_FIELDS_READONLY(type) = 0;
101488 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
101489 + TYPE_ATTRIBUTES(type) = remove_attribute("do_const", TYPE_ATTRIBUTES(type));
101490 +}
101491 +
101492 +static void deconstify_tree(tree node)
101493 +{
101494 + tree old_type, new_type, field;
101495 +
101496 + old_type = TREE_TYPE(node);
101497 + while (TREE_CODE(old_type) == ARRAY_TYPE && TREE_CODE(TREE_TYPE(old_type)) != ARRAY_TYPE) {
101498 + node = TREE_TYPE(node) = copy_node(old_type);
101499 + old_type = TREE_TYPE(old_type);
101500 + }
101501 +
101502 + gcc_assert(TREE_CODE(old_type) == RECORD_TYPE || TREE_CODE(old_type) == UNION_TYPE);
101503 + gcc_assert(TYPE_READONLY(old_type) && (TYPE_QUALS(old_type) & TYPE_QUAL_CONST));
101504 +
101505 + new_type = build_qualified_type(old_type, TYPE_QUALS(old_type) & ~TYPE_QUAL_CONST);
101506 + TYPE_FIELDS(new_type) = copy_list(TYPE_FIELDS(new_type));
101507 + for (field = TYPE_FIELDS(new_type); field; field = TREE_CHAIN(field))
101508 + DECL_FIELD_CONTEXT(field) = new_type;
101509 +
101510 + deconstify_type(new_type);
101511 +
101512 + TREE_TYPE(node) = new_type;
101513 +}
101514 +
101515 +static tree handle_no_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
101516 +{
101517 + tree type;
101518 + constify_info cinfo = {
101519 + .has_fptr_field = false,
101520 + .has_writable_field = false,
101521 + .has_do_const_field = false,
101522 + .has_no_const_field = false
101523 + };
101524 +
101525 + *no_add_attrs = true;
101526 + if (TREE_CODE(*node) == FUNCTION_DECL) {
101527 + error("%qE attribute does not apply to functions (%qF)", name, *node);
101528 + return NULL_TREE;
101529 + }
101530 +
101531 + if (TREE_CODE(*node) == PARM_DECL) {
101532 + error("%qE attribute does not apply to function parameters (%qD)", name, *node);
101533 + return NULL_TREE;
101534 + }
101535 +
101536 + if (TREE_CODE(*node) == VAR_DECL) {
101537 + error("%qE attribute does not apply to variables (%qD)", name, *node);
101538 + return NULL_TREE;
101539 + }
101540 +
101541 + if (TYPE_P(*node)) {
101542 + *no_add_attrs = false;
101543 + type = *node;
101544 + } else {
101545 + gcc_assert(TREE_CODE(*node) == TYPE_DECL);
101546 + type = TREE_TYPE(*node);
101547 + }
101548 +
101549 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE) {
101550 + error("%qE attribute used on %qT applies to struct and union types only", name, type);
101551 + return NULL_TREE;
101552 + }
101553 +
101554 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(type))) {
101555 + error("%qE attribute is already applied to the type %qT", name, type);
101556 + return NULL_TREE;
101557 + }
101558 +
101559 + if (TYPE_P(*node)) {
101560 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
101561 + error("%qE attribute used on type %qT is incompatible with 'do_const'", name, type);
101562 + return NULL_TREE;
101563 + }
101564 +
101565 + constifiable(type, &cinfo);
101566 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
101567 + deconstify_tree(*node);
101568 + TYPE_CONSTIFY_VISITED(TREE_TYPE(*node)) = 1;
101569 + return NULL_TREE;
101570 + }
101571 +
101572 + error("%qE attribute used on type %qT that is not constified", name, type);
101573 + return NULL_TREE;
101574 +}
101575 +
101576 +static void constify_type(tree type)
101577 +{
101578 + TYPE_READONLY(type) = 1;
101579 + C_TYPE_FIELDS_READONLY(type) = 1;
101580 + TYPE_CONSTIFY_VISITED(type) = 1;
101581 +// TYPE_ATTRIBUTES(type) = tree_cons(get_identifier("do_const"), NULL_TREE, TYPE_ATTRIBUTES(type));
101582 +}
101583 +
101584 +static tree handle_do_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
101585 +{
101586 + *no_add_attrs = true;
101587 + if (!TYPE_P(*node)) {
101588 + error("%qE attribute applies to types only (%qD)", name, *node);
101589 + return NULL_TREE;
101590 + }
101591 +
101592 + if (TREE_CODE(*node) != RECORD_TYPE && TREE_CODE(*node) != UNION_TYPE) {
101593 + error("%qE attribute used on %qT applies to struct and union types only", name, *node);
101594 + return NULL_TREE;
101595 + }
101596 +
101597 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(*node))) {
101598 + error("%qE attribute used on %qT is already applied to the type", name, *node);
101599 + return NULL_TREE;
101600 + }
101601 +
101602 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(*node))) {
101603 + error("%qE attribute used on %qT is incompatible with 'no_const'", name, *node);
101604 + return NULL_TREE;
101605 + }
101606 +
101607 + *no_add_attrs = false;
101608 + return NULL_TREE;
101609 +}
101610 +
101611 +static struct attribute_spec no_const_attr = {
101612 + .name = "no_const",
101613 + .min_length = 0,
101614 + .max_length = 0,
101615 + .decl_required = false,
101616 + .type_required = false,
101617 + .function_type_required = false,
101618 + .handler = handle_no_const_attribute,
101619 +#if BUILDING_GCC_VERSION >= 4007
101620 + .affects_type_identity = true
101621 +#endif
101622 +};
101623 +
101624 +static struct attribute_spec do_const_attr = {
101625 + .name = "do_const",
101626 + .min_length = 0,
101627 + .max_length = 0,
101628 + .decl_required = false,
101629 + .type_required = false,
101630 + .function_type_required = false,
101631 + .handler = handle_do_const_attribute,
101632 +#if BUILDING_GCC_VERSION >= 4007
101633 + .affects_type_identity = true
101634 +#endif
101635 +};
101636 +
101637 +static void register_attributes(void *event_data, void *data)
101638 +{
101639 + register_attribute(&no_const_attr);
101640 + register_attribute(&do_const_attr);
101641 +}
101642 +
101643 +static void finish_type(void *event_data, void *data)
101644 +{
101645 + tree type = (tree)event_data;
101646 + constify_info cinfo = {
101647 + .has_fptr_field = false,
101648 + .has_writable_field = false,
101649 + .has_do_const_field = false,
101650 + .has_no_const_field = false
101651 + };
101652 +
101653 + if (type == NULL_TREE || type == error_mark_node)
101654 + return;
101655 +
101656 + if (TYPE_FIELDS(type) == NULL_TREE || TYPE_CONSTIFY_VISITED(type))
101657 + return;
101658 +
101659 + constifiable(type, &cinfo);
101660 +
101661 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type))) {
101662 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || cinfo.has_do_const_field) {
101663 + deconstify_type(type);
101664 + TYPE_CONSTIFY_VISITED(type) = 1;
101665 + } else
101666 + error("'no_const' attribute used on type %qT that is not constified", type);
101667 + return;
101668 + }
101669 +
101670 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
101671 + if (!cinfo.has_writable_field) {
101672 + error("'do_const' attribute used on type %qT that is%sconstified", type, cinfo.has_fptr_field ? " " : " not ");
101673 + return;
101674 + }
101675 + constify_type(type);
101676 + return;
101677 + }
101678 +
101679 + if (cinfo.has_fptr_field && !cinfo.has_writable_field) {
101680 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
101681 + error("'do_const' attribute used on type %qT that is constified", type);
101682 + return;
101683 + }
101684 + constify_type(type);
101685 + return;
101686 + }
101687 +
101688 + deconstify_type(type);
101689 + TYPE_CONSTIFY_VISITED(type) = 1;
101690 +}
101691 +
101692 +static void check_global_variables(void)
101693 +{
101694 + struct varpool_node *node;
101695 +
101696 +#if BUILDING_GCC_VERSION <= 4007
101697 + for (node = varpool_nodes; node; node = node->next) {
101698 + tree var = node->decl;
101699 +#else
101700 + FOR_EACH_VARIABLE(node) {
101701 + tree var = node->symbol.decl;
101702 +#endif
101703 + tree type = TREE_TYPE(var);
101704 +
101705 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
101706 + continue;
101707 +
101708 + if (!TYPE_READONLY(type) || !C_TYPE_FIELDS_READONLY(type))
101709 + continue;
101710 +
101711 + if (!TYPE_CONSTIFY_VISITED(type))
101712 + continue;
101713 +
101714 + if (DECL_EXTERNAL(var))
101715 + continue;
101716 +
101717 + if (DECL_INITIAL(var))
101718 + continue;
101719 +
101720 + // this works around a gcc bug/feature where uninitialized globals
101721 + // are moved into the .bss section regardless of any constification
101722 + DECL_INITIAL(var) = build_constructor(type, NULL);
101723 +// inform(DECL_SOURCE_LOCATION(var), "constified variable %qE moved into .rodata", var);
101724 + }
101725 +}
101726 +
101727 +static unsigned int check_local_variables(void)
101728 +{
101729 + unsigned int ret = 0;
101730 + tree var;
101731 +
101732 +#if BUILDING_GCC_VERSION == 4005
101733 + tree vars;
101734 +#else
101735 + unsigned int i;
101736 +#endif
101737 +
101738 +#if BUILDING_GCC_VERSION == 4005
101739 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
101740 + var = TREE_VALUE(vars);
101741 +#else
101742 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
101743 +#endif
101744 + tree type = TREE_TYPE(var);
101745 +
101746 + gcc_assert(DECL_P(var));
101747 + if (is_global_var(var))
101748 + continue;
101749 +
101750 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
101751 + continue;
101752 +
101753 + if (!TYPE_READONLY(type) || !C_TYPE_FIELDS_READONLY(type))
101754 + continue;
101755 +
101756 + if (!TYPE_CONSTIFY_VISITED(type))
101757 + continue;
101758 +
101759 + error_at(DECL_SOURCE_LOCATION(var), "constified variable %qE cannot be local", var);
101760 + ret = 1;
101761 + }
101762 + return ret;
101763 +}
101764 +
101765 +static unsigned int check_variables(void)
101766 +{
101767 + check_global_variables();
101768 + return check_local_variables();
101769 +}
101770 +
101771 +static struct gimple_opt_pass pass_local_variable = {
101772 + {
101773 + .type = GIMPLE_PASS,
101774 + .name = "check_variables",
101775 +#if BUILDING_GCC_VERSION >= 4008
101776 + .optinfo_flags = OPTGROUP_NONE,
101777 +#endif
101778 + .gate = NULL,
101779 + .execute = check_variables,
101780 + .sub = NULL,
101781 + .next = NULL,
101782 + .static_pass_number = 0,
101783 + .tv_id = TV_NONE,
101784 + .properties_required = 0,
101785 + .properties_provided = 0,
101786 + .properties_destroyed = 0,
101787 + .todo_flags_start = 0,
101788 + .todo_flags_finish = 0
101789 + }
101790 +};
101791 +
101792 +static struct {
101793 + const char *name;
101794 + const char *asm_op;
101795 +} sections[] = {
101796 + {".init.rodata", "\t.section\t.init.rodata,\"a\""},
101797 + {".ref.rodata", "\t.section\t.ref.rodata,\"a\""},
101798 + {".devinit.rodata", "\t.section\t.devinit.rodata,\"a\""},
101799 + {".devexit.rodata", "\t.section\t.devexit.rodata,\"a\""},
101800 + {".cpuinit.rodata", "\t.section\t.cpuinit.rodata,\"a\""},
101801 + {".cpuexit.rodata", "\t.section\t.cpuexit.rodata,\"a\""},
101802 + {".meminit.rodata", "\t.section\t.meminit.rodata,\"a\""},
101803 + {".memexit.rodata", "\t.section\t.memexit.rodata,\"a\""},
101804 + {".data..read_only", "\t.section\t.data..read_only,\"a\""},
101805 +};
101806 +
101807 +static unsigned int (*old_section_type_flags)(tree decl, const char *name, int reloc);
101808 +
101809 +static unsigned int constify_section_type_flags(tree decl, const char *name, int reloc)
101810 +{
101811 + size_t i;
101812 +
101813 + for (i = 0; i < ARRAY_SIZE(sections); i++)
101814 + if (!strcmp(sections[i].name, name))
101815 + return 0;
101816 + return old_section_type_flags(decl, name, reloc);
101817 +}
101818 +
101819 +static void constify_start_unit(void *gcc_data, void *user_data)
101820 +{
101821 +// size_t i;
101822 +
101823 +// for (i = 0; i < ARRAY_SIZE(sections); i++)
101824 +// sections[i].section = get_unnamed_section(0, output_section_asm_op, sections[i].asm_op);
101825 +// sections[i].section = get_section(sections[i].name, 0, NULL);
101826 +
101827 + old_section_type_flags = targetm.section_type_flags;
101828 + targetm.section_type_flags = constify_section_type_flags;
101829 +}
101830 +
101831 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
101832 +{
101833 + const char * const plugin_name = plugin_info->base_name;
101834 + const int argc = plugin_info->argc;
101835 + const struct plugin_argument * const argv = plugin_info->argv;
101836 + int i;
101837 + bool constify = true;
101838 +
101839 + struct register_pass_info local_variable_pass_info = {
101840 + .pass = &pass_local_variable.pass,
101841 + .reference_pass_name = "ssa",
101842 + .ref_pass_instance_number = 1,
101843 + .pos_op = PASS_POS_INSERT_BEFORE
101844 + };
101845 +
101846 + if (!plugin_default_version_check(version, &gcc_version)) {
101847 + error(G_("incompatible gcc/plugin versions"));
101848 + return 1;
101849 + }
101850 +
101851 + for (i = 0; i < argc; ++i) {
101852 + if (!(strcmp(argv[i].key, "no-constify"))) {
101853 + constify = false;
101854 + continue;
101855 + }
101856 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
101857 + }
101858 +
101859 + if (strcmp(lang_hooks.name, "GNU C")) {
101860 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
101861 + constify = false;
101862 + }
101863 +
101864 + register_callback(plugin_name, PLUGIN_INFO, NULL, &const_plugin_info);
101865 + if (constify) {
101866 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
101867 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &local_variable_pass_info);
101868 + register_callback(plugin_name, PLUGIN_START_UNIT, constify_start_unit, NULL);
101869 + }
101870 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
101871 +
101872 + return 0;
101873 +}
101874 diff --git a/tools/gcc/generate_size_overflow_hash.sh b/tools/gcc/generate_size_overflow_hash.sh
101875 new file mode 100644
101876 index 0000000..e518932
101877 --- /dev/null
101878 +++ b/tools/gcc/generate_size_overflow_hash.sh
101879 @@ -0,0 +1,94 @@
101880 +#!/bin/bash
101881 +
101882 +# This script generates the hash table (size_overflow_hash.h) for the size_overflow gcc plugin (size_overflow_plugin.c).
101883 +
101884 +header1="size_overflow_hash.h"
101885 +database="size_overflow_hash.data"
101886 +n=65536
101887 +
101888 +usage() {
101889 +cat <<EOF
101890 +usage: $0 options
101891 +OPTIONS:
101892 + -h|--help help
101893 + -o header file
101894 + -d database file
101895 + -n hash array size
101896 +EOF
101897 + return 0
101898 +}
101899 +
101900 +while true
101901 +do
101902 + case "$1" in
101903 + -h|--help) usage && exit 0;;
101904 + -n) n=$2; shift 2;;
101905 + -o) header1="$2"; shift 2;;
101906 + -d) database="$2"; shift 2;;
101907 + --) shift 1; break ;;
101908 + *) break ;;
101909 + esac
101910 +done
101911 +
101912 +create_defines() {
101913 + for i in `seq 0 31`
101914 + do
101915 + echo -e "#define PARAM"$i" (1U << "$i")" >> "$header1"
101916 + done
101917 + echo >> "$header1"
101918 +}
101919 +
101920 +create_structs() {
101921 + rm -f "$header1"
101922 +
101923 + create_defines
101924 +
101925 + cat "$database" | while read data
101926 + do
101927 + data_array=($data)
101928 + struct_hash_name="${data_array[0]}"
101929 + funcn="${data_array[1]}"
101930 + params="${data_array[2]}"
101931 + next="${data_array[4]}"
101932 +
101933 + echo "const struct size_overflow_hash $struct_hash_name = {" >> "$header1"
101934 +
101935 + echo -e "\t.next\t= $next,\n\t.name\t= \"$funcn\"," >> "$header1"
101936 + echo -en "\t.param\t= " >> "$header1"
101937 + line=
101938 + for param_num in ${params//-/ };
101939 + do
101940 + line="${line}PARAM"$param_num"|"
101941 + done
101942 +
101943 + echo -e "${line%?},\n};\n" >> "$header1"
101944 + done
101945 +}
101946 +
101947 +create_headers() {
101948 + echo "const struct size_overflow_hash * const size_overflow_hash[$n] = {" >> "$header1"
101949 +}
101950 +
101951 +create_array_elements() {
101952 + index=0
101953 + grep -v "nohasharray" $database | sort -n -k 4 | while read data
101954 + do
101955 + data_array=($data)
101956 + i="${data_array[3]}"
101957 + hash="${data_array[0]}"
101958 + while [[ $index -lt $i ]]
101959 + do
101960 + echo -e "\t["$index"]\t= NULL," >> "$header1"
101961 + index=$(($index + 1))
101962 + done
101963 + index=$(($index + 1))
101964 + echo -e "\t["$i"]\t= &"$hash"," >> "$header1"
101965 + done
101966 + echo '};' >> $header1
101967 +}
101968 +
101969 +create_structs
101970 +create_headers
101971 +create_array_elements
101972 +
101973 +exit 0
101974 diff --git a/tools/gcc/kallocstat_plugin.c b/tools/gcc/kallocstat_plugin.c
101975 new file mode 100644
101976 index 0000000..568b360
101977 --- /dev/null
101978 +++ b/tools/gcc/kallocstat_plugin.c
101979 @@ -0,0 +1,170 @@
101980 +/*
101981 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
101982 + * Licensed under the GPL v2
101983 + *
101984 + * Note: the choice of the license means that the compilation process is
101985 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
101986 + * but for the kernel it doesn't matter since it doesn't link against
101987 + * any of the gcc libraries
101988 + *
101989 + * gcc plugin to find the distribution of k*alloc sizes
101990 + *
101991 + * TODO:
101992 + *
101993 + * BUGS:
101994 + * - none known
101995 + */
101996 +#include "gcc-plugin.h"
101997 +#include "config.h"
101998 +#include "system.h"
101999 +#include "coretypes.h"
102000 +#include "tree.h"
102001 +#include "tree-pass.h"
102002 +#include "flags.h"
102003 +#include "intl.h"
102004 +#include "toplev.h"
102005 +#include "plugin.h"
102006 +//#include "expr.h" where are you...
102007 +#include "diagnostic.h"
102008 +#include "plugin-version.h"
102009 +#include "tm.h"
102010 +#include "function.h"
102011 +#include "basic-block.h"
102012 +#include "gimple.h"
102013 +#include "rtl.h"
102014 +#include "emit-rtl.h"
102015 +
102016 +extern void print_gimple_stmt(FILE *, gimple, int, int);
102017 +
102018 +int plugin_is_GPL_compatible;
102019 +
102020 +static const char * const kalloc_functions[] = {
102021 + "__kmalloc",
102022 + "kmalloc",
102023 + "kmalloc_large",
102024 + "kmalloc_node",
102025 + "kmalloc_order",
102026 + "kmalloc_order_trace",
102027 + "kmalloc_slab",
102028 + "kzalloc",
102029 + "kzalloc_node",
102030 +};
102031 +
102032 +static struct plugin_info kallocstat_plugin_info = {
102033 + .version = "201302112000",
102034 +};
102035 +
102036 +static unsigned int execute_kallocstat(void);
102037 +
102038 +static struct gimple_opt_pass kallocstat_pass = {
102039 + .pass = {
102040 + .type = GIMPLE_PASS,
102041 + .name = "kallocstat",
102042 +#if BUILDING_GCC_VERSION >= 4008
102043 + .optinfo_flags = OPTGROUP_NONE,
102044 +#endif
102045 + .gate = NULL,
102046 + .execute = execute_kallocstat,
102047 + .sub = NULL,
102048 + .next = NULL,
102049 + .static_pass_number = 0,
102050 + .tv_id = TV_NONE,
102051 + .properties_required = 0,
102052 + .properties_provided = 0,
102053 + .properties_destroyed = 0,
102054 + .todo_flags_start = 0,
102055 + .todo_flags_finish = 0
102056 + }
102057 +};
102058 +
102059 +static bool is_kalloc(const char *fnname)
102060 +{
102061 + size_t i;
102062 +
102063 + for (i = 0; i < ARRAY_SIZE(kalloc_functions); i++)
102064 + if (!strcmp(fnname, kalloc_functions[i]))
102065 + return true;
102066 + return false;
102067 +}
102068 +
102069 +static unsigned int execute_kallocstat(void)
102070 +{
102071 + basic_block bb;
102072 +
102073 + // 1. loop through BBs and GIMPLE statements
102074 + FOR_EACH_BB(bb) {
102075 + gimple_stmt_iterator gsi;
102076 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
102077 + // gimple match:
102078 + tree fndecl, size;
102079 + gimple call_stmt;
102080 + const char *fnname;
102081 +
102082 + // is it a call
102083 + call_stmt = gsi_stmt(gsi);
102084 + if (!is_gimple_call(call_stmt))
102085 + continue;
102086 + fndecl = gimple_call_fndecl(call_stmt);
102087 + if (fndecl == NULL_TREE)
102088 + continue;
102089 + if (TREE_CODE(fndecl) != FUNCTION_DECL)
102090 + continue;
102091 +
102092 + // is it a call to k*alloc
102093 + fnname = IDENTIFIER_POINTER(DECL_NAME(fndecl));
102094 + if (!is_kalloc(fnname))
102095 + continue;
102096 +
102097 + // is the size arg the result of a simple const assignment
102098 + size = gimple_call_arg(call_stmt, 0);
102099 + while (true) {
102100 + gimple def_stmt;
102101 + expanded_location xloc;
102102 + size_t size_val;
102103 +
102104 + if (TREE_CODE(size) != SSA_NAME)
102105 + break;
102106 + def_stmt = SSA_NAME_DEF_STMT(size);
102107 + if (!def_stmt || !is_gimple_assign(def_stmt))
102108 + break;
102109 + if (gimple_num_ops(def_stmt) != 2)
102110 + break;
102111 + size = gimple_assign_rhs1(def_stmt);
102112 + if (!TREE_CONSTANT(size))
102113 + continue;
102114 + xloc = expand_location(gimple_location(def_stmt));
102115 + if (!xloc.file)
102116 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
102117 + size_val = TREE_INT_CST_LOW(size);
102118 + fprintf(stderr, "kallocsize: %8zu %8zx %s %s:%u\n", size_val, size_val, fnname, xloc.file, xloc.line);
102119 + break;
102120 + }
102121 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
102122 +//debug_tree(gimple_call_fn(call_stmt));
102123 +//print_node(stderr, "pax", fndecl, 4);
102124 + }
102125 + }
102126 +
102127 + return 0;
102128 +}
102129 +
102130 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
102131 +{
102132 + const char * const plugin_name = plugin_info->base_name;
102133 + struct register_pass_info kallocstat_pass_info = {
102134 + .pass = &kallocstat_pass.pass,
102135 + .reference_pass_name = "ssa",
102136 + .ref_pass_instance_number = 1,
102137 + .pos_op = PASS_POS_INSERT_AFTER
102138 + };
102139 +
102140 + if (!plugin_default_version_check(version, &gcc_version)) {
102141 + error(G_("incompatible gcc/plugin versions"));
102142 + return 1;
102143 + }
102144 +
102145 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kallocstat_plugin_info);
102146 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kallocstat_pass_info);
102147 +
102148 + return 0;
102149 +}
102150 diff --git a/tools/gcc/kernexec_plugin.c b/tools/gcc/kernexec_plugin.c
102151 new file mode 100644
102152 index 0000000..a25306b
102153 --- /dev/null
102154 +++ b/tools/gcc/kernexec_plugin.c
102155 @@ -0,0 +1,474 @@
102156 +/*
102157 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
102158 + * Licensed under the GPL v2
102159 + *
102160 + * Note: the choice of the license means that the compilation process is
102161 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
102162 + * but for the kernel it doesn't matter since it doesn't link against
102163 + * any of the gcc libraries
102164 + *
102165 + * gcc plugin to make KERNEXEC/amd64 almost as good as it is on i386
102166 + *
102167 + * TODO:
102168 + *
102169 + * BUGS:
102170 + * - none known
102171 + */
102172 +#include "gcc-plugin.h"
102173 +#include "config.h"
102174 +#include "system.h"
102175 +#include "coretypes.h"
102176 +#include "tree.h"
102177 +#include "tree-pass.h"
102178 +#include "flags.h"
102179 +#include "intl.h"
102180 +#include "toplev.h"
102181 +#include "plugin.h"
102182 +//#include "expr.h" where are you...
102183 +#include "diagnostic.h"
102184 +#include "plugin-version.h"
102185 +#include "tm.h"
102186 +#include "function.h"
102187 +#include "basic-block.h"
102188 +#include "gimple.h"
102189 +#include "rtl.h"
102190 +#include "emit-rtl.h"
102191 +#include "tree-flow.h"
102192 +
102193 +extern void print_gimple_stmt(FILE *, gimple, int, int);
102194 +extern rtx emit_move_insn(rtx x, rtx y);
102195 +
102196 +#if BUILDING_GCC_VERSION <= 4006
102197 +#define ANY_RETURN_P(rtx) (GET_CODE(rtx) == RETURN)
102198 +#endif
102199 +
102200 +#if BUILDING_GCC_VERSION >= 4008
102201 +#define TODO_dump_func 0
102202 +#endif
102203 +
102204 +int plugin_is_GPL_compatible;
102205 +
102206 +static struct plugin_info kernexec_plugin_info = {
102207 + .version = "201308230150",
102208 + .help = "method=[bts|or]\tinstrumentation method\n"
102209 +};
102210 +
102211 +static unsigned int execute_kernexec_reload(void);
102212 +static unsigned int execute_kernexec_fptr(void);
102213 +static unsigned int execute_kernexec_retaddr(void);
102214 +static bool kernexec_cmodel_check(void);
102215 +
102216 +static void (*kernexec_instrument_fptr)(gimple_stmt_iterator *);
102217 +static void (*kernexec_instrument_retaddr)(rtx);
102218 +
102219 +static struct gimple_opt_pass kernexec_reload_pass = {
102220 + .pass = {
102221 + .type = GIMPLE_PASS,
102222 + .name = "kernexec_reload",
102223 +#if BUILDING_GCC_VERSION >= 4008
102224 + .optinfo_flags = OPTGROUP_NONE,
102225 +#endif
102226 + .gate = kernexec_cmodel_check,
102227 + .execute = execute_kernexec_reload,
102228 + .sub = NULL,
102229 + .next = NULL,
102230 + .static_pass_number = 0,
102231 + .tv_id = TV_NONE,
102232 + .properties_required = 0,
102233 + .properties_provided = 0,
102234 + .properties_destroyed = 0,
102235 + .todo_flags_start = 0,
102236 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
102237 + }
102238 +};
102239 +
102240 +static struct gimple_opt_pass kernexec_fptr_pass = {
102241 + .pass = {
102242 + .type = GIMPLE_PASS,
102243 + .name = "kernexec_fptr",
102244 +#if BUILDING_GCC_VERSION >= 4008
102245 + .optinfo_flags = OPTGROUP_NONE,
102246 +#endif
102247 + .gate = kernexec_cmodel_check,
102248 + .execute = execute_kernexec_fptr,
102249 + .sub = NULL,
102250 + .next = NULL,
102251 + .static_pass_number = 0,
102252 + .tv_id = TV_NONE,
102253 + .properties_required = 0,
102254 + .properties_provided = 0,
102255 + .properties_destroyed = 0,
102256 + .todo_flags_start = 0,
102257 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
102258 + }
102259 +};
102260 +
102261 +static struct rtl_opt_pass kernexec_retaddr_pass = {
102262 + .pass = {
102263 + .type = RTL_PASS,
102264 + .name = "kernexec_retaddr",
102265 +#if BUILDING_GCC_VERSION >= 4008
102266 + .optinfo_flags = OPTGROUP_NONE,
102267 +#endif
102268 + .gate = kernexec_cmodel_check,
102269 + .execute = execute_kernexec_retaddr,
102270 + .sub = NULL,
102271 + .next = NULL,
102272 + .static_pass_number = 0,
102273 + .tv_id = TV_NONE,
102274 + .properties_required = 0,
102275 + .properties_provided = 0,
102276 + .properties_destroyed = 0,
102277 + .todo_flags_start = 0,
102278 + .todo_flags_finish = TODO_dump_func | TODO_ggc_collect
102279 + }
102280 +};
102281 +
102282 +static bool kernexec_cmodel_check(void)
102283 +{
102284 + tree section;
102285 +
102286 + if (ix86_cmodel != CM_KERNEL)
102287 + return false;
102288 +
102289 + section = lookup_attribute("section", DECL_ATTRIBUTES(current_function_decl));
102290 + if (!section || !TREE_VALUE(section))
102291 + return true;
102292 +
102293 + section = TREE_VALUE(TREE_VALUE(section));
102294 + if (strncmp(TREE_STRING_POINTER(section), ".vsyscall_", 10))
102295 + return true;
102296 +
102297 + return false;
102298 +}
102299 +
102300 +/*
102301 + * add special KERNEXEC instrumentation: reload %r12 after it has been clobbered
102302 + */
102303 +static void kernexec_reload_fptr_mask(gimple_stmt_iterator *gsi)
102304 +{
102305 + gimple asm_movabs_stmt;
102306 +
102307 + // build asm volatile("movabs $0x8000000000000000, %%r12\n\t" : : : );
102308 + asm_movabs_stmt = gimple_build_asm_vec("movabs $0x8000000000000000, %%r12\n\t", NULL, NULL, NULL, NULL);
102309 + gimple_asm_set_volatile(asm_movabs_stmt, true);
102310 + gsi_insert_after(gsi, asm_movabs_stmt, GSI_CONTINUE_LINKING);
102311 + update_stmt(asm_movabs_stmt);
102312 +}
102313 +
102314 +/*
102315 + * find all asm() stmts that clobber r12 and add a reload of r12
102316 + */
102317 +static unsigned int execute_kernexec_reload(void)
102318 +{
102319 + basic_block bb;
102320 +
102321 + // 1. loop through BBs and GIMPLE statements
102322 + FOR_EACH_BB(bb) {
102323 + gimple_stmt_iterator gsi;
102324 +
102325 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
102326 + // gimple match: __asm__ ("" : : : "r12");
102327 + gimple asm_stmt;
102328 + size_t nclobbers;
102329 +
102330 + // is it an asm ...
102331 + asm_stmt = gsi_stmt(gsi);
102332 + if (gimple_code(asm_stmt) != GIMPLE_ASM)
102333 + continue;
102334 +
102335 + // ... clobbering r12
102336 + nclobbers = gimple_asm_nclobbers(asm_stmt);
102337 + while (nclobbers--) {
102338 + tree op = gimple_asm_clobber_op(asm_stmt, nclobbers);
102339 + if (strcmp(TREE_STRING_POINTER(TREE_VALUE(op)), "r12"))
102340 + continue;
102341 + kernexec_reload_fptr_mask(&gsi);
102342 +//print_gimple_stmt(stderr, asm_stmt, 0, TDF_LINENO);
102343 + break;
102344 + }
102345 + }
102346 + }
102347 +
102348 + return 0;
102349 +}
102350 +
102351 +/*
102352 + * add special KERNEXEC instrumentation: force MSB of fptr to 1, which will produce
102353 + * a non-canonical address from a userland ptr and will just trigger a GPF on dereference
102354 + */
102355 +static void kernexec_instrument_fptr_bts(gimple_stmt_iterator *gsi)
102356 +{
102357 + gimple assign_intptr, assign_new_fptr, call_stmt;
102358 + tree intptr, orptr, old_fptr, new_fptr, kernexec_mask;
102359 +
102360 + call_stmt = gsi_stmt(*gsi);
102361 + old_fptr = gimple_call_fn(call_stmt);
102362 +
102363 + // create temporary unsigned long variable used for bitops and cast fptr to it
102364 + intptr = create_tmp_var(long_unsigned_type_node, "kernexec_bts");
102365 +#if BUILDING_GCC_VERSION <= 4007
102366 + add_referenced_var(intptr);
102367 +#endif
102368 + intptr = make_ssa_name(intptr, NULL);
102369 + assign_intptr = gimple_build_assign(intptr, fold_convert(long_unsigned_type_node, old_fptr));
102370 + SSA_NAME_DEF_STMT(intptr) = assign_intptr;
102371 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
102372 + update_stmt(assign_intptr);
102373 +
102374 + // apply logical or to temporary unsigned long and bitmask
102375 + kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0x8000000000000000LL);
102376 +// kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0xffffffff80000000LL);
102377 + orptr = fold_build2(BIT_IOR_EXPR, long_long_unsigned_type_node, intptr, kernexec_mask);
102378 + intptr = make_ssa_name(SSA_NAME_VAR(intptr), NULL);
102379 + assign_intptr = gimple_build_assign(intptr, orptr);
102380 + SSA_NAME_DEF_STMT(intptr) = assign_intptr;
102381 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
102382 + update_stmt(assign_intptr);
102383 +
102384 + // cast temporary unsigned long back to a temporary fptr variable
102385 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_fptr");
102386 +#if BUILDING_GCC_VERSION <= 4007
102387 + add_referenced_var(new_fptr);
102388 +#endif
102389 + new_fptr = make_ssa_name(new_fptr, NULL);
102390 + assign_new_fptr = gimple_build_assign(new_fptr, fold_convert(TREE_TYPE(old_fptr), intptr));
102391 + SSA_NAME_DEF_STMT(new_fptr) = assign_new_fptr;
102392 + gsi_insert_before(gsi, assign_new_fptr, GSI_SAME_STMT);
102393 + update_stmt(assign_new_fptr);
102394 +
102395 + // replace call stmt fn with the new fptr
102396 + gimple_call_set_fn(call_stmt, new_fptr);
102397 + update_stmt(call_stmt);
102398 +}
102399 +
102400 +static void kernexec_instrument_fptr_or(gimple_stmt_iterator *gsi)
102401 +{
102402 + gimple asm_or_stmt, call_stmt;
102403 + tree old_fptr, new_fptr, input, output;
102404 +#if BUILDING_GCC_VERSION <= 4007
102405 + VEC(tree, gc) *inputs = NULL;
102406 + VEC(tree, gc) *outputs = NULL;
102407 +#else
102408 + vec<tree, va_gc> *inputs = NULL;
102409 + vec<tree, va_gc> *outputs = NULL;
102410 +#endif
102411 +
102412 + call_stmt = gsi_stmt(*gsi);
102413 + old_fptr = gimple_call_fn(call_stmt);
102414 +
102415 + // create temporary fptr variable
102416 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_or");
102417 +#if BUILDING_GCC_VERSION <= 4007
102418 + add_referenced_var(new_fptr);
102419 +#endif
102420 + new_fptr = make_ssa_name(new_fptr, NULL);
102421 +
102422 + // build asm volatile("orq %%r12, %0\n\t" : "=r"(new_fptr) : "0"(old_fptr));
102423 + input = build_tree_list(NULL_TREE, build_string(1, "0"));
102424 + input = chainon(NULL_TREE, build_tree_list(input, old_fptr));
102425 + output = build_tree_list(NULL_TREE, build_string(2, "=r"));
102426 + output = chainon(NULL_TREE, build_tree_list(output, new_fptr));
102427 +#if BUILDING_GCC_VERSION <= 4007
102428 + VEC_safe_push(tree, gc, inputs, input);
102429 + VEC_safe_push(tree, gc, outputs, output);
102430 +#else
102431 + vec_safe_push(inputs, input);
102432 + vec_safe_push(outputs, output);
102433 +#endif
102434 + asm_or_stmt = gimple_build_asm_vec("orq %%r12, %0\n\t", inputs, outputs, NULL, NULL);
102435 + SSA_NAME_DEF_STMT(new_fptr) = asm_or_stmt;
102436 + gimple_asm_set_volatile(asm_or_stmt, true);
102437 + gsi_insert_before(gsi, asm_or_stmt, GSI_SAME_STMT);
102438 + update_stmt(asm_or_stmt);
102439 +
102440 + // replace call stmt fn with the new fptr
102441 + gimple_call_set_fn(call_stmt, new_fptr);
102442 + update_stmt(call_stmt);
102443 +}
102444 +
102445 +/*
102446 + * find all C level function pointer dereferences and forcibly set the highest bit of the pointer
102447 + */
102448 +static unsigned int execute_kernexec_fptr(void)
102449 +{
102450 + basic_block bb;
102451 +
102452 + // 1. loop through BBs and GIMPLE statements
102453 + FOR_EACH_BB(bb) {
102454 + gimple_stmt_iterator gsi;
102455 +
102456 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
102457 + // gimple match: h_1 = get_fptr (); D.2709_3 = h_1 (x_2(D));
102458 + tree fn;
102459 + gimple call_stmt;
102460 +
102461 + // is it a call ...
102462 + call_stmt = gsi_stmt(gsi);
102463 + if (!is_gimple_call(call_stmt))
102464 + continue;
102465 + fn = gimple_call_fn(call_stmt);
102466 + if (TREE_CODE(fn) == ADDR_EXPR)
102467 + continue;
102468 + if (TREE_CODE(fn) != SSA_NAME)
102469 + gcc_unreachable();
102470 +
102471 + // ... through a function pointer
102472 + if (SSA_NAME_VAR(fn) != NULL_TREE) {
102473 + fn = SSA_NAME_VAR(fn);
102474 + if (TREE_CODE(fn) != VAR_DECL && TREE_CODE(fn) != PARM_DECL) {
102475 + debug_tree(fn);
102476 + gcc_unreachable();
102477 + }
102478 + }
102479 + fn = TREE_TYPE(fn);
102480 + if (TREE_CODE(fn) != POINTER_TYPE)
102481 + continue;
102482 + fn = TREE_TYPE(fn);
102483 + if (TREE_CODE(fn) != FUNCTION_TYPE)
102484 + continue;
102485 +
102486 + kernexec_instrument_fptr(&gsi);
102487 +
102488 +//debug_tree(gimple_call_fn(call_stmt));
102489 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
102490 + }
102491 + }
102492 +
102493 + return 0;
102494 +}
102495 +
102496 +// add special KERNEXEC instrumentation: btsq $63,(%rsp) just before retn
102497 +static void kernexec_instrument_retaddr_bts(rtx insn)
102498 +{
102499 + rtx btsq;
102500 + rtvec argvec, constraintvec, labelvec;
102501 + int line;
102502 +
102503 + // create asm volatile("btsq $63,(%%rsp)":::)
102504 + argvec = rtvec_alloc(0);
102505 + constraintvec = rtvec_alloc(0);
102506 + labelvec = rtvec_alloc(0);
102507 + line = expand_location(RTL_LOCATION(insn)).line;
102508 + btsq = gen_rtx_ASM_OPERANDS(VOIDmode, "btsq $63,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
102509 + MEM_VOLATILE_P(btsq) = 1;
102510 +// RTX_FRAME_RELATED_P(btsq) = 1; // not for ASM_OPERANDS
102511 + emit_insn_before(btsq, insn);
102512 +}
102513 +
102514 +// add special KERNEXEC instrumentation: orq %r12,(%rsp) just before retn
102515 +static void kernexec_instrument_retaddr_or(rtx insn)
102516 +{
102517 + rtx orq;
102518 + rtvec argvec, constraintvec, labelvec;
102519 + int line;
102520 +
102521 + // create asm volatile("orq %%r12,(%%rsp)":::)
102522 + argvec = rtvec_alloc(0);
102523 + constraintvec = rtvec_alloc(0);
102524 + labelvec = rtvec_alloc(0);
102525 + line = expand_location(RTL_LOCATION(insn)).line;
102526 + orq = gen_rtx_ASM_OPERANDS(VOIDmode, "orq %%r12,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
102527 + MEM_VOLATILE_P(orq) = 1;
102528 +// RTX_FRAME_RELATED_P(orq) = 1; // not for ASM_OPERANDS
102529 + emit_insn_before(orq, insn);
102530 +}
102531 +
102532 +/*
102533 + * find all asm level function returns and forcibly set the highest bit of the return address
102534 + */
102535 +static unsigned int execute_kernexec_retaddr(void)
102536 +{
102537 + rtx insn;
102538 +
102539 +// if (stack_realign_drap)
102540 +// inform(DECL_SOURCE_LOCATION(current_function_decl), "drap detected in %s\n", IDENTIFIER_POINTER(DECL_NAME(current_function_decl)));
102541 +
102542 + // 1. find function returns
102543 + for (insn = get_insns(); insn; insn = NEXT_INSN(insn)) {
102544 + // rtl match: (jump_insn 41 40 42 2 (return) fptr.c:42 634 {return_internal} (nil))
102545 + // (jump_insn 12 9 11 2 (parallel [ (return) (unspec [ (0) ] UNSPEC_REP) ]) fptr.c:46 635 {return_internal_long} (nil))
102546 + // (jump_insn 97 96 98 6 (simple_return) fptr.c:50 -1 (nil) -> simple_return)
102547 + rtx body;
102548 +
102549 + // is it a retn
102550 + if (!JUMP_P(insn))
102551 + continue;
102552 + body = PATTERN(insn);
102553 + if (GET_CODE(body) == PARALLEL)
102554 + body = XVECEXP(body, 0, 0);
102555 + if (!ANY_RETURN_P(body))
102556 + continue;
102557 + kernexec_instrument_retaddr(insn);
102558 + }
102559 +
102560 +// print_simple_rtl(stderr, get_insns());
102561 +// print_rtl(stderr, get_insns());
102562 +
102563 + return 0;
102564 +}
102565 +
102566 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
102567 +{
102568 + const char * const plugin_name = plugin_info->base_name;
102569 + const int argc = plugin_info->argc;
102570 + const struct plugin_argument * const argv = plugin_info->argv;
102571 + int i;
102572 + struct register_pass_info kernexec_reload_pass_info = {
102573 + .pass = &kernexec_reload_pass.pass,
102574 + .reference_pass_name = "ssa",
102575 + .ref_pass_instance_number = 1,
102576 + .pos_op = PASS_POS_INSERT_AFTER
102577 + };
102578 + struct register_pass_info kernexec_fptr_pass_info = {
102579 + .pass = &kernexec_fptr_pass.pass,
102580 + .reference_pass_name = "ssa",
102581 + .ref_pass_instance_number = 1,
102582 + .pos_op = PASS_POS_INSERT_AFTER
102583 + };
102584 + struct register_pass_info kernexec_retaddr_pass_info = {
102585 + .pass = &kernexec_retaddr_pass.pass,
102586 + .reference_pass_name = "pro_and_epilogue",
102587 + .ref_pass_instance_number = 1,
102588 + .pos_op = PASS_POS_INSERT_AFTER
102589 + };
102590 +
102591 + if (!plugin_default_version_check(version, &gcc_version)) {
102592 + error(G_("incompatible gcc/plugin versions"));
102593 + return 1;
102594 + }
102595 +
102596 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kernexec_plugin_info);
102597 +
102598 + if (TARGET_64BIT == 0)
102599 + return 0;
102600 +
102601 + for (i = 0; i < argc; ++i) {
102602 + if (!strcmp(argv[i].key, "method")) {
102603 + if (!argv[i].value) {
102604 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
102605 + continue;
102606 + }
102607 + if (!strcmp(argv[i].value, "bts")) {
102608 + kernexec_instrument_fptr = kernexec_instrument_fptr_bts;
102609 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_bts;
102610 + } else if (!strcmp(argv[i].value, "or")) {
102611 + kernexec_instrument_fptr = kernexec_instrument_fptr_or;
102612 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_or;
102613 + fix_register("r12", 1, 1);
102614 + } else
102615 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
102616 + continue;
102617 + }
102618 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
102619 + }
102620 + if (!kernexec_instrument_fptr || !kernexec_instrument_retaddr)
102621 + error(G_("no instrumentation method was selected via '-fplugin-arg-%s-method'"), plugin_name);
102622 +
102623 + if (kernexec_instrument_fptr == kernexec_instrument_fptr_or)
102624 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_reload_pass_info);
102625 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_fptr_pass_info);
102626 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_retaddr_pass_info);
102627 +
102628 + return 0;
102629 +}
102630 diff --git a/tools/gcc/latent_entropy_plugin.c b/tools/gcc/latent_entropy_plugin.c
102631 new file mode 100644
102632 index 0000000..679b9ef
102633 --- /dev/null
102634 +++ b/tools/gcc/latent_entropy_plugin.c
102635 @@ -0,0 +1,335 @@
102636 +/*
102637 + * Copyright 2012-2013 by the PaX Team <pageexec@freemail.hu>
102638 + * Licensed under the GPL v2
102639 + *
102640 + * Note: the choice of the license means that the compilation process is
102641 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
102642 + * but for the kernel it doesn't matter since it doesn't link against
102643 + * any of the gcc libraries
102644 + *
102645 + * gcc plugin to help generate a little bit of entropy from program state,
102646 + * used during boot in the kernel
102647 + *
102648 + * TODO:
102649 + * - add ipa pass to identify not explicitly marked candidate functions
102650 + * - mix in more program state (function arguments/return values, loop variables, etc)
102651 + * - more instrumentation control via attribute parameters
102652 + *
102653 + * BUGS:
102654 + * - LTO needs -flto-partition=none for now
102655 + */
102656 +#include "gcc-plugin.h"
102657 +#include "config.h"
102658 +#include "system.h"
102659 +#include "coretypes.h"
102660 +#include "tree.h"
102661 +#include "tree-pass.h"
102662 +#include "flags.h"
102663 +#include "intl.h"
102664 +#include "toplev.h"
102665 +#include "plugin.h"
102666 +//#include "expr.h" where are you...
102667 +#include "diagnostic.h"
102668 +#include "plugin-version.h"
102669 +#include "tm.h"
102670 +#include "function.h"
102671 +#include "basic-block.h"
102672 +#include "gimple.h"
102673 +#include "rtl.h"
102674 +#include "emit-rtl.h"
102675 +#include "tree-flow.h"
102676 +#include "langhooks.h"
102677 +
102678 +#if BUILDING_GCC_VERSION >= 4008
102679 +#define TODO_dump_func 0
102680 +#endif
102681 +
102682 +int plugin_is_GPL_compatible;
102683 +
102684 +static tree latent_entropy_decl;
102685 +
102686 +static struct plugin_info latent_entropy_plugin_info = {
102687 + .version = "201308230230",
102688 + .help = NULL
102689 +};
102690 +
102691 +static unsigned int execute_latent_entropy(void);
102692 +static bool gate_latent_entropy(void);
102693 +
102694 +static struct gimple_opt_pass latent_entropy_pass = {
102695 + .pass = {
102696 + .type = GIMPLE_PASS,
102697 + .name = "latent_entropy",
102698 +#if BUILDING_GCC_VERSION >= 4008
102699 + .optinfo_flags = OPTGROUP_NONE,
102700 +#endif
102701 + .gate = gate_latent_entropy,
102702 + .execute = execute_latent_entropy,
102703 + .sub = NULL,
102704 + .next = NULL,
102705 + .static_pass_number = 0,
102706 + .tv_id = TV_NONE,
102707 + .properties_required = PROP_gimple_leh | PROP_cfg,
102708 + .properties_provided = 0,
102709 + .properties_destroyed = 0,
102710 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
102711 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
102712 + }
102713 +};
102714 +
102715 +static unsigned HOST_WIDE_INT seed;
102716 +static unsigned HOST_WIDE_INT get_random_const(void)
102717 +{
102718 + seed = (seed >> 1U) ^ (-(seed & 1ULL) & 0xD800000000000000ULL);
102719 + return seed;
102720 +}
102721 +
102722 +static tree handle_latent_entropy_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
102723 +{
102724 + switch (TREE_CODE(*node)) {
102725 + default:
102726 + *no_add_attrs = true;
102727 + error("%qE attribute only applies to functions and variables", name);
102728 + break;
102729 +
102730 + case VAR_DECL:
102731 + if (DECL_INITIAL(*node)) {
102732 + *no_add_attrs = true;
102733 + error("variable %qD with %qE attribute must not be initialized", *node, name);
102734 + break;
102735 + }
102736 + DECL_INITIAL(*node) = build_int_cstu(long_long_unsigned_type_node, get_random_const());
102737 + break;
102738 +
102739 + case FUNCTION_DECL:
102740 + break;
102741 + }
102742 +
102743 + return NULL_TREE;
102744 +}
102745 +
102746 +static struct attribute_spec latent_entropy_attr = {
102747 + .name = "latent_entropy",
102748 + .min_length = 0,
102749 + .max_length = 0,
102750 + .decl_required = true,
102751 + .type_required = false,
102752 + .function_type_required = false,
102753 + .handler = handle_latent_entropy_attribute,
102754 +#if BUILDING_GCC_VERSION >= 4007
102755 + .affects_type_identity = false
102756 +#endif
102757 +};
102758 +
102759 +static void register_attributes(void *event_data, void *data)
102760 +{
102761 + register_attribute(&latent_entropy_attr);
102762 +}
102763 +
102764 +static bool gate_latent_entropy(void)
102765 +{
102766 + tree latent_entropy_attr;
102767 +
102768 + latent_entropy_attr = lookup_attribute("latent_entropy", DECL_ATTRIBUTES(current_function_decl));
102769 + return latent_entropy_attr != NULL_TREE;
102770 +}
102771 +
102772 +static enum tree_code get_op(tree *rhs)
102773 +{
102774 + static enum tree_code op;
102775 + unsigned HOST_WIDE_INT random_const;
102776 +
102777 + random_const = get_random_const();
102778 +
102779 + switch (op) {
102780 + case BIT_XOR_EXPR:
102781 + op = PLUS_EXPR;
102782 + break;
102783 +
102784 + case PLUS_EXPR:
102785 + if (rhs) {
102786 + op = LROTATE_EXPR;
102787 + random_const &= HOST_BITS_PER_WIDE_INT - 1;
102788 + break;
102789 + }
102790 +
102791 + case LROTATE_EXPR:
102792 + default:
102793 + op = BIT_XOR_EXPR;
102794 + break;
102795 + }
102796 + if (rhs)
102797 + *rhs = build_int_cstu(unsigned_intDI_type_node, random_const);
102798 + return op;
102799 +}
102800 +
102801 +static void perturb_local_entropy(basic_block bb, tree local_entropy)
102802 +{
102803 + gimple_stmt_iterator gsi;
102804 + gimple assign;
102805 + tree addxorrol, rhs;
102806 + enum tree_code op;
102807 +
102808 + op = get_op(&rhs);
102809 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, op, unsigned_intDI_type_node, local_entropy, rhs);
102810 + assign = gimple_build_assign(local_entropy, addxorrol);
102811 + gsi = gsi_after_labels(bb);
102812 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
102813 + update_stmt(assign);
102814 +//debug_bb(bb);
102815 +}
102816 +
102817 +static void perturb_latent_entropy(basic_block bb, tree rhs)
102818 +{
102819 + gimple_stmt_iterator gsi;
102820 + gimple assign;
102821 + tree addxorrol, temp;
102822 +
102823 + // 1. create temporary copy of latent_entropy
102824 + temp = create_tmp_var(unsigned_intDI_type_node, "temp_latent_entropy");
102825 +#if BUILDING_GCC_VERSION <= 4007
102826 + add_referenced_var(temp);
102827 +#endif
102828 +
102829 + // 2. read...
102830 + temp = make_ssa_name(temp, NULL);
102831 + assign = gimple_build_assign(temp, latent_entropy_decl);
102832 + SSA_NAME_DEF_STMT(temp) = assign;
102833 +#if BUILDING_GCC_VERSION <= 4007
102834 + add_referenced_var(latent_entropy_decl);
102835 +#endif
102836 + gsi = gsi_after_labels(bb);
102837 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
102838 + update_stmt(assign);
102839 +
102840 + // 3. ...modify...
102841 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, get_op(NULL), unsigned_intDI_type_node, temp, rhs);
102842 + temp = make_ssa_name(SSA_NAME_VAR(temp), NULL);
102843 + assign = gimple_build_assign(temp, addxorrol);
102844 + SSA_NAME_DEF_STMT(temp) = assign;
102845 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
102846 + update_stmt(assign);
102847 +
102848 + // 4. ...write latent_entropy
102849 + assign = gimple_build_assign(latent_entropy_decl, temp);
102850 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
102851 + update_stmt(assign);
102852 +}
102853 +
102854 +static unsigned int execute_latent_entropy(void)
102855 +{
102856 + basic_block bb;
102857 + gimple assign;
102858 + gimple_stmt_iterator gsi;
102859 + tree local_entropy;
102860 +
102861 + if (!latent_entropy_decl) {
102862 + struct varpool_node *node;
102863 +
102864 +#if BUILDING_GCC_VERSION <= 4007
102865 + for (node = varpool_nodes; node; node = node->next) {
102866 + tree var = node->decl;
102867 +#else
102868 + FOR_EACH_VARIABLE(node) {
102869 + tree var = node->symbol.decl;
102870 +#endif
102871 + if (strcmp(IDENTIFIER_POINTER(DECL_NAME(var)), "latent_entropy"))
102872 + continue;
102873 + latent_entropy_decl = var;
102874 +// debug_tree(var);
102875 + break;
102876 + }
102877 + if (!latent_entropy_decl) {
102878 +// debug_tree(current_function_decl);
102879 + return 0;
102880 + }
102881 + }
102882 +
102883 +//fprintf(stderr, "latent_entropy: %s\n", IDENTIFIER_POINTER(DECL_NAME(current_function_decl)));
102884 +
102885 + // 1. create local entropy variable
102886 + local_entropy = create_tmp_var(unsigned_intDI_type_node, "local_entropy");
102887 +#if BUILDING_GCC_VERSION <= 4007
102888 + add_referenced_var(local_entropy);
102889 + mark_sym_for_renaming(local_entropy);
102890 +#endif
102891 +
102892 + // 2. initialize local entropy variable
102893 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
102894 + if (dom_info_available_p(CDI_DOMINATORS))
102895 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
102896 + gsi = gsi_start_bb(bb);
102897 +
102898 + assign = gimple_build_assign(local_entropy, build_int_cstu(unsigned_intDI_type_node, get_random_const()));
102899 +// gimple_set_location(assign, loc);
102900 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
102901 + update_stmt(assign);
102902 +//debug_bb(bb);
102903 + bb = bb->next_bb;
102904 +
102905 + // 3. instrument each BB with an operation on the local entropy variable
102906 + while (bb != EXIT_BLOCK_PTR) {
102907 + perturb_local_entropy(bb, local_entropy);
102908 +//debug_bb(bb);
102909 + bb = bb->next_bb;
102910 + };
102911 +
102912 + // 4. mix local entropy into the global entropy variable
102913 + perturb_latent_entropy(EXIT_BLOCK_PTR->prev_bb, local_entropy);
102914 +//debug_bb(EXIT_BLOCK_PTR->prev_bb);
102915 + return 0;
102916 +}
102917 +
102918 +static void start_unit_callback(void *gcc_data, void *user_data)
102919 +{
102920 + tree latent_entropy_type;
102921 +
102922 +#if BUILDING_GCC_VERSION >= 4007
102923 + seed = get_random_seed(false);
102924 +#else
102925 + sscanf(get_random_seed(false), "%" HOST_WIDE_INT_PRINT "x", &seed);
102926 + seed *= seed;
102927 +#endif
102928 +
102929 + if (in_lto_p)
102930 + return;
102931 +
102932 + // extern volatile u64 latent_entropy
102933 + gcc_assert(TYPE_PRECISION(long_long_unsigned_type_node) == 64);
102934 + latent_entropy_type = build_qualified_type(long_long_unsigned_type_node, TYPE_QUALS(long_long_unsigned_type_node) | TYPE_QUAL_VOLATILE);
102935 + latent_entropy_decl = build_decl(UNKNOWN_LOCATION, VAR_DECL, get_identifier("latent_entropy"), latent_entropy_type);
102936 +
102937 + TREE_STATIC(latent_entropy_decl) = 1;
102938 + TREE_PUBLIC(latent_entropy_decl) = 1;
102939 + TREE_USED(latent_entropy_decl) = 1;
102940 + TREE_THIS_VOLATILE(latent_entropy_decl) = 1;
102941 + DECL_EXTERNAL(latent_entropy_decl) = 1;
102942 + DECL_ARTIFICIAL(latent_entropy_decl) = 1;
102943 + lang_hooks.decls.pushdecl(latent_entropy_decl);
102944 +// DECL_ASSEMBLER_NAME(latent_entropy_decl);
102945 +// varpool_finalize_decl(latent_entropy_decl);
102946 +// varpool_mark_needed_node(latent_entropy_decl);
102947 +}
102948 +
102949 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
102950 +{
102951 + const char * const plugin_name = plugin_info->base_name;
102952 + struct register_pass_info latent_entropy_pass_info = {
102953 + .pass = &latent_entropy_pass.pass,
102954 + .reference_pass_name = "optimized",
102955 + .ref_pass_instance_number = 1,
102956 + .pos_op = PASS_POS_INSERT_BEFORE
102957 + };
102958 +
102959 + if (!plugin_default_version_check(version, &gcc_version)) {
102960 + error(G_("incompatible gcc/plugin versions"));
102961 + return 1;
102962 + }
102963 +
102964 + register_callback(plugin_name, PLUGIN_INFO, NULL, &latent_entropy_plugin_info);
102965 + register_callback ("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
102966 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &latent_entropy_pass_info);
102967 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
102968 +
102969 + return 0;
102970 +}
102971 diff --git a/tools/gcc/size_overflow_hash.data b/tools/gcc/size_overflow_hash.data
102972 new file mode 100644
102973 index 0000000..a0c9844
102974 --- /dev/null
102975 +++ b/tools/gcc/size_overflow_hash.data
102976 @@ -0,0 +1,7723 @@
102977 +intel_fake_agp_alloc_by_type_1 intel_fake_agp_alloc_by_type 1 1 NULL
102978 +ocfs2_get_refcount_tree_3 ocfs2_get_refcount_tree 0 3 NULL
102979 +batadv_orig_node_del_if_4 batadv_orig_node_del_if 2 4 NULL
102980 +storvsc_connect_to_vsp_22 storvsc_connect_to_vsp 2 22 NULL
102981 +compat_sock_setsockopt_23 compat_sock_setsockopt 5 23 NULL
102982 +carl9170_alloc_27 carl9170_alloc 1 27 NULL
102983 +sel_read_policyvers_55 sel_read_policyvers 3 55 NULL nohasharray
102984 +padzero_55 padzero 1 55 &sel_read_policyvers_55
102985 +cfg80211_disconnected_57 cfg80211_disconnected 4 57 NULL
102986 +__skb_to_sgvec_72 __skb_to_sgvec 0 72 NULL
102987 +crypto_authenc_setkey_80 crypto_authenc_setkey 3 80 NULL
102988 +snd_korg1212_copy_to_92 snd_korg1212_copy_to 6 92 NULL
102989 +load_msg_95 load_msg 2 95 NULL
102990 +device_flush_iotlb_115 device_flush_iotlb 2-3 115 NULL
102991 +ipath_verbs_send_117 ipath_verbs_send 5-3 117 NULL nohasharray
102992 +write_all_supers_117 write_all_supers 0 117 &ipath_verbs_send_117
102993 +init_q_132 init_q 4 132 NULL
102994 +ocfs2_local_alloc_slide_window_134 ocfs2_local_alloc_slide_window 0 134 NULL
102995 +memstick_alloc_host_142 memstick_alloc_host 1 142 NULL
102996 +hva_to_gfn_memslot_149 hva_to_gfn_memslot 0-1 149 NULL
102997 +ping_v6_sendmsg_152 ping_v6_sendmsg 4 152 NULL
102998 +ext4_ext_get_actual_len_153 ext4_ext_get_actual_len 0 153 NULL nohasharray
102999 +tracing_trace_options_write_153 tracing_trace_options_write 3 153 &ext4_ext_get_actual_len_153
103000 +nvme_create_queue_170 nvme_create_queue 3 170 NULL
103001 +xfs_buf_item_get_format_189 xfs_buf_item_get_format 2 189 NULL
103002 +iscsi_session_setup_196 iscsi_session_setup 4-5 196 NULL
103003 +device_add_bin_attributes_205 device_add_bin_attributes 0 205 NULL
103004 +br_port_info_size_268 br_port_info_size 0 268 NULL
103005 +generic_file_direct_write_291 generic_file_direct_write 0 291 NULL
103006 +read_file_war_stats_292 read_file_war_stats 3 292 NULL
103007 +SYSC_connect_304 SYSC_connect 3 304 NULL
103008 +syslog_print_307 syslog_print 2 307 NULL
103009 +dn_setsockopt_314 dn_setsockopt 5 314 NULL
103010 +next_node_allowed_318 next_node_allowed 1-0 318 NULL
103011 +mlx5_core_access_reg_361 mlx5_core_access_reg 5-3 361 NULL
103012 +xfs_get_blocks_364 xfs_get_blocks 2 364 NULL
103013 +get_more_blocks_367 get_more_blocks 0 367 NULL
103014 +sysfs_create_dir_398 sysfs_create_dir 0 398 NULL
103015 +hw_device_state_409 hw_device_state 0 409 NULL
103016 +aio_read_events_ring_410 aio_read_events_ring 3 410 NULL
103017 +lbs_rdmac_read_418 lbs_rdmac_read 3 418 NULL
103018 +snd_ca0106_ptr_read_467 snd_ca0106_ptr_read 0 467 NULL
103019 +sparse_index_init_482 sparse_index_init 2 482 NULL
103020 +cfs_trace_set_debug_mb_usrstr_486 cfs_trace_set_debug_mb_usrstr 2 486 NULL
103021 +nvme_trans_modesel_data_488 nvme_trans_modesel_data 4 488 NULL
103022 +iwl_dbgfs_protection_mode_write_502 iwl_dbgfs_protection_mode_write 3 502 NULL
103023 +rx_rx_defrag_end_read_505 rx_rx_defrag_end_read 3 505 NULL
103024 +_snd_pcm_hw_param_first_516 _snd_pcm_hw_param_first 0 516 NULL
103025 +ocfs2_validate_meta_ecc_bhs_527 ocfs2_validate_meta_ecc_bhs 0 527 NULL
103026 +zlib_deflate_workspacesize_537 zlib_deflate_workspacesize 0-1-2 537 NULL
103027 +iwl_dbgfs_wowlan_sram_read_540 iwl_dbgfs_wowlan_sram_read 3 540 NULL
103028 +sco_sock_setsockopt_552 sco_sock_setsockopt 5 552 NULL
103029 +lpfc_nlp_state_name_556 lpfc_nlp_state_name 2 556 NULL
103030 +snd_aw2_saa7146_get_hw_ptr_playback_558 snd_aw2_saa7146_get_hw_ptr_playback 0 558 NULL
103031 +dev_hard_header_565 dev_hard_header 0 565 NULL nohasharray
103032 +start_isoc_chain_565 start_isoc_chain 2 565 &dev_hard_header_565
103033 +ocfs2_refcounted_xattr_delete_need_584 ocfs2_refcounted_xattr_delete_need 0 584 NULL
103034 +smk_write_load_self2_591 smk_write_load_self2 3 591 NULL
103035 +cl_page_own0_599 cl_page_own0 0 599 NULL
103036 +btrfs_stack_file_extent_offset_607 btrfs_stack_file_extent_offset 0 607 NULL
103037 +ni_gpct_device_construct_610 ni_gpct_device_construct 5 610 NULL
103038 +fuse_request_alloc_nofs_617 fuse_request_alloc_nofs 1 617 NULL
103039 +ptlrpc_lprocfs_nrs_seq_write_621 ptlrpc_lprocfs_nrs_seq_write 3 621 NULL
103040 +viafb_dfpl_proc_write_627 viafb_dfpl_proc_write 3 627 NULL
103041 +ocfs2_num_free_extents_632 ocfs2_num_free_extents 0 632 NULL
103042 +clone_split_bio_633 clone_split_bio 6 633 NULL
103043 +ceph_osdc_new_request_635 ceph_osdc_new_request 6 635 NULL
103044 +remap_to_cache_640 remap_to_cache 3 640 NULL
103045 +cfs_hash_bkt_size_643 cfs_hash_bkt_size 0 643 NULL nohasharray
103046 +drbd_bm_find_next_643 drbd_bm_find_next 2 643 &cfs_hash_bkt_size_643
103047 +unlink_queued_645 unlink_queued 4 645 NULL
103048 +dtim_interval_read_654 dtim_interval_read 3 654 NULL
103049 +div_u64_rem_672 div_u64_rem 0 672 NULL
103050 +mem_rx_free_mem_blks_read_675 mem_rx_free_mem_blks_read 3 675 NULL
103051 +persistent_ram_vmap_709 persistent_ram_vmap 1-2 709 NULL
103052 +ipath_resize_cq_712 ipath_resize_cq 2 712 NULL
103053 +disk_max_parts_719 disk_max_parts 0 719 NULL
103054 +sctp_setsockopt_peer_addr_params_734 sctp_setsockopt_peer_addr_params 3 734 NULL
103055 +dvb_video_write_754 dvb_video_write 3 754 NULL
103056 +cfs_trace_allocate_string_buffer_781 cfs_trace_allocate_string_buffer 2 781 NULL
103057 +jbd2_journal_dirty_metadata_784 jbd2_journal_dirty_metadata 0 784 NULL
103058 +ath6kl_disconnect_timeout_write_794 ath6kl_disconnect_timeout_write 3 794 NULL
103059 +__vmalloc_node_range_811 __vmalloc_node_range 7 811 NULL nohasharray
103060 +snd_pcm_drain_811 snd_pcm_drain 0 811 &__vmalloc_node_range_811
103061 +if_writecmd_815 if_writecmd 2 815 NULL
103062 +aac_change_queue_depth_825 aac_change_queue_depth 2 825 NULL
103063 +SyS_write_846 SyS_write 3 846 NULL
103064 +um_idi_read_850 um_idi_read 3 850 NULL
103065 +error_state_read_859 error_state_read 6 859 NULL
103066 +o2net_send_message_vec_879 o2net_send_message_vec 4 879 NULL nohasharray
103067 +iwl_dbgfs_fh_reg_read_879 iwl_dbgfs_fh_reg_read 3 879 &o2net_send_message_vec_879
103068 +intel_alloc_iova_883 intel_alloc_iova 3 883 NULL
103069 +snd_pcm_action_single_905 snd_pcm_action_single 0 905 NULL
103070 +readw_931 readw 0 931 NULL
103071 +carl9170_cmd_buf_950 carl9170_cmd_buf 3 950 NULL
103072 +__nodes_weight_956 __nodes_weight 2-0 956 NULL
103073 +bnx2x_fill_fw_str_968 bnx2x_fill_fw_str 3 968 NULL
103074 +memcmp_990 memcmp 0 990 NULL
103075 +pte_prefetch_gfn_to_pfn_997 pte_prefetch_gfn_to_pfn 2 997 NULL
103076 +free_ind_block_999 free_ind_block 0 999 NULL
103077 +dm_cache_set_dirty_1016 dm_cache_set_dirty 2 1016 NULL
103078 +readreg_1017 readreg 0-1 1017 NULL
103079 +_do_truncate_1019 _do_truncate 2 1019 NULL
103080 +smk_write_cipso2_1021 smk_write_cipso2 3 1021 NULL
103081 +gigaset_initdriver_1060 gigaset_initdriver 2 1060 NULL
103082 +mce_request_packet_1073 mce_request_packet 3 1073 NULL
103083 +agp_create_memory_1075 agp_create_memory 1 1075 NULL
103084 +ext4_orphan_add_1080 ext4_orphan_add 0 1080 NULL
103085 +_scsih_adjust_queue_depth_1083 _scsih_adjust_queue_depth 2 1083 NULL
103086 +llcp_sock_sendmsg_1092 llcp_sock_sendmsg 4 1092 NULL
103087 +inode_ref_info_1094 inode_ref_info 0 1094 NULL nohasharray
103088 +llc_mac_hdr_init_1094 llc_mac_hdr_init 0 1094 &inode_ref_info_1094
103089 +nfs4_init_nonuniform_client_string_1097 nfs4_init_nonuniform_client_string 3 1097 NULL
103090 +utf8s_to_utf16s_1115 utf8s_to_utf16s 0 1115 NULL
103091 +__btrfs_cow_block_1125 __btrfs_cow_block 7-0 1125 NULL nohasharray
103092 +__ext4_journal_stop_1125 __ext4_journal_stop 0 1125 &__btrfs_cow_block_1125
103093 +cfg80211_report_obss_beacon_1133 cfg80211_report_obss_beacon 3 1133 NULL
103094 +vmalloc_32_1135 vmalloc_32 1 1135 NULL
103095 +i2400m_rx_ctl_1157 i2400m_rx_ctl 4 1157 NULL
103096 +find_free_extent_1173 find_free_extent 4-0 1173 NULL
103097 +ipc_alloc_1192 ipc_alloc 1 1192 NULL
103098 +ib_create_send_mad_1196 ib_create_send_mad 5 1196 NULL
103099 +pstore_ftrace_knob_write_1198 pstore_ftrace_knob_write 3 1198 NULL
103100 +i2400m_rx_ctl_ack_1199 i2400m_rx_ctl_ack 3 1199 NULL
103101 +dgrp_dpa_read_1204 dgrp_dpa_read 3 1204 NULL
103102 +i2cdev_read_1206 i2cdev_read 3 1206 NULL
103103 +lov_ost_pool_init_1215 lov_ost_pool_init 2 1215 NULL
103104 +acpi_battery_write_alarm_1240 acpi_battery_write_alarm 3 1240 NULL
103105 +nested_get_page_1252 nested_get_page 2 1252 NULL
103106 +ocfs2_extend_file_1266 ocfs2_extend_file 3 1266 NULL
103107 +qla4xxx_change_queue_depth_1268 qla4xxx_change_queue_depth 2 1268 NULL
103108 +ioctl_private_iw_point_1273 ioctl_private_iw_point 7 1273 NULL
103109 +batadv_tt_prepare_packet_buff_1280 batadv_tt_prepare_packet_buff 4 1280 NULL
103110 +SyS_flistxattr_1287 SyS_flistxattr 3 1287 NULL
103111 +tx_frag_in_process_called_read_1290 tx_frag_in_process_called_read 3 1290 NULL
103112 +ocfs2_append_rec_to_path_1321 ocfs2_append_rec_to_path 0 1321 NULL
103113 +ffs_1322 ffs 0 1322 NULL
103114 +qlcnic_pci_sriov_configure_1327 qlcnic_pci_sriov_configure 2 1327 NULL nohasharray
103115 +push_node_left_1327 push_node_left 0 1327 &qlcnic_pci_sriov_configure_1327
103116 +btrfs_submit_compressed_write_1347 btrfs_submit_compressed_write 5 1347 NULL
103117 +gen_pool_best_fit_1348 gen_pool_best_fit 2-3-4 1348 NULL
103118 +btrfs_alloc_logged_file_extent_1354 btrfs_alloc_logged_file_extent 0 1354 NULL
103119 +snd_pcm_lib_write1_1358 snd_pcm_lib_write1 0-3 1358 NULL
103120 +ipx_sendmsg_1362 ipx_sendmsg 4 1362 NULL
103121 +iov_num_pages_1364 iov_num_pages 0 1364 NULL
103122 +fw_stats_raw_read_1369 fw_stats_raw_read 3 1369 NULL
103123 +ocfs2_prepare_inode_for_write_1372 ocfs2_prepare_inode_for_write 3 1372 NULL
103124 +sctp_setsockopt_initmsg_1383 sctp_setsockopt_initmsg 3 1383 NULL
103125 +do_msgsnd_1387 do_msgsnd 4 1387 NULL
103126 +SYSC_io_getevents_1392 SYSC_io_getevents 3 1392 NULL
103127 +zone_page_state_1393 zone_page_state 0 1393 NULL
103128 +file_read_actor_1401 file_read_actor 4 1401 NULL
103129 +vb2_vmalloc_alloc_1402 vb2_vmalloc_alloc 2 1402 NULL
103130 +cfs_trace_copyout_string_1416 cfs_trace_copyout_string 2 1416 NULL
103131 +pq_init_1423 pq_init 1 1423 NULL
103132 +init_rs_internal_1436 init_rs_internal 1 1436 NULL
103133 +vb2_dc_get_user_pages_1442 vb2_dc_get_user_pages 1-3 1442 NULL
103134 +stack_max_size_read_1445 stack_max_size_read 3 1445 NULL
103135 +tx_queue_len_read_1463 tx_queue_len_read 3 1463 NULL
103136 +xprt_alloc_1475 xprt_alloc 2 1475 NULL
103137 +SYSC_syslog_1477 SYSC_syslog 3 1477 NULL
103138 +sta_num_ps_buf_frames_read_1488 sta_num_ps_buf_frames_read 3 1488 NULL
103139 +posix_acl_permission_1495 posix_acl_permission 0 1495 NULL
103140 +fpregs_set_1497 fpregs_set 4 1497 NULL
103141 +ocfs2_alloc_dinode_update_counts_1507 ocfs2_alloc_dinode_update_counts 0 1507 NULL
103142 +tomoyo_round2_1518 tomoyo_round2 0 1518 NULL
103143 +alloc_perm_bits_1532 alloc_perm_bits 2 1532 NULL
103144 +ath6kl_init_get_fwcaps_1557 ath6kl_init_get_fwcaps 3 1557 NULL
103145 +extent_from_logical_1585 extent_from_logical 0 1585 NULL
103146 +ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime_1589 ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime 3 1589 NULL
103147 +ipath_ht_handle_hwerrors_1592 ipath_ht_handle_hwerrors 3 1592 NULL
103148 +packet_buffer_init_1607 packet_buffer_init 2 1607 NULL
103149 +btmrvl_hscmd_read_1614 btmrvl_hscmd_read 3 1614 NULL
103150 +v9fs_fid_xattr_get_1618 v9fs_fid_xattr_get 0 1618 NULL
103151 +run_delayed_extent_op_1637 run_delayed_extent_op 0 1637 NULL
103152 +ikconfig_read_current_1658 ikconfig_read_current 3 1658 NULL
103153 +qgroup_rescan_init_1664 qgroup_rescan_init 0 1664 NULL
103154 +mei_cl_recv_1665 mei_cl_recv 3 1665 NULL
103155 +rmap_add_1677 rmap_add 3 1677 NULL
103156 +configfs_read_file_1683 configfs_read_file 3 1683 NULL
103157 +pdu_write_u_1710 pdu_write_u 3 1710 NULL
103158 +coda_psdev_write_1711 coda_psdev_write 3 1711 NULL nohasharray
103159 +gfn_to_hva_prot_1711 gfn_to_hva_prot 2 1711 &coda_psdev_write_1711
103160 +btrfs_dir_data_len_1714 btrfs_dir_data_len 0 1714 NULL
103161 +dma_memcpy_pg_to_iovec_1725 dma_memcpy_pg_to_iovec 6 1725 NULL
103162 +internal_create_group_1733 internal_create_group 0 1733 NULL
103163 +dev_irnet_read_1741 dev_irnet_read 3 1741 NULL
103164 +tx_frag_called_read_1748 tx_frag_called_read 3 1748 NULL
103165 +ebt_size_mwt_1768 ebt_size_mwt 0 1768 NULL
103166 +cosa_write_1774 cosa_write 3 1774 NULL
103167 +fcoe_ctlr_device_add_1793 fcoe_ctlr_device_add 3 1793 NULL
103168 +__nodelist_scnprintf_1815 __nodelist_scnprintf 4-2-0 1815 NULL
103169 +sb_issue_zeroout_1884 sb_issue_zeroout 3-0 1884 NULL
103170 +rx_defrag_called_read_1897 rx_defrag_called_read 3 1897 NULL
103171 +nfs_parse_server_name_1899 nfs_parse_server_name 2 1899 NULL
103172 +SyS_add_key_1900 SyS_add_key 4 1900 NULL
103173 +uhid_char_read_1920 uhid_char_read 3 1920 NULL
103174 +tx_tx_retry_data_read_1926 tx_tx_retry_data_read 3 1926 NULL
103175 +bdev_erase_1933 bdev_erase 3 1933 NULL
103176 +ext3_fiemap_1936 ext3_fiemap 4 1936 NULL
103177 +cyttsp_probe_1940 cyttsp_probe 4 1940 NULL
103178 +ieee80211_if_fmt_dot11MeshConfirmTimeout_1945 ieee80211_if_fmt_dot11MeshConfirmTimeout 3 1945 NULL
103179 +read_swap_header_1957 read_swap_header 0 1957 NULL
103180 +ivtv_v4l2_read_1964 ivtv_v4l2_read 3 1964 NULL
103181 +sel_read_avc_hash_stats_1984 sel_read_avc_hash_stats 3 1984 NULL
103182 +gpio_power_write_1991 gpio_power_write 3 1991 NULL
103183 +__alloc_bootmem_node_1992 __alloc_bootmem_node 2 1992 NULL
103184 +atomic_read_unchecked_1995 atomic_read_unchecked 0 1995 NULL
103185 +sb_min_blocksize_2004 sb_min_blocksize 0-2 2004 NULL
103186 +batadv_tt_commit_changes_2008 batadv_tt_commit_changes 4 2008 NULL
103187 +sep_prepare_input_dma_table_2009 sep_prepare_input_dma_table 2-3 2009 NULL
103188 +rx_rx_defrag_read_2010 rx_rx_defrag_read 3 2010 NULL
103189 +ksm_madvise_2012 ksm_madvise 0 2012 NULL
103190 +ocfs2_global_qinit_alloc_2018 ocfs2_global_qinit_alloc 0 2018 NULL
103191 +write_flush_pipefs_2021 write_flush_pipefs 3 2021 NULL
103192 +BcmCopySection_2035 BcmCopySection 5-0 2035 NULL
103193 +ath6kl_fwlog_mask_read_2050 ath6kl_fwlog_mask_read 3 2050 NULL
103194 +ocfs2_expand_inline_dir_2063 ocfs2_expand_inline_dir 3 2063 NULL
103195 +__generic_copy_from_user_intel_2073 __generic_copy_from_user_intel 0-3 2073 NULL
103196 +diva_set_driver_dbg_mask_2077 diva_set_driver_dbg_mask 0 2077 NULL nohasharray
103197 +alloc_retstack_tasklist_2077 alloc_retstack_tasklist 0 2077 &diva_set_driver_dbg_mask_2077
103198 +iwl_dbgfs_current_sleep_command_read_2081 iwl_dbgfs_current_sleep_command_read 3 2081 NULL
103199 +get_unaligned_le32_2092 get_unaligned_le32 0 2092 NULL
103200 +idetape_chrdev_read_2097 idetape_chrdev_read 3 2097 NULL
103201 +audit_expand_2098 audit_expand 0 2098 NULL
103202 +num_pages_spanned_2105 num_pages_spanned 0 2105 NULL
103203 +shrd128_2106 shrd128 0-1-3-2 2106 NULL
103204 +iwl_dbgfs_log_event_read_2107 iwl_dbgfs_log_event_read 3 2107 NULL
103205 +ecryptfs_encrypt_and_encode_filename_2109 ecryptfs_encrypt_and_encode_filename 6 2109 NULL
103206 +enable_read_2117 enable_read 3 2117 NULL
103207 +pcf50633_write_block_2124 pcf50633_write_block 2-3 2124 NULL
103208 +snd_interval_refine_last_2127 snd_interval_refine_last 0 2127 NULL
103209 +check_load_and_stores_2143 check_load_and_stores 2 2143 NULL
103210 +lp_gpio_irq_map_2149 lp_gpio_irq_map 2 2149 NULL
103211 +iov_iter_count_2152 iov_iter_count 0 2152 NULL
103212 +__copy_to_user_ll_2157 __copy_to_user_ll 0-3 2157 NULL
103213 +ocfs2_et_sanity_check_2164 ocfs2_et_sanity_check 0 2164 NULL
103214 +_ore_get_io_state_2166 _ore_get_io_state 5-3-4 2166 NULL
103215 +bio_integrity_alloc_2194 bio_integrity_alloc 3 2194 NULL
103216 +picolcd_debug_reset_write_2195 picolcd_debug_reset_write 3 2195 NULL
103217 +mei_dbgfs_read_meclients_2219 mei_dbgfs_read_meclients 3 2219 NULL nohasharray
103218 +u32_array_read_2219 u32_array_read 3 2219 &mei_dbgfs_read_meclients_2219
103219 +vhci_write_2224 vhci_write 3 2224 NULL
103220 +__ocfs2_journal_access_2241 __ocfs2_journal_access 0 2241 NULL
103221 +ieee80211_if_read_dot11MeshHWMPRannInterval_2249 ieee80211_if_read_dot11MeshHWMPRannInterval 3 2249 NULL
103222 +netlbl_secattr_catmap_walk_2255 netlbl_secattr_catmap_walk 0-2 2255 NULL
103223 +sel_write_avc_cache_threshold_2256 sel_write_avc_cache_threshold 3 2256 NULL
103224 +do_update_counters_2259 do_update_counters 4 2259 NULL
103225 +ath6kl_wmi_bssinfo_event_rx_2275 ath6kl_wmi_bssinfo_event_rx 3 2275 NULL
103226 +debug_debug5_read_2291 debug_debug5_read 3 2291 NULL
103227 +ocfs2_shift_tree_depth_2292 ocfs2_shift_tree_depth 0 2292 NULL
103228 +kvm_clear_guest_page_2308 kvm_clear_guest_page 2-4 2308 NULL
103229 +intel_sdvo_set_value_2311 intel_sdvo_set_value 4 2311 NULL
103230 +picolcd_fb_write_2318 picolcd_fb_write 3 2318 NULL nohasharray
103231 +hfsplus_find_init_2318 hfsplus_find_init 0 2318 &picolcd_fb_write_2318
103232 +gart_map_page_2325 gart_map_page 4-3 2325 NULL
103233 +__erst_read_to_erange_2341 __erst_read_to_erange 0 2341 NULL
103234 +zr364xx_read_2354 zr364xx_read 3 2354 NULL
103235 +viafb_iga2_odev_proc_write_2363 viafb_iga2_odev_proc_write 3 2363 NULL
103236 +SyS_mremap_2367 SyS_mremap 2-3-1-5 2367 NULL
103237 +xfs_buf_map_from_irec_2368 xfs_buf_map_from_irec 5 2368 NULL nohasharray
103238 +rose_recvmsg_2368 rose_recvmsg 4 2368 &xfs_buf_map_from_irec_2368
103239 +il_dbgfs_sensitivity_read_2370 il_dbgfs_sensitivity_read 3 2370 NULL
103240 +rxpipe_rx_prep_beacon_drop_read_2403 rxpipe_rx_prep_beacon_drop_read 3 2403 NULL
103241 +SYSC_mlock_2415 SYSC_mlock 1-2 2415 NULL
103242 +isdn_v110_open_2418 isdn_v110_open 3 2418 NULL
103243 +raid1_size_2419 raid1_size 0-2 2419 NULL
103244 +timespec_to_jiffies_timeout_2428 timespec_to_jiffies_timeout 0 2428 NULL
103245 +tty_buffer_find_2443 tty_buffer_find 2 2443 NULL
103246 +b43legacy_debugfs_read_2473 b43legacy_debugfs_read 3 2473 NULL
103247 +wiphy_new_2482 wiphy_new 2 2482 NULL
103248 +bio_alloc_bioset_2484 bio_alloc_bioset 2 2484 NULL
103249 +hfsplus_user_setxattr_2485 hfsplus_user_setxattr 4 2485 NULL
103250 +lookup_cache_entry_2494 lookup_cache_entry 2 2494 NULL
103251 +squashfs_read_fragment_index_table_2506 squashfs_read_fragment_index_table 4 2506 NULL
103252 +v9fs_cached_file_read_2514 v9fs_cached_file_read 3 2514 NULL
103253 +ext4_get_inode_loc_2516 ext4_get_inode_loc 0 2516 NULL
103254 +gspca_dev_probe_2570 gspca_dev_probe 4 2570 NULL
103255 +pcm_sanity_check_2574 pcm_sanity_check 0 2574 NULL
103256 +mdc_max_rpcs_in_flight_seq_write_2594 mdc_max_rpcs_in_flight_seq_write 3 2594 NULL
103257 +slot_bytes_2609 slot_bytes 0 2609 NULL
103258 +smk_write_logging_2618 smk_write_logging 3 2618 NULL
103259 +switch_status_2629 switch_status 5 2629 NULL
103260 +tlv_put_string_2631 tlv_put_string 0 2631 NULL
103261 +kvm_gfn_to_hva_cache_init_2636 kvm_gfn_to_hva_cache_init 3 2636 NULL
103262 +tcp_xmit_size_goal_2661 tcp_xmit_size_goal 2 2661 NULL
103263 +osc_build_ppga_2670 osc_build_ppga 2 2670 NULL
103264 +ffs_ep0_read_2672 ffs_ep0_read 3 2672 NULL
103265 +ocfs2_rotate_subtree_right_2674 ocfs2_rotate_subtree_right 0 2674 NULL
103266 +oti6858_write_2692 oti6858_write 4 2692 NULL
103267 +nfc_llcp_send_ui_frame_2702 nfc_llcp_send_ui_frame 5 2702 NULL
103268 +memcpy_fromiovecend_2707 memcpy_fromiovecend 4-3 2707 NULL
103269 +SyS_pwrite64_2708 SyS_pwrite64 3 2708 NULL nohasharray
103270 +lprocfs_stats_counter_size_2708 lprocfs_stats_counter_size 0 2708 &SyS_pwrite64_2708
103271 +__xip_file_write_2733 __xip_file_write 3-4 2733 NULL
103272 +can_nocow_extent_2744 can_nocow_extent 3 2744 NULL
103273 +xfs_readdir_2767 xfs_readdir 3 2767 NULL
103274 +mon_bin_ioctl_2771 mon_bin_ioctl 3 2771 NULL nohasharray
103275 +bictcp_update_2771 bictcp_update 2 2771 &mon_bin_ioctl_2771
103276 +__next_cpu_2782 __next_cpu 1-0 2782 NULL
103277 +set_msr_hyperv_pw_2785 set_msr_hyperv_pw 3 2785 NULL
103278 +device_add_attrs_2789 device_add_attrs 0 2789 NULL
103279 +iwl_dbgfs_clear_ucode_statistics_write_2804 iwl_dbgfs_clear_ucode_statistics_write 3 2804 NULL
103280 +sel_read_enforce_2828 sel_read_enforce 3 2828 NULL
103281 +vb2_dc_get_userptr_2829 vb2_dc_get_userptr 2-3 2829 NULL nohasharray
103282 +snd_pcm_reset_2829 snd_pcm_reset 0 2829 &vb2_dc_get_userptr_2829
103283 +sock_create_2838 sock_create 0 2838 NULL
103284 +wait_for_avail_2847 wait_for_avail 0 2847 NULL
103285 +ufs_free_fragments_2857 ufs_free_fragments 2 2857 NULL
103286 +sfq_alloc_2861 sfq_alloc 1 2861 NULL
103287 +irnet_ctrl_read_2863 irnet_ctrl_read 4 2863 NULL
103288 +move_addr_to_user_2868 move_addr_to_user 2 2868 NULL
103289 +mq_map_2871 mq_map 2 2871 NULL
103290 +__swab64p_2875 __swab64p 0 2875 NULL
103291 +nla_padlen_2883 nla_padlen 1 2883 NULL
103292 +cmm_write_2896 cmm_write 3 2896 NULL
103293 +alloc_page_cgroup_2919 alloc_page_cgroup 1-2 2919 NULL
103294 +osc_import_seq_write_2923 osc_import_seq_write 3 2923 NULL
103295 +xfs_trans_get_buf_map_2927 xfs_trans_get_buf_map 4 2927 NULL
103296 +nes_read_indexed_2946 nes_read_indexed 0 2946 NULL
103297 +tm6000_i2c_recv_regs16_2949 tm6000_i2c_recv_regs16 5 2949 NULL
103298 +i40e_dbg_prep_dump_buf_2951 i40e_dbg_prep_dump_buf 2 2951 NULL
103299 +set_fast_connectable_2952 set_fast_connectable 4 2952 NULL
103300 +free_area_init_core_2962 free_area_init_core 2-3 2962 NULL
103301 +do_strnlen_user_2976 do_strnlen_user 0-2 2976 NULL
103302 +ocfs2_find_branch_target_2989 ocfs2_find_branch_target 0 2989 NULL
103303 +p9_nr_pages_2992 p9_nr_pages 0-2 2992 NULL
103304 +lov_stripetype_seq_write_3013 lov_stripetype_seq_write 3 3013 NULL
103305 +btrfs_add_block_group_cache_3016 btrfs_add_block_group_cache 0 3016 NULL
103306 +do_dmabuf_dirty_sou_3017 do_dmabuf_dirty_sou 7 3017 NULL
103307 +depth_write_3021 depth_write 3 3021 NULL
103308 +snd_azf3328_codec_inl_3022 snd_azf3328_codec_inl 0 3022 NULL
103309 +kvm_unmap_hva_3028 kvm_unmap_hva 2 3028 NULL
103310 +xfrm_dst_alloc_copy_3034 xfrm_dst_alloc_copy 3 3034 NULL
103311 +lpfc_idiag_mbxacc_write_3038 lpfc_idiag_mbxacc_write 3 3038 NULL nohasharray
103312 +iwl_dbgfs_sleep_level_override_read_3038 iwl_dbgfs_sleep_level_override_read 3 3038 &lpfc_idiag_mbxacc_write_3038
103313 +nr_free_buffer_pages_3044 nr_free_buffer_pages 0 3044 NULL
103314 +il3945_ucode_rx_stats_read_3048 il3945_ucode_rx_stats_read 3 3048 NULL
103315 +qp_alloc_ppn_set_3068 qp_alloc_ppn_set 2-4 3068 NULL
103316 +__blk_end_bidi_request_3070 __blk_end_bidi_request 4-3 3070 NULL
103317 +dac960_user_command_proc_write_3071 dac960_user_command_proc_write 3 3071 NULL
103318 +read_file_antenna_diversity_3077 read_file_antenna_diversity 3 3077 NULL
103319 +free_coherent_3082 free_coherent 4-2 3082 NULL
103320 +ocfs2_get_right_path_3097 ocfs2_get_right_path 0 3097 NULL
103321 +clone_bio_3100 clone_bio 6 3100 NULL nohasharray
103322 +ttusb2_msg_3100 ttusb2_msg 4 3100 &clone_bio_3100
103323 +rb_alloc_3102 rb_alloc 1 3102 NULL
103324 +simple_write_to_buffer_3122 simple_write_to_buffer 2-5 3122 NULL
103325 +print_time_3132 print_time 0 3132 NULL
103326 +fill_write_buffer_3142 fill_write_buffer 3 3142 NULL
103327 +find_free_extent_3153 find_free_extent 5 3153 NULL
103328 +CIFSSMBSetPosixACL_3154 CIFSSMBSetPosixACL 5 3154 NULL
103329 +compat_sys_migrate_pages_3157 compat_sys_migrate_pages 2 3157 NULL
103330 +i915_gem_obj_ggtt_offset_3162 i915_gem_obj_ggtt_offset 0 3162 NULL
103331 +uv_num_possible_blades_3177 uv_num_possible_blades 0 3177 NULL
103332 +uvc_video_stats_dump_3181 uvc_video_stats_dump 3 3181 NULL
103333 +compat_do_ip6t_set_ctl_3184 compat_do_ip6t_set_ctl 4 3184 NULL
103334 +wait_table_bits_3187 wait_table_bits 1 3187 NULL
103335 +mempool_create_node_3191 mempool_create_node 1-6 3191 NULL
103336 +alloc_context_3194 alloc_context 1 3194 NULL
103337 +shmem_pread_slow_3198 shmem_pread_slow 3-2 3198 NULL
103338 +codec_reg_write_file_3204 codec_reg_write_file 3 3204 NULL
103339 +SyS_sendto_3219 SyS_sendto 6 3219 NULL
103340 +btrfs_prealloc_file_range_3227 btrfs_prealloc_file_range 3 3227 NULL
103341 +btrfs_next_leaf_3232 btrfs_next_leaf 0 3232 NULL
103342 +kimage_crash_alloc_3233 kimage_crash_alloc 3 3233 NULL
103343 +write_adapter_mem_3234 write_adapter_mem 3 3234 NULL
103344 +do_read_log_to_user_3236 do_read_log_to_user 4 3236 NULL
103345 +ext3_xattr_find_entry_3237 ext3_xattr_find_entry 0 3237 NULL
103346 +key_key_read_3241 key_key_read 3 3241 NULL
103347 +mmap_piobufs_3244 mmap_piobufs 4 3244 NULL
103348 +did_overwrite_first_ref_3259 did_overwrite_first_ref 0 3259 NULL
103349 +__ilog2_u64_3284 __ilog2_u64 0 3284 NULL
103350 +__iovec_copy_from_user_inatomic_3314 __iovec_copy_from_user_inatomic 0-4-3 3314 NULL
103351 +dbDiscardAG_3322 dbDiscardAG 3 3322 NULL
103352 +compat_sys_setsockopt_3326 compat_sys_setsockopt 5 3326 NULL
103353 +read_from_oldmem_3337 read_from_oldmem 2 3337 NULL
103354 +sysfs_create_group_3339 sysfs_create_group 0 3339 NULL
103355 +tty_port_register_device_attr_3341 tty_port_register_device_attr 3 3341 NULL
103356 +il_dbgfs_interrupt_read_3351 il_dbgfs_interrupt_read 3 3351 NULL
103357 +gsm_control_rls_3353 gsm_control_rls 3 3353 NULL
103358 +scnprintf_3360 scnprintf 0-2 3360 NULL
103359 +ReadByteAmd7930_3365 ReadByteAmd7930 0 3365 NULL
103360 +sr_read_3366 sr_read 3 3366 NULL
103361 +count_inode_refs_3375 count_inode_refs 0 3375 NULL
103362 +x86_emulate_instruction_3389 x86_emulate_instruction 2 3389 NULL
103363 +mtdchar_writeoob_3393 mtdchar_writeoob 4 3393 NULL
103364 +send_stream_3397 send_stream 4 3397 NULL
103365 +isdn_readbchan_3401 isdn_readbchan 0-5 3401 NULL
103366 +mei_io_cb_alloc_resp_buf_3414 mei_io_cb_alloc_resp_buf 2 3414 NULL
103367 +zone_to_nid_3415 zone_to_nid 0 3415 NULL
103368 +pci_add_cap_save_buffer_3426 pci_add_cap_save_buffer 3 3426 NULL
103369 +crystalhd_create_dio_pool_3427 crystalhd_create_dio_pool 2 3427 NULL
103370 +SyS_msgsnd_3436 SyS_msgsnd 3 3436 NULL
103371 +send_unlink_3438 send_unlink 0 3438 NULL
103372 +pipe_iov_copy_to_user_3447 pipe_iov_copy_to_user 3 3447 NULL
103373 +map_single_3449 map_single 0 3449 NULL
103374 +softsynth_write_3455 softsynth_write 3 3455 NULL
103375 +jffs2_acl_setxattr_3464 jffs2_acl_setxattr 4 3464 NULL nohasharray
103376 +snd_pcm_lib_readv_transfer_3464 snd_pcm_lib_readv_transfer 5-4-2 3464 &jffs2_acl_setxattr_3464
103377 +security_context_to_sid_default_3492 security_context_to_sid_default 2 3492 NULL
103378 +xfrm_migrate_msgsize_3496 xfrm_migrate_msgsize 1 3496 NULL
103379 +run_one_delayed_ref_3503 run_one_delayed_ref 0 3503 NULL nohasharray
103380 +kvm_handle_bad_page_3503 kvm_handle_bad_page 2 3503 &run_one_delayed_ref_3503
103381 +mem_tx_free_mem_blks_read_3521 mem_tx_free_mem_blks_read 3 3521 NULL
103382 +SyS_semtimedop_3532 SyS_semtimedop 3 3532 NULL
103383 +SyS_readv_3539 SyS_readv 3 3539 NULL
103384 +btrfs_dir_name_len_3549 btrfs_dir_name_len 0 3549 NULL
103385 +iommu_map_3554 iommu_map 3-2 3554 NULL
103386 +btrfs_delayed_update_inode_3557 btrfs_delayed_update_inode 0 3557 NULL
103387 +i915_gem_execbuffer_reserve_3558 i915_gem_execbuffer_reserve 0 3558 NULL
103388 +alloc_smp_resp_3566 alloc_smp_resp 1 3566 NULL
103389 +evtchn_read_3569 evtchn_read 3 3569 NULL
103390 +ll_track_ppid_seq_write_3582 ll_track_ppid_seq_write 3 3582 NULL
103391 +vc_resize_3585 vc_resize 3-2 3585 NULL
103392 +kvm_mmu_notifier_change_pte_3596 kvm_mmu_notifier_change_pte 3 3596 NULL
103393 +sctp_getsockopt_events_3607 sctp_getsockopt_events 2 3607 NULL
103394 +edac_mc_alloc_3611 edac_mc_alloc 4 3611 NULL
103395 +tx_tx_starts_read_3617 tx_tx_starts_read 3 3617 NULL
103396 +aligned_kmalloc_3628 aligned_kmalloc 1 3628 NULL
103397 +x86_swiotlb_alloc_coherent_3649 x86_swiotlb_alloc_coherent 2 3649 NULL
103398 +ath6kl_disconnect_timeout_read_3650 ath6kl_disconnect_timeout_read 3 3650 NULL
103399 +i915_compat_ioctl_3656 i915_compat_ioctl 2 3656 NULL
103400 +replace_pin_at_irq_node_3687 replace_pin_at_irq_node 2 3687 NULL
103401 +ntfs_attr_make_non_resident_3694 ntfs_attr_make_non_resident 0-2 3694 NULL
103402 +snd_m3_assp_read_3703 snd_m3_assp_read 0 3703 NULL nohasharray
103403 +create_irq_3703 create_irq 0 3703 &snd_m3_assp_read_3703
103404 +videobuf_pages_to_sg_3708 videobuf_pages_to_sg 2 3708 NULL
103405 +ci_ll_write_3740 ci_ll_write 4 3740 NULL nohasharray
103406 +ath6kl_mgmt_tx_3740 ath6kl_mgmt_tx 7 3740 &ci_ll_write_3740
103407 +uar_index2pfn_3741 uar_index2pfn 0-2 3741 NULL
103408 +sctp_setsockopt_auth_key_3793 sctp_setsockopt_auth_key 3 3793 NULL
103409 +btrfs_alloc_chunk_3808 btrfs_alloc_chunk 0 3808 NULL
103410 +ncp_file_write_3813 ncp_file_write 3 3813 NULL
103411 +llc_ui_recvmsg_3826 llc_ui_recvmsg 4 3826 NULL
103412 +btrfs_uuid_iter_rem_3831 btrfs_uuid_iter_rem 0 3831 NULL
103413 +hfsplus_direct_IO_3835 hfsplus_direct_IO 4 3835 NULL
103414 +stringify_nodemap_3842 stringify_nodemap 2 3842 NULL
103415 +ubi_eba_read_leb_3847 ubi_eba_read_leb 0 3847 NULL
103416 +create_one_cdev_3852 create_one_cdev 2 3852 NULL
103417 +smk_read_onlycap_3855 smk_read_onlycap 3 3855 NULL
103418 +get_fd_set_3866 get_fd_set 1 3866 NULL
103419 +apei_res_sub_3873 apei_res_sub 0 3873 NULL
103420 +garp_attr_create_3883 garp_attr_create 3 3883 NULL
103421 +efivarfs_file_read_3893 efivarfs_file_read 3 3893 NULL
103422 +nvram_write_3894 nvram_write 3 3894 NULL
103423 +pipeline_pre_proc_swi_read_3898 pipeline_pre_proc_swi_read 3 3898 NULL
103424 +comedi_buf_read_n_available_3899 comedi_buf_read_n_available 0 3899 NULL
103425 +vcs_write_3910 vcs_write 3 3910 NULL
103426 +SyS_move_pages_3920 SyS_move_pages 2 3920 NULL
103427 +hdlc_irq_one_3944 hdlc_irq_one 2 3944 NULL
103428 +brcmf_debugfs_fws_stats_read_3947 brcmf_debugfs_fws_stats_read 3 3947 NULL
103429 +mite_bytes_written_to_memory_lb_3987 mite_bytes_written_to_memory_lb 0 3987 NULL
103430 +do_add_counters_3992 do_add_counters 3 3992 NULL
103431 +obd_alloc_memmd_4002 obd_alloc_memmd 0 4002 NULL
103432 +userspace_status_4004 userspace_status 4 4004 NULL
103433 +mei_write_4005 mei_write 3 4005 NULL nohasharray
103434 +xfs_check_block_4005 xfs_check_block 4 4005 &mei_write_4005
103435 +snd_hdsp_capture_copy_4011 snd_hdsp_capture_copy 5 4011 NULL
103436 +mm_populate_4016 mm_populate 1-2 4016 NULL nohasharray
103437 +i915_gem_object_unbind_4016 i915_gem_object_unbind 0 4016 &mm_populate_4016
103438 +blk_end_request_4024 blk_end_request 3 4024 NULL
103439 +ext4_xattr_find_entry_4025 ext4_xattr_find_entry 0 4025 NULL
103440 +mtip_hw_read_registers_4037 mtip_hw_read_registers 3 4037 NULL
103441 +i915_gpu_idle_4062 i915_gpu_idle 0 4062 NULL
103442 +read_file_queues_4078 read_file_queues 3 4078 NULL
103443 +fbcon_do_set_font_4079 fbcon_do_set_font 2-3 4079 NULL
103444 +btrfs_inc_ref_4084 btrfs_inc_ref 0 4084 NULL
103445 +da9052_free_irq_4090 da9052_free_irq 2 4090 NULL
103446 +tm6000_read_4151 tm6000_read 3 4151 NULL
103447 +mpt_raid_phys_disk_get_num_paths_4155 mpt_raid_phys_disk_get_num_paths 0 4155 NULL
103448 +msg_bits_4158 msg_bits 0-3-4 4158 NULL
103449 +get_alua_req_4166 get_alua_req 3 4166 NULL
103450 +blk_dropped_read_4168 blk_dropped_read 3 4168 NULL
103451 +read_file_bool_4180 read_file_bool 3 4180 NULL
103452 +ocfs2_find_cpos_for_right_leaf_4194 ocfs2_find_cpos_for_right_leaf 0 4194 NULL
103453 +f1x_determine_channel_4202 f1x_determine_channel 2 4202 NULL
103454 +_osd_req_list_objects_4204 _osd_req_list_objects 6 4204 NULL
103455 +__snd_gf1_read_addr_4210 __snd_gf1_read_addr 0 4210 NULL
103456 +ath6kl_force_roam_write_4282 ath6kl_force_roam_write 3 4282 NULL
103457 +goldfish_audio_write_4284 goldfish_audio_write 3 4284 NULL
103458 +msb_do_write_request_4286 msb_do_write_request 2 4286 NULL
103459 +paging32_page_fault_4288 paging32_page_fault 2 4288 NULL
103460 +xt_compat_add_offset_4289 xt_compat_add_offset 0 4289 NULL
103461 +__usbnet_read_cmd_4299 __usbnet_read_cmd 7 4299 NULL
103462 +dvb_ringbuffer_pkt_read_user_4303 dvb_ringbuffer_pkt_read_user 3-2-5 4303 NULL
103463 +__pool_find_4308 __pool_find 3 4308 NULL
103464 +count_strings_4315 count_strings 0 4315 NULL
103465 +nouveau_fifo_create__4327 nouveau_fifo_create_ 5-6 4327 NULL
103466 +snd_rawmidi_kernel_read_4328 snd_rawmidi_kernel_read 3 4328 NULL
103467 +kvm_apic_get_reg_4354 kvm_apic_get_reg 0 4354 NULL
103468 +__copy_from_user_inatomic_4365 __copy_from_user_inatomic 0-3 4365 NULL nohasharray
103469 +lookup_string_4365 lookup_string 0 4365 &__copy_from_user_inatomic_4365
103470 +btrfs_set_disk_extent_flags_4374 btrfs_set_disk_extent_flags 0 4374 NULL
103471 +irda_sendmsg_4388 irda_sendmsg 4 4388 NULL
103472 +access_process_vm_4412 access_process_vm 0-4-2 4412 NULL nohasharray
103473 +cxacru_cm_get_array_4412 cxacru_cm_get_array 4 4412 &access_process_vm_4412
103474 +libfc_vport_create_4415 libfc_vport_create 2 4415 NULL
103475 +rtw_android_get_rssi_4421 rtw_android_get_rssi 0 4421 NULL
103476 +do_pages_stat_4437 do_pages_stat 2 4437 NULL
103477 +memparse_4444 memparse 0 4444 NULL
103478 +tcp_dma_try_early_copy_4457 tcp_dma_try_early_copy 3 4457 NULL
103479 +at76_set_card_command_4471 at76_set_card_command 4 4471 NULL
103480 +snd_seq_expand_var_event_4481 snd_seq_expand_var_event 5-0 4481 NULL
103481 +ocfs2_grow_tree_4492 ocfs2_grow_tree 0 4492 NULL
103482 +vmbus_establish_gpadl_4495 vmbus_establish_gpadl 3 4495 NULL
103483 +set_link_security_4502 set_link_security 4 4502 NULL
103484 +dm_cache_remove_mapping_4513 dm_cache_remove_mapping 2 4513 NULL
103485 +__gfn_to_pfn_memslot_4530 __gfn_to_pfn_memslot 2-0 4530 NULL
103486 +ll_max_readahead_per_file_mb_seq_write_4531 ll_max_readahead_per_file_mb_seq_write 3 4531 NULL
103487 +da9052_group_write_4534 da9052_group_write 2-3 4534 NULL
103488 +tty_register_device_4544 tty_register_device 2 4544 NULL
103489 +videobuf_vmalloc_to_sg_4548 videobuf_vmalloc_to_sg 2 4548 NULL
103490 +btrfs_file_extent_inline_item_len_4575 btrfs_file_extent_inline_item_len 0 4575 NULL
103491 +xfs_buf_get_maps_4581 xfs_buf_get_maps 2 4581 NULL
103492 +iommu_map_page_4588 iommu_map_page 5 4588 NULL
103493 +bch_alloc_4593 bch_alloc 1 4593 NULL
103494 +ocfs2_refcount_lock_4595 ocfs2_refcount_lock 0 4595 NULL
103495 +__wb_force_remove_mapping_4622 __wb_force_remove_mapping 2 4622 NULL
103496 +ll_rw_extents_stats_seq_write_4633 ll_rw_extents_stats_seq_write 3 4633 NULL
103497 +iwl_dbgfs_tx_queue_read_4635 iwl_dbgfs_tx_queue_read 3 4635 NULL
103498 +ext3_orphan_add_4665 ext3_orphan_add 0 4665 NULL
103499 +skb_add_data_nocache_4682 skb_add_data_nocache 4 4682 NULL
103500 +cx18_read_pos_4683 cx18_read_pos 3 4683 NULL
103501 +short_retry_limit_read_4687 short_retry_limit_read 3 4687 NULL
103502 +kone_receive_4690 kone_receive 4 4690 NULL
103503 +link_to_fixup_dir_4699 link_to_fixup_dir 0 4699 NULL
103504 +cxgbi_alloc_big_mem_4707 cxgbi_alloc_big_mem 1 4707 NULL
103505 +konepure_sysfs_read_4709 konepure_sysfs_read 6 4709 NULL
103506 +ati_create_gatt_pages_4722 ati_create_gatt_pages 1 4722 NULL nohasharray
103507 +show_header_4722 show_header 3 4722 &ati_create_gatt_pages_4722
103508 +gfs2_bit_search_4728 gfs2_bit_search 0-2 4728 NULL
103509 +ll_rw_offset_stats_seq_write_4736 ll_rw_offset_stats_seq_write 3 4736 NULL nohasharray
103510 +bitmap_startwrite_4736 bitmap_startwrite 2 4736 &ll_rw_offset_stats_seq_write_4736
103511 +__find_free_cblock_4741 __find_free_cblock 2 4741 NULL
103512 +lu_buf_alloc_4753 lu_buf_alloc 2 4753 NULL
103513 +find_next_best_node_4774 find_next_best_node 1-0 4774 NULL nohasharray
103514 +pwr_rcvd_bcns_cnt_read_4774 pwr_rcvd_bcns_cnt_read 3 4774 &find_next_best_node_4774
103515 +btrfs_del_items_4791 btrfs_del_items 0 4791 NULL nohasharray
103516 +create_subvol_4791 create_subvol 4 4791 &btrfs_del_items_4791
103517 +ncp__vol2io_4804 ncp__vol2io 5 4804 NULL
103518 +repair_io_failure_4815 repair_io_failure 4-3 4815 NULL
103519 +comedi_buf_write_free_4847 comedi_buf_write_free 2 4847 NULL
103520 +gigaset_if_receive_4861 gigaset_if_receive 3 4861 NULL
103521 +key_tx_spec_read_4862 key_tx_spec_read 3 4862 NULL
103522 +get_new_location_4866 get_new_location 0 4866 NULL
103523 +ocfs2_defrag_extent_4873 ocfs2_defrag_extent 3-2 4873 NULL
103524 +hid_register_field_4874 hid_register_field 2-3 4874 NULL
103525 +vga_arb_read_4886 vga_arb_read 3 4886 NULL
103526 +ntfs_rl_insert_4931 ntfs_rl_insert 4-2 4931 NULL
103527 +ieee80211_if_fmt_ave_beacon_4941 ieee80211_if_fmt_ave_beacon 3 4941 NULL
103528 +ocfs2_should_refresh_lock_res_4958 ocfs2_should_refresh_lock_res 0 4958 NULL
103529 +compat_rawv6_setsockopt_4967 compat_rawv6_setsockopt 5 4967 NULL
103530 +skb_network_header_len_4971 skb_network_header_len 0 4971 NULL
103531 +ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval_4976 ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval 3 4976 NULL
103532 +do_sync_read_4977 do_sync_read 0 4977 NULL
103533 +vmw_surface_define_size_4993 vmw_surface_define_size 0 4993 NULL
103534 +compat_SyS_ipc_5000 compat_SyS_ipc 3 5000 NULL
103535 +do_mincore_5018 do_mincore 0-2-1 5018 NULL
103536 +btrfs_punch_hole_5041 btrfs_punch_hole 2 5041 NULL
103537 +cfg80211_rx_mgmt_5056 cfg80211_rx_mgmt 5 5056 NULL
103538 +ocfs2_check_range_for_holes_5066 ocfs2_check_range_for_holes 3-2 5066 NULL
103539 +snd_mixart_BA1_read_5082 snd_mixart_BA1_read 5 5082 NULL
103540 +snd_emu10k1_ptr20_read_5087 snd_emu10k1_ptr20_read 0 5087 NULL
103541 +get_random_bytes_5091 get_random_bytes 2 5091 NULL nohasharray
103542 +kfifo_copy_from_user_5091 kfifo_copy_from_user 4-3-0 5091 &get_random_bytes_5091 nohasharray
103543 +blk_rq_sectors_5091 blk_rq_sectors 0 5091 &kfifo_copy_from_user_5091
103544 +sound_write_5102 sound_write 3 5102 NULL
103545 +clear_dirty_5105 clear_dirty 3 5105 NULL
103546 +i40e_dbg_netdev_ops_write_5117 i40e_dbg_netdev_ops_write 3 5117 NULL
103547 +qib_7220_handle_hwerrors_5142 qib_7220_handle_hwerrors 3 5142 NULL
103548 +ufs_add_fragments_5144 ufs_add_fragments 2 5144 NULL
103549 +ocfs2_inode_lock_full_nested_5148 ocfs2_inode_lock_full_nested 0 5148 NULL
103550 +__uwb_addr_print_5161 __uwb_addr_print 2 5161 NULL
103551 +iwl_dbgfs_status_read_5171 iwl_dbgfs_status_read 3 5171 NULL
103552 +acpi_pcc_get_sqty_5176 acpi_pcc_get_sqty 0 5176 NULL
103553 +ppp_cp_parse_cr_5214 ppp_cp_parse_cr 4 5214 NULL nohasharray
103554 +r600_mip_minify_5214 r600_mip_minify 2-1-0 5214 &ppp_cp_parse_cr_5214
103555 +dwc2_hcd_urb_alloc_5217 dwc2_hcd_urb_alloc 2 5217 NULL
103556 +ath6kl_debug_roam_tbl_event_5224 ath6kl_debug_roam_tbl_event 3 5224 NULL
103557 +nouveau_fb_create__5244 nouveau_fb_create_ 5 5244 NULL
103558 +gfn_to_hva_memslot_5265 gfn_to_hva_memslot 2 5265 NULL
103559 +btrfs_alloc_reserved_file_extent_5274 btrfs_alloc_reserved_file_extent 0 5274 NULL
103560 +iommu_domain_identity_map_5284 iommu_domain_identity_map 2-3 5284 NULL
103561 +alloc_cache_blocks_with_hash_5285 alloc_cache_blocks_with_hash 2 5285 NULL
103562 +usb_descriptor_fillbuf_5302 usb_descriptor_fillbuf 0 5302 NULL
103563 +__gfn_to_hva_memslot_5304 __gfn_to_hva_memslot 0-2 5304 NULL
103564 +r592_write_fifo_pio_5315 r592_write_fifo_pio 3 5315 NULL
103565 +sbc_get_write_same_sectors_5317 sbc_get_write_same_sectors 0 5317 NULL
103566 +pwr_elp_enter_read_5324 pwr_elp_enter_read 3 5324 NULL
103567 +allocate_cnodes_5329 allocate_cnodes 1 5329 NULL
103568 +vm_insert_pfn_5341 vm_insert_pfn 3-0 5341 NULL
103569 +cq_free_res_5355 cq_free_res 5 5355 NULL
103570 +ps_pspoll_utilization_read_5361 ps_pspoll_utilization_read 3 5361 NULL
103571 +cciss_allocate_sg_chain_blocks_5368 cciss_allocate_sg_chain_blocks 2-3 5368 NULL
103572 +kvm_pin_pages_5369 kvm_pin_pages 2-0 5369 NULL
103573 +bitmap_fold_5396 bitmap_fold 4 5396 NULL
103574 +security_inode_init_security_5408 security_inode_init_security 0 5408 NULL
103575 +__resolve_indirect_refs_5409 __resolve_indirect_refs 0 5409 NULL
103576 +nilfs_palloc_entries_per_group_5418 nilfs_palloc_entries_per_group 0 5418 NULL
103577 +check_item_in_log_5440 check_item_in_log 0 5440 NULL
103578 +__split_bvec_across_targets_5454 __split_bvec_across_targets 3 5454 NULL
103579 +xfs_efd_init_5463 xfs_efd_init 3 5463 NULL
103580 +xfs_efi_init_5476 xfs_efi_init 2 5476 NULL
103581 +ubi_leb_write_5478 ubi_leb_write 4-5 5478 NULL
103582 +cifs_security_flags_proc_write_5484 cifs_security_flags_proc_write 3 5484 NULL
103583 +tty_write_5494 tty_write 3 5494 NULL
103584 +tomoyo_update_domain_5498 tomoyo_update_domain 2 5498 NULL nohasharray
103585 +ieee80211_if_fmt_last_beacon_5498 ieee80211_if_fmt_last_beacon 3 5498 &tomoyo_update_domain_5498
103586 +__max_nr_grant_frames_5505 __max_nr_grant_frames 0 5505 NULL
103587 +ieee80211_if_fmt_auto_open_plinks_5534 ieee80211_if_fmt_auto_open_plinks 3 5534 NULL
103588 +iommu_prepare_identity_map_5540 iommu_prepare_identity_map 2-3 5540 NULL
103589 +get_entry_msg_len_5552 get_entry_msg_len 0 5552 NULL
103590 +le_readq_5557 le_readq 0 5557 NULL
103591 +inw_5558 inw 0 5558 NULL
103592 +bioset_create_5580 bioset_create 1 5580 NULL
103593 +domain_sg_mapping_5586 domain_sg_mapping 4 5586 NULL
103594 +oz_ep_alloc_5587 oz_ep_alloc 1 5587 NULL
103595 +ldm_frag_add_5611 ldm_frag_add 2 5611 NULL
103596 +compat_copy_entries_5617 compat_copy_entries 0 5617 NULL
103597 +SYSC_init_module_5626 SYSC_init_module 2 5626 NULL
103598 +iterate_extent_inodes_5631 iterate_extent_inodes 0 5631 NULL
103599 +SYSC_fsetxattr_5639 SYSC_fsetxattr 4 5639 NULL
103600 +ext4_xattr_get_5661 ext4_xattr_get 0 5661 NULL
103601 +posix_clock_register_5662 posix_clock_register 2 5662 NULL
103602 +kgdb_arch_pc_5673 kgdb_arch_pc 0 5673 NULL
103603 +wb_clear_dirty_5684 wb_clear_dirty 2 5684 NULL
103604 +get_arg_5694 get_arg 3 5694 NULL
103605 +subbuf_read_actor_5708 subbuf_read_actor 3 5708 NULL
103606 +ntfs_attr_record_resize_5720 ntfs_attr_record_resize 0 5720 NULL
103607 +vmw_kms_readback_5727 vmw_kms_readback 6 5727 NULL
103608 +rts51x_transfer_data_partial_5735 rts51x_transfer_data_partial 6 5735 NULL
103609 +ubi_calc_fm_size_5749 ubi_calc_fm_size 0 5749 NULL
103610 +sctp_setsockopt_autoclose_5775 sctp_setsockopt_autoclose 3 5775 NULL
103611 +__vxge_hw_blockpool_malloc_5786 __vxge_hw_blockpool_malloc 2 5786 NULL
103612 +nvme_trans_bdev_char_page_5797 nvme_trans_bdev_char_page 3 5797 NULL
103613 +skb_copy_datagram_iovec_5806 skb_copy_datagram_iovec 2-4 5806 NULL
103614 +nv50_disp_pioc_create__5812 nv50_disp_pioc_create_ 5 5812 NULL
103615 +ceph_x_encrypt_buflen_5829 ceph_x_encrypt_buflen 0-1 5829 NULL
103616 +ceph_msg_new_5846 ceph_msg_new 2 5846 NULL
103617 +setup_req_5848 setup_req 3 5848 NULL
103618 +ria_page_count_5849 ria_page_count 0 5849 NULL
103619 +rx_filter_max_arp_queue_dep_read_5851 rx_filter_max_arp_queue_dep_read 3 5851 NULL
103620 +config_buf_5862 config_buf 0 5862 NULL
103621 +ext4_ext_correct_indexes_5865 ext4_ext_correct_indexes 0 5865 NULL
103622 +paging64_walk_addr_5887 paging64_walk_addr 3 5887 NULL
103623 +scan_bitmap_5888 scan_bitmap 3 5888 NULL
103624 +lprocfs_fid_width_seq_write_5889 lprocfs_fid_width_seq_write 3 5889 NULL
103625 +port_show_regs_5904 port_show_regs 3 5904 NULL
103626 +rbd_segment_length_5907 rbd_segment_length 0-3-2 5907 NULL
103627 +uhci_debug_read_5911 uhci_debug_read 3 5911 NULL
103628 +lbs_highsnr_read_5931 lbs_highsnr_read 3 5931 NULL
103629 +ps_poll_ps_poll_timeouts_read_5934 ps_poll_ps_poll_timeouts_read 3 5934 NULL
103630 +edac_device_alloc_ctl_info_5941 edac_device_alloc_ctl_info 1 5941 NULL
103631 +find_parent_nodes_5948 find_parent_nodes 0 5948 NULL
103632 +ll_statahead_one_5962 ll_statahead_one 3 5962 NULL
103633 +__apu_get_register_5967 __apu_get_register 0 5967 NULL
103634 +ieee80211_if_fmt_rc_rateidx_mask_5ghz_5971 ieee80211_if_fmt_rc_rateidx_mask_5ghz 3 5971 NULL
103635 +native_pte_val_5978 native_pte_val 0 5978 NULL
103636 +jbd2_journal_stop_5979 jbd2_journal_stop 0 5979 NULL
103637 +ntfs_rl_append_6037 ntfs_rl_append 4-2 6037 NULL
103638 +da9052_request_irq_6058 da9052_request_irq 2 6058 NULL nohasharray
103639 +device_add_attributes_6058 device_add_attributes 0 6058 &da9052_request_irq_6058
103640 +alloc_msg_6072 alloc_msg 1 6072 NULL
103641 +sctp_setsockopt_connectx_6073 sctp_setsockopt_connectx 3 6073 NULL
103642 +rts51x_ms_rw_multi_sector_6076 rts51x_ms_rw_multi_sector 3-4 6076 NULL
103643 +md_trim_bio_6078 md_trim_bio 2 6078 NULL
103644 +finish_inode_if_needed_6098 finish_inode_if_needed 0 6098 NULL
103645 +ipmi_addr_length_6110 ipmi_addr_length 0 6110 NULL
103646 +dfs_global_file_write_6112 dfs_global_file_write 3 6112 NULL
103647 +nouveau_parent_create__6131 nouveau_parent_create_ 7 6131 NULL
103648 +__btrfs_commit_inode_delayed_items_6150 __btrfs_commit_inode_delayed_items 0 6150 NULL
103649 +ieee80211_if_fmt_beacon_timeout_6153 ieee80211_if_fmt_beacon_timeout 3 6153 NULL
103650 +ivtv_copy_buf_to_user_6159 ivtv_copy_buf_to_user 4 6159 NULL
103651 +vdma_mem_alloc_6171 vdma_mem_alloc 1 6171 NULL
103652 +wl1251_cmd_template_set_6172 wl1251_cmd_template_set 4 6172 NULL
103653 +paging64_walk_addr_generic_6180 paging64_walk_addr_generic 4 6180 NULL
103654 +SyS_setgroups_6182 SyS_setgroups 1 6182 NULL
103655 +__add_pin_to_irq_node_6188 __add_pin_to_irq_node 2 6188 NULL
103656 +qp_host_get_user_memory_6189 qp_host_get_user_memory 1-2 6189 NULL
103657 +cl_sync_io_wait_6196 cl_sync_io_wait 0 6196 NULL
103658 +i915_gem_execbuffer_move_to_gpu_6197 i915_gem_execbuffer_move_to_gpu 0 6197 NULL
103659 +mxt_show_instance_6207 mxt_show_instance 2-0 6207 NULL
103660 +v4l2_ctrl_new_std_menu_6221 v4l2_ctrl_new_std_menu 4 6221 NULL
103661 +mqueue_read_file_6228 mqueue_read_file 3 6228 NULL
103662 +f_hidg_read_6238 f_hidg_read 3 6238 NULL
103663 +changed_ref_6242 changed_ref 0 6242 NULL
103664 +fbcon_prepare_logo_6246 fbcon_prepare_logo 5 6246 NULL
103665 +ext4_ext_split_6249 ext4_ext_split 0 6249 NULL
103666 +pcpu_next_pop_6277 pcpu_next_pop 4 6277 NULL
103667 +tx_tx_start_null_frame_read_6281 tx_tx_start_null_frame_read 3 6281 NULL
103668 +snd_hda_override_conn_list_6282 snd_hda_override_conn_list 3-0 6282 NULL nohasharray
103669 +xenbus_file_write_6282 xenbus_file_write 3 6282 &snd_hda_override_conn_list_6282
103670 +posix_acl_fix_xattr_to_user_6283 posix_acl_fix_xattr_to_user 2 6283 NULL
103671 +paging64_gva_to_gpa_nested_6287 paging64_gva_to_gpa_nested 2 6287 NULL
103672 +qlcnic_sriov_alloc_bc_msg_6309 qlcnic_sriov_alloc_bc_msg 2 6309 NULL
103673 +exclude_super_stripes_6326 exclude_super_stripes 0 6326 NULL
103674 +SyS_mincore_6329 SyS_mincore 2-1 6329 NULL nohasharray
103675 +hfa384x_inw_6329 hfa384x_inw 0 6329 &SyS_mincore_6329
103676 +fuse_get_req_for_background_6337 fuse_get_req_for_background 2 6337 NULL
103677 +ucs2_strnlen_6342 ucs2_strnlen 0 6342 NULL
103678 +utc2ntfs_6347 utc2ntfs 0 6347 NULL
103679 +regcache_sync_block_raw_6350 regcache_sync_block_raw 5-4 6350 NULL
103680 +mei_dbgfs_read_devstate_6352 mei_dbgfs_read_devstate 3 6352 NULL
103681 +_proc_do_string_6376 _proc_do_string 2 6376 NULL
103682 +osd_req_read_sg_kern_6378 osd_req_read_sg_kern 5 6378 NULL
103683 +msb_write_block_6379 msb_write_block 3 6379 NULL
103684 +BcmFlash2xBulkRead_6395 BcmFlash2xBulkRead 0 6395 NULL
103685 +posix_acl_fix_xattr_userns_6420 posix_acl_fix_xattr_userns 4 6420 NULL
103686 +add_transaction_credits_6422 add_transaction_credits 2-3 6422 NULL
103687 +ipr_change_queue_depth_6431 ipr_change_queue_depth 2 6431 NULL
103688 +__alloc_bootmem_node_nopanic_6432 __alloc_bootmem_node_nopanic 2 6432 NULL
103689 +add_to_list_6433 add_to_list 0 6433 NULL
103690 +paging32_gva_to_gpa_nested_6442 paging32_gva_to_gpa_nested 2 6442 NULL
103691 +i915_gem_object_wait_rendering_6446 i915_gem_object_wait_rendering 0 6446 NULL
103692 +mlx4_ib_reg_user_mr_6471 mlx4_ib_reg_user_mr 2-3 6471 NULL
103693 +ieee80211_if_fmt_dot11MeshMaxRetries_6476 ieee80211_if_fmt_dot11MeshMaxRetries 3 6476 NULL
103694 +qp_memcpy_from_queue_6479 qp_memcpy_from_queue 5-4 6479 NULL
103695 +cipso_v4_map_lvl_hton_6490 cipso_v4_map_lvl_hton 0 6490 NULL
103696 +ntfs_cluster_free_6497 ntfs_cluster_free 0 6497 NULL
103697 +dbg_intr_buf_6501 dbg_intr_buf 2 6501 NULL
103698 +mei_read_6507 mei_read 3 6507 NULL
103699 +__start_delalloc_inodes_6528 __start_delalloc_inodes 0 6528 NULL
103700 +rndis_set_oid_6547 rndis_set_oid 4 6547 NULL
103701 +wdm_read_6549 wdm_read 3 6549 NULL
103702 +dm_stats_create_6551 dm_stats_create 4-2-3 6551 NULL
103703 +fb_alloc_cmap_6554 fb_alloc_cmap 2 6554 NULL
103704 +SyS_semtimedop_6563 SyS_semtimedop 3 6563 NULL
103705 +SyS_fcntl64_6582 SyS_fcntl64 3 6582 NULL
103706 +snd_pcm_hw_refine_old_user_6586 snd_pcm_hw_refine_old_user 0 6586 NULL
103707 +btrfs_start_all_delalloc_inodes_6596 btrfs_start_all_delalloc_inodes 0 6596 NULL
103708 +snmp_mib_init_6604 snmp_mib_init 2-3 6604 NULL
103709 +ecryptfs_filldir_6622 ecryptfs_filldir 3 6622 NULL
103710 +xfs_do_div_6649 xfs_do_div 0-2 6649 NULL
103711 +journal_dirty_metadata_6658 journal_dirty_metadata 0 6658 NULL
103712 +process_rcvd_data_6679 process_rcvd_data 3 6679 NULL
103713 +btrfs_lookup_csums_range_6696 btrfs_lookup_csums_range 2-3-0 6696 NULL
103714 +ps_pspoll_max_apturn_read_6699 ps_pspoll_max_apturn_read 3 6699 NULL
103715 +bnad_debugfs_write_regrd_6706 bnad_debugfs_write_regrd 3 6706 NULL
103716 +mpeg_read_6708 mpeg_read 3 6708 NULL
103717 +ibmpex_query_sensor_count_6709 ibmpex_query_sensor_count 0 6709 NULL
103718 +set_orig_insn_6712 set_orig_insn 3 6712 NULL
103719 +video_proc_write_6724 video_proc_write 3 6724 NULL
103720 +posix_acl_xattr_count_6725 posix_acl_xattr_count 0-1 6725 NULL
103721 +ocfs2_insert_extent_6737 ocfs2_insert_extent 0 6737 NULL
103722 +btrfs_inode_delayed_dir_index_count_6759 btrfs_inode_delayed_dir_index_count 0 6759 NULL
103723 +kobject_add_varg_6781 kobject_add_varg 0 6781 NULL
103724 +iwl_dbgfs_channels_read_6784 iwl_dbgfs_channels_read 3 6784 NULL
103725 +ieee80211_if_read_6785 ieee80211_if_read 3 6785 NULL
103726 +zone_spanned_pages_in_node_6787 zone_spanned_pages_in_node 0-3-4 6787 NULL
103727 +hdlcdrv_register_6792 hdlcdrv_register 2 6792 NULL
103728 +tx_tx_done_data_read_6799 tx_tx_done_data_read 3 6799 NULL
103729 +ocfs2_calc_refcount_meta_credits_6802 ocfs2_calc_refcount_meta_credits 0 6802 NULL
103730 +lbs_rdrf_write_6826 lbs_rdrf_write 3 6826 NULL
103731 +make_8259A_irq_6828 make_8259A_irq 1 6828 NULL
103732 +calc_pages_for_6838 calc_pages_for 0-1-2 6838 NULL
103733 +mon_bin_read_6841 mon_bin_read 3 6841 NULL
103734 +snd_cs4281_BA0_read_6847 snd_cs4281_BA0_read 5 6847 NULL
103735 +ecryptfs_write_lower_6870 ecryptfs_write_lower 4 6870 NULL
103736 +dio_complete_6879 dio_complete 0-2-3 6879 NULL
103737 +ieee80211_if_fmt_path_refresh_time_6888 ieee80211_if_fmt_path_refresh_time 3 6888 NULL nohasharray
103738 +raw_seticmpfilter_6888 raw_seticmpfilter 3 6888 &ieee80211_if_fmt_path_refresh_time_6888
103739 +dlmfs_file_write_6892 dlmfs_file_write 3 6892 NULL
103740 +ext4_inode_bitmap_6902 ext4_inode_bitmap 0 6902 NULL
103741 +spi_show_regs_6911 spi_show_regs 3 6911 NULL nohasharray
103742 +proc_sessionid_read_6911 proc_sessionid_read 3 6911 &spi_show_regs_6911 nohasharray
103743 +acm_alloc_minor_6911 acm_alloc_minor 0 6911 &proc_sessionid_read_6911
103744 +__kfifo_dma_in_finish_r_6913 __kfifo_dma_in_finish_r 2-3 6913 NULL
103745 +do_msgrcv_6921 do_msgrcv 3 6921 NULL
103746 +__vxge_hw_mempool_create_6923 __vxge_hw_mempool_create 3-2-6 6923 NULL
103747 +cache_do_downcall_6926 cache_do_downcall 3 6926 NULL
103748 +ipath_verbs_send_dma_6929 ipath_verbs_send_dma 6 6929 NULL
103749 +qsfp_cks_6945 qsfp_cks 2-0 6945 NULL
103750 +tg3_nvram_write_block_unbuffered_6955 tg3_nvram_write_block_unbuffered 3 6955 NULL
103751 +pch_uart_hal_read_6961 pch_uart_hal_read 0 6961 NULL
103752 +videobuf_dma_init_kernel_6963 videobuf_dma_init_kernel 3 6963 NULL
103753 +i40e_dbg_dump_write_6973 i40e_dbg_dump_write 3 6973 NULL nohasharray
103754 +rsa_extract_mpi_6973 rsa_extract_mpi 5 6973 &i40e_dbg_dump_write_6973
103755 +crypto_authenc_esn_setkey_6985 crypto_authenc_esn_setkey 3 6985 NULL
103756 +request_key_async_6990 request_key_async 4 6990 NULL
103757 +tpl_write_6998 tpl_write 3 6998 NULL
103758 +r871x_set_wpa_ie_7000 r871x_set_wpa_ie 3 7000 NULL
103759 +log_wait_commit_7005 log_wait_commit 0 7005 NULL
103760 +cipso_v4_gentag_enum_7006 cipso_v4_gentag_enum 0 7006 NULL
103761 +tracing_cpumask_read_7010 tracing_cpumask_read 3 7010 NULL
103762 +ld_usb_write_7022 ld_usb_write 3 7022 NULL
103763 +wimax_msg_7030 wimax_msg 4 7030 NULL
103764 +ipath_get_base_info_7043 ipath_get_base_info 3 7043 NULL
103765 +snd_pcm_oss_bytes_7051 snd_pcm_oss_bytes 2 7051 NULL
103766 +hci_sock_recvmsg_7072 hci_sock_recvmsg 4 7072 NULL
103767 +event_enable_read_7074 event_enable_read 3 7074 NULL
103768 +ip_vs_sync_conn_7075 ip_vs_sync_conn 3 7075 NULL
103769 +beacon_interval_read_7091 beacon_interval_read 3 7091 NULL
103770 +pipeline_enc_rx_stat_fifo_int_read_7107 pipeline_enc_rx_stat_fifo_int_read 3 7107 NULL
103771 +check_header_7108 check_header 0 7108 NULL
103772 +osc_resend_count_seq_write_7120 osc_resend_count_seq_write 3 7120 NULL
103773 +qib_format_hwerrors_7133 qib_format_hwerrors 5 7133 NULL
103774 +kvm_mmu_notifier_test_young_7139 kvm_mmu_notifier_test_young 3 7139 NULL
103775 +ipv6_recv_rxpmtu_7142 ipv6_recv_rxpmtu 3 7142 NULL
103776 +qlcnic_enable_msix_7144 qlcnic_enable_msix 2 7144 NULL
103777 +ocfs2_get_left_path_7159 ocfs2_get_left_path 0 7159 NULL
103778 +core_alua_write_tpg_metadata_7168 core_alua_write_tpg_metadata 3 7168 NULL
103779 +ext3_xattr_ibody_list_7201 ext3_xattr_ibody_list 3-0 7201 NULL
103780 +__alloc_objio_seg_7203 __alloc_objio_seg 1 7203 NULL
103781 +get_param_h_7247 get_param_h 0 7247 NULL
103782 +af_alg_make_sg_7254 af_alg_make_sg 3-0 7254 NULL
103783 +hdlc_loop_7255 hdlc_loop 0 7255 NULL
103784 +vm_mmap_pgoff_7259 vm_mmap_pgoff 0 7259 NULL
103785 +snd_mask_refine_7267 snd_mask_refine 0 7267 NULL
103786 +f_midi_start_ep_7270 f_midi_start_ep 0 7270 NULL
103787 +dma_ops_alloc_addresses_7272 dma_ops_alloc_addresses 3-4-5-0 7272 NULL
103788 +rx_rate_rx_frames_per_rates_read_7282 rx_rate_rx_frames_per_rates_read 3 7282 NULL
103789 +get_string_7302 get_string 0 7302 NULL
103790 +wb_remove_mapping_7307 wb_remove_mapping 2 7307 NULL
103791 +wait_on_sync_kiocb_7327 wait_on_sync_kiocb 0 7327 NULL
103792 +mgmt_control_7349 mgmt_control 3 7349 NULL
103793 +max8998_irq_domain_map_7359 max8998_irq_domain_map 2 7359 NULL
103794 +i915_gem_do_execbuffer_7362 i915_gem_do_execbuffer 0 7362 NULL nohasharray
103795 +ext3_free_blocks_7362 ext3_free_blocks 3-4 7362 &i915_gem_do_execbuffer_7362
103796 +at_est2timeout_7365 at_est2timeout 0-1 7365 NULL
103797 +ieee80211_if_read_dot11MeshHWMPactivePathTimeout_7368 ieee80211_if_read_dot11MeshHWMPactivePathTimeout 3 7368 NULL
103798 +schedule_timeout_7371 schedule_timeout 0 7371 NULL
103799 +ath10k_read_fw_stats_7387 ath10k_read_fw_stats 3 7387 NULL
103800 +hweight_long_7388 hweight_long 1-0 7388 NULL
103801 +sl_change_mtu_7396 sl_change_mtu 2 7396 NULL
103802 +_ore_add_stripe_unit_7399 _ore_add_stripe_unit 6-3 7399 NULL
103803 +readb_7401 readb 0 7401 NULL
103804 +drm_property_create_blob_7414 drm_property_create_blob 2 7414 NULL
103805 +ip_options_get_alloc_7448 ip_options_get_alloc 1 7448 NULL
103806 +SYSC_setgroups_7454 SYSC_setgroups 1 7454 NULL
103807 +rt2x00debug_read_queue_stats_7455 rt2x00debug_read_queue_stats 3 7455 NULL
103808 +l2tp_ip6_sendmsg_7461 l2tp_ip6_sendmsg 4 7461 NULL
103809 +ReadHSCX_7471 ReadHSCX 0 7471 NULL nohasharray
103810 +garp_request_join_7471 garp_request_join 4 7471 &ReadHSCX_7471
103811 +snd_pcm_lib_read1_7491 snd_pcm_lib_read1 0-3 7491 NULL
103812 +iwl_mvm_power_dbgfs_read_7502 iwl_mvm_power_dbgfs_read 0 7502 NULL
103813 +sdhci_alloc_host_7509 sdhci_alloc_host 2 7509 NULL nohasharray
103814 +ahash_instance_headroom_7509 ahash_instance_headroom 0 7509 &sdhci_alloc_host_7509
103815 +array_zalloc_7519 array_zalloc 2-1 7519 NULL
103816 +btrfs_insert_xattr_item_7545 btrfs_insert_xattr_item 0 7545 NULL
103817 +goal_in_my_reservation_7553 goal_in_my_reservation 3 7553 NULL
103818 +smk_read_mapped_7562 smk_read_mapped 3 7562 NULL
103819 +cfs_cpt_num_estimate_7571 cfs_cpt_num_estimate 0 7571 NULL
103820 +ext4_ext_insert_extent_7576 ext4_ext_insert_extent 0 7576 NULL
103821 +btrfs_block_rsv_add_7579 btrfs_block_rsv_add 3-0 7579 NULL
103822 +ext3_try_to_allocate_7590 ext3_try_to_allocate 5-3-0 7590 NULL
103823 +ocfs2_lock_create_7612 ocfs2_lock_create 0 7612 NULL
103824 +create_dir_7614 create_dir 0 7614 NULL nohasharray
103825 +groups_alloc_7614 groups_alloc 1 7614 &create_dir_7614
103826 +_rtw_zmalloc_7636 _rtw_zmalloc 1 7636 NULL
103827 +fault_inject_write_7662 fault_inject_write 3 7662 NULL
103828 +acpi_ex_allocate_name_string_7685 acpi_ex_allocate_name_string 1-2 7685 NULL
103829 +acpi_ns_get_pathname_length_7699 acpi_ns_get_pathname_length 0 7699 NULL
103830 +dev_write_7708 dev_write 3 7708 NULL
103831 +unmap_region_7709 unmap_region 1 7709 NULL
103832 +dbg_check_cats_7713 dbg_check_cats 0 7713 NULL
103833 +pci_raw_set_power_state_7729 pci_raw_set_power_state 0 7729 NULL
103834 +vxge_device_register_7752 vxge_device_register 4 7752 NULL
103835 +ubi_io_read_vid_hdr_7766 ubi_io_read_vid_hdr 0 7766 NULL
103836 +paths_from_inode_7774 paths_from_inode 0 7774 NULL
103837 +alloc_candev_7776 alloc_candev 1-2 7776 NULL
103838 +dfs_global_file_read_7787 dfs_global_file_read 3 7787 NULL
103839 +bnx2_nvram_write_7790 bnx2_nvram_write 2-4 7790 NULL
103840 +diva_os_copy_from_user_7792 diva_os_copy_from_user 4 7792 NULL nohasharray
103841 +lustre_packed_msg_size_7792 lustre_packed_msg_size 0 7792 &diva_os_copy_from_user_7792
103842 +ubifs_leb_read_7828 ubifs_leb_read 0 7828 NULL
103843 +cfs_trace_dump_debug_buffer_usrstr_7861 cfs_trace_dump_debug_buffer_usrstr 2 7861 NULL
103844 +tipc_alloc_entry_7875 tipc_alloc_entry 2 7875 NULL
103845 +btrfs_find_space_for_alloc_7876 btrfs_find_space_for_alloc 2 7876 NULL
103846 +config_desc_7878 config_desc 0 7878 NULL
103847 +dvb_dmxdev_read_sec_7892 dvb_dmxdev_read_sec 4 7892 NULL
103848 +xfs_trans_get_efi_7898 xfs_trans_get_efi 2 7898 NULL
103849 +ext3_group_extend_7911 ext3_group_extend 3 7911 NULL
103850 +libfc_host_alloc_7917 libfc_host_alloc 2 7917 NULL
103851 +f_hidg_write_7932 f_hidg_write 3 7932 NULL
103852 +io_apic_setup_irq_pin_once_7934 io_apic_setup_irq_pin_once 1-2 7934 NULL
103853 +compare_refs_7938 compare_refs 0 7938 NULL
103854 +fsnotify_7943 fsnotify 0 7943 NULL
103855 +hash_netiface6_expire_7944 hash_netiface6_expire 3 7944 NULL
103856 +integrity_digsig_verify_7956 integrity_digsig_verify 3 7956 NULL
103857 +smk_write_load_self_7958 smk_write_load_self 3 7958 NULL
103858 +bch_btree_to_text_7960 bch_btree_to_text 2 7960 NULL
103859 +fixup_inode_link_count_8002 fixup_inode_link_count 0 8002 NULL
103860 +extend_or_restart_transaction_8008 extend_or_restart_transaction 0 8008 NULL
103861 +tt3650_ci_msg_locked_8013 tt3650_ci_msg_locked 4 8013 NULL
103862 +vcs_read_8017 vcs_read 3 8017 NULL
103863 +vhost_add_used_and_signal_n_8038 vhost_add_used_and_signal_n 4 8038 NULL
103864 +ms_read_multiple_pages_8052 ms_read_multiple_pages 5-4 8052 NULL
103865 +dgrp_mon_read_8065 dgrp_mon_read 3 8065 NULL
103866 +leb_read_lock_8070 leb_read_lock 0 8070 NULL
103867 +spi_write_then_read_8073 spi_write_then_read 5-3 8073 NULL
103868 +alloc_targets_8074 alloc_targets 2 8074 NULL nohasharray
103869 +qla4xxx_post_ping_evt_work_8074 qla4xxx_post_ping_evt_work 4 8074 &alloc_targets_8074
103870 +ext4_ext_map_blocks_8078 ext4_ext_map_blocks 0 8078 NULL
103871 +venus_lookup_8121 venus_lookup 4 8121 NULL
103872 +ieee80211_if_fmt_num_buffered_multicast_8127 ieee80211_if_fmt_num_buffered_multicast 3 8127 NULL
103873 +xfs_iomap_prealloc_size_8141 xfs_iomap_prealloc_size 3 8141 NULL
103874 +dma_map_area_8178 dma_map_area 3-2-5-0 8178 NULL
103875 +ore_truncate_8181 ore_truncate 3 8181 NULL
103876 +__sk_mem_schedule_8185 __sk_mem_schedule 2 8185 NULL
103877 +ieee80211_if_fmt_dot11MeshHoldingTimeout_8187 ieee80211_if_fmt_dot11MeshHoldingTimeout 3 8187 NULL
103878 +update_cowonly_root_8200 update_cowonly_root 0 8200 NULL
103879 +recent_mt_proc_write_8206 recent_mt_proc_write 3 8206 NULL
103880 +__ocfs2_lock_refcount_tree_8207 __ocfs2_lock_refcount_tree 0 8207 NULL
103881 +rt2x00debug_write_bbp_8212 rt2x00debug_write_bbp 3 8212 NULL
103882 +ad7879_spi_multi_read_8218 ad7879_spi_multi_read 3 8218 NULL
103883 +play_iframe_8219 play_iframe 3 8219 NULL
103884 +create_log_8225 create_log 2 8225 NULL nohasharray
103885 +kvm_mmu_page_set_gfn_8225 kvm_mmu_page_set_gfn 2 8225 &create_log_8225
103886 +sctp_ssnmap_size_8228 sctp_ssnmap_size 0-1-2 8228 NULL
103887 +ceph_sync_write_8233 ceph_sync_write 4 8233 NULL
103888 +bnx2x_iov_get_max_queue_count_8235 bnx2x_iov_get_max_queue_count 0 8235 NULL
103889 +check_xattr_ref_inode_8244 check_xattr_ref_inode 0 8244 NULL
103890 +t3_init_l2t_8261 t3_init_l2t 1 8261 NULL
103891 +init_cdev_8274 init_cdev 1 8274 NULL
103892 +rproc_recovery_write_8281 rproc_recovery_write 3 8281 NULL
103893 +qib_decode_7220_err_8315 qib_decode_7220_err 3 8315 NULL
103894 +snd_pcm_update_state_8320 snd_pcm_update_state 0 8320 NULL
103895 +construct_key_and_link_8321 construct_key_and_link 4 8321 NULL
103896 +ipwireless_send_packet_8328 ipwireless_send_packet 4 8328 NULL
103897 +cfs_cpt_spread_node_8338 cfs_cpt_spread_node 0 8338 NULL
103898 +tracing_entries_read_8345 tracing_entries_read 3 8345 NULL
103899 +ieee80211_if_fmt_ht_opmode_8347 ieee80211_if_fmt_ht_opmode 3 8347 NULL
103900 +generic_write_sync_8358 generic_write_sync 0 8358 NULL
103901 +ping_getfrag_8360 ping_getfrag 4-3 8360 NULL
103902 +ath6kl_lrssi_roam_write_8362 ath6kl_lrssi_roam_write 3 8362 NULL
103903 +ocfs2_decrease_refcount_rec_8385 ocfs2_decrease_refcount_rec 0 8385 NULL
103904 +xdi_copy_from_user_8395 xdi_copy_from_user 4 8395 NULL
103905 +zd_rf_scnprint_id_8406 zd_rf_scnprint_id 0-3 8406 NULL
103906 +smk_write_change_rule_8411 smk_write_change_rule 3 8411 NULL nohasharray
103907 +uvc_v4l2_ioctl_8411 uvc_v4l2_ioctl 2 8411 &smk_write_change_rule_8411
103908 +pca953x_gpio_to_irq_8424 pca953x_gpio_to_irq 2 8424 NULL
103909 +irq_create_mapping_8437 irq_create_mapping 2-0 8437 NULL
103910 +generic_bin_search_8440 generic_bin_search 0 8440 NULL
103911 +ring_wait_for_space_8457 ring_wait_for_space 0 8457 NULL
103912 +dir_changed_8471 dir_changed 0 8471 NULL
103913 +afs_cell_lookup_8482 afs_cell_lookup 2 8482 NULL
103914 +fore200e_chunk_alloc_8501 fore200e_chunk_alloc 4-3 8501 NULL
103915 +batadv_tt_len_8502 batadv_tt_len 0-1 8502 NULL
103916 +dev_config_8506 dev_config 3 8506 NULL
103917 +ACL_to_cifs_posix_8509 ACL_to_cifs_posix 3 8509 NULL
103918 +opticon_process_data_packet_8524 opticon_process_data_packet 3 8524 NULL
103919 +alloc_pg_vec_8533 alloc_pg_vec 2 8533 NULL
103920 +ocfs2_read_virt_blocks_8538 ocfs2_read_virt_blocks 2-3 8538 NULL
103921 +user_on_off_8552 user_on_off 2 8552 NULL
103922 +profile_remove_8556 profile_remove 3 8556 NULL
103923 +remove_extent_backref_8559 remove_extent_backref 0 8559 NULL
103924 +cache_slow_downcall_8570 cache_slow_downcall 2 8570 NULL
103925 +isr_dma0_done_read_8574 isr_dma0_done_read 3 8574 NULL
103926 +tower_write_8580 tower_write 3 8580 NULL
103927 +ocfs2_reserve_local_alloc_bits_8581 ocfs2_reserve_local_alloc_bits 0 8581 NULL
103928 +cfs_cpt_number_8618 cfs_cpt_number 0 8618 NULL
103929 +shash_setkey_unaligned_8620 shash_setkey_unaligned 3 8620 NULL
103930 +iommu_unmap_8624 iommu_unmap 2-0 8624 NULL
103931 +it821x_firmware_command_8628 it821x_firmware_command 3 8628 NULL
103932 +scsi_dma_map_8632 scsi_dma_map 0 8632 NULL
103933 +fuse_send_write_pages_8636 fuse_send_write_pages 0-5 8636 NULL
103934 +generic_acl_set_8658 generic_acl_set 4 8658 NULL
103935 +mlx5_vzalloc_8663 mlx5_vzalloc 1 8663 NULL
103936 +dio_bio_alloc_8677 dio_bio_alloc 5 8677 NULL
103937 +lbs_bcnmiss_read_8678 lbs_bcnmiss_read 3 8678 NULL
103938 +tc3589x_gpio_irq_unmap_8680 tc3589x_gpio_irq_unmap 2 8680 NULL
103939 +rproc_trace_read_8686 rproc_trace_read 3 8686 NULL
103940 +skb_frag_size_8695 skb_frag_size 0 8695 NULL
103941 +arcfb_write_8702 arcfb_write 3 8702 NULL
103942 +i_size_read_8703 i_size_read 0 8703 NULL nohasharray
103943 +init_header_8703 init_header 0 8703 &i_size_read_8703
103944 +HDLC_irq_8709 HDLC_irq 2 8709 NULL
103945 +ctrl_out_8712 ctrl_out 5-3 8712 NULL
103946 +__create_free_space_inode_8724 __create_free_space_inode 0 8724 NULL
103947 +tracing_max_lat_write_8728 tracing_max_lat_write 3 8728 NULL
103948 +jffs2_acl_count_8729 jffs2_acl_count 0-1 8729 NULL
103949 +f_dupfd_8730 f_dupfd 1 8730 NULL
103950 +__create_irqs_8733 __create_irqs 2-1-0-3 8733 NULL
103951 +pca953x_gpio_irq_map_8737 pca953x_gpio_irq_map 2 8737 NULL
103952 +tx_tx_exch_expiry_read_8749 tx_tx_exch_expiry_read 3 8749 NULL
103953 +compound_order_8750 compound_order 0 8750 NULL
103954 +ocfs2_find_path_8754 ocfs2_find_path 0 8754 NULL
103955 +yurex_write_8761 yurex_write 3 8761 NULL
103956 +joydev_compat_ioctl_8765 joydev_compat_ioctl 2 8765 NULL
103957 +x32_arch_ptrace_8767 x32_arch_ptrace 3 8767 NULL
103958 +kstrtoint_from_user_8778 kstrtoint_from_user 2 8778 NULL
103959 +paging32_prefetch_gpte_8783 paging32_prefetch_gpte 4 8783 NULL
103960 +ext4_try_to_write_inline_data_8785 ext4_try_to_write_inline_data 3-4 8785 NULL
103961 +aligned_nrpages_8791 aligned_nrpages 0-1-2 8791 NULL
103962 +__bitmap_weight_8796 __bitmap_weight 0-2 8796 NULL
103963 +cpuset_common_file_read_8800 cpuset_common_file_read 5 8800 NULL
103964 +intel_ring_begin_8808 intel_ring_begin 0 8808 NULL
103965 +ntfs_commit_pages_after_write_8809 ntfs_commit_pages_after_write 4-3 8809 NULL
103966 +metronomefb_write_8823 metronomefb_write 3 8823 NULL
103967 +SyS_llistxattr_8824 SyS_llistxattr 3 8824 NULL
103968 +get_queue_depth_8833 get_queue_depth 0 8833 NULL
103969 +dvb_ringbuffer_pkt_next_8834 dvb_ringbuffer_pkt_next 0-2 8834 NULL
103970 +usb_ep_queue_8839 usb_ep_queue 0 8839 NULL
103971 +clear_bitset_8840 clear_bitset 2 8840 NULL
103972 +debug_debug1_read_8856 debug_debug1_read 3 8856 NULL
103973 +wa_nep_queue_8858 wa_nep_queue 2 8858 NULL
103974 +sk_memory_allocated_8882 sk_memory_allocated 0 8882 NULL
103975 +compressed_bio_size_8887 compressed_bio_size 0-2 8887 NULL
103976 +ab3100_get_set_reg_8890 ab3100_get_set_reg 3 8890 NULL nohasharray
103977 +tracing_max_lat_read_8890 tracing_max_lat_read 3 8890 &ab3100_get_set_reg_8890
103978 +xfs_contig_bits_8904 xfs_contig_bits 3-0 8904 NULL
103979 +sdio_max_byte_size_8907 sdio_max_byte_size 0 8907 NULL
103980 +sysfs_merge_group_8917 sysfs_merge_group 0 8917 NULL
103981 +write_file_ani_8918 write_file_ani 3 8918 NULL
103982 +layout_commit_8926 layout_commit 3 8926 NULL
103983 +adjust_priv_size_8935 adjust_priv_size 0-1 8935 NULL
103984 +driver_stats_read_8944 driver_stats_read 3 8944 NULL
103985 +lookup_zone_8956 lookup_zone 2 8956 NULL
103986 +read_file_tgt_stats_8959 read_file_tgt_stats 3 8959 NULL
103987 +seq_bitmap_list_8963 seq_bitmap_list 3 8963 NULL
103988 +usb_allocate_stream_buffers_8964 usb_allocate_stream_buffers 3 8964 NULL
103989 +qib_qsfp_dump_8966 qib_qsfp_dump 0-3 8966 NULL
103990 +venus_mkdir_8967 venus_mkdir 4 8967 NULL
103991 +seq_open_net_8968 seq_open_net 4 8968 NULL nohasharray
103992 +vol_cdev_read_8968 vol_cdev_read 3 8968 &seq_open_net_8968
103993 +bio_integrity_get_tag_8974 bio_integrity_get_tag 3 8974 NULL
103994 +btrfs_alloc_free_block_8986 btrfs_alloc_free_block 3-8 8986 NULL
103995 +jbd2_journal_blocks_per_page_9004 jbd2_journal_blocks_per_page 0 9004 NULL
103996 +il_dbgfs_clear_ucode_stats_write_9016 il_dbgfs_clear_ucode_stats_write 3 9016 NULL
103997 +sparse_index_alloc_9021 sparse_index_alloc 1 9021 NULL
103998 +snd_emu10k1_ptr_read_9026 snd_emu10k1_ptr_read 0-2 9026 NULL
103999 +fd_ioctl_9028 fd_ioctl 3 9028 NULL
104000 +nla_put_9042 nla_put 3 9042 NULL
104001 +offset_il_node_9059 offset_il_node 0 9059 NULL
104002 +snd_emu10k1_synth_copy_from_user_9061 snd_emu10k1_synth_copy_from_user 5-3 9061 NULL
104003 +snd_gus_dram_peek_9062 snd_gus_dram_peek 4 9062 NULL
104004 +fib_info_hash_alloc_9075 fib_info_hash_alloc 1 9075 NULL
104005 +create_queues_9088 create_queues 3-2 9088 NULL
104006 +ftdi_prepare_write_buffer_9093 ftdi_prepare_write_buffer 3 9093 NULL
104007 +adxl34x_spi_read_block_9108 adxl34x_spi_read_block 3 9108 NULL
104008 +alloc_slabmgmt_9109 alloc_slabmgmt 5 9109 NULL
104009 +caif_stream_sendmsg_9110 caif_stream_sendmsg 4 9110 NULL nohasharray
104010 +gfn_to_rmap_9110 gfn_to_rmap 3-2 9110 &caif_stream_sendmsg_9110
104011 +udf_direct_IO_9111 udf_direct_IO 4 9111 NULL
104012 +pmcraid_change_queue_depth_9116 pmcraid_change_queue_depth 2 9116 NULL
104013 +mq_remove_mapping_9124 mq_remove_mapping 2 9124 NULL
104014 +mlx4_alloc_resize_umem_9132 mlx4_alloc_resize_umem 3 9132 NULL
104015 +ext4_list_backups_9138 ext4_list_backups 0 9138 NULL
104016 +apei_resources_merge_9149 apei_resources_merge 0 9149 NULL
104017 +vb2_dma_sg_alloc_9157 vb2_dma_sg_alloc 2 9157 NULL
104018 +dbg_command_buf_9165 dbg_command_buf 2 9165 NULL
104019 +__btrfs_add_delayed_deletion_item_9177 __btrfs_add_delayed_deletion_item 0 9177 NULL
104020 +isr_irqs_read_9181 isr_irqs_read 3 9181 NULL
104021 +count_leading_zeros_9183 count_leading_zeros 0 9183 NULL
104022 +altera_swap_ir_9194 altera_swap_ir 2 9194 NULL
104023 +snd_m3_get_pointer_9206 snd_m3_get_pointer 0 9206 NULL
104024 +get_pfn_9207 get_pfn 1 9207 NULL
104025 +virtqueue_add_9217 virtqueue_add 4-5 9217 NULL
104026 +tx_tx_prepared_descs_read_9221 tx_tx_prepared_descs_read 3 9221 NULL
104027 +sctp_getsockopt_delayed_ack_9232 sctp_getsockopt_delayed_ack 2 9232 NULL
104028 +ext4_mark_iloc_dirty_9239 ext4_mark_iloc_dirty 0 9239 NULL
104029 +ocfs2_clear_ext_refcount_9256 ocfs2_clear_ext_refcount 4-0 9256 NULL
104030 +hfsplus_bnode_read_u16_9262 hfsplus_bnode_read_u16 0 9262 NULL
104031 +btrfs_search_slot_9264 btrfs_search_slot 0 9264 NULL
104032 +ocfs2_merge_rec_right_9267 ocfs2_merge_rec_right 0 9267 NULL
104033 +sparse_early_usemaps_alloc_node_9269 sparse_early_usemaps_alloc_node 4 9269 NULL
104034 +hdpvr_read_9273 hdpvr_read 3 9273 NULL
104035 +flakey_status_9274 flakey_status 5 9274 NULL
104036 +iwl_dbgfs_stations_read_9309 iwl_dbgfs_stations_read 3 9309 NULL
104037 +ceph_sync_setxattr_9310 ceph_sync_setxattr 4 9310 NULL
104038 +ieee80211_if_fmt_txpower_9334 ieee80211_if_fmt_txpower 3 9334 NULL
104039 +nvme_trans_fmt_get_parm_header_9340 nvme_trans_fmt_get_parm_header 2 9340 NULL
104040 +ocfs2_orphan_for_truncate_9342 ocfs2_orphan_for_truncate 4 9342 NULL
104041 +__ksm_enter_9347 __ksm_enter 0 9347 NULL
104042 +ll_direct_rw_pages_9361 ll_direct_rw_pages 0 9361 NULL
104043 +of_node_to_nid_9367 of_node_to_nid 0 9367 NULL
104044 +sta_beacon_loss_count_read_9370 sta_beacon_loss_count_read 3 9370 NULL
104045 +get_request_type_9393 get_request_type 0 9393 NULL nohasharray
104046 +mlx4_bitmap_init_9393 mlx4_bitmap_init 5-2 9393 &get_request_type_9393
104047 +virtqueue_add_outbuf_9395 virtqueue_add_outbuf 3 9395 NULL
104048 +read_9397 read 3 9397 NULL
104049 +btrfs_drop_extents_9423 btrfs_drop_extents 4-0 9423 NULL
104050 +bm_realloc_pages_9431 bm_realloc_pages 2 9431 NULL
104051 +ffs_ep0_write_9438 ffs_ep0_write 3 9438 NULL
104052 +ieee80211_if_fmt_fwded_unicast_9454 ieee80211_if_fmt_fwded_unicast 3 9454 NULL
104053 +ext3_xattr_set_acl_9467 ext3_xattr_set_acl 4 9467 NULL
104054 +agp_generic_alloc_user_9470 agp_generic_alloc_user 1 9470 NULL nohasharray
104055 +get_registers_9470 get_registers 4 9470 &agp_generic_alloc_user_9470
104056 +btrfs_csum_file_blocks_9491 btrfs_csum_file_blocks 0 9491 NULL
104057 +crypt_status_9492 crypt_status 5 9492 NULL
104058 +lbs_threshold_write_9502 lbs_threshold_write 5 9502 NULL
104059 +btrfs_add_delayed_data_ref_9508 btrfs_add_delayed_data_ref 0 9508 NULL
104060 +lp_write_9511 lp_write 3 9511 NULL
104061 +mext_calc_swap_extents_9517 mext_calc_swap_extents 4 9517 NULL
104062 +scsi_tgt_kspace_exec_9522 scsi_tgt_kspace_exec 8 9522 NULL
104063 +ll_max_read_ahead_whole_mb_seq_write_9528 ll_max_read_ahead_whole_mb_seq_write 3 9528 NULL
104064 +read_file_dma_9530 read_file_dma 3 9530 NULL
104065 +ext3_alloc_branch_9534 ext3_alloc_branch 5 9534 NULL
104066 +iwl_dbgfs_bf_params_read_9542 iwl_dbgfs_bf_params_read 3 9542 NULL
104067 +unmerge_ksm_pages_9546 unmerge_ksm_pages 0 9546 NULL nohasharray
104068 +il_dbgfs_missed_beacon_write_9546 il_dbgfs_missed_beacon_write 3 9546 &unmerge_ksm_pages_9546
104069 +compat_SyS_pwritev64_9548 compat_SyS_pwritev64 3 9548 NULL
104070 +readl_9557 readl 0 9557 NULL
104071 +fw_node_create_9559 fw_node_create 2 9559 NULL
104072 +ipath_get_user_pages_9561 ipath_get_user_pages 1-2 9561 NULL
104073 +kobj_map_9566 kobj_map 3-2 9566 NULL
104074 +f2fs_read_data_pages_9574 f2fs_read_data_pages 4 9574 NULL
104075 +use_block_rsv_9597 use_block_rsv 3 9597 NULL
104076 +snd_emu10k1_fx8010_read_9605 snd_emu10k1_fx8010_read 5-6 9605 NULL
104077 +ocfs2_claim_suballoc_bits_9615 ocfs2_claim_suballoc_bits 0 9615 NULL
104078 +lov_ost_pool_add_9626 lov_ost_pool_add 3 9626 NULL
104079 +saa7164_buffer_alloc_user_9627 saa7164_buffer_alloc_user 2 9627 NULL
104080 +ceph_copy_user_to_page_vector_9635 ceph_copy_user_to_page_vector 3-4 9635 NULL
104081 +acpi_ex_insert_into_field_9638 acpi_ex_insert_into_field 3 9638 NULL
104082 +compat_sys_keyctl_9639 compat_sys_keyctl 4 9639 NULL
104083 +ll_checksum_seq_write_9648 ll_checksum_seq_write 3 9648 NULL
104084 +ocfs2_xattr_get_rec_9652 ocfs2_xattr_get_rec 0 9652 NULL
104085 +queue_received_packet_9657 queue_received_packet 5 9657 NULL
104086 +snd_opl4_mem_proc_write_9670 snd_opl4_mem_proc_write 5 9670 NULL
104087 +dns_query_9676 dns_query 3 9676 NULL
104088 +qib_7322_handle_hwerrors_9678 qib_7322_handle_hwerrors 3 9678 NULL
104089 +__erst_read_from_storage_9690 __erst_read_from_storage 0 9690 NULL
104090 +vx_transfer_end_9701 vx_transfer_end 0 9701 NULL
104091 +fnb_9703 fnb 2-3-0 9703 NULL
104092 +fuse_iter_npages_9705 fuse_iter_npages 0 9705 NULL nohasharray
104093 +ieee80211_if_read_aid_9705 ieee80211_if_read_aid 3 9705 &fuse_iter_npages_9705
104094 +cfg80211_tx_mlme_mgmt_9715 cfg80211_tx_mlme_mgmt 3 9715 NULL
104095 +btrfs_stack_file_extent_num_bytes_9720 btrfs_stack_file_extent_num_bytes 0 9720 NULL
104096 +SYSC_ppoll_9721 SYSC_ppoll 2 9721 NULL
104097 +nla_get_u8_9736 nla_get_u8 0 9736 NULL
104098 +ieee80211_if_fmt_num_mcast_sta_9738 ieee80211_if_fmt_num_mcast_sta 3 9738 NULL
104099 +shmem_replace_page_9740 shmem_replace_page 0 9740 NULL
104100 +ddb_input_read_9743 ddb_input_read 3-0 9743 NULL
104101 +sta_last_ack_signal_read_9751 sta_last_ack_signal_read 3 9751 NULL
104102 +ni_calculate_power_boost_limit_9757 ni_calculate_power_boost_limit 3 9757 NULL
104103 +btrfs_super_root_9763 btrfs_super_root 0 9763 NULL
104104 +__alloc_percpu_9764 __alloc_percpu 2-1 9764 NULL
104105 +btrfs_write_and_wait_transaction_9768 btrfs_write_and_wait_transaction 0 9768 NULL
104106 +__blk_queue_init_tags_9778 __blk_queue_init_tags 2 9778 NULL
104107 +snd_mem_proc_write_9786 snd_mem_proc_write 3 9786 NULL
104108 +kvm_age_hva_9795 kvm_age_hva 2 9795 NULL
104109 +parse_uac2_sample_rate_range_9801 parse_uac2_sample_rate_range 0 9801 NULL
104110 +tpm_data_in_9802 tpm_data_in 0 9802 NULL
104111 +ttm_bo_fbdev_io_9805 ttm_bo_fbdev_io 4 9805 NULL
104112 +udpv6_recvmsg_9813 udpv6_recvmsg 4 9813 NULL nohasharray
104113 +ieee80211_if_read_state_9813 ieee80211_if_read_state 3 9813 &udpv6_recvmsg_9813
104114 +svc_pool_map_get_node_9817 svc_pool_map_get_node 0 9817 NULL
104115 +dvb_dvr_set_buffer_size_9840 dvb_dvr_set_buffer_size 2 9840 NULL
104116 +pmcraid_alloc_sglist_9864 pmcraid_alloc_sglist 1 9864 NULL
104117 +btrfs_free_reserved_extent_9867 btrfs_free_reserved_extent 2 9867 NULL
104118 +f1x_translate_sysaddr_to_cs_9868 f1x_translate_sysaddr_to_cs 2 9868 NULL
104119 +mlx4_bitmap_alloc_range_9876 mlx4_bitmap_alloc_range 2-3 9876 NULL
104120 +wil_read_file_ioblob_9878 wil_read_file_ioblob 3 9878 NULL
104121 +bm_register_write_9893 bm_register_write 3 9893 NULL nohasharray
104122 +snd_midi_event_new_9893 snd_midi_event_new 1 9893 &bm_register_write_9893
104123 +snd_gf1_pcm_playback_copy_9895 snd_gf1_pcm_playback_copy 5-3 9895 NULL
104124 +nonpaging_page_fault_9908 nonpaging_page_fault 2 9908 NULL
104125 +ext4_map_blocks_9916 ext4_map_blocks 0 9916 NULL
104126 +root_nfs_parse_options_9937 root_nfs_parse_options 3 9937 NULL
104127 +tc3589x_reg_read_9940 tc3589x_reg_read 0 9940 NULL
104128 +pstore_ftrace_knob_read_9947 pstore_ftrace_knob_read 3 9947 NULL
104129 +read_file_misc_9948 read_file_misc 3 9948 NULL
104130 +ext2_new_blocks_9954 ext2_new_blocks 2-0 9954 NULL
104131 +csum_partial_copy_fromiovecend_9957 csum_partial_copy_fromiovecend 4-3 9957 NULL
104132 +SyS_gethostname_9964 SyS_gethostname 2 9964 NULL
104133 +get_free_serial_index_9969 get_free_serial_index 0 9969 NULL
104134 +btrfs_add_link_9973 btrfs_add_link 5-0 9973 NULL
104135 +SYSC_move_pages_9986 SYSC_move_pages 2 9986 NULL
104136 +aat2870_dump_reg_10019 aat2870_dump_reg 0 10019 NULL
104137 +batadv_orig_hash_add_if_10033 batadv_orig_hash_add_if 2 10033 NULL
104138 +iterate_inodes_from_logical_10037 iterate_inodes_from_logical 0 10037 NULL
104139 +vm_iomap_memory_10038 vm_iomap_memory 2 10038 NULL
104140 +ieee80211_set_probe_resp_10077 ieee80211_set_probe_resp 3 10077 NULL
104141 +ufs_bitmap_search_10105 ufs_bitmap_search 0-3 10105 NULL
104142 +get_elem_size_10110 get_elem_size 0-2 10110 NULL nohasharray
104143 +dynamic_ps_timeout_read_10110 dynamic_ps_timeout_read 3 10110 &get_elem_size_10110
104144 +gfs2_meta_read_10112 gfs2_meta_read 0 10112 NULL
104145 +SyS_migrate_pages_10134 SyS_migrate_pages 2 10134 NULL nohasharray
104146 +offset_to_bit_10134 offset_to_bit 0-2-1-3 10134 &SyS_migrate_pages_10134
104147 +aes_decrypt_packets_read_10155 aes_decrypt_packets_read 3 10155 NULL
104148 +rx_out_of_mem_read_10157 rx_out_of_mem_read 3 10157 NULL
104149 +hidg_alloc_ep_req_10159 hidg_alloc_ep_req 2 10159 NULL nohasharray
104150 +ol_chunk_entries_10159 ol_chunk_entries 0 10159 &hidg_alloc_ep_req_10159
104151 +stmpe_irq_unmap_10164 stmpe_irq_unmap 2 10164 NULL
104152 +asd_store_update_bios_10165 asd_store_update_bios 4 10165 NULL
104153 +kstrtol_from_user_10168 kstrtol_from_user 2 10168 NULL
104154 +proc_pid_attr_read_10173 proc_pid_attr_read 3 10173 NULL
104155 +jffs2_user_setxattr_10182 jffs2_user_setxattr 4 10182 NULL
104156 +register_ftrace_function_10218 register_ftrace_function 0 10218 NULL
104157 +hdlc_rpr_irq_10240 hdlc_rpr_irq 2 10240 NULL
104158 +mutex_lock_killable_10244 mutex_lock_killable 0 10244 NULL
104159 +insert_orphan_item_10249 insert_orphan_item 0 10249 NULL
104160 +cciss_proc_write_10259 cciss_proc_write 3 10259 NULL
104161 +gpiochip_add_to_list_10262 gpiochip_add_to_list 0 10262 NULL
104162 +__qlcnic_pci_sriov_enable_10281 __qlcnic_pci_sriov_enable 2 10281 NULL
104163 +snd_rme9652_capture_copy_10287 snd_rme9652_capture_copy 5 10287 NULL
104164 +ubi_leb_change_10289 ubi_leb_change 0-4 10289 NULL
104165 +read_emulate_10310 read_emulate 2-4 10310 NULL
104166 +read_file_spectral_count_10320 read_file_spectral_count 3 10320 NULL
104167 +ttm_object_device_init_10321 ttm_object_device_init 2 10321 NULL
104168 +compat_SyS_writev_10327 compat_SyS_writev 3 10327 NULL
104169 +ubi_leb_read_10328 ubi_leb_read 0 10328 NULL
104170 +tun_sendmsg_10337 tun_sendmsg 4 10337 NULL
104171 +get_dump_page_10338 get_dump_page 1 10338 NULL
104172 +ufx_alloc_urb_list_10349 ufx_alloc_urb_list 3 10349 NULL
104173 +whci_add_cap_10350 whci_add_cap 0 10350 NULL
104174 +dbAllocAny_10354 dbAllocAny 0 10354 NULL
104175 +ath6kl_listen_int_read_10355 ath6kl_listen_int_read 3 10355 NULL
104176 +__ntfs_cluster_free_10360 __ntfs_cluster_free 0 10360 NULL
104177 +ms_write_multiple_pages_10362 ms_write_multiple_pages 6-5 10362 NULL
104178 +sta_ht_capa_read_10366 sta_ht_capa_read 3 10366 NULL
104179 +ecryptfs_decode_and_decrypt_filename_10379 ecryptfs_decode_and_decrypt_filename 5 10379 NULL
104180 +do_compat_pselect_10398 do_compat_pselect 1 10398 NULL
104181 +fwtty_rx_10434 fwtty_rx 3 10434 NULL
104182 +event_phy_transmit_error_read_10471 event_phy_transmit_error_read 3 10471 NULL
104183 +ext4_itable_unused_count_10501 ext4_itable_unused_count 0 10501 NULL
104184 +qib_alloc_fast_reg_page_list_10507 qib_alloc_fast_reg_page_list 2 10507 NULL
104185 +sel_write_disable_10511 sel_write_disable 3 10511 NULL
104186 +osd_req_write_sg_kern_10514 osd_req_write_sg_kern 5 10514 NULL
104187 +rds_message_alloc_10517 rds_message_alloc 1 10517 NULL
104188 +qlcnic_pci_sriov_enable_10519 qlcnic_pci_sriov_enable 2 10519 NULL nohasharray
104189 +hash_netiface4_expire_10519 hash_netiface4_expire 3 10519 &qlcnic_pci_sriov_enable_10519
104190 +snd_pcm_hw_params_user_10520 snd_pcm_hw_params_user 0 10520 NULL
104191 +ocfs2_add_refcounted_extent_10526 ocfs2_add_refcounted_extent 6 10526 NULL
104192 +snd_pcm_lib_read_10536 snd_pcm_lib_read 0-3 10536 NULL nohasharray
104193 +kstrtouint_from_user_10536 kstrtouint_from_user 2 10536 &snd_pcm_lib_read_10536
104194 +SYSC_read_10545 SYSC_read 3 10545 NULL
104195 +ext4_write_begin_10576 ext4_write_begin 3-4 10576 NULL
104196 +scrub_remap_extent_10588 scrub_remap_extent 2 10588 NULL
104197 +otp_read_10594 otp_read 5-4-2 10594 NULL
104198 +supply_map_read_file_10608 supply_map_read_file 3 10608 NULL
104199 +ima_show_htable_violations_10619 ima_show_htable_violations 3 10619 NULL
104200 +alloc_coherent_10632 alloc_coherent 2 10632 NULL
104201 +ubi_io_write_vid_hdr_10660 ubi_io_write_vid_hdr 0 10660 NULL nohasharray
104202 +nfs_idmap_lookup_id_10660 nfs_idmap_lookup_id 2 10660 &ubi_io_write_vid_hdr_10660
104203 +efx_max_tx_len_10662 efx_max_tx_len 0-2 10662 NULL
104204 +dtf_read_device_10663 dtf_read_device 3 10663 NULL
104205 +parport_write_10669 parport_write 0 10669 NULL
104206 +alloc_vmap_area_10682 alloc_vmap_area 5 10682 NULL
104207 +edge_write_10692 edge_write 4 10692 NULL
104208 +ubi_wl_get_peb_10699 ubi_wl_get_peb 0 10699 NULL
104209 +inl_10708 inl 0 10708 NULL nohasharray
104210 +selinux_inode_setxattr_10708 selinux_inode_setxattr 4 10708 &inl_10708
104211 +pvr2_ioread_read_10720 pvr2_ioread_read 3 10720 NULL nohasharray
104212 +shash_async_setkey_10720 shash_async_setkey 3 10720 &pvr2_ioread_read_10720
104213 +spi_sync_10731 spi_sync 0 10731 NULL
104214 +sctp_getsockopt_maxseg_10737 sctp_getsockopt_maxseg 2 10737 NULL nohasharray
104215 +apu_get_register_10737 apu_get_register 0 10737 &sctp_getsockopt_maxseg_10737
104216 +alloc_one_pg_vec_page_10747 alloc_one_pg_vec_page 1 10747 NULL
104217 +ttm_ref_object_add_10748 ttm_ref_object_add 0 10748 NULL
104218 +SyS_io_getevents_10756 SyS_io_getevents 3 10756 NULL
104219 +vhost_add_used_n_10760 vhost_add_used_n 3 10760 NULL
104220 +kvm_read_guest_atomic_10765 kvm_read_guest_atomic 2-4 10765 NULL
104221 +wb_set_dirty_10778 wb_set_dirty 2 10778 NULL
104222 +__qp_memcpy_to_queue_10779 __qp_memcpy_to_queue 2-4 10779 NULL
104223 +i915_gem_wait_for_error_10791 i915_gem_wait_for_error 0 10791 NULL
104224 +snd_mask_value_10794 snd_mask_value 0 10794 NULL
104225 +diva_set_trace_filter_10820 diva_set_trace_filter 0-1 10820 NULL
104226 +lbs_sleepparams_read_10840 lbs_sleepparams_read 3 10840 NULL
104227 +ida_get_new_above_10853 ida_get_new_above 2-0 10853 NULL
104228 +fuse_conn_max_background_read_10855 fuse_conn_max_background_read 3 10855 NULL
104229 +ol_chunk_blocks_10864 ol_chunk_blocks 0 10864 NULL
104230 +snd_pcm_oss_write1_10872 snd_pcm_oss_write1 3 10872 NULL
104231 +drm_ht_insert_item_10877 drm_ht_insert_item 0 10877 NULL
104232 +wiidebug_drm_write_10879 wiidebug_drm_write 3 10879 NULL
104233 +get_scq_10897 get_scq 2 10897 NULL
104234 +cgroup_write_string_10900 cgroup_write_string 5 10900 NULL
104235 +tifm_alloc_adapter_10903 tifm_alloc_adapter 1 10903 NULL
104236 +lprocfs_wr_atomic_10912 lprocfs_wr_atomic 3 10912 NULL
104237 +__copy_from_user_10918 __copy_from_user 3-0 10918 NULL
104238 +kobject_add_10919 kobject_add 0 10919 NULL
104239 +da9052_map_irq_10952 da9052_map_irq 2 10952 NULL
104240 +ci_port_test_write_10962 ci_port_test_write 3 10962 NULL
104241 +bm_entry_read_10976 bm_entry_read 3 10976 NULL
104242 +sched_autogroup_write_10984 sched_autogroup_write 3 10984 NULL
104243 +__hci_num_ctrl_10985 __hci_num_ctrl 0 10985 NULL
104244 +lz4_compress_10986 lz4_compress 2 10986 NULL
104245 +do_switch_10994 do_switch 0 10994 NULL
104246 +xfrm_hash_alloc_10997 xfrm_hash_alloc 1 10997 NULL
104247 +btrfs_add_delayed_extent_op_11000 btrfs_add_delayed_extent_op 0 11000 NULL
104248 +rx_filter_accum_arp_pend_requests_read_11003 rx_filter_accum_arp_pend_requests_read 3 11003 NULL
104249 +SetLineNumber_11023 SetLineNumber 0 11023 NULL
104250 +btrfs_find_space_for_alloc_11028 btrfs_find_space_for_alloc 2 11028 NULL
104251 +mb_find_next_bit_11037 mb_find_next_bit 0-2-3 11037 NULL
104252 +tda10048_writeregbulk_11050 tda10048_writeregbulk 4 11050 NULL
104253 +insert_inline_extent_backref_11063 insert_inline_extent_backref 8-0 11063 NULL
104254 +tcp_send_mss_11079 tcp_send_mss 0 11079 NULL
104255 +snd_pcm_delay_11081 snd_pcm_delay 0 11081 NULL
104256 +count_argc_11083 count_argc 0 11083 NULL
104257 +kvm_write_guest_cached_11106 kvm_write_guest_cached 4 11106 NULL
104258 +stmpe_gpio_to_irq_11110 stmpe_gpio_to_irq 2 11110 NULL
104259 +tw_change_queue_depth_11116 tw_change_queue_depth 2 11116 NULL
104260 +page_offset_11120 page_offset 0 11120 NULL
104261 +tracing_buffers_read_11124 tracing_buffers_read 3 11124 NULL nohasharray
104262 +cea_db_payload_len_11124 cea_db_payload_len 0 11124 &tracing_buffers_read_11124
104263 +alloc_alien_cache_11127 alloc_alien_cache 2-1 11127 NULL
104264 +eb_lookup_objects_11163 eb_lookup_objects 0 11163 NULL
104265 +snd_gf1_pcm_playback_silence_11172 snd_gf1_pcm_playback_silence 4-3 11172 NULL
104266 +il_dbgfs_rx_queue_read_11221 il_dbgfs_rx_queue_read 3 11221 NULL
104267 +comedi_alloc_spriv_11234 comedi_alloc_spriv 2 11234 NULL
104268 +mmap_region_11247 mmap_region 0-2 11247 NULL
104269 +ubifs_write_node_11258 ubifs_write_node 5-3 11258 NULL
104270 +dm_cache_discard_bitset_resize_11262 dm_cache_discard_bitset_resize 3 11262 NULL
104271 +hugetlbfs_read_11268 hugetlbfs_read 3 11268 NULL
104272 +ath6kl_power_params_write_11274 ath6kl_power_params_write 3 11274 NULL
104273 +__proc_daemon_file_11305 __proc_daemon_file 5 11305 NULL
104274 +split_vma_11312 split_vma 0 11312 NULL
104275 +btrfs_update_inode_fallback_11313 btrfs_update_inode_fallback 0 11313 NULL
104276 +ext4_xattr_check_names_11314 ext4_xattr_check_names 0 11314 NULL
104277 +sk_filter_size_11316 sk_filter_size 0 11316 NULL nohasharray
104278 +tcp_send_rcvq_11316 tcp_send_rcvq 3 11316 &sk_filter_size_11316
104279 +shmem_radix_tree_replace_11325 shmem_radix_tree_replace 0 11325 NULL
104280 +construct_key_11329 construct_key 3 11329 NULL nohasharray
104281 +__kfifo_out_peek_11329 __kfifo_out_peek 0-3 11329 &construct_key_11329
104282 +next_segment_11330 next_segment 0-2-1 11330 NULL
104283 +persistent_ram_buffer_map_11332 persistent_ram_buffer_map 2-1 11332 NULL
104284 +ext4_get_inline_size_11349 ext4_get_inline_size 0 11349 NULL
104285 +nl80211_send_mgmt_11353 nl80211_send_mgmt 7 11353 NULL nohasharray
104286 +sel_write_create_11353 sel_write_create 3 11353 &nl80211_send_mgmt_11353
104287 +drm_vblank_init_11362 drm_vblank_init 2 11362 NULL
104288 +qib_get_base_info_11369 qib_get_base_info 3 11369 NULL
104289 +isku_sysfs_read_keys_capslock_11392 isku_sysfs_read_keys_capslock 6 11392 NULL
104290 +dev_irnet_write_11398 dev_irnet_write 3 11398 NULL
104291 +__btrfs_add_delayed_insertion_item_11400 __btrfs_add_delayed_insertion_item 0 11400 NULL
104292 +lprocfs_wr_evict_client_11402 lprocfs_wr_evict_client 3 11402 NULL
104293 +___alloc_bootmem_11410 ___alloc_bootmem 1 11410 NULL
104294 +str_to_user_11411 str_to_user 2 11411 NULL
104295 +mem_fw_gen_free_mem_blks_read_11413 mem_fw_gen_free_mem_blks_read 3 11413 NULL
104296 +ath6kl_wmi_test_rx_11414 ath6kl_wmi_test_rx 3 11414 NULL
104297 +relocate_entry_gtt_11416 relocate_entry_gtt 0 11416 NULL
104298 +adis16480_show_firmware_revision_11417 adis16480_show_firmware_revision 3 11417 NULL
104299 +trace_options_read_11419 trace_options_read 3 11419 NULL
104300 +i40e_dbg_command_write_11421 i40e_dbg_command_write 3 11421 NULL
104301 +__irq_set_trigger_11422 __irq_set_trigger 0 11422 NULL nohasharray
104302 +xd_read_multiple_pages_11422 xd_read_multiple_pages 5-4 11422 &__irq_set_trigger_11422
104303 +prepare_image_11424 prepare_image 0 11424 NULL
104304 +ext3_xattr_block_list_11428 ext3_xattr_block_list 3 11428 NULL
104305 +bttv_read_11432 bttv_read 3 11432 NULL
104306 +create_zero_mask_11453 create_zero_mask 0-1 11453 NULL
104307 +do_blockdev_direct_IO_11455 do_blockdev_direct_IO 0-6 11455 NULL
104308 +swp_offset_11475 swp_offset 0 11475 NULL
104309 +st_sensors_write_data_with_mask_11476 st_sensors_write_data_with_mask 3 11476 NULL
104310 +pci_set_power_state_11479 pci_set_power_state 0 11479 NULL nohasharray
104311 +sca3000_read_first_n_hw_rb_11479 sca3000_read_first_n_hw_rb 2 11479 &pci_set_power_state_11479
104312 +xfs_file_buffered_aio_write_11492 xfs_file_buffered_aio_write 4 11492 NULL
104313 +sd_do_mode_sense_11507 sd_do_mode_sense 5 11507 NULL
104314 +kmem_zalloc_11510 kmem_zalloc 1 11510 NULL
104315 +ll_direct_IO_26_seg_11518 ll_direct_IO_26_seg 0 11518 NULL
104316 +twl_direction_in_11527 twl_direction_in 2 11527 NULL
104317 +setup_IO_APIC_irq_extra_11537 setup_IO_APIC_irq_extra 1 11537 NULL
104318 +radix_tree_extend_11555 radix_tree_extend 0 11555 NULL
104319 +skb_cow_data_11565 skb_cow_data 0 11565 NULL
104320 +posix_acl_create_masq_11567 posix_acl_create_masq 0 11567 NULL
104321 +qgroup_account_ref_step2_11575 qgroup_account_ref_step2 0 11575 NULL
104322 +lpfc_idiag_ctlacc_write_11576 lpfc_idiag_ctlacc_write 3 11576 NULL
104323 +oprofilefs_ulong_to_user_11582 oprofilefs_ulong_to_user 3 11582 NULL
104324 +snd_pcm_action_11589 snd_pcm_action 0 11589 NULL
104325 +fw_device_op_ioctl_11595 fw_device_op_ioctl 2 11595 NULL
104326 +btrfs_uuid_tree_add_11598 btrfs_uuid_tree_add 0 11598 NULL
104327 +SYSC_mq_timedsend_11607 SYSC_mq_timedsend 3 11607 NULL
104328 +i915_gem_object_pin_11630 i915_gem_object_pin 0 11630 NULL
104329 +add_new_bitmap_11644 add_new_bitmap 3 11644 NULL
104330 +sisusb_send_bridge_packet_11649 sisusb_send_bridge_packet 2 11649 NULL
104331 +nla_total_size_11658 nla_total_size 0-1 11658 NULL
104332 +slab_ksize_11664 slab_ksize 0 11664 NULL
104333 +__btrfs_run_delayed_items_11671 __btrfs_run_delayed_items 0 11671 NULL
104334 +ide_queue_pc_tail_11673 ide_queue_pc_tail 5 11673 NULL
104335 +compat_SyS_msgsnd_11675 compat_SyS_msgsnd 3 11675 NULL
104336 +btrfs_alloc_delayed_item_11678 btrfs_alloc_delayed_item 1 11678 NULL
104337 +dsp_buffer_alloc_11684 dsp_buffer_alloc 2 11684 NULL
104338 +sctp_setsockopt_hmac_ident_11687 sctp_setsockopt_hmac_ident 3 11687 NULL
104339 +split_11691 split 2 11691 NULL
104340 +snd_ctl_elem_user_tlv_11695 snd_ctl_elem_user_tlv 3 11695 NULL
104341 +blk_rq_cur_bytes_11723 blk_rq_cur_bytes 0 11723 NULL
104342 +dm_bio_prison_create_11749 dm_bio_prison_create 1 11749 NULL
104343 +iwl_dbgfs_qos_read_11753 iwl_dbgfs_qos_read 3 11753 NULL
104344 +intel_map_page_11762 intel_map_page 4-3 11762 NULL
104345 +ocfs2_relink_block_group_11769 ocfs2_relink_block_group 0 11769 NULL
104346 +ps_pspoll_timeouts_read_11776 ps_pspoll_timeouts_read 3 11776 NULL
104347 +ebt_buf_add_11779 ebt_buf_add 0 11779 NULL
104348 +btrfs_key_blockptr_11786 btrfs_key_blockptr 0 11786 NULL
104349 +rtw_alloc_etherdev_11792 rtw_alloc_etherdev 1 11792 NULL
104350 +pcpu_fc_alloc_11818 pcpu_fc_alloc 2 11818 NULL
104351 +umc_device_register_11824 umc_device_register 0 11824 NULL
104352 +zerocopy_sg_from_iovec_11828 zerocopy_sg_from_iovec 3 11828 NULL
104353 +sctp_setsockopt_maxseg_11829 sctp_setsockopt_maxseg 3 11829 NULL
104354 +rts51x_read_status_11830 rts51x_read_status 4 11830 NULL
104355 +unix_stream_connect_11844 unix_stream_connect 3 11844 NULL
104356 +ecryptfs_copy_filename_11868 ecryptfs_copy_filename 4 11868 NULL
104357 +ieee80211_rx_bss_info_11887 ieee80211_rx_bss_info 3 11887 NULL
104358 +mdc_rename_11899 mdc_rename 4-6 11899 NULL
104359 +xstateregs_get_11906 xstateregs_get 4 11906 NULL
104360 +ti_write_11916 ti_write 4 11916 NULL
104361 +fs_devrw_entry_11924 fs_devrw_entry 3 11924 NULL
104362 +bitmap_remap_11929 bitmap_remap 5 11929 NULL
104363 +atomic_sub_return_11939 atomic_sub_return 0-1 11939 NULL
104364 +r1_sync_page_io_11963 r1_sync_page_io 3 11963 NULL
104365 +f1x_swap_interleaved_region_11970 f1x_swap_interleaved_region 0-2 11970 NULL
104366 +usc_InReg_11976 usc_InReg 0 11976 NULL nohasharray
104367 +split_node_11976 split_node 0 11976 &usc_InReg_11976
104368 +BeceemFlashBulkRead_11979 BeceemFlashBulkRead 0 11979 NULL
104369 +read_and_add_raw_conns_11987 read_and_add_raw_conns 0 11987 NULL
104370 +i40e_pci_sriov_configure_12011 i40e_pci_sriov_configure 2 12011 NULL
104371 +intel_init_ring_buffer_12016 intel_init_ring_buffer 0 12016 NULL
104372 +ftdi_elan_total_command_size_12045 ftdi_elan_total_command_size 0 12045 NULL
104373 +did_overwrite_ref_12046 did_overwrite_ref 0 12046 NULL
104374 +ieee80211_if_read_user_power_level_12050 ieee80211_if_read_user_power_level 3 12050 NULL
104375 +il4965_ucode_tx_stats_read_12064 il4965_ucode_tx_stats_read 3 12064 NULL
104376 +ptc_proc_write_12076 ptc_proc_write 3 12076 NULL
104377 +ubifs_recover_log_leb_12079 ubifs_recover_log_leb 3 12079 NULL
104378 +pse36_gfn_delta_12087 pse36_gfn_delta 0-1 12087 NULL
104379 +rtw_malloc2d_12102 rtw_malloc2d 1-2-3 12102 NULL
104380 +twl6030_irq_map_12105 twl6030_irq_map 2 12105 NULL
104381 +i915_gem_evict_something_12118 i915_gem_evict_something 0 12118 NULL
104382 +alloc_bulk_urbs_generic_12127 alloc_bulk_urbs_generic 5 12127 NULL
104383 +set_powered_12129 set_powered 4 12129 NULL
104384 +ramoops_init_prz_12134 ramoops_init_prz 5 12134 NULL
104385 +xfs_handle_to_dentry_12135 xfs_handle_to_dentry 3 12135 NULL
104386 +rawv6_seticmpfilter_12137 rawv6_seticmpfilter 5 12137 NULL
104387 +vmw_fifo_reserve_12141 vmw_fifo_reserve 2 12141 NULL
104388 +rawsock_recvmsg_12144 rawsock_recvmsg 4 12144 NULL
104389 +get_idx_gc_leb_12148 get_idx_gc_leb 0 12148 NULL
104390 +btmrvl_sdio_host_to_card_12152 btmrvl_sdio_host_to_card 3 12152 NULL
104391 +ocfs2_local_alloc_new_window_12153 ocfs2_local_alloc_new_window 0 12153 NULL
104392 +vmbus_open_12154 vmbus_open 2-3 12154 NULL
104393 +dma_memcpy_to_iovec_12173 dma_memcpy_to_iovec 5 12173 NULL
104394 +LNetEQAlloc_12178 LNetEQAlloc 1 12178 NULL
104395 +ddp_make_gl_12179 ddp_make_gl 1 12179 NULL
104396 +compat_do_arpt_set_ctl_12184 compat_do_arpt_set_ctl 4 12184 NULL
104397 +ip_generic_getfrag_12187 ip_generic_getfrag 3-4 12187 NULL
104398 +scaled_div_12201 scaled_div 2-1-0 12201 NULL
104399 +snd_pcm_kernel_ioctl_12219 snd_pcm_kernel_ioctl 0 12219 NULL
104400 +fuse_get_req_12221 fuse_get_req 2 12221 NULL nohasharray
104401 +aat2870_reg_read_file_12221 aat2870_reg_read_file 3 12221 &fuse_get_req_12221
104402 +__alloc_bootmem_low_nopanic_12235 __alloc_bootmem_low_nopanic 1 12235 NULL
104403 +kvirt_to_pa_12247 kvirt_to_pa 0 12247 NULL
104404 +ib_uverbs_unmarshall_recv_12251 ib_uverbs_unmarshall_recv 5 12251 NULL
104405 +shash_compat_setkey_12267 shash_compat_setkey 3 12267 NULL
104406 +add_sctp_bind_addr_12269 add_sctp_bind_addr 3 12269 NULL
104407 +note_last_dentry_12285 note_last_dentry 3 12285 NULL
104408 +il_dbgfs_nvm_read_12288 il_dbgfs_nvm_read 3 12288 NULL nohasharray
104409 +roundup_to_multiple_of_64_12288 roundup_to_multiple_of_64 0-1 12288 &il_dbgfs_nvm_read_12288
104410 +wrap_min_12303 wrap_min 0-1-2 12303 NULL
104411 +bt_sock_recvmsg_12316 bt_sock_recvmsg 4 12316 NULL
104412 +pcbit_writecmd_12332 pcbit_writecmd 2 12332 NULL
104413 +btrfs_lookup_file_extent_12341 btrfs_lookup_file_extent 0 12341 NULL
104414 +mptctl_ioctl_12355 mptctl_ioctl 2 12355 NULL
104415 +paging32_walk_addr_12359 paging32_walk_addr 3 12359 NULL
104416 +__nf_ct_ext_add_length_12364 __nf_ct_ext_add_length 3 12364 NULL
104417 +xfs_iext_inline_to_direct_12384 xfs_iext_inline_to_direct 2 12384 NULL
104418 +btrfs_file_extent_ram_bytes_12391 btrfs_file_extent_ram_bytes 0 12391 NULL nohasharray
104419 +populate_dir_12391 populate_dir 0 12391 &btrfs_file_extent_ram_bytes_12391
104420 +ntfs_get_size_for_mapping_pairs_12413 ntfs_get_size_for_mapping_pairs 0 12413 NULL nohasharray
104421 +ext4_bg_num_gdb_nometa_12413 ext4_bg_num_gdb_nometa 0 12413 &ntfs_get_size_for_mapping_pairs_12413
104422 +hbucket_elem_add_12416 hbucket_elem_add 3 12416 NULL
104423 +ieee80211_if_read_num_mcast_sta_12419 ieee80211_if_read_num_mcast_sta 3 12419 NULL
104424 +cfs_array_alloc_12441 cfs_array_alloc 2 12441 NULL
104425 +skb_do_copy_data_nocache_12465 skb_do_copy_data_nocache 5 12465 NULL
104426 +x25_sendmsg_12487 x25_sendmsg 4 12487 NULL
104427 +fnic_trace_ctrl_read_12497 fnic_trace_ctrl_read 3 12497 NULL
104428 +qib_alloc_fast_reg_mr_12526 qib_alloc_fast_reg_mr 2 12526 NULL
104429 +xfs_get_extsz_hint_12531 xfs_get_extsz_hint 0 12531 NULL
104430 +kvm_setup_async_pf_12555 kvm_setup_async_pf 3 12555 NULL
104431 +ib_umem_get_12557 ib_umem_get 2-3 12557 NULL
104432 +ceph_osdc_wait_request_12572 ceph_osdc_wait_request 0 12572 NULL
104433 +hvc_alloc_12579 hvc_alloc 4 12579 NULL
104434 +snd_pcm_plugin_alloc_12580 snd_pcm_plugin_alloc 2 12580 NULL
104435 +pcpu_extend_area_map_12589 pcpu_extend_area_map 2 12589 NULL
104436 +tlbflush_write_file_12598 tlbflush_write_file 3 12598 NULL
104437 +vhci_put_user_12604 vhci_put_user 4 12604 NULL
104438 +ipath_mmap_mem_12625 ipath_mmap_mem 3 12625 NULL
104439 +sdhci_pltfm_init_12627 sdhci_pltfm_init 3 12627 NULL
104440 +pwr_rcvd_awake_bcns_cnt_read_12632 pwr_rcvd_awake_bcns_cnt_read 3 12632 NULL
104441 +pn_sendmsg_12640 pn_sendmsg 4 12640 NULL
104442 +dwc3_link_state_write_12641 dwc3_link_state_write 3 12641 NULL
104443 +nr_recvmsg_12649 nr_recvmsg 4 12649 NULL
104444 +wb_create_12651 wb_create 1 12651 NULL
104445 +rtw_android_get_link_speed_12655 rtw_android_get_link_speed 0 12655 NULL
104446 +ocfs2_read_block_12659 ocfs2_read_block 0 12659 NULL
104447 +sel_read_class_12669 sel_read_class 3 12669 NULL nohasharray
104448 +sparse_mem_maps_populate_node_12669 sparse_mem_maps_populate_node 4 12669 &sel_read_class_12669
104449 +ext4_writepage_trans_blocks_12674 ext4_writepage_trans_blocks 0 12674 NULL
104450 +ext4_bg_num_gdb_meta_12702 ext4_bg_num_gdb_meta 0 12702 NULL
104451 +iwl_dbgfs_calib_disabled_write_12707 iwl_dbgfs_calib_disabled_write 3 12707 NULL
104452 +ieee80211_if_read_num_buffered_multicast_12716 ieee80211_if_read_num_buffered_multicast 3 12716 NULL
104453 +ivtv_write_12721 ivtv_write 3 12721 NULL
104454 +key_rx_spec_read_12736 key_rx_spec_read 3 12736 NULL
104455 +__mei_cl_async_send_12737 __mei_cl_async_send 3 12737 NULL
104456 +run_delayed_data_ref_12749 run_delayed_data_ref 0 12749 NULL
104457 +ieee80211_if_read_dot11MeshMaxRetries_12756 ieee80211_if_read_dot11MeshMaxRetries 3 12756 NULL
104458 +listxattr_12769 listxattr 3 12769 NULL
104459 +sctp_ssnmap_init_12772 sctp_ssnmap_init 2-3 12772 NULL
104460 +btrfs_remove_free_space_12793 btrfs_remove_free_space 2-0 12793 NULL
104461 +scsi_adjust_queue_depth_12802 scsi_adjust_queue_depth 3 12802 NULL
104462 +xfs_inumbers_fmt_12817 xfs_inumbers_fmt 3 12817 NULL
104463 +tlv_put_uuid_12824 tlv_put_uuid 0 12824 NULL
104464 +readq_12825 readq 0 12825 NULL
104465 +SyS_add_key_12834 SyS_add_key 4 12834 NULL
104466 +TSS_authhmac_12839 TSS_authhmac 3 12839 NULL
104467 +spidev_sync_12842 spidev_sync 0 12842 NULL
104468 +spidev_ioctl_12846 spidev_ioctl 2 12846 NULL
104469 +get_leb_cnt_12892 get_leb_cnt 0-2 12892 NULL
104470 +ocfs2_hamming_encode_block_12904 ocfs2_hamming_encode_block 2 12904 NULL
104471 +get_virtual_node_size_12908 get_virtual_node_size 0 12908 NULL
104472 +rds_pages_in_vec_12922 rds_pages_in_vec 0 12922 NULL
104473 +free_tind_blocks_12926 free_tind_blocks 0 12926 NULL
104474 +ci_ll_init_12930 ci_ll_init 3 12930 NULL
104475 +SYSC_sendfile_12936 SYSC_sendfile 4 12936 NULL
104476 +do_inode_permission_12946 do_inode_permission 0 12946 NULL
104477 +bm_status_write_12964 bm_status_write 3 12964 NULL
104478 +raid56_parity_recover_12987 raid56_parity_recover 5 12987 NULL
104479 +TransmitTcb_12989 TransmitTcb 4 12989 NULL
104480 +sk_peek_offset_12991 sk_peek_offset 0 12991 NULL
104481 +subsystem_filter_write_13022 subsystem_filter_write 3 13022 NULL
104482 +btrfs_write_dirty_block_groups_13030 btrfs_write_dirty_block_groups 0 13030 NULL
104483 +generic_segment_checks_13041 generic_segment_checks 0 13041 NULL
104484 +SyS_sendfile64_13043 SyS_sendfile64 4 13043 NULL
104485 +ocfs2_write_begin_13045 ocfs2_write_begin 3-4 13045 NULL
104486 +ptlrpc_lprocfs_threads_min_seq_write_13060 ptlrpc_lprocfs_threads_min_seq_write 3 13060 NULL nohasharray
104487 +__dn_setsockopt_13060 __dn_setsockopt 5 13060 &ptlrpc_lprocfs_threads_min_seq_write_13060
104488 +biovec_create_pool_13079 biovec_create_pool 2 13079 NULL
104489 +_ocfs2_free_suballoc_bits_13085 _ocfs2_free_suballoc_bits 0 13085 NULL
104490 +irq_set_chip_and_handler_13088 irq_set_chip_and_handler 1 13088 NULL
104491 +xattr_getsecurity_13090 xattr_getsecurity 0 13090 NULL
104492 +mb_find_next_zero_bit_13100 mb_find_next_zero_bit 2-3-0 13100 NULL
104493 +ttm_dma_pool_alloc_new_pages_13105 ttm_dma_pool_alloc_new_pages 3 13105 NULL
104494 +SyS_msgrcv_13109 SyS_msgrcv 3 13109 NULL
104495 +snd_rme96_playback_copy_13111 snd_rme96_playback_copy 5 13111 NULL
104496 +xen_allocate_irq_dynamic_13116 xen_allocate_irq_dynamic 0 13116 NULL
104497 +bfad_debugfs_read_13119 bfad_debugfs_read 3 13119 NULL
104498 +blk_update_request_13146 blk_update_request 3 13146 NULL
104499 +caif_stream_recvmsg_13173 caif_stream_recvmsg 4 13173 NULL
104500 +pwr_disable_ps_read_13176 pwr_disable_ps_read 3 13176 NULL
104501 +ucs2_strlen_13178 ucs2_strlen 0 13178 NULL
104502 +dgrp_net_ioctl_13183 dgrp_net_ioctl 2 13183 NULL
104503 +create_trace_uprobe_13184 create_trace_uprobe 1 13184 NULL
104504 +__cmpxchg64_13187 __cmpxchg64 0 13187 NULL
104505 +comedi_read_13199 comedi_read 3 13199 NULL
104506 +mmc_ext_csd_read_13205 mmc_ext_csd_read 3 13205 NULL
104507 +__nodes_fold_13215 __nodes_fold 4 13215 NULL
104508 +get_unaligned_le64_13219 get_unaligned_le64 0 13219 NULL
104509 +svm_msrpm_offset_13220 svm_msrpm_offset 0-1 13220 NULL
104510 +fnic_trace_ctrl_write_13229 fnic_trace_ctrl_write 3 13229 NULL
104511 +asix_read_cmd_13245 asix_read_cmd 5 13245 NULL
104512 +kvm_lapic_enable_pv_eoi_13249 kvm_lapic_enable_pv_eoi 2 13249 NULL
104513 +init_tid_tabs_13252 init_tid_tabs 2-3-4 13252 NULL
104514 +bio_integrity_trim_13259 bio_integrity_trim 3 13259 NULL
104515 +simple_attr_write_13260 simple_attr_write 3 13260 NULL
104516 +c4iw_reg_user_mr_13269 c4iw_reg_user_mr 2-3 13269 NULL
104517 +pmcraid_notify_aen_13274 pmcraid_notify_aen 3 13274 NULL
104518 +il4965_stats_flag_13281 il4965_stats_flag 0-3 13281 NULL
104519 +lpfc_idiag_mbxacc_get_setup_13282 lpfc_idiag_mbxacc_get_setup 0 13282 NULL
104520 +sd_major_13294 sd_major 0-1 13294 NULL
104521 +kempld_read16_13297 kempld_read16 0 13297 NULL
104522 +reexecute_instruction_13321 reexecute_instruction 2 13321 NULL
104523 +__clone_and_map_data_bio_13334 __clone_and_map_data_bio 4-8 13334 NULL
104524 +kvm_read_nested_guest_page_13337 kvm_read_nested_guest_page 5-2 13337 NULL
104525 +get_bits_13353 get_bits 0-2 13353 NULL
104526 +hscx_empty_fifo_13360 hscx_empty_fifo 2 13360 NULL
104527 +iso_sched_alloc_13377 iso_sched_alloc 1 13377 NULL nohasharray
104528 +wep_key_not_found_read_13377 wep_key_not_found_read 3 13377 &iso_sched_alloc_13377
104529 +ext4_meta_trans_blocks_13380 ext4_meta_trans_blocks 0-3-2 13380 NULL
104530 +lov_mds_md_size_13388 lov_mds_md_size 0-1 13388 NULL nohasharray
104531 +dis_bypass_write_13388 dis_bypass_write 3 13388 &lov_mds_md_size_13388
104532 +BcmSetActiveSection_13389 BcmSetActiveSection 0 13389 NULL
104533 +ocfs2_inode_lock_update_13414 ocfs2_inode_lock_update 0 13414 NULL
104534 +netxen_alloc_sds_rings_13417 netxen_alloc_sds_rings 2 13417 NULL
104535 +compat_SyS_sendfile64_13420 compat_SyS_sendfile64 4 13420 NULL
104536 +keyring_read_13438 keyring_read 3 13438 NULL
104537 +sctp_setsockopt_peer_primary_addr_13440 sctp_setsockopt_peer_primary_addr 3 13440 NULL
104538 +ath6kl_cfg80211_connect_event_13443 ath6kl_cfg80211_connect_event 8-9-7 13443 NULL
104539 +sb_init_dio_done_wq_13482 sb_init_dio_done_wq 0 13482 NULL
104540 +data_read_13494 data_read 3 13494 NULL
104541 +i915_switch_context_13498 i915_switch_context 0 13498 NULL
104542 +ioat_chansts_32_13506 ioat_chansts_32 0 13506 NULL
104543 +ocfs2_align_bytes_to_blocks_13512 ocfs2_align_bytes_to_blocks 2-0 13512 NULL
104544 +core_status_13515 core_status 4 13515 NULL
104545 +smk_write_mapped_13519 smk_write_mapped 3 13519 NULL
104546 +bm_init_13529 bm_init 2 13529 NULL
104547 +kvm_get_cr8_13538 kvm_get_cr8 0 13538 NULL
104548 +SYSC_remap_file_pages_13540 SYSC_remap_file_pages 1-2 13540 NULL nohasharray
104549 +non_atomic_pte_lookup_13540 non_atomic_pte_lookup 2 13540 &SYSC_remap_file_pages_13540
104550 +__btrfs_alloc_chunk_13554 __btrfs_alloc_chunk 0 13554 NULL
104551 +llcp_sock_recvmsg_13556 llcp_sock_recvmsg 4 13556 NULL
104552 +ieee80211_if_read_ap_power_level_13558 ieee80211_if_read_ap_power_level 3 13558 NULL
104553 +ubifs_get_idx_gc_leb_13566 ubifs_get_idx_gc_leb 0 13566 NULL
104554 +read_file_antenna_13574 read_file_antenna 3 13574 NULL
104555 +cache_write_13589 cache_write 3 13589 NULL
104556 +Rd_Indx_13602 Rd_Indx 3-2 13602 NULL
104557 +swap_cgroup_swapon_13614 swap_cgroup_swapon 2 13614 NULL
104558 +wm8994_bulk_write_13615 wm8994_bulk_write 2-3 13615 NULL
104559 +pmcraid_get_minor_13619 pmcraid_get_minor 0 13619 NULL
104560 +packet_snd_13634 packet_snd 3 13634 NULL
104561 +blk_msg_write_13655 blk_msg_write 3 13655 NULL
104562 +cache_downcall_13666 cache_downcall 3 13666 NULL
104563 +ext3_xattr_list_entries_13682 ext3_xattr_list_entries 0-4 13682 NULL
104564 +nv94_aux_13689 nv94_aux 2-5 13689 NULL
104565 +usb_get_string_13693 usb_get_string 0 13693 NULL
104566 +atomic_cmpxchg_13700 atomic_cmpxchg 0 13700 NULL
104567 +fw_iso_buffer_alloc_13704 fw_iso_buffer_alloc 2 13704 NULL
104568 +ocfs2_cache_block_dealloc_13731 ocfs2_cache_block_dealloc 0 13731 NULL
104569 +netdev_queue_numa_node_read_13732 netdev_queue_numa_node_read 0 13732 NULL
104570 +audit_unpack_string_13748 audit_unpack_string 3 13748 NULL
104571 +ufs_dtog_13750 ufs_dtog 0-2 13750 NULL
104572 +ieee802154_alloc_device_13767 ieee802154_alloc_device 1 13767 NULL
104573 +fb_sys_read_13778 fb_sys_read 3 13778 NULL
104574 +ath6kl_mgmt_powersave_ap_13791 ath6kl_mgmt_powersave_ap 6 13791 NULL
104575 +random_read_13815 random_read 3 13815 NULL
104576 +mutex_lock_interruptible_nested_13817 mutex_lock_interruptible_nested 0 13817 NULL
104577 +hsi_register_board_info_13820 hsi_register_board_info 2 13820 NULL
104578 +___mei_cl_send_13821 ___mei_cl_send 3 13821 NULL
104579 +enc_pools_insert_13849 enc_pools_insert 3 13849 NULL
104580 +evdev_ioctl_compat_13851 evdev_ioctl_compat 2 13851 NULL
104581 +compat_ip_setsockopt_13870 compat_ip_setsockopt 5 13870 NULL
104582 +btrfs_insert_empty_item_13885 btrfs_insert_empty_item 0 13885 NULL
104583 +qp_memcpy_to_queue_13886 qp_memcpy_to_queue 5-2 13886 NULL nohasharray
104584 +__fsnotify_parent_13886 __fsnotify_parent 0 13886 &qp_memcpy_to_queue_13886
104585 +window_alignment_13895 window_alignment 0 13895 NULL
104586 +snd_pcm_aio_read_13900 snd_pcm_aio_read 3 13900 NULL
104587 +is_inode_existent_13913 is_inode_existent 0 13913 NULL
104588 +cfg80211_inform_bss_width_13933 cfg80211_inform_bss_width 9 13933 NULL
104589 +ext3_xattr_block_get_13936 ext3_xattr_block_get 0 13936 NULL
104590 +ieee80211_if_read_dot11MeshForwarding_13940 ieee80211_if_read_dot11MeshForwarding 3 13940 NULL nohasharray
104591 +ocfs2_xa_value_truncate_13940 ocfs2_xa_value_truncate 2 13940 &ieee80211_if_read_dot11MeshForwarding_13940
104592 +iwl_dbgfs_protection_mode_read_13943 iwl_dbgfs_protection_mode_read 3 13943 NULL
104593 +ieee80211_if_read_min_discovery_timeout_13946 ieee80211_if_read_min_discovery_timeout 3 13946 NULL
104594 +qib_mmap_mem_13947 qib_mmap_mem 3 13947 NULL
104595 +lpfc_idiag_queacc_read_13950 lpfc_idiag_queacc_read 3 13950 NULL
104596 +osc_grant_shrink_interval_seq_write_13952 osc_grant_shrink_interval_seq_write 3 13952 NULL
104597 +ocfs2_refresh_slot_info_13957 ocfs2_refresh_slot_info 0 13957 NULL
104598 +snd_pcm_plug_slave_size_13967 snd_pcm_plug_slave_size 0-2 13967 NULL
104599 +qcam_read_13977 qcam_read 3 13977 NULL
104600 +dsp_read_13980 dsp_read 2 13980 NULL
104601 +bm_block_bits_13981 bm_block_bits 0 13981 NULL nohasharray
104602 +dvb_demux_read_13981 dvb_demux_read 3 13981 &bm_block_bits_13981
104603 +create_files_14003 create_files 0 14003 NULL
104604 +sddr09_write_data_14014 sddr09_write_data 3 14014 NULL
104605 +btrfs_get_blocks_direct_14016 btrfs_get_blocks_direct 2 14016 NULL
104606 +dmi_format_ids_14018 dmi_format_ids 2 14018 NULL
104607 +iscsi_create_flashnode_conn_14022 iscsi_create_flashnode_conn 4 14022 NULL
104608 +dvb_usercopy_14036 dvb_usercopy 2 14036 NULL
104609 +read_def_modal_eeprom_14041 read_def_modal_eeprom 3 14041 NULL
104610 +ieee80211_if_fmt_aid_14055 ieee80211_if_fmt_aid 3 14055 NULL
104611 +sta_agg_status_read_14058 sta_agg_status_read 3 14058 NULL
104612 +ovs_flow_actions_alloc_14072 ovs_flow_actions_alloc 1 14072 NULL
104613 +lov_stripeoffset_seq_write_14078 lov_stripeoffset_seq_write 3 14078 NULL
104614 +do_proc_readlink_14096 do_proc_readlink 3 14096 NULL
104615 +compat_sys_pselect6_14105 compat_sys_pselect6 1 14105 NULL
104616 +intel_ring_wait_seqno_14107 intel_ring_wait_seqno 0 14107 NULL
104617 +ext4_journal_blocks_per_page_14127 ext4_journal_blocks_per_page 0 14127 NULL
104618 +ntfs_rl_replace_14136 ntfs_rl_replace 4-2 14136 NULL
104619 +qfq_ffs_14139 qfq_ffs 2 14139 NULL
104620 +isku_sysfs_read_light_14140 isku_sysfs_read_light 6 14140 NULL
104621 +em_canid_change_14150 em_canid_change 3 14150 NULL
104622 +gsm_dlci_data_14155 gsm_dlci_data 3 14155 NULL
104623 +print_input_mask_14168 print_input_mask 3-0 14168 NULL
104624 +ocfs2_split_and_insert_14171 ocfs2_split_and_insert 0 14171 NULL
104625 +ocfs2_xattr_value_truncate_14183 ocfs2_xattr_value_truncate 3 14183 NULL
104626 +datafab_read_data_14186 datafab_read_data 4 14186 NULL
104627 +do_splice_14196 do_splice 5 14196 NULL
104628 +hfsplus_brec_find_14200 hfsplus_brec_find 0 14200 NULL
104629 +alloc_async_14208 alloc_async 1 14208 NULL
104630 +ath6kl_regread_write_14220 ath6kl_regread_write 3 14220 NULL
104631 +ieee80211_if_write_uapsd_max_sp_len_14233 ieee80211_if_write_uapsd_max_sp_len 3 14233 NULL
104632 +dma_declare_coherent_memory_14244 dma_declare_coherent_memory 4 14244 NULL
104633 +snd_soc_hw_bulk_write_raw_14245 snd_soc_hw_bulk_write_raw 2-4 14245 NULL
104634 +ext4_journal_restart_14251 ext4_journal_restart 0 14251 NULL
104635 +will_overwrite_ref_14252 will_overwrite_ref 0 14252 NULL
104636 +ath6kl_connect_event_14267 ath6kl_connect_event 7-8-9 14267 NULL
104637 +numa_mem_id_14279 numa_mem_id 0 14279 NULL
104638 +rr_status_14293 rr_status 5 14293 NULL
104639 +read_default_ldt_14302 read_default_ldt 2 14302 NULL
104640 +__readl_14308 __readl 0 14308 NULL
104641 +send_chown_14309 send_chown 0 14309 NULL
104642 +i915_gem_object_finish_gpu_14312 i915_gem_object_finish_gpu 0 14312 NULL
104643 +oo_objects_14319 oo_objects 0 14319 NULL
104644 +ww_mutex_deadlock_injection_14321 ww_mutex_deadlock_injection 0 14321 NULL
104645 +ll_get_user_pages_14328 ll_get_user_pages 2-3-0 14328 NULL
104646 +down_write_failed_14331 down_write_failed 2 14331 NULL
104647 +p9_client_zc_rpc_14345 p9_client_zc_rpc 7 14345 NULL
104648 +alloc_tx_struct_14349 alloc_tx_struct 1 14349 NULL
104649 +snd_pcm_lib_readv_14363 snd_pcm_lib_readv 0-3 14363 NULL
104650 +btrfs_set_inode_index_14379 btrfs_set_inode_index 0 14379 NULL
104651 +acpi_get_override_irq_14381 acpi_get_override_irq 1 14381 NULL
104652 +ath6kl_regdump_read_14393 ath6kl_regdump_read 3 14393 NULL
104653 +smk_write_onlycap_14400 smk_write_onlycap 3 14400 NULL
104654 +first_logical_byte_14403 first_logical_byte 0 14403 NULL
104655 +mtd_concat_create_14416 mtd_concat_create 2 14416 NULL
104656 +get_kcore_size_14425 get_kcore_size 0 14425 NULL
104657 +qib_user_sdma_page_length_14432 qib_user_sdma_page_length 0-2-1 14432 NULL
104658 +check_lpt_crc_14442 check_lpt_crc 0 14442 NULL
104659 +block_size_14443 block_size 0 14443 NULL
104660 +lmv_user_md_size_14456 lmv_user_md_size 0-1 14456 NULL
104661 +snd_emu10k1_proc_spdif_status_14457 snd_emu10k1_proc_spdif_status 4-5 14457 NULL
104662 +lustre_msg_size_v2_14470 lustre_msg_size_v2 0 14470 NULL
104663 +dma_transfer_size_14473 dma_transfer_size 0 14473 NULL
104664 +udplite_getfrag_14479 udplite_getfrag 3-4 14479 NULL
104665 +efx_mdio_check_mmds_14486 efx_mdio_check_mmds 2 14486 NULL nohasharray
104666 +ieee80211_if_read_dot11MeshGateAnnouncementProtocol_14486 ieee80211_if_read_dot11MeshGateAnnouncementProtocol 3 14486 &efx_mdio_check_mmds_14486
104667 +ocfs2_debug_read_14507 ocfs2_debug_read 3 14507 NULL
104668 +ep0_write_14536 ep0_write 3 14536 NULL nohasharray
104669 +dataflash_read_user_otp_14536 dataflash_read_user_otp 3-2 14536 &ep0_write_14536
104670 +register_trace_sched_switch_14545 register_trace_sched_switch 0 14545 NULL
104671 +picolcd_debug_eeprom_read_14549 picolcd_debug_eeprom_read 3 14549 NULL
104672 +drm_vmalloc_dma_14550 drm_vmalloc_dma 1 14550 NULL
104673 +qp_host_alloc_queue_14566 qp_host_alloc_queue 1 14566 NULL
104674 +SyS_setdomainname_14569 SyS_setdomainname 2 14569 NULL
104675 +remap_to_origin_then_cache_14583 remap_to_origin_then_cache 3 14583 NULL
104676 +idmap_pipe_downcall_14591 idmap_pipe_downcall 3 14591 NULL
104677 +ceph_osdc_alloc_request_14597 ceph_osdc_alloc_request 3 14597 NULL
104678 +ocfs2_steal_meta_14602 ocfs2_steal_meta 0 14602 NULL
104679 +ocfs2_trim_group_14641 ocfs2_trim_group 4-3 14641 NULL
104680 +dbJoin_14644 dbJoin 0 14644 NULL
104681 +profile_replace_14652 profile_replace 3 14652 NULL
104682 +add_to_page_cache_locked_14668 add_to_page_cache_locked 0 14668 NULL
104683 +min_bytes_needed_14675 min_bytes_needed 0 14675 NULL
104684 +nvme_trans_log_info_exceptions_14677 nvme_trans_log_info_exceptions 3 14677 NULL
104685 +pipeline_enc_tx_stat_fifo_int_read_14680 pipeline_enc_tx_stat_fifo_int_read 3 14680 NULL
104686 +ieee80211_if_fmt_rc_rateidx_mask_2ghz_14683 ieee80211_if_fmt_rc_rateidx_mask_2ghz 3 14683 NULL
104687 +SyS_fsetxattr_14702 SyS_fsetxattr 4 14702 NULL
104688 +persistent_ram_ecc_string_14704 persistent_ram_ecc_string 0 14704 NULL
104689 +u_audio_playback_14709 u_audio_playback 3 14709 NULL
104690 +rtw_cbuf_alloc_14710 rtw_cbuf_alloc 1 14710 NULL
104691 +cgroup_path_14713 cgroup_path 3 14713 NULL
104692 +get_bio_block_14714 get_bio_block 0 14714 NULL
104693 +vfd_write_14717 vfd_write 3 14717 NULL
104694 +SyS_sendfile_14718 SyS_sendfile 4 14718 NULL
104695 +__blk_end_request_14729 __blk_end_request 3 14729 NULL
104696 +raid1_resize_14740 raid1_resize 2 14740 NULL
104697 +i915_error_state_buf_init_14742 i915_error_state_buf_init 2 14742 NULL
104698 +btrfs_inode_extref_name_len_14752 btrfs_inode_extref_name_len 0 14752 NULL
104699 +rx_rx_cmplt_read_14753 rx_rx_cmplt_read 3 14753 NULL
104700 +regmap_range_read_file_14775 regmap_range_read_file 3 14775 NULL
104701 +sta_dev_read_14782 sta_dev_read 3 14782 NULL
104702 +keys_proc_write_14792 keys_proc_write 3 14792 NULL
104703 +ext4_kvmalloc_14796 ext4_kvmalloc 1 14796 NULL
104704 +__kfifo_in_14797 __kfifo_in 3-0 14797 NULL
104705 +hpet_readl_14801 hpet_readl 0 14801 NULL nohasharray
104706 +snd_als300_gcr_read_14801 snd_als300_gcr_read 0 14801 &hpet_readl_14801
104707 +changed_cb_14819 changed_cb 0 14819 NULL
104708 +do_tune_cpucache_14828 do_tune_cpucache 2 14828 NULL
104709 +mrp_attr_create_14853 mrp_attr_create 3 14853 NULL
104710 +lcd_write_14857 lcd_write 3 14857 NULL
104711 +get_user_cpu_mask_14861 get_user_cpu_mask 2 14861 NULL
104712 +gmux_index_read8_14890 gmux_index_read8 0 14890 NULL
104713 +acpi_os_allocate_14892 acpi_os_allocate 1 14892 NULL
104714 +SYSC_readv_14901 SYSC_readv 3 14901 NULL
104715 +regmap_irq_get_virq_14910 regmap_irq_get_virq 2-0 14910 NULL
104716 +__arch_hweight64_14923 __arch_hweight64 0 14923 NULL nohasharray
104717 +qp_memcpy_to_queue_iov_14923 qp_memcpy_to_queue_iov 5-2 14923 &__arch_hweight64_14923
104718 +ocfs2_expand_nonsparse_inode_14936 ocfs2_expand_nonsparse_inode 3-4 14936 NULL
104719 +range_to_mtrr_14940 range_to_mtrr 2 14940 NULL
104720 +queue_cnt_14951 queue_cnt 0 14951 NULL
104721 +unix_dgram_recvmsg_14952 unix_dgram_recvmsg 4 14952 NULL
104722 +i915_vma_unbind_14954 i915_vma_unbind 0 14954 NULL
104723 +videobuf_read_stream_14956 videobuf_read_stream 3 14956 NULL
104724 +mce_flush_rx_buffer_14976 mce_flush_rx_buffer 2 14976 NULL
104725 +setkey_14987 setkey 3 14987 NULL nohasharray
104726 +gpio_twl4030_write_14987 gpio_twl4030_write 1 14987 &setkey_14987
104727 +xfs_dinode_size_14996 xfs_dinode_size 0 14996 NULL
104728 +blk_integrity_tuple_size_15027 blk_integrity_tuple_size 0 15027 NULL
104729 +irq_get_next_irq_15053 irq_get_next_irq 1-0 15053 NULL
104730 +cld_pipe_downcall_15058 cld_pipe_downcall 3 15058 NULL
104731 +ieee80211_if_read_uapsd_max_sp_len_15067 ieee80211_if_read_uapsd_max_sp_len 3 15067 NULL
104732 +nfs4_write_cached_acl_15070 nfs4_write_cached_acl 4 15070 NULL
104733 +ntfs_copy_from_user_15072 ntfs_copy_from_user 3-5-0 15072 NULL
104734 +pppoe_recvmsg_15073 pppoe_recvmsg 4 15073 NULL
104735 +ceph_calc_ceph_pg_15075 ceph_calc_ceph_pg 0 15075 NULL
104736 +perf_trace_sched_stat_runtime_15115 perf_trace_sched_stat_runtime 3 15115 NULL
104737 +hex_dump_to_buffer_15121 hex_dump_to_buffer 6 15121 NULL
104738 +start_port_15124 start_port 0 15124 NULL
104739 +ipwireless_ppp_mru_15153 ipwireless_ppp_mru 0 15153 NULL
104740 +iwl_dbgfs_sta_drain_write_15167 iwl_dbgfs_sta_drain_write 3 15167 NULL
104741 +self_check_not_bad_15175 self_check_not_bad 0 15175 NULL
104742 +SYSC_setdomainname_15180 SYSC_setdomainname 2 15180 NULL
104743 +iscsi_create_endpoint_15193 iscsi_create_endpoint 1 15193 NULL
104744 +reserve_resources_15194 reserve_resources 3 15194 NULL
104745 +mtt_alloc_res_15211 mtt_alloc_res 5 15211 NULL
104746 +bfad_debugfs_write_regrd_15218 bfad_debugfs_write_regrd 3 15218 NULL
104747 +iwl_dbgfs_sram_write_15239 iwl_dbgfs_sram_write 3 15239 NULL
104748 +il_dbgfs_rx_stats_read_15243 il_dbgfs_rx_stats_read 3 15243 NULL
104749 +div64_u64_15263 div64_u64 0-1-2 15263 NULL
104750 +simple_strtol_15273 simple_strtol 0 15273 NULL
104751 +fw_realloc_buffer_15280 fw_realloc_buffer 2 15280 NULL
104752 +arch_enable_uv_irq_15294 arch_enable_uv_irq 2 15294 NULL
104753 +acpi_ev_create_gpe_block_15297 acpi_ev_create_gpe_block 5 15297 NULL
104754 +ocfs2_read_refcount_block_15305 ocfs2_read_refcount_block 0 15305 NULL
104755 +__ocfs2_remove_xattr_range_15330 __ocfs2_remove_xattr_range 4-3-5 15330 NULL
104756 +bfloat_mantissa_15334 bfloat_mantissa 0 15334 NULL
104757 +xlog_ticket_alloc_15335 xlog_ticket_alloc 2 15335 NULL
104758 +kovaplus_sysfs_read_15337 kovaplus_sysfs_read 6 15337 NULL
104759 +ioread16_15342 ioread16 0 15342 NULL
104760 +ept_prefetch_gpte_15348 ept_prefetch_gpte 4 15348 NULL
104761 +acpi_ut_create_string_object_15360 acpi_ut_create_string_object 1 15360 NULL
104762 +count_inode_extrefs_15366 count_inode_extrefs 0 15366 NULL
104763 +ext4_direct_IO_15369 ext4_direct_IO 4 15369 NULL
104764 +graph_depth_read_15371 graph_depth_read 3 15371 NULL
104765 +compat_sys_process_vm_readv_15374 compat_sys_process_vm_readv 3-5 15374 NULL
104766 +fq_codel_zalloc_15378 fq_codel_zalloc 1 15378 NULL
104767 +domain_flush_pages_15379 domain_flush_pages 2-3 15379 NULL
104768 +alloc_fddidev_15382 alloc_fddidev 1 15382 NULL
104769 +btrfs_level_size_15392 btrfs_level_size 0 15392 NULL
104770 +pipeline_csum_to_rx_xfer_swi_read_15403 pipeline_csum_to_rx_xfer_swi_read 3 15403 NULL
104771 +get_modalias_15406 get_modalias 2 15406 NULL
104772 +blockdev_direct_IO_15408 blockdev_direct_IO 0-5 15408 NULL
104773 +dm_cache_resize_15422 dm_cache_resize 2 15422 NULL
104774 +__videobuf_copy_to_user_15423 __videobuf_copy_to_user 4-0 15423 NULL
104775 +tcp_mtu_to_mss_15438 tcp_mtu_to_mss 2-0 15438 NULL
104776 +hpsa_change_queue_depth_15449 hpsa_change_queue_depth 2 15449 NULL
104777 +memweight_15450 memweight 2 15450 NULL
104778 +vmalloc_15464 vmalloc 1 15464 NULL
104779 +__mutex_lock_killable_slowpath_15472 __mutex_lock_killable_slowpath 0 15472 NULL
104780 +insert_old_idx_znode_15500 insert_old_idx_znode 0 15500 NULL
104781 +zd_chip_is_zd1211b_15518 zd_chip_is_zd1211b 0 15518 NULL
104782 +ifx_spi_write_15531 ifx_spi_write 3 15531 NULL
104783 +da9052_bat_irq_15533 da9052_bat_irq 1 15533 NULL
104784 +p9_check_zc_errors_15534 p9_check_zc_errors 4 15534 NULL
104785 +xfrm_state_mtu_15548 xfrm_state_mtu 0-2 15548 NULL
104786 +snd_pcm_channel_info_15572 snd_pcm_channel_info 0 15572 NULL
104787 +persistent_status_15574 persistent_status 4 15574 NULL
104788 +bnx2fc_process_unsol_compl_15576 bnx2fc_process_unsol_compl 2 15576 NULL
104789 +cl_io_submit_sync_15579 cl_io_submit_sync 0 15579 NULL
104790 +vme_user_write_15587 vme_user_write 3 15587 NULL
104791 +ocfs2_truncate_rec_15595 ocfs2_truncate_rec 7-0 15595 NULL
104792 +sx150x_install_irq_chip_15609 sx150x_install_irq_chip 3 15609 NULL
104793 +iommu_device_max_index_15620 iommu_device_max_index 0-3-2-1 15620 NULL nohasharray
104794 +compat_fillonedir_15620 compat_fillonedir 3 15620 &iommu_device_max_index_15620
104795 +proc_loginuid_read_15631 proc_loginuid_read 3 15631 NULL
104796 +tomoyo_scan_bprm_15642 tomoyo_scan_bprm 4-2 15642 NULL nohasharray
104797 +sk_memory_allocated_add_15642 sk_memory_allocated_add 2 15642 &tomoyo_scan_bprm_15642 nohasharray
104798 +pipeline_hs_tx_stat_fifo_int_read_15642 pipeline_hs_tx_stat_fifo_int_read 3 15642 &sk_memory_allocated_add_15642
104799 +joydev_handle_JSIOCSBTNMAP_15643 joydev_handle_JSIOCSBTNMAP 3 15643 NULL
104800 +fs_path_add_15648 fs_path_add 3-0 15648 NULL
104801 +xsd_read_15653 xsd_read 3 15653 NULL
104802 +unix_bind_15668 unix_bind 3 15668 NULL
104803 +SyS_connect_15674 SyS_connect 3 15674 NULL nohasharray
104804 +dm_read_15674 dm_read 3 15674 &SyS_connect_15674
104805 +pstore_mkfile_15675 pstore_mkfile 6 15675 NULL
104806 +i915_gem_object_set_to_cpu_domain_15705 i915_gem_object_set_to_cpu_domain 0 15705 NULL nohasharray
104807 +uncore_alloc_box_15705 uncore_alloc_box 2 15705 &i915_gem_object_set_to_cpu_domain_15705
104808 +ocfs2_split_tree_15716 ocfs2_split_tree 5-0 15716 NULL
104809 +tracing_snapshot_write_15719 tracing_snapshot_write 3 15719 NULL
104810 +HiSax_readstatus_15752 HiSax_readstatus 2 15752 NULL
104811 +ftrace_profile_init_cpu_15761 ftrace_profile_init_cpu 0 15761 NULL
104812 +bitmap_search_next_usable_block_15762 bitmap_search_next_usable_block 3-1-0 15762 NULL
104813 +i915_gem_init_seqno_15793 i915_gem_init_seqno 0 15793 NULL
104814 +smk_read_direct_15803 smk_read_direct 3 15803 NULL
104815 +nameseq_list_15817 nameseq_list 3-0 15817 NULL nohasharray
104816 +gnttab_expand_15817 gnttab_expand 1 15817 &nameseq_list_15817
104817 +afs_proc_rootcell_write_15822 afs_proc_rootcell_write 3 15822 NULL
104818 +brcmf_sdbrcm_died_dump_15841 brcmf_sdbrcm_died_dump 3 15841 NULL
104819 +table_size_15851 table_size 0-1-2 15851 NULL
104820 +ubi_io_write_15870 ubi_io_write 0-5-4 15870 NULL nohasharray
104821 +media_entity_init_15870 media_entity_init 2-4 15870 &ubi_io_write_15870
104822 +__mptctl_ioctl_15875 __mptctl_ioctl 2 15875 NULL
104823 +profile_pc_15887 profile_pc 0 15887 NULL
104824 +nfs_map_group_to_gid_15892 nfs_map_group_to_gid 3 15892 NULL
104825 +native_read_msr_15905 native_read_msr 0 15905 NULL
104826 +parse_audio_stream_data_15937 parse_audio_stream_data 3 15937 NULL
104827 +power_read_15939 power_read 3 15939 NULL
104828 +lpfc_idiag_drbacc_read_15948 lpfc_idiag_drbacc_read 3 15948 NULL
104829 +snd_pcm_lib_read_transfer_15952 snd_pcm_lib_read_transfer 5-2-4 15952 NULL
104830 +tfrc_calc_x_15975 tfrc_calc_x 2-1 15975 NULL
104831 +frame_alloc_15981 frame_alloc 4 15981 NULL
104832 +hdpvr_register_videodev_16010 hdpvr_register_videodev 3 16010 NULL
104833 +viafb_vt1636_proc_write_16018 viafb_vt1636_proc_write 3 16018 NULL
104834 +i915_gem_object_pin_16032 i915_gem_object_pin 0 16032 NULL
104835 +dccp_recvmsg_16056 dccp_recvmsg 4 16056 NULL
104836 +read_file_spectral_period_16057 read_file_spectral_period 3 16057 NULL
104837 +si5351_msynth_params_address_16062 si5351_msynth_params_address 0-1 16062 NULL
104838 +ocfs2_sync_local_to_main_16076 ocfs2_sync_local_to_main 0 16076 NULL
104839 +isr_tx_exch_complete_read_16103 isr_tx_exch_complete_read 3 16103 NULL
104840 +dma_tx_requested_read_16110 dma_tx_requested_read 3 16110 NULL nohasharray
104841 +isr_hw_pm_mode_changes_read_16110 isr_hw_pm_mode_changes_read 3 16110 &dma_tx_requested_read_16110
104842 +irq_set_chip_and_handler_name_16111 irq_set_chip_and_handler_name 1 16111 NULL
104843 +snd_dma_pointer_16126 snd_dma_pointer 0-2 16126 NULL
104844 +compat_sys_select_16131 compat_sys_select 1 16131 NULL
104845 +fsm_init_16134 fsm_init 2 16134 NULL
104846 +ext4_xattr_block_get_16148 ext4_xattr_block_get 0 16148 NULL
104847 +update_block_group_16155 update_block_group 0 16155 NULL
104848 +optimal_reclaimed_pages_16172 optimal_reclaimed_pages 0 16172 NULL
104849 +mapping_level_16188 mapping_level 2-0 16188 NULL
104850 +i40e_allocate_virt_mem_d_16191 i40e_allocate_virt_mem_d 3 16191 NULL
104851 +tcp_syn_options_16197 tcp_syn_options 0 16197 NULL
104852 +ath10k_htt_rx_ring_size_16201 ath10k_htt_rx_ring_size 0 16201 NULL
104853 +cipso_v4_map_cat_rng_hton_16203 cipso_v4_map_cat_rng_hton 0 16203 NULL
104854 +SyS_pselect6_16210 SyS_pselect6 1 16210 NULL
104855 +create_table_16213 create_table 2 16213 NULL
104856 +atomic_read_file_16227 atomic_read_file 3 16227 NULL
104857 +BcmGetSectionValStartOffset_16235 BcmGetSectionValStartOffset 0 16235 NULL
104858 +lov_prep_brw_set_16246 lov_prep_brw_set 3 16246 NULL
104859 +i40e_dbg_dump_read_16247 i40e_dbg_dump_read 3 16247 NULL nohasharray
104860 +btrfs_dev_extent_chunk_offset_16247 btrfs_dev_extent_chunk_offset 0 16247 &i40e_dbg_dump_read_16247
104861 +il_dbgfs_disable_ht40_write_16249 il_dbgfs_disable_ht40_write 3 16249 NULL
104862 +SyS_fgetxattr_16254 SyS_fgetxattr 4 16254 NULL
104863 +reiserfs_acl_count_16265 reiserfs_acl_count 0-1 16265 NULL
104864 +mq_force_mapping_16277 mq_force_mapping 2 16277 NULL
104865 +ocfs2_xattr_bucket_value_truncate_16279 ocfs2_xattr_bucket_value_truncate 4 16279 NULL
104866 +drbd_setsockopt_16280 drbd_setsockopt 5 16280 NULL nohasharray
104867 +nand_bch_init_16280 nand_bch_init 2-3 16280 &drbd_setsockopt_16280
104868 +account_16283 account 0-4-2 16283 NULL nohasharray
104869 +mirror_status_16283 mirror_status 5 16283 &account_16283
104870 +retry_instruction_16285 retry_instruction 2 16285 NULL
104871 +jumpshot_read_data_16287 jumpshot_read_data 4 16287 NULL
104872 +mo_xattr_get_16288 mo_xattr_get 0 16288 NULL
104873 +stk_allocate_buffers_16291 stk_allocate_buffers 2 16291 NULL
104874 +rbd_segment_offset_16293 rbd_segment_offset 0-2 16293 NULL
104875 +tfrc_invert_loss_event_rate_16295 tfrc_invert_loss_event_rate 1 16295 NULL
104876 +rsc_mgr_init_16299 rsc_mgr_init 3 16299 NULL
104877 +wb_map_16301 wb_map 2 16301 NULL
104878 +kvm_handle_hva_range_16312 kvm_handle_hva_range 3-2 16312 NULL
104879 +ext4_blocks_count_16320 ext4_blocks_count 0 16320 NULL
104880 +vmw_cursor_update_image_16332 vmw_cursor_update_image 3-4 16332 NULL
104881 +btrfs_insert_item_16357 btrfs_insert_item 0 16357 NULL
104882 +sysfs_create_groups_16360 sysfs_create_groups 0 16360 NULL
104883 +total_ps_buffered_read_16365 total_ps_buffered_read 3 16365 NULL
104884 +iscsi_tcp_conn_setup_16376 iscsi_tcp_conn_setup 2 16376 NULL
104885 +diva_os_malloc_16406 diva_os_malloc 2 16406 NULL
104886 +ieee80211_if_read_tsf_16420 ieee80211_if_read_tsf 3 16420 NULL
104887 +rxrpc_server_keyring_16431 rxrpc_server_keyring 3 16431 NULL
104888 +__bio_add_page_16435 __bio_add_page 0-4 16435 NULL
104889 +btrfs_truncate_inode_items_16452 btrfs_truncate_inode_items 0-4 16452 NULL
104890 +ocfs2_expand_refcount_tree_16455 ocfs2_expand_refcount_tree 0 16455 NULL
104891 +netlink_change_ngroups_16457 netlink_change_ngroups 2 16457 NULL
104892 +alloc_disk_node_16458 alloc_disk_node 2 16458 NULL
104893 +req_capsule_get_size_16467 req_capsule_get_size 0 16467 NULL
104894 +ocfs2_block_group_set_bits_16488 ocfs2_block_group_set_bits 0 16488 NULL
104895 +add_qgroup_item_16492 add_qgroup_item 0 16492 NULL
104896 +tracing_readme_read_16493 tracing_readme_read 3 16493 NULL
104897 +filemap_write_and_wait_16506 filemap_write_and_wait 0 16506 NULL
104898 +start_this_handle_16519 start_this_handle 0 16519 NULL
104899 +snd_interval_max_16529 snd_interval_max 0 16529 NULL
104900 +raid10_resize_16537 raid10_resize 2 16537 NULL
104901 +lpfc_debugfs_read_16566 lpfc_debugfs_read 3 16566 NULL
104902 +perf_event_set_period_16574 perf_event_set_period 2-3 16574 NULL
104903 +agp_allocate_memory_wrap_16576 agp_allocate_memory_wrap 1 16576 NULL
104904 +lustre_msg_hdr_size_v2_16589 lustre_msg_hdr_size_v2 0 16589 NULL
104905 +btrfs_insert_orphan_item_16602 btrfs_insert_orphan_item 0 16602 NULL
104906 +gmux_index_read32_16604 gmux_index_read32 0 16604 NULL
104907 +btrfs_end_transaction_16610 btrfs_end_transaction 0 16610 NULL
104908 +palmas_irq_get_virq_16613 palmas_irq_get_virq 2 16613 NULL
104909 +btrfs_wait_marked_extents_16615 btrfs_wait_marked_extents 0 16615 NULL
104910 +rtw_set_wpa_ie_16633 rtw_set_wpa_ie 3 16633 NULL
104911 +btrfs_get_token_32_16651 btrfs_get_token_32 0 16651 NULL
104912 +packet_recv_error_16669 packet_recv_error 3 16669 NULL
104913 +__proc_lnet_buffers_16717 __proc_lnet_buffers 5 16717 NULL
104914 +__copy_to_user_swizzled_16748 __copy_to_user_swizzled 3-4 16748 NULL
104915 +arcmsr_adjust_disk_queue_depth_16756 arcmsr_adjust_disk_queue_depth 2 16756 NULL
104916 +blk_rq_map_user_iov_16772 blk_rq_map_user_iov 5 16772 NULL
104917 +i2o_parm_issue_16790 i2o_parm_issue 0 16790 NULL
104918 +get_server_iovec_16804 get_server_iovec 2 16804 NULL
104919 +tipc_send2name_16809 tipc_send2name 6 16809 NULL
104920 +dm_vcalloc_16814 dm_vcalloc 1-2 16814 NULL
104921 +cache_grow_16818 cache_grow 3 16818 NULL
104922 +drm_malloc_ab_16831 drm_malloc_ab 1-2 16831 NULL
104923 +scsi_mode_sense_16835 scsi_mode_sense 5 16835 NULL
104924 +hfsplus_min_io_size_16859 hfsplus_min_io_size 0 16859 NULL
104925 +alloc_idx_lebs_16872 alloc_idx_lebs 2 16872 NULL
104926 +carl9170_debugfs_ampdu_state_read_16873 carl9170_debugfs_ampdu_state_read 3 16873 NULL
104927 +st_write_16874 st_write 3 16874 NULL
104928 +__kfifo_peek_n_16877 __kfifo_peek_n 0 16877 NULL
104929 +transport_init_session_tags_16878 transport_init_session_tags 1-2 16878 NULL
104930 +ext4_ext_zeroout_16895 ext4_ext_zeroout 0 16895 NULL
104931 +psb_unlocked_ioctl_16926 psb_unlocked_ioctl 2 16926 NULL nohasharray
104932 +snd_gf1_mem_proc_dump_16926 snd_gf1_mem_proc_dump 5 16926 &psb_unlocked_ioctl_16926
104933 +_sp2d_alloc_16944 _sp2d_alloc 3-2-1 16944 NULL
104934 +squashfs_read_table_16945 squashfs_read_table 3 16945 NULL
104935 +wrm_16966 wrm 0 16966 NULL
104936 +keyctl_instantiate_key_iov_16969 keyctl_instantiate_key_iov 3 16969 NULL
104937 +ocfs2_read_quota_phys_block_16990 ocfs2_read_quota_phys_block 0 16990 NULL
104938 +ceph_read_dir_17005 ceph_read_dir 3 17005 NULL
104939 +snd_mask_refine_first_17026 snd_mask_refine_first 0 17026 NULL
104940 +copy_counters_to_user_17027 copy_counters_to_user 5 17027 NULL
104941 +btrfs_unlink_inode_17043 btrfs_unlink_inode 0 17043 NULL
104942 +jffs2_trusted_setxattr_17048 jffs2_trusted_setxattr 4 17048 NULL
104943 +__arch_hweight32_17060 __arch_hweight32 0 17060 NULL
104944 +__copy_user_nocache_17065 __copy_user_nocache 0 17065 NULL
104945 +sddr55_read_data_17072 sddr55_read_data 4 17072 NULL
104946 +dvb_dvr_read_17073 dvb_dvr_read 3 17073 NULL
104947 +simple_transaction_read_17076 simple_transaction_read 3 17076 NULL
104948 +__kmalloc_reserve_17080 __kmalloc_reserve 3 17080 NULL
104949 +carl9170_debugfs_mem_usage_read_17084 carl9170_debugfs_mem_usage_read 3 17084 NULL
104950 +entry_length_17093 entry_length 0 17093 NULL
104951 +ocfs2_get_refcount_cpos_end_17113 ocfs2_get_refcount_cpos_end 0 17113 NULL
104952 +write_mem_17114 write_mem 3 17114 NULL
104953 +pvr2_hdw_state_report_17121 pvr2_hdw_state_report 3 17121 NULL
104954 +wrmaltWithLock_17139 wrmaltWithLock 0 17139 NULL
104955 +nouveau_instobj_create__17144 nouveau_instobj_create_ 4 17144 NULL
104956 +jumpshot_write_data_17151 jumpshot_write_data 4 17151 NULL
104957 +sep_read_17161 sep_read 3 17161 NULL
104958 +befs_nls2utf_17163 befs_nls2utf 3 17163 NULL
104959 +tx_tx_start_templates_read_17164 tx_tx_start_templates_read 3 17164 NULL
104960 +UniStrnlen_17169 UniStrnlen 0 17169 NULL
104961 +ocfs2_flock_handle_signal_17189 ocfs2_flock_handle_signal 0 17189 NULL nohasharray
104962 +access_remote_vm_17189 access_remote_vm 0-4-2 17189 &ocfs2_flock_handle_signal_17189 nohasharray
104963 +iwl_dbgfs_txfifo_flush_write_17189 iwl_dbgfs_txfifo_flush_write 3 17189 &access_remote_vm_17189
104964 +driver_state_read_17194 driver_state_read 3 17194 NULL nohasharray
104965 +iscsit_find_cmd_from_itt_or_dump_17194 iscsit_find_cmd_from_itt_or_dump 3 17194 &driver_state_read_17194
104966 +sync_request_17208 sync_request 2 17208 NULL
104967 +dn_recvmsg_17213 dn_recvmsg 4 17213 NULL
104968 +send_write_or_clone_17241 send_write_or_clone 0 17241 NULL
104969 +to_oblock_17254 to_oblock 0-1 17254 NULL
104970 +unpack_value_17259 unpack_value 1 17259 NULL
104971 +lprocfs_read_frac_helper_17261 lprocfs_read_frac_helper 0 17261 NULL
104972 +error_error_frame_cts_nul_flid_read_17262 error_error_frame_cts_nul_flid_read 3 17262 NULL
104973 +alloc_reserved_file_extent_17267 alloc_reserved_file_extent 0 17267 NULL
104974 +alloc_ep_17269 alloc_ep 1 17269 NULL
104975 +hw_test_and_write_17271 hw_test_and_write 3 17271 NULL
104976 +pg_read_17276 pg_read 3 17276 NULL
104977 +raw_recvmsg_17277 raw_recvmsg 4 17277 NULL
104978 +hmac_sha256_17278 hmac_sha256 2 17278 NULL
104979 +neigh_hash_grow_17283 neigh_hash_grow 2 17283 NULL
104980 +minstrel_stats_read_17290 minstrel_stats_read 3 17290 NULL
104981 +install_breakpoint_17292 install_breakpoint 4 17292 NULL
104982 +ieee80211_if_fmt_dot11MeshForwarding_17301 ieee80211_if_fmt_dot11MeshForwarding 3 17301 NULL
104983 +mb_cache_create_17307 mb_cache_create 2 17307 NULL
104984 +gnttab_map_frames_v2_17314 gnttab_map_frames_v2 2 17314 NULL
104985 +SYSC_pread64_17337 SYSC_pread64 3 17337 NULL
104986 +ieee80211_if_read_dot11MeshHWMPperrMinInterval_17346 ieee80211_if_read_dot11MeshHWMPperrMinInterval 3 17346 NULL
104987 +ath6kl_wmi_send_mgmt_cmd_17347 ath6kl_wmi_send_mgmt_cmd 7 17347 NULL
104988 +mdc_import_seq_write_17409 mdc_import_seq_write 3 17409 NULL
104989 +lpfc_debugfs_dif_err_write_17424 lpfc_debugfs_dif_err_write 3 17424 NULL
104990 +compat_sys_ppoll_17430 compat_sys_ppoll 2 17430 NULL
104991 +sta_connected_time_read_17435 sta_connected_time_read 3 17435 NULL
104992 +SYSC_fcntl_17441 SYSC_fcntl 3 17441 NULL
104993 +libcfs_ipif_enumerate_17445 libcfs_ipif_enumerate 0 17445 NULL
104994 +nla_get_u32_17455 nla_get_u32 0 17455 NULL
104995 +__ref_totlen_17461 __ref_totlen 0 17461 NULL
104996 +probe_kernel_write_17481 probe_kernel_write 3 17481 NULL
104997 +TSS_rawhmac_17486 TSS_rawhmac 3 17486 NULL
104998 +lookup_tree_block_ref_17494 lookup_tree_block_ref 0 17494 NULL
104999 +bitmap_pos_to_ord_17503 bitmap_pos_to_ord 3 17503 NULL
105000 +lbs_highrssi_write_17515 lbs_highrssi_write 3 17515 NULL
105001 +qp_free_res_17541 qp_free_res 5 17541 NULL
105002 +xlog_do_log_recovery_17550 xlog_do_log_recovery 3 17550 NULL
105003 +__copy_to_user_17551 __copy_to_user 3-0 17551 NULL
105004 +copy_from_user_17559 copy_from_user 3-0 17559 NULL
105005 +snd_pcm_action_lock_irq_17569 snd_pcm_action_lock_irq 0 17569 NULL
105006 +acpi_ut_create_package_object_17594 acpi_ut_create_package_object 1 17594 NULL
105007 +neigh_hash_alloc_17595 neigh_hash_alloc 1 17595 NULL
105008 +__inode_info_17603 __inode_info 0 17603 NULL
105009 +wm8994_gpio_to_irq_17604 wm8994_gpio_to_irq 2 17604 NULL
105010 +osst_execute_17607 osst_execute 7-6 17607 NULL
105011 +ocfs2_mark_extent_written_17615 ocfs2_mark_extent_written 6 17615 NULL
105012 +ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout_17618 ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout 3 17618 NULL
105013 +dma_map_page_17628 dma_map_page 0 17628 NULL
105014 +ocfs2_rotate_subtree_left_17634 ocfs2_rotate_subtree_left 0 17634 NULL
105015 +twl4030_set_gpio_direction_17645 twl4030_set_gpio_direction 1 17645 NULL
105016 +SYSC_migrate_pages_17657 SYSC_migrate_pages 2 17657 NULL
105017 +packet_setsockopt_17662 packet_setsockopt 5 17662 NULL nohasharray
105018 +ubi_io_read_data_17662 ubi_io_read_data 0 17662 &packet_setsockopt_17662
105019 +kernel_write_17665 kernel_write 3 17665 NULL
105020 +pwr_enable_ps_read_17686 pwr_enable_ps_read 3 17686 NULL
105021 +filemap_fdatawait_17688 filemap_fdatawait 0 17688 NULL
105022 +gfn_to_pfn_memslot_17693 gfn_to_pfn_memslot 2-0 17693 NULL
105023 +__einj_error_trigger_17707 __einj_error_trigger 0 17707 NULL nohasharray
105024 +venus_rename_17707 venus_rename 4-5 17707 &__einj_error_trigger_17707
105025 +exofs_read_lookup_dev_table_17733 exofs_read_lookup_dev_table 3 17733 NULL
105026 +sctpprobe_read_17741 sctpprobe_read 3 17741 NULL
105027 +mark_unsafe_pages_17759 mark_unsafe_pages 0 17759 NULL
105028 +dgap_do_fep_load_17765 dgap_do_fep_load 3 17765 NULL
105029 +dtf_read_run_17768 dtf_read_run 3 17768 NULL
105030 +brcmf_sdio_chip_verifynvram_17776 brcmf_sdio_chip_verifynvram 4 17776 NULL
105031 +hash_ipport6_expire_17784 hash_ipport6_expire 3 17784 NULL
105032 +perf_clock_17787 perf_clock 0 17787 NULL
105033 +ubifs_leb_change_17789 ubifs_leb_change 0-4 17789 NULL
105034 +get_unaligned_be64_17794 get_unaligned_be64 0 17794 NULL nohasharray
105035 +shrink_slab_node_17794 shrink_slab_node 3-4 17794 &get_unaligned_be64_17794
105036 +bkey_to_cacheline_17811 bkey_to_cacheline 0 17811 NULL
105037 +_snd_pcm_lib_alloc_vmalloc_buffer_17820 _snd_pcm_lib_alloc_vmalloc_buffer 2 17820 NULL
105038 +gnet_stats_copy_app_17821 gnet_stats_copy_app 3 17821 NULL
105039 +cipso_v4_gentag_rbm_17836 cipso_v4_gentag_rbm 0 17836 NULL
105040 +dm_stats_message_17863 dm_stats_message 5 17863 NULL
105041 +sisusb_send_bulk_msg_17864 sisusb_send_bulk_msg 3 17864 NULL
105042 +alloc_sja1000dev_17868 alloc_sja1000dev 1 17868 NULL
105043 +ray_cs_essid_proc_write_17875 ray_cs_essid_proc_write 3 17875 NULL
105044 +orinoco_set_key_17878 orinoco_set_key 7-5 17878 NULL nohasharray
105045 +i40e_align_l2obj_base_17878 i40e_align_l2obj_base 0-1 17878 &orinoco_set_key_17878
105046 +init_per_cpu_17880 init_per_cpu 1 17880 NULL
105047 +ieee80211_if_fmt_dot11MeshMaxPeerLinks_17883 ieee80211_if_fmt_dot11MeshMaxPeerLinks 3 17883 NULL
105048 +ieee80211_if_fmt_dot11MeshHWMPRootMode_17890 ieee80211_if_fmt_dot11MeshHWMPRootMode 3 17890 NULL
105049 +ocfs2_clusters_to_blocks_17896 ocfs2_clusters_to_blocks 0-2 17896 NULL
105050 +recover_head_17904 recover_head 3 17904 NULL
105051 +xfs_buf_associate_memory_17915 xfs_buf_associate_memory 3 17915 NULL
105052 +scsi_bufflen_17933 scsi_bufflen 0 17933 NULL
105053 +__mutex_lock_check_stamp_17947 __mutex_lock_check_stamp 0 17947 NULL
105054 +beacon_interval_write_17952 beacon_interval_write 3 17952 NULL
105055 +ufs_free_blocks_17963 ufs_free_blocks 3-2 17963 NULL nohasharray
105056 +tlv_put_u64_17963 tlv_put_u64 0 17963 &ufs_free_blocks_17963
105057 +calc_nr_buckets_17976 calc_nr_buckets 0 17976 NULL
105058 +ext4_ext_calc_credits_for_single_extent_17983 ext4_ext_calc_credits_for_single_extent 0-2 17983 NULL
105059 +smk_write_cipso_17989 smk_write_cipso 3 17989 NULL
105060 +gnttab_max_grant_frames_17993 gnttab_max_grant_frames 0 17993 NULL
105061 +ext4_num_overhead_clusters_18001 ext4_num_overhead_clusters 2 18001 NULL
105062 +pvr2_v4l2_read_18006 pvr2_v4l2_read 3 18006 NULL
105063 +alloc_rx_desc_ring_18016 alloc_rx_desc_ring 2 18016 NULL
105064 +fill_read_18019 fill_read 0 18019 NULL
105065 +o2hb_highest_node_18034 o2hb_highest_node 2-0 18034 NULL
105066 +__posix_lock_file_18035 __posix_lock_file 0 18035 NULL
105067 +ocfs2_cache_cluster_dealloc_18043 ocfs2_cache_cluster_dealloc 0 18043 NULL
105068 +cryptd_alloc_instance_18048 cryptd_alloc_instance 3-2 18048 NULL
105069 +find_next_inuse_18051 find_next_inuse 2-3-0 18051 NULL
105070 +ddebug_proc_write_18055 ddebug_proc_write 3 18055 NULL
105071 +lua_sysfs_read_18062 lua_sysfs_read 6 18062 NULL
105072 +fpregs_get_18066 fpregs_get 4 18066 NULL
105073 +kvm_read_guest_page_18074 kvm_read_guest_page 5-2 18074 NULL
105074 +SYSC_pselect6_18076 SYSC_pselect6 1 18076 NULL
105075 +SYSC_semtimedop_18091 SYSC_semtimedop 3 18091 NULL
105076 +mpi_alloc_18094 mpi_alloc 1 18094 NULL
105077 +hfs_direct_IO_18104 hfs_direct_IO 4 18104 NULL
105078 +dfs_file_read_18116 dfs_file_read 3 18116 NULL
105079 +svc_getnl_18120 svc_getnl 0 18120 NULL
105080 +paging32_gpte_to_gfn_lvl_18131 paging32_gpte_to_gfn_lvl 0-2-1 18131 NULL
105081 +vmw_surface_dma_size_18132 vmw_surface_dma_size 0 18132 NULL
105082 +selinux_inode_setsecurity_18148 selinux_inode_setsecurity 4 18148 NULL
105083 +is_idx_node_in_use_18165 is_idx_node_in_use 0 18165 NULL
105084 +pccard_store_cis_18176 pccard_store_cis 6 18176 NULL
105085 +snd_pcm_hw_refine_user_18204 snd_pcm_hw_refine_user 0 18204 NULL
105086 +orinoco_add_extscan_result_18207 orinoco_add_extscan_result 3 18207 NULL
105087 +gsm_control_message_18209 gsm_control_message 4 18209 NULL
105088 +ocfs2_divide_leaf_refcount_block_18214 ocfs2_divide_leaf_refcount_block 0 18214 NULL
105089 +do_ipv6_setsockopt_18215 do_ipv6_setsockopt 5 18215 NULL
105090 +gnttab_alloc_grant_references_18240 gnttab_alloc_grant_references 1 18240 NULL
105091 +alloc_trace_uprobe_18247 alloc_trace_uprobe 3 18247 NULL
105092 +rfcomm_sock_setsockopt_18254 rfcomm_sock_setsockopt 5 18254 NULL
105093 +__sysfs_add_one_18258 __sysfs_add_one 0 18258 NULL
105094 +qdisc_class_hash_alloc_18262 qdisc_class_hash_alloc 1 18262 NULL
105095 +gfs2_alloc_sort_buffer_18275 gfs2_alloc_sort_buffer 1 18275 NULL
105096 +alloc_ring_18278 alloc_ring 4-2-8 18278 NULL
105097 +find_dirty_idx_leb_18280 find_dirty_idx_leb 0 18280 NULL
105098 +nouveau_subdev_create__18281 nouveau_subdev_create_ 7 18281 NULL nohasharray
105099 +bio_phys_segments_18281 bio_phys_segments 0 18281 &nouveau_subdev_create__18281
105100 +ext4_readpages_18283 ext4_readpages 4 18283 NULL
105101 +mmc_send_bus_test_18285 mmc_send_bus_test 4 18285 NULL
105102 +um_idi_write_18293 um_idi_write 3 18293 NULL
105103 +nouveau_disp_create__18305 nouveau_disp_create_ 4-7 18305 NULL
105104 +vga_r_18310 vga_r 0 18310 NULL
105105 +class_add_profile_18315 class_add_profile 1-3-5 18315 NULL
105106 +csio_mem_read_18319 csio_mem_read 3 18319 NULL
105107 +alloc_and_copy_string_18321 alloc_and_copy_string 2 18321 NULL
105108 +ecryptfs_send_message_18322 ecryptfs_send_message 2 18322 NULL
105109 +bio_integrity_advance_18324 bio_integrity_advance 2 18324 NULL
105110 +__inorder_to_tree_18329 __inorder_to_tree 0-3-1 18329 NULL
105111 +lcd_proc_write_18351 lcd_proc_write 3 18351 NULL
105112 +pwr_power_save_off_read_18355 pwr_power_save_off_read 3 18355 NULL
105113 +xlbd_reserve_minors_18365 xlbd_reserve_minors 1-2 18365 NULL
105114 +SyS_process_vm_readv_18366 SyS_process_vm_readv 5-3 18366 NULL
105115 +ep_io_18367 ep_io 0 18367 NULL
105116 +qib_user_sdma_num_pages_18371 qib_user_sdma_num_pages 0 18371 NULL
105117 +ci_role_write_18388 ci_role_write 3 18388 NULL nohasharray
105118 +irq_find_mapping_18388 irq_find_mapping 0-2 18388 &ci_role_write_18388
105119 +btrfs_update_inode_18394 btrfs_update_inode 0 18394 NULL
105120 +hdlc_empty_fifo_18397 hdlc_empty_fifo 2 18397 NULL
105121 +__video_register_device_18399 __video_register_device 3 18399 NULL
105122 +hash_ip4_expire_18402 hash_ip4_expire 3 18402 NULL nohasharray
105123 +adis16136_show_serial_18402 adis16136_show_serial 3 18402 &hash_ip4_expire_18402
105124 +btrfs_rmap_block_18403 btrfs_rmap_block 0 18403 NULL
105125 +crystalhd_user_data_18407 crystalhd_user_data 3 18407 NULL
105126 +batadv_orig_node_add_if_18433 batadv_orig_node_add_if 2 18433 NULL nohasharray
105127 +iscsi_create_flashnode_sess_18433 iscsi_create_flashnode_sess 4 18433 &batadv_orig_node_add_if_18433
105128 +snd_hda_get_connections_18437 snd_hda_get_connections 0 18437 NULL
105129 +btrfs_uuid_tree_lookup_18451 btrfs_uuid_tree_lookup 0 18451 NULL
105130 +flash_dev_cache_miss_18454 flash_dev_cache_miss 4 18454 NULL
105131 +fuse_perform_write_18457 fuse_perform_write 4 18457 NULL
105132 +regset_tls_set_18459 regset_tls_set 4 18459 NULL
105133 +pcibios_window_alignment_18460 pcibios_window_alignment 0 18460 NULL
105134 +dma_alloc_from_contiguous_18466 dma_alloc_from_contiguous 3-2 18466 NULL
105135 +pci_vpd_lrdt_size_18479 pci_vpd_lrdt_size 0 18479 NULL nohasharray
105136 +mite_bytes_in_transit_18479 mite_bytes_in_transit 0 18479 &pci_vpd_lrdt_size_18479
105137 +r600_texture_size_18487 r600_texture_size 4-5-6 18487 NULL nohasharray
105138 +udpv6_setsockopt_18487 udpv6_setsockopt 5 18487 &r600_texture_size_18487
105139 +btrfs_fiemap_18501 btrfs_fiemap 3 18501 NULL nohasharray
105140 +remap_pmd_range_18501 remap_pmd_range 3-4-5 18501 &btrfs_fiemap_18501
105141 +i915_gem_object_wait_fence_18508 i915_gem_object_wait_fence 0 18508 NULL
105142 +__copy_user_zeroing_intel_18510 __copy_user_zeroing_intel 0-3 18510 NULL
105143 +snd_vx_inb_18514 snd_vx_inb 0 18514 NULL
105144 +snd_gus_dram_poke_18525 snd_gus_dram_poke 4 18525 NULL
105145 +nouveau_fifo_channel_create__18530 nouveau_fifo_channel_create_ 9 18530 NULL
105146 +seq_copy_in_user_18543 seq_copy_in_user 3 18543 NULL
105147 +acpi_register_gsi_ioapic_18550 acpi_register_gsi_ioapic 2 18550 NULL
105148 +sas_change_queue_depth_18555 sas_change_queue_depth 2 18555 NULL
105149 +vb2_streamon_18562 vb2_streamon 0 18562 NULL
105150 +smk_write_rules_list_18565 smk_write_rules_list 3 18565 NULL
105151 +debug_output_18575 debug_output 3 18575 NULL
105152 +is_extent_unchanged_18576 is_extent_unchanged 0 18576 NULL
105153 +check_lpt_type_18577 check_lpt_type 0 18577 NULL
105154 +numa_node_id_18596 numa_node_id 0 18596 NULL
105155 +filemap_fdatawait_range_18600 filemap_fdatawait_range 0 18600 NULL nohasharray
105156 +slabinfo_write_18600 slabinfo_write 3 18600 &filemap_fdatawait_range_18600
105157 +iowarrior_write_18604 iowarrior_write 3 18604 NULL
105158 +audio_get_endpoint_req_18624 audio_get_endpoint_req 0 18624 NULL
105159 +from_buffer_18625 from_buffer 3 18625 NULL
105160 +snd_pcm_oss_write3_18657 snd_pcm_oss_write3 0-3 18657 NULL
105161 +ieee80211_if_fmt_rssi_threshold_18664 ieee80211_if_fmt_rssi_threshold 3 18664 NULL
105162 +unmap_page_18665 unmap_page 2-3 18665 NULL
105163 +xfs_iext_insert_18667 xfs_iext_insert 3 18667 NULL
105164 +__alloc_skb_head_18683 __alloc_skb_head 2 18683 NULL
105165 +echo_client_prep_commit_18693 echo_client_prep_commit 8 18693 NULL
105166 +replay_log_leb_18704 replay_log_leb 3 18704 NULL
105167 +iwl_dbgfs_rx_handlers_read_18708 iwl_dbgfs_rx_handlers_read 3 18708 NULL
105168 +ceph_alloc_page_vector_18710 ceph_alloc_page_vector 1 18710 NULL
105169 +ocfs2_trim_extent_18711 ocfs2_trim_extent 3-4 18711 NULL
105170 +blk_rq_bytes_18715 blk_rq_bytes 0 18715 NULL
105171 +byt_gpio_to_irq_18721 byt_gpio_to_irq 2 18721 NULL
105172 +ext4_es_insert_extent_18729 ext4_es_insert_extent 0 18729 NULL
105173 +snd_als4k_gcr_read_addr_18741 snd_als4k_gcr_read_addr 0 18741 NULL
105174 +o2hb_debug_create_18744 o2hb_debug_create 4 18744 NULL
105175 +__erst_read_to_erange_from_nvram_18748 __erst_read_to_erange_from_nvram 0 18748 NULL
105176 +wep_packets_read_18751 wep_packets_read 3 18751 NULL
105177 +read_file_dump_nfcal_18766 read_file_dump_nfcal 3 18766 NULL
105178 +ffs_epfile_read_18775 ffs_epfile_read 3 18775 NULL
105179 +SyS_lsetxattr_18776 SyS_lsetxattr 4 18776 NULL
105180 +alloc_fcdev_18780 alloc_fcdev 1 18780 NULL
105181 +prealloc_18800 prealloc 0 18800 NULL
105182 +madvise_hwpoison_18812 madvise_hwpoison 2 18812 NULL
105183 +setup_ioapic_irq_18813 setup_ioapic_irq 1 18813 NULL
105184 +dm_stats_print_18815 dm_stats_print 7 18815 NULL
105185 +sys_modify_ldt_18824 sys_modify_ldt 3 18824 NULL
105186 +mtf_test_write_18844 mtf_test_write 3 18844 NULL
105187 +iterate_inode_refs_18846 iterate_inode_refs 0 18846 NULL
105188 +drm_ht_create_18853 drm_ht_create 2 18853 NULL
105189 +sctp_setsockopt_events_18862 sctp_setsockopt_events 3 18862 NULL
105190 +ieee80211_if_read_element_ttl_18869 ieee80211_if_read_element_ttl 3 18869 NULL nohasharray
105191 +heads_to_leaves_18869 heads_to_leaves 2-0 18869 &ieee80211_if_read_element_ttl_18869
105192 +xlog_find_verify_log_record_18870 xlog_find_verify_log_record 2 18870 NULL
105193 +width_to_agaw_18883 width_to_agaw 0-1 18883 NULL
105194 +overwrite_item_18896 overwrite_item 0 18896 NULL
105195 +kmem_cache_alloc_node_18899 kmem_cache_alloc_node 3 18899 NULL
105196 +ceph_setxattr_18913 ceph_setxattr 4 18913 NULL
105197 +ext4_block_in_group_18922 ext4_block_in_group 2 18922 NULL
105198 +ieee80211_rx_mgmt_disassoc_18927 ieee80211_rx_mgmt_disassoc 3 18927 NULL
105199 +create_pending_snapshot_18936 create_pending_snapshot 0 18936 NULL
105200 +snapshot_write_next_18937 snapshot_write_next 0 18937 NULL
105201 +regcache_sync_block_18963 regcache_sync_block 4-3 18963 NULL
105202 +__nla_reserve_18974 __nla_reserve 3 18974 NULL
105203 +__blockdev_direct_IO_18977 __blockdev_direct_IO 0-6 18977 NULL
105204 +gfn_to_pfn_atomic_18981 gfn_to_pfn_atomic 2 18981 NULL
105205 +get_inode_path_18988 get_inode_path 0 18988 NULL
105206 +find_dirtiest_idx_leb_19001 find_dirtiest_idx_leb 0 19001 NULL nohasharray
105207 +test_check_exists_19001 test_check_exists 2 19001 &find_dirtiest_idx_leb_19001
105208 +layout_in_gaps_19006 layout_in_gaps 2 19006 NULL
105209 +huge_page_size_19008 huge_page_size 0 19008 NULL
105210 +push_leaf_right_19017 push_leaf_right 0 19017 NULL
105211 +prepare_highmem_image_19028 prepare_highmem_image 0 19028 NULL
105212 +ocfs2_steal_resource_19036 ocfs2_steal_resource 0 19036 NULL
105213 +revalidate_19043 revalidate 2 19043 NULL
105214 +afs_vnode_store_data_19048 afs_vnode_store_data 2-3-4-5 19048 NULL
105215 +osc_pinger_recov_seq_write_19056 osc_pinger_recov_seq_write 3 19056 NULL
105216 +create_gpadl_header_19064 create_gpadl_header 2 19064 NULL
105217 +ieee80211_key_alloc_19065 ieee80211_key_alloc 3 19065 NULL
105218 +ceph_create_snap_context_19082 ceph_create_snap_context 1 19082 NULL
105219 +kvm_lapic_set_vapic_addr_19083 kvm_lapic_set_vapic_addr 2 19083 NULL
105220 +sta_last_seq_ctrl_read_19106 sta_last_seq_ctrl_read 3 19106 NULL
105221 +cifs_readv_from_socket_19109 cifs_readv_from_socket 3 19109 NULL
105222 +ATOMIC_SUB_RETURN_19115 ATOMIC_SUB_RETURN 2 19115 NULL
105223 +ext4_inode_table_19125 ext4_inode_table 0 19125 NULL
105224 +snd_als4k_iobase_readl_19136 snd_als4k_iobase_readl 0 19136 NULL
105225 +btrfs_run_delayed_refs_19137 btrfs_run_delayed_refs 0 19137 NULL
105226 +alloc_irdadev_19140 alloc_irdadev 1 19140 NULL
105227 +sleep_auth_read_19159 sleep_auth_read 3 19159 NULL
105228 +ext3_reserve_inode_write_19163 ext3_reserve_inode_write 0 19163 NULL
105229 +smk_write_access2_19170 smk_write_access2 3 19170 NULL
105230 +iwl_dbgfs_reply_tx_error_read_19205 iwl_dbgfs_reply_tx_error_read 3 19205 NULL
105231 +vmw_unlocked_ioctl_19212 vmw_unlocked_ioctl 2 19212 NULL
105232 +__copy_to_user_inatomic_19214 __copy_to_user_inatomic 3-0 19214 NULL
105233 +dev_counters_read_19216 dev_counters_read 3 19216 NULL
105234 +wbcir_tx_19219 wbcir_tx 3 19219 NULL
105235 +gsi_to_irq_19220 gsi_to_irq 0-1 19220 NULL
105236 +snd_mask_max_19224 snd_mask_max 0 19224 NULL
105237 +snd_pcm_capture_rewind_19229 snd_pcm_capture_rewind 0-2 19229 NULL
105238 +bio_alloc_mddev_19238 bio_alloc_mddev 2 19238 NULL
105239 +ucma_query_19260 ucma_query 4 19260 NULL
105240 +write_one_cache_group_19261 write_one_cache_group 0 19261 NULL
105241 +il_dbgfs_rxon_filter_flags_read_19281 il_dbgfs_rxon_filter_flags_read 3 19281 NULL
105242 +cfg80211_rx_unprot_mlme_mgmt_19288 cfg80211_rx_unprot_mlme_mgmt 3 19288 NULL
105243 +____cache_alloc_node_19297 ____cache_alloc_node 3 19297 NULL
105244 +qc_capture_19298 qc_capture 3 19298 NULL
105245 +ocfs2_prepare_inode_for_refcount_19303 ocfs2_prepare_inode_for_refcount 4-3 19303 NULL
105246 +event_tx_stuck_read_19305 event_tx_stuck_read 3 19305 NULL
105247 +gfn_to_gpa_19320 gfn_to_gpa 0-1 19320 NULL
105248 +debug_read_19322 debug_read 3 19322 NULL
105249 +SYSC_sendfile64_19327 SYSC_sendfile64 4 19327 NULL
105250 +cfg80211_inform_bss_19332 cfg80211_inform_bss 8 19332 NULL nohasharray
105251 +lbs_host_sleep_write_19332 lbs_host_sleep_write 3 19332 &cfg80211_inform_bss_19332
105252 +closure_sub_19359 closure_sub 2 19359 NULL
105253 +firmware_data_write_19360 firmware_data_write 6-5 19360 NULL
105254 +read_zero_19366 read_zero 3 19366 NULL
105255 +interpret_user_input_19393 interpret_user_input 2 19393 NULL
105256 +sync_fill_pt_info_19397 sync_fill_pt_info 0 19397 NULL
105257 +get_unaligned_be16_19400 get_unaligned_be16 0 19400 NULL
105258 +get_n_events_by_type_19401 get_n_events_by_type 0 19401 NULL
105259 +pep_recvmsg_19402 pep_recvmsg 4 19402 NULL
105260 +dvbdmx_write_19423 dvbdmx_write 3 19423 NULL
105261 +__phys_addr_19434 __phys_addr 0 19434 NULL
105262 +SyS_sched_getaffinity_19444 SyS_sched_getaffinity 2 19444 NULL
105263 +xfrm_alg_auth_len_19454 xfrm_alg_auth_len 0 19454 NULL
105264 +gnet_stats_copy_19458 gnet_stats_copy 4 19458 NULL
105265 +sky2_read16_19475 sky2_read16 0 19475 NULL
105266 +__read_status_pciv2_19492 __read_status_pciv2 0 19492 NULL
105267 +kstrtoll_from_user_19500 kstrtoll_from_user 2 19500 NULL
105268 +ext4_add_new_descs_19509 ext4_add_new_descs 3 19509 NULL
105269 +cfc_write_array_to_buffer_19529 cfc_write_array_to_buffer 3 19529 NULL nohasharray
105270 +apei_exec_pre_map_gars_19529 apei_exec_pre_map_gars 0 19529 &cfc_write_array_to_buffer_19529
105271 +nfc_llcp_build_tlv_19536 nfc_llcp_build_tlv 3 19536 NULL
105272 +howmany_64_19548 howmany_64 2 19548 NULL
105273 +btrfs_xattr_security_init_19553 btrfs_xattr_security_init 0 19553 NULL
105274 +gfn_to_index_19558 gfn_to_index 0-1-3-2 19558 NULL
105275 +kernel_read_19559 kernel_read 4-0 19559 NULL
105276 +ocfs2_control_message_19564 ocfs2_control_message 3 19564 NULL
105277 +ieee80211_if_read_tkip_mic_test_19565 ieee80211_if_read_tkip_mic_test 3 19565 NULL
105278 +nfsd_read_19568 nfsd_read 5 19568 NULL
105279 +cgroup_read_s64_19570 cgroup_read_s64 5 19570 NULL
105280 +bm_status_read_19583 bm_status_read 3 19583 NULL
105281 +batadv_tt_update_orig_19586 batadv_tt_update_orig 4 19586 NULL
105282 +load_xattr_datum_19594 load_xattr_datum 0 19594 NULL
105283 +__mei_cl_recv_19636 __mei_cl_recv 3 19636 NULL
105284 +usbvision_rvmalloc_19655 usbvision_rvmalloc 1 19655 NULL
105285 +LoadBitmap_19658 LoadBitmap 2 19658 NULL
105286 +i915_gem_object_bind_to_gtt_19682 i915_gem_object_bind_to_gtt 0 19682 NULL
105287 +bio_detain_19690 bio_detain 2 19690 NULL
105288 +btrfs_del_inode_extref_19692 btrfs_del_inode_extref 0 19692 NULL
105289 +mem_cgroup_swappiness_19718 mem_cgroup_swappiness 0 19718 NULL
105290 +btrfs_write_marked_extents_19720 btrfs_write_marked_extents 0 19720 NULL
105291 +read_reg_19723 read_reg 0 19723 NULL
105292 +wm8350_block_write_19727 wm8350_block_write 2-3 19727 NULL
105293 +memcpy_toiovecend_19736 memcpy_toiovecend 3-4-0 19736 NULL
105294 +snd_es1968_get_dma_ptr_19747 snd_es1968_get_dma_ptr 0 19747 NULL
105295 +p9_client_read_19750 p9_client_read 0-5 19750 NULL
105296 +pnpbios_proc_write_19758 pnpbios_proc_write 3 19758 NULL
105297 +ocfs2_readpages_19759 ocfs2_readpages 4 19759 NULL
105298 +jffs2_acl_from_medium_19762 jffs2_acl_from_medium 2 19762 NULL
105299 +readhscx_19769 readhscx 0 19769 NULL
105300 +ocfs2_read_group_descriptor_19771 ocfs2_read_group_descriptor 0 19771 NULL
105301 +__set_print_fmt_19776 __set_print_fmt 0 19776 NULL
105302 +saa7146_vmalloc_build_pgtable_19780 saa7146_vmalloc_build_pgtable 2 19780 NULL
105303 +irda_setsockopt_19824 irda_setsockopt 5 19824 NULL
105304 +pcpu_next_unpop_19831 pcpu_next_unpop 4 19831 NULL
105305 +vfs_getxattr_19832 vfs_getxattr 0 19832 NULL
105306 +security_context_to_sid_19839 security_context_to_sid 2 19839 NULL
105307 +crypt_alloc_buffer_19846 crypt_alloc_buffer 2 19846 NULL
105308 +cfg80211_mlme_register_mgmt_19852 cfg80211_mlme_register_mgmt 5 19852 NULL
105309 +__nla_put_19857 __nla_put 3 19857 NULL
105310 +mrp_request_join_19882 mrp_request_join 4 19882 NULL
105311 +blk_alloc_queue_node_19887 blk_alloc_queue_node 2 19887 NULL
105312 +aes_decrypt_interrupt_read_19910 aes_decrypt_interrupt_read 3 19910 NULL
105313 +ps_upsd_max_apturn_read_19918 ps_upsd_max_apturn_read 3 19918 NULL
105314 +mangle_name_19923 mangle_name 0 19923 NULL
105315 +cgroup_task_count_19930 cgroup_task_count 0 19930 NULL
105316 +guest_read_tsc_19931 guest_read_tsc 0 19931 NULL
105317 +iwl_dbgfs_rx_queue_read_19943 iwl_dbgfs_rx_queue_read 3 19943 NULL
105318 +cfg80211_rx_assoc_resp_19944 cfg80211_rx_assoc_resp 4 19944 NULL
105319 +alloc_elfnotes_buf_19974 alloc_elfnotes_buf 1 19974 NULL
105320 +get_jack_mode_name_19976 get_jack_mode_name 4 19976 NULL
105321 +attach_hdlc_protocol_19986 attach_hdlc_protocol 3 19986 NULL
105322 +rtw_set_wps_probe_resp_19989 rtw_set_wps_probe_resp 3 19989 NULL
105323 +diva_um_idi_read_20003 diva_um_idi_read 0 20003 NULL
105324 +lov_stripe_md_size_20009 lov_stripe_md_size 0-1 20009 NULL
105325 +SYSC_fgetxattr_20027 SYSC_fgetxattr 4 20027 NULL
105326 +split_scan_timeout_read_20029 split_scan_timeout_read 3 20029 NULL
105327 +mlx5_ib_db_map_user_20037 mlx5_ib_db_map_user 2 20037 NULL
105328 +btrfs_block_rsv_migrate_20050 btrfs_block_rsv_migrate 0 20050 NULL
105329 +__be32_to_cpup_20056 __be32_to_cpup 0 20056 NULL
105330 +alloc_ieee80211_20063 alloc_ieee80211 1 20063 NULL
105331 +iwl_mvm_power_mac_dbgfs_read_20067 iwl_mvm_power_mac_dbgfs_read 4 20067 NULL
105332 +btrfs_pin_extent_for_log_replay_20069 btrfs_pin_extent_for_log_replay 2 20069 NULL
105333 +target_message_20072 target_message 2 20072 NULL
105334 +rawv6_sendmsg_20080 rawv6_sendmsg 4 20080 NULL
105335 +fuse_conn_limit_read_20084 fuse_conn_limit_read 3 20084 NULL
105336 +aat2870_reg_write_file_20086 aat2870_reg_write_file 3 20086 NULL
105337 +team_options_register_20091 team_options_register 3 20091 NULL
105338 +qla2x00_adjust_sdev_qdepth_up_20097 qla2x00_adjust_sdev_qdepth_up 2 20097 NULL
105339 +read_int_20098 read_int 0 20098 NULL
105340 +root_nfs_copy_20111 root_nfs_copy 3 20111 NULL
105341 +hptiop_adjust_disk_queue_depth_20122 hptiop_adjust_disk_queue_depth 2 20122 NULL
105342 +self_check_vid_hdr_20131 self_check_vid_hdr 0 20131 NULL
105343 +tomoyo_commit_ok_20167 tomoyo_commit_ok 2 20167 NULL
105344 +read_flush_pipefs_20171 read_flush_pipefs 3 20171 NULL
105345 +wep_addr_key_count_read_20174 wep_addr_key_count_read 3 20174 NULL
105346 +create_trace_probe_20175 create_trace_probe 1 20175 NULL
105347 +crystalhd_map_dio_20181 crystalhd_map_dio 3 20181 NULL
105348 +udf_bitmap_new_block_20214 udf_bitmap_new_block 4 20214 NULL
105349 +pvr2_ctrl_value_to_sym_20229 pvr2_ctrl_value_to_sym 5 20229 NULL
105350 +rose_sendmsg_20249 rose_sendmsg 4 20249 NULL
105351 +tm6000_i2c_send_regs_20250 tm6000_i2c_send_regs 5 20250 NULL
105352 +pcpu_alloc_20255 pcpu_alloc 1-2 20255 NULL
105353 +resource_size_20256 resource_size 0 20256 NULL
105354 +uv_blade_to_memory_nid_20259 uv_blade_to_memory_nid 0 20259 NULL
105355 +r10_sync_page_io_20307 r10_sync_page_io 3 20307 NULL
105356 +dm_get_reserved_bio_based_ios_20315 dm_get_reserved_bio_based_ios 0 20315 NULL
105357 +tx_tx_burst_programmed_read_20320 tx_tx_burst_programmed_read 3 20320 NULL
105358 +vx_send_msg_nolock_20322 vx_send_msg_nolock 0 20322 NULL
105359 +snd_cs4281_BA1_read_20323 snd_cs4281_BA1_read 5 20323 NULL
105360 +ocfs2_et_insert_check_20341 ocfs2_et_insert_check 0 20341 NULL
105361 +gfs2_glock_nq_m_20347 gfs2_glock_nq_m 1 20347 NULL
105362 +handle_arr_calc_size_20355 handle_arr_calc_size 0-1 20355 NULL
105363 +snd_pcm_stop_20376 snd_pcm_stop 0 20376 NULL
105364 +smk_set_cipso_20379 smk_set_cipso 3 20379 NULL
105365 +block_read_full_page_20380 block_read_full_page 0 20380 NULL
105366 +snd_nm256_readl_20394 snd_nm256_readl 0 20394 NULL nohasharray
105367 +read_7220_creg32_20394 read_7220_creg32 0 20394 &snd_nm256_readl_20394
105368 +__kfifo_from_user_20399 __kfifo_from_user 3 20399 NULL nohasharray
105369 +SyS_get_mempolicy_20399 SyS_get_mempolicy 3-4 20399 &__kfifo_from_user_20399
105370 +btrfs_set_acl_20440 btrfs_set_acl 0 20440 NULL
105371 +nfs3_setxattr_20458 nfs3_setxattr 4 20458 NULL
105372 +compat_ipv6_setsockopt_20468 compat_ipv6_setsockopt 5 20468 NULL
105373 +read_buf_20469 read_buf 2 20469 NULL
105374 +btrfs_get_32_20476 btrfs_get_32 0 20476 NULL
105375 +fast_user_write_20494 fast_user_write 5 20494 NULL
105376 +ocfs2_db_frozen_trigger_20503 ocfs2_db_frozen_trigger 4 20503 NULL
105377 +pcpu_alloc_area_20511 pcpu_alloc_area 0-3 20511 NULL
105378 +link_free_space_20512 link_free_space 0 20512 NULL
105379 +pcpu_depopulate_chunk_20517 pcpu_depopulate_chunk 3-2 20517 NULL
105380 +xfs_iext_realloc_direct_20521 xfs_iext_realloc_direct 2 20521 NULL
105381 +drbd_bm_resize_20522 drbd_bm_resize 2 20522 NULL
105382 +amd_create_gatt_pages_20537 amd_create_gatt_pages 1 20537 NULL
105383 +scsi_report_opcode_20551 scsi_report_opcode 3 20551 NULL
105384 +venus_create_20555 venus_create 4 20555 NULL
105385 +btrfs_super_log_root_20565 btrfs_super_log_root 0 20565 NULL
105386 +crypto_ahash_reqsize_20569 crypto_ahash_reqsize 0 20569 NULL
105387 +batadv_tt_append_diff_20588 batadv_tt_append_diff 4 20588 NULL nohasharray
105388 +ocfs2_cluster_lock_20588 ocfs2_cluster_lock 0 20588 &batadv_tt_append_diff_20588
105389 +kvm_test_age_hva_20593 kvm_test_age_hva 2 20593 NULL
105390 +sync_timeline_create_20601 sync_timeline_create 2 20601 NULL
105391 +lirc_write_20604 lirc_write 3 20604 NULL
105392 +qib_qsfp_write_20614 qib_qsfp_write 0-2-4 20614 NULL
105393 +snd_pcm_oss_prepare_20641 snd_pcm_oss_prepare 0 20641 NULL
105394 +get_extent_skip_holes_20642 get_extent_skip_holes 2 20642 NULL
105395 +kfifo_copy_to_user_20646 kfifo_copy_to_user 4-3 20646 NULL
105396 +cpulist_scnprintf_20648 cpulist_scnprintf 2-0 20648 NULL
105397 +oz_add_farewell_20652 oz_add_farewell 5 20652 NULL
105398 +oz_cdev_read_20659 oz_cdev_read 3 20659 NULL
105399 +snd_hdsp_playback_copy_20676 snd_hdsp_playback_copy 5 20676 NULL nohasharray
105400 +btrfs_qgroup_reserve_20676 btrfs_qgroup_reserve 0 20676 &snd_hdsp_playback_copy_20676
105401 +get_user_page_nowait_20682 get_user_page_nowait 3 20682 NULL nohasharray
105402 +dvb_dmxdev_buffer_read_20682 dvb_dmxdev_buffer_read 0-4 20682 &get_user_page_nowait_20682
105403 +cpumask_size_20683 cpumask_size 0 20683 NULL
105404 +btrfs_node_blockptr_20685 btrfs_node_blockptr 0 20685 NULL
105405 +gru_vtop_20689 gru_vtop 2 20689 NULL
105406 +read_file_tgt_int_stats_20697 read_file_tgt_int_stats 3 20697 NULL
105407 +i915_gem_obj_ggtt_pin_20698 i915_gem_obj_ggtt_pin 0 20698 NULL
105408 +__maestro_read_20700 __maestro_read 0 20700 NULL
105409 +cipso_v4_gentag_rng_20703 cipso_v4_gentag_rng 0 20703 NULL
105410 +pcpu_page_first_chunk_20712 pcpu_page_first_chunk 1 20712 NULL
105411 +ocfs2_read_xattr_bucket_20722 ocfs2_read_xattr_bucket 0 20722 NULL
105412 +security_context_to_sid_force_20724 security_context_to_sid_force 2 20724 NULL
105413 +io_apic_set_pci_routing_20740 io_apic_set_pci_routing 2 20740 NULL
105414 +fb_prepare_logo_20743 fb_prepare_logo 0 20743 NULL
105415 +vol_cdev_direct_write_20751 vol_cdev_direct_write 3 20751 NULL
105416 +ocfs2_align_bytes_to_clusters_20754 ocfs2_align_bytes_to_clusters 2 20754 NULL
105417 +brcmf_p2p_escan_20763 brcmf_p2p_escan 2 20763 NULL
105418 +ubi_io_read_20767 ubi_io_read 0 20767 NULL
105419 +ext4_r_blocks_count_20768 ext4_r_blocks_count 0 20768 NULL
105420 +fb_alloc_cmap_gfp_20792 fb_alloc_cmap_gfp 2 20792 NULL
105421 +iommu_range_alloc_20794 iommu_range_alloc 3 20794 NULL
105422 +iwl_dbgfs_rxon_flags_read_20795 iwl_dbgfs_rxon_flags_read 3 20795 NULL
105423 +ext4_convert_unwritten_extents_endio_20812 ext4_convert_unwritten_extents_endio 0 20812 NULL
105424 +strndup_user_20819 strndup_user 2 20819 NULL
105425 +dtf_read_channel_20831 dtf_read_channel 3 20831 NULL
105426 +wl1271_format_buffer_20834 wl1271_format_buffer 2 20834 NULL
105427 +uvc_alloc_entity_20836 uvc_alloc_entity 3-4 20836 NULL
105428 +btrfs_orphan_add_20840 btrfs_orphan_add 0 20840 NULL
105429 +p9_tag_alloc_20845 p9_tag_alloc 3 20845 NULL
105430 +nvme_trans_supported_vpd_pages_20847 nvme_trans_supported_vpd_pages 4 20847 NULL
105431 +get_name_20855 get_name 4 20855 NULL
105432 +iwl_dbgfs_pm_params_read_20866 iwl_dbgfs_pm_params_read 3 20866 NULL
105433 +snd_pcm_capture_avail_20867 snd_pcm_capture_avail 0 20867 NULL
105434 +srq_free_res_20868 srq_free_res 5 20868 NULL
105435 +ocfs2_bmap_20874 ocfs2_bmap 2 20874 NULL
105436 +cfs_cpt_table_create_20884 cfs_cpt_table_create 1 20884 NULL
105437 +rb_simple_write_20890 rb_simple_write 3 20890 NULL
105438 +sisusb_send_packet_20891 sisusb_send_packet 2 20891 NULL
105439 +key_icverrors_read_20895 key_icverrors_read 3 20895 NULL
105440 +vfio_msi_enable_20906 vfio_msi_enable 2 20906 NULL
105441 +lbs_rdbbp_write_20918 lbs_rdbbp_write 3 20918 NULL
105442 +htable_bits_20933 htable_bits 0 20933 NULL
105443 +check_eofblocks_fl_20942 check_eofblocks_fl 0 20942 NULL
105444 +altera_set_ir_post_20948 altera_set_ir_post 2 20948 NULL
105445 +rx_rx_phy_hdr_read_20950 rx_rx_phy_hdr_read 3 20950 NULL
105446 +rsxx_cram_read_20957 rsxx_cram_read 3 20957 NULL
105447 +nfs_map_name_to_uid_20962 nfs_map_name_to_uid 3 20962 NULL
105448 +snd_rme9652_playback_copy_20970 snd_rme9652_playback_copy 5 20970 NULL
105449 +alg_setsockopt_20985 alg_setsockopt 5 20985 NULL
105450 +qib_verbs_send_20999 qib_verbs_send 5-3 20999 NULL
105451 +ocfs2_free_clusters_21001 ocfs2_free_clusters 4-0 21001 NULL
105452 +btrfs_inode_ref_name_len_21024 btrfs_inode_ref_name_len 0 21024 NULL
105453 +rx_defrag_tkip_called_read_21031 rx_defrag_tkip_called_read 3 21031 NULL
105454 +lbs_threshold_read_21046 lbs_threshold_read 5 21046 NULL
105455 +reiserfs_direct_IO_21051 reiserfs_direct_IO 4 21051 NULL
105456 +proc_fault_inject_write_21058 proc_fault_inject_write 3 21058 NULL
105457 +btrfs_insert_root_21061 btrfs_insert_root 0 21061 NULL
105458 +qdisc_get_default_21072 qdisc_get_default 2 21072 NULL
105459 +event_calibration_read_21083 event_calibration_read 3 21083 NULL
105460 +bl_add_page_to_bio_21094 bl_add_page_to_bio 2 21094 NULL nohasharray
105461 +multipath_status_21094 multipath_status 5 21094 &bl_add_page_to_bio_21094
105462 +ext2_valid_block_bitmap_21101 ext2_valid_block_bitmap 3 21101 NULL
105463 +ath6kl_send_go_probe_resp_21113 ath6kl_send_go_probe_resp 3 21113 NULL
105464 +bitset_size_in_bytes_21124 bitset_size_in_bytes 0-1 21124 NULL
105465 +i2400m_rx_trace_21127 i2400m_rx_trace 3 21127 NULL
105466 +tps6586x_irq_init_21144 tps6586x_irq_init 3 21144 NULL
105467 +chunk_size_21146 chunk_size 0 21146 NULL
105468 +ocfs2_block_check_validate_21149 ocfs2_block_check_validate 2 21149 NULL
105469 +alloc_pg_vec_21159 alloc_pg_vec 3 21159 NULL
105470 +btrfs_add_root_ref_21186 btrfs_add_root_ref 0 21186 NULL
105471 +cx18_v4l2_read_21196 cx18_v4l2_read 3 21196 NULL
105472 +get_current_ntfs_time_21198 get_current_ntfs_time 0 21198 NULL
105473 +ipc_rcu_alloc_21208 ipc_rcu_alloc 1 21208 NULL
105474 +scsi_execute_req_flags_21215 scsi_execute_req_flags 5 21215 NULL
105475 +_ocfs2_free_clusters_21220 _ocfs2_free_clusters 4-0 21220 NULL
105476 +get_numpages_21227 get_numpages 0-1-2 21227 NULL
105477 +SyS_mlock_21238 SyS_mlock 1-2 21238 NULL
105478 +input_ff_create_21240 input_ff_create 2 21240 NULL
105479 +cfg80211_notify_new_peer_candidate_21242 cfg80211_notify_new_peer_candidate 4 21242 NULL
105480 +fru_length_21257 fru_length 0 21257 NULL
105481 +rtw_set_wps_beacon_21262 rtw_set_wps_beacon 3 21262 NULL
105482 +ocfs2_blocks_for_bytes_21268 ocfs2_blocks_for_bytes 0-2 21268 NULL
105483 +vmw_gmr2_bind_21305 vmw_gmr2_bind 3 21305 NULL
105484 +do_msg_fill_21307 do_msg_fill 3 21307 NULL
105485 +add_res_range_21310 add_res_range 4 21310 NULL
105486 +get_zeroed_page_21322 get_zeroed_page 0 21322 NULL
105487 +ftrace_profile_read_21327 ftrace_profile_read 3 21327 NULL
105488 +gfs2_ea_get_copy_21353 gfs2_ea_get_copy 0 21353 NULL
105489 +max77693_irq_domain_map_21357 max77693_irq_domain_map 2 21357 NULL
105490 +alloc_orinocodev_21371 alloc_orinocodev 1 21371 NULL
105491 +split_leaf_21378 split_leaf 0 21378 NULL
105492 +SYSC_rt_sigpending_21379 SYSC_rt_sigpending 2 21379 NULL
105493 +video_ioctl2_21380 video_ioctl2 2 21380 NULL
105494 +diva_get_driver_dbg_mask_21399 diva_get_driver_dbg_mask 0 21399 NULL
105495 +sle64_to_cpu_21400 sle64_to_cpu 0-1 21400 NULL
105496 +snd_m3_inw_21406 snd_m3_inw 0 21406 NULL
105497 +snapshot_read_next_21426 snapshot_read_next 0 21426 NULL
105498 +tcp_bound_to_half_wnd_21429 tcp_bound_to_half_wnd 0-2 21429 NULL
105499 +tracing_saved_cmdlines_read_21434 tracing_saved_cmdlines_read 3 21434 NULL
105500 +aggr_size_tx_agg_vs_rate_read_21438 aggr_size_tx_agg_vs_rate_read 3 21438 NULL
105501 +__ertm_hdr_size_21450 __ertm_hdr_size 0 21450 NULL
105502 +ReadISAR_21453 ReadISAR 0 21453 NULL
105503 +mei_nfc_send_21477 mei_nfc_send 3 21477 NULL
105504 +read_file_xmit_21487 read_file_xmit 3 21487 NULL
105505 +mmc_alloc_sg_21504 mmc_alloc_sg 1 21504 NULL
105506 +dma_skb_copy_datagram_iovec_21516 dma_skb_copy_datagram_iovec 3-5 21516 NULL
105507 +btrfs_file_aio_write_21520 btrfs_file_aio_write 4 21520 NULL
105508 +il_dbgfs_stations_read_21532 il_dbgfs_stations_read 3 21532 NULL
105509 +cipso_v4_map_cat_enum_hton_21540 cipso_v4_map_cat_enum_hton 0 21540 NULL
105510 +rxrpc_send_data_21553 rxrpc_send_data 5 21553 NULL
105511 +rx_rx_beacon_early_term_read_21559 rx_rx_beacon_early_term_read 3 21559 NULL
105512 +xfs_buf_read_uncached_21585 xfs_buf_read_uncached 3 21585 NULL
105513 +snd_es18xx_mixer_read_21586 snd_es18xx_mixer_read 0 21586 NULL
105514 +ocfs2_acl_from_xattr_21604 ocfs2_acl_from_xattr 2 21604 NULL
105515 +filemap_get_page_21606 filemap_get_page 2 21606 NULL
105516 +xlog_do_recovery_pass_21618 xlog_do_recovery_pass 3 21618 NULL
105517 +pci_cardbus_resource_alignment_21625 pci_cardbus_resource_alignment 0 21625 NULL
105518 +add_pin_to_irq_node_21628 add_pin_to_irq_node 2 21628 NULL
105519 +ocfs2_refcount_cow_hunk_21630 ocfs2_refcount_cow_hunk 3-4 21630 NULL
105520 +__jfs_getxattr_21631 __jfs_getxattr 0 21631 NULL
105521 +validate_nnode_21638 validate_nnode 0 21638 NULL
105522 +__irq_alloc_descs_21639 __irq_alloc_descs 2-1-0-3-4 21639 NULL
105523 +ocfs2_lock_refcount_allocators_21646 ocfs2_lock_refcount_allocators 0 21646 NULL
105524 +atalk_sendmsg_21677 atalk_sendmsg 4 21677 NULL
105525 +ocfs2_xattr_get_nolock_21678 ocfs2_xattr_get_nolock 0 21678 NULL
105526 +rtllib_alloc_txb_21687 rtllib_alloc_txb 1 21687 NULL
105527 +evdev_ioctl_handler_21705 evdev_ioctl_handler 2 21705 NULL
105528 +btrfs_find_all_leafs_21712 btrfs_find_all_leafs 0 21712 NULL
105529 +unix_skb_len_21722 unix_skb_len 0 21722 NULL
105530 +lprocfs_wr_import_21728 lprocfs_wr_import 3 21728 NULL
105531 +ocfs2_remove_rightmost_path_21729 ocfs2_remove_rightmost_path 0 21729 NULL
105532 +reiserfs_allocate_list_bitmaps_21732 reiserfs_allocate_list_bitmaps 3 21732 NULL nohasharray
105533 +ext4_split_extent_at_21732 ext4_split_extent_at 0 21732 &reiserfs_allocate_list_bitmaps_21732
105534 +vm_brk_21739 vm_brk 1-2 21739 NULL
105535 +mthca_alloc_init_21754 mthca_alloc_init 2 21754 NULL
105536 +usbat_flash_read_data_21762 usbat_flash_read_data 4 21762 NULL
105537 +gen_pool_add_21776 gen_pool_add 3-4 21776 NULL
105538 +SyS_sendfile_21777 SyS_sendfile 4 21777 NULL
105539 +atomic64_cmpxchg_21782 atomic64_cmpxchg 0 21782 NULL
105540 +xfs_da_grow_inode_int_21785 xfs_da_grow_inode_int 3 21785 NULL
105541 +dvb_generic_ioctl_21810 dvb_generic_ioctl 2 21810 NULL
105542 +__ocfs2_cluster_lock_21812 __ocfs2_cluster_lock 0 21812 NULL
105543 +wm8994_request_irq_21822 wm8994_request_irq 2 21822 NULL
105544 +oom_adj_read_21847 oom_adj_read 3 21847 NULL
105545 +gen_unique_name_21852 gen_unique_name 0 21852 NULL
105546 +lpfc_idiag_extacc_avail_get_21865 lpfc_idiag_extacc_avail_get 0-3 21865 NULL
105547 +brcms_debugfs_hardware_read_21867 brcms_debugfs_hardware_read 3 21867 NULL
105548 +sisusbcon_bmove_21873 sisusbcon_bmove 6-5-7 21873 NULL
105549 +ldlm_lock_create_21888 ldlm_lock_create 7 21888 NULL
105550 +__alloc_reserved_percpu_21895 __alloc_reserved_percpu 2-1 21895 NULL
105551 +rio_destid_first_21900 rio_destid_first 0 21900 NULL
105552 +dbAllocCtl_21911 dbAllocCtl 0 21911 NULL
105553 +qsfp_1_read_21915 qsfp_1_read 3 21915 NULL
105554 +ast_ttm_tt_create_21917 ast_ttm_tt_create 2 21917 NULL
105555 +__ocfs2_claim_clusters_21936 __ocfs2_claim_clusters 0 21936 NULL
105556 +alloc_ldt_21972 alloc_ldt 2 21972 NULL
105557 +SYSC_prctl_21980 SYSC_prctl 4 21980 NULL
105558 +rxpipe_descr_host_int_trig_rx_data_read_22001 rxpipe_descr_host_int_trig_rx_data_read 3 22001 NULL nohasharray
105559 +compat_rw_copy_check_uvector_22001 compat_rw_copy_check_uvector 3-0 22001 &rxpipe_descr_host_int_trig_rx_data_read_22001
105560 +ocfs2_reserve_cluster_bitmap_bits_22016 ocfs2_reserve_cluster_bitmap_bits 0 22016 NULL
105561 +regcache_sync_block_raw_flush_22021 regcache_sync_block_raw_flush 3-4 22021 NULL
105562 +btrfs_get_16_22023 btrfs_get_16 0 22023 NULL
105563 +i915_gem_evict_something_22028 i915_gem_evict_something 0 22028 NULL
105564 +_sp2d_min_pg_22032 _sp2d_min_pg 0 22032 NULL
105565 +zd_usb_read_fw_22049 zd_usb_read_fw 4 22049 NULL
105566 +atalk_recvmsg_22053 atalk_recvmsg 4 22053 NULL
105567 +ieee80211_if_fmt_dropped_frames_ttl_22054 ieee80211_if_fmt_dropped_frames_ttl 3 22054 NULL
105568 +btrfs_reloc_clone_csums_22077 btrfs_reloc_clone_csums 2-3 22077 NULL
105569 +write_opcode_22082 write_opcode 2 22082 NULL
105570 +mem_rw_22085 mem_rw 3 22085 NULL
105571 +snd_pcm_xrun_22088 snd_pcm_xrun 0 22088 NULL
105572 +sched_clock_cpu_22098 sched_clock_cpu 0 22098 NULL
105573 +rt2x00debug_read_crypto_stats_22109 rt2x00debug_read_crypto_stats 3 22109 NULL
105574 +shmem_add_to_page_cache_22121 shmem_add_to_page_cache 0 22121 NULL
105575 +snd_hda_codec_read_22130 snd_hda_codec_read 0 22130 NULL
105576 +SyS_sched_setaffinity_22148 SyS_sched_setaffinity 2 22148 NULL
105577 +do_tcp_sendpages_22155 do_tcp_sendpages 4 22155 NULL
105578 +remap_pud_range_22164 remap_pud_range 3-4-5 22164 NULL
105579 +__kfifo_alloc_22173 __kfifo_alloc 3 22173 NULL nohasharray
105580 +vmci_qp_broker_map_22173 vmci_qp_broker_map 3 22173 &__kfifo_alloc_22173
105581 +fls_22210 fls 0 22210 NULL
105582 +rfcomm_sock_recvmsg_22227 rfcomm_sock_recvmsg 4 22227 NULL nohasharray
105583 +bitmap_clear_bits_22227 bitmap_clear_bits 3 22227 &rfcomm_sock_recvmsg_22227
105584 +mem_write_22232 mem_write 3 22232 NULL
105585 +p9_virtio_zc_request_22240 p9_virtio_zc_request 6-5 22240 NULL
105586 +fsnotify_parent_22243 fsnotify_parent 0 22243 NULL
105587 +compat_process_vm_rw_22254 compat_process_vm_rw 3-5 22254 NULL
105588 +ping_common_sendmsg_22261 ping_common_sendmsg 5 22261 NULL
105589 +add_res_tree_22263 add_res_tree 7 22263 NULL
105590 +__btrfs_direct_write_22273 __btrfs_direct_write 4 22273 NULL
105591 +queue_max_sectors_22280 queue_max_sectors 0 22280 NULL
105592 +i915_gem_execbuffer_relocate_22294 i915_gem_execbuffer_relocate 0 22294 NULL
105593 +pci_vpd_srdt_size_22300 pci_vpd_srdt_size 0 22300 NULL nohasharray
105594 +__tun_chr_ioctl_22300 __tun_chr_ioctl 4 22300 &pci_vpd_srdt_size_22300
105595 +mesh_table_alloc_22305 mesh_table_alloc 1 22305 NULL
105596 +lov_setstripe_22307 lov_setstripe 2 22307 NULL
105597 +udpv6_sendmsg_22316 udpv6_sendmsg 4 22316 NULL
105598 +C_SYSC_msgrcv_22320 C_SYSC_msgrcv 3 22320 NULL
105599 +radix_tree_find_next_bit_22334 radix_tree_find_next_bit 3-2-0 22334 NULL
105600 +atomic_read_22342 atomic_read 0 22342 NULL
105601 +ll_lazystatfs_seq_write_22353 ll_lazystatfs_seq_write 3 22353 NULL
105602 +mlx4_db_alloc_22358 mlx4_db_alloc 3 22358 NULL
105603 +irq_reserve_irq_22360 irq_reserve_irq 1 22360 NULL nohasharray
105604 +memcg_size_22360 memcg_size 0 22360 &irq_reserve_irq_22360
105605 +snd_pcm_alsa_frames_22363 snd_pcm_alsa_frames 2 22363 NULL
105606 +tps6586x_gpio_to_irq_22365 tps6586x_gpio_to_irq 2 22365 NULL
105607 +evdev_ioctl_22371 evdev_ioctl 2 22371 NULL
105608 +alloc_large_system_hash_22391 alloc_large_system_hash 2-8-9 22391 NULL
105609 +ocfs2_assign_bh_22392 ocfs2_assign_bh 0 22392 NULL
105610 +zoran_write_22404 zoran_write 3 22404 NULL
105611 +ATOMIC_ADD_RETURN_22413 ATOMIC_ADD_RETURN 2 22413 NULL
105612 +queue_reply_22416 queue_reply 3 22416 NULL
105613 +__set_enter_print_fmt_22431 __set_enter_print_fmt 0 22431 NULL
105614 +queue_max_segments_22441 queue_max_segments 0 22441 NULL
105615 +_rtw_vmalloc_22444 _rtw_vmalloc 1 22444 NULL
105616 +handle_received_packet_22457 handle_received_packet 3 22457 NULL
105617 +mem_cgroup_read_22461 mem_cgroup_read 5 22461 NULL
105618 +btrfs_write_out_cache_22471 btrfs_write_out_cache 0 22471 NULL nohasharray
105619 +dtf_write_device_22471 dtf_write_device 3 22471 &btrfs_write_out_cache_22471
105620 +source_sink_start_ep_22472 source_sink_start_ep 0 22472 NULL
105621 +alloc_desc_22487 alloc_desc 2 22487 NULL
105622 +ecryptfs_write_22488 ecryptfs_write 4-3 22488 NULL
105623 +qib_user_sdma_alloc_header_22490 qib_user_sdma_alloc_header 2 22490 NULL
105624 +cache_write_procfs_22491 cache_write_procfs 3 22491 NULL
105625 +mp_find_ioapic_pin_22499 mp_find_ioapic_pin 0-2 22499 NULL
105626 +mutex_lock_interruptible_22505 mutex_lock_interruptible 0 22505 NULL
105627 +__btrfs_add_delayed_item_22511 __btrfs_add_delayed_item 0 22511 NULL
105628 +trim_no_bitmap_22524 trim_no_bitmap 4-3 22524 NULL
105629 +ocfs2_read_extent_block_22550 ocfs2_read_extent_block 0 22550 NULL
105630 +agp_alloc_page_array_22554 agp_alloc_page_array 1 22554 NULL
105631 +snd_pcm_hw_params_choose_22560 snd_pcm_hw_params_choose 0 22560 NULL
105632 +dbFindCtl_22587 dbFindCtl 0 22587 NULL
105633 +snapshot_read_22601 snapshot_read 3 22601 NULL
105634 +ocfs2_get_refcount_block_22610 ocfs2_get_refcount_block 0 22610 NULL
105635 +remove_breakpoint_22628 remove_breakpoint 3 22628 NULL
105636 +sctp_setsockopt_connectx_old_22631 sctp_setsockopt_connectx_old 3 22631 NULL
105637 +ide_core_cp_entry_22636 ide_core_cp_entry 3 22636 NULL
105638 +wl1271_rx_filter_get_fields_size_22638 wl1271_rx_filter_get_fields_size 0 22638 NULL
105639 +pwr_wake_on_timer_exp_read_22640 pwr_wake_on_timer_exp_read 3 22640 NULL
105640 +sysfs_attr_ns_22645 sysfs_attr_ns 0 22645 NULL
105641 +iwl_dbgfs_calib_disabled_read_22649 iwl_dbgfs_calib_disabled_read 3 22649 NULL
105642 +compat_SyS_msgrcv_22661 compat_SyS_msgrcv 3 22661 NULL
105643 +ubifs_leb_write_22679 ubifs_leb_write 4-5 22679 NULL nohasharray
105644 +ext4_ext_direct_IO_22679 ext4_ext_direct_IO 4 22679 &ubifs_leb_write_22679
105645 +fill_gap_22681 fill_gap 0 22681 NULL nohasharray
105646 +l2tp_ip_recvmsg_22681 l2tp_ip_recvmsg 4 22681 &fill_gap_22681
105647 +bch_dump_read_22685 bch_dump_read 3 22685 NULL
105648 +reg_umr_22686 reg_umr 5 22686 NULL
105649 +ocfs2_get_block_22687 ocfs2_get_block 2 22687 NULL
105650 +map_22700 map 2 22700 NULL nohasharray
105651 +btrfs_del_inode_ref_in_log_22700 btrfs_del_inode_ref_in_log 0 22700 &map_22700
105652 +alloc_libipw_22708 alloc_libipw 1 22708 NULL
105653 +ecryptfs_write_metadata_to_contents_22721 ecryptfs_write_metadata_to_contents 3 22721 NULL
105654 +cx18_copy_buf_to_user_22735 cx18_copy_buf_to_user 4-0 22735 NULL
105655 +ceph_decode_32_22738 ceph_decode_32 0 22738 NULL nohasharray
105656 +__mei_cl_send_22738 __mei_cl_send 3 22738 &ceph_decode_32_22738
105657 +iio_debugfs_write_reg_22742 iio_debugfs_write_reg 3 22742 NULL
105658 +qlcnic_sriov_init_22762 qlcnic_sriov_init 2 22762 NULL
105659 +print_frame_22769 print_frame 0 22769 NULL
105660 +ftrace_arch_read_dyn_info_22773 ftrace_arch_read_dyn_info 0 22773 NULL
105661 +ocfs2_block_group_alloc_22774 ocfs2_block_group_alloc 0 22774 NULL
105662 +pla_ocp_write_22802 pla_ocp_write 4 22802 NULL
105663 +__generic_copy_to_user_intel_22806 __generic_copy_to_user_intel 0-3 22806 NULL
105664 +clone_bio_integrity_22842 clone_bio_integrity 4 22842 NULL
105665 +read_file_rcstat_22854 read_file_rcstat 3 22854 NULL
105666 +create_attr_set_22861 create_attr_set 1 22861 NULL
105667 +vmw_execbuf_process_22885 vmw_execbuf_process 5 22885 NULL
105668 +usblp_new_writeurb_22894 usblp_new_writeurb 2 22894 NULL
105669 +mdc800_device_read_22896 mdc800_device_read 3 22896 NULL
105670 +policy_emit_config_values_22900 policy_emit_config_values 3 22900 NULL
105671 +__btrfs_add_free_space_22917 __btrfs_add_free_space 0 22917 NULL
105672 +xstateregs_set_22932 xstateregs_set 4 22932 NULL
105673 +pcpu_mem_zalloc_22948 pcpu_mem_zalloc 1 22948 NULL
105674 +alloc_sglist_22960 alloc_sglist 3-2 22960 NULL
105675 +caif_seqpkt_sendmsg_22961 caif_seqpkt_sendmsg 4 22961 NULL
105676 +vme_get_size_22964 vme_get_size 0 22964 NULL
105677 +tx_frag_key_not_found_read_22971 tx_frag_key_not_found_read 3 22971 NULL
105678 +cached_dev_cache_miss_22979 cached_dev_cache_miss 4 22979 NULL
105679 +usb_get_langid_22983 usb_get_langid 0 22983 NULL
105680 +set_msr_hyperv_22985 set_msr_hyperv 3 22985 NULL
105681 +remote_settings_file_write_22987 remote_settings_file_write 3 22987 NULL
105682 +brcmf_sdio_chip_exit_download_23001 brcmf_sdio_chip_exit_download 4 23001 NULL
105683 +viafb_dvp0_proc_write_23023 viafb_dvp0_proc_write 3 23023 NULL
105684 +cifs_local_to_utf16_bytes_23025 cifs_local_to_utf16_bytes 0 23025 NULL
105685 +ocfs2_refcount_cow_xattr_23029 ocfs2_refcount_cow_xattr 0-6-7 23029 NULL
105686 +st_status_23032 st_status 5 23032 NULL
105687 +nv50_disp_chan_create__23056 nv50_disp_chan_create_ 5 23056 NULL
105688 +comedi_buf_write_n_available_23057 comedi_buf_write_n_available 0 23057 NULL
105689 +reiserfs_add_entry_23062 reiserfs_add_entry 4 23062 NULL nohasharray
105690 +unix_seqpacket_recvmsg_23062 unix_seqpacket_recvmsg 4 23062 &reiserfs_add_entry_23062
105691 +mei_cl_send_23068 mei_cl_send 3 23068 NULL
105692 +filp_close_23071 filp_close 0 23071 NULL
105693 +kvm_mmu_gva_to_gpa_write_23075 kvm_mmu_gva_to_gpa_write 0 23075 NULL
105694 +vm_map_ram_23078 vm_map_ram 3 23078 NULL nohasharray
105695 +raw_sendmsg_23078 raw_sendmsg 4 23078 &vm_map_ram_23078
105696 +get_user_hdr_len_23079 get_user_hdr_len 0 23079 NULL
105697 +isr_tx_procs_read_23084 isr_tx_procs_read 3 23084 NULL
105698 +lnw_gpio_irq_map_23087 lnw_gpio_irq_map 2 23087 NULL
105699 +rt2x00debug_write_eeprom_23091 rt2x00debug_write_eeprom 3 23091 NULL
105700 +__add_prelim_ref_23095 __add_prelim_ref 0 23095 NULL
105701 +fls_long_23096 fls_long 0 23096 NULL
105702 +ntfs_ucstonls_23097 ntfs_ucstonls 5-3 23097 NULL
105703 +pipe_iov_copy_from_user_23102 pipe_iov_copy_from_user 3 23102 NULL
105704 +dgram_recvmsg_23104 dgram_recvmsg 4 23104 NULL
105705 +ip_recv_error_23109 ip_recv_error 3 23109 NULL
105706 +mwl8k_cmd_set_beacon_23110 mwl8k_cmd_set_beacon 4 23110 NULL
105707 +nl80211_send_rx_auth_23111 nl80211_send_rx_auth 4 23111 NULL
105708 +__clear_user_23118 __clear_user 0-2 23118 NULL
105709 +drm_mode_create_tv_properties_23122 drm_mode_create_tv_properties 2 23122 NULL
105710 +ata_scsi_change_queue_depth_23126 ata_scsi_change_queue_depth 2 23126 NULL
105711 +ext3_listxattr_23137 ext3_listxattr 3 23137 NULL
105712 +read_file_ani_23161 read_file_ani 3 23161 NULL
105713 +tg_get_cfs_quota_23176 tg_get_cfs_quota 0 23176 NULL
105714 +usblp_write_23178 usblp_write 3 23178 NULL
105715 +msnd_fifo_alloc_23179 msnd_fifo_alloc 2 23179 NULL
105716 +gss_pipe_downcall_23182 gss_pipe_downcall 3 23182 NULL
105717 +fix_unclean_leb_23188 fix_unclean_leb 3 23188 NULL
105718 +mpi_alloc_limb_space_23190 mpi_alloc_limb_space 1 23190 NULL
105719 +convert_ip_to_linear_23198 convert_ip_to_linear 0 23198 NULL
105720 +pm80x_free_irq_23210 pm80x_free_irq 2 23210 NULL
105721 +tty_buffer_request_room_23228 tty_buffer_request_room 2-0 23228 NULL
105722 +__read_status_pci_23229 __read_status_pci 0 23229 NULL nohasharray
105723 +xlog_get_bp_23229 xlog_get_bp 2 23229 &__read_status_pci_23229
105724 +ft1000_read_dpram_mag_32_23232 ft1000_read_dpram_mag_32 0 23232 NULL
105725 +rxrpc_client_sendmsg_23236 rxrpc_client_sendmsg 5 23236 NULL
105726 +__gfn_to_rmap_23240 __gfn_to_rmap 2-1 23240 NULL
105727 +sctp_recvmsg_23265 sctp_recvmsg 4 23265 NULL
105728 +uwb_dev_addr_print_23282 uwb_dev_addr_print 2 23282 NULL
105729 +diva_get_trace_filter_23286 diva_get_trace_filter 0 23286 NULL
105730 +gru_preload_tlb_23305 gru_preload_tlb 7-4 23305 NULL
105731 +i2cdev_write_23310 i2cdev_write 3 23310 NULL
105732 +__aa_kvmalloc_23320 __aa_kvmalloc 1 23320 NULL
105733 +__es_remove_extent_23323 __es_remove_extent 0 23323 NULL
105734 +page_readlink_23346 page_readlink 3 23346 NULL
105735 +kmem_zalloc_large_23351 kmem_zalloc_large 1 23351 NULL
105736 +get_dst_timing_23358 get_dst_timing 0 23358 NULL
105737 +fd_setup_write_same_buf_23369 fd_setup_write_same_buf 3 23369 NULL
105738 +iscsi_change_queue_depth_23416 iscsi_change_queue_depth 2 23416 NULL
105739 +vga_mm_r_23419 vga_mm_r 0 23419 NULL
105740 +vzalloc_node_23424 vzalloc_node 1-2 23424 NULL
105741 +__ctzsi2_23444 __ctzsi2 1 23444 NULL
105742 +ocfs2_zero_tail_23447 ocfs2_zero_tail 3 23447 NULL
105743 +hidraw_send_report_23449 hidraw_send_report 3 23449 NULL
105744 +__ata_change_queue_depth_23484 __ata_change_queue_depth 3-0 23484 NULL
105745 +linear_conf_23485 linear_conf 2 23485 NULL
105746 +copy_module_from_user_23492 copy_module_from_user 2 23492 NULL
105747 +event_filter_read_23494 event_filter_read 3 23494 NULL
105748 +ext4_remove_blocks_23497 ext4_remove_blocks 0 23497 NULL
105749 +lustre_acl_xattr_merge2ext_23502 lustre_acl_xattr_merge2ext 2 23502 NULL
105750 +__gfn_to_hva_many_23508 __gfn_to_hva_many 0-2 23508 NULL
105751 +devm_iio_device_alloc_23511 devm_iio_device_alloc 2 23511 NULL
105752 +__proc_cpt_table_23516 __proc_cpt_table 5 23516 NULL
105753 +ima_show_measurements_count_23536 ima_show_measurements_count 3 23536 NULL
105754 +__es_insert_extent_23543 __es_insert_extent 0 23543 NULL
105755 +xen_allocate_irq_gsi_23546 xen_allocate_irq_gsi 1-0 23546 NULL
105756 +tcp_current_mss_23552 tcp_current_mss 0 23552 NULL
105757 +dbg_leb_change_23555 dbg_leb_change 0-4 23555 NULL
105758 +btrfs_super_bytenr_23561 btrfs_super_bytenr 0 23561 NULL
105759 +venus_symlink_23570 venus_symlink 6-4 23570 NULL
105760 +iwl_dbgfs_interrupt_read_23574 iwl_dbgfs_interrupt_read 3 23574 NULL
105761 +xfpregs_get_23586 xfpregs_get 4 23586 NULL
105762 +snd_interval_min_23590 snd_interval_min 0 23590 NULL
105763 +do_mmap_pgoff_23600 do_mmap_pgoff 0 23600 NULL
105764 +islpci_mgt_transaction_23610 islpci_mgt_transaction 5 23610 NULL
105765 +ocfs2_journal_access_23616 ocfs2_journal_access 0 23616 NULL
105766 +alloc_pte_23642 alloc_pte 3 23642 NULL
105767 +__i2400mu_send_barker_23652 __i2400mu_send_barker 3 23652 NULL
105768 +sInW_23663 sInW 0 23663 NULL
105769 +SyS_connect_23669 SyS_connect 3 23669 NULL
105770 +cx18_read_23699 cx18_read 3 23699 NULL
105771 +btrfs_insert_delayed_item_23705 btrfs_insert_delayed_item 0 23705 NULL
105772 +at_get_23708 at_get 0 23708 NULL
105773 +snd_pcm_hw_refine_23721 snd_pcm_hw_refine 0 23721 NULL
105774 +mp_config_acpi_gsi_23728 mp_config_acpi_gsi 2 23728 NULL
105775 +rx_rx_dropped_frame_read_23748 rx_rx_dropped_frame_read 3 23748 NULL
105776 +__kfifo_max_r_23768 __kfifo_max_r 0-2-1 23768 NULL
105777 +svc_prepare_thread_23772 svc_prepare_thread 3 23772 NULL
105778 +__build_packet_message_23778 __build_packet_message 4-10 23778 NULL
105779 +security_inode_getxattr_23781 security_inode_getxattr 0 23781 NULL
105780 +cfg80211_inform_bss_width_frame_23782 cfg80211_inform_bss_width_frame 5 23782 NULL
105781 +mpt_free_res_23793 mpt_free_res 5 23793 NULL
105782 +map_write_23795 map_write 3 23795 NULL
105783 +diva_alloc_dma_map_23798 diva_alloc_dma_map 2 23798 NULL
105784 +rx_path_reset_read_23801 rx_path_reset_read 3 23801 NULL
105785 +ocfs2_replace_cow_23803 ocfs2_replace_cow 0 23803 NULL
105786 +__earlyonly_bootmem_alloc_23824 __earlyonly_bootmem_alloc 2 23824 NULL
105787 +lustre_msg_buflen_23827 lustre_msg_buflen 0 23827 NULL
105788 +ceph_copy_page_vector_to_user_23829 ceph_copy_page_vector_to_user 0-4-3 23829 NULL
105789 +tfrc_binsearch_23833 tfrc_binsearch 0 23833 NULL
105790 +pgdat_end_pfn_23842 pgdat_end_pfn 0 23842 NULL
105791 +iwl_dbgfs_nvm_read_23845 iwl_dbgfs_nvm_read 3 23845 NULL
105792 +p54_init_common_23850 p54_init_common 1 23850 NULL
105793 +gart_alloc_coherent_23852 gart_alloc_coherent 2 23852 NULL
105794 +bin_to_hex_dup_23853 bin_to_hex_dup 2 23853 NULL
105795 +ocfs2_xattr_get_clusters_23857 ocfs2_xattr_get_clusters 0 23857 NULL
105796 +ieee80211_if_read_dot11MeshMaxPeerLinks_23878 ieee80211_if_read_dot11MeshMaxPeerLinks 3 23878 NULL
105797 +nes_alloc_resource_23891 nes_alloc_resource 3 23891 NULL
105798 +_rtw_zvmalloc_23892 _rtw_zvmalloc 1 23892 NULL
105799 +tipc_snprintf_23893 tipc_snprintf 2-0 23893 NULL
105800 +usbg_prepare_w_request_23895 usbg_prepare_w_request 0 23895 NULL
105801 +add_new_gdb_meta_bg_23911 add_new_gdb_meta_bg 3 23911 NULL nohasharray
105802 +ieee80211_if_read_hw_queues_23911 ieee80211_if_read_hw_queues 3 23911 &add_new_gdb_meta_bg_23911
105803 +device_create_bin_file_23914 device_create_bin_file 0 23914 NULL
105804 +f2fs_getxattr_23917 f2fs_getxattr 0 23917 NULL
105805 +ipath_reg_phys_mr_23918 ipath_reg_phys_mr 3 23918 NULL nohasharray
105806 +mpihelp_mul_karatsuba_case_23918 mpihelp_mul_karatsuba_case 5-3 23918 &ipath_reg_phys_mr_23918
105807 +kvm_read_guest_23928 kvm_read_guest 4-2 23928 NULL nohasharray
105808 +intel_ring_alloc_seqno_23928 intel_ring_alloc_seqno 0 23928 &kvm_read_guest_23928
105809 +__alloc_skb_23940 __alloc_skb 4 23940 NULL
105810 +uvc_endpoint_max_bpi_23944 uvc_endpoint_max_bpi 0 23944 NULL
105811 +cifs_setxattr_23957 cifs_setxattr 4 23957 NULL
105812 +size_roundup_power2_23958 size_roundup_power2 0-1 23958 NULL
105813 +vfs_write_23971 vfs_write 0-3 23971 NULL
105814 +sddr55_write_data_23983 sddr55_write_data 4 23983 NULL
105815 +zd_usb_iowrite16v_async_23984 zd_usb_iowrite16v_async 3 23984 NULL
105816 +cxgb_alloc_mem_24007 cxgb_alloc_mem 1 24007 NULL
105817 +intel_ring_idle_24014 intel_ring_idle 0 24014 NULL
105818 +give_pages_24021 give_pages 3 24021 NULL
105819 +ocfs2_mark_extent_refcounted_24035 ocfs2_mark_extent_refcounted 6 24035 NULL
105820 +adis16400_show_serial_number_24037 adis16400_show_serial_number 3 24037 NULL
105821 +hmac_setkey_24043 hmac_setkey 3 24043 NULL
105822 +afs_cell_alloc_24052 afs_cell_alloc 2 24052 NULL
105823 +blkcipher_copy_iv_24075 blkcipher_copy_iv 3 24075 NULL
105824 +vb2_fop_read_24080 vb2_fop_read 3 24080 NULL
105825 +ocfs2_cannibalize_resv_24090 ocfs2_cannibalize_resv 3 24090 NULL
105826 +pipeline_post_proc_swi_read_24108 pipeline_post_proc_swi_read 3 24108 NULL
105827 +request_key_auth_read_24109 request_key_auth_read 3 24109 NULL
105828 +lov_brw_24122 lov_brw 4 24122 NULL
105829 +mpu401_read_24126 mpu401_read 3-0 24126 NULL
105830 +_picolcd_flash_write_24134 _picolcd_flash_write 4 24134 NULL
105831 +irnet_ctrl_write_24139 irnet_ctrl_write 3 24139 NULL
105832 +SyS_sethostname_24150 SyS_sethostname 2 24150 NULL
105833 +trim_bitmaps_24158 trim_bitmaps 3 24158 NULL
105834 +set_discard_24162 set_discard 2 24162 NULL
105835 +__copy_user_zeroing_intel_nocache_24163 __copy_user_zeroing_intel_nocache 0-3 24163 NULL
105836 +adu_read_24177 adu_read 3 24177 NULL
105837 +safe_prepare_write_buffer_24187 safe_prepare_write_buffer 3 24187 NULL
105838 +shrink_tnc_24190 shrink_tnc 0 24190 NULL
105839 +irq_remapping_setup_msi_irqs_24194 irq_remapping_setup_msi_irqs 2 24194 NULL
105840 +ieee80211_if_read_dot11MeshHWMPpreqMinInterval_24208 ieee80211_if_read_dot11MeshHWMPpreqMinInterval 3 24208 NULL
105841 +efx_vf_size_24213 efx_vf_size 0 24213 NULL
105842 +SyS_sendfile64_24220 SyS_sendfile64 4 24220 NULL
105843 +tcpprobe_sprint_24222 tcpprobe_sprint 0-2 24222 NULL
105844 +pcpu_embed_first_chunk_24224 pcpu_embed_first_chunk 3-2-1 24224 NULL nohasharray
105845 +mei_amthif_read_24224 mei_amthif_read 4 24224 &pcpu_embed_first_chunk_24224
105846 +pci_num_vf_24235 pci_num_vf 0 24235 NULL
105847 +sel_read_bool_24236 sel_read_bool 3 24236 NULL
105848 +dm_cache_save_hint_24257 dm_cache_save_hint 2 24257 NULL
105849 +em28xx_alloc_urbs_24260 em28xx_alloc_urbs 4-6 24260 NULL
105850 +calculate_sizes_24273 calculate_sizes 2 24273 NULL
105851 +thin_status_24278 thin_status 5 24278 NULL
105852 +msg_size_24288 msg_size 0 24288 NULL
105853 +ext2_free_blocks_24292 ext2_free_blocks 3-2 24292 NULL
105854 +i2c_smbus_check_pec_24297 i2c_smbus_check_pec 0 24297 NULL
105855 +map_page_24298 map_page 3-4 24298 NULL
105856 +gserial_connect_24302 gserial_connect 0 24302 NULL
105857 +btmrvl_pscmd_read_24308 btmrvl_pscmd_read 3 24308 NULL
105858 +reserve_metadata_bytes_24313 reserve_metadata_bytes 3-0 24313 NULL
105859 +ath6kl_add_bss_if_needed_24317 ath6kl_add_bss_if_needed 6 24317 NULL
105860 +ocfs2_direct_IO_get_blocks_24333 ocfs2_direct_IO_get_blocks 2 24333 NULL
105861 +si476x_radio_read_acf_blob_24336 si476x_radio_read_acf_blob 3 24336 NULL
105862 +kzalloc_node_24352 kzalloc_node 1-3 24352 NULL
105863 +qla2x00_handle_queue_full_24365 qla2x00_handle_queue_full 2 24365 NULL
105864 +cfi_read_pri_24366 cfi_read_pri 3 24366 NULL
105865 +btrfs_item_size_nr_24367 btrfs_item_size_nr 0 24367 NULL
105866 +igetword_24373 igetword 0 24373 NULL
105867 +max_io_len_24384 max_io_len 0-1 24384 NULL
105868 +mpt_alloc_res_24387 mpt_alloc_res 5 24387 NULL
105869 +osc_cur_grant_bytes_seq_write_24396 osc_cur_grant_bytes_seq_write 3 24396 NULL
105870 +pvr2_v4l2_ioctl_24398 pvr2_v4l2_ioctl 2 24398 NULL nohasharray
105871 +getxattr_24398 getxattr 4 24398 &pvr2_v4l2_ioctl_24398 nohasharray
105872 +__btrfs_write_out_cache_24398 __btrfs_write_out_cache 0 24398 &getxattr_24398
105873 +blk_update_bidi_request_24415 blk_update_bidi_request 3-4 24415 NULL
105874 +nvme_trans_log_supp_pages_24418 nvme_trans_log_supp_pages 3 24418 NULL
105875 +b43_debugfs_read_24425 b43_debugfs_read 3 24425 NULL
105876 +xenbus_file_read_24427 xenbus_file_read 3 24427 NULL
105877 +ieee80211_rx_mgmt_beacon_24430 ieee80211_rx_mgmt_beacon 3 24430 NULL
105878 +copy_and_ioctl_24434 copy_and_ioctl 4 24434 NULL
105879 +ixgbe_alloc_q_vector_24439 ixgbe_alloc_q_vector 6-4 24439 NULL
105880 +smk_user_access_24440 smk_user_access 3 24440 NULL nohasharray
105881 +rtw_set_wps_assoc_resp_24440 rtw_set_wps_assoc_resp 3 24440 &smk_user_access_24440
105882 +__push_leaf_left_24456 __push_leaf_left 0 24456 NULL
105883 +evdev_do_ioctl_24459 evdev_do_ioctl 2 24459 NULL
105884 +lbs_highsnr_write_24460 lbs_highsnr_write 3 24460 NULL
105885 +skb_copy_and_csum_datagram_iovec_24466 skb_copy_and_csum_datagram_iovec 2 24466 NULL nohasharray
105886 +ocfs2_write_cluster_by_desc_24466 ocfs2_write_cluster_by_desc 6-5 24466 &skb_copy_and_csum_datagram_iovec_24466
105887 +snd_pcm_hw_param_first_24487 snd_pcm_hw_param_first 0 24487 NULL
105888 +read_file_spec_scan_ctl_24491 read_file_spec_scan_ctl 3 24491 NULL
105889 +i915_gem_obj_offset_24494 i915_gem_obj_offset 0 24494 NULL
105890 +push_nodes_for_insert_24496 push_nodes_for_insert 0 24496 NULL
105891 +pd_video_read_24510 pd_video_read 3 24510 NULL
105892 +request_key_with_auxdata_24515 request_key_with_auxdata 4 24515 NULL
105893 +xfs_buf_get_map_24522 xfs_buf_get_map 3 24522 NULL
105894 +do_mpage_readpage_24536 do_mpage_readpage 3 24536 NULL
105895 +write_cache_pages_24562 write_cache_pages 0 24562 NULL
105896 +SyS_pselect6_24582 SyS_pselect6 1 24582 NULL
105897 +udf_compute_nr_groups_24594 udf_compute_nr_groups 0 24594 NULL
105898 +sensor_hub_get_physical_device_count_24605 sensor_hub_get_physical_device_count 0 24605 NULL nohasharray
105899 +lov_alloc_memmd_24605 lov_alloc_memmd 2 24605 &sensor_hub_get_physical_device_count_24605
105900 +SyS_poll_24620 SyS_poll 2 24620 NULL
105901 +kvm_pv_enable_async_pf_24637 kvm_pv_enable_async_pf 2 24637 NULL
105902 +context_alloc_24645 context_alloc 3 24645 NULL
105903 +blk_rq_err_bytes_24650 blk_rq_err_bytes 0 24650 NULL
105904 +btrfs_check_data_free_space_24692 btrfs_check_data_free_space 0 24692 NULL
105905 +datafab_write_data_24696 datafab_write_data 4 24696 NULL
105906 +intelfbhw_get_p1p2_24703 intelfbhw_get_p1p2 2 24703 NULL
105907 +simple_attr_read_24738 simple_attr_read 3 24738 NULL
105908 +qla2x00_change_queue_depth_24742 qla2x00_change_queue_depth 2 24742 NULL
105909 +get_dma_residue_24749 get_dma_residue 0 24749 NULL
105910 +ocfs2_cow_file_pos_24751 ocfs2_cow_file_pos 3 24751 NULL
105911 +kgdb_hex2mem_24755 kgdb_hex2mem 3 24755 NULL
105912 +kempld_read8_24756 kempld_read8 0 24756 NULL
105913 +ocfs2_read_blocks_24777 ocfs2_read_blocks 0 24777 NULL
105914 +datablob_hmac_verify_24786 datablob_hmac_verify 4 24786 NULL
105915 +cache_read_24790 cache_read 3 24790 NULL
105916 +__xfs_get_blocks_24791 __xfs_get_blocks 2 24791 NULL
105917 +i915_gem_check_wedge_24793 i915_gem_check_wedge 0 24793 NULL
105918 +user_regset_copyout_24796 user_regset_copyout 7 24796 NULL
105919 +kvm_read_guest_virt_helper_24804 kvm_read_guest_virt_helper 3-1 24804 NULL
105920 +__next_cpu_nr_24805 __next_cpu_nr 1 24805 NULL
105921 +sb_set_blocksize_24807 sb_set_blocksize 0-2 24807 NULL
105922 +ath6kl_fwlog_mask_write_24810 ath6kl_fwlog_mask_write 3 24810 NULL
105923 +comedi_buf_alloc_24822 comedi_buf_alloc 3 24822 NULL
105924 +net2272_read_24825 net2272_read 0 24825 NULL
105925 +snd_als4k_gcr_read_24840 snd_als4k_gcr_read 0 24840 NULL
105926 +btrfs_next_old_item_24843 btrfs_next_old_item 0 24843 NULL
105927 +xfs_free_file_space_24853 xfs_free_file_space 2-3 24853 NULL
105928 +snd_pcm_lib_buffer_bytes_24865 snd_pcm_lib_buffer_bytes 0 24865 NULL
105929 +pnp_alloc_24869 pnp_alloc 1 24869 NULL nohasharray
105930 +l2cap_create_basic_pdu_24869 l2cap_create_basic_pdu 3 24869 &pnp_alloc_24869
105931 +setup_buffering_24872 setup_buffering 3 24872 NULL
105932 +queues_read_24877 queues_read 3 24877 NULL
105933 +__vxge_hw_vp_initialize_24885 __vxge_hw_vp_initialize 2 24885 NULL
105934 +codec_list_read_file_24910 codec_list_read_file 3 24910 NULL
105935 +__btrfs_free_extent_24927 __btrfs_free_extent 7-0 24927 NULL nohasharray
105936 +v4l2_ctrl_new_24927 v4l2_ctrl_new 7 24927 &__btrfs_free_extent_24927
105937 +ocfs2_fiemap_24949 ocfs2_fiemap 4-3 24949 NULL
105938 +packet_sendmsg_24954 packet_sendmsg 4 24954 NULL
105939 +ensure_wear_leveling_24971 ensure_wear_leveling 0 24971 NULL
105940 +twl_i2c_write_u8_24976 twl_i2c_write_u8 3 24976 NULL
105941 +llc_ui_sendmsg_24987 llc_ui_sendmsg 4 24987 NULL
105942 +btrfs_update_delayed_inode_24988 btrfs_update_delayed_inode 0 24988 NULL
105943 +key_conf_hw_key_idx_read_25003 key_conf_hw_key_idx_read 3 25003 NULL
105944 +il_dbgfs_channels_read_25005 il_dbgfs_channels_read 3 25005 NULL
105945 +twl6030_irq_unmap_25014 twl6030_irq_unmap 2 25014 NULL
105946 +ni_660x_num_counters_25031 ni_660x_num_counters 0 25031 NULL
105947 +nfs_dns_resolve_name_25036 nfs_dns_resolve_name 3 25036 NULL
105948 +load_unaligned_zeropad_25050 load_unaligned_zeropad 0 25050 NULL
105949 +btrfs_stack_key_blockptr_25058 btrfs_stack_key_blockptr 0 25058 NULL
105950 +gs_buf_alloc_25067 gs_buf_alloc 2 25067 NULL
105951 +ll_track_pid_seq_write_25068 ll_track_pid_seq_write 3 25068 NULL
105952 +SYSC_listxattr_25072 SYSC_listxattr 3 25072 NULL
105953 +iwl_dbgfs_tx_flush_write_25091 iwl_dbgfs_tx_flush_write 3 25091 NULL
105954 +gfs2_iter_unstuffed_25099 gfs2_iter_unstuffed 0 25099 NULL nohasharray
105955 +blkg_path_25099 blkg_path 3 25099 &gfs2_iter_unstuffed_25099
105956 +snd_rawmidi_kernel_write_25106 snd_rawmidi_kernel_write 3 25106 NULL
105957 +fs32_to_cpu_25143 fs32_to_cpu 0 25143 NULL
105958 +record_new_ref_25154 record_new_ref 0 25154 NULL
105959 +ipath_init_qp_table_25167 ipath_init_qp_table 2 25167 NULL nohasharray
105960 +btrfs_delete_delayed_items_25167 btrfs_delete_delayed_items 0 25167 &ipath_init_qp_table_25167
105961 +kvm_mmu_notifier_change_pte_25169 kvm_mmu_notifier_change_pte 3 25169 NULL
105962 +sctp_getsockopt_local_addrs_25178 sctp_getsockopt_local_addrs 2 25178 NULL
105963 +res_counter_read_u64_25180 res_counter_read_u64 0 25180 NULL
105964 +send_create_inode_if_needed_25211 send_create_inode_if_needed 0 25211 NULL
105965 +security_socket_post_create_25221 security_socket_post_create 0 25221 NULL
105966 +ocfs2_block_check_compute_25223 ocfs2_block_check_compute 2 25223 NULL
105967 +dtf_write_string_25232 dtf_write_string 5 25232 NULL
105968 +mon_stat_read_25238 mon_stat_read 3 25238 NULL
105969 +nilfs_palloc_find_available_slot_25245 nilfs_palloc_find_available_slot 5-3 25245 NULL
105970 +stripe_status_25259 stripe_status 5 25259 NULL
105971 +snd_pcm_start_25273 snd_pcm_start 0 25273 NULL
105972 +crypto_alloc_instance2_25277 crypto_alloc_instance2 3 25277 NULL
105973 +vfs_writev_25278 vfs_writev 3 25278 NULL
105974 +l2tp_session_create_25286 l2tp_session_create 1 25286 NULL
105975 +ath9k_debugfs_read_buf_25316 ath9k_debugfs_read_buf 3 25316 NULL
105976 +rng_buffer_size_25348 rng_buffer_size 0 25348 NULL
105977 +SYSC_kexec_load_25361 SYSC_kexec_load 2 25361 NULL
105978 +rio_destid_next_25368 rio_destid_next 2-0 25368 NULL nohasharray
105979 +unix_mkname_25368 unix_mkname 0-2 25368 &rio_destid_next_25368
105980 +sel_read_mls_25369 sel_read_mls 3 25369 NULL
105981 +tc3589x_gpio_to_irq_25371 tc3589x_gpio_to_irq 2 25371 NULL
105982 +orphanize_inode_25382 orphanize_inode 0 25382 NULL
105983 +SyS_splice_25390 SyS_splice 5 25390 NULL
105984 +btrfs_update_reserved_bytes_25393 btrfs_update_reserved_bytes 0 25393 NULL
105985 +vsp1_entity_init_25407 vsp1_entity_init 3 25407 NULL
105986 +ebt_buf_add_pad_25413 ebt_buf_add_pad 0 25413 NULL
105987 +dai_list_read_file_25421 dai_list_read_file 3 25421 NULL
105988 +generic_file_buffered_write_25464 generic_file_buffered_write 4 25464 NULL
105989 +ipath_decode_err_25468 ipath_decode_err 3 25468 NULL
105990 +crypto_hash_digestsize_25469 crypto_hash_digestsize 0 25469 NULL
105991 +ocfs2_hamming_encode_25501 ocfs2_hamming_encode 3 25501 NULL
105992 +ivtv_buf_copy_from_user_25502 ivtv_buf_copy_from_user 4-0 25502 NULL
105993 +evm_init_hmac_25504 evm_init_hmac 0 25504 NULL
105994 +snd_pcm_plugin_build_25505 snd_pcm_plugin_build 5 25505 NULL
105995 +sb_permission_25523 sb_permission 0 25523 NULL
105996 +down_read_failed_25532 down_read_failed 2 25532 NULL
105997 +ext3_get_inode_loc_25542 ext3_get_inode_loc 0 25542 NULL
105998 +ieee80211_if_read_path_refresh_time_25545 ieee80211_if_read_path_refresh_time 3 25545 NULL
105999 +wimax_addr_scnprint_25548 wimax_addr_scnprint 2 25548 NULL
106000 +mgag200_ttm_tt_create_25550 mgag200_ttm_tt_create 2 25550 NULL
106001 +ht_print_chan_25556 ht_print_chan 0 25556 NULL
106002 +skb_tailroom_25567 skb_tailroom 0 25567 NULL
106003 +ping_recvmsg_25597 ping_recvmsg 4 25597 NULL nohasharray
106004 +find_extend_vma_25597 find_extend_vma 2 25597 &ping_recvmsg_25597
106005 +copy_user_generic_25611 copy_user_generic 0 25611 NULL
106006 +proc_coredump_filter_write_25625 proc_coredump_filter_write 3 25625 NULL
106007 +__get_user_pages_25628 __get_user_pages 0-3-4 25628 NULL nohasharray
106008 +befs_utf2nls_25628 befs_utf2nls 3 25628 &__get_user_pages_25628
106009 +__direct_map_25647 __direct_map 6-5 25647 NULL
106010 +ext2_try_to_allocate_25667 ext2_try_to_allocate 4-2-0 25667 NULL
106011 +aircable_prepare_write_buffer_25669 aircable_prepare_write_buffer 3 25669 NULL
106012 +lpfc_idiag_cmd_get_25672 lpfc_idiag_cmd_get 2 25672 NULL
106013 +sta_inactive_ms_read_25690 sta_inactive_ms_read 3 25690 NULL
106014 +ebitmap_start_positive_25703 ebitmap_start_positive 0 25703 NULL
106015 +wl1271_tx_enabled_rates_get_25712 wl1271_tx_enabled_rates_get 0 25712 NULL nohasharray
106016 +rx_filter_mc_filter_read_25712 rx_filter_mc_filter_read 3 25712 &wl1271_tx_enabled_rates_get_25712
106017 +ibmasm_new_command_25714 ibmasm_new_command 2 25714 NULL
106018 +ttm_tt_init_25717 ttm_tt_init 3 25717 NULL
106019 +sel_write_context_25726 sel_write_context 3 25726 NULL nohasharray
106020 +__alloc_bootmem_low_node_25726 __alloc_bootmem_low_node 2 25726 &sel_write_context_25726
106021 +ext2_find_near_25734 ext2_find_near 0 25734 NULL
106022 +__set_clear_dirty_25744 __set_clear_dirty 2 25744 NULL
106023 +cxgbi_device_portmap_create_25747 cxgbi_device_portmap_create 3 25747 NULL
106024 +dtf_write_channel_25748 dtf_write_channel 3 25748 NULL
106025 +event_rx_pool_read_25792 event_rx_pool_read 3 25792 NULL
106026 +sg_read_25799 sg_read 3 25799 NULL
106027 +system_enable_read_25815 system_enable_read 3 25815 NULL
106028 +realloc_buffer_25816 realloc_buffer 2 25816 NULL
106029 +ftrace_profile_init_25821 ftrace_profile_init 0 25821 NULL
106030 +mthca_map_user_db_25823 mthca_map_user_db 5 25823 NULL
106031 +pwr_missing_bcns_read_25824 pwr_missing_bcns_read 3 25824 NULL
106032 +parport_read_25855 parport_read 0 25855 NULL
106033 +xfs_dir2_sf_hdr_size_25858 xfs_dir2_sf_hdr_size 0 25858 NULL
106034 +key_attr_size_25865 key_attr_size 0 25865 NULL
106035 +ath6kl_regread_read_25884 ath6kl_regread_read 3 25884 NULL
106036 +run_delalloc_nocow_25896 run_delalloc_nocow 3-4 25896 NULL
106037 +sisusbcon_scroll_area_25899 sisusbcon_scroll_area 4-3 25899 NULL
106038 +lpfc_change_queue_depth_25905 lpfc_change_queue_depth 2 25905 NULL
106039 +nvme_trans_mode_page_create_25908 nvme_trans_mode_page_create 7-4 25908 NULL
106040 +do_jffs2_setxattr_25910 do_jffs2_setxattr 5 25910 NULL
106041 +rcname_read_25919 rcname_read 3 25919 NULL
106042 +snd_es1938_capture_copy_25930 snd_es1938_capture_copy 5 25930 NULL
106043 +key_flags_read_25931 key_flags_read 3 25931 NULL
106044 +copy_play_buf_25932 copy_play_buf 3 25932 NULL
106045 +flush_25957 flush 2 25957 NULL
106046 +video_register_device_25971 video_register_device 3 25971 NULL
106047 +udp_setsockopt_25985 udp_setsockopt 5 25985 NULL
106048 +lustre_msg_buflen_v2_25997 lustre_msg_buflen_v2 0 25997 NULL
106049 +ebt_compat_entry_padsize_26001 ebt_compat_entry_padsize 0 26001 NULL
106050 +blk_init_queue_node_26015 blk_init_queue_node 3 26015 NULL
106051 +SyS_process_vm_readv_26019 SyS_process_vm_readv 3-5 26019 NULL
106052 +irq_create_strict_mappings_26025 irq_create_strict_mappings 2-4 26025 NULL
106053 +xfs_xattr_acl_set_26028 xfs_xattr_acl_set 4 26028 NULL
106054 +mptscsih_change_queue_depth_26036 mptscsih_change_queue_depth 2 26036 NULL
106055 +selinux_inode_post_setxattr_26037 selinux_inode_post_setxattr 4 26037 NULL
106056 +tun_do_read_26047 tun_do_read 5 26047 NULL
106057 +make_bfloat_26056 make_bfloat 2 26056 NULL
106058 +keyctl_update_key_26061 keyctl_update_key 3 26061 NULL
106059 +rx_rx_wa_density_dropped_frame_read_26095 rx_rx_wa_density_dropped_frame_read 3 26095 NULL
106060 +__add_inline_refs_26096 __add_inline_refs 0 26096 NULL
106061 +dup_ref_26100 dup_ref 0 26100 NULL
106062 +intel_wrap_ring_buffer_26117 intel_wrap_ring_buffer 0 26117 NULL
106063 +read_sb_page_26119 read_sb_page 5 26119 NULL
106064 +__fswab64_26155 __fswab64 0 26155 NULL
106065 +copy_oldmem_page_26164 copy_oldmem_page 3 26164 NULL
106066 +gfs2_xattr_acl_get_26166 gfs2_xattr_acl_get 0 26166 NULL nohasharray
106067 +ath6kl_roam_table_read_26166 ath6kl_roam_table_read 3 26166 &gfs2_xattr_acl_get_26166
106068 +disk_devt_26180 disk_devt 0 26180 NULL
106069 +cgroup_setxattr_26188 cgroup_setxattr 4 26188 NULL
106070 +ieee80211_if_fmt_dot11MeshTTL_26198 ieee80211_if_fmt_dot11MeshTTL 3 26198 NULL
106071 +xfs_idata_realloc_26199 xfs_idata_realloc 2 26199 NULL
106072 +mce_write_26201 mce_write 3 26201 NULL
106073 +SyS_splice_26206 SyS_splice 5 26206 NULL
106074 +mwifiex_regrdwr_write_26225 mwifiex_regrdwr_write 3 26225 NULL
106075 +_scsih_change_queue_depth_26230 _scsih_change_queue_depth 2 26230 NULL
106076 +rxrpc_recvmsg_26233 rxrpc_recvmsg 4 26233 NULL
106077 +bio_split_26235 bio_split 2 26235 NULL
106078 +btrfs_delayed_inode_reserve_metadata_26236 btrfs_delayed_inode_reserve_metadata 0 26236 NULL
106079 +ecryptfs_read_lower_page_segment_26244 ecryptfs_read_lower_page_segment 4 26244 NULL
106080 +do_setxattr_26264 do_setxattr 0 26264 NULL
106081 +crypto_ctxsize_26278 crypto_ctxsize 0 26278 NULL
106082 +apei_resources_request_26279 apei_resources_request 0 26279 NULL
106083 +wacom_set_device_mode_26280 wacom_set_device_mode 3 26280 NULL
106084 +ext2_find_goal_26306 ext2_find_goal 0 26306 NULL
106085 +snd_pcm_plug_client_channels_buf_26309 snd_pcm_plug_client_channels_buf 0-3 26309 NULL nohasharray
106086 +pax_get_random_long_26309 pax_get_random_long 0 26309 &snd_pcm_plug_client_channels_buf_26309
106087 +pwr_wake_on_host_read_26321 pwr_wake_on_host_read 3 26321 NULL
106088 +check_can_nocow_26336 check_can_nocow 2 26336 NULL
106089 +snd_vx_check_reg_bit_26344 snd_vx_check_reg_bit 0 26344 NULL
106090 +ocfs2_duplicate_clusters_by_page_26357 ocfs2_duplicate_clusters_by_page 5-0-6-3 26357 NULL
106091 +cifs_readdata_alloc_26360 cifs_readdata_alloc 1 26360 NULL
106092 +invalidate_inode_pages2_range_26403 invalidate_inode_pages2_range 0 26403 NULL
106093 +ntty_write_26404 ntty_write 3 26404 NULL
106094 +pagemap_read_26441 pagemap_read 3 26441 NULL
106095 +tower_read_26461 tower_read 3 26461 NULL nohasharray
106096 +enc_pools_add_pages_26461 enc_pools_add_pages 1 26461 &tower_read_26461 nohasharray
106097 +numa_cpu_node_26461 numa_cpu_node 0 26461 &enc_pools_add_pages_26461
106098 +memory_present_26470 memory_present 1 26470 NULL
106099 +ib_alloc_device_26483 ib_alloc_device 1 26483 NULL
106100 +ulong_write_file_26485 ulong_write_file 3 26485 NULL
106101 +dvb_ca_en50221_io_ioctl_26490 dvb_ca_en50221_io_ioctl 2 26490 NULL
106102 +vfio_pin_pages_26494 vfio_pin_pages 1 26494 NULL
106103 +read_vmcore_26501 read_vmcore 3 26501 NULL
106104 +uhid_char_write_26502 uhid_char_write 3 26502 NULL
106105 +vfio_pci_set_msi_trigger_26507 vfio_pci_set_msi_trigger 4-3 26507 NULL
106106 +iwl_dbgfs_rf_reset_read_26512 iwl_dbgfs_rf_reset_read 3 26512 NULL
106107 +SyS_rt_sigpending_26538 SyS_rt_sigpending 2 26538 NULL
106108 +rds_message_inc_copy_to_user_26540 rds_message_inc_copy_to_user 3 26540 NULL
106109 +__vhost_add_used_n_26554 __vhost_add_used_n 3 26554 NULL
106110 +qgroup_account_ref_step3_26558 qgroup_account_ref_step3 0 26558 NULL
106111 +dio_new_bio_26562 dio_new_bio 0 26562 NULL
106112 +kvm_iommu_put_pages_26571 kvm_iommu_put_pages 2 26571 NULL
106113 +rts51x_read_mem_26577 rts51x_read_mem 4 26577 NULL
106114 +regcache_set_reg_present_26598 regcache_set_reg_present 2 26598 NULL
106115 +__unmap_single_26604 __unmap_single 2-3 26604 NULL
106116 +dev_to_node_26617 dev_to_node 0 26617 NULL
106117 +iommu_alloc_26621 iommu_alloc 4 26621 NULL
106118 +pack_value_26625 pack_value 1 26625 NULL
106119 +pwr_fix_tsf_ps_read_26627 pwr_fix_tsf_ps_read 3 26627 NULL
106120 +drm_ht_find_item_26637 drm_ht_find_item 0 26637 NULL
106121 +process_extent_26646 process_extent 0 26646 NULL nohasharray
106122 +btrfs_lookup_inode_26646 btrfs_lookup_inode 0 26646 &process_extent_26646
106123 +irq_alloc_generic_chip_26650 irq_alloc_generic_chip 2 26650 NULL nohasharray
106124 +inb_p_26650 inb_p 0 26650 &irq_alloc_generic_chip_26650
106125 +usb_reset_device_26661 usb_reset_device 0 26661 NULL
106126 +cipso_v4_map_cat_rbm_hton_26680 cipso_v4_map_cat_rbm_hton 0 26680 NULL
106127 +nouveau_namedb_create__26732 nouveau_namedb_create_ 7 26732 NULL
106128 +SyS_fcntl_26737 SyS_fcntl 3 26737 NULL
106129 +pipeline_tcp_rx_stat_fifo_int_read_26745 pipeline_tcp_rx_stat_fifo_int_read 3 26745 NULL
106130 +bos_desc_26752 bos_desc 0 26752 NULL
106131 +snd_hda_get_raw_connections_26762 snd_hda_get_raw_connections 0 26762 NULL
106132 +dma_map_single_attrs_26779 dma_map_single_attrs 0 26779 NULL
106133 +cache_save_setup_26783 cache_save_setup 0 26783 NULL
106134 +qlcnic_alloc_sds_rings_26795 qlcnic_alloc_sds_rings 2 26795 NULL
106135 +cipso_v4_genopt_26812 cipso_v4_genopt 0 26812 NULL
106136 +iwl_trans_read_mem32_26825 iwl_trans_read_mem32 0 26825 NULL
106137 +smk_write_load_26829 smk_write_load 3 26829 NULL
106138 +ept_get_level1_sp_gpa_26831 ept_get_level1_sp_gpa 0 26831 NULL
106139 +__nodes_onto_26838 __nodes_onto 4 26838 NULL
106140 +scnprint_id_26842 scnprint_id 3-0 26842 NULL
106141 +ecryptfs_miscdev_write_26847 ecryptfs_miscdev_write 3 26847 NULL
106142 +tipc_conn_sendmsg_26867 tipc_conn_sendmsg 5 26867 NULL
106143 +ath6kl_create_qos_write_26879 ath6kl_create_qos_write 3 26879 NULL
106144 +svc_print_xprts_26881 svc_print_xprts 0 26881 NULL
106145 +cfg80211_process_auth_26916 cfg80211_process_auth 3 26916 NULL
106146 +x25_asy_change_mtu_26928 x25_asy_change_mtu 2 26928 NULL
106147 +compat_mtw_from_user_26932 compat_mtw_from_user 0 26932 NULL
106148 +scsi_tgt_copy_sense_26933 scsi_tgt_copy_sense 3 26933 NULL
106149 +pwr_ps_enter_read_26935 pwr_ps_enter_read 3 26935 NULL nohasharray
106150 +sctp_setsockopt_adaptation_layer_26935 sctp_setsockopt_adaptation_layer 3 26935 &pwr_ps_enter_read_26935
106151 +remove_from_bitmap_26939 remove_from_bitmap 0 26939 NULL
106152 +create_bm_block_list_26940 create_bm_block_list 0 26940 NULL
106153 +hecubafb_write_26942 hecubafb_write 3 26942 NULL
106154 +extract_entropy_user_26952 extract_entropy_user 3 26952 NULL nohasharray
106155 +do_trimming_26952 do_trimming 3 26952 &extract_entropy_user_26952
106156 +xlog_grant_push_ail_26972 xlog_grant_push_ail 2 26972 NULL
106157 +do_direct_IO_26979 do_direct_IO 0 26979 NULL
106158 +pcf857x_irq_domain_map_26998 pcf857x_irq_domain_map 2 26998 NULL
106159 +i2c_smbus_xfer_27006 i2c_smbus_xfer 0 27006 NULL
106160 +omfs_allocate_range_27034 omfs_allocate_range 3 27034 NULL
106161 +fill_read_buf_27036 fill_read_buf 0 27036 NULL
106162 +ufs_alloc_fragments_27059 ufs_alloc_fragments 3-0-2 27059 NULL
106163 +__videobuf_alloc_vb_27062 __videobuf_alloc_vb 1 27062 NULL
106164 +ext4_convert_unwritten_extents_27064 ext4_convert_unwritten_extents 4-3-0 27064 NULL
106165 +snd_pcm_lib_period_bytes_27071 snd_pcm_lib_period_bytes 0 27071 NULL
106166 +paravirt_read_msr_27077 paravirt_read_msr 0 27077 NULL
106167 +snd_mixer_oss_set_recsrc_27080 snd_mixer_oss_set_recsrc 2 27080 NULL
106168 +alloc_fdmem_27083 alloc_fdmem 1 27083 NULL
106169 +find_first_bit_27088 find_first_bit 0-2 27088 NULL
106170 +btmrvl_hscmd_write_27089 btmrvl_hscmd_write 3 27089 NULL
106171 +nes_reg_user_mr_27106 nes_reg_user_mr 2-3 27106 NULL
106172 +__devcgroup_inode_permission_27108 __devcgroup_inode_permission 0 27108 NULL
106173 +i915_gem_execbuffer_relocate_slow_27116 i915_gem_execbuffer_relocate_slow 0 27116 NULL
106174 +get_kernel_page_27133 get_kernel_page 0 27133 NULL
106175 +__ext4_handle_dirty_metadata_27137 __ext4_handle_dirty_metadata 0 27137 NULL
106176 +drbd_get_capacity_27141 drbd_get_capacity 0 27141 NULL
106177 +pms_capture_27142 pms_capture 4 27142 NULL
106178 +btmrvl_hscfgcmd_write_27143 btmrvl_hscfgcmd_write 3 27143 NULL
106179 +snd_compr_calc_avail_27165 snd_compr_calc_avail 0 27165 NULL
106180 +ieee80211_if_read_rc_rateidx_mask_5ghz_27183 ieee80211_if_read_rc_rateidx_mask_5ghz 3 27183 NULL
106181 +get_unaligned_be32_27184 get_unaligned_be32 0 27184 NULL
106182 +__intel_ring_begin_27197 __intel_ring_begin 0 27197 NULL
106183 +__sg_alloc_table_27198 __sg_alloc_table 0 27198 NULL
106184 +ocfs2_read_blocks_sync_27210 ocfs2_read_blocks_sync 0 27210 NULL
106185 +write_kmem_27225 write_kmem 3 27225 NULL
106186 +dbAllocAG_27228 dbAllocAG 0 27228 NULL
106187 +rxrpc_request_key_27235 rxrpc_request_key 3 27235 NULL
106188 +ocfs2_journal_access_path_27243 ocfs2_journal_access_path 0 27243 NULL
106189 +ll_track_gid_seq_write_27267 ll_track_gid_seq_write 3 27267 NULL
106190 +qfq_unblock_groups_27269 qfq_unblock_groups 2 27269 NULL
106191 +comedi_alloc_devpriv_27272 comedi_alloc_devpriv 2 27272 NULL
106192 +__dma_map_cont_27289 __dma_map_cont 5 27289 NULL
106193 +copy_from_buf_27308 copy_from_buf 2-4 27308 NULL
106194 +virtqueue_add_inbuf_27312 virtqueue_add_inbuf 3 27312 NULL
106195 +write_buf_27316 write_buf 0-3 27316 NULL
106196 +ocfs2_blocks_to_clusters_27327 ocfs2_blocks_to_clusters 0-2 27327 NULL
106197 +snd_pcm_oss_write2_27332 snd_pcm_oss_write2 3-0 27332 NULL
106198 +afs_cell_create_27346 afs_cell_create 2 27346 NULL
106199 +iwl_dbgfs_csr_write_27363 iwl_dbgfs_csr_write 3 27363 NULL
106200 +pcbit_stat_27364 pcbit_stat 2 27364 NULL
106201 +lz4_compress_crypto_27387 lz4_compress_crypto 3 27387 NULL
106202 +seq_read_27411 seq_read 3 27411 NULL
106203 +ib_dma_map_sg_27413 ib_dma_map_sg 0 27413 NULL nohasharray
106204 +zalloc_cpumask_var_node_27413 zalloc_cpumask_var_node 3 27413 &ib_dma_map_sg_27413
106205 +ieee80211_if_read_smps_27416 ieee80211_if_read_smps 3 27416 NULL
106206 +ocfs2_refcount_cal_cow_clusters_27422 ocfs2_refcount_cal_cow_clusters 0-3-4 27422 NULL nohasharray
106207 +evm_inode_init_security_27422 evm_inode_init_security 0 27422 &ocfs2_refcount_cal_cow_clusters_27422
106208 +cypress_write_27423 cypress_write 4 27423 NULL
106209 +sddr09_read_data_27447 sddr09_read_data 3 27447 NULL
106210 +ktime_to_us_27455 ktime_to_us 0 27455 NULL
106211 +sk_extract_addr_27474 sk_extract_addr 0 27474 NULL
106212 +v4l2_ctrl_new_std_menu_items_27487 v4l2_ctrl_new_std_menu_items 4 27487 NULL
106213 +hcd_buffer_alloc_27495 hcd_buffer_alloc 2 27495 NULL
106214 +qib_create_cq_27497 qib_create_cq 2 27497 NULL
106215 +ip_set_get_h32_27498 ip_set_get_h32 0 27498 NULL
106216 +btrfs_get_64_27499 btrfs_get_64 0 27499 NULL
106217 +ept_walk_addr_generic_27501 ept_walk_addr_generic 4 27501 NULL
106218 +garmin_read_process_27509 garmin_read_process 3 27509 NULL
106219 +oti_alloc_cookies_27510 oti_alloc_cookies 2 27510 NULL
106220 +ib_copy_to_udata_27525 ib_copy_to_udata 3 27525 NULL
106221 +snd_sonicvibes_getdmaa_27552 snd_sonicvibes_getdmaa 0 27552 NULL
106222 +SyS_fgetxattr_27571 SyS_fgetxattr 4 27571 NULL
106223 +sco_sock_recvmsg_27572 sco_sock_recvmsg 4 27572 NULL
106224 +libipw_alloc_txb_27579 libipw_alloc_txb 1 27579 NULL
106225 +read_flush_procfs_27642 read_flush_procfs 3 27642 NULL nohasharray
106226 +nl80211_send_connect_result_27642 nl80211_send_connect_result 5-7 27642 &read_flush_procfs_27642 nohasharray
106227 +ocfs2_direct_IO_27642 ocfs2_direct_IO 4 27642 &nl80211_send_connect_result_27642 nohasharray
106228 +ocfs2_xattr_ibody_get_27642 ocfs2_xattr_ibody_get 0 27642 &ocfs2_direct_IO_27642
106229 +add_new_gdb_27643 add_new_gdb 3 27643 NULL
106230 +btrfs_fallocate_27647 btrfs_fallocate 3-4 27647 NULL
106231 +qnx6_readpages_27657 qnx6_readpages 4 27657 NULL
106232 +cdrom_read_cdda_old_27664 cdrom_read_cdda_old 4 27664 NULL
106233 +record_changed_ref_27665 record_changed_ref 0 27665 NULL
106234 +iommu_pgsize_27677 iommu_pgsize 2-0 27677 NULL
106235 +ocfs2_extend_dir_27695 ocfs2_extend_dir 4 27695 NULL
106236 +fs_path_add_from_extent_buffer_27702 fs_path_add_from_extent_buffer 4-0 27702 NULL
106237 +evm_write_key_27715 evm_write_key 3 27715 NULL
106238 +ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol_27722 ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol 3 27722 NULL
106239 +xfs_dir2_block_sfsize_27727 xfs_dir2_block_sfsize 0 27727 NULL
106240 +macvtap_skb_to_vnet_hdr_27747 macvtap_skb_to_vnet_hdr 0 27747 NULL
106241 +SyS_setsockopt_27759 SyS_setsockopt 5 27759 NULL
106242 +gpiochip_export_27776 gpiochip_export 0 27776 NULL
106243 +__lov_setstripe_27782 __lov_setstripe 2 27782 NULL
106244 +twl4030_set_gpio_dataout_27792 twl4030_set_gpio_dataout 1 27792 NULL
106245 +DivaSTraceGetMemotyRequirement_27797 DivaSTraceGetMemotyRequirement 0-1 27797 NULL
106246 +ttm_object_file_init_27804 ttm_object_file_init 2 27804 NULL nohasharray
106247 +SyS_readv_27804 SyS_readv 3 27804 &ttm_object_file_init_27804
106248 +mpihelp_mul_27805 mpihelp_mul 5-3 27805 NULL
106249 +fwtty_buffer_rx_27821 fwtty_buffer_rx 3 27821 NULL
106250 +hpt374_read_freq_27828 hpt374_read_freq 0 27828 NULL
106251 +init_header_complete_27833 init_header_complete 0 27833 NULL
106252 +read_profile_27859 read_profile 3 27859 NULL
106253 +sky2_pci_read16_27863 sky2_pci_read16 0 27863 NULL
106254 +ieee80211_if_read_dot11MeshHWMProotInterval_27873 ieee80211_if_read_dot11MeshHWMProotInterval 3 27873 NULL
106255 +process_all_extents_27879 process_all_extents 0 27879 NULL
106256 +unix_seqpacket_sendmsg_27893 unix_seqpacket_sendmsg 4 27893 NULL
106257 +gluebi_write_27905 gluebi_write 3-2 27905 NULL
106258 +SyS_ptrace_27924 SyS_ptrace 3 27924 NULL
106259 +bm_find_next_27929 bm_find_next 2 27929 NULL
106260 +check_mapped_name_27943 check_mapped_name 3 27943 NULL
106261 +i915_gem_execbuffer_reserve_object_27956 i915_gem_execbuffer_reserve_object 0 27956 NULL
106262 +tracing_clock_write_27961 tracing_clock_write 3 27961 NULL
106263 +tipc_media_addr_printf_27971 tipc_media_addr_printf 2 27971 NULL
106264 +device_register_27972 device_register 0 27972 NULL nohasharray
106265 +mic_rx_pkts_read_27972 mic_rx_pkts_read 3 27972 &device_register_27972
106266 +pci_enable_device_flags_27977 pci_enable_device_flags 0 27977 NULL
106267 +f2fs_bio_alloc_27983 f2fs_bio_alloc 2 27983 NULL
106268 +edt_ft5x06_debugfs_raw_data_read_28002 edt_ft5x06_debugfs_raw_data_read 3 28002 NULL
106269 +snd_rawmidi_write_28008 snd_rawmidi_write 3 28008 NULL
106270 +remove_extent_data_ref_28023 remove_extent_data_ref 0 28023 NULL
106271 +alloc_one_pg_vec_page_28031 alloc_one_pg_vec_page 1 28031 NULL
106272 +record_deleted_ref_28039 record_deleted_ref 0 28039 NULL
106273 +sctp_setsockopt_maxburst_28041 sctp_setsockopt_maxburst 3 28041 NULL
106274 +rts51x_xd_rw_28046 rts51x_xd_rw 3-4 28046 NULL
106275 +p9_fd_write_28050 p9_fd_write 3 28050 NULL
106276 +cx231xx_init_vbi_isoc_28053 cx231xx_init_vbi_isoc 3-2-4 28053 NULL
106277 +pool_status_28055 pool_status 5 28055 NULL
106278 +init_rs_non_canonical_28059 init_rs_non_canonical 1 28059 NULL
106279 +lpfc_idiag_mbxacc_read_28061 lpfc_idiag_mbxacc_read 3 28061 NULL
106280 +tx_frag_bad_mblk_num_read_28064 tx_frag_bad_mblk_num_read 3 28064 NULL
106281 +ext4_read_block_bitmap_nowait_28078 ext4_read_block_bitmap_nowait 2 28078 NULL
106282 +platform_get_irq_28088 platform_get_irq 0 28088 NULL
106283 +SyS_brk_28096 SyS_brk 1 28096 NULL
106284 +mmc_test_alloc_mem_28102 mmc_test_alloc_mem 2-3 28102 NULL
106285 +rx_defrag_need_defrag_read_28117 rx_defrag_need_defrag_read 3 28117 NULL
106286 +vgacon_adjust_height_28124 vgacon_adjust_height 2 28124 NULL
106287 +tipc_msg_init_28128 tipc_msg_init 4-2 28128 NULL
106288 +video_read_28148 video_read 3 28148 NULL
106289 +snd_midi_channel_alloc_set_28153 snd_midi_channel_alloc_set 1 28153 NULL
106290 +stats_dot11FCSErrorCount_read_28154 stats_dot11FCSErrorCount_read 3 28154 NULL
106291 +__add_reloc_root_28155 __add_reloc_root 0 28155 NULL
106292 +vread_28173 vread 0-3 28173 NULL
106293 +macvtap_get_user_28185 macvtap_get_user 4 28185 NULL
106294 +counter_free_res_28187 counter_free_res 5 28187 NULL
106295 +read_disk_sb_28188 read_disk_sb 2 28188 NULL
106296 +nouveau_mxm_create__28200 nouveau_mxm_create_ 4 28200 NULL
106297 +__exclude_logged_extent_28212 __exclude_logged_extent 2-0 28212 NULL
106298 +__qp_memcpy_from_queue_28220 __qp_memcpy_from_queue 3-4 28220 NULL
106299 +ocfs2_cow_sync_writeback_28221 ocfs2_cow_sync_writeback 0 28221 NULL
106300 +line6_alloc_sysex_buffer_28225 line6_alloc_sysex_buffer 4 28225 NULL
106301 +amd_nb_num_28228 amd_nb_num 0 28228 NULL
106302 +ext4_validate_block_bitmap_28243 ext4_validate_block_bitmap 3 28243 NULL
106303 +fuse_direct_IO_28275 fuse_direct_IO 4 28275 NULL
106304 +usemap_size_28281 usemap_size 0 28281 NULL
106305 +inline_xattr_size_28285 inline_xattr_size 0 28285 NULL
106306 +dma_map_sg_attrs_28289 dma_map_sg_attrs 0 28289 NULL
106307 +SyS_ppoll_28290 SyS_ppoll 2 28290 NULL
106308 +kstrtos16_from_user_28300 kstrtos16_from_user 2 28300 NULL
106309 +acpi_register_gsi_xen_28305 acpi_register_gsi_xen 2 28305 NULL nohasharray
106310 +nouveau_compat_ioctl_28305 nouveau_compat_ioctl 2 28305 &acpi_register_gsi_xen_28305
106311 +create_io_context_28306 create_io_context 2 28306 NULL
106312 +__mlock_vma_pages_range_28315 __mlock_vma_pages_range 2-3-0 28315 NULL
106313 +snd_pcm_oss_read_28317 snd_pcm_oss_read 3 28317 NULL
106314 +bm_entry_write_28338 bm_entry_write 3 28338 NULL
106315 +tcp_copy_to_iovec_28344 tcp_copy_to_iovec 3 28344 NULL
106316 +cpuset_spread_node_28351 cpuset_spread_node 0 28351 NULL nohasharray
106317 +snapshot_write_28351 snapshot_write 3 28351 &cpuset_spread_node_28351
106318 +xfs_iomap_write_unwritten_28365 xfs_iomap_write_unwritten 3-2 28365 NULL
106319 +dlmfs_file_read_28385 dlmfs_file_read 3 28385 NULL
106320 +tx_frag_cache_miss_read_28394 tx_frag_cache_miss_read 3 28394 NULL
106321 +bypass_pwup_write_28416 bypass_pwup_write 3 28416 NULL
106322 +subdev_ioctl_28417 subdev_ioctl 2 28417 NULL
106323 +get_extent_allocation_hint_28423 get_extent_allocation_hint 0 28423 NULL
106324 +ksocknal_alloc_tx_28426 ksocknal_alloc_tx 2 28426 NULL
106325 +mpage_readpages_28436 mpage_readpages 3 28436 NULL
106326 +snd_emu10k1_efx_read_28452 snd_emu10k1_efx_read 2 28452 NULL
106327 +key_mic_failures_read_28457 key_mic_failures_read 3 28457 NULL
106328 +alloc_irq_cpu_rmap_28459 alloc_irq_cpu_rmap 1 28459 NULL
106329 +vmw_du_crtc_cursor_set_28479 vmw_du_crtc_cursor_set 4-5 28479 NULL
106330 +ocfs2_backup_super_blkno_28484 ocfs2_backup_super_blkno 0-2 28484 NULL
106331 +__filemap_fdatawrite_28485 __filemap_fdatawrite 0 28485 NULL
106332 +clear_discard_28494 clear_discard 2 28494 NULL
106333 +ps_poll_upsd_utilization_read_28519 ps_poll_upsd_utilization_read 3 28519 NULL
106334 +__next_node_28521 __next_node 1-0 28521 NULL
106335 +i2400m_tx_stats_read_28527 i2400m_tx_stats_read 3 28527 NULL
106336 +sel_read_policycap_28544 sel_read_policycap 3 28544 NULL
106337 +run_delalloc_range_28545 run_delalloc_range 3-4 28545 NULL nohasharray
106338 +mptctl_getiocinfo_28545 mptctl_getiocinfo 2 28545 &run_delalloc_range_28545 nohasharray
106339 +aio_read_events_28545 aio_read_events 3 28545 &mptctl_getiocinfo_28545
106340 +sysfs_create_bin_file_28551 sysfs_create_bin_file 0 28551 NULL
106341 +b43legacy_debugfs_write_28556 b43legacy_debugfs_write 3 28556 NULL
106342 +i2o_msg_post_wait_mem_28558 i2o_msg_post_wait_mem 0 28558 NULL
106343 +asymmetric_verify_28567 asymmetric_verify 3 28567 NULL
106344 +oxygen_read32_28582 oxygen_read32 0 28582 NULL
106345 +ocfs2_read_dir_block_28587 ocfs2_read_dir_block 2 28587 NULL
106346 +extract_entropy_28604 extract_entropy 5-3 28604 NULL
106347 +kfifo_unused_28612 kfifo_unused 0 28612 NULL
106348 +mp_override_legacy_irq_28618 mp_override_legacy_irq 4 28618 NULL
106349 +snd_nm256_capture_copy_28622 snd_nm256_capture_copy 5-3 28622 NULL
106350 +setup_usemap_28636 setup_usemap 3-4 28636 NULL
106351 +qib_handle_6120_hwerrors_28642 qib_handle_6120_hwerrors 3 28642 NULL
106352 +p9_fcall_alloc_28652 p9_fcall_alloc 1 28652 NULL
106353 +read_nic_io_byte_28654 read_nic_io_byte 0 28654 NULL
106354 +btrfs_previous_item_28667 btrfs_previous_item 0 28667 NULL
106355 +blk_queue_resize_tags_28670 blk_queue_resize_tags 2 28670 NULL
106356 +__perf_sw_event_28684 __perf_sw_event 2 28684 NULL
106357 +SyS_setgroups16_28686 SyS_setgroups16 1 28686 NULL
106358 +kvm_mmu_get_page_28692 kvm_mmu_get_page 2 28692 NULL
106359 +balance_level_28707 balance_level 0 28707 NULL
106360 +drm_plane_init_28731 drm_plane_init 6 28731 NULL
106361 +alloc_irq_cfg_28734 alloc_irq_cfg 2 28734 NULL
106362 +spi_execute_28736 spi_execute 5 28736 NULL
106363 +snd_pcm_aio_write_28738 snd_pcm_aio_write 3 28738 NULL
106364 +read_file_btcoex_28743 read_file_btcoex 3 28743 NULL
106365 +max_hw_blocks_28748 max_hw_blocks 0 28748 NULL
106366 +rpc_pipe_generic_upcall_28766 rpc_pipe_generic_upcall 4 28766 NULL
106367 +atomic_inc_return_unchecked_28778 atomic_inc_return_unchecked 0 28778 NULL
106368 +ath6kl_get_num_reg_28780 ath6kl_get_num_reg 0 28780 NULL
106369 +btrfs_block_rsv_refill_28800 btrfs_block_rsv_refill 3 28800 NULL nohasharray
106370 +sel_write_member_28800 sel_write_member 3 28800 &btrfs_block_rsv_refill_28800
106371 +cgroup_file_read_28804 cgroup_file_read 3 28804 NULL
106372 +memory_bm_create_28814 memory_bm_create 0 28814 NULL
106373 +iwl_dbgfs_rxon_filter_flags_read_28832 iwl_dbgfs_rxon_filter_flags_read 3 28832 NULL
106374 +vp_request_msix_vectors_28849 vp_request_msix_vectors 2 28849 NULL
106375 +ipv6_renew_options_28867 ipv6_renew_options 5 28867 NULL
106376 +max_io_len_target_boundary_28879 max_io_len_target_boundary 0-1 28879 NULL
106377 +packet_sendmsg_spkt_28885 packet_sendmsg_spkt 4 28885 NULL
106378 +to_cblock_28899 to_cblock 0-1 28899 NULL
106379 +da9055_group_write_28904 da9055_group_write 2-3 28904 NULL
106380 +ps_upsd_timeouts_read_28924 ps_upsd_timeouts_read 3 28924 NULL
106381 +iwl_dbgfs_sleep_level_override_write_28925 iwl_dbgfs_sleep_level_override_write 3 28925 NULL
106382 +ocfs2_frozen_trigger_28929 ocfs2_frozen_trigger 4 28929 NULL
106383 +push_rx_28939 push_rx 3 28939 NULL
106384 +btrfs_trim_block_group_28963 btrfs_trim_block_group 4-3 28963 NULL
106385 +alloc_sched_domains_28972 alloc_sched_domains 1 28972 NULL
106386 +remap_pfn_range_28976 remap_pfn_range 3-4-2 28976 NULL
106387 +ext4_mb_add_groupinfo_28988 ext4_mb_add_groupinfo 2 28988 NULL
106388 +hci_sock_setsockopt_28993 hci_sock_setsockopt 5 28993 NULL
106389 +bin_uuid_28999 bin_uuid 3 28999 NULL
106390 +fd_execute_rw_29004 fd_execute_rw 3 29004 NULL nohasharray
106391 +offset_to_bitmap_29004 offset_to_bitmap 2 29004 &fd_execute_rw_29004
106392 +xz_dec_init_29029 xz_dec_init 2 29029 NULL
106393 +i915_gem_object_bind_to_vm_29035 i915_gem_object_bind_to_vm 0 29035 NULL
106394 +ieee80211_if_read_ht_opmode_29044 ieee80211_if_read_ht_opmode 3 29044 NULL
106395 +ProcessGetHostMibs_29049 ProcessGetHostMibs 0 29049 NULL nohasharray
106396 +rxrpc_sendmsg_29049 rxrpc_sendmsg 4 29049 &ProcessGetHostMibs_29049
106397 +btrfs_root_bytenr_29058 btrfs_root_bytenr 0 29058 NULL
106398 +iso_packets_buffer_init_29061 iso_packets_buffer_init 3-4 29061 NULL
106399 +roundup_64_29066 roundup_64 2-0-1 29066 NULL
106400 +lpfc_idiag_extacc_drivr_get_29067 lpfc_idiag_extacc_drivr_get 0-3 29067 NULL
106401 +sctp_getsockopt_assoc_stats_29074 sctp_getsockopt_assoc_stats 2 29074 NULL
106402 +iwl_dbgfs_log_event_write_29088 iwl_dbgfs_log_event_write 3 29088 NULL
106403 +i915_error_object_create_sized_29091 i915_error_object_create_sized 3 29091 NULL
106404 +init_cache_node_node_29092 init_cache_node_node 1 29092 NULL
106405 +isdn_ppp_write_29109 isdn_ppp_write 4 29109 NULL
106406 +snprintf_29125 snprintf 0 29125 NULL
106407 +iov_shorten_29130 iov_shorten 0 29130 NULL
106408 +proc_scsi_write_29142 proc_scsi_write 3 29142 NULL
106409 +alloc_irqs_from_29152 alloc_irqs_from 1-2-0-3 29152 NULL
106410 +kvm_mmu_notifier_clear_flush_young_29154 kvm_mmu_notifier_clear_flush_young 3 29154 NULL
106411 +drm_property_create_enum_29201 drm_property_create_enum 5 29201 NULL
106412 +wusb_prf_256_29203 wusb_prf_256 7 29203 NULL
106413 +__mm_populate_29204 __mm_populate 1-2 29204 NULL
106414 +do_shrinker_shrink_29208 do_shrinker_shrink 0 29208 NULL
106415 +rds_iw_inc_copy_to_user_29214 rds_iw_inc_copy_to_user 3 29214 NULL
106416 +iwl_dbgfs_temperature_read_29224 iwl_dbgfs_temperature_read 3 29224 NULL
106417 +nvme_trans_copy_from_user_29227 nvme_trans_copy_from_user 3 29227 NULL
106418 +irq_domain_add_linear_29236 irq_domain_add_linear 2 29236 NULL
106419 +recover_peb_29238 recover_peb 0-7-6 29238 NULL
106420 +evdev_handle_get_val_29242 evdev_handle_get_val 5-6 29242 NULL
106421 +rw_verify_area_29243 rw_verify_area 0-4 29243 NULL
106422 +security_context_to_sid_core_29248 security_context_to_sid_core 2 29248 NULL
106423 +block_div_29268 block_div 0-1-2 29268 NULL
106424 +prism2_set_genericelement_29277 prism2_set_genericelement 3 29277 NULL
106425 +bitmap_ord_to_pos_29279 bitmap_ord_to_pos 3 29279 NULL
106426 +ext4_fiemap_29296 ext4_fiemap 4 29296 NULL
106427 +sn9c102_read_29305 sn9c102_read 3 29305 NULL
106428 +replace_file_extents_29312 replace_file_extents 0 29312 NULL
106429 +__fuse_get_req_29315 __fuse_get_req 2 29315 NULL
106430 +lprocfs_write_helper_29323 lprocfs_write_helper 2 29323 NULL
106431 +kvm_handle_hva_29326 kvm_handle_hva 2 29326 NULL
106432 +tun_put_user_29337 tun_put_user 5 29337 NULL
106433 +__alloc_ei_netdev_29338 __alloc_ei_netdev 1 29338 NULL
106434 +ide_read_altstatus_29343 ide_read_altstatus 0 29343 NULL
106435 +l2cap_sock_setsockopt_old_29346 l2cap_sock_setsockopt_old 4 29346 NULL
106436 +gpiochip_find_base_29366 gpiochip_find_base 0-1 29366 NULL
106437 +ktime_us_delta_29375 ktime_us_delta 0 29375 NULL
106438 +mwifiex_cfg80211_mgmt_tx_29387 mwifiex_cfg80211_mgmt_tx 7 29387 NULL
106439 +pca953x_irq_setup_29407 pca953x_irq_setup 3 29407 NULL
106440 +btrfs_run_delayed_items_29428 btrfs_run_delayed_items 0 29428 NULL
106441 +mempool_create_29437 mempool_create 1 29437 NULL
106442 +crypto_ahash_alignmask_29445 crypto_ahash_alignmask 0 29445 NULL
106443 +p9_client_prepare_req_29448 p9_client_prepare_req 3 29448 NULL
106444 +ept_page_fault_29450 ept_page_fault 2 29450 NULL
106445 +__kmalloc_node_29455 __kmalloc_node 3 29455 NULL
106446 +validate_scan_freqs_29462 validate_scan_freqs 0 29462 NULL
106447 +SyS_flistxattr_29474 SyS_flistxattr 3 29474 NULL
106448 +do_register_entry_29478 do_register_entry 4 29478 NULL
106449 +simple_strtoul_29480 simple_strtoul 0 29480 NULL
106450 +sched_clock_local_29498 sched_clock_local 0 29498 NULL
106451 +btmrvl_pscmd_write_29504 btmrvl_pscmd_write 3 29504 NULL
106452 +btrfs_file_extent_disk_bytenr_29505 btrfs_file_extent_disk_bytenr 0 29505 NULL
106453 +write_file_regidx_29517 write_file_regidx 3 29517 NULL
106454 +atk_debugfs_ggrp_read_29522 atk_debugfs_ggrp_read 3 29522 NULL
106455 +_regmap_raw_write_29541 _regmap_raw_write 2-4 29541 NULL
106456 +vfs_read_29543 vfs_read 0-3 29543 NULL
106457 +set_brk_29551 set_brk 1-2 29551 NULL nohasharray
106458 +ftrace_write_29551 ftrace_write 3 29551 &set_brk_29551
106459 +idetape_queue_rw_tail_29562 idetape_queue_rw_tail 3 29562 NULL
106460 +leaf_dealloc_29566 leaf_dealloc 3 29566 NULL
106461 +kvm_read_guest_virt_system_29569 kvm_read_guest_virt_system 4-2 29569 NULL
106462 +p9_fd_read_29570 p9_fd_read 3 29570 NULL
106463 +lbs_lowsnr_read_29571 lbs_lowsnr_read 3 29571 NULL
106464 +iwl_dbgfs_missed_beacon_write_29586 iwl_dbgfs_missed_beacon_write 3 29586 NULL
106465 +pvr2_hdw_report_unlocked_29589 pvr2_hdw_report_unlocked 4-0 29589 NULL
106466 +dio_set_defer_completion_29599 dio_set_defer_completion 0 29599 NULL
106467 +slots_per_page_29601 slots_per_page 0 29601 NULL
106468 +osc_cached_mb_seq_write_29610 osc_cached_mb_seq_write 3 29610 NULL
106469 +nla_get_u16_29624 nla_get_u16 0 29624 NULL
106470 +tx_frag_cache_hit_read_29639 tx_frag_cache_hit_read 3 29639 NULL
106471 +sctp_make_abort_user_29654 sctp_make_abort_user 3 29654 NULL
106472 +sisusb_write_mem_bulk_29678 sisusb_write_mem_bulk 4 29678 NULL
106473 +tracepoint_probe_register_29688 tracepoint_probe_register 0 29688 NULL
106474 +__btrfs_setxattr_29689 __btrfs_setxattr 0 29689 NULL
106475 +jbd2_journal_restart_29692 jbd2_journal_restart 0 29692 NULL
106476 +lustre_posix_acl_xattr_2ext_29693 lustre_posix_acl_xattr_2ext 2 29693 NULL
106477 +posix_acl_from_xattr_29708 posix_acl_from_xattr 3 29708 NULL
106478 +probes_write_29711 probes_write 3 29711 NULL
106479 +read_cis_cache_29735 read_cis_cache 4 29735 NULL
106480 +xfs_new_eof_29737 xfs_new_eof 2 29737 NULL
106481 +std_nic_write_29752 std_nic_write 3 29752 NULL
106482 +dbAlloc_29794 dbAlloc 0 29794 NULL
106483 +ext4_trim_all_free_29806 ext4_trim_all_free 4-3-2 29806 NULL
106484 +tcp_sendpage_29829 tcp_sendpage 4 29829 NULL
106485 +scan_bitmap_block_29840 scan_bitmap_block 4 29840 NULL
106486 +__probe_kernel_write_29842 __probe_kernel_write 3 29842 NULL
106487 +kvm_read_hva_atomic_29848 kvm_read_hva_atomic 3 29848 NULL
106488 +count_partial_29850 count_partial 0 29850 NULL
106489 +radeon_ttm_tt_create_29859 radeon_ttm_tt_create 2 29859 NULL
106490 +solo_enc_alloc_29860 solo_enc_alloc 3 29860 NULL
106491 +ipv6_setsockopt_29871 ipv6_setsockopt 5 29871 NULL
106492 +tlv_put_29872 tlv_put 0 29872 NULL
106493 +scsi_end_request_29876 scsi_end_request 3 29876 NULL
106494 +changed_extent_29881 changed_extent 0 29881 NULL
106495 +crypto_aead_alignmask_29885 crypto_aead_alignmask 0 29885 NULL
106496 +lov_ost_pool_extend_29914 lov_ost_pool_extend 2 29914 NULL
106497 +write_file_queue_29922 write_file_queue 3 29922 NULL
106498 +ext4_xattr_set_acl_29930 ext4_xattr_set_acl 4 29930 NULL
106499 +__btrfs_getxattr_29947 __btrfs_getxattr 0 29947 NULL nohasharray
106500 +ipv6_recv_error_29947 ipv6_recv_error 3 29947 &__btrfs_getxattr_29947
106501 +diva_os_get_context_size_29983 diva_os_get_context_size 0 29983 NULL
106502 +arch_setup_dmar_msi_29992 arch_setup_dmar_msi 1 29992 NULL
106503 +vmci_host_setup_notify_30002 vmci_host_setup_notify 2 30002 NULL
106504 +dev_mem_write_30028 dev_mem_write 3 30028 NULL
106505 +alloc_netdev_mqs_30030 alloc_netdev_mqs 1 30030 NULL
106506 +scsi_vpd_inquiry_30040 scsi_vpd_inquiry 4 30040 NULL
106507 +drp_wmove_30043 drp_wmove 4 30043 NULL nohasharray
106508 +wrmalt_30043 wrmalt 0 30043 &drp_wmove_30043
106509 +mem_cgroup_charge_common_30047 mem_cgroup_charge_common 0 30047 NULL
106510 +SyS_write_30059 SyS_write 3 30059 NULL
106511 +cxgbi_ddp_reserve_30091 cxgbi_ddp_reserve 4 30091 NULL
106512 +snd_midi_channel_init_set_30092 snd_midi_channel_init_set 1 30092 NULL
106513 +rx_filter_data_filter_read_30098 rx_filter_data_filter_read 3 30098 NULL
106514 +defragment_dma_buffer_30113 defragment_dma_buffer 0 30113 NULL
106515 +spi_async_locked_30117 spi_async_locked 0 30117 NULL
106516 +calgary_unmap_page_30130 calgary_unmap_page 3-2 30130 NULL
106517 +recv_stream_30138 recv_stream 4 30138 NULL
106518 +u_memcpya_30139 u_memcpya 3-2 30139 NULL
106519 +elfcorehdr_read_30159 elfcorehdr_read 2 30159 NULL
106520 +alloc_switch_ctx_30165 alloc_switch_ctx 2 30165 NULL
106521 +expand_inode_data_30169 expand_inode_data 2-3 30169 NULL
106522 +btrfs_start_transaction_lflush_30178 btrfs_start_transaction_lflush 2 30178 NULL
106523 +mempool_create_page_pool_30189 mempool_create_page_pool 1 30189 NULL
106524 +drm_property_create_bitmask_30195 drm_property_create_bitmask 5 30195 NULL
106525 +snd_pcm_playback_forward_30201 snd_pcm_playback_forward 0-2 30201 NULL
106526 +usblp_ioctl_30203 usblp_ioctl 2 30203 NULL
106527 +read_4k_modal_eeprom_30212 read_4k_modal_eeprom 3 30212 NULL
106528 +bitmap_file_set_bit_30228 bitmap_file_set_bit 2 30228 NULL
106529 +shmem_unuse_inode_30263 shmem_unuse_inode 0 30263 NULL
106530 +rawv6_recvmsg_30265 rawv6_recvmsg 4 30265 NULL
106531 +hfsplus_trusted_setxattr_30270 hfsplus_trusted_setxattr 4 30270 NULL
106532 +isr_pci_pm_read_30271 isr_pci_pm_read 3 30271 NULL
106533 +compat_readv_30273 compat_readv 3 30273 NULL
106534 +lapic_register_intr_30279 lapic_register_intr 1 30279 NULL
106535 +skcipher_sendmsg_30290 skcipher_sendmsg 4 30290 NULL
106536 +pipeline_sec_frag_swi_read_30294 pipeline_sec_frag_swi_read 3 30294 NULL
106537 +tcp_sendmsg_30296 tcp_sendmsg 4 30296 NULL
106538 +osc_contention_seconds_seq_write_30305 osc_contention_seconds_seq_write 3 30305 NULL
106539 +drm_core_get_reg_ofs_30309 drm_core_get_reg_ofs 0 30309 NULL
106540 +ext4_acl_from_disk_30320 ext4_acl_from_disk 2 30320 NULL
106541 +i8254_read_30330 i8254_read 0 30330 NULL
106542 +generic_ptrace_pokedata_30338 generic_ptrace_pokedata 2 30338 NULL
106543 +resource_from_user_30341 resource_from_user 3 30341 NULL
106544 +o2nm_this_node_30342 o2nm_this_node 0 30342 NULL
106545 +__vmalloc_node_flags_30352 __vmalloc_node_flags 1-2 30352 NULL
106546 +kstrtou32_from_user_30361 kstrtou32_from_user 2 30361 NULL
106547 +inet_getid_30365 inet_getid 2 30365 NULL
106548 +C_SYSC_readv_30369 C_SYSC_readv 3 30369 NULL
106549 +blkdev_issue_zeroout_30392 blkdev_issue_zeroout 3-0 30392 NULL
106550 +c4iw_init_resource_30393 c4iw_init_resource 2-3 30393 NULL
106551 +get_kernel_pages_30397 get_kernel_pages 0 30397 NULL
106552 +_drbd_bm_find_next_zero_30415 _drbd_bm_find_next_zero 2 30415 NULL
106553 +ext3_xattr_list_30419 ext3_xattr_list 3 30419 NULL
106554 +vb2_fop_write_30420 vb2_fop_write 3 30420 NULL
106555 +tx_tx_template_prepared_read_30424 tx_tx_template_prepared_read 3 30424 NULL
106556 +mq_create_30425 mq_create 1 30425 NULL nohasharray
106557 +lstcon_session_info_30425 lstcon_session_info 6 30425 &mq_create_30425
106558 +ext4_ext_create_new_leaf_30428 ext4_ext_create_new_leaf 0 30428 NULL
106559 +enable_write_30456 enable_write 3 30456 NULL
106560 +pci_resource_alignment_30457 pci_resource_alignment 0 30457 NULL
106561 +tx_tx_template_programmed_read_30461 tx_tx_template_programmed_read 3 30461 NULL
106562 +urandom_read_30462 urandom_read 3 30462 NULL
106563 +zoran_ioctl_30465 zoran_ioctl 2 30465 NULL
106564 +i2c_ctrl_read_30467 i2c_ctrl_read 0 30467 NULL
106565 +send_rmdir_30470 send_rmdir 0 30470 NULL
106566 +i915_mutex_lock_interruptible_30474 i915_mutex_lock_interruptible 0 30474 NULL nohasharray
106567 +ocrdma_reg_user_mr_30474 ocrdma_reg_user_mr 2-3 30474 &i915_mutex_lock_interruptible_30474
106568 +write_head_30481 write_head 4 30481 NULL
106569 +adu_write_30487 adu_write 3 30487 NULL
106570 +dtim_interval_write_30489 dtim_interval_write 3 30489 NULL
106571 +btrfs_free_extent_30515 btrfs_free_extent 0 30515 NULL
106572 +dwc3_testmode_write_30516 dwc3_testmode_write 3 30516 NULL
106573 +debug_debug2_read_30526 debug_debug2_read 3 30526 NULL nohasharray
106574 +set_config_30526 set_config 0 30526 &debug_debug2_read_30526
106575 +disk_expand_part_tbl_30561 disk_expand_part_tbl 2 30561 NULL
106576 +set_le_30581 set_le 4 30581 NULL
106577 +from_cblock_30582 from_cblock 0-1 30582 NULL
106578 +blk_init_tags_30592 blk_init_tags 1 30592 NULL
106579 +i2c_hid_get_report_length_30598 i2c_hid_get_report_length 0 30598 NULL
106580 +sgl_map_user_pages_30610 sgl_map_user_pages 2-3-4 30610 NULL
106581 +SyS_msgrcv_30611 SyS_msgrcv 3 30611 NULL
106582 +macvtap_sendmsg_30629 macvtap_sendmsg 4 30629 NULL
106583 +ieee80211_if_read_dot11MeshAwakeWindowDuration_30631 ieee80211_if_read_dot11MeshAwakeWindowDuration 3 30631 NULL
106584 +compat_raw_setsockopt_30634 compat_raw_setsockopt 5 30634 NULL
106585 +mlx5_ib_alloc_fast_reg_page_list_30638 mlx5_ib_alloc_fast_reg_page_list 2 30638 NULL
106586 +SyS_listxattr_30647 SyS_listxattr 3 30647 NULL
106587 +agp_remap_30665 agp_remap 2 30665 NULL
106588 +jffs2_flash_read_30667 jffs2_flash_read 0 30667 NULL
106589 +ni_ai_fifo_read_30681 ni_ai_fifo_read 3 30681 NULL
106590 +dccp_setsockopt_ccid_30701 dccp_setsockopt_ccid 4 30701 NULL
106591 +lbs_wrbbp_write_30712 lbs_wrbbp_write 3 30712 NULL
106592 +ocfs2_find_cpos_for_left_leaf_30713 ocfs2_find_cpos_for_left_leaf 0 30713 NULL
106593 +__mutex_lock_common_30717 __mutex_lock_common 0 30717 NULL
106594 +lbs_debugfs_read_30721 lbs_debugfs_read 3 30721 NULL
106595 +snd_nm256_playback_silence_30727 snd_nm256_playback_silence 4-3 30727 NULL
106596 +snapshot_status_30744 snapshot_status 5 30744 NULL
106597 +fuse_conn_limit_write_30777 fuse_conn_limit_write 3 30777 NULL
106598 +SyS_pread64_30778 SyS_pread64 3 30778 NULL
106599 +btrfs_run_ordered_operations_30793 btrfs_run_ordered_operations 0 30793 NULL
106600 +smk_read_doi_30813 smk_read_doi 3 30813 NULL
106601 +SYSC_splice_30820 SYSC_splice 5 30820 NULL
106602 +xlog_grant_head_wait_30829 xlog_grant_head_wait 4 30829 NULL
106603 +get_kobj_path_length_30831 get_kobj_path_length 0 30831 NULL
106604 +sctp_setsockopt_auth_chunk_30843 sctp_setsockopt_auth_chunk 3 30843 NULL
106605 +cfg80211_rx_mgmt_30844 cfg80211_rx_mgmt 5 30844 NULL
106606 +wd_autoreset_write_30862 wd_autoreset_write 3 30862 NULL
106607 +ieee80211_if_fmt_dropped_frames_no_route_30884 ieee80211_if_fmt_dropped_frames_no_route 3 30884 NULL
106608 +pn_recvmsg_30887 pn_recvmsg 4 30887 NULL
106609 +sctp_setsockopt_rtoinfo_30941 sctp_setsockopt_rtoinfo 3 30941 NULL
106610 +find_free_dev_extent_30963 find_free_dev_extent 0 30963 NULL
106611 +tty_insert_flip_string_flags_30969 tty_insert_flip_string_flags 4 30969 NULL
106612 +huge_page_mask_30981 huge_page_mask 0 30981 NULL
106613 +read_file_bt_ant_diversity_30983 read_file_bt_ant_diversity 3 30983 NULL
106614 +lbs_host_sleep_read_31013 lbs_host_sleep_read 3 31013 NULL
106615 +do_setup_msi_irqs_31043 do_setup_msi_irqs 2 31043 NULL
106616 +stride_pg_count_31053 stride_pg_count 0-2-1-4-3-5 31053 NULL
106617 +lbs_failcount_read_31063 lbs_failcount_read 3 31063 NULL
106618 +find_next_bit_le_31064 find_next_bit_le 0-2-3 31064 NULL
106619 +sctp_setsockopt_context_31091 sctp_setsockopt_context 3 31091 NULL
106620 +proc_gid_map_write_31093 proc_gid_map_write 3 31093 NULL
106621 +compat_sys_get_mempolicy_31109 compat_sys_get_mempolicy 3 31109 NULL
106622 +si_calculate_power_efficiency_ratio_31111 si_calculate_power_efficiency_ratio 3-2 31111 NULL
106623 +depth_read_31112 depth_read 3 31112 NULL
106624 +kimage_normal_alloc_31140 kimage_normal_alloc 3 31140 NULL
106625 +size_inside_page_31141 size_inside_page 0-1-2 31141 NULL
106626 +w9966_v4l_read_31148 w9966_v4l_read 3 31148 NULL
106627 +ch_do_scsi_31171 ch_do_scsi 4 31171 NULL
106628 +r592_read_fifo_pio_31198 r592_read_fifo_pio 3 31198 NULL
106629 +mtdchar_readoob_31200 mtdchar_readoob 4 31200 NULL
106630 +__btrfs_free_reserved_extent_31207 __btrfs_free_reserved_extent 2 31207 NULL
106631 +kvm_mmu_page_fault_31213 kvm_mmu_page_fault 2 31213 NULL
106632 +cpumask_weight_31215 cpumask_weight 0 31215 NULL
106633 +__read_reg_31216 __read_reg 0 31216 NULL
106634 +atm_get_addr_31221 atm_get_addr 3 31221 NULL
106635 +ulist_rbtree_insert_31235 ulist_rbtree_insert 0 31235 NULL
106636 +tcp_recvmsg_31238 tcp_recvmsg 4 31238 NULL
106637 +cyy_readb_31240 cyy_readb 0 31240 NULL
106638 +_create_sg_bios_31244 _create_sg_bios 4 31244 NULL
106639 +ieee80211_if_read_last_beacon_31257 ieee80211_if_read_last_beacon 3 31257 NULL
106640 +sctp_tsnmap_find_gap_ack_31272 sctp_tsnmap_find_gap_ack 3-2 31272 NULL
106641 +uvc_simplify_fraction_31303 uvc_simplify_fraction 3 31303 NULL
106642 +push_leaf_left_31306 push_leaf_left 0 31306 NULL
106643 +sisusbcon_scroll_31315 sisusbcon_scroll 5-2-3 31315 NULL
106644 +command_file_write_31318 command_file_write 3 31318 NULL
106645 +ext4_xattr_block_list_31325 ext4_xattr_block_list 3 31325 NULL
106646 +hwerr_crcbits_31334 hwerr_crcbits 4 31334 NULL
106647 +radix_tree_insert_31336 radix_tree_insert 0 31336 NULL
106648 +em28xx_init_usb_xfer_31337 em28xx_init_usb_xfer 4-6 31337 NULL
106649 +__cpu_to_node_31345 __cpu_to_node 0 31345 NULL
106650 +outlen_write_31358 outlen_write 3 31358 NULL
106651 +ieee80211_rx_mgmt_auth_31366 ieee80211_rx_mgmt_auth 3 31366 NULL
106652 +xprt_rdma_allocate_31372 xprt_rdma_allocate 2 31372 NULL
106653 +vb2_vmalloc_get_userptr_31374 vb2_vmalloc_get_userptr 2-3 31374 NULL
106654 +trace_parser_get_init_31379 trace_parser_get_init 2 31379 NULL
106655 +inb_31388 inb 0 31388 NULL
106656 +key_ifindex_read_31411 key_ifindex_read 3 31411 NULL
106657 +i915_gem_object_put_fence_31413 i915_gem_object_put_fence 0 31413 NULL
106658 +_sp2d_max_pg_31422 _sp2d_max_pg 0 31422 NULL
106659 +TSS_checkhmac1_31429 TSS_checkhmac1 5 31429 NULL
106660 +snd_aw2_saa7146_get_hw_ptr_capture_31431 snd_aw2_saa7146_get_hw_ptr_capture 0 31431 NULL
106661 +acpi_sci_ioapic_setup_31445 acpi_sci_ioapic_setup 4 31445 NULL
106662 +transport_alloc_session_tags_31449 transport_alloc_session_tags 2-3 31449 NULL
106663 +opera1_xilinx_rw_31453 opera1_xilinx_rw 5 31453 NULL
106664 +register_ftrace_graph_31456 register_ftrace_graph 0 31456 NULL
106665 +input_get_new_minor_31464 input_get_new_minor 1 31464 NULL
106666 +do_fcntl_31468 do_fcntl 3 31468 NULL
106667 +xfs_btree_get_numrecs_31477 xfs_btree_get_numrecs 0 31477 NULL
106668 +__ext4_journal_get_write_access_31482 __ext4_journal_get_write_access 0 31482 NULL
106669 +alg_setkey_31485 alg_setkey 3 31485 NULL
106670 +rds_message_map_pages_31487 rds_message_map_pages 2 31487 NULL
106671 +qsfp_2_read_31491 qsfp_2_read 3 31491 NULL
106672 +__alloc_bootmem_31498 __alloc_bootmem 1 31498 NULL
106673 +nouveau_mc_create__31513 nouveau_mc_create_ 5 31513 NULL
106674 +hidraw_write_31536 hidraw_write 3 31536 NULL
106675 +mtd_div_by_eb_31543 mtd_div_by_eb 0-1 31543 NULL
106676 +usbvision_read_31555 usbvision_read 3 31555 NULL
106677 +tx_frag_tkip_called_read_31575 tx_frag_tkip_called_read 3 31575 NULL
106678 +get_max_inline_xattr_value_size_31578 get_max_inline_xattr_value_size 0 31578 NULL
106679 +osst_write_31581 osst_write 3 31581 NULL
106680 +snd_compr_get_avail_31584 snd_compr_get_avail 0 31584 NULL
106681 +iwl_dbgfs_ucode_tx_stats_read_31611 iwl_dbgfs_ucode_tx_stats_read 3 31611 NULL
106682 +mtd_get_user_prot_info_31616 mtd_get_user_prot_info 0 31616 NULL
106683 +arvo_sysfs_read_31617 arvo_sysfs_read 6 31617 NULL
106684 +videobuf_read_one_31637 videobuf_read_one 3 31637 NULL
106685 +pod_alloc_sysex_buffer_31651 pod_alloc_sysex_buffer 3 31651 NULL
106686 +xfer_secondary_pool_31661 xfer_secondary_pool 2 31661 NULL
106687 +emulator_set_cr_31665 emulator_set_cr 3 31665 NULL
106688 +__lgread_31668 __lgread 4 31668 NULL
106689 +forced_ps_read_31685 forced_ps_read 3 31685 NULL
106690 +fst_recover_rx_error_31687 fst_recover_rx_error 3 31687 NULL
106691 +reiserfs_in_journal_31689 reiserfs_in_journal 3 31689 NULL
106692 +gfn_to_hva_read_31728 gfn_to_hva_read 2 31728 NULL
106693 +utf16s_to_utf8s_31735 utf16s_to_utf8s 0 31735 NULL nohasharray
106694 +lu_buf_check_and_grow_31735 lu_buf_check_and_grow 2 31735 &utf16s_to_utf8s_31735
106695 +shmem_pwrite_slow_31741 shmem_pwrite_slow 3-2 31741 NULL
106696 +NCR_700_change_queue_depth_31742 NCR_700_change_queue_depth 2 31742 NULL nohasharray
106697 +input_abs_get_max_31742 input_abs_get_max 0 31742 &NCR_700_change_queue_depth_31742
106698 +muldiv64_31743 muldiv64 3-2-0 31743 NULL
106699 +stmpe_set_altfunc_31750 stmpe_set_altfunc 2 31750 NULL nohasharray
106700 +bcm_char_read_31750 bcm_char_read 3 31750 &stmpe_set_altfunc_31750
106701 +snd_seq_device_new_31753 snd_seq_device_new 4 31753 NULL
106702 +SyS_lsetxattr_31766 SyS_lsetxattr 4 31766 NULL
106703 +usblp_cache_device_id_string_31790 usblp_cache_device_id_string 0 31790 NULL
106704 +ecryptfs_send_message_locked_31801 ecryptfs_send_message_locked 2 31801 NULL
106705 +isr_rx_procs_read_31804 isr_rx_procs_read 3 31804 NULL
106706 +data_write_31805 data_write 3 31805 NULL
106707 +SyS_msgsnd_31814 SyS_msgsnd 3 31814 NULL
106708 +strnlen_user_31815 strnlen_user 0-2 31815 NULL
106709 +sta_last_signal_read_31818 sta_last_signal_read 3 31818 NULL
106710 +fsnotify_perm_31843 fsnotify_perm 0 31843 NULL
106711 +SyS_ppoll_31855 SyS_ppoll 2 31855 NULL
106712 +iwl_dbgfs_disable_ht40_write_31876 iwl_dbgfs_disable_ht40_write 3 31876 NULL
106713 +drm_mode_crtc_set_gamma_size_31881 drm_mode_crtc_set_gamma_size 2 31881 NULL
106714 +ddb_output_write_31902 ddb_output_write 3-0 31902 NULL
106715 +xattr_permission_31907 xattr_permission 0 31907 NULL
106716 +lu_buf_realloc_31915 lu_buf_realloc 2 31915 NULL
106717 +new_dir_31919 new_dir 3 31919 NULL
106718 +kmem_alloc_31920 kmem_alloc 1 31920 NULL
106719 +guestwidth_to_adjustwidth_31937 guestwidth_to_adjustwidth 0-1 31937 NULL
106720 +process_recorded_refs_if_needed_31938 process_recorded_refs_if_needed 0 31938 NULL
106721 +SYSC_sethostname_31940 SYSC_sethostname 2 31940 NULL
106722 +iov_iter_copy_from_user_31942 iov_iter_copy_from_user 4-0 31942 NULL nohasharray
106723 +read_mem_31942 read_mem 3 31942 &iov_iter_copy_from_user_31942
106724 +vb2_write_31948 vb2_write 3 31948 NULL
106725 +pvr2_ctrl_get_valname_31951 pvr2_ctrl_get_valname 4 31951 NULL
106726 +regcache_rbtree_sync_31964 regcache_rbtree_sync 2 31964 NULL
106727 +copy_from_user_toio_31966 copy_from_user_toio 3 31966 NULL
106728 +mtd_add_partition_31971 mtd_add_partition 3 31971 NULL
106729 +btrfs_insert_empty_inode_31975 btrfs_insert_empty_inode 0 31975 NULL
106730 +vx_read_status_31982 vx_read_status 0 31982 NULL nohasharray
106731 +iblock_execute_rw_31982 iblock_execute_rw 3 31982 &vx_read_status_31982
106732 +find_next_zero_bit_31990 find_next_zero_bit 3-2-0 31990 NULL
106733 +default_setup_hpet_msi_31991 default_setup_hpet_msi 1 31991 NULL
106734 +lustre_acl_xattr_merge2posix_31992 lustre_acl_xattr_merge2posix 2 31992 NULL
106735 +sysfs_create_file_31996 sysfs_create_file 0 31996 NULL
106736 +tps6586x_irq_map_32002 tps6586x_irq_map 2 32002 NULL
106737 +calc_hmac_32010 calc_hmac 3 32010 NULL
106738 +vmcs_read64_32012 vmcs_read64 0 32012 NULL
106739 +resource_alignment_32020 resource_alignment 0 32020 NULL
106740 +aead_len_32021 aead_len 0 32021 NULL
106741 +ocfs2_remove_extent_32032 ocfs2_remove_extent 4-3-0 32032 NULL
106742 +posix_acl_set_32037 posix_acl_set 4 32037 NULL
106743 +stk_read_32038 stk_read 3 32038 NULL
106744 +vmw_cursor_update_dmabuf_32045 vmw_cursor_update_dmabuf 3-4 32045 NULL
106745 +ocfs2_update_edge_lengths_32046 ocfs2_update_edge_lengths 0 32046 NULL
106746 +SYSC_llistxattr_32061 SYSC_llistxattr 3 32061 NULL
106747 +proc_scsi_devinfo_write_32064 proc_scsi_devinfo_write 3 32064 NULL
106748 +cow_file_range_inline_32091 cow_file_range_inline 3 32091 NULL
106749 +bio_alloc_32095 bio_alloc 2 32095 NULL
106750 +alloc_pwms_32100 alloc_pwms 1-2 32100 NULL
106751 +ath6kl_fwlog_read_32101 ath6kl_fwlog_read 3 32101 NULL
106752 +disk_status_32120 disk_status 4 32120 NULL
106753 +kobject_add_internal_32133 kobject_add_internal 0 32133 NULL
106754 +btrfs_split_item_32164 btrfs_split_item 0 32164 NULL
106755 +venus_link_32165 venus_link 5 32165 NULL
106756 +do_writepages_32173 do_writepages 0 32173 NULL nohasharray
106757 +ntfs_rl_realloc_nofail_32173 ntfs_rl_realloc_nofail 3 32173 &do_writepages_32173
106758 +load_header_32183 load_header 0 32183 NULL
106759 +ubi_wl_scrub_peb_32196 ubi_wl_scrub_peb 0 32196 NULL
106760 +wusb_ccm_mac_32199 wusb_ccm_mac 7 32199 NULL
106761 +__mem_cgroup_try_charge_swapin_32204 __mem_cgroup_try_charge_swapin 0 32204 NULL
106762 +riva_get_cmap_len_32218 riva_get_cmap_len 0 32218 NULL
106763 +caif_seqpkt_recvmsg_32241 caif_seqpkt_recvmsg 4 32241 NULL
106764 +lbs_lowrssi_read_32242 lbs_lowrssi_read 3 32242 NULL
106765 +ocfs2_xattr_find_entry_32260 ocfs2_xattr_find_entry 0 32260 NULL
106766 +vmalloc_user_32308 vmalloc_user 1 32308 NULL
106767 +kvm_set_spte_hva_32312 kvm_set_spte_hva 2 32312 NULL
106768 +cas_calc_tabort_32316 cas_calc_tabort 0 32316 NULL
106769 +SyS_select_32319 SyS_select 1 32319 NULL
106770 +nouveau_bar_create__32332 nouveau_bar_create_ 4 32332 NULL
106771 +nl80211_send_mlme_event_32337 nl80211_send_mlme_event 4 32337 NULL
106772 +apic_get_tmcct_32338 apic_get_tmcct 0 32338 NULL
106773 +t4_alloc_mem_32342 t4_alloc_mem 1 32342 NULL
106774 +dispatch_ioctl_32357 dispatch_ioctl 2 32357 NULL nohasharray
106775 +rx_streaming_always_write_32357 rx_streaming_always_write 3 32357 &dispatch_ioctl_32357
106776 +sel_read_initcon_32362 sel_read_initcon 3 32362 NULL nohasharray
106777 +ReadHDLCPCI_32362 ReadHDLCPCI 0 32362 &sel_read_initcon_32362
106778 +__wait_seqno_32370 __wait_seqno 0 32370 NULL
106779 +_drbd_bm_find_next_32372 _drbd_bm_find_next 2 32372 NULL
106780 +cpuset_slab_spread_node_32376 cpuset_slab_spread_node 0 32376 NULL
106781 +intel_iommu_map_32384 intel_iommu_map 4-3 32384 NULL
106782 +local_clock_32385 local_clock 0 32385 NULL
106783 +ocfs2_cancel_convert_32392 ocfs2_cancel_convert 0 32392 NULL
106784 +ll_setxattr_common_32398 ll_setxattr_common 4 32398 NULL
106785 +xfs_iext_add_indirect_multi_32400 xfs_iext_add_indirect_multi 3 32400 NULL
106786 +__add_missing_keys_32402 __add_missing_keys 0 32402 NULL
106787 +vmci_qp_alloc_32405 vmci_qp_alloc 5-3 32405 NULL
106788 +regmap_irq_map_32429 regmap_irq_map 2 32429 NULL
106789 +break_ksm_32439 break_ksm 0 32439 NULL
106790 +__ext4_handle_dirty_super_32458 __ext4_handle_dirty_super 0 32458 NULL
106791 +snd_pcm_sync_ptr_32461 snd_pcm_sync_ptr 0 32461 NULL
106792 +cache_status_32462 cache_status 5 32462 NULL
106793 +fill_readbuf_32464 fill_readbuf 3 32464 NULL
106794 +dgap_usertoboard_32490 dgap_usertoboard 4 32490 NULL
106795 +ide_driver_proc_write_32493 ide_driver_proc_write 3 32493 NULL
106796 +bypass_pwoff_write_32499 bypass_pwoff_write 3 32499 NULL
106797 +mdc_pinger_recov_seq_write_32510 mdc_pinger_recov_seq_write 3 32510 NULL
106798 +ctrl_std_val_to_sym_32516 ctrl_std_val_to_sym 5 32516 NULL
106799 +ocfs2_local_alloc_reserve_for_window_32518 ocfs2_local_alloc_reserve_for_window 0 32518 NULL
106800 +disconnect_32521 disconnect 4 32521 NULL
106801 +qsfp_read_32522 qsfp_read 0-2-4 32522 NULL
106802 +audio_get_intf_req_32524 audio_get_intf_req 0 32524 NULL nohasharray
106803 +ocfs2_refresh_qinfo_32524 ocfs2_refresh_qinfo 0 32524 &audio_get_intf_req_32524
106804 +ilo_read_32531 ilo_read 3 32531 NULL
106805 +ieee80211_if_read_estab_plinks_32533 ieee80211_if_read_estab_plinks 3 32533 NULL
106806 +format_devstat_counter_32550 format_devstat_counter 3 32550 NULL
106807 +__first_node_32558 __first_node 0 32558 NULL
106808 +aes_encrypt_fail_read_32562 aes_encrypt_fail_read 3 32562 NULL
106809 +osc_iocontrol_32565 osc_iocontrol 3 32565 NULL
106810 +mem_swapout_entry_32586 mem_swapout_entry 3 32586 NULL
106811 +pipeline_tcp_tx_stat_fifo_int_read_32589 pipeline_tcp_tx_stat_fifo_int_read 3 32589 NULL
106812 +read_file_beacon_32595 read_file_beacon 3 32595 NULL
106813 +ieee80211_if_read_dropped_frames_congestion_32603 ieee80211_if_read_dropped_frames_congestion 3 32603 NULL
106814 +irda_recvmsg_dgram_32631 irda_recvmsg_dgram 4 32631 NULL
106815 +cfg80211_roamed_32632 cfg80211_roamed 5-7 32632 NULL
106816 +ite_decode_bytes_32642 ite_decode_bytes 3 32642 NULL
106817 +kvmalloc_32646 kvmalloc 1 32646 NULL
106818 +ib_sg_dma_len_32649 ib_sg_dma_len 0 32649 NULL
106819 +generic_readlink_32654 generic_readlink 3 32654 NULL nohasharray
106820 +ftrace_startup_32654 ftrace_startup 0 32654 &generic_readlink_32654
106821 +get_unaligned_be24_32667 get_unaligned_be24 0 32667 NULL
106822 +move_addr_to_kernel_32673 move_addr_to_kernel 2 32673 NULL
106823 +apei_res_add_32674 apei_res_add 0 32674 NULL
106824 +jfs_readpages_32702 jfs_readpages 4 32702 NULL
106825 +rt2x00debug_read_queue_dump_32712 rt2x00debug_read_queue_dump 3 32712 NULL
106826 +i40e_pci_sriov_enable_32742 i40e_pci_sriov_enable 2 32742 NULL
106827 +get_arg_page_32746 get_arg_page 2 32746 NULL
106828 +megasas_change_queue_depth_32747 megasas_change_queue_depth 2 32747 NULL
106829 +stats_read_ul_32751 stats_read_ul 3 32751 NULL
106830 +begin_cmd_32766 begin_cmd 0 32766 NULL
106831 +vmci_transport_dgram_dequeue_32775 vmci_transport_dgram_dequeue 4 32775 NULL
106832 +sctp_tsnmap_grow_32784 sctp_tsnmap_grow 2 32784 NULL
106833 +ocfs2_read_inode_block_full_32790 ocfs2_read_inode_block_full 0 32790 NULL
106834 +rproc_name_read_32805 rproc_name_read 3 32805 NULL
106835 +new_tape_buffer_32866 new_tape_buffer 2 32866 NULL
106836 +io_apic_setup_irq_pin_32868 io_apic_setup_irq_pin 1-2 32868 NULL
106837 +ath6kl_usb_submit_ctrl_in_32880 ath6kl_usb_submit_ctrl_in 6 32880 NULL nohasharray
106838 +cifs_writedata_alloc_32880 cifs_writedata_alloc 1 32880 &ath6kl_usb_submit_ctrl_in_32880
106839 +vp702x_usb_inout_cmd_32884 vp702x_usb_inout_cmd 6-4 32884 NULL
106840 +ext4_get_group_number_32899 ext4_get_group_number 0-2 32899 NULL
106841 +il_dbgfs_tx_stats_read_32913 il_dbgfs_tx_stats_read 3 32913 NULL
106842 +zlib_inflate_workspacesize_32927 zlib_inflate_workspacesize 0 32927 NULL
106843 +rmap_recycle_32938 rmap_recycle 3 32938 NULL
106844 +irq_reserve_irqs_32946 irq_reserve_irqs 1-2 32946 NULL
106845 +ext4_valid_block_bitmap_32958 ext4_valid_block_bitmap 3 32958 NULL
106846 +xfs_log_reserve_32959 xfs_log_reserve 2 32959 NULL
106847 +ext4_group_overhead_blocks_32971 ext4_group_overhead_blocks 0 32971 NULL
106848 +arch_ptrace_32981 arch_ptrace 3 32981 NULL
106849 +compat_filldir_32999 compat_filldir 3 32999 NULL
106850 +btrfs_lookup_extent_info_33000 btrfs_lookup_extent_info 0 33000 NULL
106851 +ext3_alloc_blocks_33007 ext3_alloc_blocks 3-0 33007 NULL nohasharray
106852 +SyS_syslog_33007 SyS_syslog 3 33007 &ext3_alloc_blocks_33007
106853 +br_multicast_set_hash_max_33012 br_multicast_set_hash_max 2 33012 NULL
106854 +write_file_bt_ant_diversity_33019 write_file_bt_ant_diversity 3 33019 NULL
106855 +snd_pcm_prepare_33036 snd_pcm_prepare 0 33036 NULL
106856 +SYSC_lgetxattr_33049 SYSC_lgetxattr 4 33049 NULL
106857 +pipeline_dec_packet_in_fifo_full_read_33052 pipeline_dec_packet_in_fifo_full_read 3 33052 NULL
106858 +ebt_compat_match_offset_33053 ebt_compat_match_offset 0-2 33053 NULL
106859 +bitmap_resize_33054 bitmap_resize 2-3 33054 NULL
106860 +intel_ring_flush_all_caches_33059 intel_ring_flush_all_caches 0 33059 NULL
106861 +stats_dot11RTSSuccessCount_read_33065 stats_dot11RTSSuccessCount_read 3 33065 NULL
106862 +sel_read_checkreqprot_33068 sel_read_checkreqprot 3 33068 NULL
106863 +alloc_tio_33077 alloc_tio 3 33077 NULL
106864 +acl_permission_check_33083 acl_permission_check 0 33083 NULL
106865 +write_node_33121 write_node 4 33121 NULL
106866 +fb_sys_write_33130 fb_sys_write 3 33130 NULL
106867 +__len_within_target_33132 __len_within_target 0 33132 NULL
106868 +SyS_poll_33152 SyS_poll 2 33152 NULL
106869 +debug_debug6_read_33168 debug_debug6_read 3 33168 NULL
106870 +dataflash_read_fact_otp_33204 dataflash_read_fact_otp 3-2 33204 NULL
106871 +pp_read_33210 pp_read 3 33210 NULL
106872 +xfs_file_aio_write_33234 xfs_file_aio_write 4 33234 NULL nohasharray
106873 +i915_gem_object_wait_rendering__tail_33234 i915_gem_object_wait_rendering__tail 0 33234 &xfs_file_aio_write_33234
106874 +__vb2_wait_for_done_vb_33246 __vb2_wait_for_done_vb 0 33246 NULL
106875 +snd_pcm_plug_client_size_33267 snd_pcm_plug_client_size 0-2 33267 NULL
106876 +cachefiles_cook_key_33274 cachefiles_cook_key 2 33274 NULL
106877 +sync_pt_create_33282 sync_pt_create 2 33282 NULL
106878 +btrfs_delete_one_dir_name_33303 btrfs_delete_one_dir_name 0 33303 NULL
106879 +mcs7830_get_reg_33308 mcs7830_get_reg 3 33308 NULL
106880 +isku_sysfs_read_keys_easyzone_33318 isku_sysfs_read_keys_easyzone 6 33318 NULL
106881 +vx_send_irq_dsp_33329 vx_send_irq_dsp 0 33329 NULL
106882 +joydev_ioctl_33343 joydev_ioctl 2 33343 NULL
106883 +lov_stripesize_seq_write_33353 lov_stripesize_seq_write 3 33353 NULL
106884 +create_xattr_datum_33356 create_xattr_datum 5 33356 NULL nohasharray
106885 +irq_pkt_threshold_read_33356 irq_pkt_threshold_read 3 33356 &create_xattr_datum_33356
106886 +read_file_regidx_33370 read_file_regidx 3 33370 NULL
106887 +ocfs2_quota_read_33382 ocfs2_quota_read 5 33382 NULL
106888 +ieee80211_if_read_dropped_frames_no_route_33383 ieee80211_if_read_dropped_frames_no_route 3 33383 NULL
106889 +scsi_varlen_cdb_length_33385 scsi_varlen_cdb_length 0 33385 NULL
106890 +tg_get_cfs_period_33390 tg_get_cfs_period 0 33390 NULL
106891 +ocfs2_allocate_unwritten_extents_33394 ocfs2_allocate_unwritten_extents 3-2 33394 NULL
106892 +cfs_trace_copyin_string_33396 cfs_trace_copyin_string 4 33396 NULL
106893 +ext4_meta_bg_first_block_no_33408 ext4_meta_bg_first_block_no 2 33408 NULL nohasharray
106894 +snd_pcm_capture_ioctl1_33408 snd_pcm_capture_ioctl1 0 33408 &ext4_meta_bg_first_block_no_33408
106895 +ufs_getfrag_block_33409 ufs_getfrag_block 2 33409 NULL
106896 +filemap_fdatawrite_33415 filemap_fdatawrite 0 33415 NULL
106897 +dis_tap_write_33426 dis_tap_write 3 33426 NULL
106898 +ubh_scanc_33436 ubh_scanc 0-3-4 33436 NULL
106899 +message_stats_list_33440 message_stats_list 5 33440 NULL
106900 +ovs_vport_alloc_33475 ovs_vport_alloc 1 33475 NULL
106901 +create_entry_33479 create_entry 2 33479 NULL
106902 +ip_setsockopt_33487 ip_setsockopt 5 33487 NULL nohasharray
106903 +elf_map_33487 elf_map 0-2 33487 &ip_setsockopt_33487
106904 +ol_dqblk_chunk_off_33489 ol_dqblk_chunk_off 2 33489 NULL
106905 +res_counter_read_33499 res_counter_read 4 33499 NULL
106906 +fb_read_33506 fb_read 3 33506 NULL
106907 +musb_test_mode_write_33518 musb_test_mode_write 3 33518 NULL
106908 +ahash_setkey_unaligned_33521 ahash_setkey_unaligned 3 33521 NULL
106909 +nes_alloc_fast_reg_page_list_33523 nes_alloc_fast_reg_page_list 2 33523 NULL
106910 +aggr_size_rx_size_read_33526 aggr_size_rx_size_read 3 33526 NULL
106911 +acpi_gsi_to_irq_33533 acpi_gsi_to_irq 1 33533 NULL
106912 +osc_max_rpcs_in_flight_seq_write_33539 osc_max_rpcs_in_flight_seq_write 3 33539 NULL nohasharray
106913 +tomoyo_read_self_33539 tomoyo_read_self 3 33539 &osc_max_rpcs_in_flight_seq_write_33539
106914 +read_symlink_33572 read_symlink 0 33572 NULL
106915 +count_subheaders_33591 count_subheaders 0 33591 NULL
106916 +scsi_execute_33596 scsi_execute 5 33596 NULL
106917 +comedi_buf_write_n_allocated_33604 comedi_buf_write_n_allocated 0 33604 NULL
106918 +xt_compat_target_offset_33608 xt_compat_target_offset 0 33608 NULL
106919 +usb_gstrings_attach_33615 usb_gstrings_attach 3 33615 NULL nohasharray
106920 +il_dbgfs_qos_read_33615 il_dbgfs_qos_read 3 33615 &usb_gstrings_attach_33615
106921 +do_sync_write_33624 do_sync_write 0 33624 NULL
106922 +stride_page_count_33641 stride_page_count 2 33641 NULL
106923 +slab_alloc_node_33663 slab_alloc_node 3 33663 NULL
106924 +irq_blk_threshold_read_33666 irq_blk_threshold_read 3 33666 NULL
106925 +inw_p_33668 inw_p 0 33668 NULL
106926 +arp_hdr_len_33671 arp_hdr_len 0 33671 NULL
106927 +i2c_hid_alloc_buffers_33673 i2c_hid_alloc_buffers 2 33673 NULL
106928 +nv50_disp_dmac_create__33696 nv50_disp_dmac_create_ 6 33696 NULL
106929 +netlink_sendmsg_33708 netlink_sendmsg 4 33708 NULL
106930 +tipc_link_stats_33716 tipc_link_stats 3 33716 NULL
106931 +ext4_wb_update_i_disksize_33717 ext4_wb_update_i_disksize 2 33717 NULL
106932 +pvr2_stream_buffer_count_33719 pvr2_stream_buffer_count 2 33719 NULL
106933 +ocfs2_extent_map_get_blocks_33720 ocfs2_extent_map_get_blocks 2 33720 NULL
106934 +write_file_spectral_count_33723 write_file_spectral_count 3 33723 NULL nohasharray
106935 +ocfs2_lock_allocators_move_extents_33723 ocfs2_lock_allocators_move_extents 0 33723 &write_file_spectral_count_33723
106936 +__mutex_lock_interruptible_slowpath_33735 __mutex_lock_interruptible_slowpath 0 33735 NULL
106937 +do_munmap_33752 do_munmap 0 33752 NULL
106938 +vifs_state_read_33762 vifs_state_read 3 33762 NULL
106939 +hashtab_create_33769 hashtab_create 3 33769 NULL
106940 +btrfs_delayed_refs_qgroup_accounting_33775 btrfs_delayed_refs_qgroup_accounting 0 33775 NULL
106941 +irq_map_generic_chip_33793 irq_map_generic_chip 2 33793 NULL
106942 +if_sdio_read_rx_len_33800 if_sdio_read_rx_len 0 33800 NULL
106943 +find_next_offset_33804 find_next_offset 3-0 33804 NULL
106944 +filter_write_33819 filter_write 3 33819 NULL
106945 +sep_create_msgarea_context_33829 sep_create_msgarea_context 4 33829 NULL
106946 +scrub_setup_recheck_block_33831 scrub_setup_recheck_block 5-4 33831 NULL
106947 +ext4_journal_extend_33835 ext4_journal_extend 2-0 33835 NULL
106948 +snd_pcm_action_nonatomic_33844 snd_pcm_action_nonatomic 0 33844 NULL
106949 +calgary_alloc_coherent_33851 calgary_alloc_coherent 2 33851 NULL
106950 +oz_cdev_write_33852 oz_cdev_write 3 33852 NULL
106951 +bin_string_33884 bin_string 3-5 33884 NULL
106952 +get_user_pages_33908 get_user_pages 0-3-4 33908 NULL
106953 +ath6kl_roam_mode_write_33912 ath6kl_roam_mode_write 3 33912 NULL
106954 +queue_logical_block_size_33918 queue_logical_block_size 0 33918 NULL
106955 +sel_read_avc_cache_threshold_33942 sel_read_avc_cache_threshold 3 33942 NULL
106956 +lpfc_idiag_ctlacc_read_33943 lpfc_idiag_ctlacc_read 3 33943 NULL
106957 +read_file_tgt_rx_stats_33944 read_file_tgt_rx_stats 3 33944 NULL nohasharray
106958 +btrfs_uuid_tree_rem_33944 btrfs_uuid_tree_rem 0 33944 &read_file_tgt_rx_stats_33944
106959 +hfsplus_osx_setxattr_33952 hfsplus_osx_setxattr 4 33952 NULL
106960 +__proc_dump_kernel_33954 __proc_dump_kernel 5 33954 NULL
106961 +ocfs2_create_new_meta_bhs_33955 ocfs2_create_new_meta_bhs 0 33955 NULL
106962 +vga_switcheroo_debugfs_write_33984 vga_switcheroo_debugfs_write 3 33984 NULL
106963 +snd_interval_refine_33987 snd_interval_refine 0 33987 NULL
106964 +__ntfs_malloc_34022 __ntfs_malloc 1 34022 NULL
106965 +lbs_lowrssi_write_34025 lbs_lowrssi_write 3 34025 NULL
106966 +ppp_write_34034 ppp_write 3 34034 NULL
106967 +tty_insert_flip_string_34042 tty_insert_flip_string 3-0 34042 NULL
106968 +__domain_flush_pages_34045 __domain_flush_pages 2-3 34045 NULL
106969 +is_trap_at_addr_34047 is_trap_at_addr 2 34047 NULL
106970 +memcg_update_all_caches_34068 memcg_update_all_caches 1 34068 NULL
106971 +pipeline_pipeline_fifo_full_read_34095 pipeline_pipeline_fifo_full_read 3 34095 NULL
106972 +__irq_domain_add_34101 __irq_domain_add 2 34101 NULL
106973 +i915_gem_object_set_cache_level_34107 i915_gem_object_set_cache_level 0 34107 NULL nohasharray
106974 +proc_scsi_host_write_34107 proc_scsi_host_write 3 34107 &i915_gem_object_set_cache_level_34107
106975 +is_discarded_oblock_34120 is_discarded_oblock 2 34120 NULL
106976 +islpci_mgt_transmit_34133 islpci_mgt_transmit 5 34133 NULL
106977 +ttm_dma_page_pool_free_34135 ttm_dma_page_pool_free 2-0 34135 NULL
106978 +ixgbe_dbg_netdev_ops_write_34141 ixgbe_dbg_netdev_ops_write 3 34141 NULL
106979 +shmem_pread_fast_34147 shmem_pread_fast 3 34147 NULL
106980 +ext4_xattr_list_34162 ext4_xattr_list 3 34162 NULL
106981 +ocfs2_xattr_list_entry_34165 ocfs2_xattr_list_entry 0 34165 NULL
106982 +skb_to_sgvec_34171 skb_to_sgvec 0 34171 NULL
106983 +dtf_write_run_34196 dtf_write_run 3 34196 NULL
106984 +ext4_da_write_begin_34215 ext4_da_write_begin 3-4 34215 NULL
106985 +i915_gem_execbuffer_reserve_object_34224 i915_gem_execbuffer_reserve_object 0 34224 NULL
106986 +setup_nodes_for_search_34248 setup_nodes_for_search 0 34248 NULL
106987 +numa_migrate_prep_34256 numa_migrate_prep 0 34256 NULL
106988 +btrfs_bitmap_cluster_34257 btrfs_bitmap_cluster 4 34257 NULL
106989 +bl_pipe_downcall_34264 bl_pipe_downcall 3 34264 NULL
106990 +ocfs2_dlm_lock_34265 ocfs2_dlm_lock 0 34265 NULL
106991 +pcf857x_to_irq_34273 pcf857x_to_irq 2 34273 NULL
106992 +device_private_init_34279 device_private_init 0 34279 NULL
106993 +get_task_io_context_34316 get_task_io_context 3 34316 NULL
106994 +ext4_get_groups_count_34324 ext4_get_groups_count 0 34324 NULL
106995 +iov_iter_single_seg_count_34326 iov_iter_single_seg_count 0 34326 NULL nohasharray
106996 +pcpu_need_to_extend_34326 pcpu_need_to_extend 0 34326 &iov_iter_single_seg_count_34326
106997 +SYSC_brk_34331 SYSC_brk 1 34331 NULL
106998 +__insert_34349 __insert 2-3 34349 NULL
106999 +sync_page_io_34363 sync_page_io 3 34363 NULL nohasharray
107000 +crypto_ablkcipher_ivsize_34363 crypto_ablkcipher_ivsize 0 34363 &sync_page_io_34363
107001 +rngapi_reset_34366 rngapi_reset 3 34366 NULL
107002 +reiserfs_resize_34377 reiserfs_resize 2 34377 NULL
107003 +ea_read_34378 ea_read 0 34378 NULL
107004 +fuse_send_read_34379 fuse_send_read 4 34379 NULL
107005 +av7110_vbi_write_34384 av7110_vbi_write 3 34384 NULL
107006 +usbvision_v4l2_read_34386 usbvision_v4l2_read 3 34386 NULL
107007 +read_rbu_image_type_34387 read_rbu_image_type 6 34387 NULL
107008 +iwl_calib_set_34400 iwl_calib_set 3 34400 NULL nohasharray
107009 +ivtv_read_pos_34400 ivtv_read_pos 3 34400 &iwl_calib_set_34400
107010 +wd_exp_mode_write_34407 wd_exp_mode_write 3 34407 NULL
107011 +nl80211_send_disassoc_34424 nl80211_send_disassoc 4 34424 NULL
107012 +security_socket_create_34439 security_socket_create 0 34439 NULL
107013 +usbtest_alloc_urb_34446 usbtest_alloc_urb 5-3 34446 NULL
107014 +mwifiex_regrdwr_read_34472 mwifiex_regrdwr_read 3 34472 NULL
107015 +skcipher_sndbuf_34476 skcipher_sndbuf 0 34476 NULL
107016 +i2o_parm_field_get_34477 i2o_parm_field_get 5 34477 NULL
107017 +ocfs2_block_group_clear_bits_34484 ocfs2_block_group_clear_bits 0 34484 NULL
107018 +security_inode_permission_34488 security_inode_permission 0 34488 NULL
107019 +SyS_pwritev_34494 SyS_pwritev 3 34494 NULL nohasharray
107020 +__ffs64_34494 __ffs64 1-0 34494 &SyS_pwritev_34494
107021 +qp_alloc_res_34496 qp_alloc_res 5 34496 NULL
107022 +lu_buf_check_and_alloc_34505 lu_buf_check_and_alloc 2 34505 NULL
107023 +snd_pcm_hw_param_value_34525 snd_pcm_hw_param_value 0 34525 NULL
107024 +ext4_fallocate_34537 ext4_fallocate 4-3 34537 NULL nohasharray
107025 +tracing_stats_read_34537 tracing_stats_read 3 34537 &ext4_fallocate_34537
107026 +hugetlbfs_read_actor_34547 hugetlbfs_read_actor 4-5-2-0 34547 NULL
107027 +dbBackSplit_34561 dbBackSplit 0 34561 NULL
107028 +alloc_ieee80211_rsl_34564 alloc_ieee80211_rsl 1 34564 NULL nohasharray
107029 +self_check_peb_ec_hdr_34564 self_check_peb_ec_hdr 0 34564 &alloc_ieee80211_rsl_34564
107030 +i915_gem_execbuffer_relocate_object_34575 i915_gem_execbuffer_relocate_object 0 34575 NULL
107031 +lov_stripecount_seq_write_34582 lov_stripecount_seq_write 3 34582 NULL
107032 +init_send_hfcd_34586 init_send_hfcd 1 34586 NULL
107033 +inet6_ifla6_size_34591 inet6_ifla6_size 0 34591 NULL
107034 +ceph_msgpool_init_34599 ceph_msgpool_init 4 34599 NULL nohasharray
107035 +cw1200_queue_init_34599 cw1200_queue_init 4 34599 &ceph_msgpool_init_34599
107036 +__add_prelim_ref_34600 __add_prelim_ref 0 34600 NULL
107037 +brcmf_cfg80211_mgmt_tx_34608 brcmf_cfg80211_mgmt_tx 7 34608 NULL
107038 +__jffs2_ref_totlen_34609 __jffs2_ref_totlen 0 34609 NULL nohasharray
107039 +mtd_write_34609 mtd_write 0 34609 &__jffs2_ref_totlen_34609
107040 +apei_get_nvs_resources_34616 apei_get_nvs_resources 0 34616 NULL
107041 +__cfg80211_disconnected_34622 __cfg80211_disconnected 3 34622 NULL
107042 +cnic_alloc_dma_34641 cnic_alloc_dma 3 34641 NULL
107043 +tomoyo_dump_page_34649 tomoyo_dump_page 2 34649 NULL
107044 +kvm_set_spte_hva_34671 kvm_set_spte_hva 2 34671 NULL
107045 +sleep_auth_write_34676 sleep_auth_write 3 34676 NULL
107046 +isr_fiqs_read_34687 isr_fiqs_read 3 34687 NULL
107047 +port_print_34704 port_print 3 34704 NULL
107048 +alloc_irq_and_cfg_at_34706 alloc_irq_and_cfg_at 1-2 34706 NULL
107049 +ext4_listxattr_34712 ext4_listxattr 3 34712 NULL
107050 +ieee80211_if_read_num_sta_ps_34722 ieee80211_if_read_num_sta_ps 3 34722 NULL
107051 +platform_list_read_file_34734 platform_list_read_file 3 34734 NULL
107052 +reg_w_ixbuf_34736 reg_w_ixbuf 4 34736 NULL
107053 +lsm_alloc_plain_34755 lsm_alloc_plain 1 34755 NULL
107054 +device_add_34766 device_add 0 34766 NULL
107055 +qib_cdev_init_34778 qib_cdev_init 1 34778 NULL
107056 +SYSC_keyctl_34800 SYSC_keyctl 4 34800 NULL
107057 +can_nocow_extent_34801 can_nocow_extent 2 34801 NULL
107058 +drbd_get_max_capacity_34804 drbd_get_max_capacity 0 34804 NULL
107059 +ll_setxattr_34806 ll_setxattr 4 34806 NULL
107060 +file_page_index_34820 file_page_index 0-2 34820 NULL
107061 +b43_debugfs_write_34838 b43_debugfs_write 3 34838 NULL
107062 +nl_portid_hash_zalloc_34843 nl_portid_hash_zalloc 1 34843 NULL
107063 +acpi_system_write_wakeup_device_34853 acpi_system_write_wakeup_device 3 34853 NULL
107064 +usb_serial_generic_prepare_write_buffer_34857 usb_serial_generic_prepare_write_buffer 3 34857 NULL
107065 +ieee80211_if_read_txpower_34871 ieee80211_if_read_txpower 3 34871 NULL
107066 +msg_print_text_34889 msg_print_text 0 34889 NULL
107067 +ieee80211_if_write_34894 ieee80211_if_write 3 34894 NULL
107068 +si476x_radio_read_rsq_primary_blob_34916 si476x_radio_read_rsq_primary_blob 3 34916 NULL
107069 +__inode_permission_34925 __inode_permission 0 34925 NULL nohasharray
107070 +btrfs_super_chunk_root_34925 btrfs_super_chunk_root 0 34925 &__inode_permission_34925
107071 +ODM_AllocateMemory_34929 ODM_AllocateMemory 3 34929 NULL
107072 +ceph_aio_write_34930 ceph_aio_write 4 34930 NULL
107073 +sec_flags2str_34933 sec_flags2str 3 34933 NULL
107074 +snd_info_entry_read_34938 snd_info_entry_read 3 34938 NULL
107075 +i2c_transfer_34958 i2c_transfer 0 34958 NULL
107076 +do_add_page_to_bio_34974 do_add_page_to_bio 2-10 34974 NULL
107077 +mq_lookup_34990 mq_lookup 2 34990 NULL
107078 +i915_gem_gtt_prepare_object_34991 i915_gem_gtt_prepare_object 0 34991 NULL
107079 +schedule_erase_34996 schedule_erase 0 34996 NULL
107080 +rx_rx_hdr_overflow_read_35002 rx_rx_hdr_overflow_read 3 35002 NULL
107081 +l2cap_skbuff_fromiovec_35003 l2cap_skbuff_fromiovec 4-3 35003 NULL
107082 +dm_cache_insert_mapping_35005 dm_cache_insert_mapping 2-3 35005 NULL
107083 +sisusb_copy_memory_35016 sisusb_copy_memory 4 35016 NULL
107084 +snd_pcm_hw_params_35020 snd_pcm_hw_params 0 35020 NULL
107085 +process_changed_xattr_35025 process_changed_xattr 0 35025 NULL
107086 +coda_psdev_read_35029 coda_psdev_read 3 35029 NULL
107087 +brcmf_sdio_chip_writenvram_35042 brcmf_sdio_chip_writenvram 4 35042 NULL
107088 +pwr_connection_out_of_sync_read_35061 pwr_connection_out_of_sync_read 3 35061 NULL
107089 +ext4_split_unwritten_extents_35063 ext4_split_unwritten_extents 0 35063 NULL
107090 +ntfs_attr_extend_initialized_35084 ntfs_attr_extend_initialized 2 35084 NULL
107091 +store_ifalias_35088 store_ifalias 4 35088 NULL
107092 +__kfifo_uint_must_check_helper_35097 __kfifo_uint_must_check_helper 0-1 35097 NULL
107093 +capi_write_35104 capi_write 3 35104 NULL nohasharray
107094 +tx_tx_done_template_read_35104 tx_tx_done_template_read 3 35104 &capi_write_35104
107095 +ide_settings_proc_write_35110 ide_settings_proc_write 3 35110 NULL
107096 +ceph_osdc_start_request_35122 ceph_osdc_start_request 0 35122 NULL
107097 +message_stats_print_35158 message_stats_print 6 35158 NULL
107098 +iscsi_conn_setup_35159 iscsi_conn_setup 2 35159 NULL
107099 +ieee80211_if_read_bssid_35161 ieee80211_if_read_bssid 3 35161 NULL
107100 +relocate_entry_cpu_35176 relocate_entry_cpu 0 35176 NULL
107101 +solo_v4l2_init_35179 solo_v4l2_init 2 35179 NULL
107102 +SyS_init_module_35180 SyS_init_module 2 35180 NULL
107103 +mlx4_ib_get_cq_umem_35184 mlx4_ib_get_cq_umem 5-6 35184 NULL
107104 +uprobe_get_swbp_addr_35201 uprobe_get_swbp_addr 0 35201 NULL
107105 +unix_stream_recvmsg_35210 unix_stream_recvmsg 4 35210 NULL
107106 +striped_read_35218 striped_read 0-3-2 35218 NULL nohasharray
107107 +security_key_getsecurity_35218 security_key_getsecurity 0 35218 &striped_read_35218
107108 +video_register_device_no_warn_35226 video_register_device_no_warn 3 35226 NULL nohasharray
107109 +rx_rx_cmplt_task_read_35226 rx_rx_cmplt_task_read 3 35226 &video_register_device_no_warn_35226
107110 +gfn_to_page_many_atomic_35234 gfn_to_page_many_atomic 2 35234 NULL nohasharray
107111 +may_commit_transaction_35234 may_commit_transaction 0 35234 &gfn_to_page_many_atomic_35234
107112 +SYSC_madvise_35241 SYSC_madvise 1-2 35241 NULL
107113 +set_fd_set_35249 set_fd_set 1 35249 NULL
107114 +ioapic_setup_resources_35255 ioapic_setup_resources 1 35255 NULL
107115 +alloc_thread_groups_35256 alloc_thread_groups 2 35256 NULL
107116 +jbd2_journal_get_write_access_35263 jbd2_journal_get_write_access 0 35263 NULL
107117 +dis_disc_write_35265 dis_disc_write 3 35265 NULL
107118 +dma_show_regs_35266 dma_show_regs 3 35266 NULL
107119 +irda_recvmsg_stream_35280 irda_recvmsg_stream 4 35280 NULL
107120 +i2o_block_end_request_35282 i2o_block_end_request 3 35282 NULL
107121 +isr_rx_rdys_read_35283 isr_rx_rdys_read 3 35283 NULL
107122 +brcmf_sdio_forensic_read_35311 brcmf_sdio_forensic_read 3 35311 NULL nohasharray
107123 +__btrfs_buffered_write_35311 __btrfs_buffered_write 3 35311 &brcmf_sdio_forensic_read_35311
107124 +tracing_read_pipe_35312 tracing_read_pipe 3 35312 NULL
107125 +fallback_on_nodma_alloc_35332 fallback_on_nodma_alloc 2 35332 NULL
107126 +ieee80211_if_fmt_ap_power_level_35347 ieee80211_if_fmt_ap_power_level 3 35347 NULL
107127 +nouveau_devinit_create__35348 nouveau_devinit_create_ 4 35348 NULL
107128 +ieee80211_rx_mgmt_deauth_35351 ieee80211_rx_mgmt_deauth 3 35351 NULL
107129 +compat_filldir64_35354 compat_filldir64 3 35354 NULL
107130 +amd_iommu_map_35355 amd_iommu_map 4 35355 NULL
107131 +read_kmem_35372 read_kmem 3 35372 NULL
107132 +ocfs2_journal_access_di_35393 ocfs2_journal_access_di 0 35393 NULL
107133 +create_pending_snapshots_35402 create_pending_snapshots 0 35402 NULL
107134 +btrfs_search_old_slot_35406 btrfs_search_old_slot 0 35406 NULL
107135 +SyS_getxattr_35408 SyS_getxattr 4 35408 NULL
107136 +rawv6_send_hdrinc_35425 rawv6_send_hdrinc 3 35425 NULL
107137 +C_SYSC_sendfile_35432 C_SYSC_sendfile 4 35432 NULL
107138 +__set_test_and_free_35436 __set_test_and_free 2 35436 NULL
107139 +buffer_to_user_35439 buffer_to_user 3 35439 NULL
107140 +memcg_memory_allocated_read_35469 memcg_memory_allocated_read 0 35469 NULL
107141 +fiemap_prepare_and_copy_exts_35494 fiemap_prepare_and_copy_exts 5 35494 NULL
107142 +btrfs_prealloc_file_range_trans_35500 btrfs_prealloc_file_range_trans 4-0 35500 NULL
107143 +async_setkey_35521 async_setkey 3 35521 NULL
107144 +inet_mask_len_35527 inet_mask_len 1 35527 NULL
107145 +__filemap_fdatawrite_range_35528 __filemap_fdatawrite_range 0 35528 NULL
107146 +iwl_dbgfs_bt_traffic_read_35534 iwl_dbgfs_bt_traffic_read 3 35534 NULL
107147 +pstore_mkfile_35536 pstore_mkfile 7 35536 NULL
107148 +rxpipe_tx_xfr_host_int_trig_rx_data_read_35538 rxpipe_tx_xfr_host_int_trig_rx_data_read 3 35538 NULL
107149 +ibnl_put_attr_35541 ibnl_put_attr 3 35541 NULL
107150 +ieee80211_if_write_smps_35550 ieee80211_if_write_smps 3 35550 NULL
107151 +send_update_extent_35556 send_update_extent 0 35556 NULL
107152 +vb2_dqbuf_35559 vb2_dqbuf 0 35559 NULL
107153 +sysfs_create_subdir_35567 sysfs_create_subdir 0 35567 NULL
107154 +ext4_blocks_for_truncate_35579 ext4_blocks_for_truncate 0 35579 NULL
107155 +ext2_acl_from_disk_35580 ext2_acl_from_disk 2 35580 NULL
107156 +spk_msg_set_35586 spk_msg_set 3 35586 NULL
107157 +kernel_readv_35617 kernel_readv 3 35617 NULL
107158 +reiserfs_readpages_35629 reiserfs_readpages 4 35629 NULL
107159 +ptlrpcd_steal_rqset_35637 ptlrpcd_steal_rqset 0 35637 NULL
107160 +nv50_vm_create_35643 nv50_vm_create 2-3 35643 NULL
107161 +spi_register_board_info_35651 spi_register_board_info 2 35651 NULL
107162 +rdmaltWithLock_35669 rdmaltWithLock 0 35669 NULL
107163 +cpu_to_sle64_35677 cpu_to_sle64 0-1 35677 NULL
107164 +ext3_mark_iloc_dirty_35686 ext3_mark_iloc_dirty 0 35686 NULL
107165 +dm_table_create_35687 dm_table_create 3 35687 NULL
107166 +SYSC_pwritev_35690 SYSC_pwritev 3 35690 NULL
107167 +rds_page_copy_user_35691 rds_page_copy_user 4 35691 NULL
107168 +md_super_write_35703 md_super_write 4 35703 NULL
107169 +btrfs_commit_transaction_35725 btrfs_commit_transaction 0 35725 NULL
107170 +rtw_IOL_cmd_tx_pkt_buf_dump_35732 rtw_IOL_cmd_tx_pkt_buf_dump 2 35732 NULL
107171 +ext4_truncate_restart_trans_35750 ext4_truncate_restart_trans 0 35750 NULL
107172 +iwl_dbgfs_disable_ht40_read_35761 iwl_dbgfs_disable_ht40_read 3 35761 NULL
107173 +udf_alloc_i_data_35786 udf_alloc_i_data 2 35786 NULL
107174 +pvr2_hdw_cpufw_get_35824 pvr2_hdw_cpufw_get 0-4-2 35824 NULL
107175 +tx_tx_cmplt_read_35854 tx_tx_cmplt_read 3 35854 NULL
107176 +vx_query_hbuffer_size_35859 vx_query_hbuffer_size 0 35859 NULL
107177 +changed_xattr_35860 changed_xattr 0 35860 NULL
107178 +mthca_buf_alloc_35861 mthca_buf_alloc 2 35861 NULL
107179 +fls64_35862 fls64 0 35862 NULL
107180 +kvm_dirty_bitmap_bytes_35886 kvm_dirty_bitmap_bytes 0 35886 NULL
107181 +ieee80211_if_fmt_dot11MeshRetryTimeout_35890 ieee80211_if_fmt_dot11MeshRetryTimeout 3 35890 NULL
107182 +uwb_rc_cmd_done_35892 uwb_rc_cmd_done 4 35892 NULL
107183 +SyS_set_mempolicy_35909 SyS_set_mempolicy 3 35909 NULL
107184 +kernel_setsockopt_35913 kernel_setsockopt 5 35913 NULL
107185 +rbio_nr_pages_35916 rbio_nr_pages 0-1-2 35916 NULL
107186 +balance_node_right_35920 balance_node_right 0 35920 NULL
107187 +sctp_tsnmap_mark_35929 sctp_tsnmap_mark 2 35929 NULL
107188 +rx_defrag_init_called_read_35935 rx_defrag_init_called_read 3 35935 NULL
107189 +put_cmsg_compat_35937 put_cmsg_compat 4 35937 NULL
107190 +ext_rts51x_sd_execute_write_data_35971 ext_rts51x_sd_execute_write_data 9 35971 NULL
107191 +ceph_buffer_new_35974 ceph_buffer_new 1 35974 NULL nohasharray
107192 +generic_ocp_read_35974 generic_ocp_read 3 35974 &ceph_buffer_new_35974
107193 +acl_alloc_35979 acl_alloc 1 35979 NULL
107194 +device_add_class_symlinks_35985 device_add_class_symlinks 0 35985 NULL
107195 +generic_file_aio_read_35987 generic_file_aio_read 0 35987 NULL
107196 +write_file_antenna_35998 write_file_antenna 3 35998 NULL nohasharray
107197 +kuc_alloc_35998 kuc_alloc 1 35998 &write_file_antenna_35998
107198 +locks_mandatory_area_35999 locks_mandatory_area 0 35999 NULL
107199 +il3945_ucode_tx_stats_read_36016 il3945_ucode_tx_stats_read 3 36016 NULL
107200 +ubi_eba_write_leb_36029 ubi_eba_write_leb 0-6-5 36029 NULL
107201 +__videobuf_alloc_36031 __videobuf_alloc 1 36031 NULL
107202 +account_shadowed_36048 account_shadowed 2 36048 NULL
107203 +gpio_power_read_36059 gpio_power_read 3 36059 NULL
107204 +snd_pcm_playback_hw_avail_36061 snd_pcm_playback_hw_avail 0 36061 NULL
107205 +did_create_dir_36062 did_create_dir 0 36062 NULL
107206 +write_emulate_36065 write_emulate 2-4 36065 NULL
107207 +stack_max_size_write_36068 stack_max_size_write 3 36068 NULL
107208 +radeon_vm_num_pdes_36070 radeon_vm_num_pdes 0 36070 NULL
107209 +ieee80211_if_fmt_peer_36071 ieee80211_if_fmt_peer 3 36071 NULL
107210 +ext3_new_blocks_36073 ext3_new_blocks 3-0 36073 NULL
107211 +ieee80211_if_write_tsf_36077 ieee80211_if_write_tsf 3 36077 NULL
107212 +snd_pcm_plug_read_transfer_36080 snd_pcm_plug_read_transfer 0-3 36080 NULL
107213 +mtip_hw_read_device_status_36082 mtip_hw_read_device_status 3 36082 NULL
107214 +vga_arb_write_36112 vga_arb_write 3 36112 NULL
107215 +simple_xattr_alloc_36118 simple_xattr_alloc 2 36118 NULL
107216 +compat_ptrace_request_36131 compat_ptrace_request 3 36131 NULL
107217 +vmalloc_exec_36132 vmalloc_exec 1 36132 NULL
107218 +max8925_irq_domain_map_36133 max8925_irq_domain_map 2 36133 NULL
107219 +set_flexbg_block_bitmap_36136 set_flexbg_block_bitmap 0-4-5 36136 NULL
107220 +ext3_readpages_36144 ext3_readpages 4 36144 NULL
107221 +twl_set_36154 twl_set 2 36154 NULL
107222 +b1_alloc_card_36155 b1_alloc_card 1 36155 NULL
107223 +btrfs_file_extent_inline_len_36158 btrfs_file_extent_inline_len 0 36158 NULL
107224 +snd_korg1212_copy_from_36169 snd_korg1212_copy_from 6 36169 NULL
107225 +wm8994_edge_irq_map_36170 wm8994_edge_irq_map 2 36170 NULL
107226 +SyS_kexec_load_36176 SyS_kexec_load 2 36176 NULL
107227 +ramoops_init_przs_36199 ramoops_init_przs 4 36199 NULL
107228 +SYSC_sched_getaffinity_36208 SYSC_sched_getaffinity 2 36208 NULL
107229 +SYSC_process_vm_readv_36216 SYSC_process_vm_readv 5-3 36216 NULL
107230 +ubifs_read_nnode_36221 ubifs_read_nnode 0 36221 NULL
107231 +is_dirty_36223 is_dirty 2 36223 NULL
107232 +ept_walk_addr_36226 ept_walk_addr 3 36226 NULL
107233 +atomic_stats_read_36228 atomic_stats_read 3 36228 NULL
107234 +viafb_iga1_odev_proc_write_36241 viafb_iga1_odev_proc_write 3 36241 NULL
107235 +SYSC_getxattr_36242 SYSC_getxattr 4 36242 NULL
107236 +rproc_recovery_read_36245 rproc_recovery_read 3 36245 NULL
107237 +scrub_stripe_36248 scrub_stripe 5-4 36248 NULL
107238 +compat_sys_mbind_36256 compat_sys_mbind 5 36256 NULL
107239 +usb_buffer_alloc_36276 usb_buffer_alloc 2 36276 NULL nohasharray
107240 +cfs_hash_buckets_realloc_36276 cfs_hash_buckets_realloc 4 36276 &usb_buffer_alloc_36276
107241 +codec_reg_read_file_36280 codec_reg_read_file 3 36280 NULL
107242 +crypto_shash_digestsize_36284 crypto_shash_digestsize 0 36284 NULL
107243 +nouveau_cli_create_36293 nouveau_cli_create 3 36293 NULL
107244 +lpfc_debugfs_dif_err_read_36303 lpfc_debugfs_dif_err_read 3 36303 NULL
107245 +cfg80211_rx_mlme_mgmt_36306 cfg80211_rx_mlme_mgmt 3 36306 NULL
107246 +ad7879_spi_xfer_36311 ad7879_spi_xfer 3 36311 NULL
107247 +fuse_get_user_addr_36312 fuse_get_user_addr 0 36312 NULL
107248 +fat_compat_ioctl_filldir_36328 fat_compat_ioctl_filldir 3 36328 NULL
107249 +lc_create_36332 lc_create 4 36332 NULL
107250 +jbd2_journal_init_revoke_table_36336 jbd2_journal_init_revoke_table 1 36336 NULL
107251 +isku_sysfs_read_key_mask_36343 isku_sysfs_read_key_mask 6 36343 NULL
107252 +ath6kl_regwrite_write_36351 ath6kl_regwrite_write 3 36351 NULL
107253 +v9fs_file_readn_36353 v9fs_file_readn 4 36353 NULL nohasharray
107254 +xz_dec_lzma2_create_36353 xz_dec_lzma2_create 2 36353 &v9fs_file_readn_36353
107255 +to_sector_36361 to_sector 0-1 36361 NULL
107256 +irq_domain_disassociate_36367 irq_domain_disassociate 2 36367 NULL
107257 +posix_acl_create_36383 posix_acl_create 0 36383 NULL
107258 +tunables_read_36385 tunables_read 3 36385 NULL
107259 +afs_alloc_flat_call_36399 afs_alloc_flat_call 3-2 36399 NULL
107260 +sierra_write_36402 sierra_write 4 36402 NULL
107261 +msb_update_block_36412 msb_update_block 2 36412 NULL
107262 +SyS_sethostname_36417 SyS_sethostname 2 36417 NULL
107263 +ReadW6692B_36445 ReadW6692B 0 36445 NULL
107264 +sctp_tsnmap_init_36446 sctp_tsnmap_init 2 36446 NULL
107265 +alloc_etherdev_mqs_36450 alloc_etherdev_mqs 1 36450 NULL
107266 +check_extent_in_eb_36467 check_extent_in_eb 0 36467 NULL
107267 +SyS_process_vm_writev_36476 SyS_process_vm_writev 5-3 36476 NULL
107268 +b43_nphy_load_samples_36481 b43_nphy_load_samples 3 36481 NULL
107269 +set_var_mtrr_range_36483 set_var_mtrr_range 2 36483 NULL
107270 +ip6_append_data_36490 ip6_append_data 4 36490 NULL nohasharray
107271 +tx_tx_checksum_result_read_36490 tx_tx_checksum_result_read 3 36490 &ip6_append_data_36490
107272 +cmd_loop_36491 cmd_loop 0 36491 NULL
107273 +__hwahc_op_set_ptk_36510 __hwahc_op_set_ptk 5 36510 NULL
107274 +mcam_v4l_read_36513 mcam_v4l_read 3 36513 NULL
107275 +get_param_l_36518 get_param_l 0 36518 NULL
107276 +ieee80211_if_read_fwded_frames_36520 ieee80211_if_read_fwded_frames 3 36520 NULL
107277 +lguest_setup_irq_36531 lguest_setup_irq 1 36531 NULL
107278 +crypto_aead_authsize_36537 crypto_aead_authsize 0 36537 NULL
107279 +cpu_type_read_36540 cpu_type_read 3 36540 NULL
107280 +__kfifo_to_user_36555 __kfifo_to_user 3-0 36555 NULL nohasharray
107281 +macvtap_do_read_36555 macvtap_do_read 4 36555 &__kfifo_to_user_36555
107282 +btrfs_get_token_64_36572 btrfs_get_token_64 0 36572 NULL
107283 +__erst_read_36579 __erst_read 0 36579 NULL
107284 +put_cmsg_36589 put_cmsg 4 36589 NULL
107285 +do_sendfile_36610 do_sendfile 4-5 36610 NULL
107286 +fat_ioctl_filldir_36621 fat_ioctl_filldir 3 36621 NULL
107287 +i915_gem_execbuffer_relocate_slow_36634 i915_gem_execbuffer_relocate_slow 0 36634 NULL
107288 +vxge_config_vpaths_36636 vxge_config_vpaths 0 36636 NULL
107289 +convert_extent_item_v0_36645 convert_extent_item_v0 4-0 36645 NULL
107290 +ced_ioctl_36647 ced_ioctl 2 36647 NULL
107291 +lpfc_idiag_extacc_alloc_get_36648 lpfc_idiag_extacc_alloc_get 0-3 36648 NULL
107292 +osd_req_list_collection_objects_36664 osd_req_list_collection_objects 5 36664 NULL
107293 +iscsi_host_alloc_36671 iscsi_host_alloc 2 36671 NULL
107294 +xillybus_read_36678 xillybus_read 3 36678 NULL
107295 +tlv_put_btrfs_timespec_36685 tlv_put_btrfs_timespec 0 36685 NULL nohasharray
107296 +ext4_mb_discard_group_preallocations_36685 ext4_mb_discard_group_preallocations 2 36685 &tlv_put_btrfs_timespec_36685
107297 +gsmtty_write_36702 gsmtty_write 3 36702 NULL
107298 +sched_clock_36717 sched_clock 0 36717 NULL
107299 +ocfs2_rotate_tree_right_36723 ocfs2_rotate_tree_right 0 36723 NULL
107300 +snd_rawmidi_kernel_read1_36740 snd_rawmidi_kernel_read1 4-0 36740 NULL
107301 +cxgbi_device_register_36746 cxgbi_device_register 2-1 36746 NULL
107302 +fc_exch_mgr_alloc_36751 fc_exch_mgr_alloc 3-4 36751 NULL
107303 +ps_poll_upsd_timeouts_read_36755 ps_poll_upsd_timeouts_read 3 36755 NULL
107304 +ext4_ext_convert_to_initialized_36765 ext4_ext_convert_to_initialized 0 36765 NULL
107305 +ptp_filter_init_36780 ptp_filter_init 2 36780 NULL
107306 +i40e_init_lan_hmc_36796 i40e_init_lan_hmc 2-3-4-5 36796 NULL
107307 +proc_fault_inject_read_36802 proc_fault_inject_read 3 36802 NULL
107308 +hiddev_ioctl_36816 hiddev_ioctl 2 36816 NULL
107309 +ocfs2_journal_access_rb_36823 ocfs2_journal_access_rb 0 36823 NULL
107310 +int_hardware_entry_36833 int_hardware_entry 3 36833 NULL
107311 +fc_change_queue_depth_36841 fc_change_queue_depth 2 36841 NULL
107312 +keyctl_describe_key_36853 keyctl_describe_key 3 36853 NULL
107313 +cm_write_36858 cm_write 3 36858 NULL
107314 +range_to_mtrr_with_hole_36861 range_to_mtrr_with_hole 2 36861 NULL
107315 +tx_tx_data_programmed_read_36871 tx_tx_data_programmed_read 3 36871 NULL
107316 +svc_setsockopt_36876 svc_setsockopt 5 36876 NULL
107317 +raid56_parity_write_36877 raid56_parity_write 5 36877 NULL
107318 +__btrfs_map_block_36883 __btrfs_map_block 3 36883 NULL
107319 +ib_ucm_alloc_data_36885 ib_ucm_alloc_data 3 36885 NULL
107320 +selinux_inode_notifysecctx_36896 selinux_inode_notifysecctx 3 36896 NULL
107321 +OS_kmalloc_36909 OS_kmalloc 1 36909 NULL
107322 +audio_set_endpoint_req_36918 audio_set_endpoint_req 0 36918 NULL
107323 +build_key_36931 build_key 1 36931 NULL
107324 +crypto_blkcipher_ivsize_36944 crypto_blkcipher_ivsize 0 36944 NULL
107325 +div_u64_36951 div_u64 0 36951 NULL
107326 +write_leb_36957 write_leb 0-5 36957 NULL
107327 +ntfs_external_attr_find_36963 ntfs_external_attr_find 0 36963 NULL
107328 +sparse_early_mem_maps_alloc_node_36971 sparse_early_mem_maps_alloc_node 4 36971 NULL
107329 +il4965_rs_sta_dbgfs_scale_table_write_36979 il4965_rs_sta_dbgfs_scale_table_write 3 36979 NULL
107330 +drbd_new_dev_size_36998 drbd_new_dev_size 0-3 36998 NULL
107331 +auok190xfb_write_37001 auok190xfb_write 3 37001 NULL
107332 +setxattr_37006 setxattr 4 37006 NULL
107333 +btrfs_update_root_37035 btrfs_update_root 0 37035 NULL
107334 +ocfs2_dlm_unlock_37037 ocfs2_dlm_unlock 0 37037 NULL
107335 +command_file_read_37038 command_file_read 3 37038 NULL
107336 +__hfsplus_brec_find_37048 __hfsplus_brec_find 0 37048 NULL
107337 +figure_loop_size_37051 figure_loop_size 2-3 37051 NULL
107338 +qp_broker_create_37053 qp_broker_create 6-5 37053 NULL nohasharray
107339 +ieee80211_if_read_drop_unencrypted_37053 ieee80211_if_read_drop_unencrypted 3 37053 &qp_broker_create_37053
107340 +SYSC_setxattr_37078 SYSC_setxattr 4 37078 NULL
107341 +parse_command_37079 parse_command 2 37079 NULL
107342 +pipeline_cs_rx_packet_in_read_37089 pipeline_cs_rx_packet_in_read 3 37089 NULL
107343 +tun_get_user_37094 tun_get_user 5 37094 NULL
107344 +has_wrprotected_page_37123 has_wrprotected_page 3-2 37123 NULL
107345 +snd_hda_get_conn_list_37132 snd_hda_get_conn_list 0 37132 NULL
107346 +mtt_free_res_37144 mtt_free_res 5 37144 NULL
107347 +msg_word_37164 msg_word 0 37164 NULL
107348 +BeceemNVMRead_37166 BeceemNVMRead 0 37166 NULL
107349 +f2fs_direct_IO_37167 f2fs_direct_IO 4 37167 NULL
107350 +can_set_xattr_37182 can_set_xattr 4 37182 NULL
107351 +btrfs_insert_delayed_items_37191 btrfs_insert_delayed_items 0 37191 NULL
107352 +vcc_recvmsg_37198 vcc_recvmsg 4 37198 NULL
107353 +sysfs_add_file_37200 sysfs_add_file 0 37200 NULL
107354 +mpol_misplaced_37205 mpol_misplaced 0 37205 NULL
107355 +forced_ps_write_37209 forced_ps_write 3 37209 NULL
107356 +crypto_shash_descsize_37212 crypto_shash_descsize 0 37212 NULL nohasharray
107357 +ext4_ind_direct_IO_37212 ext4_ind_direct_IO 0-4 37212 &crypto_shash_descsize_37212
107358 +bchannel_get_rxbuf_37213 bchannel_get_rxbuf 2-0 37213 NULL
107359 +regmap_access_read_file_37223 regmap_access_read_file 3 37223 NULL
107360 +__do_replace_37227 __do_replace 5 37227 NULL
107361 +produce_free_peb_37232 produce_free_peb 0 37232 NULL
107362 +iwl_dbgfs_d3_sram_read_37237 iwl_dbgfs_d3_sram_read 3 37237 NULL
107363 +rx_filter_dup_filter_read_37238 rx_filter_dup_filter_read 3 37238 NULL
107364 +BeceemFlashBulkWrite_37255 BeceemFlashBulkWrite 0 37255 NULL
107365 +prot_queue_del_37258 prot_queue_del 0 37258 NULL
107366 +exofs_max_io_pages_37263 exofs_max_io_pages 0-2 37263 NULL
107367 +__add_keyed_refs_37264 __add_keyed_refs 0 37264 NULL
107368 +nested_svm_map_37268 nested_svm_map 2 37268 NULL
107369 +create_cq_user_37278 create_cq_user 5 37278 NULL
107370 +request_threaded_irq_37303 request_threaded_irq 0 37303 NULL
107371 +ieee80211_if_read_power_mode_37305 ieee80211_if_read_power_mode 3 37305 NULL
107372 +ext3_direct_IO_37308 ext3_direct_IO 4 37308 NULL
107373 +jffs2_write_dirent_37311 jffs2_write_dirent 5 37311 NULL
107374 +send_msg_37323 send_msg 4 37323 NULL
107375 +l2cap_create_connless_pdu_37327 l2cap_create_connless_pdu 3 37327 NULL nohasharray
107376 +bnx2x_vf_fill_fw_str_37327 bnx2x_vf_fill_fw_str 3 37327 &l2cap_create_connless_pdu_37327
107377 +scsi_mode_select_37330 scsi_mode_select 6 37330 NULL
107378 +rxrpc_server_sendmsg_37331 rxrpc_server_sendmsg 4 37331 NULL
107379 +lz4_compressbound_37337 lz4_compressbound 0-1 37337 NULL
107380 +move_vma_37341 move_vma 0-5 37341 NULL
107381 +security_inode_getsecurity_37354 security_inode_getsecurity 0 37354 NULL
107382 +cl_io_submit_rw_37374 cl_io_submit_rw 0 37374 NULL
107383 +iterate_leaf_refs_37385 iterate_leaf_refs 0 37385 NULL
107384 +iommu_num_pages_37391 iommu_num_pages 0-1-3-2 37391 NULL
107385 +btrfs_find_free_objectid_37412 btrfs_find_free_objectid 0 37412 NULL
107386 +hci_sock_sendmsg_37420 hci_sock_sendmsg 4 37420 NULL
107387 +acpi_os_allocate_zeroed_37422 acpi_os_allocate_zeroed 1 37422 NULL nohasharray
107388 +find_next_bit_37422 find_next_bit 0-3-2 37422 &acpi_os_allocate_zeroed_37422
107389 +ocfs2_insert_path_37425 ocfs2_insert_path 0 37425 NULL
107390 +tty_insert_flip_string_fixed_flag_37428 tty_insert_flip_string_fixed_flag 4-0 37428 NULL
107391 +iwl_print_last_event_logs_37433 iwl_print_last_event_logs 0-7-9 37433 NULL
107392 +fru_alloc_37442 fru_alloc 1 37442 NULL
107393 +tcp_established_options_37450 tcp_established_options 0 37450 NULL
107394 +brcmf_sdio_dump_console_37455 brcmf_sdio_dump_console 4 37455 NULL
107395 +__remove_37457 __remove 2 37457 NULL
107396 +ufs_data_ptr_to_cpu_37475 ufs_data_ptr_to_cpu 0 37475 NULL
107397 +get_est_timing_37484 get_est_timing 0 37484 NULL
107398 +kmem_realloc_37489 kmem_realloc 2 37489 NULL
107399 +__hfsplus_setxattr_37499 __hfsplus_setxattr 4 37499 NULL
107400 +bitmap_dirty_bits_37503 bitmap_dirty_bits 2 37503 NULL
107401 +osc_active_seq_write_37514 osc_active_seq_write 3 37514 NULL
107402 +bdev_writeseg_37519 bdev_writeseg 2-3 37519 NULL nohasharray
107403 +vmalloc_32_user_37519 vmalloc_32_user 1 37519 &bdev_writeseg_37519
107404 +xz_dec_test_write_37527 xz_dec_test_write 3 37527 NULL
107405 +fault_inject_read_37534 fault_inject_read 3 37534 NULL
107406 +hdr_size_37536 hdr_size 0 37536 NULL
107407 +extent_map_end_37550 extent_map_end 0 37550 NULL
107408 +sep_create_dcb_dmatables_context_37551 sep_create_dcb_dmatables_context 6 37551 NULL
107409 +ioat_chansts_37558 ioat_chansts 0 37558 NULL
107410 +xhci_alloc_streams_37586 xhci_alloc_streams 5 37586 NULL
107411 +ocfs2_add_branch_37588 ocfs2_add_branch 0 37588 NULL
107412 +alloc_descs_37593 alloc_descs 0-1-3 37593 NULL
107413 +qla2x00_debounce_register_37597 qla2x00_debounce_register 0 37597 NULL
107414 +find_extent_clone_37603 find_extent_clone 0 37603 NULL
107415 +btrfs_write_and_wait_marked_extents_37604 btrfs_write_and_wait_marked_extents 0 37604 NULL
107416 +kvm_read_guest_page_mmu_37611 kvm_read_guest_page_mmu 6-3 37611 NULL
107417 +SYSC_mbind_37622 SYSC_mbind 5 37622 NULL nohasharray
107418 +ocfs2_split_refcount_rec_37622 ocfs2_split_refcount_rec 0 37622 &SYSC_mbind_37622
107419 +btrfs_calc_trans_metadata_size_37629 btrfs_calc_trans_metadata_size 0-2 37629 NULL nohasharray
107420 +policy_residency_37629 policy_residency 0 37629 &btrfs_calc_trans_metadata_size_37629
107421 +alloc_fd_37637 alloc_fd 1 37637 NULL
107422 +SyS_mbind_37638 SyS_mbind 5 37638 NULL
107423 +bio_copy_user_iov_37660 bio_copy_user_iov 4 37660 NULL
107424 +rfcomm_sock_sendmsg_37661 rfcomm_sock_sendmsg 4 37661 NULL nohasharray
107425 +vmw_framebuffer_dmabuf_dirty_37661 vmw_framebuffer_dmabuf_dirty 6 37661 &rfcomm_sock_sendmsg_37661
107426 +SYSC_get_mempolicy_37664 SYSC_get_mempolicy 4-3 37664 NULL
107427 +lnw_gpio_to_irq_37665 lnw_gpio_to_irq 2 37665 NULL
107428 +ieee80211_if_read_rc_rateidx_mcs_mask_2ghz_37675 ieee80211_if_read_rc_rateidx_mcs_mask_2ghz 3 37675 NULL
107429 +regmap_map_read_file_37685 regmap_map_read_file 3 37685 NULL
107430 +page_chain_free_37697 page_chain_free 0 37697 NULL
107431 +nametbl_header_37698 nametbl_header 2-0 37698 NULL
107432 +__le32_to_cpup_37702 __le32_to_cpup 0 37702 NULL
107433 +dynamic_ps_timeout_write_37713 dynamic_ps_timeout_write 3 37713 NULL
107434 +dm_thin_remove_block_37724 dm_thin_remove_block 2 37724 NULL
107435 +find_active_uprobe_37733 find_active_uprobe 1 37733 NULL
107436 +read_enabled_file_bool_37744 read_enabled_file_bool 3 37744 NULL
107437 +ocfs2_duplicate_clusters_by_jbd_37749 ocfs2_duplicate_clusters_by_jbd 5-4-6 37749 NULL
107438 +ocfs2_control_cfu_37750 ocfs2_control_cfu 2 37750 NULL
107439 +ipath_cdev_init_37752 ipath_cdev_init 1 37752 NULL
107440 +dccp_setsockopt_cscov_37766 dccp_setsockopt_cscov 2 37766 NULL
107441 +il4965_rs_sta_dbgfs_rate_scale_data_read_37792 il4965_rs_sta_dbgfs_rate_scale_data_read 3 37792 NULL
107442 +smk_read_logging_37804 smk_read_logging 3 37804 NULL
107443 +deny_write_access_37813 deny_write_access 0 37813 NULL
107444 +ocrdma_alloc_frmr_page_list_37815 ocrdma_alloc_frmr_page_list 2 37815 NULL
107445 +rx_decrypt_key_not_found_read_37820 rx_decrypt_key_not_found_read 3 37820 NULL
107446 +bitmap_find_next_zero_area_37827 bitmap_find_next_zero_area 2-3-0-5-4 37827 NULL
107447 +android_get_p2p_addr_37832 android_get_p2p_addr 0 37832 NULL
107448 +jbd2_journal_get_undo_access_37837 jbd2_journal_get_undo_access 0 37837 NULL
107449 +o2hb_debug_read_37851 o2hb_debug_read 3 37851 NULL
107450 +SYSC_pwrite64_37862 SYSC_pwrite64 3 37862 NULL
107451 +xfs_dir2_block_to_sf_37868 xfs_dir2_block_to_sf 3 37868 NULL
107452 +set_registers_37883 set_registers 4 37883 NULL
107453 +btrfs_stack_file_extent_disk_bytenr_37888 btrfs_stack_file_extent_disk_bytenr 0 37888 NULL
107454 +max77686_irq_domain_map_37897 max77686_irq_domain_map 2 37897 NULL
107455 +tipc_link_send_sections_fast_37920 tipc_link_send_sections_fast 4 37920 NULL
107456 +_rtw_malloc_37928 _rtw_malloc 1 37928 NULL nohasharray
107457 +pkt_alloc_packet_data_37928 pkt_alloc_packet_data 1 37928 &_rtw_malloc_37928
107458 +read_rbu_packet_size_37939 read_rbu_packet_size 6 37939 NULL
107459 +write_file_bool_37957 write_file_bool 3 37957 NULL
107460 +fifo_alloc_37961 fifo_alloc 1 37961 NULL
107461 +ext3_free_blocks_sb_37967 ext3_free_blocks_sb 4-3 37967 NULL
107462 +rds_rdma_extra_size_37990 rds_rdma_extra_size 0 37990 NULL
107463 +persistent_ram_old_size_37997 persistent_ram_old_size 0 37997 NULL
107464 +vfs_readv_38011 vfs_readv 3 38011 NULL
107465 +aggr_recv_addba_req_evt_38037 aggr_recv_addba_req_evt 4 38037 NULL
107466 +SyS_pwrite64_38041 SyS_pwrite64 3 38041 NULL
107467 +klsi_105_prepare_write_buffer_38044 klsi_105_prepare_write_buffer 3 38044 NULL nohasharray
107468 +il_dbgfs_chain_noise_read_38044 il_dbgfs_chain_noise_read 3 38044 &klsi_105_prepare_write_buffer_38044
107469 +SyS_llistxattr_38048 SyS_llistxattr 3 38048 NULL
107470 +sysfs_do_create_link_38051 sysfs_do_create_link 0 38051 NULL
107471 +_xfs_buf_alloc_38058 _xfs_buf_alloc 3 38058 NULL nohasharray
107472 +is_discarded_38058 is_discarded 2 38058 &_xfs_buf_alloc_38058
107473 +nsm_create_handle_38060 nsm_create_handle 4 38060 NULL
107474 +alloc_ltalkdev_38071 alloc_ltalkdev 1 38071 NULL
107475 +xfs_buf_readahead_map_38081 xfs_buf_readahead_map 3 38081 NULL
107476 +uwb_mac_addr_print_38085 uwb_mac_addr_print 2 38085 NULL
107477 +request_key_auth_new_38092 request_key_auth_new 3 38092 NULL
107478 +proc_self_readlink_38094 proc_self_readlink 3 38094 NULL
107479 +ep0_read_38095 ep0_read 3 38095 NULL
107480 +sk_wmem_schedule_38096 sk_wmem_schedule 2 38096 NULL nohasharray
107481 +osc_checksum_seq_write_38096 osc_checksum_seq_write 3 38096 &sk_wmem_schedule_38096
107482 +o2hb_read_slots_38105 o2hb_read_slots 2 38105 NULL
107483 +snd_pcm_oss_write_38108 snd_pcm_oss_write 3 38108 NULL
107484 +_get_val_38115 _get_val 2 38115 NULL
107485 +vmw_kms_present_38130 vmw_kms_present 9 38130 NULL
107486 +__ntfs_copy_from_user_iovec_inatomic_38153 __ntfs_copy_from_user_iovec_inatomic 0-4-3 38153 NULL
107487 +btrfs_extent_same_38163 btrfs_extent_same 3-2 38163 NULL
107488 +kvm_clear_guest_38164 kvm_clear_guest 3-2 38164 NULL
107489 +cirrus_ttm_tt_create_38167 cirrus_ttm_tt_create 2 38167 NULL
107490 +send_rename_38170 send_rename 0 38170 NULL
107491 +cdev_add_38176 cdev_add 2-3 38176 NULL
107492 +create_srq_user_38191 create_srq_user 5 38191 NULL
107493 +rt2x00debug_write_rf_38195 rt2x00debug_write_rf 3 38195 NULL
107494 +do_chunk_alloc_38200 do_chunk_alloc 0 38200 NULL
107495 +get_ucode_user_38202 get_ucode_user 3 38202 NULL
107496 +ext3_new_block_38208 ext3_new_block 3-0 38208 NULL
107497 +stmpe_gpio_irq_map_38222 stmpe_gpio_irq_map 3 38222 NULL
107498 +osd_req_list_partition_collections_38223 osd_req_list_partition_collections 5 38223 NULL
107499 +palmas_gpio_to_irq_38235 palmas_gpio_to_irq 2 38235 NULL
107500 +ceph_decode_16_38239 ceph_decode_16 0 38239 NULL
107501 +_ipw_read_reg32_38245 _ipw_read_reg32 0 38245 NULL
107502 +snd_pcm_playback_rewind_38249 snd_pcm_playback_rewind 0-2 38249 NULL
107503 +from_dblock_38256 from_dblock 0-1 38256 NULL
107504 +vmci_qp_broker_set_page_store_38260 vmci_qp_broker_set_page_store 3-2 38260 NULL
107505 +SYSC_msgrcv_38268 SYSC_msgrcv 3 38268 NULL nohasharray
107506 +ieee80211_if_read_auto_open_plinks_38268 ieee80211_if_read_auto_open_plinks 3 38268 &SYSC_msgrcv_38268 nohasharray
107507 +mthca_alloc_icm_table_38268 mthca_alloc_icm_table 4-3 38268 &ieee80211_if_read_auto_open_plinks_38268
107508 +xfs_bmdr_to_bmbt_38275 xfs_bmdr_to_bmbt 5 38275 NULL nohasharray
107509 +xfs_bmbt_to_bmdr_38275 xfs_bmbt_to_bmdr 3 38275 &xfs_bmdr_to_bmbt_38275
107510 +ftdi_process_packet_38281 ftdi_process_packet 4 38281 NULL
107511 +gpa_to_gfn_38291 gpa_to_gfn 0-1 38291 NULL
107512 +ucma_query_path_38305 ucma_query_path 3 38305 NULL
107513 +isr_rx_headers_read_38325 isr_rx_headers_read 3 38325 NULL
107514 +ida_simple_get_38326 ida_simple_get 2-0 38326 NULL
107515 +ocfs2_rotate_rightmost_leaf_left_38330 ocfs2_rotate_rightmost_leaf_left 0 38330 NULL
107516 +__snd_gf1_look8_38333 __snd_gf1_look8 0 38333 NULL
107517 +ocfs2_replace_extent_rec_38357 ocfs2_replace_extent_rec 0 38357 NULL
107518 +btrfs_file_extent_disk_num_bytes_38363 btrfs_file_extent_disk_num_bytes 0 38363 NULL
107519 +dn_sendmsg_38390 dn_sendmsg 4 38390 NULL
107520 +get_valid_node_allowed_38412 get_valid_node_allowed 1-0 38412 NULL
107521 +ocfs2_which_cluster_group_38413 ocfs2_which_cluster_group 0-2 38413 NULL
107522 +ht_destroy_irq_38418 ht_destroy_irq 1 38418 NULL
107523 +ieee80211_if_read_dtim_count_38419 ieee80211_if_read_dtim_count 3 38419 NULL
107524 +pmcraid_copy_sglist_38431 pmcraid_copy_sglist 3 38431 NULL
107525 +kvm_write_guest_38454 kvm_write_guest 4-2 38454 NULL
107526 +btrfs_next_old_leaf_38465 btrfs_next_old_leaf 0 38465 NULL
107527 +kvm_arch_setup_async_pf_38481 kvm_arch_setup_async_pf 3 38481 NULL
107528 +blk_end_bidi_request_38482 blk_end_bidi_request 4-3 38482 NULL
107529 +cpu_to_mem_38501 cpu_to_mem 0 38501 NULL
107530 +dev_names_read_38509 dev_names_read 3 38509 NULL
107531 +iscsi_create_iface_38510 iscsi_create_iface 5 38510 NULL
107532 +event_rx_mismatch_read_38518 event_rx_mismatch_read 3 38518 NULL
107533 +mlx4_ib_db_map_user_38529 mlx4_ib_db_map_user 2 38529 NULL
107534 +ubifs_idx_node_sz_38546 ubifs_idx_node_sz 0-2 38546 NULL
107535 +btrfs_discard_extent_38547 btrfs_discard_extent 2 38547 NULL
107536 +kuc_len_38557 kuc_len 0-1 38557 NULL
107537 +cpu_to_node_38561 cpu_to_node 0 38561 NULL
107538 +irda_sendmsg_dgram_38563 irda_sendmsg_dgram 4 38563 NULL
107539 +il4965_rs_sta_dbgfs_scale_table_read_38564 il4965_rs_sta_dbgfs_scale_table_read 3 38564 NULL
107540 +_ipw_read32_38565 _ipw_read32 0 38565 NULL
107541 +snd_nm256_playback_copy_38567 snd_nm256_playback_copy 5-3 38567 NULL
107542 +copy_ctl_value_to_user_38587 copy_ctl_value_to_user 4 38587 NULL
107543 +compat_sys_ptrace_38595 compat_sys_ptrace 3 38595 NULL
107544 +blkg_stat_read_38612 blkg_stat_read 0 38612 NULL
107545 +icn_writecmd_38629 icn_writecmd 2 38629 NULL
107546 +write_enabled_file_bool_38630 write_enabled_file_bool 3 38630 NULL
107547 +ext2_readpages_38640 ext2_readpages 4 38640 NULL
107548 +cma_create_area_38642 cma_create_area 2 38642 NULL
107549 +audit_init_entry_38644 audit_init_entry 1 38644 NULL
107550 +qp_broker_alloc_38646 qp_broker_alloc 6-5 38646 NULL
107551 +mmc_send_cxd_data_38655 mmc_send_cxd_data 5 38655 NULL
107552 +nouveau_instmem_create__38664 nouveau_instmem_create_ 4 38664 NULL
107553 +snd_es1371_wait_src_ready_38673 snd_es1371_wait_src_ready 0 38673 NULL
107554 +iscsit_dump_data_payload_38683 iscsit_dump_data_payload 2 38683 NULL
107555 +ext4_wait_block_bitmap_38695 ext4_wait_block_bitmap 2 38695 NULL
107556 +validate_vid_hdr_38699 validate_vid_hdr 0 38699 NULL
107557 +rbio_add_io_page_38700 rbio_add_io_page 6 38700 NULL
107558 +find_next_usable_block_38716 find_next_usable_block 3-1-0 38716 NULL
107559 +alloc_trace_probe_38720 alloc_trace_probe 6 38720 NULL
107560 +w83977af_sir_interrupt_38738 w83977af_sir_interrupt 0 38738 NULL
107561 +udf_readpages_38761 udf_readpages 4 38761 NULL
107562 +iwl_dbgfs_thermal_throttling_read_38779 iwl_dbgfs_thermal_throttling_read 3 38779 NULL
107563 +bcache_device_init_38781 bcache_device_init 3 38781 NULL
107564 +snd_gus_dram_write_38784 snd_gus_dram_write 4 38784 NULL
107565 +slab_order_38794 slab_order 0 38794 NULL
107566 +do_pci_enable_device_38802 do_pci_enable_device 0 38802 NULL
107567 +err_decode_38804 err_decode 2 38804 NULL
107568 +btrfs_find_space_cluster_38812 btrfs_find_space_cluster 4-0 38812 NULL
107569 +ipv6_renew_option_38813 ipv6_renew_option 3 38813 NULL
107570 +direct_entry_38836 direct_entry 3 38836 NULL
107571 +compat_udp_setsockopt_38840 compat_udp_setsockopt 5 38840 NULL
107572 +read_nic_io_word_38853 read_nic_io_word 0 38853 NULL
107573 +interfaces_38859 interfaces 2 38859 NULL
107574 +pci_msix_table_size_38867 pci_msix_table_size 0 38867 NULL
107575 +dbgfs_state_38894 dbgfs_state 3 38894 NULL
107576 +f2fs_xattr_set_acl_38895 f2fs_xattr_set_acl 4 38895 NULL
107577 +traverse_38897 traverse 0 38897 NULL
107578 +__fswab16_38898 __fswab16 0 38898 NULL
107579 +ext3_trim_all_free_38929 ext3_trim_all_free 4-3-2 38929 NULL
107580 +il_dbgfs_sram_write_38942 il_dbgfs_sram_write 3 38942 NULL
107581 +__ath6kl_wmi_send_mgmt_cmd_38971 __ath6kl_wmi_send_mgmt_cmd 7 38971 NULL
107582 +C_SYSC_preadv64_38977 C_SYSC_preadv64 3 38977 NULL nohasharray
107583 +usb_maxpacket_38977 usb_maxpacket 0 38977 &C_SYSC_preadv64_38977
107584 +OSDSetBlock_38986 OSDSetBlock 2-4 38986 NULL
107585 +lpfc_idiag_extacc_write_38998 lpfc_idiag_extacc_write 3 38998 NULL
107586 +udf_new_block_38999 udf_new_block 4 38999 NULL
107587 +get_nodes_39012 get_nodes 3 39012 NULL
107588 +twl6030_interrupt_unmask_39013 twl6030_interrupt_unmask 2 39013 NULL
107589 +__blkdev_issue_zeroout_39020 __blkdev_issue_zeroout 3-0 39020 NULL
107590 +qgroup_account_ref_step1_39024 qgroup_account_ref_step1 0 39024 NULL
107591 +acpi_install_gpe_block_39031 acpi_install_gpe_block 4 39031 NULL
107592 +_zd_iowrite32v_async_locked_39034 _zd_iowrite32v_async_locked 3 39034 NULL
107593 +do_write_kmem_39051 do_write_kmem 1-3-0 39051 NULL
107594 +gen_pool_create_39064 gen_pool_create 2 39064 NULL
107595 +ext4_init_block_bitmap_39071 ext4_init_block_bitmap 3 39071 NULL
107596 +ReadHFC_39104 ReadHFC 0 39104 NULL
107597 +tomoyo_truncate_39105 tomoyo_truncate 0 39105 NULL
107598 +leb_write_lock_39111 leb_write_lock 0 39111 NULL
107599 +__kfifo_to_user_r_39123 __kfifo_to_user_r 5-3 39123 NULL
107600 +ttm_mem_global_alloc_zone_39125 ttm_mem_global_alloc_zone 0 39125 NULL
107601 +ea_foreach_39133 ea_foreach 0 39133 NULL
107602 +generic_permission_39150 generic_permission 0 39150 NULL
107603 +proc_coredump_filter_read_39153 proc_coredump_filter_read 3 39153 NULL
107604 +echo_client_kbrw_39170 echo_client_kbrw 6 39170 NULL
107605 +btrfs_start_delalloc_flush_39173 btrfs_start_delalloc_flush 0 39173 NULL
107606 +ext3_xattr_check_names_39174 ext3_xattr_check_names 0 39174 NULL
107607 +ubi_more_update_data_39189 ubi_more_update_data 4-0 39189 NULL
107608 +qcam_read_bytes_39205 qcam_read_bytes 0 39205 NULL
107609 +ivtv_v4l2_write_39226 ivtv_v4l2_write 3 39226 NULL
107610 +posix_acl_to_xattr_39237 posix_acl_to_xattr 0 39237 NULL
107611 +drm_order_39244 drm_order 0 39244 NULL
107612 +snd_pcm_capture_forward_39248 snd_pcm_capture_forward 0-2 39248 NULL
107613 +r128_compat_ioctl_39250 r128_compat_ioctl 2 39250 NULL nohasharray
107614 +pwr_cont_miss_bcns_spread_read_39250 pwr_cont_miss_bcns_spread_read 3 39250 &r128_compat_ioctl_39250
107615 +i915_error_state_read_39254 i915_error_state_read 3 39254 NULL
107616 +bitmap_set_bits_39272 bitmap_set_bits 3 39272 NULL
107617 +rx_filter_protection_filter_read_39282 rx_filter_protection_filter_read 3 39282 NULL
107618 +__vmalloc_node_39308 __vmalloc_node 1-5 39308 NULL
107619 +__cfg80211_connect_result_39326 __cfg80211_connect_result 4-6 39326 NULL
107620 +insert_reserved_file_extent_39327 insert_reserved_file_extent 3-0 39327 NULL
107621 +wimax_msg_alloc_39343 wimax_msg_alloc 4 39343 NULL
107622 +__copy_from_user_nocache_39351 __copy_from_user_nocache 3-0 39351 NULL
107623 +ide_complete_rq_39354 ide_complete_rq 3 39354 NULL
107624 +do_write_log_from_user_39362 do_write_log_from_user 3-0 39362 NULL
107625 +vortex_wtdma_getlinearpos_39371 vortex_wtdma_getlinearpos 0 39371 NULL
107626 +regmap_name_read_file_39379 regmap_name_read_file 3 39379 NULL
107627 +fnic_trace_debugfs_read_39380 fnic_trace_debugfs_read 3 39380 NULL
107628 +ps_poll_ps_poll_utilization_read_39383 ps_poll_ps_poll_utilization_read 3 39383 NULL
107629 +__send_to_port_39386 __send_to_port 3 39386 NULL
107630 +perf_trace_buf_submit_39413 perf_trace_buf_submit 5 39413 NULL
107631 +user_power_read_39414 user_power_read 3 39414 NULL
107632 +alloc_agpphysmem_i8xx_39427 alloc_agpphysmem_i8xx 1 39427 NULL
107633 +__vb2_get_done_vb_39448 __vb2_get_done_vb 0 39448 NULL
107634 +apei_resources_add_39470 apei_resources_add 0 39470 NULL
107635 +setkey_unaligned_39474 setkey_unaligned 3 39474 NULL
107636 +do_get_mempolicy_39485 do_get_mempolicy 3 39485 NULL
107637 +ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries_39499 ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries 3 39499 NULL
107638 +cl_req_alloc_39523 cl_req_alloc 4 39523 NULL
107639 +int_proc_write_39542 int_proc_write 3 39542 NULL
107640 +pp_write_39554 pp_write 3 39554 NULL
107641 +ol_dqblk_block_39558 ol_dqblk_block 2-0-3 39558 NULL
107642 +datablob_format_39571 datablob_format 2 39571 NULL nohasharray
107643 +ieee80211_if_read_fwded_mcast_39571 ieee80211_if_read_fwded_mcast 3 39571 &datablob_format_39571
107644 +ext_depth_39607 ext_depth 0 39607 NULL
107645 +nfs_idmap_get_key_39616 nfs_idmap_get_key 2 39616 NULL
107646 +sdio_readb_39618 sdio_readb 0 39618 NULL
107647 +set_dev_class_39645 set_dev_class 4 39645 NULL nohasharray
107648 +dm_exception_table_init_39645 dm_exception_table_init 2 39645 &set_dev_class_39645
107649 +snd_rme32_capture_copy_39653 snd_rme32_capture_copy 5 39653 NULL
107650 +tcp_try_rmem_schedule_39657 tcp_try_rmem_schedule 3 39657 NULL
107651 +kvm_read_guest_cached_39666 kvm_read_guest_cached 4 39666 NULL
107652 +v4l_stk_read_39672 v4l_stk_read 3 39672 NULL
107653 +hsc_msg_len_get_39673 hsc_msg_len_get 0 39673 NULL
107654 +do_surface_dirty_sou_39678 do_surface_dirty_sou 7 39678 NULL
107655 +vmx_set_cr3_39688 vmx_set_cr3 2 39688 NULL
107656 +sd_completed_bytes_39705 sd_completed_bytes 0 39705 NULL
107657 +ftrace_pid_write_39710 ftrace_pid_write 3 39710 NULL
107658 +test_add_free_space_entry_39754 test_add_free_space_entry 2-3 39754 NULL
107659 +adt7316_spi_multi_read_39765 adt7316_spi_multi_read 3 39765 NULL
107660 +remap_to_origin_clear_discard_39767 remap_to_origin_clear_discard 3 39767 NULL
107661 +crypto_ablkcipher_blocksize_39811 crypto_ablkcipher_blocksize 0 39811 NULL
107662 +security_inode_listsecurity_39812 security_inode_listsecurity 0 39812 NULL
107663 +snd_pcm_oss_writev3_39818 snd_pcm_oss_writev3 3 39818 NULL
107664 +get_priv_size_39828 get_priv_size 0-1 39828 NULL
107665 +can_rmdir_39890 can_rmdir 0 39890 NULL
107666 +pkt_add_39897 pkt_add 3 39897 NULL
107667 +read_file_modal_eeprom_39909 read_file_modal_eeprom 3 39909 NULL
107668 +gen_pool_add_virt_39913 gen_pool_add_virt 4-5 39913 NULL
107669 +dw210x_op_rw_39915 dw210x_op_rw 6 39915 NULL
107670 +dma_to_mm_pfn_39916 dma_to_mm_pfn 0-1 39916 NULL
107671 +aes_encrypt_interrupt_read_39919 aes_encrypt_interrupt_read 3 39919 NULL
107672 +exofs_read_kern_39921 exofs_read_kern 6 39921 NULL nohasharray
107673 +oom_score_adj_read_39921 oom_score_adj_read 3 39921 &exofs_read_kern_39921
107674 +__spi_async_39932 __spi_async 0 39932 NULL
107675 +__get_order_39935 __get_order 0 39935 NULL
107676 +error_error_frame_read_39947 error_error_frame_read 3 39947 NULL
107677 +tty_prepare_flip_string_39955 tty_prepare_flip_string 3-0 39955 NULL
107678 +lstcon_group_list_39958 lstcon_group_list 2 39958 NULL
107679 +dma_push_rx_39973 dma_push_rx 2 39973 NULL
107680 +broadsheetfb_write_39976 broadsheetfb_write 3 39976 NULL
107681 +mthca_array_init_39987 mthca_array_init 2 39987 NULL
107682 +fw_device_op_read_39990 fw_device_op_read 3 39990 NULL
107683 +server_name2svname_39998 server_name2svname 4 39998 NULL
107684 +xen_hvm_config_40018 xen_hvm_config 2 40018 NULL
107685 +ivtvfb_write_40023 ivtvfb_write 3 40023 NULL
107686 +disc_pwup_write_40027 disc_pwup_write 3 40027 NULL
107687 +ea_foreach_i_40028 ea_foreach_i 0 40028 NULL
107688 +datablob_hmac_append_40038 datablob_hmac_append 3 40038 NULL
107689 +regmap_add_irq_chip_40042 regmap_add_irq_chip 4 40042 NULL
107690 +ocfs2_claim_clusters_40050 ocfs2_claim_clusters 0 40050 NULL
107691 +add_tty_40055 add_tty 1 40055 NULL nohasharray
107692 +l2cap_create_iframe_pdu_40055 l2cap_create_iframe_pdu 3 40055 &add_tty_40055
107693 +atomic_xchg_40070 atomic_xchg 0 40070 NULL
107694 +snd_pcm_sw_params_user_40095 snd_pcm_sw_params_user 0 40095 NULL
107695 +gen_pool_first_fit_40110 gen_pool_first_fit 2-3-4 40110 NULL
107696 +sctp_setsockopt_delayed_ack_40129 sctp_setsockopt_delayed_ack 3 40129 NULL
107697 +dwc2_max_desc_num_40132 dwc2_max_desc_num 0 40132 NULL
107698 +rx_rx_frame_checksum_read_40140 rx_rx_frame_checksum_read 3 40140 NULL
107699 +ath10k_write_simulate_fw_crash_40143 ath10k_write_simulate_fw_crash 3 40143 NULL
107700 +iwch_alloc_fastreg_pbl_40153 iwch_alloc_fastreg_pbl 2 40153 NULL
107701 +clone_backref_node_40154 clone_backref_node 0 40154 NULL
107702 +pt_write_40159 pt_write 3 40159 NULL
107703 +scsi_sg_count_40182 scsi_sg_count 0 40182 NULL
107704 +ipr_alloc_ucode_buffer_40199 ipr_alloc_ucode_buffer 1 40199 NULL nohasharray
107705 +devnode_find_40199 devnode_find 3-2 40199 &ipr_alloc_ucode_buffer_40199
107706 +allocate_probes_40204 allocate_probes 1 40204 NULL
107707 +acpi_system_write_alarm_40205 acpi_system_write_alarm 3 40205 NULL
107708 +au0828_v4l2_read_40220 au0828_v4l2_read 3 40220 NULL
107709 +compress_file_range_40225 compress_file_range 3-4 40225 NULL
107710 +osst_read_40237 osst_read 3 40237 NULL
107711 +lpage_info_slot_40243 lpage_info_slot 3-1 40243 NULL
107712 +ocfs2_zero_extend_get_range_40248 ocfs2_zero_extend_get_range 4-3 40248 NULL
107713 +rs_sta_dbgfs_scale_table_read_40262 rs_sta_dbgfs_scale_table_read 3 40262 NULL
107714 +ext2_fiemap_40271 ext2_fiemap 4 40271 NULL
107715 +usbnet_read_cmd_40275 usbnet_read_cmd 7 40275 NULL
107716 +rx_xfr_hint_trig_read_40283 rx_xfr_hint_trig_read 3 40283 NULL
107717 +vfio_unmap_unpin_40284 vfio_unmap_unpin 3 40284 NULL
107718 +_calc_trunk_info_40291 _calc_trunk_info 2 40291 NULL
107719 +SyS_bind_40303 SyS_bind 3 40303 NULL
107720 +ubi_io_write_data_40305 ubi_io_write_data 0-5-4 40305 NULL
107721 +batadv_tt_changes_fill_buff_40323 batadv_tt_changes_fill_buff 4 40323 NULL
107722 +ib_get_mad_data_offset_40336 ib_get_mad_data_offset 0 40336 NULL
107723 +mmio_read_40348 mmio_read 4 40348 NULL
107724 +ocfs2_release_clusters_40355 ocfs2_release_clusters 4-0 40355 NULL
107725 +event_rx_mem_empty_read_40363 event_rx_mem_empty_read 3 40363 NULL
107726 +ocfs2_check_range_for_refcount_40365 ocfs2_check_range_for_refcount 3-2 40365 NULL
107727 +get_chars_40373 get_chars 3 40373 NULL
107728 +submit_page_section_40408 submit_page_section 0 40408 NULL
107729 +ecryptfs_read_lower_40419 ecryptfs_read_lower 3 40419 NULL
107730 +slab_node_40421 slab_node 0 40421 NULL
107731 +fb_prepare_extra_logos_40429 fb_prepare_extra_logos 0-2 40429 NULL
107732 +tomoyo_update_policy_40458 tomoyo_update_policy 2 40458 NULL
107733 +zd_usb_scnprint_id_40459 zd_usb_scnprint_id 0-3 40459 NULL
107734 +SyS_writev_40467 SyS_writev 3 40467 NULL
107735 +__i915_add_request_40469 __i915_add_request 0 40469 NULL
107736 +SyS_select_40473 SyS_select 1 40473 NULL
107737 +afs_fs_store_data_40484 afs_fs_store_data 3-4-5-6 40484 NULL
107738 +batadv_hash_new_40491 batadv_hash_new 1 40491 NULL
107739 +devcgroup_inode_permission_40492 devcgroup_inode_permission 0 40492 NULL
107740 +drm_vma_node_start_40500 drm_vma_node_start 0 40500 NULL
107741 +sg_phys_40507 sg_phys 0 40507 NULL
107742 +__ethtool_get_sset_count_40511 __ethtool_get_sset_count 0 40511 NULL
107743 +TSS_checkhmac2_40520 TSS_checkhmac2 7-5 40520 NULL
107744 +ixgbe_dbg_reg_ops_read_40540 ixgbe_dbg_reg_ops_read 3 40540 NULL
107745 +i915_gem_execbuffer_relocate_object_slow_40546 i915_gem_execbuffer_relocate_object_slow 0 40546 NULL
107746 +ima_write_policy_40548 ima_write_policy 3 40548 NULL
107747 +btrfs_flush_all_pending_stuffs_40553 btrfs_flush_all_pending_stuffs 0 40553 NULL
107748 +esp_alloc_tmp_40558 esp_alloc_tmp 2-3 40558 NULL
107749 +ufs_inode_getfrag_40560 ufs_inode_getfrag 2-4 40560 NULL
107750 +bdev_sectors_40564 bdev_sectors 0 40564 NULL
107751 +lba_to_map_index_40580 lba_to_map_index 0-1 40580 NULL
107752 +b1_get_byte_40597 b1_get_byte 0 40597 NULL
107753 +get_priv_descr_and_size_40612 get_priv_descr_and_size 0 40612 NULL
107754 +qla8044_rd_reg_40652 qla8044_rd_reg 0 40652 NULL
107755 +pid_nr_ns_40654 pid_nr_ns 0 40654 NULL
107756 +twl4030_kpwrite_u8_40665 twl4030_kpwrite_u8 3 40665 NULL
107757 +__cfg80211_roamed_40668 __cfg80211_roamed 4-6 40668 NULL
107758 +pipeline_rx_complete_stat_fifo_int_read_40671 pipeline_rx_complete_stat_fifo_int_read 3 40671 NULL
107759 +fops_read_40672 fops_read 3 40672 NULL
107760 +ext4_mark_inode_dirty_40673 ext4_mark_inode_dirty 0 40673 NULL
107761 +idr_get_empty_slot_40674 idr_get_empty_slot 0 40674 NULL
107762 +alloc_rbio_40676 alloc_rbio 4 40676 NULL
107763 +videobuf_dma_init_user_locked_40678 videobuf_dma_init_user_locked 3-4 40678 NULL
107764 +pci_enable_resources_40680 pci_enable_resources 0 40680 NULL
107765 +nfc_hci_set_param_40697 nfc_hci_set_param 5 40697 NULL
107766 +__seq_open_private_40715 __seq_open_private 3 40715 NULL
107767 +btrfs_find_one_extref_40724 btrfs_find_one_extref 0 40724 NULL
107768 +fuse_readpages_40737 fuse_readpages 4 40737 NULL
107769 +xfs_iext_remove_direct_40744 xfs_iext_remove_direct 3 40744 NULL nohasharray
107770 +find_next_zero_bit_le_40744 find_next_zero_bit_le 2-3-0 40744 &xfs_iext_remove_direct_40744
107771 +i915_gem_execbuffer_relocate_entry_40750 i915_gem_execbuffer_relocate_entry 0 40750 NULL
107772 +security_inode_listxattr_40752 security_inode_listxattr 0 40752 NULL
107773 +card_send_command_40757 card_send_command 3 40757 NULL
107774 +ad1889_readl_40765 ad1889_readl 0 40765 NULL
107775 +pg_write_40766 pg_write 3 40766 NULL
107776 +show_list_40775 show_list 3-0 40775 NULL
107777 +calcu_metadata_size_40782 calcu_metadata_size 0 40782 NULL
107778 +kfifo_out_copy_r_40784 kfifo_out_copy_r 3-0 40784 NULL
107779 +bitmap_weight_40791 bitmap_weight 0-2 40791 NULL
107780 +pyra_sysfs_read_40795 pyra_sysfs_read 6 40795 NULL
107781 +add_action_40811 add_action 4 40811 NULL
107782 +nl80211_send_roamed_40825 nl80211_send_roamed 5-7 40825 NULL
107783 +SyS_mbind_40828 SyS_mbind 5 40828 NULL
107784 +__mlx4_qp_reserve_range_40847 __mlx4_qp_reserve_range 2-3 40847 NULL
107785 +nilfs_mdt_init_40849 nilfs_mdt_init 3 40849 NULL
107786 +ocfs2_zero_partial_clusters_40856 ocfs2_zero_partial_clusters 2-3 40856 NULL
107787 +v9fs_file_read_40858 v9fs_file_read 3 40858 NULL
107788 +read_file_queue_40895 read_file_queue 3 40895 NULL
107789 +btrfs_set_inode_index_count_40901 btrfs_set_inode_index_count 0 40901 NULL
107790 +waiters_read_40902 waiters_read 3 40902 NULL
107791 +isdn_add_channels_40905 isdn_add_channels 3 40905 NULL
107792 +gfs2_ea_find_40913 gfs2_ea_find 0 40913 NULL
107793 +vol_cdev_write_40915 vol_cdev_write 3 40915 NULL
107794 +snd_vx_create_40948 snd_vx_create 4 40948 NULL nohasharray
107795 +sg_alloc_table_40948 sg_alloc_table 0 40948 &snd_vx_create_40948
107796 +wm8994_free_irq_40951 wm8994_free_irq 2 40951 NULL
107797 +rds_sendmsg_40976 rds_sendmsg 4 40976 NULL
107798 +btrfs_find_orphan_item_40977 btrfs_find_orphan_item 0 40977 NULL
107799 +insert_old_idx_40987 insert_old_idx 0 40987 NULL
107800 +il_dbgfs_fh_reg_read_40993 il_dbgfs_fh_reg_read 3 40993 NULL
107801 +mac80211_format_buffer_41010 mac80211_format_buffer 2 41010 NULL
107802 +mtd_block_isbad_41015 mtd_block_isbad 0 41015 NULL
107803 +__proc_dobitmasks_41029 __proc_dobitmasks 5 41029 NULL
107804 +_req_append_segment_41031 _req_append_segment 2 41031 NULL
107805 +mISDN_sock_sendmsg_41035 mISDN_sock_sendmsg 4 41035 NULL
107806 +ocfs2_xattr_index_block_find_41040 ocfs2_xattr_index_block_find 0 41040 NULL
107807 +lprocfs_write_frac_helper_41050 lprocfs_write_frac_helper 2 41050 NULL
107808 +BcmFlash2xBulkWrite_41054 BcmFlash2xBulkWrite 0 41054 NULL
107809 +calculate_order_41061 calculate_order 0 41061 NULL
107810 +vfs_listxattr_41062 vfs_listxattr 0 41062 NULL nohasharray
107811 +beacon_filtering_write_41062 beacon_filtering_write 3 41062 &vfs_listxattr_41062
107812 +cfg80211_inform_bss_frame_41078 cfg80211_inform_bss_frame 4 41078 NULL
107813 +roccat_read_41093 roccat_read 3 41093 NULL nohasharray
107814 +nvme_map_user_pages_41093 nvme_map_user_pages 4-3 41093 &roccat_read_41093
107815 +dma_attach_41094 dma_attach 6-5 41094 NULL
107816 +provide_user_output_41105 provide_user_output 3 41105 NULL
107817 +f_audio_buffer_alloc_41110 f_audio_buffer_alloc 1 41110 NULL
107818 +ath10k_read_wmi_services_41112 ath10k_read_wmi_services 3 41112 NULL
107819 +ocfs2_extend_trans_41116 ocfs2_extend_trans 0 41116 NULL
107820 +btrfs_subvolume_reserve_metadata_41130 btrfs_subvolume_reserve_metadata 3 41130 NULL
107821 +v4l2_ctrl_new_int_menu_41151 v4l2_ctrl_new_int_menu 4 41151 NULL
107822 +tx_frag_mpdu_alloc_failed_read_41167 tx_frag_mpdu_alloc_failed_read 3 41167 NULL
107823 +dvb_ca_write_41171 dvb_ca_write 3 41171 NULL
107824 +ol_quota_chunk_block_41177 ol_quota_chunk_block 0-2 41177 NULL
107825 +dgap_driver_kzmalloc_41189 dgap_driver_kzmalloc 1 41189 NULL
107826 +compat_sys_process_vm_writev_41194 compat_sys_process_vm_writev 3-5 41194 NULL
107827 +dfs_file_write_41196 dfs_file_write 3 41196 NULL
107828 +ocfs2_read_quota_block_41207 ocfs2_read_quota_block 2 41207 NULL
107829 +nfs_page_array_len_41219 nfs_page_array_len 0-2-1 41219 NULL
107830 +cfg80211_process_disassoc_41231 cfg80211_process_disassoc 3 41231 NULL
107831 +hiddev_compat_ioctl_41255 hiddev_compat_ioctl 2 41255 NULL
107832 +create_dir_41256 create_dir 0 41256 NULL
107833 +erst_read_41260 erst_read 0 41260 NULL
107834 +setup_cluster_bitmap_41270 setup_cluster_bitmap 4-0 41270 NULL
107835 +alloc_context_41283 alloc_context 1 41283 NULL
107836 +objio_alloc_io_state_41316 objio_alloc_io_state 7-6 41316 NULL
107837 +o2hb_setup_one_bio_41341 o2hb_setup_one_bio 4 41341 NULL
107838 +twl_change_queue_depth_41342 twl_change_queue_depth 2 41342 NULL
107839 +rtw_android_set_block_41347 rtw_android_set_block 0 41347 NULL
107840 +irq_expand_nr_irqs_41351 irq_expand_nr_irqs 0 41351 NULL
107841 +cnic_init_id_tbl_41354 cnic_init_id_tbl 2 41354 NULL
107842 +jbd2_alloc_41359 jbd2_alloc 1 41359 NULL
107843 +kmp_init_41373 kmp_init 2 41373 NULL
107844 +netlink_alloc_large_skb_41375 netlink_alloc_large_skb 1 41375 NULL
107845 +isr_commands_read_41398 isr_commands_read 3 41398 NULL
107846 +is_writethrough_io_41406 is_writethrough_io 3 41406 NULL
107847 +rx_defrag_decrypt_failed_read_41411 rx_defrag_decrypt_failed_read 3 41411 NULL
107848 +xfs_iext_add_41422 xfs_iext_add 3 41422 NULL
107849 +isdn_ppp_fill_rq_41428 isdn_ppp_fill_rq 2 41428 NULL
107850 +lbs_rdrf_read_41431 lbs_rdrf_read 3 41431 NULL
107851 +iio_device_alloc_41440 iio_device_alloc 1 41440 NULL
107852 +ntfs_file_buffered_write_41442 ntfs_file_buffered_write 6-4 41442 NULL
107853 +pcpu_build_alloc_info_41443 pcpu_build_alloc_info 1-2-3 41443 NULL
107854 +layout_leb_in_gaps_41470 layout_leb_in_gaps 0 41470 NULL
107855 +snd_pcm_status_41472 snd_pcm_status 0 41472 NULL
107856 +rt2x00debug_write_rfcsr_41473 rt2x00debug_write_rfcsr 3 41473 NULL
107857 +bl_alloc_init_bio_41478 bl_alloc_init_bio 1 41478 NULL
107858 +split_item_41483 split_item 0 41483 NULL
107859 +kvm_unmap_hva_range_41484 kvm_unmap_hva_range 3-2 41484 NULL
107860 +ipath_user_sdma_page_length_41490 ipath_user_sdma_page_length 0-2-1 41490 NULL
107861 +wep_interrupt_read_41492 wep_interrupt_read 3 41492 NULL
107862 +SyS_get_mempolicy_41495 SyS_get_mempolicy 3-4 41495 NULL
107863 +hpfs_translate_name_41497 hpfs_translate_name 3 41497 NULL
107864 +xfrm_hash_new_size_41505 xfrm_hash_new_size 0-1 41505 NULL
107865 +perf_sw_event_41517 perf_sw_event 2 41517 NULL
107866 +SyS_preadv_41523 SyS_preadv 3 41523 NULL
107867 +dm_get_reserved_rq_based_ios_41529 dm_get_reserved_rq_based_ios 0 41529 NULL
107868 +add_excluded_extent_41547 add_excluded_extent 0 41547 NULL
107869 +tx_tx_frame_checksum_read_41553 tx_tx_frame_checksum_read 3 41553 NULL
107870 +ath6kl_endpoint_stats_read_41554 ath6kl_endpoint_stats_read 3 41554 NULL
107871 +si476x_radio_fops_read_41559 si476x_radio_fops_read 3 41559 NULL nohasharray
107872 +nr_status_frames_41559 nr_status_frames 0-1 41559 &si476x_radio_fops_read_41559
107873 +rng_dev_read_41581 rng_dev_read 3 41581 NULL
107874 +vga_io_r_41609 vga_io_r 0 41609 NULL
107875 +tcp_hdrlen_41610 tcp_hdrlen 0 41610 NULL
107876 +lbs_bcnmiss_write_41613 lbs_bcnmiss_write 3 41613 NULL nohasharray
107877 +usb_endpoint_maxp_41613 usb_endpoint_maxp 0 41613 &lbs_bcnmiss_write_41613
107878 +a2mp_send_41615 a2mp_send 4 41615 NULL
107879 +btrfs_calc_trunc_metadata_size_41626 btrfs_calc_trunc_metadata_size 0-2 41626 NULL
107880 +lstcon_batch_list_41627 lstcon_batch_list 2 41627 NULL
107881 +mempool_create_kmalloc_pool_41650 mempool_create_kmalloc_pool 1 41650 NULL
107882 +rx_rx_pre_complt_read_41653 rx_rx_pre_complt_read 3 41653 NULL
107883 +get_std_timing_41654 get_std_timing 0 41654 NULL
107884 +start_graph_tracing_41656 start_graph_tracing 0 41656 NULL
107885 +ieee80211_if_fmt_bssid_41677 ieee80211_if_fmt_bssid 3 41677 NULL
107886 +params_period_bytes_41683 params_period_bytes 0 41683 NULL
107887 +fill_pcm_stream_name_41685 fill_pcm_stream_name 2 41685 NULL
107888 +lov_unpackmd_41701 lov_unpackmd 4 41701 NULL
107889 +__ext3_journal_get_write_access_41705 __ext3_journal_get_write_access 0 41705 NULL
107890 +apei_exec_for_each_entry_41717 apei_exec_for_each_entry 0 41717 NULL
107891 +bdx_tx_db_init_41719 bdx_tx_db_init 2 41719 NULL
107892 +ocfs2_block_group_fill_41744 ocfs2_block_group_fill 0 41744 NULL
107893 +fillonedir_41746 fillonedir 3 41746 NULL
107894 +ocfs2_dx_dir_rebalance_41793 ocfs2_dx_dir_rebalance 7 41793 NULL
107895 +iwl_dbgfs_bt_notif_read_41794 iwl_dbgfs_bt_notif_read 3 41794 NULL
107896 +remap_pte_range_41800 remap_pte_range 5 41800 NULL
107897 +hsi_alloc_controller_41802 hsi_alloc_controller 1 41802 NULL
107898 +regcache_sync_block_raw_41803 regcache_sync_block_raw 4-3 41803 NULL
107899 +rtw_android_get_macaddr_41812 rtw_android_get_macaddr 0 41812 NULL
107900 +da9052_enable_irq_41814 da9052_enable_irq 2 41814 NULL
107901 +sco_send_frame_41815 sco_send_frame 3 41815 NULL
107902 +lp_gpio_to_irq_41822 lp_gpio_to_irq 2 41822 NULL
107903 +ixgbe_dbg_netdev_ops_read_41839 ixgbe_dbg_netdev_ops_read 3 41839 NULL
107904 +do_ip_setsockopt_41852 do_ip_setsockopt 5 41852 NULL
107905 +keyctl_instantiate_key_41855 keyctl_instantiate_key 3 41855 NULL
107906 +pci_map_single_41869 pci_map_single 0 41869 NULL
107907 +usb_gadget_get_string_41871 usb_gadget_get_string 0 41871 NULL
107908 +v_APCI3120_InterruptDmaMoveBlock16bit_41914 v_APCI3120_InterruptDmaMoveBlock16bit 4 41914 NULL
107909 +get_fdb_entries_41916 get_fdb_entries 3 41916 NULL
107910 +find_ge_pid_41918 find_ge_pid 1 41918 NULL
107911 +build_inv_iotlb_pages_41922 build_inv_iotlb_pages 4-5 41922 NULL
107912 +nfsd_getxattr_41934 nfsd_getxattr 0 41934 NULL
107913 +ext4_da_write_inline_data_begin_41935 ext4_da_write_inline_data_begin 3-4 41935 NULL
107914 +read_gssp_41947 read_gssp 3 41947 NULL
107915 +ocfs2_xattr_bucket_get_name_value_41949 ocfs2_xattr_bucket_get_name_value 0 41949 NULL
107916 +portnames_read_41958 portnames_read 3 41958 NULL
107917 +ubi_self_check_all_ff_41959 ubi_self_check_all_ff 0-4 41959 NULL
107918 +dst_mtu_41969 dst_mtu 0 41969 NULL
107919 +btrfs_check_trunc_cache_free_space_41973 btrfs_check_trunc_cache_free_space 0 41973 NULL
107920 +cx24116_writeregN_41975 cx24116_writeregN 4 41975 NULL
107921 +ubi_io_is_bad_41983 ubi_io_is_bad 0 41983 NULL
107922 +pool_allocate_42012 pool_allocate 3 42012 NULL
107923 +spidev_sync_read_42014 spidev_sync_read 0 42014 NULL
107924 +rs_sta_dbgfs_scale_table_write_42017 rs_sta_dbgfs_scale_table_write 3 42017 NULL
107925 +nouveau_ttm_tt_create_42026 nouveau_ttm_tt_create 2 42026 NULL
107926 +acpi_ut_create_buffer_object_42030 acpi_ut_create_buffer_object 1 42030 NULL
107927 +__btrfs_drop_extents_42032 __btrfs_drop_extents 5-0 42032 NULL
107928 +__hwahc_op_set_gtk_42038 __hwahc_op_set_gtk 4 42038 NULL
107929 +irda_sendmsg_ultra_42047 irda_sendmsg_ultra 4 42047 NULL
107930 +dma_generic_alloc_coherent_42048 dma_generic_alloc_coherent 2 42048 NULL nohasharray
107931 +jffs2_do_link_42048 jffs2_do_link 6 42048 &dma_generic_alloc_coherent_42048
107932 +ps_poll_upsd_max_ap_turn_read_42050 ps_poll_upsd_max_ap_turn_read 3 42050 NULL
107933 +InterfaceTransmitPacket_42058 InterfaceTransmitPacket 3 42058 NULL
107934 +alloc_bitset_42085 alloc_bitset 1 42085 NULL
107935 +scsi_execute_req_42088 scsi_execute_req 5 42088 NULL
107936 +sk_chk_filter_42095 sk_chk_filter 2 42095 NULL
107937 +send_truncate_42107 send_truncate 0 42107 NULL
107938 +submit_inquiry_42108 submit_inquiry 3 42108 NULL
107939 +sysfs_read_file_42113 sysfs_read_file 3 42113 NULL nohasharray
107940 +dw_dma_cyclic_prep_42113 dw_dma_cyclic_prep 3-4 42113 &sysfs_read_file_42113
107941 +__btrfs_unlink_inode_42114 __btrfs_unlink_inode 0 42114 NULL
107942 +ext4_do_update_inode_42127 ext4_do_update_inode 0 42127 NULL
107943 +blk_ioctl_zeroout_42160 blk_ioctl_zeroout 3 42160 NULL
107944 +mmc_align_data_size_42161 mmc_align_data_size 0-2 42161 NULL
107945 +kvm_lapic_get_cr8_42166 kvm_lapic_get_cr8 0 42166 NULL
107946 +read_file_base_eeprom_42168 read_file_base_eeprom 3 42168 NULL
107947 +oprofilefs_str_to_user_42182 oprofilefs_str_to_user 3 42182 NULL
107948 +write_file_beacon_42185 write_file_beacon 3 42185 NULL
107949 +get_znodes_to_commit_42201 get_znodes_to_commit 0 42201 NULL
107950 +ocfs2_resv_window_bits_42207 ocfs2_resv_window_bits 0 42207 NULL
107951 +pla_ocp_read_42235 pla_ocp_read 3 42235 NULL
107952 +rx_defrag_need_decrypt_read_42253 rx_defrag_need_decrypt_read 3 42253 NULL
107953 +vfio_remove_dma_overlap_42255 vfio_remove_dma_overlap 2 42255 NULL
107954 +__pcpu_size_to_slot_42271 __pcpu_size_to_slot 0 42271 NULL
107955 +snd_pcm_hw_param_value_max_42280 snd_pcm_hw_param_value_max 0 42280 NULL
107956 +__cpus_weight_42299 __cpus_weight 2-0 42299 NULL
107957 +sel_read_perm_42302 sel_read_perm 3 42302 NULL
107958 +sctp_setsockopt_del_key_42304 sctp_setsockopt_del_key 3 42304 NULL nohasharray
107959 +ulong_read_file_42304 ulong_read_file 3 42304 &sctp_setsockopt_del_key_42304
107960 +gfn_to_hva_42305 gfn_to_hva 2-0 42305 NULL
107961 +close_cur_inode_file_42308 close_cur_inode_file 0 42308 NULL nohasharray
107962 +xfs_vm_readpages_42308 xfs_vm_readpages 4 42308 &close_cur_inode_file_42308
107963 +free_cblock_42318 free_cblock 2 42318 NULL
107964 +hysdn_conf_read_42324 hysdn_conf_read 3 42324 NULL
107965 +tcp_sync_mss_42330 tcp_sync_mss 2-0 42330 NULL
107966 +snd_pcm_plug_alloc_42339 snd_pcm_plug_alloc 2 42339 NULL
107967 +ide_raw_taskfile_42355 ide_raw_taskfile 4 42355 NULL
107968 +drbd_md_last_sector_42378 drbd_md_last_sector 0 42378 NULL
107969 +il_dbgfs_disable_ht40_read_42386 il_dbgfs_disable_ht40_read 3 42386 NULL
107970 +hash_ipportnet4_expire_42391 hash_ipportnet4_expire 3 42391 NULL
107971 +msnd_fifo_read_42406 msnd_fifo_read 0-3 42406 NULL
107972 +krng_get_random_42420 krng_get_random 3 42420 NULL
107973 +gsm_data_alloc_42437 gsm_data_alloc 3 42437 NULL
107974 +key_conf_keyidx_read_42443 key_conf_keyidx_read 3 42443 NULL
107975 +alloc_request_42448 alloc_request 0 42448 NULL
107976 +snd_pcm_action_group_42452 snd_pcm_action_group 0 42452 NULL
107977 +tcm_loop_change_queue_depth_42454 tcm_loop_change_queue_depth 2 42454 NULL
107978 +kuc_free_42455 kuc_free 2 42455 NULL
107979 +tc3589x_gpio_irq_get_virq_42457 tc3589x_gpio_irq_get_virq 2 42457 NULL
107980 +ext3_valid_block_bitmap_42459 ext3_valid_block_bitmap 3 42459 NULL
107981 +__simple_xattr_set_42474 __simple_xattr_set 4 42474 NULL
107982 +follow_hugetlb_page_42486 follow_hugetlb_page 0-7 42486 NULL
107983 +omfs_readpages_42490 omfs_readpages 4 42490 NULL
107984 +bypass_write_42498 bypass_write 3 42498 NULL
107985 +SyS_mincore_42511 SyS_mincore 1-2 42511 NULL
107986 +jbd2_log_wait_commit_42519 jbd2_log_wait_commit 0 42519 NULL
107987 +kvm_write_wall_clock_42520 kvm_write_wall_clock 2 42520 NULL
107988 +dio_bio_complete_42524 dio_bio_complete 0 42524 NULL
107989 +smk_write_netlbladdr_42525 smk_write_netlbladdr 3 42525 NULL
107990 +self_check_ec_hdr_42528 self_check_ec_hdr 0 42528 NULL
107991 +__register_ftrace_function_42543 __register_ftrace_function 0 42543 NULL
107992 +dbAllocNear_42546 dbAllocNear 0 42546 NULL
107993 +inorder_next_42548 inorder_next 1-0 42548 NULL
107994 +ath6kl_wmi_proc_events_vif_42549 ath6kl_wmi_proc_events_vif 5 42549 NULL
107995 +udp_recvmsg_42558 udp_recvmsg 4 42558 NULL
107996 +iwl_print_event_log_42566 iwl_print_event_log 0-5-7 42566 NULL
107997 +ocfs2_reserve_suballoc_bits_42569 ocfs2_reserve_suballoc_bits 0 42569 NULL
107998 +xfrm_new_hash_mask_42579 xfrm_new_hash_mask 0-1 42579 NULL
107999 +oom_score_adj_write_42594 oom_score_adj_write 3 42594 NULL
108000 +map_state_42602 map_state 1 42602 NULL
108001 +resp_write_42628 resp_write 2 42628 NULL
108002 +ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout_42635 ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout 3 42635 NULL
108003 +scsi_activate_tcq_42640 scsi_activate_tcq 2 42640 NULL
108004 +br_mdb_rehash_42643 br_mdb_rehash 2 42643 NULL
108005 +parport_pc_compat_write_block_pio_42644 parport_pc_compat_write_block_pio 3 42644 NULL
108006 +ocfs2_search_chain_42655 ocfs2_search_chain 0 42655 NULL
108007 +request_key_and_link_42693 request_key_and_link 4 42693 NULL
108008 +acpi_dev_get_irqresource_42694 acpi_dev_get_irqresource 2 42694 NULL
108009 +vb2_read_42703 vb2_read 3 42703 NULL
108010 +__ocfs2_decrease_refcount_42717 __ocfs2_decrease_refcount 5-4-0 42717 NULL
108011 +read_status_42722 read_status 0 42722 NULL
108012 +dvb_demux_ioctl_42733 dvb_demux_ioctl 2 42733 NULL
108013 +set_aoe_iflist_42737 set_aoe_iflist 2 42737 NULL
108014 +ax25_setsockopt_42740 ax25_setsockopt 5 42740 NULL
108015 +xen_bind_pirq_gsi_to_irq_42750 xen_bind_pirq_gsi_to_irq 1 42750 NULL
108016 +dpm_sysfs_add_42756 dpm_sysfs_add 0 42756 NULL
108017 +x25_recvmsg_42777 x25_recvmsg 4 42777 NULL
108018 +snd_midi_event_decode_42780 snd_midi_event_decode 0 42780 NULL
108019 +cryptd_hash_setkey_42781 cryptd_hash_setkey 3 42781 NULL nohasharray
108020 +isku_sysfs_read_info_42781 isku_sysfs_read_info 6 42781 &cryptd_hash_setkey_42781
108021 +elfcorehdr_read_notes_42786 elfcorehdr_read_notes 2 42786 NULL
108022 +koneplus_sysfs_read_42792 koneplus_sysfs_read 6 42792 NULL
108023 +ntfs_attr_extend_allocation_42796 ntfs_attr_extend_allocation 0-2-3 42796 NULL
108024 +fw_device_op_compat_ioctl_42804 fw_device_op_compat_ioctl 2 42804 NULL
108025 +drm_ioctl_42813 drm_ioctl 2 42813 NULL
108026 +iwl_dbgfs_ucode_bt_stats_read_42820 iwl_dbgfs_ucode_bt_stats_read 3 42820 NULL
108027 +xfs_iomap_eof_prealloc_initial_size_42822 xfs_iomap_eof_prealloc_initial_size 0-3 42822 NULL
108028 +set_arg_42824 set_arg 3 42824 NULL
108029 +si476x_radio_read_rsq_blob_42827 si476x_radio_read_rsq_blob 3 42827 NULL
108030 +ocfs2_desc_bitmap_to_cluster_off_42831 ocfs2_desc_bitmap_to_cluster_off 2 42831 NULL
108031 +prandom_u32_42853 prandom_u32 0 42853 NULL
108032 +ntfs_mapping_pairs_build_42859 ntfs_mapping_pairs_build 0 42859 NULL
108033 +nouveau_vm_create_42869 nouveau_vm_create 3-2 42869 NULL
108034 +ocfs2_clusters_for_bytes_42872 ocfs2_clusters_for_bytes 0-2 42872 NULL
108035 +nvme_trans_unit_serial_page_42879 nvme_trans_unit_serial_page 4 42879 NULL
108036 +xpc_kmalloc_cacheline_aligned_42895 xpc_kmalloc_cacheline_aligned 1 42895 NULL
108037 +hd_end_request_42904 hd_end_request 2 42904 NULL
108038 +sta_last_rx_rate_read_42909 sta_last_rx_rate_read 3 42909 NULL
108039 +sctp_getsockopt_maxburst_42941 sctp_getsockopt_maxburst 2 42941 NULL
108040 +get_unmapped_area_42944 get_unmapped_area 0 42944 NULL
108041 +vx_reset_chk_42946 vx_reset_chk 0 42946 NULL
108042 +send_link_42948 send_link 0 42948 NULL
108043 +blkdev_direct_IO_42962 blkdev_direct_IO 4 42962 NULL
108044 +read_file_node_stat_42964 read_file_node_stat 3 42964 NULL
108045 +compat_udpv6_setsockopt_42981 compat_udpv6_setsockopt 5 42981 NULL
108046 +nfs_idmap_get_desc_42990 nfs_idmap_get_desc 2-4 42990 NULL nohasharray
108047 +rtw_os_xmit_resource_alloc_42990 rtw_os_xmit_resource_alloc 3 42990 &nfs_idmap_get_desc_42990
108048 +mlx4_qp_reserve_range_43000 mlx4_qp_reserve_range 2-3 43000 NULL
108049 +isr_rx_mem_overflow_read_43025 isr_rx_mem_overflow_read 3 43025 NULL
108050 +add_bytes_to_bitmap_43026 add_bytes_to_bitmap 0-3-4 43026 NULL
108051 +init_phys_status_page_43028 init_phys_status_page 0 43028 NULL
108052 +wep_default_key_count_read_43035 wep_default_key_count_read 3 43035 NULL
108053 +send_to_group_43051 send_to_group 0 43051 NULL
108054 +nouveau_gpuobj_create__43072 nouveau_gpuobj_create_ 9 43072 NULL
108055 +nfs_map_group_to_gid_43082 nfs_map_group_to_gid 3 43082 NULL
108056 +ieee80211_if_fmt_drop_unencrypted_43107 ieee80211_if_fmt_drop_unencrypted 3 43107 NULL
108057 +calculate_node_totalpages_43118 calculate_node_totalpages 2-3 43118 NULL
108058 +cow_file_range_inline_43132 cow_file_range_inline 4 43132 NULL
108059 +read_file_dfs_43145 read_file_dfs 3 43145 NULL
108060 +cfs_cpt_table_alloc_43159 cfs_cpt_table_alloc 1 43159 NULL
108061 +usb_string_sub_43164 usb_string_sub 0 43164 NULL
108062 +il_dbgfs_power_save_status_read_43165 il_dbgfs_power_save_status_read 3 43165 NULL
108063 +send_cmd_43168 send_cmd 0 43168 NULL
108064 +ath6kl_set_assoc_req_ies_43185 ath6kl_set_assoc_req_ies 3 43185 NULL
108065 +ext4_xattr_ibody_get_43200 ext4_xattr_ibody_get 0 43200 NULL
108066 +uio_write_43202 uio_write 3 43202 NULL
108067 +iso_callback_43208 iso_callback 3 43208 NULL
108068 +ath10k_p2p_calc_noa_ie_len_43209 ath10k_p2p_calc_noa_ie_len 0 43209 NULL
108069 +f2fs_acl_from_disk_43210 f2fs_acl_from_disk 2 43210 NULL
108070 +atomic_long_add_return_43217 atomic_long_add_return 1-0 43217 NULL
108071 +vmemmap_alloc_block_43245 vmemmap_alloc_block 1 43245 NULL
108072 +fixup_leb_43256 fixup_leb 3 43256 NULL
108073 +ide_end_rq_43269 ide_end_rq 4 43269 NULL
108074 +nilfs_direct_IO_43271 nilfs_direct_IO 4 43271 NULL
108075 +mlx5_ib_reg_user_mr_43275 mlx5_ib_reg_user_mr 2-3 43275 NULL
108076 +parport_pc_ecp_write_block_pio_43278 parport_pc_ecp_write_block_pio 3 43278 NULL nohasharray
108077 +evtchn_write_43278 evtchn_write 3 43278 &parport_pc_ecp_write_block_pio_43278
108078 +filemap_write_and_wait_range_43279 filemap_write_and_wait_range 0 43279 NULL
108079 +mpage_alloc_43299 mpage_alloc 3 43299 NULL
108080 +get_nr_irqs_gsi_43315 get_nr_irqs_gsi 0 43315 NULL
108081 +mmu_set_spte_43327 mmu_set_spte 7-6 43327 NULL
108082 +__ext4_get_inode_loc_43332 __ext4_get_inode_loc 0 43332 NULL
108083 +kvm_host_page_size_43348 kvm_host_page_size 2-0 43348 NULL
108084 +activation_descriptor_init_43358 activation_descriptor_init 1 43358 NULL
108085 +gart_free_coherent_43362 gart_free_coherent 4-2 43362 NULL
108086 +hash_net4_expire_43378 hash_net4_expire 3 43378 NULL
108087 +xenfb_write_43412 xenfb_write 3 43412 NULL
108088 +__alloc_bootmem_low_43423 __alloc_bootmem_low 1 43423 NULL
108089 +usb_alloc_urb_43436 usb_alloc_urb 1 43436 NULL
108090 +ath6kl_wmi_roam_tbl_event_rx_43440 ath6kl_wmi_roam_tbl_event_rx 3 43440 NULL
108091 +ocfs2_rotate_tree_left_43442 ocfs2_rotate_tree_left 0 43442 NULL
108092 +usemap_size_43443 usemap_size 0-2-1 43443 NULL nohasharray
108093 +usb_string_43443 usb_string 0 43443 &usemap_size_43443
108094 +get_vm_area_size_43444 get_vm_area_size 0 43444 NULL
108095 +nvme_trans_device_id_page_43466 nvme_trans_device_id_page 4 43466 NULL
108096 +calculate_discard_block_size_43480 calculate_discard_block_size 0 43480 NULL nohasharray
108097 +alloc_new_reservation_43480 alloc_new_reservation 4-0-2 43480 &calculate_discard_block_size_43480
108098 +tx_tx_data_prepared_read_43497 tx_tx_data_prepared_read 3 43497 NULL
108099 +ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime_43505 ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime 3 43505 NULL
108100 +do_readlink_43518 do_readlink 2 43518 NULL
108101 +dvb_ca_en50221_io_write_43533 dvb_ca_en50221_io_write 3 43533 NULL
108102 +read_events_43534 read_events 3 43534 NULL
108103 +cachefiles_daemon_write_43535 cachefiles_daemon_write 3 43535 NULL
108104 +tx_frag_failed_read_43540 tx_frag_failed_read 3 43540 NULL nohasharray
108105 +ufs_alloccg_block_43540 ufs_alloccg_block 3-0 43540 &tx_frag_failed_read_43540
108106 +request_resource_43548 request_resource 0 43548 NULL
108107 +rpc_malloc_43573 rpc_malloc 2 43573 NULL
108108 +handle_frequent_errors_43599 handle_frequent_errors 4 43599 NULL
108109 +lpfc_idiag_drbacc_read_reg_43606 lpfc_idiag_drbacc_read_reg 0-3 43606 NULL
108110 +proc_read_43614 proc_read 3 43614 NULL
108111 +i915_gem_execbuffer_relocate_object_slow_43618 i915_gem_execbuffer_relocate_object_slow 0 43618 NULL nohasharray
108112 +disable_dma_on_even_43618 disable_dma_on_even 0 43618 &i915_gem_execbuffer_relocate_object_slow_43618
108113 +alloc_thread_groups_43625 alloc_thread_groups 2 43625 NULL
108114 +random_write_43656 random_write 3 43656 NULL
108115 +bio_integrity_tag_43658 bio_integrity_tag 3 43658 NULL
108116 +ext4_acl_count_43659 ext4_acl_count 0-1 43659 NULL
108117 +fs_path_copy_43673 fs_path_copy 0 43673 NULL
108118 +dmam_declare_coherent_memory_43679 dmam_declare_coherent_memory 4 43679 NULL
108119 +calgary_map_page_43686 calgary_map_page 4 43686 NULL
108120 +max77693_bulk_write_43698 max77693_bulk_write 2-3 43698 NULL
108121 +wait_for_completion_interruptible_43723 wait_for_completion_interruptible 0 43723 NULL
108122 +drbd_md_first_sector_43729 drbd_md_first_sector 0 43729 NULL
108123 +reset_card_proc_43731 reset_card_proc 0 43731 NULL
108124 +snd_rme32_playback_copy_43732 snd_rme32_playback_copy 5 43732 NULL
108125 +ocfs2_replace_clusters_43733 ocfs2_replace_clusters 5-0 43733 NULL
108126 +fuse_conn_congestion_threshold_write_43736 fuse_conn_congestion_threshold_write 3 43736 NULL
108127 +__bm_find_next_43748 __bm_find_next 2 43748 NULL
108128 +gigaset_initcs_43753 gigaset_initcs 2 43753 NULL
108129 +sctp_setsockopt_active_key_43755 sctp_setsockopt_active_key 3 43755 NULL
108130 +ocfs2_xattr_get_value_outside_43787 ocfs2_xattr_get_value_outside 0 43787 NULL nohasharray
108131 +byte_pos_43787 byte_pos 0-2 43787 &ocfs2_xattr_get_value_outside_43787
108132 +btrfs_copy_from_user_43806 btrfs_copy_from_user 0-3-1 43806 NULL
108133 +ext4_read_block_bitmap_43814 ext4_read_block_bitmap 2 43814 NULL
108134 +div64_u64_safe_43815 div64_u64_safe 2-1 43815 NULL
108135 +ext4_split_extent_43818 ext4_split_extent 0 43818 NULL
108136 +i915_gem_execbuffer_relocate_entry_43822 i915_gem_execbuffer_relocate_entry 0 43822 NULL
108137 +ieee80211_if_fmt_element_ttl_43825 ieee80211_if_fmt_element_ttl 3 43825 NULL
108138 +ieee80211_alloc_hw_43829 ieee80211_alloc_hw 1 43829 NULL
108139 +read_flush_43851 read_flush 3 43851 NULL
108140 +ocfs2_block_group_find_clear_bits_43874 ocfs2_block_group_find_clear_bits 4 43874 NULL
108141 +pm860x_bulk_write_43875 pm860x_bulk_write 2-3 43875 NULL
108142 +SendString_43928 SendString 3 43928 NULL
108143 +xen_register_gsi_43946 xen_register_gsi 2-1 43946 NULL
108144 +stats_dot11RTSFailureCount_read_43948 stats_dot11RTSFailureCount_read 3 43948 NULL
108145 +perf_tp_event_43971 perf_tp_event 2 43971 NULL
108146 +__get_required_blob_size_43980 __get_required_blob_size 0-3-2 43980 NULL
108147 +nla_reserve_43984 nla_reserve 3 43984 NULL
108148 +__clkdev_alloc_43990 __clkdev_alloc 1 43990 NULL
108149 +scsi_command_size_43992 scsi_command_size 0 43992 NULL nohasharray
108150 +kvm_read_guest_virt_43992 kvm_read_guest_virt 4-2 43992 &scsi_command_size_43992 nohasharray
108151 +bcm_recvmsg_43992 bcm_recvmsg 4 43992 &kvm_read_guest_virt_43992
108152 +ulist_add_43994 ulist_add 0 43994 NULL
108153 +emit_flags_44006 emit_flags 4-3 44006 NULL
108154 +write_flush_procfs_44011 write_flush_procfs 3 44011 NULL
108155 +fru_strlen_44046 fru_strlen 0 44046 NULL
108156 +tree_insert_offset_44069 tree_insert_offset 0 44069 NULL
108157 +SYSC_add_key_44079 SYSC_add_key 4 44079 NULL
108158 +btrfs_prev_leaf_44083 btrfs_prev_leaf 0 44083 NULL nohasharray
108159 +load_discard_44083 load_discard 3 44083 &btrfs_prev_leaf_44083
108160 +__vxge_hw_vpath_tim_configure_44093 __vxge_hw_vpath_tim_configure 2 44093 NULL
108161 +xlog_recover_add_to_cont_trans_44102 xlog_recover_add_to_cont_trans 4 44102 NULL
108162 +skb_frag_dma_map_44112 skb_frag_dma_map 0 44112 NULL
108163 +tracing_set_trace_read_44122 tracing_set_trace_read 3 44122 NULL
108164 +hwif_to_node_44127 hwif_to_node 0 44127 NULL
108165 +SyS_process_vm_writev_44129 SyS_process_vm_writev 3-5 44129 NULL
108166 +vmw_gmr_bind_44130 vmw_gmr_bind 3 44130 NULL
108167 +lookup_extent_data_ref_44136 lookup_extent_data_ref 0 44136 NULL
108168 +ttm_get_pages_44142 ttm_get_pages 2 44142 NULL
108169 +scsi_get_resid_44147 scsi_get_resid 0 44147 NULL
108170 +ubifs_find_dirty_idx_leb_44169 ubifs_find_dirty_idx_leb 0 44169 NULL
108171 +ocfs2_xattr_bucket_find_44174 ocfs2_xattr_bucket_find 0 44174 NULL
108172 +SYSC_set_mempolicy_44176 SYSC_set_mempolicy 3 44176 NULL
108173 +readreg_ipac_44186 readreg_ipac 0 44186 NULL
108174 +handle_eviocgbit_44193 handle_eviocgbit 3 44193 NULL
108175 +IO_APIC_get_PCI_irq_vector_44198 IO_APIC_get_PCI_irq_vector 0 44198 NULL
108176 +__set_free_44211 __set_free 2 44211 NULL
108177 +claim_ptd_buffers_44213 claim_ptd_buffers 3 44213 NULL
108178 +srp_alloc_iu_44227 srp_alloc_iu 2 44227 NULL
108179 +ioapic_register_intr_44238 ioapic_register_intr 1 44238 NULL
108180 +scsi_track_queue_full_44239 scsi_track_queue_full 2 44239 NULL
108181 +sigma_action_write_regmap_44240 sigma_action_write_regmap 3 44240 NULL
108182 +tc3589x_gpio_irq_map_44245 tc3589x_gpio_irq_map 2 44245 NULL
108183 +apei_resources_sub_44252 apei_resources_sub 0 44252 NULL
108184 +byt_gpio_irq_map_44275 byt_gpio_irq_map 2 44275 NULL
108185 +device_create_file_44285 device_create_file 0 44285 NULL
108186 +ufs_clusteracct_44293 ufs_clusteracct 3 44293 NULL
108187 +ocfs2_zero_range_for_truncate_44294 ocfs2_zero_range_for_truncate 3 44294 NULL
108188 +ath6kl_keepalive_read_44303 ath6kl_keepalive_read 3 44303 NULL
108189 +bitmap_scnprintf_44318 bitmap_scnprintf 0-2 44318 NULL
108190 +dispatch_proc_write_44320 dispatch_proc_write 3 44320 NULL
108191 +rs_init_44327 rs_init 1 44327 NULL
108192 +create_free_space_inode_44332 create_free_space_inode 0 44332 NULL
108193 +insert_into_bitmap_44340 insert_into_bitmap 0 44340 NULL
108194 +ubi_eba_write_leb_st_44343 ubi_eba_write_leb_st 0-5 44343 NULL
108195 +radix_tree_maybe_preload_44346 radix_tree_maybe_preload 0 44346 NULL
108196 +nfs_fscache_get_super_cookie_44355 nfs_fscache_get_super_cookie 3 44355 NULL nohasharray
108197 +blk_queue_init_tags_44355 blk_queue_init_tags 2 44355 &nfs_fscache_get_super_cookie_44355
108198 +__is_discarded_44359 __is_discarded 2 44359 NULL
108199 +ipx_recvmsg_44366 ipx_recvmsg 4 44366 NULL
108200 +alloc_requests_44372 alloc_requests 0 44372 NULL
108201 +rts_threshold_read_44384 rts_threshold_read 3 44384 NULL
108202 +iterate_dir_item_44386 iterate_dir_item 0 44386 NULL
108203 +mtip_hw_read_flags_44396 mtip_hw_read_flags 3 44396 NULL
108204 +aoedev_flush_44398 aoedev_flush 2 44398 NULL
108205 +strlcpy_44400 strlcpy 3 44400 NULL
108206 +drm_buffer_alloc_44405 drm_buffer_alloc 2 44405 NULL
108207 +osst_do_scsi_44410 osst_do_scsi 4 44410 NULL
108208 +check_user_page_hwpoison_44412 check_user_page_hwpoison 1 44412 NULL
108209 +ieee80211_if_read_rc_rateidx_mcs_mask_5ghz_44423 ieee80211_if_read_rc_rateidx_mcs_mask_5ghz 3 44423 NULL
108210 +iwl_dbgfs_bf_params_write_44450 iwl_dbgfs_bf_params_write 3 44450 NULL
108211 +write_file_debug_44476 write_file_debug 3 44476 NULL
108212 +btrfs_chunk_item_size_44478 btrfs_chunk_item_size 0-1 44478 NULL
108213 +sdio_align_size_44489 sdio_align_size 0-2 44489 NULL
108214 +bio_advance_44496 bio_advance 2 44496 NULL
108215 +ieee80211_if_read_dropped_frames_ttl_44500 ieee80211_if_read_dropped_frames_ttl 3 44500 NULL
108216 +ac_register_board_44504 ac_register_board 3 44504 NULL
108217 +security_getprocattr_44505 security_getprocattr 0 44505 NULL nohasharray
108218 +iwl_dbgfs_sram_read_44505 iwl_dbgfs_sram_read 3 44505 &security_getprocattr_44505
108219 +spidev_write_44510 spidev_write 3 44510 NULL
108220 +SyS_io_getevents_44519 SyS_io_getevents 3 44519 NULL
108221 +ieee80211_rx_mgmt_assoc_resp_44525 ieee80211_rx_mgmt_assoc_resp 3 44525 NULL
108222 +comm_write_44537 comm_write 3 44537 NULL
108223 +xfs_log_calc_unit_res_44540 xfs_log_calc_unit_res 0-2 44540 NULL
108224 +snd_pcm_drop_44542 snd_pcm_drop 0 44542 NULL
108225 +dbg_chk_pnode_44555 dbg_chk_pnode 0 44555 NULL
108226 +shmem_getpage_gfp_44556 shmem_getpage_gfp 0 44556 NULL
108227 +hash_ipport4_expire_44564 hash_ipport4_expire 3 44564 NULL
108228 +dgrp_config_proc_write_44571 dgrp_config_proc_write 3 44571 NULL
108229 +snd_pcm_alloc_vmalloc_buffer_44595 snd_pcm_alloc_vmalloc_buffer 2 44595 NULL
108230 +btrfs_qgroup_account_ref_44604 btrfs_qgroup_account_ref 0 44604 NULL
108231 +huge_page_shift_44618 huge_page_shift 0 44618 NULL
108232 +sysfs_add_one_44629 sysfs_add_one 0 44629 NULL
108233 +msb_get_free_block_44633 msb_get_free_block 2 44633 NULL
108234 +ext2_new_block_44645 ext2_new_block 2-0 44645 NULL
108235 +alloc_ctrl_packet_44667 alloc_ctrl_packet 1 44667 NULL
108236 +mpi_resize_44674 mpi_resize 2 44674 NULL
108237 +sysfs_create_link_44685 sysfs_create_link 0 44685 NULL nohasharray
108238 +__copy_user_intel_nocache_44685 __copy_user_intel_nocache 0-3 44685 &sysfs_create_link_44685
108239 +ts_read_44687 ts_read 3 44687 NULL
108240 +qib_get_user_pages_44689 qib_get_user_pages 1-2 44689 NULL
108241 +lov_emerg_alloc_44698 lov_emerg_alloc 1 44698 NULL
108242 +__ocfs2_rotate_tree_left_44705 __ocfs2_rotate_tree_left 0 44705 NULL
108243 +xfer_to_user_44713 xfer_to_user 3 44713 NULL nohasharray
108244 +__generic_block_fiemap_44713 __generic_block_fiemap 4 44713 &xfer_to_user_44713
108245 +_zd_iowrite32v_locked_44725 _zd_iowrite32v_locked 3 44725 NULL
108246 +clusterip_proc_write_44729 clusterip_proc_write 3 44729 NULL
108247 +fib_count_nexthops_44730 fib_count_nexthops 0 44730 NULL
108248 +SyS_read_44732 SyS_read 3 44732 NULL
108249 +vm_insert_mixed_44738 vm_insert_mixed 3 44738 NULL
108250 +key_tx_rx_count_read_44742 key_tx_rx_count_read 3 44742 NULL
108251 +set_brk_44749 set_brk 1-2 44749 NULL
108252 +tnode_new_44757 tnode_new 3 44757 NULL nohasharray
108253 +pty_write_44757 pty_write 3 44757 &tnode_new_44757
108254 +__videobuf_copy_stream_44769 __videobuf_copy_stream 4-0 44769 NULL
108255 +handsfree_ramp_44777 handsfree_ramp 2 44777 NULL
108256 +irq_domain_add_legacy_44781 irq_domain_add_legacy 4-2 44781 NULL
108257 +sctp_setsockopt_44788 sctp_setsockopt 5 44788 NULL
108258 +rx_dropped_read_44799 rx_dropped_read 3 44799 NULL
108259 +qla4xxx_alloc_work_44813 qla4xxx_alloc_work 2 44813 NULL
108260 +mei_cl_read_start_44824 mei_cl_read_start 2 44824 NULL
108261 +rmap_write_protect_44833 rmap_write_protect 2 44833 NULL
108262 +sisusb_write_44834 sisusb_write 3 44834 NULL
108263 +kvm_read_hva_44847 kvm_read_hva 3 44847 NULL
108264 +cubic_root_44848 cubic_root 1 44848 NULL
108265 +qib_verbs_send_dma_44850 qib_verbs_send_dma 6 44850 NULL
108266 +copydesc_user_44855 copydesc_user 3 44855 NULL
108267 +i915_gem_execbuffer_relocate_44868 i915_gem_execbuffer_relocate 0 44868 NULL
108268 +init_rs_44873 init_rs 1 44873 NULL
108269 +skb_availroom_44883 skb_availroom 0 44883 NULL
108270 +ocfs2_wait_for_mask_44893 ocfs2_wait_for_mask 0 44893 NULL
108271 +do_tty_write_44896 do_tty_write 5 44896 NULL
108272 +regmap_spi_read_44921 regmap_spi_read 3-5 44921 NULL
108273 +_snd_pcm_hw_param_last_44947 _snd_pcm_hw_param_last 0 44947 NULL
108274 +__add_delayed_refs_44977 __add_delayed_refs 0 44977 NULL
108275 +tx_queue_status_read_44978 tx_queue_status_read 3 44978 NULL
108276 +map_index_to_lba_44993 map_index_to_lba 0-1 44993 NULL
108277 +send_chmod_45011 send_chmod 0 45011 NULL
108278 +i915_gem_do_execbuffer_45012 i915_gem_do_execbuffer 0 45012 NULL
108279 +bytepos_delta_45017 bytepos_delta 0-2 45017 NULL
108280 +read_block_bitmap_45021 read_block_bitmap 2 45021 NULL nohasharray
108281 +ptrace_writedata_45021 ptrace_writedata 4-3 45021 &read_block_bitmap_45021
108282 +dm_kvzalloc_45025 dm_kvzalloc 1-2 45025 NULL
108283 +vhci_get_user_45039 vhci_get_user 3 45039 NULL
108284 +sysfs_do_create_link_sd_45057 sysfs_do_create_link_sd 0 45057 NULL
108285 +remap_oldmem_pfn_range_45060 remap_oldmem_pfn_range 2-3-4 45060 NULL nohasharray
108286 +sel_write_user_45060 sel_write_user 3 45060 &remap_oldmem_pfn_range_45060
108287 +vmscan_swappiness_45062 vmscan_swappiness 0 45062 NULL
108288 +snd_mixart_BA0_read_45069 snd_mixart_BA0_read 5 45069 NULL
108289 +kvm_mmu_page_get_gfn_45110 kvm_mmu_page_get_gfn 0-2 45110 NULL
108290 +pwr_missing_bcns_cnt_read_45113 pwr_missing_bcns_cnt_read 3 45113 NULL
108291 +usbdev_read_45114 usbdev_read 3 45114 NULL
108292 +send_to_tty_45141 send_to_tty 3 45141 NULL
108293 +stmpe_irq_map_45146 stmpe_irq_map 2 45146 NULL
108294 +cfs_trace_daemon_command_usrstr_45147 cfs_trace_daemon_command_usrstr 2 45147 NULL
108295 +gen_bitmask_string_45149 gen_bitmask_string 6 45149 NULL
108296 +ocfs2_remove_inode_range_45156 ocfs2_remove_inode_range 3-4 45156 NULL nohasharray
108297 +device_write_45156 device_write 3 45156 &ocfs2_remove_inode_range_45156
108298 +ocfs2_dq_frozen_trigger_45159 ocfs2_dq_frozen_trigger 4 45159 NULL
108299 +SYSC_write_45160 SYSC_write 3 45160 NULL
108300 +tomoyo_write_self_45161 tomoyo_write_self 3 45161 NULL
108301 +sta_agg_status_write_45164 sta_agg_status_write 3 45164 NULL
108302 +sctp_pack_cookie_45190 sctp_pack_cookie 6 45190 NULL nohasharray
108303 +snd_sb_csp_load_user_45190 snd_sb_csp_load_user 3 45190 &sctp_pack_cookie_45190
108304 +num_clusters_in_group_45194 num_clusters_in_group 2 45194 NULL
108305 +__radix_tree_preload_45197 __radix_tree_preload 0 45197 NULL
108306 +iso_alloc_urb_45206 iso_alloc_urb 4-5 45206 NULL
108307 +spi_alloc_master_45223 spi_alloc_master 2 45223 NULL
108308 +__dirty_45228 __dirty 2 45228 NULL
108309 +ieee80211_if_read_peer_45233 ieee80211_if_read_peer 3 45233 NULL
108310 +event_enable_write_45238 event_enable_write 3 45238 NULL
108311 +prism2_pda_proc_read_45246 prism2_pda_proc_read 3 45246 NULL
108312 +input_mt_init_slots_45279 input_mt_init_slots 2 45279 NULL
108313 +gfs2_fiemap_45282 gfs2_fiemap 4 45282 NULL
108314 +snd_pcm_oss_sync1_45298 snd_pcm_oss_sync1 2 45298 NULL
108315 +e1000_tx_map_45309 e1000_tx_map 5 45309 NULL
108316 +pte_val_45313 pte_val 0 45313 NULL
108317 +copy_vm86_regs_from_user_45340 copy_vm86_regs_from_user 3 45340 NULL
108318 +null_alloc_repbuf_45375 null_alloc_repbuf 3 45375 NULL
108319 +sock_recv_errqueue_45412 sock_recv_errqueue 3 45412 NULL
108320 +paging64_gva_to_gpa_45421 paging64_gva_to_gpa 2 45421 NULL nohasharray
108321 +ieee80211_if_fmt_dot11MeshHWMProotInterval_45421 ieee80211_if_fmt_dot11MeshHWMProotInterval 3 45421 &paging64_gva_to_gpa_45421
108322 +alloc_task_struct_node_45426 alloc_task_struct_node 1 45426 NULL
108323 +ll_iocontrol_register_45430 ll_iocontrol_register 2 45430 NULL
108324 +tty_buffer_alloc_45437 tty_buffer_alloc 2 45437 NULL
108325 +SYSC_mremap_45446 SYSC_mremap 5-1-2-3 45446 NULL
108326 +__node_remap_45458 __node_remap 4 45458 NULL
108327 +rds_ib_set_wr_signal_state_45463 rds_ib_set_wr_signal_state 0 45463 NULL
108328 +tracing_read_dyn_info_45468 tracing_read_dyn_info 3 45468 NULL
108329 +snd_pcm_hwsync_45479 snd_pcm_hwsync 0 45479 NULL
108330 +arizona_init_fll_45503 arizona_init_fll 5 45503 NULL
108331 +rds_message_copy_from_user_45510 rds_message_copy_from_user 3 45510 NULL
108332 +i40e_alloc_vfs_45511 i40e_alloc_vfs 2 45511 NULL
108333 +__split_vma_45522 __split_vma 0 45522 NULL
108334 +cgroup_read_u64_45532 cgroup_read_u64 5 45532 NULL
108335 +copy_macs_45534 copy_macs 4 45534 NULL
108336 +nla_attr_size_45545 nla_attr_size 0-1 45545 NULL
108337 +v9fs_direct_read_45546 v9fs_direct_read 3 45546 NULL
108338 +cx18_copy_mdl_to_user_45549 cx18_copy_mdl_to_user 4 45549 NULL
108339 +ext3_group_first_block_no_45555 ext3_group_first_block_no 0-2 45555 NULL
108340 +stats_dot11ACKFailureCount_read_45558 stats_dot11ACKFailureCount_read 3 45558 NULL
108341 +_regmap_bus_raw_write_45559 _regmap_bus_raw_write 2 45559 NULL
108342 +posix_acl_xattr_size_45561 posix_acl_xattr_size 0-1 45561 NULL
108343 +venus_rmdir_45564 venus_rmdir 4 45564 NULL
108344 +btrfs_find_free_ino_45585 btrfs_find_free_ino 0 45585 NULL
108345 +ipath_create_cq_45586 ipath_create_cq 2 45586 NULL
108346 +ath6kl_keepalive_write_45600 ath6kl_keepalive_write 3 45600 NULL
108347 +hidraw_get_report_45609 hidraw_get_report 3 45609 NULL
108348 +commit_cowonly_roots_45640 commit_cowonly_roots 0 45640 NULL
108349 +ebitmap_next_positive_45651 ebitmap_next_positive 3-0 45651 NULL
108350 +ext4_reserve_inode_write_45654 ext4_reserve_inode_write 0 45654 NULL
108351 +dma_map_cont_45668 dma_map_cont 5 45668 NULL
108352 +compat_mpctl_ioctl_45671 compat_mpctl_ioctl 2 45671 NULL
108353 +dgram_sendmsg_45679 dgram_sendmsg 4 45679 NULL
108354 +smk_write_ambient_45691 smk_write_ambient 3 45691 NULL
108355 +unix_dgram_sendmsg_45699 unix_dgram_sendmsg 4 45699 NULL nohasharray
108356 +bscnl_emit_45699 bscnl_emit 0-2-5 45699 &unix_dgram_sendmsg_45699
108357 +sg_proc_write_adio_45704 sg_proc_write_adio 3 45704 NULL
108358 +snd_cs46xx_io_read_45734 snd_cs46xx_io_read 5 45734 NULL nohasharray
108359 +task_cgroup_path_45734 task_cgroup_path 3 45734 &snd_cs46xx_io_read_45734
108360 +rw_copy_check_uvector_45748 rw_copy_check_uvector 3-0 45748 NULL nohasharray
108361 +v4l2_ctrl_new_std_45748 v4l2_ctrl_new_std 5 45748 &rw_copy_check_uvector_45748
108362 +lkdtm_debugfs_read_45752 lkdtm_debugfs_read 3 45752 NULL
108363 +btrfs_delete_delayed_dir_index_45757 btrfs_delete_delayed_dir_index 0 45757 NULL
108364 +alloc_ts_config_45775 alloc_ts_config 1 45775 NULL
108365 +osc_checksum_type_seq_write_45785 osc_checksum_type_seq_write 3 45785 NULL
108366 +raw_setsockopt_45800 raw_setsockopt 5 45800 NULL
108367 +rds_tcp_inc_copy_to_user_45804 rds_tcp_inc_copy_to_user 3 45804 NULL
108368 +lbs_rdbbp_read_45805 lbs_rdbbp_read 3 45805 NULL
108369 +pcpu_alloc_alloc_info_45813 pcpu_alloc_alloc_info 1-2 45813 NULL
108370 +ll_max_readahead_mb_seq_write_45815 ll_max_readahead_mb_seq_write 3 45815 NULL
108371 +fm_v4l2_init_video_device_45821 fm_v4l2_init_video_device 2 45821 NULL
108372 +memcg_update_cache_size_45828 memcg_update_cache_size 2 45828 NULL
108373 +ipv6_recv_rxpmtu_45830 ipv6_recv_rxpmtu 3 45830 NULL
108374 +task_state_char_45839 task_state_char 1 45839 NULL
108375 +__ip_select_ident_45851 __ip_select_ident 3 45851 NULL
108376 +x509_process_extension_45854 x509_process_extension 5 45854 NULL
108377 +efx_tx_queue_insert_45859 efx_tx_queue_insert 2 45859 NULL
108378 +isdn_write_45863 isdn_write 3 45863 NULL
108379 +unpack_orig_pfns_45867 unpack_orig_pfns 0 45867 NULL
108380 +tpm_config_in_45880 tpm_config_in 0 45880 NULL
108381 +get_rdac_req_45882 get_rdac_req 3 45882 NULL
108382 +ocfs2_xattr_block_find_45891 ocfs2_xattr_block_find 0 45891 NULL
108383 +online_page_cgroup_45894 online_page_cgroup 3 45894 NULL
108384 +cfs_cpt_weight_45903 cfs_cpt_weight 0 45903 NULL
108385 +wm_adsp_region_to_reg_45915 wm_adsp_region_to_reg 0-2 45915 NULL
108386 +dbgfs_frame_45917 dbgfs_frame 3 45917 NULL
108387 +alloc_mr_45935 alloc_mr 1 45935 NULL
108388 +kmem_cache_alloc_node_trace_45968 kmem_cache_alloc_node_trace 3 45968 NULL
108389 +copy_to_45969 copy_to 3 45969 NULL
108390 +rb_simple_read_45972 rb_simple_read 3 45972 NULL
108391 +ioat2_dca_count_dca_slots_45984 ioat2_dca_count_dca_slots 0 45984 NULL
108392 +ore_calc_stripe_info_46023 ore_calc_stripe_info 2 46023 NULL
108393 +sierra_setup_urb_46029 sierra_setup_urb 5 46029 NULL
108394 +get_free_entries_46030 get_free_entries 1 46030 NULL
108395 +__access_remote_vm_46031 __access_remote_vm 0-3-5 46031 NULL
108396 +snd_emu10k1x_ptr_read_46049 snd_emu10k1x_ptr_read 0 46049 NULL
108397 +acpi_register_gsi_xen_hvm_46052 acpi_register_gsi_xen_hvm 2 46052 NULL
108398 +__ocfs2_move_extent_46060 __ocfs2_move_extent 5-6-4-0-3 46060 NULL nohasharray
108399 +dma_tx_errors_read_46060 dma_tx_errors_read 3 46060 &__ocfs2_move_extent_46060
108400 +sel_commit_bools_write_46077 sel_commit_bools_write 3 46077 NULL
108401 +arizona_set_irq_wake_46101 arizona_set_irq_wake 2 46101 NULL
108402 +memcg_update_array_size_46111 memcg_update_array_size 1 46111 NULL nohasharray
108403 +il3945_ucode_general_stats_read_46111 il3945_ucode_general_stats_read 3 46111 &memcg_update_array_size_46111
108404 +C_SYSC_writev_46113 C_SYSC_writev 3 46113 NULL
108405 +mlx4_ib_alloc_fast_reg_page_list_46119 mlx4_ib_alloc_fast_reg_page_list 2 46119 NULL
108406 +paging32_walk_addr_nested_46121 paging32_walk_addr_nested 3 46121 NULL
108407 +replay_dir_deletes_46136 replay_dir_deletes 0 46136 NULL
108408 +rtw_buf_update_46138 rtw_buf_update 4 46138 NULL
108409 +vb2_dma_sg_get_userptr_46146 vb2_dma_sg_get_userptr 2-3 46146 NULL
108410 +__netlink_change_ngroups_46156 __netlink_change_ngroups 2 46156 NULL
108411 +alloc_iova_46160 alloc_iova 2 46160 NULL
108412 +twl_direction_out_46182 twl_direction_out 2 46182 NULL
108413 +vxge_os_dma_malloc_46184 vxge_os_dma_malloc 2 46184 NULL
108414 +fq_resize_46195 fq_resize 2 46195 NULL
108415 +add_conn_list_46197 add_conn_list 3-0 46197 NULL
108416 +i2400m_op_msg_from_user_46213 i2400m_op_msg_from_user 4 46213 NULL
108417 +tm6000_i2c_recv_regs_46215 tm6000_i2c_recv_regs 5 46215 NULL
108418 +dsp_write_46218 dsp_write 2 46218 NULL
108419 +xen_setup_msi_irqs_46245 xen_setup_msi_irqs 2 46245 NULL
108420 +mpi_read_raw_data_46248 mpi_read_raw_data 2 46248 NULL
108421 +ReadReg_46277 ReadReg 0 46277 NULL
108422 +sg_proc_write_dressz_46316 sg_proc_write_dressz 3 46316 NULL
108423 +__hwahc_dev_set_key_46328 __hwahc_dev_set_key 5 46328 NULL nohasharray
108424 +compat_SyS_readv_46328 compat_SyS_readv 3 46328 &__hwahc_dev_set_key_46328
108425 +iwl_dbgfs_chain_noise_read_46355 iwl_dbgfs_chain_noise_read 3 46355 NULL
108426 +smk_write_direct_46363 smk_write_direct 3 46363 NULL
108427 +__iommu_calculate_agaw_46366 __iommu_calculate_agaw 2 46366 NULL
108428 +ubi_dump_flash_46381 ubi_dump_flash 4 46381 NULL
108429 +mmap_ureg_46388 mmap_ureg 3 46388 NULL
108430 +vma_adjust_46390 vma_adjust 0 46390 NULL
108431 +fuse_file_aio_write_46399 fuse_file_aio_write 4 46399 NULL
108432 +crypto_ablkcipher_reqsize_46411 crypto_ablkcipher_reqsize 0 46411 NULL
108433 +ttm_page_pool_get_pages_46431 ttm_page_pool_get_pages 0-5 46431 NULL
108434 +cfs_power2_roundup_46433 cfs_power2_roundup 0-1 46433 NULL
108435 +hash_ipportip6_expire_46443 hash_ipportip6_expire 3 46443 NULL
108436 +cp210x_set_config_46447 cp210x_set_config 4 46447 NULL
108437 +parport_pc_fifo_write_block_46455 parport_pc_fifo_write_block 3 46455 NULL
108438 +il_dbgfs_clear_traffic_stats_write_46458 il_dbgfs_clear_traffic_stats_write 3 46458 NULL
108439 +filldir64_46469 filldir64 3 46469 NULL
108440 +ocfs2_reserve_clusters_with_limit_46479 ocfs2_reserve_clusters_with_limit 0 46479 NULL
108441 +fill_in_write_vector_46498 fill_in_write_vector 0 46498 NULL
108442 +p9pdu_vreadf_46500 p9pdu_vreadf 0 46500 NULL
108443 +pin_code_reply_46510 pin_code_reply 4 46510 NULL
108444 +mthca_alloc_cq_buf_46512 mthca_alloc_cq_buf 3 46512 NULL
108445 +nouveau_drm_ioctl_46514 nouveau_drm_ioctl 2 46514 NULL nohasharray
108446 +kmsg_read_46514 kmsg_read 3 46514 &nouveau_drm_ioctl_46514
108447 +bdx_rxdb_create_46525 bdx_rxdb_create 1 46525 NULL
108448 +nl80211_send_rx_assoc_46538 nl80211_send_rx_assoc 4 46538 NULL
108449 +pm860x_irq_domain_map_46553 pm860x_irq_domain_map 2 46553 NULL
108450 +link_send_sections_long_46556 link_send_sections_long 4 46556 NULL
108451 +dn_current_mss_46574 dn_current_mss 0 46574 NULL nohasharray
108452 +blk_flush_complete_seq_46574 blk_flush_complete_seq 2 46574 &dn_current_mss_46574
108453 +serverworks_create_gatt_pages_46582 serverworks_create_gatt_pages 1 46582 NULL
108454 +snd_compr_write_data_46592 snd_compr_write_data 3 46592 NULL
108455 +il3945_stats_flag_46606 il3945_stats_flag 0-3 46606 NULL
108456 +vscnprintf_46617 vscnprintf 0-2 46617 NULL
108457 +__kfifo_out_r_46623 __kfifo_out_r 3-0 46623 NULL
108458 +request_key_async_with_auxdata_46624 request_key_async_with_auxdata 4 46624 NULL
108459 +pci_enable_device_46642 pci_enable_device 0 46642 NULL
108460 +vfs_getxattr_alloc_46649 vfs_getxattr_alloc 0 46649 NULL
108461 +av7110_ipack_init_46655 av7110_ipack_init 2 46655 NULL
108462 +e1000_tx_map_46672 e1000_tx_map 4 46672 NULL
108463 +alloc_data_packet_46698 alloc_data_packet 1 46698 NULL
108464 +__ilog2_u32_46706 __ilog2_u32 0 46706 NULL
108465 +erst_dbg_write_46715 erst_dbg_write 3 46715 NULL
108466 +ide_read_status_46719 ide_read_status 0 46719 NULL
108467 +wl1271_rx_filter_alloc_field_46721 wl1271_rx_filter_alloc_field 5 46721 NULL
108468 +irq_domain_add_simple_46734 irq_domain_add_simple 2-3 46734 NULL
108469 +ext4_count_free_46754 ext4_count_free 2 46754 NULL nohasharray
108470 +pte_pfn_46754 pte_pfn 0 46754 &ext4_count_free_46754
108471 +ntfs2utc_46762 ntfs2utc 1 46762 NULL
108472 +hest_ghes_dev_register_46766 hest_ghes_dev_register 1 46766 NULL
108473 +int_hw_irq_en_46776 int_hw_irq_en 3 46776 NULL
108474 +regcache_lzo_sync_46777 regcache_lzo_sync 2 46777 NULL
108475 +_xfs_buf_get_pages_46811 _xfs_buf_get_pages 2 46811 NULL
108476 +btrfs_insert_empty_items_46822 btrfs_insert_empty_items 0 46822 NULL
108477 +xfs_iroot_realloc_46826 xfs_iroot_realloc 2 46826 NULL
108478 +shmem_pwrite_fast_46842 shmem_pwrite_fast 3 46842 NULL
108479 +readreg_46845 readreg 0 46845 NULL
108480 +spi_async_46857 spi_async 0 46857 NULL
108481 +vsnprintf_46863 vsnprintf 0 46863 NULL nohasharray
108482 +SyS_move_pages_46863 SyS_move_pages 2 46863 &vsnprintf_46863
108483 +nvme_alloc_queue_46865 nvme_alloc_queue 3 46865 NULL
108484 +rvmalloc_46873 rvmalloc 1 46873 NULL
108485 +qp_memcpy_from_queue_iov_46874 qp_memcpy_from_queue_iov 5-4 46874 NULL
108486 +lov_iocontrol_46876 lov_iocontrol 3 46876 NULL
108487 +stmpe_gpio_irq_unmap_46884 stmpe_gpio_irq_unmap 2 46884 NULL
108488 +ixgbe_dbg_reg_ops_write_46895 ixgbe_dbg_reg_ops_write 3 46895 NULL
108489 +sk_mem_pages_46896 sk_mem_pages 0-1 46896 NULL
108490 +ol_dqblk_off_46904 ol_dqblk_off 2-3 46904 NULL
108491 +ieee80211_if_fmt_power_mode_46906 ieee80211_if_fmt_power_mode 3 46906 NULL
108492 +wlcore_alloc_hw_46917 wlcore_alloc_hw 1-3 46917 NULL
108493 +fb_write_46924 fb_write 3 46924 NULL
108494 +i915_gem_check_olr_46925 i915_gem_check_olr 0 46925 NULL
108495 +kvm_register_read_46948 kvm_register_read 0 46948 NULL
108496 +__sctp_setsockopt_connectx_46949 __sctp_setsockopt_connectx 3 46949 NULL
108497 +qla4xxx_post_aen_work_46953 qla4xxx_post_aen_work 3 46953 NULL
108498 +SYSC_poll_46965 SYSC_poll 2 46965 NULL
108499 +crypto_tfm_alg_alignmask_46971 crypto_tfm_alg_alignmask 0 46971 NULL
108500 +mgmt_pending_add_46976 mgmt_pending_add 5 46976 NULL
108501 +strlcat_46985 strlcat 3 46985 NULL
108502 +bitmap_file_clear_bit_46990 bitmap_file_clear_bit 2 46990 NULL
108503 +gfs2_xattr_system_set_46996 gfs2_xattr_system_set 4 46996 NULL nohasharray
108504 +sel_write_bool_46996 sel_write_bool 3 46996 &gfs2_xattr_system_set_46996
108505 +ttm_bo_io_47000 ttm_bo_io 5 47000 NULL
108506 +blk_rq_map_kern_47004 blk_rq_map_kern 4 47004 NULL
108507 +__map_single_47020 __map_single 3-4-7-0 47020 NULL
108508 +cx231xx_init_bulk_47024 cx231xx_init_bulk 3-2-4 47024 NULL
108509 +fs_path_len_47060 fs_path_len 0 47060 NULL
108510 +ufs_new_fragments_47070 ufs_new_fragments 4-3-5 47070 NULL nohasharray
108511 +ext4_xattr_list_entries_47070 ext4_xattr_list_entries 0-4 47070 &ufs_new_fragments_47070
108512 +pipeline_dec_packet_in_read_47076 pipeline_dec_packet_in_read 3 47076 NULL
108513 +scsi_deactivate_tcq_47086 scsi_deactivate_tcq 2 47086 NULL
108514 +iwl_dump_nic_event_log_47089 iwl_dump_nic_event_log 0 47089 NULL
108515 +ptlrpc_lprocfs_threads_max_seq_write_47104 ptlrpc_lprocfs_threads_max_seq_write 3 47104 NULL
108516 +tboot_log_read_47110 tboot_log_read 3 47110 NULL
108517 +mousedev_read_47123 mousedev_read 3 47123 NULL
108518 +ubi_compare_lebs_47141 ubi_compare_lebs 0 47141 NULL
108519 +ses_recv_diag_47143 ses_recv_diag 4 47143 NULL nohasharray
108520 +acpi_ut_initialize_buffer_47143 acpi_ut_initialize_buffer 2 47143 &ses_recv_diag_47143
108521 +mxms_headerlen_47161 mxms_headerlen 0 47161 NULL
108522 +rs_sta_dbgfs_rate_scale_data_read_47165 rs_sta_dbgfs_rate_scale_data_read 3 47165 NULL
108523 +alloc_cpumask_var_node_47167 alloc_cpumask_var_node 3 47167 NULL
108524 +bpf_alloc_binary_47170 bpf_alloc_binary 1 47170 NULL
108525 +rts51x_ms_rw_47171 rts51x_ms_rw 3-4 47171 NULL
108526 +btrfs_del_inode_ref_47181 btrfs_del_inode_ref 0 47181 NULL
108527 +can_set_system_xattr_47182 can_set_system_xattr 4 47182 NULL
108528 +options_write_47243 options_write 3 47243 NULL
108529 +portcntrs_1_read_47253 portcntrs_1_read 3 47253 NULL
108530 +da9052_disable_irq_nosync_47260 da9052_disable_irq_nosync 2 47260 NULL
108531 +p9pdu_readf_47269 p9pdu_readf 0 47269 NULL
108532 +ablkcipher_next_slow_47274 ablkcipher_next_slow 3-4 47274 NULL
108533 +gfs2_readpages_47285 gfs2_readpages 4 47285 NULL
108534 +vsnprintf_47291 vsnprintf 0 47291 NULL
108535 +tx_internal_desc_overflow_read_47300 tx_internal_desc_overflow_read 3 47300 NULL
108536 +iterate_inode_ref_47322 iterate_inode_ref 0 47322 NULL
108537 +SyS_madvise_47354 SyS_madvise 1-2 47354 NULL
108538 +ieee80211_if_read_dot11MeshHoldingTimeout_47356 ieee80211_if_read_dot11MeshHoldingTimeout 3 47356 NULL
108539 +avc_get_hash_stats_47359 avc_get_hash_stats 0 47359 NULL
108540 +find_first_zero_bit_le_47369 find_first_zero_bit_le 2 47369 NULL
108541 +__bio_map_kern_47379 __bio_map_kern 3 47379 NULL
108542 +nv_rd32_47390 nv_rd32 0 47390 NULL nohasharray
108543 +trace_options_core_read_47390 trace_options_core_read 3 47390 &nv_rd32_47390
108544 +nametbl_list_47391 nametbl_list 2 47391 NULL
108545 +dgrp_net_write_47392 dgrp_net_write 3 47392 NULL
108546 +pfkey_sendmsg_47394 pfkey_sendmsg 4 47394 NULL
108547 +gfn_to_pfn_prot_47398 gfn_to_pfn_prot 2 47398 NULL
108548 +lbs_wrmac_write_47400 lbs_wrmac_write 3 47400 NULL
108549 +ocfs2_resv_end_47408 ocfs2_resv_end 0 47408 NULL
108550 +sta_vht_capa_read_47409 sta_vht_capa_read 3 47409 NULL
108551 +crypto_ablkcipher_alignmask_47410 crypto_ablkcipher_alignmask 0 47410 NULL
108552 +lbs_wrrf_write_47418 lbs_wrrf_write 3 47418 NULL
108553 +vzalloc_47421 vzalloc 1 47421 NULL
108554 +hash_ipportip4_expire_47426 hash_ipportip4_expire 3 47426 NULL
108555 +posix_acl_from_disk_47445 posix_acl_from_disk 2 47445 NULL
108556 +numaq_apicid_to_cpu_present_47449 numaq_apicid_to_cpu_present 1 47449 NULL
108557 +environ_read_47451 environ_read 3 47451 NULL
108558 +__load_mapping_47460 __load_mapping 2 47460 NULL
108559 +try_lock_extent_47465 try_lock_extent 0 47465 NULL
108560 +nvme_trans_send_fw_cmd_47479 nvme_trans_send_fw_cmd 4 47479 NULL
108561 +wb_force_mapping_47485 wb_force_mapping 2 47485 NULL nohasharray
108562 +newpart_47485 newpart 6-4 47485 &wb_force_mapping_47485
108563 +mcp23s17_read_regs_47491 mcp23s17_read_regs 4 47491 NULL
108564 +core_sys_select_47494 core_sys_select 1 47494 NULL
108565 +read_block_for_search_47502 read_block_for_search 0 47502 NULL
108566 +alloc_arraycache_47505 alloc_arraycache 2-1 47505 NULL nohasharray
108567 +btrfs_init_inode_security_47505 btrfs_init_inode_security 0 47505 &alloc_arraycache_47505
108568 +unlink_simple_47506 unlink_simple 3 47506 NULL
108569 +pstore_decompress_47510 pstore_decompress 0 47510 NULL
108570 +ufs_inode_getblock_47512 ufs_inode_getblock 4 47512 NULL
108571 +__proc_lnet_portal_rotor_47529 __proc_lnet_portal_rotor 5 47529 NULL
108572 +snd_pcm_resume_47530 snd_pcm_resume 0 47530 NULL
108573 +vscnprintf_47533 vscnprintf 0-2 47533 NULL nohasharray
108574 +process_vm_rw_47533 process_vm_rw 3-5 47533 &vscnprintf_47533
108575 +einj_check_trigger_header_47534 einj_check_trigger_header 0 47534 NULL
108576 +ieee80211_if_fmt_min_discovery_timeout_47539 ieee80211_if_fmt_min_discovery_timeout 3 47539 NULL
108577 +ocfs2_resv_find_window_47557 ocfs2_resv_find_window 3 47557 NULL
108578 +read_ldt_47570 read_ldt 2 47570 NULL
108579 +isku_sysfs_read_last_set_47572 isku_sysfs_read_last_set 6 47572 NULL
108580 +rpipe_get_idx_47579 rpipe_get_idx 2-0 47579 NULL
108581 +SYSC_fcntl64_47581 SYSC_fcntl64 3 47581 NULL
108582 +vendorextnReadSection_47583 vendorextnReadSection 0 47583 NULL
108583 +btrfs_stack_header_bytenr_47589 btrfs_stack_header_bytenr 0 47589 NULL
108584 +ext4_kvzalloc_47605 ext4_kvzalloc 1 47605 NULL
108585 +sctp_ssnmap_new_47608 sctp_ssnmap_new 2-1 47608 NULL
108586 +cache_read_pipefs_47615 cache_read_pipefs 3 47615 NULL
108587 +twl4030_clear_set_47624 twl4030_clear_set 4 47624 NULL
108588 +irq_set_chip_47638 irq_set_chip 1 47638 NULL
108589 +get_size_47644 get_size 1-2 47644 NULL
108590 +snd_pcm_info_47699 snd_pcm_info 0 47699 NULL
108591 +packet_recvmsg_47700 packet_recvmsg 4 47700 NULL nohasharray
108592 +ipath_format_hwmsg_47700 ipath_format_hwmsg 2 47700 &packet_recvmsg_47700
108593 +global_rt_runtime_47712 global_rt_runtime 0 47712 NULL
108594 +save_microcode_47717 save_microcode 3 47717 NULL
108595 +bits_to_user_47733 bits_to_user 3-2 47733 NULL
108596 +carl9170_debugfs_read_47738 carl9170_debugfs_read 3 47738 NULL
108597 +ir_prepare_write_buffer_47747 ir_prepare_write_buffer 3 47747 NULL
108598 +mvumi_alloc_mem_resource_47750 mvumi_alloc_mem_resource 3 47750 NULL
108599 +ext3_find_near_47752 ext3_find_near 0 47752 NULL
108600 +alloc_sched_domains_47756 alloc_sched_domains 1 47756 NULL
108601 +uwb_ie_dump_hex_47774 uwb_ie_dump_hex 4 47774 NULL
108602 +SyS_setgroups16_47780 SyS_setgroups16 1 47780 NULL
108603 +error_error_numll_frame_cts_start_read_47781 error_error_numll_frame_cts_start_read 3 47781 NULL
108604 +posix_acl_fix_xattr_from_user_47793 posix_acl_fix_xattr_from_user 2 47793 NULL
108605 +W6692_empty_Bfifo_47804 W6692_empty_Bfifo 2 47804 NULL
108606 +lov_packmd_47810 lov_packmd 0 47810 NULL
108607 +pinconf_dbg_config_write_47835 pinconf_dbg_config_write 3 47835 NULL
108608 +KEY_SIZE_47855 KEY_SIZE 0 47855 NULL
108609 +ubifs_unpack_nnode_47866 ubifs_unpack_nnode 0 47866 NULL
108610 +vhci_read_47878 vhci_read 3 47878 NULL
108611 +ubi_wl_put_peb_47886 ubi_wl_put_peb 0 47886 NULL
108612 +keyctl_instantiate_key_common_47889 keyctl_instantiate_key_common 4 47889 NULL
108613 +load_mapping_47904 load_mapping 3 47904 NULL
108614 +btrfs_duplicate_item_47910 btrfs_duplicate_item 0 47910 NULL
108615 +cfs_percpt_alloc_47918 cfs_percpt_alloc 2 47918 NULL
108616 +comedi_write_47926 comedi_write 3 47926 NULL
108617 +nvme_trans_get_blk_desc_len_47946 nvme_trans_get_blk_desc_len 0-2 47946 NULL
108618 +lp8788_irq_map_47964 lp8788_irq_map 2 47964 NULL
108619 +gether_get_ifname_47972 gether_get_ifname 3 47972 NULL
108620 +iwl_dbgfs_ucode_tracing_read_47983 iwl_dbgfs_ucode_tracing_read 3 47983 NULL nohasharray
108621 +mempool_resize_47983 mempool_resize 2 47983 &iwl_dbgfs_ucode_tracing_read_47983
108622 +dbg_port_buf_47990 dbg_port_buf 2 47990 NULL
108623 +ib_umad_write_47993 ib_umad_write 3 47993 NULL
108624 +ocfs2_find_refcount_split_pos_48001 ocfs2_find_refcount_split_pos 0 48001 NULL
108625 +lustre_cfg_len_48002 lustre_cfg_len 0 48002 NULL
108626 +gdm_tty_recv_complete_48011 gdm_tty_recv_complete 2 48011 NULL
108627 +ffs_epfile_write_48014 ffs_epfile_write 3 48014 NULL
108628 +bio_integrity_set_tag_48035 bio_integrity_set_tag 3 48035 NULL
108629 +pppoe_sendmsg_48039 pppoe_sendmsg 4 48039 NULL
108630 +SYSC_writev_48040 SYSC_writev 3 48040 NULL
108631 +btrfs_reserve_extent_48044 btrfs_reserve_extent 6 48044 NULL
108632 +wpan_phy_alloc_48056 wpan_phy_alloc 1 48056 NULL
108633 +ocfs2_change_refcount_rec_48059 ocfs2_change_refcount_rec 0 48059 NULL
108634 +posix_acl_alloc_48063 posix_acl_alloc 1 48063 NULL
108635 +palmas_bulk_write_48068 palmas_bulk_write 2-3-5 48068 NULL
108636 +disc_write_48070 disc_write 3 48070 NULL
108637 +mmc_alloc_host_48097 mmc_alloc_host 1 48097 NULL
108638 +skb_copy_datagram_const_iovec_48102 skb_copy_datagram_const_iovec 4-2-5-0 48102 NULL
108639 +radio_isa_common_probe_48107 radio_isa_common_probe 3 48107 NULL
108640 +vmw_framebuffer_surface_dirty_48132 vmw_framebuffer_surface_dirty 6 48132 NULL
108641 +set_discoverable_48141 set_discoverable 4 48141 NULL
108642 +dn_fib_count_nhs_48145 dn_fib_count_nhs 0 48145 NULL
108643 +get_cur_inode_state_48149 get_cur_inode_state 0 48149 NULL
108644 +_add_to_r4w_48152 _add_to_r4w 4 48152 NULL nohasharray
108645 +bitmap_onto_48152 bitmap_onto 4 48152 &_add_to_r4w_48152
108646 +isr_dma1_done_read_48159 isr_dma1_done_read 3 48159 NULL
108647 +c4iw_id_table_alloc_48163 c4iw_id_table_alloc 3 48163 NULL
108648 +ocfs2_find_next_zero_bit_unaligned_48170 ocfs2_find_next_zero_bit_unaligned 2-3 48170 NULL nohasharray
108649 +rbd_obj_method_sync_48170 rbd_obj_method_sync 8 48170 &ocfs2_find_next_zero_bit_unaligned_48170
108650 +alloc_cc770dev_48186 alloc_cc770dev 1 48186 NULL
108651 +init_ipath_48187 init_ipath 1 48187 NULL
108652 +brcmf_sdio_chip_cm3_exitdl_48192 brcmf_sdio_chip_cm3_exitdl 4 48192 NULL
108653 +cfg80211_process_deauth_48200 cfg80211_process_deauth 3 48200 NULL
108654 +ext4_index_trans_blocks_48205 ext4_index_trans_blocks 0-2 48205 NULL
108655 +snd_seq_dump_var_event_48209 snd_seq_dump_var_event 0 48209 NULL
108656 +ll_direct_IO_26_48216 ll_direct_IO_26 4 48216 NULL
108657 +is_block_in_journal_48223 is_block_in_journal 3 48223 NULL
108658 +uv_blade_nr_possible_cpus_48226 uv_blade_nr_possible_cpus 0 48226 NULL
108659 +nilfs_readpages_48229 nilfs_readpages 4 48229 NULL
108660 +read_file_recv_48232 read_file_recv 3 48232 NULL
108661 +unaccount_shadowed_48233 unaccount_shadowed 2 48233 NULL nohasharray
108662 +blk_rq_pos_48233 blk_rq_pos 0 48233 &unaccount_shadowed_48233
108663 +nouveau_i2c_port_create__48240 nouveau_i2c_port_create_ 7 48240 NULL
108664 +nfsctl_transaction_read_48250 nfsctl_transaction_read 3 48250 NULL
108665 +batadv_socket_read_48257 batadv_socket_read 3 48257 NULL
108666 +cache_write_pipefs_48270 cache_write_pipefs 3 48270 NULL
108667 +trace_options_write_48275 trace_options_write 3 48275 NULL
108668 +send_set_info_48288 send_set_info 7 48288 NULL
108669 +lpfc_idiag_extacc_read_48301 lpfc_idiag_extacc_read 3 48301 NULL
108670 +timblogiw_read_48305 timblogiw_read 3 48305 NULL
108671 +hash_setkey_48310 hash_setkey 3 48310 NULL
108672 +audio_set_intf_req_48319 audio_set_intf_req 0 48319 NULL
108673 +kvm_mmu_pte_write_48340 kvm_mmu_pte_write 2 48340 NULL
108674 +__alloc_fd_48356 __alloc_fd 2 48356 NULL
108675 +skb_add_data_48363 skb_add_data 3 48363 NULL
108676 +tx_frag_init_called_read_48377 tx_frag_init_called_read 3 48377 NULL
108677 +lbs_debugfs_write_48413 lbs_debugfs_write 3 48413 NULL
108678 +uhid_event_from_user_48417 uhid_event_from_user 2 48417 NULL
108679 +div64_u64_rem_48418 div64_u64_rem 0-1-2 48418 NULL
108680 +snd_power_wait_48422 snd_power_wait 0 48422 NULL
108681 +pwr_tx_without_ps_read_48423 pwr_tx_without_ps_read 3 48423 NULL
108682 +hugepage_madvise_48435 hugepage_madvise 0 48435 NULL
108683 +print_filtered_48442 print_filtered 2-0 48442 NULL
108684 +tun_recvmsg_48463 tun_recvmsg 4 48463 NULL
108685 +compat_SyS_preadv64_48469 compat_SyS_preadv64 3 48469 NULL
108686 +ipath_format_hwerrors_48487 ipath_format_hwerrors 5 48487 NULL
108687 +init_section_page_cgroup_48489 init_section_page_cgroup 2 48489 NULL nohasharray
108688 +r8712_usbctrl_vendorreq_48489 r8712_usbctrl_vendorreq 6 48489 &init_section_page_cgroup_48489
108689 +ocfs2_refcount_cow_48495 ocfs2_refcount_cow 3 48495 NULL
108690 +send_control_msg_48498 send_control_msg 6 48498 NULL
108691 +mlx4_en_create_tx_ring_48501 mlx4_en_create_tx_ring 4 48501 NULL
108692 +count_masked_bytes_48507 count_masked_bytes 0-1 48507 NULL
108693 +diva_os_copy_to_user_48508 diva_os_copy_to_user 4 48508 NULL
108694 +brcmf_sdio_trap_info_48510 brcmf_sdio_trap_info 4 48510 NULL
108695 +phantom_get_free_48514 phantom_get_free 0 48514 NULL
108696 +drbd_bm_capacity_48530 drbd_bm_capacity 0 48530 NULL
108697 +ext3_splice_branch_48531 ext3_splice_branch 6 48531 NULL
108698 +raid10_size_48571 raid10_size 0-2-3 48571 NULL
108699 +llog_data_len_48607 llog_data_len 1 48607 NULL
108700 +ufs_dtogd_48616 ufs_dtogd 0-2 48616 NULL
108701 +do_ip_vs_set_ctl_48641 do_ip_vs_set_ctl 4 48641 NULL
108702 +ll_rw_extents_stats_pp_seq_write_48651 ll_rw_extents_stats_pp_seq_write 3 48651 NULL
108703 +mtd_read_48655 mtd_read 0 48655 NULL
108704 +aes_encrypt_packets_read_48666 aes_encrypt_packets_read 3 48666 NULL
108705 +ore_get_rw_state_48667 ore_get_rw_state 5-4 48667 NULL
108706 +sm501_create_subdev_48668 sm501_create_subdev 4-3 48668 NULL
108707 +ubi_eba_unmap_leb_48671 ubi_eba_unmap_leb 0 48671 NULL
108708 +hysdn_log_write_48694 hysdn_log_write 3 48694 NULL
108709 +altera_drscan_48698 altera_drscan 2 48698 NULL
108710 +kvm_set_irq_routing_48704 kvm_set_irq_routing 3 48704 NULL
108711 +recv_msg_48709 recv_msg 4 48709 NULL
108712 +lpfc_idiag_drbacc_write_48712 lpfc_idiag_drbacc_write 3 48712 NULL
108713 +SyS_lgetxattr_48719 SyS_lgetxattr 4 48719 NULL
108714 +ath6kl_usb_bmi_read_48745 ath6kl_usb_bmi_read 3 48745 NULL
108715 +ath6kl_regwrite_read_48747 ath6kl_regwrite_read 3 48747 NULL
108716 +event_buffer_read_48772 event_buffer_read 3 48772 NULL nohasharray
108717 +l2cap_segment_sdu_48772 l2cap_segment_sdu 4 48772 &event_buffer_read_48772
108718 +gfs2_direct_IO_48774 gfs2_direct_IO 4 48774 NULL
108719 +il3945_sta_dbgfs_stats_table_read_48802 il3945_sta_dbgfs_stats_table_read 3 48802 NULL
108720 +twa_change_queue_depth_48808 twa_change_queue_depth 2 48808 NULL
108721 +register_ftrace_profiler_48816 register_ftrace_profiler 0 48816 NULL
108722 +atomic_counters_read_48827 atomic_counters_read 3 48827 NULL
108723 +azx_get_position_48841 azx_get_position 0 48841 NULL
108724 +vc_do_resize_48842 vc_do_resize 4-3 48842 NULL
108725 +comedi_buf_write_alloc_48846 comedi_buf_write_alloc 0-2 48846 NULL
108726 +suspend_dtim_interval_write_48854 suspend_dtim_interval_write 3 48854 NULL
108727 +C_SYSC_pwritev64_48864 C_SYSC_pwritev64 3 48864 NULL nohasharray
108728 +viafb_dvp1_proc_write_48864 viafb_dvp1_proc_write 3 48864 &C_SYSC_pwritev64_48864
108729 +ide_port_alloc_devices_48866 ide_port_alloc_devices 2 48866 NULL
108730 +__ffs_ep0_read_events_48868 __ffs_ep0_read_events 3 48868 NULL
108731 +ext2_alloc_branch_48889 ext2_alloc_branch 4 48889 NULL
108732 +crypto_cipher_ctxsize_48890 crypto_cipher_ctxsize 0 48890 NULL
108733 +joydev_handle_JSIOCSAXMAP_48898 joydev_handle_JSIOCSAXMAP 3 48898 NULL
108734 +xdi_copy_to_user_48900 xdi_copy_to_user 4 48900 NULL
108735 +msg_hdr_sz_48908 msg_hdr_sz 0 48908 NULL
108736 +snd_pcm_update_hw_ptr_48925 snd_pcm_update_hw_ptr 0 48925 NULL
108737 +sep_crypto_dma_48937 sep_crypto_dma 0 48937 NULL
108738 +si5351_write_parameters_48940 si5351_write_parameters 2 48940 NULL
108739 +event_heart_beat_read_48961 event_heart_beat_read 3 48961 NULL
108740 +nand_ecc_test_run_48966 nand_ecc_test_run 1 48966 NULL
108741 +vmci_handle_arr_create_48971 vmci_handle_arr_create 1 48971 NULL
108742 +batadv_orig_hash_del_if_48972 batadv_orig_hash_del_if 2 48972 NULL
108743 +btrfs_delete_delayed_insertion_item_48981 btrfs_delete_delayed_insertion_item 0 48981 NULL
108744 +rds_rm_size_48996 rds_rm_size 0-2 48996 NULL
108745 +sel_write_enforce_48998 sel_write_enforce 3 48998 NULL
108746 +null_alloc_rs_49019 null_alloc_rs 2 49019 NULL
108747 +filemap_check_errors_49022 filemap_check_errors 0 49022 NULL
108748 +aic_inb_49023 aic_inb 0 49023 NULL
108749 +transient_status_49027 transient_status 4 49027 NULL
108750 +iwl_mvm_power_legacy_dbgfs_read_49038 iwl_mvm_power_legacy_dbgfs_read 4 49038 NULL nohasharray
108751 +ipath_reg_user_mr_49038 ipath_reg_user_mr 2-3 49038 &iwl_mvm_power_legacy_dbgfs_read_49038
108752 +aic7xxx_rem_scb_from_disc_list_49041 aic7xxx_rem_scb_from_disc_list 0 49041 NULL
108753 +setup_msi_irq_49052 setup_msi_irq 3-4 49052 NULL
108754 +ubi_read_49061 ubi_read 0 49061 NULL
108755 +scsi_register_49094 scsi_register 2 49094 NULL
108756 +paging64_walk_addr_nested_49100 paging64_walk_addr_nested 3 49100 NULL
108757 +compat_do_readv_writev_49102 compat_do_readv_writev 4 49102 NULL
108758 +xfrm_replay_state_esn_len_49119 xfrm_replay_state_esn_len 0 49119 NULL
108759 +ll_max_cached_mb_seq_write_49122 ll_max_cached_mb_seq_write 3 49122 NULL
108760 +qib_user_sdma_pin_pages_49136 qib_user_sdma_pin_pages 4-5-6 49136 NULL nohasharray
108761 +pt_read_49136 pt_read 3 49136 &qib_user_sdma_pin_pages_49136
108762 +read_file_49137 read_file 4 49137 NULL
108763 +ipwireless_tty_received_49154 ipwireless_tty_received 3 49154 NULL
108764 +f2fs_acl_count_49155 f2fs_acl_count 0-1 49155 NULL
108765 +ipw_queue_tx_init_49161 ipw_queue_tx_init 3 49161 NULL
108766 +ext4_free_clusters_after_init_49174 ext4_free_clusters_after_init 2 49174 NULL
108767 +__jfs_setxattr_49175 __jfs_setxattr 5 49175 NULL
108768 +ath6kl_bgscan_int_write_49178 ath6kl_bgscan_int_write 3 49178 NULL
108769 +dvb_dvr_ioctl_49182 dvb_dvr_ioctl 2 49182 NULL
108770 +print_queue_49191 print_queue 0 49191 NULL
108771 +root_nfs_cat_49192 root_nfs_cat 3 49192 NULL
108772 +iwl_dbgfs_ucode_general_stats_read_49199 iwl_dbgfs_ucode_general_stats_read 3 49199 NULL
108773 +il4965_rs_sta_dbgfs_stats_table_read_49206 il4965_rs_sta_dbgfs_stats_table_read 3 49206 NULL
108774 +do_jffs2_getxattr_49210 do_jffs2_getxattr 0 49210 NULL
108775 +resp_write_same_49217 resp_write_same 2 49217 NULL
108776 +nouveau_therm_create__49228 nouveau_therm_create_ 4 49228 NULL
108777 +hugetlb_cgroup_read_49259 hugetlb_cgroup_read 5 49259 NULL
108778 +ieee80211_if_read_rssi_threshold_49260 ieee80211_if_read_rssi_threshold 3 49260 NULL
108779 +isku_sysfs_read_keys_media_49268 isku_sysfs_read_keys_media 6 49268 NULL
108780 +ptlrpc_check_set_49277 ptlrpc_check_set 0 49277 NULL
108781 +rx_filter_beacon_filter_read_49279 rx_filter_beacon_filter_read 3 49279 NULL
108782 +__ext4_ext_dirty_49284 __ext4_ext_dirty 0 49284 NULL
108783 +ext4_xattr_ibody_list_49287 ext4_xattr_ibody_list 3-0 49287 NULL
108784 +viafb_dfph_proc_write_49288 viafb_dfph_proc_write 3 49288 NULL
108785 +uio_read_49300 uio_read 3 49300 NULL
108786 +ocfs2_resmap_find_free_bits_49301 ocfs2_resmap_find_free_bits 3 49301 NULL
108787 +isku_sysfs_read_keys_macro_49312 isku_sysfs_read_keys_macro 6 49312 NULL
108788 +update_ref_for_cow_49313 update_ref_for_cow 0 49313 NULL
108789 +SYSC_mincore_49319 SYSC_mincore 2-1 49319 NULL
108790 +fwtty_port_handler_49327 fwtty_port_handler 9 49327 NULL
108791 +srpt_alloc_ioctx_ring_49330 srpt_alloc_ioctx_ring 2-4-3 49330 NULL
108792 +__intel_map_single_49338 __intel_map_single 3-2 49338 NULL
108793 +intel_ring_invalidate_all_caches_49346 intel_ring_invalidate_all_caches 0 49346 NULL
108794 +joydev_ioctl_common_49359 joydev_ioctl_common 2 49359 NULL
108795 +ocfs2_remove_btree_range_49370 ocfs2_remove_btree_range 4-3-5 49370 NULL
108796 +iscsi_alloc_session_49390 iscsi_alloc_session 3 49390 NULL
108797 +ext4_ext_index_trans_blocks_49396 ext4_ext_index_trans_blocks 0 49396 NULL
108798 +rx_streaming_always_read_49401 rx_streaming_always_read 3 49401 NULL
108799 +tnode_alloc_49407 tnode_alloc 1 49407 NULL
108800 +samples_to_bytes_49426 samples_to_bytes 0-2 49426 NULL
108801 +ubi_add_to_av_49432 ubi_add_to_av 0 49432 NULL nohasharray
108802 +md_domain_init_49432 md_domain_init 2 49432 &ubi_add_to_av_49432
108803 +compat_do_msg_fill_49440 compat_do_msg_fill 3 49440 NULL
108804 +get_lru_size_49441 get_lru_size 0 49441 NULL
108805 +i915_gem_object_set_to_gtt_domain_49450 i915_gem_object_set_to_gtt_domain 0 49450 NULL
108806 +ocfs2_merge_rec_left_49455 ocfs2_merge_rec_left 0 49455 NULL
108807 +__hfsplus_getxattr_49460 __hfsplus_getxattr 0 49460 NULL
108808 +agp_3_5_isochronous_node_enable_49465 agp_3_5_isochronous_node_enable 3 49465 NULL
108809 +xfs_iformat_local_49472 xfs_iformat_local 4 49472 NULL
108810 +savu_sysfs_read_49473 savu_sysfs_read 6 49473 NULL
108811 +isr_decrypt_done_read_49490 isr_decrypt_done_read 3 49490 NULL
108812 +SyS_listxattr_49519 SyS_listxattr 3 49519 NULL
108813 +emulator_write_phys_49520 emulator_write_phys 2-4 49520 NULL
108814 +btrfs_add_free_space_49524 btrfs_add_free_space 0 49524 NULL
108815 +smk_write_access_49561 smk_write_access 3 49561 NULL
108816 +ntfs_malloc_nofs_49572 ntfs_malloc_nofs 1 49572 NULL
108817 +alloc_chunk_49575 alloc_chunk 1 49575 NULL
108818 +sctp_setsockopt_default_send_param_49578 sctp_setsockopt_default_send_param 3 49578 NULL
108819 +readfifo_49583 readfifo 1 49583 NULL
108820 +tap_write_49595 tap_write 3 49595 NULL
108821 +create_task_io_context_49601 create_task_io_context 3 49601 NULL
108822 +isr_wakeups_read_49607 isr_wakeups_read 3 49607 NULL
108823 +btrfs_mksubvol_49616 btrfs_mksubvol 3 49616 NULL
108824 +heap_init_49617 heap_init 2 49617 NULL
108825 +smk_write_doi_49621 smk_write_doi 3 49621 NULL
108826 +port_fops_read_49626 port_fops_read 3 49626 NULL
108827 +btrfsic_cmp_log_and_dev_bytenr_49628 btrfsic_cmp_log_and_dev_bytenr 2 49628 NULL
108828 +__swab32p_49657 __swab32p 0 49657 NULL
108829 +ubi_wl_flush_49682 ubi_wl_flush 0 49682 NULL
108830 +aa_simple_write_to_buffer_49683 aa_simple_write_to_buffer 3-4 49683 NULL
108831 +SyS_pwritev_49688 SyS_pwritev 3 49688 NULL
108832 +__setup_irq_49696 __setup_irq 0 49696 NULL
108833 +cx2341x_ctrl_new_menu_49700 cx2341x_ctrl_new_menu 3 49700 NULL
108834 +do_splice_to_49714 do_splice_to 4 49714 NULL
108835 +write_pool_49718 write_pool 3 49718 NULL
108836 +dm_thin_insert_block_49720 dm_thin_insert_block 2-3 49720 NULL
108837 +kvm_mmu_notifier_invalidate_page_49723 kvm_mmu_notifier_invalidate_page 3 49723 NULL
108838 +sep_create_dcb_dmatables_context_kernel_49728 sep_create_dcb_dmatables_context_kernel 6 49728 NULL
108839 +zd_usb_iowrite16v_49744 zd_usb_iowrite16v 3 49744 NULL
108840 +btrfs_chunk_num_stripes_49751 btrfs_chunk_num_stripes 0 49751 NULL
108841 +fuse_wr_pages_49753 fuse_wr_pages 0-1-2 49753 NULL
108842 +key_conf_keylen_read_49758 key_conf_keylen_read 3 49758 NULL
108843 +fuse_conn_waiting_read_49762 fuse_conn_waiting_read 3 49762 NULL
108844 +w83977af_fir_interrupt_49775 w83977af_fir_interrupt 0 49775 NULL
108845 +ceph_osdc_readpages_49789 ceph_osdc_readpages 0 49789 NULL
108846 +nfs4_acl_new_49806 nfs4_acl_new 1 49806 NULL
108847 +ntfs_copy_from_user_iovec_49829 ntfs_copy_from_user_iovec 3-6-0 49829 NULL
108848 +add_uuid_49831 add_uuid 4 49831 NULL
108849 +ath6kl_fwlog_block_read_49836 ath6kl_fwlog_block_read 3 49836 NULL
108850 +iraw_loop_49842 iraw_loop 0-1 49842 NULL
108851 +twl4030_write_49846 twl4030_write 2 49846 NULL
108852 +scsi_dispatch_cmd_entry_49848 scsi_dispatch_cmd_entry 3 49848 NULL
108853 +timeradd_entry_49850 timeradd_entry 3 49850 NULL
108854 +ubifs_destroy_tnc_subtree_49853 ubifs_destroy_tnc_subtree 0 49853 NULL
108855 +btrfs_subvolume_reserve_metadata_49859 btrfs_subvolume_reserve_metadata 3 49859 NULL
108856 +fiemap_count_to_size_49869 fiemap_count_to_size 0-1 49869 NULL
108857 +sctp_setsockopt_bindx_49870 sctp_setsockopt_bindx 3 49870 NULL
108858 +snd_mask_eq_49889 snd_mask_eq 0 49889 NULL
108859 +ceph_get_caps_49890 ceph_get_caps 0 49890 NULL
108860 +osc_brw_49896 osc_brw 4 49896 NULL
108861 +__cow_file_range_49901 __cow_file_range 5 49901 NULL
108862 +__copy_from_user_inatomic_nocache_49921 __copy_from_user_inatomic_nocache 3 49921 NULL
108863 +config_ep_by_speed_49939 config_ep_by_speed 0 49939 NULL
108864 +batadv_tt_realloc_packet_buff_49960 batadv_tt_realloc_packet_buff 4 49960 NULL
108865 +ieee80211_if_fmt_dtim_count_49987 ieee80211_if_fmt_dtim_count 3 49987 NULL
108866 +drm_buffer_copy_from_user_49990 drm_buffer_copy_from_user 3 49990 NULL
108867 +sta2x11_swiotlb_alloc_coherent_49994 sta2x11_swiotlb_alloc_coherent 2 49994 NULL
108868 +l2cap_chan_send_49995 l2cap_chan_send 3 49995 NULL
108869 +__module_alloc_50004 __module_alloc 1 50004 NULL
108870 +dn_mss_from_pmtu_50011 dn_mss_from_pmtu 0-2 50011 NULL
108871 +ptrace_readdata_50020 ptrace_readdata 2-4 50020 NULL
108872 +isdn_read_50021 isdn_read 3 50021 NULL
108873 +mdc_rename_pack_50023 mdc_rename_pack 4-6 50023 NULL
108874 +qp_alloc_queue_50028 qp_alloc_queue 1 50028 NULL
108875 +ioread8_50049 ioread8 0 50049 NULL
108876 +fuse_conn_max_background_write_50061 fuse_conn_max_background_write 3 50061 NULL
108877 +vmw_surface_destroy_size_50072 vmw_surface_destroy_size 0 50072 NULL
108878 +arch_setup_ht_irq_50073 arch_setup_ht_irq 1 50073 NULL
108879 +__kfifo_dma_in_prepare_50081 __kfifo_dma_in_prepare 4 50081 NULL
108880 +dev_set_alias_50084 dev_set_alias 3 50084 NULL
108881 +libcfs_ioctl_popdata_50087 libcfs_ioctl_popdata 3 50087 NULL
108882 +sock_setsockopt_50088 sock_setsockopt 5 50088 NULL
108883 +altera_swap_dr_50090 altera_swap_dr 2 50090 NULL
108884 +android_set_cntry_50100 android_set_cntry 0 50100 NULL
108885 +process_recorded_refs_50110 process_recorded_refs 0 50110 NULL
108886 +read_file_slot_50111 read_file_slot 3 50111 NULL
108887 +xfs_dir3_sf_entsize_50112 xfs_dir3_sf_entsize 0-3 50112 NULL
108888 +rx_streaming_interval_write_50120 rx_streaming_interval_write 3 50120 NULL
108889 +ocfs2_search_one_group_50125 ocfs2_search_one_group 0 50125 NULL nohasharray
108890 +jfs_direct_IO_50125 jfs_direct_IO 4 50125 &ocfs2_search_one_group_50125
108891 +SYSC_preadv_50134 SYSC_preadv 3 50134 NULL
108892 +copy_items_50140 copy_items 6 50140 NULL
108893 +tx_frag_need_fragmentation_read_50153 tx_frag_need_fragmentation_read 3 50153 NULL
108894 +reiserfs_bmap_count_50160 reiserfs_bmap_count 0 50160 NULL
108895 +kmalloc_node_50163 kmalloc_node 1-3 50163 NULL
108896 +rx_filter_ibss_filter_read_50167 rx_filter_ibss_filter_read 3 50167 NULL
108897 +ahd_probe_stack_size_50168 ahd_probe_stack_size 0 50168 NULL
108898 +odev_update_50169 odev_update 2 50169 NULL
108899 +ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172 ieee80211_if_fmt_dot11MeshHWMPRannInterval 3 50172 NULL nohasharray
108900 +xfs_get_blocks_direct_50172 xfs_get_blocks_direct 2 50172 &ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172 nohasharray
108901 +ubi_resize_volume_50172 ubi_resize_volume 2 50172 &xfs_get_blocks_direct_50172
108902 +ext3_do_update_inode_50178 ext3_do_update_inode 0 50178 NULL
108903 +cfg80211_roamed_bss_50198 cfg80211_roamed_bss 6-4 50198 NULL
108904 +cyttsp4_probe_50201 cyttsp4_probe 4 50201 NULL
108905 +rx_rx_timeout_wa_read_50204 rx_rx_timeout_wa_read 3 50204 NULL
108906 +compat_SyS_sendfile_50206 compat_SyS_sendfile 4 50206 NULL nohasharray
108907 +mthca_buddy_init_50206 mthca_buddy_init 2 50206 &compat_SyS_sendfile_50206
108908 +l2cap_sock_setsockopt_50207 l2cap_sock_setsockopt 5 50207 NULL
108909 +mon_bin_compat_ioctl_50234 mon_bin_compat_ioctl 3 50234 NULL
108910 +sg_kmalloc_50240 sg_kmalloc 1 50240 NULL
108911 +vma_dup_policy_50269 vma_dup_policy 0 50269 NULL
108912 +rxrpc_setsockopt_50286 rxrpc_setsockopt 5 50286 NULL
108913 +soc_codec_reg_show_50302 soc_codec_reg_show 0-3 50302 NULL
108914 +SYSC_flistxattr_50307 SYSC_flistxattr 3 50307 NULL
108915 +SYSC_sched_setaffinity_50310 SYSC_sched_setaffinity 2 50310 NULL
108916 +iterate_irefs_50313 iterate_irefs 0 50313 NULL
108917 +soc_camera_read_50319 soc_camera_read 3 50319 NULL
108918 +do_launder_page_50329 do_launder_page 0 50329 NULL
108919 +nouveau_engine_create__50331 nouveau_engine_create_ 7 50331 NULL
108920 +lpfc_idiag_pcicfg_read_50334 lpfc_idiag_pcicfg_read 3 50334 NULL
108921 +ocfs2_block_to_cluster_group_50337 ocfs2_block_to_cluster_group 2 50337 NULL nohasharray
108922 +snd_pcm_lib_writev_50337 snd_pcm_lib_writev 0-3 50337 &ocfs2_block_to_cluster_group_50337
108923 +tpm_read_50344 tpm_read 3 50344 NULL
108924 +sched_clock_remote_50347 sched_clock_remote 0 50347 NULL
108925 +efx_nic_update_stats_50352 efx_nic_update_stats 2 50352 NULL
108926 +kvm_arch_create_memslot_50354 kvm_arch_create_memslot 2 50354 NULL
108927 +isdn_ppp_read_50356 isdn_ppp_read 4 50356 NULL
108928 +ocfs2_figure_insert_type_50362 ocfs2_figure_insert_type 0 50362 NULL nohasharray
108929 +iwl_dbgfs_echo_test_write_50362 iwl_dbgfs_echo_test_write 3 50362 &ocfs2_figure_insert_type_50362
108930 +xfrm_send_migrate_50365 xfrm_send_migrate 5 50365 NULL
108931 +roccat_common2_receive_50369 roccat_common2_receive 4 50369 NULL
108932 +sl_alloc_bufs_50380 sl_alloc_bufs 2 50380 NULL
108933 +hash_ip6_expire_50390 hash_ip6_expire 3 50390 NULL
108934 +snd_mask_refine_last_50406 snd_mask_refine_last 0 50406 NULL
108935 +l2tp_ip_sendmsg_50411 l2tp_ip_sendmsg 4 50411 NULL
108936 +iscsi_create_conn_50425 iscsi_create_conn 2 50425 NULL
108937 +validate_acl_mac_addrs_50429 validate_acl_mac_addrs 0 50429 NULL
108938 +btrfs_error_discard_extent_50444 btrfs_error_discard_extent 2 50444 NULL nohasharray
108939 +ecryptfs_write_lower_page_segment_50444 ecryptfs_write_lower_page_segment 4 50444 &btrfs_error_discard_extent_50444
108940 +calc_csum_metadata_size_50448 calc_csum_metadata_size 0 50448 NULL
108941 +pgctrl_write_50453 pgctrl_write 3 50453 NULL
108942 +device_create_sys_dev_entry_50458 device_create_sys_dev_entry 0 50458 NULL
108943 +force_mapping_50464 force_mapping 2 50464 NULL
108944 +cfs_size_round_50472 cfs_size_round 0-1 50472 NULL
108945 +cdrom_read_cdda_50478 cdrom_read_cdda 4 50478 NULL
108946 +mei_io_cb_alloc_req_buf_50493 mei_io_cb_alloc_req_buf 2 50493 NULL
108947 +pwr_rcvd_awake_beacons_read_50505 pwr_rcvd_awake_beacons_read 3 50505 NULL
108948 +__ctzdi2_50536 __ctzdi2 1 50536 NULL
108949 +ath6kl_set_ap_probe_resp_ies_50539 ath6kl_set_ap_probe_resp_ies 3 50539 NULL
108950 +usbat_flash_write_data_50553 usbat_flash_write_data 4 50553 NULL
108951 +self_check_peb_vid_hdr_50563 self_check_peb_vid_hdr 0 50563 NULL nohasharray
108952 +ttm_agp_tt_create_50563 ttm_agp_tt_create 3 50563 &self_check_peb_vid_hdr_50563
108953 +fat_readpages_50582 fat_readpages 4 50582 NULL
108954 +iwl_dbgfs_missed_beacon_read_50584 iwl_dbgfs_missed_beacon_read 3 50584 NULL
108955 +build_inv_iommu_pages_50589 build_inv_iommu_pages 2-3 50589 NULL
108956 +xillybus_write_50605 xillybus_write 3 50605 NULL
108957 +rx_rx_checksum_result_read_50617 rx_rx_checksum_result_read 3 50617 NULL
108958 +ocfs2_split_extent_50618 ocfs2_split_extent 0 50618 NULL
108959 +sparse_early_usemaps_alloc_node_50623 sparse_early_usemaps_alloc_node 4 50623 NULL
108960 +__ffs_50625 __ffs 0-1 50625 NULL
108961 +regcache_rbtree_write_50629 regcache_rbtree_write 2 50629 NULL
108962 +simple_transaction_get_50633 simple_transaction_get 3 50633 NULL
108963 +ocfs2_do_insert_extent_50658 ocfs2_do_insert_extent 0 50658 NULL
108964 +ath6kl_tm_rx_event_50664 ath6kl_tm_rx_event 3 50664 NULL
108965 +bnad_debugfs_read_50665 bnad_debugfs_read 3 50665 NULL
108966 +ext2_try_to_allocate_with_rsv_50669 ext2_try_to_allocate_with_rsv 4-2-0 50669 NULL
108967 +prism2_read_fid_reg_50689 prism2_read_fid_reg 0 50689 NULL nohasharray
108968 +i2c_smbus_read_byte_data_50689 i2c_smbus_read_byte_data 0 50689 &prism2_read_fid_reg_50689
108969 +paging32_gva_to_gpa_50696 paging32_gva_to_gpa 2 50696 NULL
108970 +xfs_growfs_get_hdr_buf_50697 xfs_growfs_get_hdr_buf 3 50697 NULL
108971 +dev_mem_read_50706 dev_mem_read 3 50706 NULL
108972 +blk_check_plugged_50736 blk_check_plugged 3 50736 NULL
108973 +__ext3_get_inode_loc_50744 __ext3_get_inode_loc 0 50744 NULL
108974 +btrfs_truncate_free_space_cache_50769 btrfs_truncate_free_space_cache 0 50769 NULL
108975 +ocfs2_xattr_block_get_50773 ocfs2_xattr_block_get 0 50773 NULL
108976 +tm6000_read_write_usb_50774 tm6000_read_write_usb 7 50774 NULL
108977 +bio_alloc_map_data_50782 bio_alloc_map_data 2-1 50782 NULL
108978 +tpm_write_50798 tpm_write 3 50798 NULL
108979 +write_flush_50803 write_flush 3 50803 NULL
108980 +dvb_play_50814 dvb_play 3 50814 NULL
108981 +dpcm_show_state_50827 dpcm_show_state 0 50827 NULL
108982 +acpi_ev_install_gpe_block_50829 acpi_ev_install_gpe_block 2 50829 NULL
108983 +SetArea_50835 SetArea 4 50835 NULL nohasharray
108984 +create_mem_extents_50835 create_mem_extents 0 50835 &SetArea_50835 nohasharray
108985 +mask_from_50835 mask_from 0-1-2 50835 &create_mem_extents_50835
108986 +videobuf_dma_init_user_50839 videobuf_dma_init_user 3-4 50839 NULL
108987 +btrfs_search_slot_for_read_50843 btrfs_search_slot_for_read 0 50843 NULL
108988 +self_check_write_50856 self_check_write 0-5 50856 NULL
108989 +carl9170_debugfs_write_50857 carl9170_debugfs_write 3 50857 NULL
108990 +alloc_masks_50861 alloc_masks 3 50861 NULL
108991 +__percpu_counter_init_50878 __percpu_counter_init 0 50878 NULL
108992 +btrfs_insert_inode_ref_50884 btrfs_insert_inode_ref 0 50884 NULL
108993 +SyS_lgetxattr_50889 SyS_lgetxattr 4 50889 NULL
108994 +netlbl_secattr_catmap_walk_rng_50894 netlbl_secattr_catmap_walk_rng 0-2 50894 NULL
108995 +__bdev_writeseg_50903 __bdev_writeseg 4 50903 NULL
108996 +xfs_iext_remove_50909 xfs_iext_remove 3 50909 NULL
108997 +blk_rq_cur_sectors_50910 blk_rq_cur_sectors 0 50910 NULL
108998 +hash_recvmsg_50924 hash_recvmsg 4 50924 NULL
108999 +chd_dec_fetch_cdata_50926 chd_dec_fetch_cdata 3 50926 NULL
109000 +show_device_status_50947 show_device_status 0 50947 NULL
109001 +irq_timeout_write_50950 irq_timeout_write 3 50950 NULL
109002 +ocfs2_add_refcount_flag_50952 ocfs2_add_refcount_flag 6 50952 NULL
109003 +sdio_uart_write_50954 sdio_uart_write 3 50954 NULL
109004 +SyS_setxattr_50957 SyS_setxattr 4 50957 NULL
109005 +btrfs_del_csums_50969 btrfs_del_csums 0 50969 NULL
109006 +__btrfs_mod_ref_50973 __btrfs_mod_ref 0 50973 NULL
109007 +iwl_statistics_flag_50981 iwl_statistics_flag 0-3 50981 NULL
109008 +timeout_write_50991 timeout_write 3 50991 NULL
109009 +wm831x_irq_map_50995 wm831x_irq_map 2 50995 NULL
109010 +proc_write_51003 proc_write 3 51003 NULL
109011 +jbd2_journal_extend_51012 jbd2_journal_extend 2-0 51012 NULL
109012 +lbs_dev_info_51023 lbs_dev_info 3 51023 NULL
109013 +ntfs_attr_find_51028 ntfs_attr_find 0 51028 NULL nohasharray
109014 +fuse_conn_congestion_threshold_read_51028 fuse_conn_congestion_threshold_read 3 51028 &ntfs_attr_find_51028
109015 +BcmGetSectionValEndOffset_51039 BcmGetSectionValEndOffset 0 51039 NULL
109016 +dump_midi_51040 dump_midi 3 51040 NULL
109017 +usb_get_descriptor_51041 usb_get_descriptor 0 51041 NULL
109018 +srpt_alloc_ioctx_51042 srpt_alloc_ioctx 2-3 51042 NULL
109019 +do_arpt_set_ctl_51053 do_arpt_set_ctl 4 51053 NULL
109020 +wusb_prf_64_51065 wusb_prf_64 7 51065 NULL
109021 +jbd2_journal_init_revoke_51088 jbd2_journal_init_revoke 2 51088 NULL
109022 +solo_enc_v4l2_init_51094 solo_enc_v4l2_init 2 51094 NULL
109023 +__ocfs2_find_path_51096 __ocfs2_find_path 0 51096 NULL
109024 +btrfs_del_item_51110 btrfs_del_item 0 51110 NULL nohasharray
109025 +ti_recv_51110 ti_recv 3 51110 &btrfs_del_item_51110
109026 +uasp_prepare_r_request_51124 uasp_prepare_r_request 0 51124 NULL
109027 +nfs_map_name_to_uid_51132 nfs_map_name_to_uid 3 51132 NULL
109028 +alloc_rtllib_51136 alloc_rtllib 1 51136 NULL
109029 +simple_xattr_set_51140 simple_xattr_set 4 51140 NULL
109030 +set_dirty_51144 set_dirty 3 51144 NULL
109031 +xfs_trans_get_efd_51148 xfs_trans_get_efd 3 51148 NULL
109032 +walk_page_buffers_51170 walk_page_buffers 0 51170 NULL
109033 +snd_pcm_unlink_51210 snd_pcm_unlink 0 51210 NULL
109034 +uhci_frame_skel_link_51213 uhci_frame_skel_link 2 51213 NULL
109035 +nf_ct_ext_create_51232 nf_ct_ext_create 3 51232 NULL
109036 +snd_pcm_write_51235 snd_pcm_write 3 51235 NULL
109037 +tipc_send_51238 tipc_send 4 51238 NULL
109038 +drm_property_create_51239 drm_property_create 4 51239 NULL
109039 +__mxt_read_reg_51249 __mxt_read_reg 0 51249 NULL
109040 +st_read_51251 st_read 3 51251 NULL
109041 +compat_dccp_setsockopt_51263 compat_dccp_setsockopt 5 51263 NULL
109042 +target_alloc_sgl_51264 target_alloc_sgl 3 51264 NULL
109043 +dvb_audio_write_51275 dvb_audio_write 3 51275 NULL
109044 +ipwireless_network_packet_received_51277 ipwireless_network_packet_received 4 51277 NULL
109045 +zone_reclaimable_pages_51283 zone_reclaimable_pages 0 51283 NULL nohasharray
109046 +__get_cur_name_and_parent_51283 __get_cur_name_and_parent 0 51283 &zone_reclaimable_pages_51283
109047 +pvr2_std_id_to_str_51288 pvr2_std_id_to_str 2 51288 NULL
109048 +bnad_debugfs_read_regrd_51308 bnad_debugfs_read_regrd 3 51308 NULL
109049 +get_cell_51316 get_cell 2 51316 NULL
109050 +init_map_ipmac_51317 init_map_ipmac 4-3-5 51317 NULL
109051 +ocfs2_read_inode_block_51319 ocfs2_read_inode_block 0 51319 NULL
109052 +alloc_hippi_dev_51320 alloc_hippi_dev 1 51320 NULL
109053 +ext2_xattr_get_51327 ext2_xattr_get 0 51327 NULL
109054 +alloc_smp_req_51337 alloc_smp_req 1 51337 NULL nohasharray
109055 +compat_arch_ptrace_51337 compat_arch_ptrace 3 51337 &alloc_smp_req_51337
109056 +ipw_get_event_log_len_51341 ipw_get_event_log_len 0 51341 NULL
109057 +ieee80211_if_fmt_estab_plinks_51370 ieee80211_if_fmt_estab_plinks 3 51370 NULL
109058 +radeon_kms_compat_ioctl_51371 radeon_kms_compat_ioctl 2 51371 NULL
109059 +pci_sriov_resource_alignment_51406 pci_sriov_resource_alignment 0 51406 NULL
109060 +ceph_sync_read_51410 ceph_sync_read 3-0 51410 NULL
109061 +get_first_ref_51413 get_first_ref 0 51413 NULL
109062 +__btrfs_end_transaction_51420 __btrfs_end_transaction 0 51420 NULL
109063 +blk_register_region_51424 blk_register_region 1-2 51424 NULL
109064 +mwifiex_rdeeprom_read_51429 mwifiex_rdeeprom_read 3 51429 NULL
109065 +hfsplus_brec_read_51436 hfsplus_brec_read 0 51436 NULL
109066 +ieee80211_if_read_dot11MeshHWMPRootMode_51441 ieee80211_if_read_dot11MeshHWMPRootMode 3 51441 NULL
109067 +print_devstats_dot11ACKFailureCount_51443 print_devstats_dot11ACKFailureCount 3 51443 NULL
109068 +____alloc_ei_netdev_51475 ____alloc_ei_netdev 1 51475 NULL
109069 +xfs_buf_get_uncached_51477 xfs_buf_get_uncached 2 51477 NULL
109070 +btrfs_find_space_cluster_51482 btrfs_find_space_cluster 5 51482 NULL
109071 +kvm_fetch_guest_virt_51493 kvm_fetch_guest_virt 4-2 51493 NULL
109072 +ieee80211_if_write_uapsd_queues_51526 ieee80211_if_write_uapsd_queues 3 51526 NULL
109073 +key_search_51533 key_search 0 51533 NULL
109074 +load_pdptrs_51541 load_pdptrs 3 51541 NULL
109075 +__alloc_eip_netdev_51549 __alloc_eip_netdev 1 51549 NULL
109076 +ixgb_get_eeprom_len_51586 ixgb_get_eeprom_len 0 51586 NULL
109077 +get_cur_path_51589 get_cur_path 0 51589 NULL nohasharray
109078 +snd_interval_refine_first_51589 snd_interval_refine_first 0 51589 &get_cur_path_51589
109079 +aac_convert_sgraw2_51598 aac_convert_sgraw2 4 51598 NULL
109080 +table_size_to_number_of_entries_51613 table_size_to_number_of_entries 0-1 51613 NULL
109081 +extent_fiemap_51621 extent_fiemap 3 51621 NULL
109082 +sctp_auth_create_key_51641 sctp_auth_create_key 1 51641 NULL
109083 +iscsi_create_session_51647 iscsi_create_session 3 51647 NULL
109084 +get_new_cssid_51665 get_new_cssid 2 51665 NULL
109085 +ps_upsd_utilization_read_51669 ps_upsd_utilization_read 3 51669 NULL
109086 +sctp_setsockopt_associnfo_51684 sctp_setsockopt_associnfo 3 51684 NULL
109087 +host_mapping_level_51696 host_mapping_level 2-0 51696 NULL
109088 +sel_write_access_51704 sel_write_access 3 51704 NULL
109089 +tty_cdev_add_51714 tty_cdev_add 2-4 51714 NULL
109090 +v9fs_alloc_rdir_buf_51716 v9fs_alloc_rdir_buf 2 51716 NULL
109091 +drm_compat_ioctl_51717 drm_compat_ioctl 2 51717 NULL
109092 +sg_read_oxfer_51724 sg_read_oxfer 3 51724 NULL
109093 +dbg_check_lpt_nodes_51727 dbg_check_lpt_nodes 0 51727 NULL
109094 +cm4040_read_51732 cm4040_read 3 51732 NULL
109095 +get_user_pages_fast_51751 get_user_pages_fast 1-2-0 51751 NULL
109096 +ifx_spi_insert_flip_string_51752 ifx_spi_insert_flip_string 3 51752 NULL
109097 +if_write_51756 if_write 3 51756 NULL
109098 +ext4_ext_create_new_leaf_51763 ext4_ext_create_new_leaf 0 51763 NULL
109099 +__fswab32_51781 __fswab32 0 51781 NULL
109100 +to_ratio_51809 to_ratio 1-2 51809 NULL
109101 +qib_alloc_devdata_51819 qib_alloc_devdata 2 51819 NULL
109102 +buffer_from_user_51826 buffer_from_user 3 51826 NULL
109103 +max732x_irq_pending_51840 max732x_irq_pending 0 51840 NULL
109104 +ioread32_51847 ioread32 0 51847 NULL nohasharray
109105 +read_file_tgt_tx_stats_51847 read_file_tgt_tx_stats 3 51847 &ioread32_51847
109106 +do_readv_writev_51849 do_readv_writev 4 51849 NULL
109107 +SYSC_sendto_51852 SYSC_sendto 6 51852 NULL
109108 +bm_page_io_async_51858 bm_page_io_async 2 51858 NULL
109109 +pointer_size_read_51863 pointer_size_read 3 51863 NULL
109110 +mlx4_alloc_db_from_pgdir_51865 mlx4_alloc_db_from_pgdir 3 51865 NULL
109111 +get_indirect_ea_51869 get_indirect_ea 4 51869 NULL
109112 +user_read_51881 user_read 3 51881 NULL
109113 +dbAdjCtl_51888 dbAdjCtl 0 51888 NULL
109114 +SyS_mq_timedsend_51896 SyS_mq_timedsend 3 51896 NULL nohasharray
109115 +virt_to_phys_51896 virt_to_phys 0 51896 &SyS_mq_timedsend_51896
109116 +commit_fs_roots_51898 commit_fs_roots 0 51898 NULL
109117 +uvhub_to_first_node_51916 uvhub_to_first_node 0 51916 NULL
109118 +wmi_set_ie_51919 wmi_set_ie 3 51919 NULL
109119 +dbg_status_buf_51930 dbg_status_buf 2 51930 NULL
109120 +__tcp_mtu_to_mss_51938 __tcp_mtu_to_mss 0-2 51938 NULL
109121 +xfrm_alg_len_51940 xfrm_alg_len 0 51940 NULL
109122 +irq_dispose_mapping_51941 irq_dispose_mapping 1 51941 NULL
109123 +scsi_get_vpd_page_51951 scsi_get_vpd_page 4 51951 NULL
109124 +arizona_free_irq_51969 arizona_free_irq 2 51969 NULL nohasharray
109125 +snd_mask_min_51969 snd_mask_min 0 51969 &arizona_free_irq_51969
109126 +__blkdev_get_51972 __blkdev_get 0 51972 NULL nohasharray
109127 +read_page_51972 read_page 2 51972 &__blkdev_get_51972
109128 +get_zone_51981 get_zone 0-1 51981 NULL
109129 +ath6kl_sdio_alloc_prep_scat_req_51986 ath6kl_sdio_alloc_prep_scat_req 2 51986 NULL
109130 +_c4iw_write_mem_dma_51991 _c4iw_write_mem_dma 3 51991 NULL
109131 +ntfs_attr_size_51994 ntfs_attr_size 0 51994 NULL
109132 +dwc3_mode_write_51997 dwc3_mode_write 3 51997 NULL
109133 +skb_copy_datagram_from_iovec_52014 skb_copy_datagram_from_iovec 4-2-5 52014 NULL
109134 +rdmalt_52022 rdmalt 0 52022 NULL
109135 +override_release_52032 override_release 2 52032 NULL
109136 +end_port_52042 end_port 0 52042 NULL
109137 +dma_rx_errors_read_52045 dma_rx_errors_read 3 52045 NULL
109138 +msnd_fifo_write_52052 msnd_fifo_write 0-3 52052 NULL
109139 +dvb_ringbuffer_avail_52057 dvb_ringbuffer_avail 0 52057 NULL
109140 +__fuse_request_alloc_52060 __fuse_request_alloc 1 52060 NULL
109141 +isofs_readpages_52067 isofs_readpages 4 52067 NULL
109142 +nsm_get_handle_52089 nsm_get_handle 4 52089 NULL
109143 +ulist_add_merge_52096 ulist_add_merge 0 52096 NULL
109144 +o2net_debug_read_52105 o2net_debug_read 3 52105 NULL
109145 +split_scan_timeout_write_52128 split_scan_timeout_write 3 52128 NULL
109146 +retry_count_read_52129 retry_count_read 3 52129 NULL
109147 +snd_pcm_channel_info_user_52135 snd_pcm_channel_info_user 0 52135 NULL
109148 +gdm_usb_hci_send_52138 gdm_usb_hci_send 3 52138 NULL
109149 +sub_alloc_52140 sub_alloc 0 52140 NULL nohasharray
109150 +zram_meta_alloc_52140 zram_meta_alloc 1 52140 &sub_alloc_52140
109151 +hysdn_conf_write_52145 hysdn_conf_write 3 52145 NULL nohasharray
109152 +ext2_alloc_blocks_52145 ext2_alloc_blocks 2-0 52145 &hysdn_conf_write_52145
109153 +htable_size_52148 htable_size 0-1 52148 NULL
109154 +smk_write_load2_52155 smk_write_load2 3 52155 NULL
109155 +ieee80211_if_read_dot11MeshRetryTimeout_52168 ieee80211_if_read_dot11MeshRetryTimeout 3 52168 NULL
109156 +mga_compat_ioctl_52170 mga_compat_ioctl 2 52170 NULL
109157 +print_prefix_52176 print_prefix 0 52176 NULL
109158 +proc_pid_readlink_52186 proc_pid_readlink 3 52186 NULL
109159 +vmci_qp_broker_alloc_52216 vmci_qp_broker_alloc 6-5 52216 NULL
109160 +do_dmabuf_dirty_ldu_52241 do_dmabuf_dirty_ldu 6 52241 NULL
109161 +fuse_request_alloc_52243 fuse_request_alloc 1 52243 NULL nohasharray
109162 +xfs_iomap_eof_align_last_fsb_52243 xfs_iomap_eof_align_last_fsb 3 52243 &fuse_request_alloc_52243
109163 +ocfs2_try_to_merge_extent_52244 ocfs2_try_to_merge_extent 0 52244 NULL
109164 +pm80x_request_irq_52250 pm80x_request_irq 2 52250 NULL
109165 +mdiobus_alloc_size_52259 mdiobus_alloc_size 1 52259 NULL
109166 +shrink_slab_52261 shrink_slab 2-3 52261 NULL
109167 +hva_to_pfn_slow_52262 hva_to_pfn_slow 1 52262 NULL
109168 +sisusbcon_do_font_op_52271 sisusbcon_do_font_op 9 52271 NULL
109169 +handle_supp_msgs_52284 handle_supp_msgs 4 52284 NULL
109170 +kobject_set_name_vargs_52309 kobject_set_name_vargs 0 52309 NULL
109171 +read_file_reset_52310 read_file_reset 3 52310 NULL
109172 +request_asymmetric_key_52317 request_asymmetric_key 4-2 52317 NULL
109173 +hwflags_read_52318 hwflags_read 3 52318 NULL
109174 +snd_pcm_hw_free_52327 snd_pcm_hw_free 0 52327 NULL
109175 +ntfs_rl_split_52328 ntfs_rl_split 4-2 52328 NULL
109176 +test_unaligned_bulk_52333 test_unaligned_bulk 3 52333 NULL
109177 +hur_len_52339 hur_len 0 52339 NULL
109178 +bytes_to_frames_52362 bytes_to_frames 0-2 52362 NULL
109179 +copy_entries_to_user_52367 copy_entries_to_user 1 52367 NULL
109180 +iwl_dump_fh_52371 iwl_dump_fh 0 52371 NULL
109181 +hfsplus_find_attr_52374 hfsplus_find_attr 0 52374 NULL
109182 +ocfs2_journal_access_eb_52377 ocfs2_journal_access_eb 0 52377 NULL
109183 +mq_emit_config_values_52378 mq_emit_config_values 3 52378 NULL
109184 +isdn_writebuf_stub_52383 isdn_writebuf_stub 4 52383 NULL
109185 +jfs_setxattr_52389 jfs_setxattr 4 52389 NULL
109186 +aer_inject_write_52399 aer_inject_write 3 52399 NULL nohasharray
109187 +cl_page_own_52399 cl_page_own 0 52399 &aer_inject_write_52399
109188 +cgroup_file_write_52417 cgroup_file_write 3 52417 NULL
109189 +line6_midibuf_init_52425 line6_midibuf_init 2 52425 NULL
109190 +hso_serial_common_create_52428 hso_serial_common_create 4 52428 NULL
109191 +delay_status_52431 delay_status 5 52431 NULL
109192 +ath6kl_delete_qos_write_52435 ath6kl_delete_qos_write 3 52435 NULL
109193 +ieee80211_if_fmt_num_sta_ps_52438 ieee80211_if_fmt_num_sta_ps 3 52438 NULL
109194 +acpi_nvs_for_each_region_52448 acpi_nvs_for_each_region 0 52448 NULL
109195 +alauda_read_data_52452 alauda_read_data 3 52452 NULL
109196 +ieee80211_alloc_txb_52477 ieee80211_alloc_txb 1 52477 NULL
109197 +usb_tranzport_write_52479 usb_tranzport_write 3 52479 NULL
109198 +ocfs2_extend_no_holes_52483 ocfs2_extend_no_holes 3-4 52483 NULL
109199 +fd_do_rw_52495 fd_do_rw 3 52495 NULL
109200 +qib_user_sdma_pin_pages_52498 qib_user_sdma_pin_pages 3-5-4 52498 NULL
109201 +int_tasklet_entry_52500 int_tasklet_entry 3 52500 NULL
109202 +lmv_get_easize_52504 lmv_get_easize 0 52504 NULL
109203 +pm_qos_power_write_52513 pm_qos_power_write 3 52513 NULL
109204 +bt_sock_stream_recvmsg_52518 bt_sock_stream_recvmsg 4 52518 NULL
109205 +dup_variable_bug_52525 dup_variable_bug 3 52525 NULL
109206 +raw_recvmsg_52529 raw_recvmsg 4 52529 NULL
109207 +from_oblock_52546 from_oblock 0-1 52546 NULL
109208 +dccpprobe_read_52549 dccpprobe_read 3 52549 NULL
109209 +ocfs2_make_right_split_rec_52562 ocfs2_make_right_split_rec 3 52562 NULL
109210 +debug_level_proc_write_52572 debug_level_proc_write 3 52572 NULL
109211 +isku_sysfs_read_macro_52587 isku_sysfs_read_macro 6 52587 NULL
109212 +snd_pcm_sw_params_52594 snd_pcm_sw_params 0 52594 NULL
109213 +SyS_setsockopt_52610 SyS_setsockopt 5 52610 NULL
109214 +ll_sa_entry_alloc_52611 ll_sa_entry_alloc 4 52611 NULL
109215 +affs_set_blocksize_52625 affs_set_blocksize 2 52625 NULL
109216 +tps80031_writes_52638 tps80031_writes 3-4 52638 NULL
109217 +brcmf_sdio_assert_info_52653 brcmf_sdio_assert_info 4 52653 NULL
109218 +perf_trace_sched_stat_template_52656 perf_trace_sched_stat_template 3 52656 NULL
109219 +nvme_queue_extra_52661 nvme_queue_extra 0-1 52661 NULL
109220 +htb_add_class_to_row_52663 htb_add_class_to_row 3 52663 NULL
109221 +posix_acl_equiv_mode_52666 posix_acl_equiv_mode 0 52666 NULL
109222 +SYSC_gethostname_52677 SYSC_gethostname 2 52677 NULL
109223 +ntfs_get_nr_significant_bytes_52688 ntfs_get_nr_significant_bytes 0 52688 NULL
109224 +nvd0_disp_pioc_create__52693 nvd0_disp_pioc_create_ 5 52693 NULL
109225 +vendorextnWriteSection_52698 vendorextnWriteSection 0 52698 NULL
109226 +nouveau_client_create__52715 nouveau_client_create_ 5 52715 NULL
109227 +__dm_stat_bio_52722 __dm_stat_bio 3 52722 NULL
109228 +cx25840_ir_rx_read_52724 cx25840_ir_rx_read 3 52724 NULL
109229 +blkcipher_next_slow_52733 blkcipher_next_slow 4-3 52733 NULL
109230 +relay_alloc_page_array_52735 relay_alloc_page_array 1 52735 NULL
109231 +hfcsusb_rx_frame_52745 hfcsusb_rx_frame 3 52745 NULL
109232 +carl9170_debugfs_vif_dump_read_52755 carl9170_debugfs_vif_dump_read 3 52755 NULL
109233 +ieee80211_if_read_beacon_timeout_52756 ieee80211_if_read_beacon_timeout 3 52756 NULL
109234 +radeon_get_ib_value_52757 radeon_get_ib_value 0 52757 NULL
109235 +nvme_trans_ext_inq_page_52776 nvme_trans_ext_inq_page 3 52776 NULL
109236 +pwr_rcvd_beacons_read_52836 pwr_rcvd_beacons_read 3 52836 NULL
109237 +map_try_harder_52846 map_try_harder 2-3 52846 NULL
109238 +ext2_xattr_set_acl_52857 ext2_xattr_set_acl 4 52857 NULL
109239 +process_deleted_xattr_52861 process_deleted_xattr 0 52861 NULL
109240 +mon_bin_get_event_52863 mon_bin_get_event 6-4 52863 NULL
109241 +twl6030_gpadc_write_52867 twl6030_gpadc_write 1 52867 NULL
109242 +qib_decode_6120_err_52876 qib_decode_6120_err 3 52876 NULL
109243 +twlreg_write_52880 twlreg_write 3 52880 NULL
109244 +pvr2_ctrl_value_to_sym_internal_52881 pvr2_ctrl_value_to_sym_internal 5 52881 NULL
109245 +cache_read_procfs_52882 cache_read_procfs 3 52882 NULL
109246 +kvm_kvzalloc_52894 kvm_kvzalloc 1 52894 NULL
109247 +arizona_request_irq_52908 arizona_request_irq 2 52908 NULL
109248 +create_vtbl_52909 create_vtbl 0 52909 NULL
109249 +dio_bio_reap_52913 dio_bio_reap 0 52913 NULL
109250 +__kfifo_out_peek_r_52919 __kfifo_out_peek_r 3 52919 NULL
109251 +iblock_get_bio_52936 iblock_get_bio 3 52936 NULL
109252 +__nodes_remap_52951 __nodes_remap 5 52951 NULL
109253 +send_packet_52960 send_packet 4 52960 NULL
109254 +ieee80211_if_fmt_fwded_mcast_52961 ieee80211_if_fmt_fwded_mcast 3 52961 NULL
109255 +tx_tx_exch_read_52986 tx_tx_exch_read 3 52986 NULL
109256 +num_node_state_52989 num_node_state 0 52989 NULL
109257 +efivarfs_file_write_53000 efivarfs_file_write 3 53000 NULL
109258 +uasp_alloc_stream_res_53015 uasp_alloc_stream_res 0 53015 NULL
109259 +btrfs_free_and_pin_reserved_extent_53016 btrfs_free_and_pin_reserved_extent 2 53016 NULL
109260 +tx_tx_exch_pending_read_53018 tx_tx_exch_pending_read 3 53018 NULL
109261 +ext4_meta_bg_first_group_53031 ext4_meta_bg_first_group 0-2 53031 NULL
109262 +ocfs2_new_leaf_refcount_block_53036 ocfs2_new_leaf_refcount_block 0 53036 NULL
109263 +bio_cur_bytes_53037 bio_cur_bytes 0 53037 NULL
109264 +regcache_lzo_block_count_53056 regcache_lzo_block_count 0 53056 NULL
109265 +cfi_read_query_53066 cfi_read_query 0 53066 NULL
109266 +iwl_dbgfs_interrupt_write_53069 iwl_dbgfs_interrupt_write 3 53069 NULL
109267 +mwifiex_debug_read_53074 mwifiex_debug_read 3 53074 NULL
109268 +page_to_nid_53085 page_to_nid 0 53085 NULL
109269 +qib_resize_cq_53090 qib_resize_cq 2 53090 NULL
109270 +insert_new_root_53097 insert_new_root 0 53097 NULL
109271 +verity_status_53120 verity_status 5 53120 NULL
109272 +__copy_from_user_ll_nocache_nozero_53123 __copy_from_user_ll_nocache_nozero 0-3 53123 NULL
109273 +brcmf_usb_dl_cmd_53130 brcmf_usb_dl_cmd 4 53130 NULL
109274 +btrfs_search_forward_53137 btrfs_search_forward 0 53137 NULL
109275 +ps_poll_ps_poll_max_ap_turn_read_53140 ps_poll_ps_poll_max_ap_turn_read 3 53140 NULL
109276 +ieee80211_bss_info_update_53170 ieee80211_bss_info_update 4 53170 NULL
109277 +btrfs_io_bio_alloc_53179 btrfs_io_bio_alloc 2 53179 NULL
109278 +clear_capture_buf_53192 clear_capture_buf 2 53192 NULL
109279 +SyS_init_module_53202 SyS_init_module 2 53202 NULL
109280 +mtdoops_erase_block_53206 mtdoops_erase_block 2 53206 NULL
109281 +fixup_user_fault_53210 fixup_user_fault 3 53210 NULL
109282 +tx_tx_start_data_read_53219 tx_tx_start_data_read 3 53219 NULL
109283 +ptlrpc_lprocfs_req_history_max_seq_write_53243 ptlrpc_lprocfs_req_history_max_seq_write 3 53243 NULL
109284 +hfsplus_xattr_set_posix_acl_53249 hfsplus_xattr_set_posix_acl 4 53249 NULL
109285 +xfs_trans_read_buf_map_53258 xfs_trans_read_buf_map 5 53258 NULL
109286 +wil_write_file_ssid_53266 wil_write_file_ssid 3 53266 NULL
109287 +btrfs_file_extent_num_bytes_53269 btrfs_file_extent_num_bytes 0 53269 NULL
109288 +tsk_fork_get_node_53271 tsk_fork_get_node 0 53271 NULL
109289 +btrfs_find_highest_objectid_53284 btrfs_find_highest_objectid 0 53284 NULL
109290 +setup_leaf_for_split_53312 setup_leaf_for_split 0 53312 NULL
109291 +ftrace_profile_write_53327 ftrace_profile_write 3 53327 NULL
109292 +setup_cluster_no_bitmap_53328 setup_cluster_no_bitmap 0 53328 NULL
109293 +gsm_control_reply_53333 gsm_control_reply 4 53333 NULL
109294 +vm_mmap_53339 vm_mmap 0 53339 NULL
109295 +vendorextnIoctl_53350 vendorextnIoctl 0 53350 NULL nohasharray
109296 +btrfs_find_all_roots_53350 btrfs_find_all_roots 0 53350 &vendorextnIoctl_53350
109297 +read_6120_creg32_53363 read_6120_creg32 0 53363 NULL
109298 +sock_setbindtodevice_53369 sock_setbindtodevice 3 53369 NULL
109299 +get_random_bytes_arch_53370 get_random_bytes_arch 2 53370 NULL
109300 +isolate_lru_page_53417 isolate_lru_page 0 53417 NULL
109301 +i915_gem_execbuffer_relocate_object_53435 i915_gem_execbuffer_relocate_object 0 53435 NULL
109302 +isr_cmd_cmplt_read_53439 isr_cmd_cmplt_read 3 53439 NULL
109303 +mwifiex_info_read_53447 mwifiex_info_read 3 53447 NULL
109304 +apei_exec_run_optional_53452 apei_exec_run_optional 0 53452 NULL
109305 +paging64_prefetch_gpte_53468 paging64_prefetch_gpte 4 53468 NULL
109306 +iowarrior_read_53483 iowarrior_read 3 53483 NULL
109307 +osd_req_write_kern_53486 osd_req_write_kern 5 53486 NULL
109308 +do_verify_xattr_datum_53499 do_verify_xattr_datum 0 53499 NULL
109309 +ext4_ext_grow_indepth_53503 ext4_ext_grow_indepth 0 53503 NULL
109310 +snd_pcm_format_physical_width_53505 snd_pcm_format_physical_width 0 53505 NULL
109311 +dbAllocNext_53506 dbAllocNext 0 53506 NULL
109312 +ocfs2_xattr_set_acl_53508 ocfs2_xattr_set_acl 4 53508 NULL
109313 +check_acl_53512 check_acl 0 53512 NULL
109314 +send_utimes_53516 send_utimes 0 53516 NULL
109315 +SYSC_bind_53582 SYSC_bind 3 53582 NULL
109316 +cifs_utf16_bytes_53593 cifs_utf16_bytes 0 53593 NULL
109317 +proc_uid_map_write_53596 proc_uid_map_write 3 53596 NULL
109318 +gfn_to_pfn_async_53597 gfn_to_pfn_async 2 53597 NULL
109319 +pfkey_recvmsg_53604 pfkey_recvmsg 4 53604 NULL
109320 +___alloc_bootmem_nopanic_53626 ___alloc_bootmem_nopanic 1 53626 NULL
109321 +xd_write_multiple_pages_53633 xd_write_multiple_pages 6-5 53633 NULL
109322 +stmpe_gpio_request_53634 stmpe_gpio_request 2 53634 NULL nohasharray
109323 +ccid_getsockopt_builtin_ccids_53634 ccid_getsockopt_builtin_ccids 2 53634 &stmpe_gpio_request_53634
109324 +nr_sendmsg_53656 nr_sendmsg 4 53656 NULL
109325 +fuse_fill_write_pages_53682 fuse_fill_write_pages 0-4 53682 NULL
109326 +v4l2_event_subscribe_53687 v4l2_event_subscribe 3 53687 NULL
109327 +bdev_logical_block_size_53690 bdev_logical_block_size 0 53690 NULL nohasharray
109328 +igb_alloc_q_vector_53690 igb_alloc_q_vector 6-4 53690 &bdev_logical_block_size_53690
109329 +find_overflow_devnum_53711 find_overflow_devnum 0 53711 NULL
109330 +bio_integrity_split_53714 bio_integrity_split 3 53714 NULL
109331 +__ocfs2_resv_find_window_53721 __ocfs2_resv_find_window 3 53721 NULL
109332 +__proc_debug_mb_53732 __proc_debug_mb 5 53732 NULL
109333 +wdm_write_53735 wdm_write 3 53735 NULL
109334 +ext3_try_to_allocate_with_rsv_53737 ext3_try_to_allocate_with_rsv 5-3-0 53737 NULL
109335 +da9052_disable_irq_53745 da9052_disable_irq 2 53745 NULL
109336 +lpfc_idiag_queacc_read_qe_53755 lpfc_idiag_queacc_read_qe 0-2 53755 NULL nohasharray
109337 +amdtp_out_stream_get_max_payload_53755 amdtp_out_stream_get_max_payload 0 53755 &lpfc_idiag_queacc_read_qe_53755
109338 +ext2_acl_count_53773 ext2_acl_count 0-1 53773 NULL
109339 +__kfifo_dma_in_prepare_r_53792 __kfifo_dma_in_prepare_r 4-5 53792 NULL
109340 +qp_alloc_host_work_53798 qp_alloc_host_work 5-3 53798 NULL
109341 +regmap_raw_write_53803 regmap_raw_write 2-4 53803 NULL
109342 +lpfc_idiag_ctlacc_read_reg_53809 lpfc_idiag_ctlacc_read_reg 0-3 53809 NULL
109343 +nls_nullsize_53815 nls_nullsize 0 53815 NULL
109344 +insert_pfn_53816 insert_pfn 3-0 53816 NULL
109345 +setup_data_read_53822 setup_data_read 3 53822 NULL
109346 +pms_read_53873 pms_read 3 53873 NULL
109347 +ieee80211_if_fmt_dropped_frames_congestion_53883 ieee80211_if_fmt_dropped_frames_congestion 3 53883 NULL
109348 +ocfs2_rm_xattr_cluster_53900 ocfs2_rm_xattr_cluster 4-5-3 53900 NULL nohasharray
109349 +SyS_setgroups_53900 SyS_setgroups 1 53900 &ocfs2_rm_xattr_cluster_53900
109350 +azx_via_get_position_53916 azx_via_get_position 0 53916 NULL
109351 +usb_serial_generic_write_53927 usb_serial_generic_write 4 53927 NULL
109352 +ocfs2_make_clusters_writable_53938 ocfs2_make_clusters_writable 5-4-0 53938 NULL
109353 +idetape_chrdev_write_53976 idetape_chrdev_write 3 53976 NULL
109354 +mthca_reg_user_mr_53980 mthca_reg_user_mr 2-3 53980 NULL
109355 +__ocfs2_xattr_set_value_outside_53981 __ocfs2_xattr_set_value_outside 5 53981 NULL
109356 +ieee80211_if_fmt_dot11MeshHWMPperrMinInterval_53998 ieee80211_if_fmt_dot11MeshHWMPperrMinInterval 3 53998 NULL
109357 +send_clone_54011 send_clone 0 54011 NULL
109358 +hfsplus_attr_build_key_54013 hfsplus_attr_build_key 0 54013 NULL
109359 +snd_pcm_lib_write_transfer_54018 snd_pcm_lib_write_transfer 5-2-4 54018 NULL
109360 +mdc_kuc_write_54019 mdc_kuc_write 3 54019 NULL
109361 +ipxrtr_route_packet_54036 ipxrtr_route_packet 4 54036 NULL
109362 +pipeline_dec_packet_out_read_54052 pipeline_dec_packet_out_read 3 54052 NULL
109363 +nl80211_send_disconnected_54056 nl80211_send_disconnected 5 54056 NULL
109364 +rproc_state_read_54057 rproc_state_read 3 54057 NULL
109365 +btrfs_start_transaction_54066 btrfs_start_transaction 2 54066 NULL
109366 +_malloc_54077 _malloc 1 54077 NULL
109367 +bitmap_bitremap_54096 bitmap_bitremap 4 54096 NULL
109368 +altera_set_ir_pre_54103 altera_set_ir_pre 2 54103 NULL nohasharray
109369 +lustre_posix_acl_xattr_filter_54103 lustre_posix_acl_xattr_filter 2 54103 &altera_set_ir_pre_54103
109370 +__comedi_buf_write_alloc_54112 __comedi_buf_write_alloc 0-2 54112 NULL
109371 +strn_len_54122 strn_len 0 54122 NULL
109372 +isku_receive_54130 isku_receive 4 54130 NULL
109373 +isr_host_acknowledges_read_54136 isr_host_acknowledges_read 3 54136 NULL
109374 +irq_blk_threshold_write_54138 irq_blk_threshold_write 3 54138 NULL
109375 +memcpy_toiovec_54166 memcpy_toiovec 3 54166 NULL
109376 +nouveau_falcon_create__54169 nouveau_falcon_create_ 8 54169 NULL
109377 +p9_client_prepare_req_54175 p9_client_prepare_req 3 54175 NULL
109378 +devm_request_threaded_irq_54215 devm_request_threaded_irq 0 54215 NULL
109379 +do_sys_poll_54221 do_sys_poll 2 54221 NULL
109380 +__register_chrdev_54223 __register_chrdev 2-3 54223 NULL
109381 +pi_read_regr_54231 pi_read_regr 0 54231 NULL
109382 +mcp23s08_read_regs_54246 mcp23s08_read_regs 4 54246 NULL
109383 +reada_add_block_54247 reada_add_block 2 54247 NULL
109384 +write_file_spec_scan_ctl_54248 write_file_spec_scan_ctl 3 54248 NULL
109385 +jbd2__journal_restart_54249 jbd2__journal_restart 0 54249 NULL
109386 +barrier_all_devices_54254 barrier_all_devices 0 54254 NULL nohasharray
109387 +xfs_dir2_sf_addname_hard_54254 xfs_dir2_sf_addname_hard 3 54254 &barrier_all_devices_54254
109388 +ceph_msgpool_get_54258 ceph_msgpool_get 2 54258 NULL
109389 +wusb_prf_54261 wusb_prf 7 54261 NULL nohasharray
109390 +audio_write_54261 audio_write 4 54261 &wusb_prf_54261
109391 +mwifiex_getlog_read_54269 mwifiex_getlog_read 3 54269 NULL
109392 +kstrtou16_from_user_54274 kstrtou16_from_user 2 54274 NULL
109393 +ubi_calc_data_len_54279 ubi_calc_data_len 0-3 54279 NULL
109394 +altera_set_dr_post_54291 altera_set_dr_post 2 54291 NULL
109395 +dlm_alloc_pagevec_54296 dlm_alloc_pagevec 1 54296 NULL
109396 +get_iovec_page_array_54298 get_iovec_page_array 6 54298 NULL
109397 +ttm_mem_global_alloc_54299 ttm_mem_global_alloc 0 54299 NULL
109398 +reclaim_pages_54301 reclaim_pages 3 54301 NULL
109399 +sprintf_54306 sprintf 0 54306 NULL
109400 +bio_add_pc_page_54319 bio_add_pc_page 4 54319 NULL
109401 +br_fdb_fillbuf_54339 br_fdb_fillbuf 0 54339 NULL
109402 +__alloc_dev_table_54343 __alloc_dev_table 2 54343 NULL
109403 +__get_free_pages_54352 __get_free_pages 0 54352 NULL
109404 +tcf_hash_create_54360 tcf_hash_create 4 54360 NULL
109405 +read_file_credit_dist_stats_54367 read_file_credit_dist_stats 3 54367 NULL
109406 +vfs_readlink_54368 vfs_readlink 3 54368 NULL
109407 +do_dccp_setsockopt_54377 do_dccp_setsockopt 5 54377 NULL nohasharray
109408 +intel_sdvo_write_cmd_54377 intel_sdvo_write_cmd 4 54377 &do_dccp_setsockopt_54377
109409 +ah_alloc_tmp_54378 ah_alloc_tmp 2-3 54378 NULL
109410 +gart_unmap_page_54379 gart_unmap_page 3-2 54379 NULL
109411 +snd_pcm_oss_read2_54387 snd_pcm_oss_read2 3-0 54387 NULL
109412 +iwl_dbgfs_power_save_status_read_54392 iwl_dbgfs_power_save_status_read 3 54392 NULL
109413 +efx_nic_describe_stats_54407 efx_nic_describe_stats 2 54407 NULL
109414 +ll_ra_count_get_54410 ll_ra_count_get 3 54410 NULL
109415 +copy_gadget_strings_54417 copy_gadget_strings 3-2 54417 NULL
109416 +btrfs_inc_extent_ref_54442 btrfs_inc_extent_ref 0 54442 NULL
109417 +sparse_early_mem_maps_alloc_node_54485 sparse_early_mem_maps_alloc_node 4 54485 NULL
109418 +simple_strtoull_54493 simple_strtoull 0 54493 NULL
109419 +swiotlb_tbl_map_single_54495 swiotlb_tbl_map_single 0 54495 NULL
109420 +btrfs_ordered_sum_size_54509 btrfs_ordered_sum_size 0-2 54509 NULL
109421 +cgroup_write_X64_54514 cgroup_write_X64 5 54514 NULL
109422 +rfc4106_set_key_54519 rfc4106_set_key 3 54519 NULL
109423 +vmci_transport_dgram_enqueue_54525 vmci_transport_dgram_enqueue 4 54525 NULL
109424 +viacam_read_54526 viacam_read 3 54526 NULL
109425 +unix_dgram_connect_54535 unix_dgram_connect 3 54535 NULL
109426 +setsockopt_54539 setsockopt 5 54539 NULL
109427 +i915_reset_gen7_sol_offsets_54547 i915_reset_gen7_sol_offsets 0 54547 NULL
109428 +lbs_lowsnr_write_54549 lbs_lowsnr_write 3 54549 NULL
109429 +ntfs_commit_pages_after_non_resident_write_54555 ntfs_commit_pages_after_non_resident_write 4-3 54555 NULL nohasharray
109430 +i915_gem_get_seqno_54555 i915_gem_get_seqno 0 54555 &ntfs_commit_pages_after_non_resident_write_54555
109431 +btrfs_update_inode_item_54561 btrfs_update_inode_item 0 54561 NULL nohasharray
109432 +SYSC_setsockopt_54561 SYSC_setsockopt 5 54561 &btrfs_update_inode_item_54561
109433 +nfsd_vfs_write_54577 nfsd_vfs_write 6 54577 NULL
109434 +fw_iso_buffer_init_54582 fw_iso_buffer_init 3 54582 NULL
109435 +nvme_npages_54601 nvme_npages 0-1 54601 NULL
109436 +irq_pkt_threshold_write_54605 irq_pkt_threshold_write 3 54605 NULL
109437 +devm_gen_pool_create_54607 devm_gen_pool_create 3 54607 NULL
109438 +port_fops_write_54627 port_fops_write 3 54627 NULL
109439 +irq_timeout_read_54653 irq_timeout_read 3 54653 NULL
109440 +dns_resolver_read_54658 dns_resolver_read 3 54658 NULL
109441 +twl6030_interrupt_mask_54659 twl6030_interrupt_mask 2 54659 NULL
109442 +kvm_read_cr3_54662 kvm_read_cr3 0 54662 NULL
109443 +tdp_page_fault_54663 tdp_page_fault 2 54663 NULL
109444 +bus_add_device_54665 bus_add_device 0 54665 NULL
109445 +cw1200_queue_stats_init_54670 cw1200_queue_stats_init 2 54670 NULL
109446 +bio_kmalloc_54672 bio_kmalloc 2 54672 NULL
109447 +vring_new_virtqueue_54673 vring_new_virtqueue 2 54673 NULL
109448 +evm_read_key_54674 evm_read_key 3 54674 NULL
109449 +fs_path_add_path_54680 fs_path_add_path 0 54680 NULL
109450 +platform_get_irq_byname_54700 platform_get_irq_byname 0 54700 NULL
109451 +__btrfs_inc_extent_ref_54706 __btrfs_inc_extent_ref 7-0 54706 NULL
109452 +rfkill_fop_read_54711 rfkill_fop_read 3 54711 NULL
109453 +clk_divider_set_rate_54726 clk_divider_set_rate 3-2 54726 NULL
109454 +ocfs2_control_write_54737 ocfs2_control_write 3 54737 NULL
109455 +kzalloc_54740 kzalloc 1 54740 NULL
109456 +wep_iv_read_54744 wep_iv_read 3 54744 NULL
109457 +lpfc_idiag_pcicfg_write_54749 lpfc_idiag_pcicfg_write 3 54749 NULL
109458 +iio_event_chrdev_read_54757 iio_event_chrdev_read 3 54757 NULL
109459 +adis16480_show_firmware_date_54762 adis16480_show_firmware_date 3 54762 NULL
109460 +ldsem_atomic_update_54774 ldsem_atomic_update 1-0 54774 NULL
109461 +gpiochip_add_54781 gpiochip_add 0 54781 NULL
109462 +flexcop_device_kmalloc_54793 flexcop_device_kmalloc 1 54793 NULL
109463 +domain_init_54797 domain_init 2 54797 NULL
109464 +ext3_find_goal_54801 ext3_find_goal 0 54801 NULL
109465 +get_dev_size_54807 get_dev_size 0 54807 NULL
109466 +nfsd_write_54809 nfsd_write 6 54809 NULL
109467 +aes_decrypt_fail_read_54815 aes_decrypt_fail_read 3 54815 NULL nohasharray
109468 +kvzalloc_54815 kvzalloc 1 54815 &aes_decrypt_fail_read_54815 nohasharray
109469 +crypto_tfm_ctx_alignment_54815 crypto_tfm_ctx_alignment 0 54815 &kvzalloc_54815
109470 +generic_perform_write_54832 generic_perform_write 3 54832 NULL
109471 +write_rio_54837 write_rio 3 54837 NULL
109472 +nouveau_engctx_create__54839 nouveau_engctx_create_ 8 54839 NULL nohasharray
109473 +ext3_acl_from_disk_54839 ext3_acl_from_disk 2 54839 &nouveau_engctx_create__54839
109474 +ufx_ops_write_54848 ufx_ops_write 3 54848 NULL
109475 +printer_read_54851 printer_read 3 54851 NULL
109476 +qib_reg_user_mr_54858 qib_reg_user_mr 2-3 54858 NULL
109477 +alloc_ep_req_54860 alloc_ep_req 2 54860 NULL
109478 +broadsheet_spiflash_rewrite_sector_54864 broadsheet_spiflash_rewrite_sector 2 54864 NULL
109479 +prism_build_supp_rates_54865 prism_build_supp_rates 0 54865 NULL
109480 +iscsi_pool_init_54913 iscsi_pool_init 4-2 54913 NULL nohasharray
109481 +kobject_set_name_vargs_54913 kobject_set_name_vargs 0 54913 &iscsi_pool_init_54913
109482 +btrfs_stack_chunk_num_stripes_54923 btrfs_stack_chunk_num_stripes 0 54923 NULL
109483 +bio_add_page_54933 bio_add_page 0-3 54933 NULL
109484 +mxms_structlen_54939 mxms_structlen 0 54939 NULL
109485 +add_port_54941 add_port 2 54941 NULL
109486 +ath9k_dump_btcoex_54949 ath9k_dump_btcoex 0 54949 NULL
109487 +alauda_write_data_54967 alauda_write_data 3 54967 NULL
109488 +c4_add_card_54968 c4_add_card 3 54968 NULL
109489 +iwl_pcie_dump_fh_54975 iwl_pcie_dump_fh 0 54975 NULL
109490 +ubi_change_vtbl_record_54979 ubi_change_vtbl_record 0 54979 NULL
109491 +ext3_xattr_get_54989 ext3_xattr_get 0 54989 NULL
109492 +rds_ib_inc_copy_to_user_55007 rds_ib_inc_copy_to_user 3 55007 NULL
109493 +mem_cgroup_get_lru_size_55008 mem_cgroup_get_lru_size 0 55008 NULL
109494 +cx231xx_v4l2_read_55014 cx231xx_v4l2_read 3 55014 NULL
109495 +paging32_get_level1_sp_gpa_55022 paging32_get_level1_sp_gpa 0 55022 NULL
109496 +error_error_null_Frame_tx_start_read_55024 error_error_null_Frame_tx_start_read 3 55024 NULL
109497 +dgap_do_bios_load_55025 dgap_do_bios_load 3 55025 NULL
109498 +btrfs_init_acl_55028 btrfs_init_acl 0 55028 NULL
109499 +write_ctree_super_55039 write_ctree_super 0 55039 NULL
109500 +ext4_ext_handle_uninitialized_extents_55059 ext4_ext_handle_uninitialized_extents 0-6 55059 NULL
109501 +apei_exec_run_55075 apei_exec_run 0 55075 NULL
109502 +bitmap_storage_alloc_55077 bitmap_storage_alloc 2 55077 NULL
109503 +snd_pcm_capture_hw_avail_55086 snd_pcm_capture_hw_avail 0 55086 NULL nohasharray
109504 +read_dma_55086 read_dma 3 55086 &snd_pcm_capture_hw_avail_55086
109505 +rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read_55106 rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read 3 55106 NULL
109506 +corrupt_data_55120 corrupt_data 0-3 55120 NULL
109507 +crypto_ahash_setkey_55134 crypto_ahash_setkey 3 55134 NULL
109508 +ocfs2_prepare_refcount_change_for_del_55137 ocfs2_prepare_refcount_change_for_del 3-0 55137 NULL nohasharray
109509 +filldir_55137 filldir 3 55137 &ocfs2_prepare_refcount_change_for_del_55137
109510 +validate_vid_hdr_55145 validate_vid_hdr 0 55145 NULL
109511 +ocfs2_truncate_file_55148 ocfs2_truncate_file 3 55148 NULL
109512 +npages_to_npools_55149 npages_to_npools 0-1 55149 NULL
109513 +ieee80211_if_read_uapsd_queues_55150 ieee80211_if_read_uapsd_queues 3 55150 NULL
109514 +mtd_get_fact_prot_info_55186 mtd_get_fact_prot_info 0 55186 NULL
109515 +sel_write_relabel_55195 sel_write_relabel 3 55195 NULL
109516 +sched_feat_write_55202 sched_feat_write 3 55202 NULL
109517 +ht40allow_map_read_55209 ht40allow_map_read 3 55209 NULL
109518 +__kfifo_dma_out_prepare_r_55211 __kfifo_dma_out_prepare_r 4-5 55211 NULL
109519 +do_raw_setsockopt_55215 do_raw_setsockopt 5 55215 NULL
109520 +qxl_alloc_client_monitors_config_55216 qxl_alloc_client_monitors_config 2 55216 NULL
109521 +dbAllocDmap_55227 dbAllocDmap 0 55227 NULL
109522 +hash_netport6_expire_55232 hash_netport6_expire 3 55232 NULL
109523 +memcpy_fromiovec_55247 memcpy_fromiovec 3 55247 NULL
109524 +lbs_failcount_write_55276 lbs_failcount_write 3 55276 NULL
109525 +persistent_ram_new_55286 persistent_ram_new 2-1 55286 NULL
109526 +ptrace_request_55288 ptrace_request 3 55288 NULL
109527 +rx_streaming_interval_read_55291 rx_streaming_interval_read 3 55291 NULL
109528 +lov_get_stripecnt_55297 lov_get_stripecnt 0-3 55297 NULL
109529 +gsm_control_modem_55303 gsm_control_modem 3 55303 NULL
109530 +wimax_msg_len_55304 wimax_msg_len 0 55304 NULL
109531 +__get_vm_area_node_55305 __get_vm_area_node 6 55305 NULL nohasharray
109532 +qp_alloc_guest_work_55305 qp_alloc_guest_work 5-3 55305 &__get_vm_area_node_55305
109533 +__vxge_hw_vpath_initialize_55328 __vxge_hw_vpath_initialize 2 55328 NULL
109534 +do_shmat_55336 do_shmat 5 55336 NULL
109535 +vme_user_read_55338 vme_user_read 3 55338 NULL
109536 +sctp_datamsg_from_user_55342 sctp_datamsg_from_user 4 55342 NULL nohasharray
109537 +__wa_xfer_setup_sizes_55342 __wa_xfer_setup_sizes 0 55342 &sctp_datamsg_from_user_55342
109538 +iterate_inode_extrefs_55362 iterate_inode_extrefs 0 55362 NULL nohasharray
109539 +acpi_system_read_event_55362 acpi_system_read_event 3 55362 &iterate_inode_extrefs_55362
109540 +cw1200_sdio_align_size_55391 cw1200_sdio_align_size 2 55391 NULL
109541 +__domain_mapping_55393 __domain_mapping 5 55393 NULL
109542 +iwl_dbgfs_plcp_delta_read_55407 iwl_dbgfs_plcp_delta_read 3 55407 NULL
109543 +si476x_radio_read_rds_blckcnt_blob_55427 si476x_radio_read_rds_blckcnt_blob 3 55427 NULL
109544 +SyS_read_55449 SyS_read 3 55449 NULL
109545 +add_relation_rb_55451 add_relation_rb 0 55451 NULL
109546 +__vxge_hw_channel_allocate_55462 __vxge_hw_channel_allocate 3 55462 NULL
109547 +cx23888_ir_rx_read_55473 cx23888_ir_rx_read 3 55473 NULL
109548 +snd_pcm_lib_write_55483 snd_pcm_lib_write 0-3 55483 NULL
109549 +i2o_pool_alloc_55485 i2o_pool_alloc 4 55485 NULL
109550 +ocfs2_rec_clusters_55501 ocfs2_rec_clusters 0 55501 NULL nohasharray
109551 +ras_stride_increase_window_55501 ras_stride_increase_window 3 55501 &ocfs2_rec_clusters_55501
109552 +ext4_flex_bg_size_55502 ext4_flex_bg_size 0 55502 NULL
109553 +tx_tx_done_int_template_read_55511 tx_tx_done_int_template_read 3 55511 NULL
109554 +ea_get_55522 ea_get 3-0 55522 NULL
109555 +buffer_size_55534 buffer_size 0 55534 NULL
109556 +set_msr_interception_55538 set_msr_interception 2 55538 NULL
109557 +tty_port_register_device_55543 tty_port_register_device 3 55543 NULL
109558 +dgap_do_config_load_55548 dgap_do_config_load 2 55548 NULL
109559 +dm_stats_list_55551 dm_stats_list 4 55551 NULL
109560 +gfs2_bitfit_55566 gfs2_bitfit 2-3-0 55566 NULL
109561 +hash_netport4_expire_55584 hash_netport4_expire 3 55584 NULL
109562 +add_partition_55588 add_partition 2 55588 NULL
109563 +kstrtou8_from_user_55599 kstrtou8_from_user 2 55599 NULL
109564 +SyS_keyctl_55602 SyS_keyctl 4 55602 NULL
109565 +allocate_without_wrapping_disk_55607 allocate_without_wrapping_disk 4 55607 NULL
109566 +macvtap_put_user_55609 macvtap_put_user 4 55609 NULL
109567 +selinux_setprocattr_55611 selinux_setprocattr 4 55611 NULL
109568 +edge_tty_recv_55622 edge_tty_recv 3 55622 NULL
109569 +snd_pcm_hw_param_last_55624 snd_pcm_hw_param_last 0 55624 NULL
109570 +reiserfs_xattr_get_55628 reiserfs_xattr_get 0 55628 NULL nohasharray
109571 +pktgen_if_write_55628 pktgen_if_write 3 55628 &reiserfs_xattr_get_55628
109572 +osc_obd_max_pages_per_rpc_seq_write_55636 osc_obd_max_pages_per_rpc_seq_write 3 55636 NULL
109573 +dvb_dmxdev_set_buffer_size_55643 dvb_dmxdev_set_buffer_size 2 55643 NULL
109574 +mlx4_buddy_alloc_55647 mlx4_buddy_alloc 2 55647 NULL
109575 +xfs_bmbt_maxrecs_55649 xfs_bmbt_maxrecs 0-2 55649 NULL
109576 +lpfc_idiag_queinfo_read_55662 lpfc_idiag_queinfo_read 3 55662 NULL
109577 +il_dbgfs_tx_queue_read_55668 il_dbgfs_tx_queue_read 3 55668 NULL
109578 +btrfs_reloc_cow_block_55672 btrfs_reloc_cow_block 0 55672 NULL
109579 +get_info_55681 get_info 3 55681 NULL
109580 +iwl_dbgfs_plcp_delta_write_55682 iwl_dbgfs_plcp_delta_write 3 55682 NULL
109581 +pm8001_store_update_fw_55716 pm8001_store_update_fw 4 55716 NULL
109582 +ocfs2_lock_refcount_tree_55719 ocfs2_lock_refcount_tree 0 55719 NULL nohasharray
109583 +mtdswap_init_55719 mtdswap_init 2 55719 &ocfs2_lock_refcount_tree_55719
109584 +tap_pwup_write_55723 tap_pwup_write 3 55723 NULL
109585 +__iio_allocate_kfifo_55738 __iio_allocate_kfifo 2 55738 NULL
109586 +set_local_name_55757 set_local_name 4 55757 NULL
109587 +strlen_55778 strlen 0 55778 NULL nohasharray
109588 +is_idx_node_in_tnc_55778 is_idx_node_in_tnc 0 55778 &strlen_55778
109589 +set_spte_55783 set_spte 4-5 55783 NULL
109590 +req_bio_endio_55786 req_bio_endio 3 55786 NULL nohasharray
109591 +conf_read_55786 conf_read 3 55786 &req_bio_endio_55786
109592 +uwb_rc_neh_grok_event_55799 uwb_rc_neh_grok_event 3 55799 NULL
109593 +sb16_copy_from_user_55836 sb16_copy_from_user 7-6-10 55836 NULL
109594 +ept_gva_to_gpa_55848 ept_gva_to_gpa 2 55848 NULL
109595 +ip_hdrlen_55849 ip_hdrlen 0 55849 NULL
109596 +hcd_alloc_coherent_55862 hcd_alloc_coherent 5 55862 NULL
109597 +shmem_setxattr_55867 shmem_setxattr 4 55867 NULL
109598 +__check_block_validity_55869 __check_block_validity 0 55869 NULL
109599 +hsc_write_55875 hsc_write 3 55875 NULL
109600 +pm_qos_power_read_55891 pm_qos_power_read 3 55891 NULL
109601 +snd_pcm_hw_param_value_min_55917 snd_pcm_hw_param_value_min 0 55917 NULL
109602 +ext2_direct_IO_55932 ext2_direct_IO 4 55932 NULL
109603 +paging64_page_fault_55942 paging64_page_fault 2 55942 NULL
109604 +kvm_write_guest_virt_system_55944 kvm_write_guest_virt_system 4-2 55944 NULL
109605 +sel_read_policy_55947 sel_read_policy 3 55947 NULL
109606 +ceph_get_direct_page_vector_55956 ceph_get_direct_page_vector 2 55956 NULL
109607 +simple_read_from_buffer_55957 simple_read_from_buffer 5-2 55957 NULL
109608 +tx_tx_imm_resp_read_55964 tx_tx_imm_resp_read 3 55964 NULL
109609 +btrfs_clone_55977 btrfs_clone 5-3 55977 NULL
109610 +wa_xfer_create_subset_sg_55992 wa_xfer_create_subset_sg 2-3 55992 NULL
109611 +nvme_alloc_iod_56027 nvme_alloc_iod 1-2 56027 NULL
109612 +dccp_sendmsg_56058 dccp_sendmsg 4 56058 NULL
109613 +__set_discard_56081 __set_discard 2 56081 NULL
109614 +pscsi_get_bio_56103 pscsi_get_bio 1 56103 NULL
109615 +usb_alloc_stream_buffers_56123 usb_alloc_stream_buffers 3 56123 NULL
109616 +sel_read_handle_status_56139 sel_read_handle_status 3 56139 NULL
109617 +write_file_frameerrors_56145 write_file_frameerrors 3 56145 NULL
109618 +add_extent_mapping_56157 add_extent_mapping 0 56157 NULL
109619 +__i2c_transfer_56162 __i2c_transfer 0 56162 NULL
109620 +rawv6_setsockopt_56165 rawv6_setsockopt 5 56165 NULL
109621 +create_irq_nr_56180 create_irq_nr 1-0-2 56180 NULL
109622 +ath9k_dump_legacy_btcoex_56194 ath9k_dump_legacy_btcoex 0 56194 NULL
109623 +ocfs2_journal_access_gd_56209 ocfs2_journal_access_gd 0 56209 NULL
109624 +update_space_info_56213 update_space_info 0 56213 NULL
109625 +ncp_read_bounce_size_56221 ncp_read_bounce_size 0-1 56221 NULL
109626 +vring_add_indirect_56222 vring_add_indirect 4 56222 NULL
109627 +ocfs2_find_xe_in_bucket_56224 ocfs2_find_xe_in_bucket 0 56224 NULL
109628 +do_ipt_set_ctl_56238 do_ipt_set_ctl 4 56238 NULL
109629 +fd_copyin_56247 fd_copyin 3 56247 NULL
109630 +sk_rmem_schedule_56255 sk_rmem_schedule 3 56255 NULL
109631 +p9pdu_vreadf_56271 p9pdu_vreadf 0 56271 NULL
109632 +il4965_ucode_general_stats_read_56277 il4965_ucode_general_stats_read 3 56277 NULL
109633 +ieee80211_if_fmt_user_power_level_56283 ieee80211_if_fmt_user_power_level 3 56283 NULL
109634 +RESIZE_IF_NEEDED_56286 RESIZE_IF_NEEDED 2 56286 NULL
109635 +dvb_aplay_56296 dvb_aplay 3 56296 NULL
109636 +btmrvl_hscfgcmd_read_56303 btmrvl_hscfgcmd_read 3 56303 NULL
109637 +speakup_file_write_56310 speakup_file_write 3 56310 NULL
109638 +pipeline_pre_to_defrag_swi_read_56321 pipeline_pre_to_defrag_swi_read 3 56321 NULL
109639 +journal_init_revoke_table_56331 journal_init_revoke_table 1 56331 NULL
109640 +snd_rawmidi_read_56337 snd_rawmidi_read 3 56337 NULL
109641 +ipv6_recv_error_56347 ipv6_recv_error 3 56347 NULL
109642 +vxge_os_dma_malloc_async_56348 vxge_os_dma_malloc_async 3 56348 NULL
109643 +mite_device_bytes_transferred_56355 mite_device_bytes_transferred 0 56355 NULL
109644 +iov_iter_copy_from_user_atomic_56368 iov_iter_copy_from_user_atomic 0-4 56368 NULL
109645 +dev_read_56369 dev_read 3 56369 NULL
109646 +ath10k_read_simulate_fw_crash_56371 ath10k_read_simulate_fw_crash 3 56371 NULL
109647 +ata_qc_complete_multiple_56376 ata_qc_complete_multiple 2 56376 NULL
109648 +snd_pcm_common_ioctl1_56382 snd_pcm_common_ioctl1 0 56382 NULL
109649 +write_gssp_56404 write_gssp 3 56404 NULL
109650 +ocfs2_control_read_56405 ocfs2_control_read 3 56405 NULL
109651 +do_get_write_access_56410 do_get_write_access 0 56410 NULL
109652 +i915_gem_object_sync_56417 i915_gem_object_sync 0 56417 NULL nohasharray
109653 +store_msg_56417 store_msg 3 56417 &i915_gem_object_sync_56417
109654 +pppol2tp_sendmsg_56420 pppol2tp_sendmsg 4 56420 NULL
109655 +fl_create_56435 fl_create 5 56435 NULL
109656 +gnttab_map_56439 gnttab_map 2 56439 NULL
109657 +cx231xx_init_isoc_56453 cx231xx_init_isoc 3-2-4 56453 NULL
109658 +set_connectable_56458 set_connectable 4 56458 NULL
109659 +osd_req_list_partition_objects_56464 osd_req_list_partition_objects 5 56464 NULL
109660 +putused_user_56467 putused_user 3 56467 NULL
109661 +lbs_rdmac_write_56471 lbs_rdmac_write 3 56471 NULL
109662 +calc_linear_pos_56472 calc_linear_pos 0-3 56472 NULL
109663 +global_rt_period_56476 global_rt_period 0 56476 NULL
109664 +crypto_shash_alignmask_56486 crypto_shash_alignmask 0 56486 NULL
109665 +ieee80211_rx_mgmt_probe_beacon_56491 ieee80211_rx_mgmt_probe_beacon 3 56491 NULL
109666 +cfs_access_process_vm_56503 cfs_access_process_vm 2-4-0 56503 NULL
109667 +init_map_ip_56508 init_map_ip 5 56508 NULL
109668 +lustre_posix_acl_xattr_reduce_space_56512 lustre_posix_acl_xattr_reduce_space 3 56512 NULL
109669 +ext4_zeroout_es_56514 ext4_zeroout_es 0 56514 NULL
109670 +cfg80211_connect_result_56515 cfg80211_connect_result 6-4 56515 NULL
109671 +ip_options_get_56538 ip_options_get 4 56538 NULL
109672 +ll_wr_track_id_56544 ll_wr_track_id 2 56544 NULL
109673 +vb2_queue_or_prepare_buf_56547 vb2_queue_or_prepare_buf 0 56547 NULL
109674 +ocfs2_change_extent_flag_56549 ocfs2_change_extent_flag 5 56549 NULL
109675 +alloc_apertures_56561 alloc_apertures 1 56561 NULL
109676 +rs_sta_dbgfs_stats_table_read_56573 rs_sta_dbgfs_stats_table_read 3 56573 NULL
109677 +portcntrs_2_read_56586 portcntrs_2_read 3 56586 NULL
109678 +event_filter_write_56609 event_filter_write 3 56609 NULL
109679 +nvme_trans_log_temperature_56613 nvme_trans_log_temperature 3 56613 NULL
109680 +gather_array_56641 gather_array 3 56641 NULL
109681 +lookup_extent_backref_56644 lookup_extent_backref 9-0 56644 NULL
109682 +uvc_debugfs_stats_read_56651 uvc_debugfs_stats_read 3 56651 NULL
109683 +tg3_nvram_write_block_56666 tg3_nvram_write_block 3 56666 NULL
109684 +btrfs_cow_block_56678 btrfs_cow_block 0 56678 NULL
109685 +snd_gus_dram_read_56686 snd_gus_dram_read 4 56686 NULL nohasharray
109686 +da9055_gpio_to_irq_56686 da9055_gpio_to_irq 2 56686 &snd_gus_dram_read_56686
109687 +build_map_info_56696 build_map_info 2 56696 NULL
109688 +dvb_ringbuffer_read_user_56702 dvb_ringbuffer_read_user 3-0 56702 NULL
109689 +sta_flags_read_56710 sta_flags_read 3 56710 NULL
109690 +ipv6_getsockopt_sticky_56711 ipv6_getsockopt_sticky 5 56711 NULL
109691 +__wa_xfer_setup_segs_56725 __wa_xfer_setup_segs 2 56725 NULL
109692 +__copy_from_user_ll_56738 __copy_from_user_ll 0-3 56738 NULL
109693 +pcpu_populate_chunk_56741 pcpu_populate_chunk 3-2 56741 NULL
109694 +drm_agp_bind_pages_56748 drm_agp_bind_pages 3 56748 NULL
109695 +btrfsic_map_block_56751 btrfsic_map_block 2 56751 NULL
109696 +alloc_iommu_56778 alloc_iommu 2-3-0 56778 NULL
109697 +hash_lookup_56792 hash_lookup 2 56792 NULL nohasharray
109698 +ttm_alloc_new_pages_56792 ttm_alloc_new_pages 5 56792 &hash_lookup_56792
109699 +do_syslog_56807 do_syslog 3 56807 NULL
109700 +ext4_ext_rm_idx_56827 ext4_ext_rm_idx 0 56827 NULL
109701 +mtdchar_write_56831 mtdchar_write 3 56831 NULL nohasharray
109702 +ntfs_rl_realloc_56831 ntfs_rl_realloc 3 56831 &mtdchar_write_56831
109703 +sysctl_sync_threshold_56835 sysctl_sync_threshold 0 56835 NULL
109704 +snd_rawmidi_kernel_write1_56847 snd_rawmidi_kernel_write1 4-0 56847 NULL
109705 +si476x_radio_read_agc_blob_56849 si476x_radio_read_agc_blob 3 56849 NULL
109706 +wb_lookup_56858 wb_lookup 2 56858 NULL
109707 +ext3_xattr_ibody_get_56880 ext3_xattr_ibody_get 0 56880 NULL
109708 +pvr2_debugifc_print_status_56890 pvr2_debugifc_print_status 3 56890 NULL
109709 +debug_debug3_read_56894 debug_debug3_read 3 56894 NULL
109710 +batadv_tt_update_changes_56895 batadv_tt_update_changes 3 56895 NULL
109711 +hfsplus_find_cat_56899 hfsplus_find_cat 0 56899 NULL
109712 +hfsplus_setxattr_56902 hfsplus_setxattr 4 56902 NULL
109713 +__bitmap_clear_bits_56912 __bitmap_clear_bits 3 56912 NULL
109714 +strcspn_56913 strcspn 0 56913 NULL
109715 +__kfifo_out_56927 __kfifo_out 0-3 56927 NULL
109716 +CopyBufferToControlPacket_56933 CopyBufferToControlPacket 0 56933 NULL nohasharray
109717 +journal_init_revoke_56933 journal_init_revoke 2 56933 &CopyBufferToControlPacket_56933
109718 +nouveau_xtensa_create__56952 nouveau_xtensa_create_ 8 56952 NULL
109719 +diva_get_driver_info_56967 diva_get_driver_info 0 56967 NULL
109720 +nouveau_device_create__56984 nouveau_device_create_ 6 56984 NULL
109721 +sptlrpc_secflags2str_56995 sptlrpc_secflags2str 3 56995 NULL
109722 +vlsi_alloc_ring_57003 vlsi_alloc_ring 3-4 57003 NULL
109723 +btrfs_super_csum_size_57004 btrfs_super_csum_size 0 57004 NULL
109724 +aircable_process_packet_57027 aircable_process_packet 4 57027 NULL
109725 +i915_gem_evict_everything_57038 i915_gem_evict_everything 0 57038 NULL
109726 +skb_network_offset_57043 skb_network_offset 0 57043 NULL nohasharray
109727 +ieee80211_if_fmt_state_57043 ieee80211_if_fmt_state 3 57043 &skb_network_offset_57043
109728 +bytes_to_samples_57049 bytes_to_samples 0-2 57049 NULL
109729 +xfs_buf_read_map_57053 xfs_buf_read_map 3 57053 NULL
109730 +__wl_get_peb_57058 __wl_get_peb 0 57058 NULL
109731 +cx2341x_ctrl_new_std_57061 cx2341x_ctrl_new_std 4 57061 NULL
109732 +sca3000_read_data_57064 sca3000_read_data 4 57064 NULL
109733 +pcmcia_replace_cis_57066 pcmcia_replace_cis 3 57066 NULL
109734 +tracing_set_trace_write_57096 tracing_set_trace_write 3 57096 NULL
109735 +altera_get_note_57099 altera_get_note 6 57099 NULL
109736 +hpfs_readpages_57106 hpfs_readpages 4 57106 NULL
109737 +snd_pcm_hw_params_old_user_57108 snd_pcm_hw_params_old_user 0 57108 NULL
109738 +crypto_compress_ctxsize_57109 crypto_compress_ctxsize 0 57109 NULL
109739 +sysfs_write_file_57116 sysfs_write_file 3 57116 NULL
109740 +cipso_v4_gentag_loc_57119 cipso_v4_gentag_loc 0 57119 NULL
109741 +nl80211_send_deauth_57136 nl80211_send_deauth 4 57136 NULL nohasharray
109742 +rds_ib_sub_signaled_57136 rds_ib_sub_signaled 2 57136 &nl80211_send_deauth_57136 nohasharray
109743 +ima_show_htable_value_57136 ima_show_htable_value 2 57136 &rds_ib_sub_signaled_57136
109744 +snd_sonicvibes_getdmac_57140 snd_sonicvibes_getdmac 0 57140 NULL
109745 +changed_inode_57156 changed_inode 0 57156 NULL
109746 +udl_prime_create_57159 udl_prime_create 2 57159 NULL
109747 +__ipath_get_user_pages_57166 __ipath_get_user_pages 1-2 57166 NULL
109748 +stk_prepare_sio_buffers_57168 stk_prepare_sio_buffers 2 57168 NULL
109749 +rx_hw_stuck_read_57179 rx_hw_stuck_read 3 57179 NULL
109750 +ocfs2_claim_metadata_57192 ocfs2_claim_metadata 0 57192 NULL
109751 +tt3650_ci_msg_57219 tt3650_ci_msg 4 57219 NULL
109752 +dma_fifo_alloc_57236 dma_fifo_alloc 5-3-2 57236 NULL
109753 +flush_space_57241 flush_space 3-0 57241 NULL
109754 +rsxx_cram_write_57244 rsxx_cram_write 3 57244 NULL
109755 +ieee80211_if_fmt_tsf_57249 ieee80211_if_fmt_tsf 3 57249 NULL
109756 +oprofilefs_ulong_from_user_57251 oprofilefs_ulong_from_user 3 57251 NULL
109757 +alloc_flex_gd_57259 alloc_flex_gd 1 57259 NULL
109758 +lbs_sleepparams_write_57283 lbs_sleepparams_write 3 57283 NULL
109759 +pstore_file_read_57288 pstore_file_read 3 57288 NULL
109760 +snd_pcm_read_57289 snd_pcm_read 3 57289 NULL
109761 +fw_file_size_57307 fw_file_size 0 57307 NULL
109762 +ftdi_elan_write_57309 ftdi_elan_write 3 57309 NULL
109763 +write_file_regval_57313 write_file_regval 3 57313 NULL
109764 +__mxt_write_reg_57326 __mxt_write_reg 3 57326 NULL
109765 +ocfs2_xattr_shrink_size_57328 ocfs2_xattr_shrink_size 3 57328 NULL
109766 +usblp_read_57342 usblp_read 3 57342 NULL
109767 +print_devstats_dot11RTSFailureCount_57347 print_devstats_dot11RTSFailureCount 3 57347 NULL
109768 +dio_send_cur_page_57348 dio_send_cur_page 0 57348 NULL
109769 +tipc_bclink_stats_57372 tipc_bclink_stats 2 57372 NULL
109770 +max8997_irq_domain_map_57375 max8997_irq_domain_map 2 57375 NULL
109771 +tty_register_device_attr_57381 tty_register_device_attr 2 57381 NULL
109772 +read_file_blob_57406 read_file_blob 3 57406 NULL
109773 +enclosure_register_57412 enclosure_register 3 57412 NULL
109774 +compat_keyctl_instantiate_key_iov_57431 compat_keyctl_instantiate_key_iov 3 57431 NULL
109775 +copy_to_user_fromio_57432 copy_to_user_fromio 3 57432 NULL
109776 +__roundup_pow_of_two_57461 __roundup_pow_of_two 0 57461 NULL
109777 +crypto_tfm_alg_blocksize_57463 crypto_tfm_alg_blocksize 0 57463 NULL
109778 +sisusb_clear_vram_57466 sisusb_clear_vram 2-3 57466 NULL
109779 +blk_flush_cur_seq_57467 blk_flush_cur_seq 0 57467 NULL
109780 +ieee80211_if_read_flags_57470 ieee80211_if_read_flags 3 57470 NULL nohasharray
109781 +sep_lock_user_pages_57470 sep_lock_user_pages 2-3 57470 &ieee80211_if_read_flags_57470
109782 +ocfs2_write_cluster_57483 ocfs2_write_cluster 9-8-2 57483 NULL
109783 +bnad_debugfs_write_regwr_57500 bnad_debugfs_write_regwr 3 57500 NULL
109784 +skb_headlen_57501 skb_headlen 0 57501 NULL
109785 +copy_in_user_57502 copy_in_user 3 57502 NULL
109786 +ckhdid_printf_57505 ckhdid_printf 2 57505 NULL
109787 +init_tag_map_57515 init_tag_map 3 57515 NULL
109788 +wil_read_file_ssid_57517 wil_read_file_ssid 3 57517 NULL nohasharray
109789 +il_dbgfs_force_reset_read_57517 il_dbgfs_force_reset_read 3 57517 &wil_read_file_ssid_57517 nohasharray
109790 +btrfs_insert_inode_extref_57517 btrfs_insert_inode_extref 0 57517 &il_dbgfs_force_reset_read_57517
109791 +cmm_read_57520 cmm_read 3 57520 NULL
109792 +inode_permission_57531 inode_permission 0 57531 NULL
109793 +acpi_dev_get_resources_57534 acpi_dev_get_resources 0 57534 NULL
109794 +ptlrpc_lprocfs_hp_ratio_seq_write_57537 ptlrpc_lprocfs_hp_ratio_seq_write 3 57537 NULL
109795 +ReadHDLCPnP_57559 ReadHDLCPnP 0 57559 NULL nohasharray
109796 +ext4_group_first_block_no_57559 ext4_group_first_block_no 0-2 57559 &ReadHDLCPnP_57559
109797 +obd_unpackmd_57563 obd_unpackmd 0 57563 NULL
109798 +snd_pcm_playback_ioctl1_57569 snd_pcm_playback_ioctl1 0 57569 NULL
109799 +get_bridge_ifindices_57579 get_bridge_ifindices 0 57579 NULL
109800 +ldlm_cli_enqueue_local_57582 ldlm_cli_enqueue_local 11 57582 NULL
109801 +il_dbgfs_interrupt_write_57591 il_dbgfs_interrupt_write 3 57591 NULL
109802 +read_file_spectral_fft_period_57593 read_file_spectral_fft_period 3 57593 NULL
109803 +wm831x_gpio_to_irq_57614 wm831x_gpio_to_irq 2 57614 NULL
109804 +vma_kernel_pagesize_57616 vma_kernel_pagesize 0 57616 NULL
109805 +tx_tx_retry_template_read_57623 tx_tx_retry_template_read 3 57623 NULL
109806 +sisusbcon_putcs_57630 sisusbcon_putcs 3 57630 NULL
109807 +mem_read_57631 mem_read 3 57631 NULL
109808 +tc3589x_irq_map_57639 tc3589x_irq_map 2 57639 NULL
109809 +r3964_write_57662 r3964_write 4 57662 NULL
109810 +proc_ns_readlink_57664 proc_ns_readlink 3 57664 NULL
109811 +__lgwrite_57669 __lgwrite 4 57669 NULL
109812 +f1x_match_to_this_node_57695 f1x_match_to_this_node 3 57695 NULL
109813 +i2400m_rx_stats_read_57706 i2400m_rx_stats_read 3 57706 NULL
109814 +snd_interval_value_57713 snd_interval_value 0 57713 NULL
109815 +ieee80211_if_read_dot11MeshHWMPconfirmationInterval_57722 ieee80211_if_read_dot11MeshHWMPconfirmationInterval 3 57722 NULL
109816 +i915_gem_object_get_pages_57734 i915_gem_object_get_pages 0 57734 NULL
109817 +nouveau_gpio_create__57735 nouveau_gpio_create_ 4-5 57735 NULL
109818 +compat_sys_set_mempolicy_57742 compat_sys_set_mempolicy 3 57742 NULL nohasharray
109819 +pppol2tp_recvmsg_57742 pppol2tp_recvmsg 4 57742 &compat_sys_set_mempolicy_57742
109820 +ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval_57762 ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval 3 57762 NULL
109821 +SYSC_process_vm_writev_57776 SYSC_process_vm_writev 5-3 57776 NULL
109822 +apei_exec_collect_resources_57788 apei_exec_collect_resources 0 57788 NULL
109823 +ld2_57794 ld2 0 57794 NULL
109824 +ivtv_read_57796 ivtv_read 3 57796 NULL
109825 +generic_ptrace_peekdata_57806 generic_ptrace_peekdata 2 57806 NULL
109826 +ipath_user_sdma_num_pages_57813 ipath_user_sdma_num_pages 0 57813 NULL
109827 +bfad_debugfs_read_regrd_57830 bfad_debugfs_read_regrd 3 57830 NULL
109828 +copy_to_user_57835 copy_to_user 3-0 57835 NULL
109829 +flash_read_57843 flash_read 3 57843 NULL
109830 +kiblnd_create_tx_pool_57846 kiblnd_create_tx_pool 2 57846 NULL
109831 +process_all_new_xattrs_57881 process_all_new_xattrs 0 57881 NULL
109832 +xt_alloc_table_info_57903 xt_alloc_table_info 1 57903 NULL
109833 +iio_read_first_n_kfifo_57910 iio_read_first_n_kfifo 2 57910 NULL nohasharray
109834 +atomic_add_return_unchecked_57910 atomic_add_return_unchecked 0-1 57910 &iio_read_first_n_kfifo_57910
109835 +memcg_caches_array_size_57918 memcg_caches_array_size 0-1 57918 NULL
109836 +twl_i2c_write_57923 twl_i2c_write 3-4 57923 NULL
109837 +__snd_gf1_look16_57925 __snd_gf1_look16 0 57925 NULL
109838 +sel_read_handle_unknown_57933 sel_read_handle_unknown 3 57933 NULL
109839 +nvc0_vm_create_57942 nvc0_vm_create 2-3 57942 NULL
109840 +xfs_mru_cache_create_57943 xfs_mru_cache_create 3 57943 NULL
109841 +key_algorithm_read_57946 key_algorithm_read 3 57946 NULL
109842 +ip_set_alloc_57953 ip_set_alloc 1 57953 NULL nohasharray
109843 +ioat3_dca_count_dca_slots_57953 ioat3_dca_count_dca_slots 0 57953 &ip_set_alloc_57953
109844 +c2_reg_user_mr_57982 c2_reg_user_mr 2-3 57982 NULL
109845 +interleave_nodes_57992 interleave_nodes 0 57992 NULL
109846 +do_rx_dma_57996 do_rx_dma 5 57996 NULL
109847 +rx_reset_counter_read_58001 rx_reset_counter_read 3 58001 NULL
109848 +iwl_dbgfs_ucode_rx_stats_read_58023 iwl_dbgfs_ucode_rx_stats_read 3 58023 NULL
109849 +io_playback_transfer_58030 io_playback_transfer 4 58030 NULL
109850 +ext4_block_bitmap_58033 ext4_block_bitmap 0 58033 NULL
109851 +mce_async_out_58056 mce_async_out 3 58056 NULL
109852 +ocfs2_find_leaf_58065 ocfs2_find_leaf 0 58065 NULL
109853 +dt3155_alloc_coherent_58073 dt3155_alloc_coherent 2 58073 NULL
109854 +cm4040_write_58079 cm4040_write 3 58079 NULL
109855 +ipv6_flowlabel_opt_58135 ipv6_flowlabel_opt 3 58135 NULL nohasharray
109856 +slhc_init_58135 slhc_init 2-1 58135 &ipv6_flowlabel_opt_58135
109857 +ocfs2_reserve_clusters_58164 ocfs2_reserve_clusters 0 58164 NULL
109858 +ext4_bg_num_gdb_58171 ext4_bg_num_gdb 0 58171 NULL
109859 +garmin_write_bulk_58191 garmin_write_bulk 3 58191 NULL
109860 +ieee80211_if_fmt_flags_58205 ieee80211_if_fmt_flags 3 58205 NULL
109861 +sysfs_add_file_mode_58222 sysfs_add_file_mode 0 58222 NULL
109862 +hva_to_pfn_58241 hva_to_pfn 1-0 58241 NULL
109863 +btrfsic_create_link_to_next_block_58246 btrfsic_create_link_to_next_block 4 58246 NULL
109864 +read_file_debug_58256 read_file_debug 3 58256 NULL
109865 +osc_max_dirty_mb_seq_write_58263 osc_max_dirty_mb_seq_write 3 58263 NULL
109866 +cfg80211_mgmt_tx_status_58266 cfg80211_mgmt_tx_status 4 58266 NULL
109867 +profile_load_58267 profile_load 3 58267 NULL
109868 +kstrtos8_from_user_58268 kstrtos8_from_user 2 58268 NULL
109869 +acpi_ds_build_internal_package_obj_58271 acpi_ds_build_internal_package_obj 3 58271 NULL
109870 +iscsi_decode_text_input_58292 iscsi_decode_text_input 4 58292 NULL
109871 +intel_alloc_coherent_58302 intel_alloc_coherent 2 58302 NULL
109872 +ieee80211_if_read_dot11MeshTTL_58307 ieee80211_if_read_dot11MeshTTL 3 58307 NULL
109873 +i915_wait_seqno_58309 i915_wait_seqno 0 58309 NULL
109874 +tx_tx_start_int_templates_read_58324 tx_tx_start_int_templates_read 3 58324 NULL
109875 +ext4_ext_truncate_extend_restart_58331 ext4_ext_truncate_extend_restart 3 58331 NULL
109876 +diva_init_dma_map_58336 diva_init_dma_map 3 58336 NULL
109877 +__copy_from_user_swizzled_58337 __copy_from_user_swizzled 2-4 58337 NULL
109878 +next_pidmap_58347 next_pidmap 2-0 58347 NULL
109879 +SyS_migrate_pages_58348 SyS_migrate_pages 2 58348 NULL
109880 +save_hint_58359 save_hint 2 58359 NULL
109881 +vmw_ttm_tt_create_58369 vmw_ttm_tt_create 2 58369 NULL nohasharray
109882 +brcmf_debugfs_sdio_counter_read_58369 brcmf_debugfs_sdio_counter_read 3 58369 &vmw_ttm_tt_create_58369
109883 +hash_ipportnet6_expire_58379 hash_ipportnet6_expire 3 58379 NULL
109884 +il_dbgfs_status_read_58388 il_dbgfs_status_read 3 58388 NULL
109885 +_drbd_md_sync_page_io_58403 _drbd_md_sync_page_io 6 58403 NULL
109886 +kvm_mmu_write_protect_pt_masked_58406 kvm_mmu_write_protect_pt_masked 3-4 58406 NULL nohasharray
109887 +idetape_pad_zeros_58406 idetape_pad_zeros 2 58406 &kvm_mmu_write_protect_pt_masked_58406
109888 +i2400m_pld_size_58415 i2400m_pld_size 0 58415 NULL
109889 +__mlx4_alloc_mtt_range_58418 __mlx4_alloc_mtt_range 2 58418 NULL
109890 +capabilities_read_58457 capabilities_read 3 58457 NULL
109891 +batadv_iv_ogm_aggr_packet_58462 batadv_iv_ogm_aggr_packet 3 58462 NULL
109892 +lpfc_idiag_baracc_read_58466 lpfc_idiag_baracc_read 3 58466 NULL nohasharray
109893 +compat_do_ipt_set_ctl_58466 compat_do_ipt_set_ctl 4 58466 &lpfc_idiag_baracc_read_58466
109894 +nv_rd08_58472 nv_rd08 0 58472 NULL
109895 +snd_gf1_read_addr_58483 snd_gf1_read_addr 0 58483 NULL
109896 +snd_rme96_capture_copy_58484 snd_rme96_capture_copy 5 58484 NULL
109897 +btrfs_cont_expand_58498 btrfs_cont_expand 2-3 58498 NULL
109898 +rndis_add_response_58544 rndis_add_response 2 58544 NULL
109899 +__clear_discard_58546 __clear_discard 2 58546 NULL
109900 +wrap_max_58548 wrap_max 0-1-2 58548 NULL
109901 +wep_decrypt_fail_read_58567 wep_decrypt_fail_read 3 58567 NULL
109902 +scnprint_mac_oui_58578 scnprint_mac_oui 3-0 58578 NULL
109903 +get_rhf_errstring_58582 get_rhf_errstring 3 58582 NULL
109904 +ea_read_inline_58589 ea_read_inline 0 58589 NULL
109905 +isku_sysfs_read_keys_thumbster_58590 isku_sysfs_read_keys_thumbster 6 58590 NULL
109906 +xip_file_read_58592 xip_file_read 3 58592 NULL
109907 +ecryptfs_write_end_58594 ecryptfs_write_end 5-3 58594 NULL
109908 +radeon_bo_size_58606 radeon_bo_size 0 58606 NULL
109909 +ebt_buf_count_58607 ebt_buf_count 0 58607 NULL
109910 +xfs_iomap_write_delay_58616 xfs_iomap_write_delay 2 58616 NULL
109911 +skb_copy_to_page_nocache_58624 skb_copy_to_page_nocache 6 58624 NULL
109912 +filemap_fdatawrite_range_58630 filemap_fdatawrite_range 0 58630 NULL
109913 +vb2_qbuf_58631 vb2_qbuf 0 58631 NULL
109914 +module_alloc_update_bounds_rx_58634 module_alloc_update_bounds_rx 1 58634 NULL
109915 +tx_tx_start_fw_gen_read_58648 tx_tx_start_fw_gen_read 3 58648 NULL
109916 +ocfs2_block_to_cluster_start_58653 ocfs2_block_to_cluster_start 2 58653 NULL
109917 +iwl_dbgfs_rx_handlers_write_58655 iwl_dbgfs_rx_handlers_write 3 58655 NULL
109918 +__gfn_to_pfn_58671 __gfn_to_pfn 2 58671 NULL
109919 +find_zero_58685 find_zero 0-1 58685 NULL
109920 +uwb_bce_print_IEs_58686 uwb_bce_print_IEs 4 58686 NULL
109921 +tps6586x_writes_58689 tps6586x_writes 2-3 58689 NULL
109922 +vmalloc_node_58700 vmalloc_node 1-2 58700 NULL
109923 +vx_send_msg_58711 vx_send_msg 0 58711 NULL
109924 +i915_gem_execbuffer_reserve_58722 i915_gem_execbuffer_reserve 0 58722 NULL
109925 +da9052_gpio_to_irq_58729 da9052_gpio_to_irq 2 58729 NULL
109926 +csum_exist_in_range_58730 csum_exist_in_range 2-3 58730 NULL
109927 +frames_to_bytes_58741 frames_to_bytes 0-2 58741 NULL
109928 +ieee80211_if_write_tkip_mic_test_58748 ieee80211_if_write_tkip_mic_test 3 58748 NULL
109929 +agp_allocate_memory_58761 agp_allocate_memory 2 58761 NULL
109930 +oblock_to_dblock_58762 oblock_to_dblock 0-2 58762 NULL
109931 +regmap_calc_reg_len_58795 regmap_calc_reg_len 0 58795 NULL
109932 +raw_send_hdrinc_58803 raw_send_hdrinc 4 58803 NULL
109933 +isku_sysfs_read_58806 isku_sysfs_read 5 58806 NULL
109934 +write_file_58812 write_file 4 58812 NULL
109935 +ep_read_58813 ep_read 3 58813 NULL
109936 +command_write_58841 command_write 3 58841 NULL
109937 +ocfs2_truncate_log_append_58850 ocfs2_truncate_log_append 3-0 58850 NULL
109938 +ath6kl_wmi_send_action_cmd_58860 ath6kl_wmi_send_action_cmd 7 58860 NULL
109939 +gs_alloc_req_58883 gs_alloc_req 2 58883 NULL
109940 +esas2r_change_queue_depth_58886 esas2r_change_queue_depth 2 58886 NULL
109941 +lprocfs_wr_pinger_recov_58914 lprocfs_wr_pinger_recov 3 58914 NULL
109942 +print_devstats_dot11FCSErrorCount_58919 print_devstats_dot11FCSErrorCount 3 58919 NULL
109943 +pipeline_cs_rx_packet_out_read_58926 pipeline_cs_rx_packet_out_read 3 58926 NULL
109944 +SyS_pread64_58935 SyS_pread64 3 58935 NULL
109945 +wait_table_hash_nr_entries_58962 wait_table_hash_nr_entries 0 58962 NULL
109946 +ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout_58965 ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout 3 58965 NULL
109947 +crypto_aead_ivsize_58970 crypto_aead_ivsize 0 58970 NULL
109948 +__mem_cgroup_try_charge_58976 __mem_cgroup_try_charge 0 58976 NULL
109949 +init_list_58990 init_list 3 58990 NULL
109950 +remap_to_cache_dirty_58991 remap_to_cache_dirty 4-3 58991 NULL
109951 +ep_write_59008 ep_write 3 59008 NULL
109952 +lpfc_idiag_baracc_write_59014 lpfc_idiag_baracc_write 3 59014 NULL
109953 +SyS_preadv_59029 SyS_preadv 3 59029 NULL
109954 +init_pci_cap_msi_perm_59033 init_pci_cap_msi_perm 2 59033 NULL
109955 +selinux_transaction_write_59038 selinux_transaction_write 3 59038 NULL
109956 +crypto_aead_reqsize_59039 crypto_aead_reqsize 0 59039 NULL
109957 +regmap_bulk_write_59049 regmap_bulk_write 2-4 59049 NULL
109958 +sysfs_link_sibling_59078 sysfs_link_sibling 0 59078 NULL
109959 +do_perf_sw_event_59099 do_perf_sw_event 3 59099 NULL
109960 +mmc_sd_num_wr_blocks_59112 mmc_sd_num_wr_blocks 0 59112 NULL
109961 +scsi_io_completion_59122 scsi_io_completion 2 59122 NULL
109962 +init_status_page_59124 init_status_page 0 59124 NULL
109963 +nfc_llcp_send_i_frame_59130 nfc_llcp_send_i_frame 3 59130 NULL
109964 +print_devstats_dot11RTSSuccessCount_59145 print_devstats_dot11RTSSuccessCount 3 59145 NULL nohasharray
109965 +framebuffer_alloc_59145 framebuffer_alloc 1 59145 &print_devstats_dot11RTSSuccessCount_59145
109966 +ocfs2_claim_local_alloc_bits_59147 ocfs2_claim_local_alloc_bits 0 59147 NULL
109967 +radeon_compat_ioctl_59150 radeon_compat_ioctl 2 59150 NULL
109968 +pvr2_hdw_report_clients_59152 pvr2_hdw_report_clients 3 59152 NULL
109969 +ksize_59176 ksize 0 59176 NULL
109970 +setup_window_59178 setup_window 4-2-5-7 59178 NULL
109971 +ocfs2_move_extent_59187 ocfs2_move_extent 3-5-2 59187 NULL
109972 +validate_exec_list_59204 validate_exec_list 0 59204 NULL
109973 +xfs_iext_realloc_indirect_59211 xfs_iext_realloc_indirect 2 59211 NULL
109974 +check_mapped_selector_name_59216 check_mapped_selector_name 5 59216 NULL
109975 +dt3155_read_59226 dt3155_read 3 59226 NULL
109976 +paging64_gpte_to_gfn_lvl_59229 paging64_gpte_to_gfn_lvl 0-1-2 59229 NULL
109977 +tty_prepare_flip_string_flags_59240 tty_prepare_flip_string_flags 4 59240 NULL
109978 +nla_len_59258 nla_len 0 59258 NULL
109979 +drbd_bm_write_page_59290 drbd_bm_write_page 2 59290 NULL
109980 +__push_leaf_right_59302 __push_leaf_right 0 59302 NULL
109981 +btrfs_insert_dir_item_59304 btrfs_insert_dir_item 4-0 59304 NULL
109982 +fd_copyout_59323 fd_copyout 3 59323 NULL
109983 +read_9287_modal_eeprom_59327 read_9287_modal_eeprom 3 59327 NULL
109984 +rx_defrag_in_process_called_read_59338 rx_defrag_in_process_called_read 3 59338 NULL
109985 +paging64_get_level1_sp_gpa_59346 paging64_get_level1_sp_gpa 0 59346 NULL nohasharray
109986 +xfs_attrmulti_attr_set_59346 xfs_attrmulti_attr_set 4 59346 &paging64_get_level1_sp_gpa_59346
109987 +__map_request_59350 __map_request 0 59350 NULL
109988 +xfs_dir2_sf_entsize_59366 xfs_dir2_sf_entsize 0-2 59366 NULL
109989 +blk_flush_policy_59368 blk_flush_policy 0 59368 NULL
109990 +f2fs_fallocate_59377 f2fs_fallocate 3-4 59377 NULL
109991 +pvr2_debugifc_print_info_59380 pvr2_debugifc_print_info 3 59380 NULL
109992 +ocfs2_replay_truncate_records_59382 ocfs2_replay_truncate_records 0 59382 NULL
109993 +journal_init_dev_59384 journal_init_dev 5 59384 NULL
109994 +isku_sysfs_read_keys_function_59412 isku_sysfs_read_keys_function 6 59412 NULL
109995 +pci_ctrl_read_59424 pci_ctrl_read 0 59424 NULL
109996 +vxge_hw_ring_rxds_per_block_get_59425 vxge_hw_ring_rxds_per_block_get 0 59425 NULL
109997 +snd_pcm_tstamp_59431 snd_pcm_tstamp 0 59431 NULL
109998 +SyS_sched_setaffinity_59442 SyS_sched_setaffinity 2 59442 NULL
109999 +fs_path_ensure_buf_59445 fs_path_ensure_buf 2-0 59445 NULL
110000 +descriptor_loc_59446 descriptor_loc 3 59446 NULL
110001 +block_rsv_use_bytes_59464 block_rsv_use_bytes 0 59464 NULL
110002 +shrink_tnc_trees_59481 shrink_tnc_trees 0 59481 NULL
110003 +btrfs_del_dir_entries_in_log_59490 btrfs_del_dir_entries_in_log 0 59490 NULL
110004 +ib_copy_from_udata_59502 ib_copy_from_udata 3 59502 NULL
110005 +rds_pin_pages_59507 rds_pin_pages 1-2 59507 NULL
110006 +ext4_resize_fs_59543 ext4_resize_fs 2 59543 NULL
110007 +mpi_get_nbits_59551 mpi_get_nbits 0 59551 NULL
110008 +tunables_write_59563 tunables_write 3 59563 NULL
110009 +__copy_from_user_ll_nozero_59571 __copy_from_user_ll_nozero 0-3 59571 NULL
110010 +write_pbl_59583 write_pbl 4 59583 NULL
110011 +memdup_user_59590 memdup_user 2 59590 NULL
110012 +tps6586x_irq_get_virq_59601 tps6586x_irq_get_virq 2 59601 NULL
110013 +mem_fwlog_free_mem_blks_read_59616 mem_fwlog_free_mem_blks_read 3 59616 NULL nohasharray
110014 +xrcdn_free_res_59616 xrcdn_free_res 5 59616 &mem_fwlog_free_mem_blks_read_59616
110015 +ath6kl_endpoint_stats_write_59621 ath6kl_endpoint_stats_write 3 59621 NULL
110016 +mtrr_write_59622 mtrr_write 3 59622 NULL
110017 +ocfs2_adjust_rightmost_branch_59623 ocfs2_adjust_rightmost_branch 0 59623 NULL
110018 +find_first_zero_bit_59636 find_first_zero_bit 0-2 59636 NULL
110019 +SyS_setdomainname_59646 SyS_setdomainname 2 59646 NULL
110020 +hidraw_read_59650 hidraw_read 3 59650 NULL
110021 +v9fs_xattr_set_acl_59651 v9fs_xattr_set_acl 4 59651 NULL
110022 +paravirt_sched_clock_59660 paravirt_sched_clock 0 59660 NULL
110023 +__devcgroup_check_permission_59665 __devcgroup_check_permission 0 59665 NULL
110024 +iwl_dbgfs_mac_params_read_59666 iwl_dbgfs_mac_params_read 3 59666 NULL
110025 +alloc_dca_provider_59670 alloc_dca_provider 2 59670 NULL
110026 +mic_calc_failure_read_59700 mic_calc_failure_read 3 59700 NULL
110027 +ioperm_get_59701 ioperm_get 4-3 59701 NULL
110028 +snd_pcm_info_user_59711 snd_pcm_info_user 0 59711 NULL
110029 +prism2_info_scanresults_59729 prism2_info_scanresults 3 59729 NULL
110030 +ieee80211_if_read_fwded_unicast_59740 ieee80211_if_read_fwded_unicast 3 59740 NULL
110031 +fat_direct_IO_59741 fat_direct_IO 4 59741 NULL
110032 +qib_decode_7220_sdma_errs_59745 qib_decode_7220_sdma_errs 4 59745 NULL
110033 +strnlen_59746 strnlen 0 59746 NULL
110034 +process_all_refs_59754 process_all_refs 0 59754 NULL nohasharray
110035 +ext3_acl_count_59754 ext3_acl_count 0-1 59754 &process_all_refs_59754
110036 +process_new_xattr_59755 process_new_xattr 0 59755 NULL
110037 +long_retry_limit_read_59766 long_retry_limit_read 3 59766 NULL
110038 +venus_remove_59781 venus_remove 4 59781 NULL
110039 +mei_nfc_recv_59784 mei_nfc_recv 3 59784 NULL
110040 +xlog_do_recover_59789 xlog_do_recover 3 59789 NULL
110041 +msb_get_zone_from_lba_59800 msb_get_zone_from_lba 0-1 59800 NULL
110042 +ipw_write_59807 ipw_write 3 59807 NULL
110043 +scsi_init_shared_tag_map_59812 scsi_init_shared_tag_map 2 59812 NULL
110044 +ieee80211_if_read_dot11MeshHWMPmaxPREQretries_59829 ieee80211_if_read_dot11MeshHWMPmaxPREQretries 3 59829 NULL
110045 +gspca_dev_probe2_59833 gspca_dev_probe2 4 59833 NULL
110046 +fs64_to_cpu_59845 fs64_to_cpu 0 59845 NULL
110047 +regmap_raw_write_async_59849 regmap_raw_write_async 2-4 59849 NULL
110048 +intel_ring_wait_request_59865 intel_ring_wait_request 0 59865 NULL
110049 +pvr2_ioread_set_sync_key_59882 pvr2_ioread_set_sync_key 3 59882 NULL
110050 +shmem_zero_setup_59885 shmem_zero_setup 0 59885 NULL nohasharray
110051 +start_transaction_59885 start_transaction 2 59885 &shmem_zero_setup_59885
110052 +l2cap_sock_recvmsg_59886 l2cap_sock_recvmsg 4 59886 NULL
110053 +ffs_prepare_buffer_59892 ffs_prepare_buffer 2 59892 NULL
110054 +ocfs2_extend_rotate_transaction_59894 ocfs2_extend_rotate_transaction 0 59894 NULL
110055 +swiotlb_map_page_59909 swiotlb_map_page 3 59909 NULL
110056 +aic7xxx_abort_waiting_scb_59932 aic7xxx_abort_waiting_scb 0 59932 NULL
110057 +kvm_mmu_notifier_invalidate_range_start_59944 kvm_mmu_notifier_invalidate_range_start 3-4 59944 NULL
110058 +ocfs2_expand_inline_ref_root_59945 ocfs2_expand_inline_ref_root 0 59945 NULL
110059 +il_dbgfs_rxon_flags_read_59950 il_dbgfs_rxon_flags_read 3 59950 NULL nohasharray
110060 +dapm_widget_power_read_file_59950 dapm_widget_power_read_file 3 59950 &il_dbgfs_rxon_flags_read_59950
110061 +lookup_node_59953 lookup_node 2 59953 NULL
110062 +il_dbgfs_missed_beacon_read_59956 il_dbgfs_missed_beacon_read 3 59956 NULL
110063 +kvm_set_cr3_59965 kvm_set_cr3 2 59965 NULL
110064 +__arch_hweight16_59975 __arch_hweight16 0 59975 NULL
110065 +osd_req_read_kern_59990 osd_req_read_kern 5 59990 NULL
110066 +ghash_async_setkey_60001 ghash_async_setkey 3 60001 NULL
110067 +ieee80211_if_fmt_dot11MeshAwakeWindowDuration_60006 ieee80211_if_fmt_dot11MeshAwakeWindowDuration 3 60006 NULL
110068 +rawsock_sendmsg_60010 rawsock_sendmsg 4 60010 NULL
110069 +mthca_init_cq_60011 mthca_init_cq 2 60011 NULL
110070 +osd_req_list_dev_partitions_60027 osd_req_list_dev_partitions 4 60027 NULL
110071 +xlog_bread_offset_60030 xlog_bread_offset 3 60030 NULL
110072 +bio_integrity_hw_sectors_60039 bio_integrity_hw_sectors 0-2 60039 NULL
110073 +do_ip6t_set_ctl_60040 do_ip6t_set_ctl 4 60040 NULL
110074 +vcs_size_60050 vcs_size 0 60050 NULL nohasharray
110075 +pin_2_irq_60050 pin_2_irq 0-3 60050 &vcs_size_60050
110076 +gru_alloc_gts_60056 gru_alloc_gts 3-2 60056 NULL
110077 +open_cur_inode_file_60057 open_cur_inode_file 0 60057 NULL
110078 +compat_writev_60063 compat_writev 3 60063 NULL
110079 +ath6kl_listen_int_write_60066 ath6kl_listen_int_write 3 60066 NULL
110080 +c4iw_num_stags_60073 c4iw_num_stags 0 60073 NULL
110081 +mp_register_gsi_60079 mp_register_gsi 2 60079 NULL
110082 +rxrpc_kernel_send_data_60083 rxrpc_kernel_send_data 3 60083 NULL
110083 +ieee80211_if_fmt_fwded_frames_60103 ieee80211_if_fmt_fwded_frames 3 60103 NULL
110084 +SYSC_msgsnd_60113 SYSC_msgsnd 3 60113 NULL
110085 +nfs_idmap_request_key_60124 nfs_idmap_request_key 2 60124 NULL
110086 +__mutex_lock_common_60134 __mutex_lock_common 0 60134 NULL
110087 +ld_usb_read_60156 ld_usb_read 3 60156 NULL
110088 +jmb38x_ms_count_slots_60164 jmb38x_ms_count_slots 0 60164 NULL
110089 +init_state_60165 init_state 2 60165 NULL
110090 +sg_build_sgat_60179 sg_build_sgat 3 60179 NULL nohasharray
110091 +jffs2_alloc_full_dirent_60179 jffs2_alloc_full_dirent 1 60179 &sg_build_sgat_60179
110092 +fuse_async_req_send_60183 fuse_async_req_send 0-3 60183 NULL
110093 +rx_rx_tkip_replays_read_60193 rx_rx_tkip_replays_read 3 60193 NULL
110094 +qib_reg_phys_mr_60202 qib_reg_phys_mr 3 60202 NULL
110095 +btrfs_get_token_16_60220 btrfs_get_token_16 0 60220 NULL
110096 +arizona_map_irq_60230 arizona_map_irq 2 60230 NULL nohasharray
110097 +__phys_addr_nodebug_60230 __phys_addr_nodebug 0 60230 &arizona_map_irq_60230
110098 +wm831x_irq_60254 wm831x_irq 2 60254 NULL
110099 +irq_alloc_domain_generic_chips_60264 irq_alloc_domain_generic_chips 3-2 60264 NULL
110100 +printer_write_60276 printer_write 3 60276 NULL
110101 +alloc_irq_pin_list_60277 alloc_irq_pin_list 1 60277 NULL
110102 +do_xip_mapping_read_60297 do_xip_mapping_read 5 60297 NULL
110103 +getDataLength_60301 getDataLength 0 60301 NULL
110104 +xfs_next_bit_60322 xfs_next_bit 0-3 60322 NULL
110105 +inorder_to_tree_60331 inorder_to_tree 1-0 60331 NULL
110106 +usb_alphatrack_write_60341 usb_alphatrack_write 3 60341 NULL
110107 +__kfifo_from_user_r_60345 __kfifo_from_user_r 5-3 60345 NULL
110108 +max_unfragmented_pages_60362 max_unfragmented_pages 0 60362 NULL
110109 +dccp_setsockopt_60367 dccp_setsockopt 5 60367 NULL
110110 +ubi_eba_atomic_leb_change_60379 ubi_eba_atomic_leb_change 0-5 60379 NULL
110111 +instruction_pointer_60384 instruction_pointer 0 60384 NULL
110112 +drop_outstanding_extent_60390 drop_outstanding_extent 0 60390 NULL
110113 +mthca_alloc_resize_buf_60394 mthca_alloc_resize_buf 3 60394 NULL
110114 +ocfs2_zero_extend_60396 ocfs2_zero_extend 3 60396 NULL
110115 +driver_names_read_60399 driver_names_read 3 60399 NULL
110116 +paging32_walk_addr_generic_60415 paging32_walk_addr_generic 4 60415 NULL
110117 +simple_alloc_urb_60420 simple_alloc_urb 3 60420 NULL
110118 +excessive_retries_read_60425 excessive_retries_read 3 60425 NULL
110119 +tstats_write_60432 tstats_write 3 60432 NULL nohasharray
110120 +kmalloc_60432 kmalloc 1 60432 &tstats_write_60432
110121 +scaled_div32_60442 scaled_div32 2-1-0 60442 NULL
110122 +snd_hda_get_num_raw_conns_60462 snd_hda_get_num_raw_conns 0 60462 NULL
110123 +crypto_shash_setkey_60483 crypto_shash_setkey 3 60483 NULL
110124 +lustre_msg_early_size_60496 lustre_msg_early_size 0 60496 NULL
110125 +v9fs_fid_readn_60544 v9fs_fid_readn 4 60544 NULL
110126 +nonpaging_map_60551 nonpaging_map 4 60551 NULL
110127 +osc_lockless_truncate_seq_write_60553 osc_lockless_truncate_seq_write 3 60553 NULL
110128 +tracing_entries_write_60563 tracing_entries_write 3 60563 NULL
110129 +hash_net6_expire_60598 hash_net6_expire 3 60598 NULL
110130 +btrfs_add_delayed_tree_ref_60602 btrfs_add_delayed_tree_ref 0 60602 NULL
110131 +skb_transport_offset_60619 skb_transport_offset 0 60619 NULL
110132 +wl1273_fm_fops_write_60621 wl1273_fm_fops_write 3 60621 NULL
110133 +usb_control_msg_60624 usb_control_msg 0 60624 NULL
110134 +acl_alloc_stack_init_60630 acl_alloc_stack_init 1 60630 NULL
110135 +free_dind_blocks_60635 free_dind_blocks 0 60635 NULL
110136 +ubifs_recover_leb_60639 ubifs_recover_leb 3 60639 NULL
110137 +__proc_lnet_stats_60647 __proc_lnet_stats 5 60647 NULL
110138 +mv_ffc64_60648 mv_ffc64 1 60648 NULL
110139 +if_sdio_host_to_card_60666 if_sdio_host_to_card 4 60666 NULL
110140 +run_clustered_refs_60668 run_clustered_refs 0 60668 NULL
110141 +ieee80211_if_read_dot11MeshConfirmTimeout_60670 ieee80211_if_read_dot11MeshConfirmTimeout 3 60670 NULL
110142 +btrfs_reserve_extent_60674 btrfs_reserve_extent 5-0 60674 NULL
110143 +init_data_container_60709 init_data_container 1 60709 NULL
110144 +vga_rcrt_60731 vga_rcrt 0 60731 NULL
110145 +snd_ice1712_ds_read_60754 snd_ice1712_ds_read 0 60754 NULL
110146 +raid_status_60755 raid_status 5 60755 NULL
110147 +sel_write_checkreqprot_60774 sel_write_checkreqprot 3 60774 NULL
110148 +opticon_write_60775 opticon_write 4 60775 NULL
110149 +acl_alloc_num_60778 acl_alloc_num 1-2 60778 NULL
110150 +snd_pcm_oss_readv3_60792 snd_pcm_oss_readv3 3 60792 NULL
110151 +block_rsv_migrate_bytes_60843 block_rsv_migrate_bytes 0 60843 NULL
110152 +pwr_tx_with_ps_read_60851 pwr_tx_with_ps_read 3 60851 NULL
110153 +alloc_buf_60864 alloc_buf 2-3 60864 NULL
110154 +generic_writepages_60871 generic_writepages 0 60871 NULL
110155 +tipc_createport_60875 tipc_createport 4 60875 NULL
110156 +ubifs_read_one_lp_60882 ubifs_read_one_lp 0 60882 NULL
110157 +ext4_update_inline_data_60888 ext4_update_inline_data 3 60888 NULL
110158 +iio_debugfs_read_reg_60908 iio_debugfs_read_reg 3 60908 NULL
110159 +libcfs_sock_ioctl_60915 libcfs_sock_ioctl 0 60915 NULL
110160 +mgt_set_varlen_60916 mgt_set_varlen 4 60916 NULL
110161 +scrub_chunk_60926 scrub_chunk 5 60926 NULL
110162 +submit_extent_page_60928 submit_extent_page 5 60928 NULL
110163 +pti_char_write_60960 pti_char_write 3 60960 NULL
110164 +mwifiex_alloc_sdio_mpa_buffers_60961 mwifiex_alloc_sdio_mpa_buffers 3-2 60961 NULL
110165 +__a2mp_build_60987 __a2mp_build 3 60987 NULL
110166 +hsc_msg_alloc_60990 hsc_msg_alloc 1 60990 NULL
110167 +ath6kl_lrssi_roam_read_61022 ath6kl_lrssi_roam_read 3 61022 NULL
110168 +graph_depth_write_61024 graph_depth_write 3 61024 NULL
110169 +sdhci_pltfm_register_61031 sdhci_pltfm_register 3 61031 NULL
110170 +lpfc_idiag_queacc_write_61043 lpfc_idiag_queacc_write 3 61043 NULL
110171 +symtab_init_61050 symtab_init 2 61050 NULL
110172 +fuse_send_write_61053 fuse_send_write 0-4 61053 NULL
110173 +snd_pcm_pause_61054 snd_pcm_pause 0 61054 NULL
110174 +bitmap_scnlistprintf_61062 bitmap_scnlistprintf 0-4-2 61062 NULL
110175 +ahash_align_buffer_size_61070 ahash_align_buffer_size 0-1-2 61070 NULL
110176 +journal_stop_61080 journal_stop 0 61080 NULL
110177 +snd_pcm_update_hw_ptr0_61084 snd_pcm_update_hw_ptr0 0 61084 NULL
110178 +get_derived_key_61100 get_derived_key 4 61100 NULL
110179 +mem_cgroup_cache_charge_61101 mem_cgroup_cache_charge 0 61101 NULL
110180 +i40e_calculate_l2fpm_size_61104 i40e_calculate_l2fpm_size 0-1-2-3-4 61104 NULL
110181 +alloc_chrdev_region_61112 alloc_chrdev_region 0 61112 NULL
110182 +__probe_kernel_read_61119 __probe_kernel_read 3 61119 NULL
110183 +vmemmap_alloc_block_buf_61126 vmemmap_alloc_block_buf 1 61126 NULL
110184 +afs_proc_cells_write_61139 afs_proc_cells_write 3 61139 NULL
110185 +brcmf_sdio_chip_cr4_exitdl_61143 brcmf_sdio_chip_cr4_exitdl 4 61143 NULL
110186 +__vmalloc_61168 __vmalloc 1 61168 NULL
110187 +event_oom_late_read_61175 event_oom_late_read 3 61175 NULL nohasharray
110188 +pair_device_61175 pair_device 4 61175 &event_oom_late_read_61175
110189 +dio_bio_add_page_61178 dio_bio_add_page 0 61178 NULL
110190 +btrfs_reloc_post_snapshot_61189 btrfs_reloc_post_snapshot 0 61189 NULL
110191 +SyS_prctl_61202 SyS_prctl 4 61202 NULL
110192 +arch_hibernation_header_save_61212 arch_hibernation_header_save 0 61212 NULL
110193 +smk_read_ambient_61220 smk_read_ambient 3 61220 NULL
110194 +__verify_planes_array_61249 __verify_planes_array 0 61249 NULL
110195 +find_get_pages_tag_61270 find_get_pages_tag 0 61270 NULL nohasharray
110196 +ifalias_store_61270 ifalias_store 4 61270 &find_get_pages_tag_61270 nohasharray
110197 +btrfs_bio_alloc_61270 btrfs_bio_alloc 3 61270 &ifalias_store_61270
110198 +kick_a_thread_61273 kick_a_thread 0 61273 NULL
110199 +hfsplus_getxattr_finder_info_61283 hfsplus_getxattr_finder_info 0 61283 NULL nohasharray
110200 +vortex_adbdma_getlinearpos_61283 vortex_adbdma_getlinearpos 0 61283 &hfsplus_getxattr_finder_info_61283
110201 +nvme_trans_copy_to_user_61288 nvme_trans_copy_to_user 3 61288 NULL
110202 +ext4_issue_discard_61305 ext4_issue_discard 2 61305 NULL
110203 +xfer_from_user_61307 xfer_from_user 3 61307 NULL
110204 +ocfs2_get_sector_61309 ocfs2_get_sector 4 61309 NULL
110205 +timespec_to_ns_61317 timespec_to_ns 0 61317 NULL
110206 +xfrm_user_sec_ctx_size_61320 xfrm_user_sec_ctx_size 0 61320 NULL
110207 +C_SYSC_msgsnd_61330 C_SYSC_msgsnd 3 61330 NULL
110208 +write_file_spectral_short_repeat_61335 write_file_spectral_short_repeat 3 61335 NULL
110209 +__fls_61340 __fls 0 61340 NULL nohasharray
110210 +st5481_setup_isocpipes_61340 st5481_setup_isocpipes 6-4 61340 &__fls_61340
110211 +do_splice_direct_61341 do_splice_direct 5 61341 NULL nohasharray
110212 +rx_rx_wa_ba_not_expected_read_61341 rx_rx_wa_ba_not_expected_read 3 61341 &do_splice_direct_61341
110213 +__dm_get_reserved_ios_61342 __dm_get_reserved_ios 0-2-3 61342 NULL
110214 +f1x_map_sysaddr_to_csrow_61344 f1x_map_sysaddr_to_csrow 2 61344 NULL
110215 +kvm_apic_id_61363 kvm_apic_id 0 61363 NULL
110216 +debug_debug4_read_61367 debug_debug4_read 3 61367 NULL
110217 +get_inode_info_61387 get_inode_info 0 61387 NULL
110218 +system_enable_write_61396 system_enable_write 3 61396 NULL
110219 +size_entry_mwt_61400 size_entry_mwt 0 61400 NULL
110220 +xfs_zero_remaining_bytes_61423 xfs_zero_remaining_bytes 3 61423 NULL
110221 +i915_emit_box_61436 i915_emit_box 0 61436 NULL
110222 +dma_ops_area_alloc_61440 dma_ops_area_alloc 3-4-5-0 61440 NULL
110223 +tc3589x_irq_unmap_61447 tc3589x_irq_unmap 2 61447 NULL
110224 +unix_stream_sendmsg_61455 unix_stream_sendmsg 4 61455 NULL
110225 +snd_pcm_lib_writev_transfer_61483 snd_pcm_lib_writev_transfer 5-4-2 61483 NULL
110226 +btrfs_item_size_61485 btrfs_item_size 0 61485 NULL
110227 +ocfs2_get_refcount_rec_61514 ocfs2_get_refcount_rec 0 61514 NULL
110228 +__vmalloc_area_node_61525 __vmalloc_area_node 4 61525 NULL
110229 +erst_errno_61526 erst_errno 0 61526 NULL
110230 +ntfs_attr_lookup_61539 ntfs_attr_lookup 0 61539 NULL
110231 +get_ohm_of_thermistor_61545 get_ohm_of_thermistor 2 61545 NULL
110232 +trace_options_core_write_61551 trace_options_core_write 3 61551 NULL
110233 +o2hb_pop_count_61553 o2hb_pop_count 2 61553 NULL
110234 +dvb_net_ioctl_61559 dvb_net_ioctl 2 61559 NULL
110235 +parport_pc_fifo_write_block_dma_61568 parport_pc_fifo_write_block_dma 3 61568 NULL
110236 +fan_proc_write_61569 fan_proc_write 3 61569 NULL
110237 +ieee80211_if_read_rc_rateidx_mask_2ghz_61570 ieee80211_if_read_rc_rateidx_mask_2ghz 3 61570 NULL
110238 +ldlm_pool_rw_atomic_seq_write_61572 ldlm_pool_rw_atomic_seq_write 3 61572 NULL
110239 +seq_open_private_61589 seq_open_private 3 61589 NULL
110240 +ept_gpte_to_gfn_lvl_61591 ept_gpte_to_gfn_lvl 0-2-1 61591 NULL
110241 +netlink_recvmsg_61600 netlink_recvmsg 4 61600 NULL
110242 +nfs4_init_uniform_client_string_61601 nfs4_init_uniform_client_string 3 61601 NULL
110243 +configfs_write_file_61621 configfs_write_file 3 61621 NULL
110244 +ieee80211_if_fmt_hw_queues_61629 ieee80211_if_fmt_hw_queues 3 61629 NULL
110245 +i2o_parm_table_get_61635 i2o_parm_table_get 6 61635 NULL
110246 +snd_pcm_oss_read3_61643 snd_pcm_oss_read3 0-3 61643 NULL
110247 +resize_stripes_61650 resize_stripes 2 61650 NULL
110248 +ttm_page_pool_free_61661 ttm_page_pool_free 2-0 61661 NULL
110249 +insert_one_name_61668 insert_one_name 7 61668 NULL
110250 +snd_pcm_playback_avail_61671 snd_pcm_playback_avail 0 61671 NULL
110251 +qib_format_hwmsg_61679 qib_format_hwmsg 2 61679 NULL
110252 +lock_loop_61681 lock_loop 1 61681 NULL
110253 +__do_tune_cpucache_61684 __do_tune_cpucache 2 61684 NULL
110254 +filter_read_61692 filter_read 3 61692 NULL
110255 +prog_page_61711 prog_page 2 61711 NULL
110256 +iov_length_61716 iov_length 0 61716 NULL
110257 +fragmentation_threshold_read_61718 fragmentation_threshold_read 3 61718 NULL
110258 +null_alloc_reqbuf_61719 null_alloc_reqbuf 3 61719 NULL
110259 +read_file_interrupt_61742 read_file_interrupt 3 61742 NULL nohasharray
110260 +read_file_regval_61742 read_file_regval 3 61742 &read_file_interrupt_61742
110261 +SyS_sendto_61763 SyS_sendto 6 61763 NULL
110262 +gfs2_meta_wait_61773 gfs2_meta_wait 0 61773 NULL
110263 +num_counter_active_61789 num_counter_active 0 61789 NULL
110264 +mls_compute_context_len_61812 mls_compute_context_len 0 61812 NULL
110265 +tps80031_irq_init_61830 tps80031_irq_init 3 61830 NULL
110266 +bfad_debugfs_write_regwr_61841 bfad_debugfs_write_regwr 3 61841 NULL
110267 +regcache_sync_block_61846 regcache_sync_block 4-5 61846 NULL
110268 +fs_path_prepare_for_add_61854 fs_path_prepare_for_add 2-0 61854 NULL
110269 +evdev_compute_buffer_size_61863 evdev_compute_buffer_size 0 61863 NULL
110270 +SYSC_lsetxattr_61869 SYSC_lsetxattr 4 61869 NULL
110271 +get_fw_name_61874 get_fw_name 3 61874 NULL
110272 +twl4030_sih_setup_61878 twl4030_sih_setup 3-0 61878 NULL
110273 +btrfs_ioctl_clone_61886 btrfs_ioctl_clone 4-3-5 61886 NULL
110274 +lprocfs_write_frac_u64_helper_61897 lprocfs_write_frac_u64_helper 2 61897 NULL
110275 +lov_mds_md_stripecnt_61899 lov_mds_md_stripecnt 0-1 61899 NULL
110276 +clear_refs_write_61904 clear_refs_write 3 61904 NULL
110277 +rx_filter_arp_filter_read_61914 rx_filter_arp_filter_read 3 61914 NULL
110278 +au0828_init_isoc_61917 au0828_init_isoc 3-2-4 61917 NULL
110279 +sctp_sendmsg_61919 sctp_sendmsg 4 61919 NULL
110280 +ocfs2_reserve_new_metadata_blocks_61926 ocfs2_reserve_new_metadata_blocks 0 61926 NULL
110281 +SyS_kexec_load_61946 SyS_kexec_load 2 61946 NULL
110282 +gfn_to_pfn_memslot_atomic_61947 gfn_to_pfn_memslot_atomic 2 61947 NULL
110283 +il4965_ucode_rx_stats_read_61948 il4965_ucode_rx_stats_read 3 61948 NULL
110284 +squashfs_read_id_index_table_61961 squashfs_read_id_index_table 4 61961 NULL
110285 +fix_read_error_61965 fix_read_error 4 61965 NULL
110286 +mlx4_alloc_mtt_range_61966 mlx4_alloc_mtt_range 2 61966 NULL
110287 +ocfs2_quota_write_61972 ocfs2_quota_write 5-4 61972 NULL
110288 +fd_locked_ioctl_61978 fd_locked_ioctl 3 61978 NULL
110289 +cow_file_range_61979 cow_file_range 3 61979 NULL
110290 +module_alloc_exec_61991 module_alloc_exec 1 61991 NULL
110291 +dequeue_event_62000 dequeue_event 3 62000 NULL
110292 +xt_compat_match_offset_62011 xt_compat_match_offset 0 62011 NULL
110293 +SyS_setxattr_62019 SyS_setxattr 4 62019 NULL
110294 +jffs2_do_unlink_62020 jffs2_do_unlink 4 62020 NULL
110295 +SYSC_select_62024 SYSC_select 1 62024 NULL
110296 +pmcraid_build_passthrough_ioadls_62034 pmcraid_build_passthrough_ioadls 2 62034 NULL
110297 +sctp_user_addto_chunk_62047 sctp_user_addto_chunk 2-3 62047 NULL
110298 +do_pselect_62061 do_pselect 1 62061 NULL
110299 +pcpu_alloc_bootmem_62074 pcpu_alloc_bootmem 2 62074 NULL
110300 +get_domain_for_dev_62099 get_domain_for_dev 2 62099 NULL
110301 +ipath_user_sdma_pin_pages_62100 ipath_user_sdma_pin_pages 3-5-4 62100 NULL
110302 +jffs2_security_setxattr_62107 jffs2_security_setxattr 4 62107 NULL
110303 +btrfs_direct_IO_62114 btrfs_direct_IO 4 62114 NULL
110304 +ip_recv_error_62117 ip_recv_error 3 62117 NULL
110305 +generic_block_fiemap_62122 generic_block_fiemap 4 62122 NULL
110306 +llc_ui_header_len_62131 llc_ui_header_len 0 62131 NULL
110307 +qib_diag_write_62133 qib_diag_write 3 62133 NULL nohasharray
110308 +kobject_add_varg_62133 kobject_add_varg 0 62133 &qib_diag_write_62133
110309 +ql_status_62135 ql_status 5 62135 NULL nohasharray
110310 +device_add_attrs_62135 device_add_attrs 0 62135 &ql_status_62135
110311 +video_usercopy_62151 video_usercopy 2 62151 NULL
110312 +wrmWithLock_62164 wrmWithLock 0 62164 NULL
110313 +SyS_getxattr_62166 SyS_getxattr 4 62166 NULL
110314 +prism54_wpa_bss_ie_get_62173 prism54_wpa_bss_ie_get 0 62173 NULL
110315 +write_file_dfs_62180 write_file_dfs 3 62180 NULL
110316 +alloc_upcall_62186 alloc_upcall 2 62186 NULL
110317 +btrfs_xattr_acl_set_62203 btrfs_xattr_acl_set 4 62203 NULL
110318 +sock_kmalloc_62205 sock_kmalloc 2 62205 NULL
110319 +SYSC_setgroups16_62232 SYSC_setgroups16 1 62232 NULL
110320 +nfsd_read_file_62241 nfsd_read_file 6 62241 NULL
110321 +allocate_partition_62245 allocate_partition 4 62245 NULL
110322 +security_file_permission_62278 security_file_permission 0 62278 NULL
110323 +get_random_int_62279 get_random_int 0 62279 NULL
110324 +__qib_get_user_pages_62287 __qib_get_user_pages 1-2 62287 NULL
110325 +il_dbgfs_sram_read_62296 il_dbgfs_sram_read 3 62296 NULL
110326 +sparse_early_usemaps_alloc_pgdat_section_62304 sparse_early_usemaps_alloc_pgdat_section 2 62304 NULL
110327 +ocfs2_find_victim_alloc_group_62306 ocfs2_find_victim_alloc_group 0 62306 NULL
110328 +subsystem_filter_read_62310 subsystem_filter_read 3 62310 NULL
110329 +timespec_to_jiffies_62321 timespec_to_jiffies 0 62321 NULL
110330 +Wb35Reg_BurstWrite_62327 Wb35Reg_BurstWrite 4 62327 NULL
110331 +subseq_list_62332 subseq_list 3-0 62332 NULL
110332 +ll_statahead_max_seq_write_62333 ll_statahead_max_seq_write 3 62333 NULL
110333 +flash_write_62354 flash_write 3 62354 NULL
110334 +xfpregs_set_62363 xfpregs_set 4 62363 NULL
110335 +rx_rx_timeout_read_62389 rx_rx_timeout_read 3 62389 NULL
110336 +altera_irscan_62396 altera_irscan 2 62396 NULL
110337 +set_ssp_62411 set_ssp 4 62411 NULL
110338 +mlx4_en_create_rx_ring_62498 mlx4_en_create_rx_ring 3 62498 NULL
110339 +ext_rts51x_sd_execute_read_data_62501 ext_rts51x_sd_execute_read_data 9 62501 NULL
110340 +mtip_get_next_rr_node_62502 mtip_get_next_rr_node 0 62502 NULL
110341 +ocfs2_path_bh_journal_access_62504 ocfs2_path_bh_journal_access 0 62504 NULL
110342 +pep_sendmsg_62524 pep_sendmsg 4 62524 NULL
110343 +test_iso_queue_62534 test_iso_queue 5 62534 NULL nohasharray
110344 +__kmalloc_node_track_caller_62534 __kmalloc_node_track_caller 3 62534 &test_iso_queue_62534
110345 +debugfs_read_62535 debugfs_read 3 62535 NULL
110346 +sco_sock_sendmsg_62542 sco_sock_sendmsg 4 62542 NULL
110347 +qib_refresh_qsfp_cache_62547 qib_refresh_qsfp_cache 0 62547 NULL
110348 +xfrm_user_policy_62573 xfrm_user_policy 4 62573 NULL
110349 +get_subdir_62581 get_subdir 3 62581 NULL
110350 +nfsd_vfs_read_62605 nfsd_vfs_read 6 62605 NULL
110351 +get_desc_base_62617 get_desc_base 0 62617 NULL
110352 +iommu_area_alloc_62619 iommu_area_alloc 2-3-4-7-0 62619 NULL
110353 +vfs_fsync_range_62635 vfs_fsync_range 0 62635 NULL
110354 +lpfc_sli4_queue_alloc_62646 lpfc_sli4_queue_alloc 3 62646 NULL
110355 +write_62671 write 3 62671 NULL
110356 +ocfs2_wait_for_mask_interruptible_62675 ocfs2_wait_for_mask_interruptible 0 62675 NULL
110357 +printer_req_alloc_62687 printer_req_alloc 2 62687 NULL
110358 +ext4_ind_map_blocks_62690 ext4_ind_map_blocks 0 62690 NULL
110359 +htb_remove_class_from_row_62692 htb_remove_class_from_row 3 62692 NULL
110360 +qla4_83xx_rd_reg_62693 qla4_83xx_rd_reg 0 62693 NULL
110361 +bioset_integrity_create_62708 bioset_integrity_create 2 62708 NULL
110362 +gfs2_log_write_62717 gfs2_log_write 3 62717 NULL
110363 +rdm_62719 rdm 0 62719 NULL
110364 +obd_ioctl_popdata_62741 obd_ioctl_popdata 3 62741 NULL
110365 +key_replays_read_62746 key_replays_read 3 62746 NULL
110366 +lov_verify_lmm_62747 lov_verify_lmm 2 62747 NULL
110367 +mwifiex_rdeeprom_write_62754 mwifiex_rdeeprom_write 3 62754 NULL
110368 +ax25_sendmsg_62770 ax25_sendmsg 4 62770 NULL
110369 +page_key_alloc_62771 page_key_alloc 0 62771 NULL
110370 +C_SYSC_ipc_62776 C_SYSC_ipc 3 62776 NULL
110371 +SyS_sched_getaffinity_62786 SyS_sched_getaffinity 2 62786 NULL
110372 +dm_stats_account_io_62787 dm_stats_account_io 3 62787 NULL
110373 +posix_acl_valid_62788 posix_acl_valid 0 62788 NULL
110374 +is_first_ref_62805 is_first_ref 0 62805 NULL
110375 +tracing_total_entries_read_62817 tracing_total_entries_read 3 62817 NULL
110376 +name_cache_insert_62822 name_cache_insert 0 62822 NULL
110377 +BeceemEEPROMBulkRead_62835 BeceemEEPROMBulkRead 0 62835 NULL
110378 +__rounddown_pow_of_two_62836 __rounddown_pow_of_two 0 62836 NULL
110379 +bio_get_nr_vecs_62838 bio_get_nr_vecs 0 62838 NULL
110380 +xlog_recover_add_to_trans_62839 xlog_recover_add_to_trans 4 62839 NULL
110381 +rx_fcs_err_read_62844 rx_fcs_err_read 3 62844 NULL
110382 +set_swbp_62853 set_swbp 3 62853 NULL
110383 +read_nic_io_dword_62859 read_nic_io_dword 0 62859 NULL
110384 +l2tp_ip6_recvmsg_62874 l2tp_ip6_recvmsg 4 62874 NULL
110385 +aoechr_write_62883 aoechr_write 3 62883 NULL
110386 +if_spi_host_to_card_62890 if_spi_host_to_card 4 62890 NULL
110387 +ocfs2_validate_gd_parent_62905 ocfs2_validate_gd_parent 0 62905 NULL
110388 +mempool_create_slab_pool_62907 mempool_create_slab_pool 1 62907 NULL
110389 +getdqbuf_62908 getdqbuf 1 62908 NULL
110390 +try_async_pf_62914 try_async_pf 3 62914 NULL nohasharray
110391 +SyS_remap_file_pages_62914 SyS_remap_file_pages 1-2 62914 &try_async_pf_62914
110392 +ll_statahead_agl_seq_write_62928 ll_statahead_agl_seq_write 3 62928 NULL
110393 +atomic64_sub_return_62941 atomic64_sub_return 1 62941 NULL
110394 +agp_create_user_memory_62955 agp_create_user_memory 1 62955 NULL
110395 +send_write_62969 send_write 0-3 62969 NULL
110396 +__ext3_journal_stop_63017 __ext3_journal_stop 0 63017 NULL
110397 +alloc_mem_cgroup_per_zone_info_63024 alloc_mem_cgroup_per_zone_info 2 63024 NULL
110398 +kstrtoull_from_user_63026 kstrtoull_from_user 2 63026 NULL
110399 +PTR_ERR_63033 PTR_ERR 0 63033 NULL nohasharray
110400 +__vb2_perform_fileio_63033 __vb2_perform_fileio 3 63033 &PTR_ERR_63033
110401 +pipeline_defrag_to_csum_swi_read_63037 pipeline_defrag_to_csum_swi_read 3 63037 NULL
110402 +scsi_host_alloc_63041 scsi_host_alloc 2 63041 NULL
110403 +run_delayed_tree_ref_63042 run_delayed_tree_ref 0 63042 NULL
110404 +unlink1_63059 unlink1 3 63059 NULL
110405 +__do_munmap_63063 __do_munmap 0 63063 NULL
110406 +xen_set_nslabs_63066 xen_set_nslabs 0 63066 NULL
110407 +iwl_dbgfs_fw_rx_stats_read_63070 iwl_dbgfs_fw_rx_stats_read 3 63070 NULL
110408 +ocfs2_decrease_refcount_63078 ocfs2_decrease_refcount 4-3-0 63078 NULL
110409 +find_extent_in_eb_63082 find_extent_in_eb 0 63082 NULL
110410 +sep_prepare_input_output_dma_table_in_dcb_63087 sep_prepare_input_output_dma_table_in_dcb 4-5-3-2 63087 NULL
110411 +__ocfs2_flush_truncate_log_63097 __ocfs2_flush_truncate_log 0 63097 NULL
110412 +iwl_dbgfs_sensitivity_read_63116 iwl_dbgfs_sensitivity_read 3 63116 NULL
110413 +ext4_chunk_trans_blocks_63123 ext4_chunk_trans_blocks 0-2 63123 NULL
110414 +alloc_cblock_63133 alloc_cblock 2 63133 NULL
110415 +snd_pcm_status_user_63140 snd_pcm_status_user 0 63140 NULL
110416 +ubifs_change_one_lp_63157 ubifs_change_one_lp 0 63157 NULL
110417 +smk_write_revoke_subj_63173 smk_write_revoke_subj 3 63173 NULL
110418 +SyS_syslog_63178 SyS_syslog 3 63178 NULL
110419 +security_policydb_len_63198 security_policydb_len 0 63198 NULL
110420 +vme_master_read_63221 vme_master_read 0 63221 NULL
110421 +SyS_gethostname_63227 SyS_gethostname 2 63227 NULL
110422 +module_alloc_update_bounds_rw_63233 module_alloc_update_bounds_rw 1 63233 NULL
110423 +ptp_read_63251 ptp_read 4 63251 NULL
110424 +xfs_dir2_leaf_getdents_63262 xfs_dir2_leaf_getdents 3 63262 NULL
110425 +ntfs_attr_can_be_non_resident_63267 ntfs_attr_can_be_non_resident 0 63267 NULL
110426 +raid5_resize_63306 raid5_resize 2 63306 NULL
110427 +proc_info_read_63344 proc_info_read 3 63344 NULL
110428 +ps_upsd_max_sptime_read_63362 ps_upsd_max_sptime_read 3 63362 NULL
110429 +idmouse_read_63374 idmouse_read 3 63374 NULL
110430 +edac_pci_alloc_ctl_info_63388 edac_pci_alloc_ctl_info 1 63388 NULL nohasharray
110431 +usbnet_read_cmd_nopm_63388 usbnet_read_cmd_nopm 7 63388 &edac_pci_alloc_ctl_info_63388
110432 +rxpipe_missed_beacon_host_int_trig_rx_data_read_63405 rxpipe_missed_beacon_host_int_trig_rx_data_read 3 63405 NULL
110433 +nouveau_event_create_63411 nouveau_event_create 1 63411 NULL
110434 +l2cap_sock_sendmsg_63427 l2cap_sock_sendmsg 4 63427 NULL
110435 +sep_prepare_input_output_dma_table_63429 sep_prepare_input_output_dma_table 3-4-2 63429 NULL
110436 +gfn_to_hva_many_63437 gfn_to_hva_many 2-0 63437 NULL
110437 +nfsd_symlink_63442 nfsd_symlink 6 63442 NULL
110438 +lookup_dir_item_inode_63447 lookup_dir_item_inode 0 63447 NULL
110439 +i915_gem_object_get_fence_63455 i915_gem_object_get_fence 0 63455 NULL
110440 +__do_kmalloc_node_63461 __do_kmalloc_node 3 63461 NULL
110441 +si5351_bulk_write_63468 si5351_bulk_write 2-3 63468 NULL
110442 +snd_info_entry_write_63474 snd_info_entry_write 3 63474 NULL
110443 +do_work_63483 do_work 0 63483 NULL
110444 +reada_find_extent_63486 reada_find_extent 2 63486 NULL
110445 +__copy_from_user_ll_nocache_63487 __copy_from_user_ll_nocache 0-3 63487 NULL
110446 +read_kcore_63488 read_kcore 3 63488 NULL nohasharray
110447 +alloc_reserved_tree_block_63488 alloc_reserved_tree_block 0 63488 &read_kcore_63488
110448 +save_hint_63497 save_hint 2 63497 NULL
110449 +wl1271_tx_min_rate_get_63498 wl1271_tx_min_rate_get 2 63498 NULL
110450 +sis_voice_irq_63501 sis_voice_irq 1 63501 NULL
110451 +snd_pcm_plug_write_transfer_63503 snd_pcm_plug_write_transfer 0-3 63503 NULL
110452 +efx_mcdi_rpc_async_63529 efx_mcdi_rpc_async 5-4 63529 NULL
110453 +ubi_more_leb_change_data_63534 ubi_more_leb_change_data 4-0 63534 NULL
110454 +write_file_spectral_period_63536 write_file_spectral_period 3 63536 NULL
110455 +if_sdio_read_scratch_63540 if_sdio_read_scratch 0 63540 NULL
110456 +append_to_buffer_63550 append_to_buffer 3 63550 NULL
110457 +dbg_leb_write_63555 dbg_leb_write 4-5 63555 NULL nohasharray
110458 +kvm_write_guest_page_63555 kvm_write_guest_page 2-5 63555 &dbg_leb_write_63555
110459 +ubifs_lpt_scan_nolock_63572 ubifs_lpt_scan_nolock 0 63572 NULL
110460 +iwch_reg_user_mr_63575 iwch_reg_user_mr 2-3 63575 NULL
110461 +ocfs2_calc_trunc_pos_63576 ocfs2_calc_trunc_pos 4 63576 NULL
110462 +rproc_alloc_63577 rproc_alloc 5 63577 NULL
110463 +ext3_clear_blocks_63597 ext3_clear_blocks 4-5 63597 NULL
110464 +write_debug_level_63613 write_debug_level 3 63613 NULL
110465 +module_alloc_63630 module_alloc 1 63630 NULL
110466 +ntfs_malloc_nofs_nofail_63631 ntfs_malloc_nofs_nofail 1 63631 NULL
110467 +symbol_build_supp_rates_63634 symbol_build_supp_rates 0 63634 NULL
110468 +_ubh_find_next_zero_bit__63640 _ubh_find_next_zero_bit_ 3-5-4 63640 NULL
110469 +ext4_ext_get_access_63642 ext4_ext_get_access 0 63642 NULL
110470 +proc_loginuid_write_63648 proc_loginuid_write 3 63648 NULL
110471 +ValidateDSDParamsChecksum_63654 ValidateDSDParamsChecksum 3 63654 NULL
110472 +ldlm_cli_enqueue_63657 ldlm_cli_enqueue 8 63657 NULL
110473 +hidraw_ioctl_63658 hidraw_ioctl 2 63658 NULL
110474 +vbi_read_63673 vbi_read 3 63673 NULL nohasharray
110475 +xen_register_pirq_63673 xen_register_pirq 1-2 63673 &vbi_read_63673
110476 +write_file_spectral_fft_period_63696 write_file_spectral_fft_period 3 63696 NULL
110477 +bin_search_63697 bin_search 0 63697 NULL
110478 +arizona_irq_map_63709 arizona_irq_map 2 63709 NULL
110479 +ocfs2_et_root_journal_access_63713 ocfs2_et_root_journal_access 0 63713 NULL
110480 +nouveau_object_create__63715 nouveau_object_create_ 5 63715 NULL
110481 +btrfs_insert_delayed_dir_index_63720 btrfs_insert_delayed_dir_index 4-0 63720 NULL
110482 +selinux_secctx_to_secid_63744 selinux_secctx_to_secid 2 63744 NULL
110483 +snd_pcm_oss_read1_63771 snd_pcm_oss_read1 3 63771 NULL
110484 +snd_pcm_link_63772 snd_pcm_link 0 63772 NULL
110485 +snd_opl4_mem_proc_read_63774 snd_opl4_mem_proc_read 5 63774 NULL
110486 +spidev_compat_ioctl_63778 spidev_compat_ioctl 2 63778 NULL
110487 +mwifiex_11n_create_rx_reorder_tbl_63806 mwifiex_11n_create_rx_reorder_tbl 4 63806 NULL
110488 +copy_nodes_to_user_63807 copy_nodes_to_user 2 63807 NULL
110489 +prepare_copy_63826 prepare_copy 2 63826 NULL
110490 +sel_write_load_63830 sel_write_load 3 63830 NULL
110491 +ll_readlink_63836 ll_readlink 3 63836 NULL
110492 +IsSectionWritable_63842 IsSectionWritable 0 63842 NULL
110493 +proc_pid_attr_write_63845 proc_pid_attr_write 3 63845 NULL
110494 +divas_write_63901 divas_write 3 63901 NULL
110495 +IsOffsetWritable_63902 IsOffsetWritable 0 63902 NULL nohasharray
110496 +xhci_alloc_stream_info_63902 xhci_alloc_stream_info 3 63902 &IsOffsetWritable_63902
110497 +uvc_alloc_urb_buffers_63922 uvc_alloc_urb_buffers 0-2-3 63922 NULL
110498 +snd_compr_write_63923 snd_compr_write 3 63923 NULL
110499 +acpi_ev_get_gpe_xrupt_block_63924 acpi_ev_get_gpe_xrupt_block 1 63924 NULL
110500 +tipc_send2port_63935 tipc_send2port 5 63935 NULL
110501 +afs_send_simple_reply_63940 afs_send_simple_reply 3 63940 NULL
110502 +__team_options_register_63941 __team_options_register 3 63941 NULL
110503 +macvtap_recvmsg_63949 macvtap_recvmsg 4 63949 NULL
110504 +generic_acl_init_63955 generic_acl_init 0 63955 NULL
110505 +domain_pfn_mapping_63957 domain_pfn_mapping 4 63957 NULL
110506 +diva_xdi_write_63975 diva_xdi_write 4 63975 NULL
110507 +rs_extent_to_bm_page_63996 rs_extent_to_bm_page 0-1 63996 NULL
110508 +read_file_frameerrors_64001 read_file_frameerrors 3 64001 NULL
110509 +hfsplus_security_setxattr_64009 hfsplus_security_setxattr 4 64009 NULL
110510 +C_SYSC_sendfile64_64017 C_SYSC_sendfile64 4 64017 NULL
110511 +SyS_rt_sigpending_64018 SyS_rt_sigpending 2 64018 NULL
110512 +offset_to_vaddr_64025 offset_to_vaddr 0-2 64025 NULL
110513 +dbAllocDmapLev_64030 dbAllocDmapLev 0 64030 NULL
110514 +resize_async_buffer_64031 resize_async_buffer 4 64031 NULL
110515 +SyS_fsetxattr_64039 SyS_fsetxattr 4 64039 NULL
110516 +tfrc_calc_x_reverse_lookup_64057 tfrc_calc_x_reverse_lookup 0 64057 NULL
110517 +__sock_create_64069 __sock_create 0 64069 NULL
110518 +get_u8_64076 get_u8 0 64076 NULL
110519 +xilly_malloc_64077 xilly_malloc 2 64077 NULL
110520 +btrfs_copy_root_64079 btrfs_copy_root 0 64079 NULL
110521 +sl_realloc_bufs_64086 sl_realloc_bufs 2 64086 NULL
110522 +clear_update_marker_64088 clear_update_marker 0 64088 NULL nohasharray
110523 +vmci_handle_arr_get_size_64088 vmci_handle_arr_get_size 0 64088 &clear_update_marker_64088
110524 +lbs_highrssi_read_64089 lbs_highrssi_read 3 64089 NULL
110525 +SyS_set_mempolicy_64096 SyS_set_mempolicy 3 64096 NULL
110526 +SyS_mq_timedsend_64107 SyS_mq_timedsend 3 64107 NULL
110527 +rdma_addr_size_64116 rdma_addr_size 0 64116 NULL
110528 +do_load_xattr_datum_64118 do_load_xattr_datum 0 64118 NULL
110529 +bypass_wd_write_64120 bypass_wd_write 3 64120 NULL
110530 +ol_quota_entries_per_block_64122 ol_quota_entries_per_block 0 64122 NULL
110531 +ext4_prepare_inline_data_64124 ext4_prepare_inline_data 3 64124 NULL
110532 +init_bch_64130 init_bch 2-1 64130 NULL
110533 +SYSC_ptrace_64136 SYSC_ptrace 3 64136 NULL
110534 +ablkcipher_copy_iv_64140 ablkcipher_copy_iv 3 64140 NULL
110535 +dlfb_ops_write_64150 dlfb_ops_write 3 64150 NULL
110536 +__comedi_buf_alloc_64155 __comedi_buf_alloc 3 64155 NULL
110537 +cpumask_scnprintf_64170 cpumask_scnprintf 0-2 64170 NULL
110538 +ocfs2_reserve_blocks_for_rec_trunc_64206 ocfs2_reserve_blocks_for_rec_trunc 0 64206 NULL
110539 +xfs_vm_direct_IO_64223 xfs_vm_direct_IO 4 64223 NULL
110540 +read_pulse_64227 read_pulse 0-3 64227 NULL
110541 +ea_len_64229 ea_len 0 64229 NULL
110542 +btrfs_make_block_group_64241 btrfs_make_block_group 0 64241 NULL
110543 +__btrfs_update_delayed_inode_64248 __btrfs_update_delayed_inode 0 64248 NULL
110544 +io_capture_transfer_64276 io_capture_transfer 4 64276 NULL
110545 +btrfs_file_extent_offset_64278 btrfs_file_extent_offset 0 64278 NULL
110546 +btrfs_next_item_64285 btrfs_next_item 0 64285 NULL
110547 +sta_current_tx_rate_read_64286 sta_current_tx_rate_read 3 64286 NULL
110548 +event_id_read_64288 event_id_read 3 64288 NULL nohasharray
110549 +xfs_dir_cilookup_result_64288 xfs_dir_cilookup_result 3 64288 &event_id_read_64288
110550 +ocfs2_block_check_validate_bhs_64302 ocfs2_block_check_validate_bhs 0 64302 NULL
110551 +snd_hda_get_sub_nodes_64304 snd_hda_get_sub_nodes 0 64304 NULL
110552 +error_error_bar_retry_read_64305 error_error_bar_retry_read 3 64305 NULL
110553 +ffz_64324 ffz 0-1 64324 NULL
110554 +map_region_64328 map_region 1 64328 NULL
110555 +sisusbcon_clear_64329 sisusbcon_clear 4-3-5 64329 NULL
110556 +ts_write_64336 ts_write 3 64336 NULL
110557 +usbtmc_write_64340 usbtmc_write 3 64340 NULL
110558 +do_write_orph_node_64343 do_write_orph_node 2 64343 NULL
110559 +ft1000_read_reg_64352 ft1000_read_reg 0 64352 NULL
110560 +bnx2x_vfop_mcast_cmd_64354 bnx2x_vfop_mcast_cmd 5 64354 NULL
110561 +user_regset_copyin_64360 user_regset_copyin 7 64360 NULL
110562 +wlc_phy_loadsampletable_nphy_64367 wlc_phy_loadsampletable_nphy 3 64367 NULL
110563 +reg_create_64372 reg_create 5 64372 NULL
110564 +ilo_write_64378 ilo_write 3 64378 NULL
110565 +btrfs_map_block_64379 btrfs_map_block 3 64379 NULL
110566 +vmcs_readl_64381 vmcs_readl 0 64381 NULL
110567 +nilfs_alloc_seg_bio_64383 nilfs_alloc_seg_bio 3 64383 NULL
110568 +ir_lirc_transmit_ir_64403 ir_lirc_transmit_ir 3 64403 NULL
110569 +pidlist_allocate_64404 pidlist_allocate 1 64404 NULL
110570 +rx_hdr_overflow_read_64407 rx_hdr_overflow_read 3 64407 NULL
110571 +snd_card_create_64418 snd_card_create 4 64418 NULL nohasharray
110572 +keyctl_get_security_64418 keyctl_get_security 3 64418 &snd_card_create_64418
110573 +nl80211_send_mgmt_64419 nl80211_send_mgmt 7 64419 NULL
110574 +oom_adj_write_64428 oom_adj_write 3 64428 NULL
110575 +ext4_trim_extent_64431 ext4_trim_extent 4 64431 NULL nohasharray
110576 +read_file_spectral_short_repeat_64431 read_file_spectral_short_repeat 3 64431 &ext4_trim_extent_64431
110577 +ax25_recvmsg_64441 ax25_recvmsg 4 64441 NULL
110578 +single_open_size_64483 single_open_size 4 64483 NULL
110579 +p54_parse_rssical_64493 p54_parse_rssical 3 64493 NULL
110580 +msg_data_sz_64503 msg_data_sz 0 64503 NULL
110581 +remove_uuid_64505 remove_uuid 4 64505 NULL nohasharray
110582 +handle_abnormal_pfn_64505 handle_abnormal_pfn 3 64505 &remove_uuid_64505
110583 +crypto_blkcipher_alignmask_64520 crypto_blkcipher_alignmask 0 64520 NULL
110584 +opera1_usb_i2c_msgxfer_64521 opera1_usb_i2c_msgxfer 4 64521 NULL
110585 +iwl_dbgfs_ucode_tracing_write_64524 iwl_dbgfs_ucode_tracing_write 3 64524 NULL
110586 +ses_send_diag_64527 ses_send_diag 4 64527 NULL
110587 +prctl_set_mm_64538 prctl_set_mm 3 64538 NULL
110588 +SyS_bind_64544 SyS_bind 3 64544 NULL
110589 +rbd_obj_read_sync_64554 rbd_obj_read_sync 4-3 64554 NULL
110590 +__btrfs_prealloc_file_range_64557 __btrfs_prealloc_file_range 3-0 64557 NULL
110591 +__spi_sync_64561 __spi_sync 0 64561 NULL nohasharray
110592 +ll_max_rw_chunk_seq_write_64561 ll_max_rw_chunk_seq_write 3 64561 &__spi_sync_64561
110593 +__apei_exec_run_64563 __apei_exec_run 0 64563 NULL
110594 +kstrtoul_from_user_64569 kstrtoul_from_user 2 64569 NULL
110595 +do_erase_64574 do_erase 4 64574 NULL
110596 +fanotify_write_64623 fanotify_write 3 64623 NULL
110597 +ocfs2_remove_refcount_extent_64631 ocfs2_remove_refcount_extent 0 64631 NULL
110598 +to_dblock_64655 to_dblock 0-1 64655 NULL
110599 +regmap_read_debugfs_64658 regmap_read_debugfs 5 64658 NULL
110600 +ocfs2_read_xattr_block_64661 ocfs2_read_xattr_block 0 64661 NULL nohasharray
110601 +tlbflush_read_file_64661 tlbflush_read_file 3 64661 &ocfs2_read_xattr_block_64661 nohasharray
110602 +pool_create_64661 pool_create 3 64661 &tlbflush_read_file_64661
110603 +efx_tsoh_get_buffer_64664 efx_tsoh_get_buffer 3 64664 NULL
110604 +rx_rx_out_of_mpdu_nodes_read_64668 rx_rx_out_of_mpdu_nodes_read 3 64668 NULL
110605 +nr_free_zone_pages_64680 nr_free_zone_pages 0 64680 NULL
110606 +sec_bulk_write_64691 sec_bulk_write 2-3 64691 NULL nohasharray
110607 +mremap_to_64691 mremap_to 0-3 64691 &sec_bulk_write_64691
110608 +pfn_to_hpa_64703 pfn_to_hpa 0-1 64703 NULL
110609 +ip_select_ident_more_64707 ip_select_ident_more 4 64707 NULL
110610 +snd_pcm_oss_capture_position_fixup_64713 snd_pcm_oss_capture_position_fixup 0 64713 NULL
110611 +dapm_bias_read_file_64715 dapm_bias_read_file 3 64715 NULL
110612 +atomic_add_return_64720 atomic_add_return 0-1 64720 NULL
110613 +i2400m_msg_to_dev_64722 i2400m_msg_to_dev 3 64722 NULL
110614 +AscGetChipVersion_64737 AscGetChipVersion 0 64737 NULL
110615 +squashfs_read_inode_lookup_table_64739 squashfs_read_inode_lookup_table 4 64739 NULL
110616 +perf_swevent_event_64745 perf_swevent_event 2 64745 NULL
110617 +bio_map_kern_64751 bio_map_kern 3 64751 NULL
110618 +rt2x00debug_write_csr_64753 rt2x00debug_write_csr 3 64753 NULL
110619 +message_for_md_64777 message_for_md 5 64777 NULL
110620 +isr_low_rssi_read_64789 isr_low_rssi_read 3 64789 NULL
110621 +regmap_reg_ranges_read_file_64798 regmap_reg_ranges_read_file 3 64798 NULL
110622 +nfsctl_transaction_write_64800 nfsctl_transaction_write 3 64800 NULL
110623 +rfkill_fop_write_64808 rfkill_fop_write 3 64808 NULL
110624 +proc_projid_map_write_64810 proc_projid_map_write 3 64810 NULL
110625 +megaraid_change_queue_depth_64815 megaraid_change_queue_depth 2 64815 NULL
110626 +ecryptfs_send_miscdev_64816 ecryptfs_send_miscdev 2 64816 NULL
110627 +vaddr_get_pfn_64818 vaddr_get_pfn 1 64818 NULL
110628 +gfn_to_page_64826 gfn_to_page 2 64826 NULL
110629 +do_kimage_alloc_64827 do_kimage_alloc 3 64827 NULL
110630 +altera_set_dr_pre_64862 altera_set_dr_pre 2 64862 NULL
110631 +gfn_to_pfn_64870 gfn_to_pfn 2 64870 NULL
110632 +lprocfs_write_u64_helper_64880 lprocfs_write_u64_helper 2 64880 NULL
110633 +ffs_epfile_io_64886 ffs_epfile_io 3 64886 NULL
110634 +mk_pid_64894 mk_pid 0-3 64894 NULL
110635 +ieee80211_if_read_ave_beacon_64924 ieee80211_if_read_ave_beacon 3 64924 NULL
110636 +usb_reset_and_verify_device_64933 usb_reset_and_verify_device 0 64933 NULL
110637 +ubifs_wbuf_write_nolock_64946 ubifs_wbuf_write_nolock 3 64946 NULL
110638 +ip_options_get_from_user_64958 ip_options_get_from_user 4 64958 NULL
110639 +acpi_os_install_interrupt_handler_64968 acpi_os_install_interrupt_handler 1 64968 NULL
110640 +traceprobe_probes_write_64969 traceprobe_probes_write 3 64969 NULL
110641 +suspend_dtim_interval_read_64971 suspend_dtim_interval_read 3 64971 NULL
110642 +ext2_group_first_block_no_64972 ext2_group_first_block_no 0-2 64972 NULL
110643 +crypto_ahash_digestsize_65014 crypto_ahash_digestsize 0 65014 NULL
110644 +insert_dent_65034 insert_dent 7 65034 NULL
110645 +snd_hda_get_pin_label_65035 snd_hda_get_pin_label 5 65035 NULL
110646 +ext4_ind_trans_blocks_65053 ext4_ind_trans_blocks 0-2 65053 NULL
110647 +pcibios_enable_device_65059 pcibios_enable_device 0 65059 NULL
110648 +make_idx_node_65068 make_idx_node 0 65068 NULL
110649 +count_run_65072 count_run 0-2-4-5 65072 NULL
110650 +__alloc_bootmem_node_high_65076 __alloc_bootmem_node_high 2 65076 NULL
110651 +ocfs2_truncate_cluster_pages_65086 ocfs2_truncate_cluster_pages 2 65086 NULL
110652 +send_create_inode_65090 send_create_inode 0 65090 NULL nohasharray
110653 +ath9k_dump_mci_btcoex_65090 ath9k_dump_mci_btcoex 0 65090 &send_create_inode_65090
110654 +uasp_alloc_cmd_65097 uasp_alloc_cmd 0 65097 NULL
110655 +__ext3_journal_dirty_metadata_65103 __ext3_journal_dirty_metadata 0 65103 NULL
110656 +generic_ocp_write_65107 generic_ocp_write 4 65107 NULL
110657 +kswapd_shrink_zone_65174 kswapd_shrink_zone 4 65174 NULL
110658 +i2c_smbus_xfer_emulated_65183 i2c_smbus_xfer_emulated 0 65183 NULL
110659 +btrfs_run_delayed_items_nr_65204 btrfs_run_delayed_items_nr 0 65204 NULL
110660 +rx_rx_done_read_65217 rx_rx_done_read 3 65217 NULL
110661 +print_endpoint_stat_65232 print_endpoint_stat 3-4-0 65232 NULL
110662 +journal_get_write_access_65243 journal_get_write_access 0 65243 NULL
110663 +whci_n_caps_65247 whci_n_caps 0 65247 NULL
110664 +kmem_zalloc_greedy_65268 kmem_zalloc_greedy 3-2 65268 NULL
110665 +kmalloc_parameter_65279 kmalloc_parameter 1 65279 NULL
110666 +compat_core_sys_select_65285 compat_core_sys_select 1 65285 NULL
110667 +get_unaligned_le16_65293 get_unaligned_le16 0 65293 NULL
110668 +mpi_set_buffer_65294 mpi_set_buffer 3 65294 NULL
110669 +redirected_tty_write_65297 redirected_tty_write 3 65297 NULL
110670 +get_var_len_65304 get_var_len 0 65304 NULL
110671 +unpack_array_65318 unpack_array 0 65318 NULL
110672 +pci_vpd_find_tag_65325 pci_vpd_find_tag 0-2 65325 NULL
110673 +dccp_setsockopt_service_65336 dccp_setsockopt_service 4 65336 NULL
110674 +init_list_set_65351 init_list_set 3-2 65351 NULL
110675 +dma_rx_requested_read_65354 dma_rx_requested_read 3 65354 NULL
110676 +batadv_tt_save_orig_buffer_65361 batadv_tt_save_orig_buffer 4 65361 NULL
110677 +alloc_cpu_rmap_65363 alloc_cpu_rmap 1 65363 NULL
110678 +__ext4_new_inode_65370 __ext4_new_inode 5 65370 NULL
110679 +SyS_writev_65372 SyS_writev 3 65372 NULL
110680 +mi_set_context_65395 mi_set_context 0 65395 NULL
110681 +__alloc_bootmem_nopanic_65397 __alloc_bootmem_nopanic 1 65397 NULL
110682 +trace_seq_to_user_65398 trace_seq_to_user 3 65398 NULL
110683 +mtd_get_device_size_65400 mtd_get_device_size 0 65400 NULL
110684 +__read_vmcore_65402 __read_vmcore 2 65402 NULL
110685 +usb_ep_enable_65405 usb_ep_enable 0 65405 NULL
110686 +ocfs2_write_begin_nolock_65410 ocfs2_write_begin_nolock 4-3 65410 NULL
110687 +drm_calloc_large_65421 drm_calloc_large 2-1 65421 NULL
110688 +device_add_groups_65423 device_add_groups 0 65423 NULL
110689 +xpc_kzalloc_cacheline_aligned_65433 xpc_kzalloc_cacheline_aligned 1 65433 NULL
110690 +vmalloc_to_pfn_65437 vmalloc_to_pfn 0 65437 NULL
110691 +usb_alloc_coherent_65444 usb_alloc_coherent 2 65444 NULL
110692 +il_dbgfs_wd_timeout_write_65464 il_dbgfs_wd_timeout_write 3 65464 NULL
110693 +ext4_es_zeroout_65465 ext4_es_zeroout 0 65465 NULL
110694 +clear_user_65470 clear_user 2 65470 NULL
110695 +__pcibus_to_node_65489 __pcibus_to_node 0 65489 NULL nohasharray
110696 +dpcm_state_read_file_65489 dpcm_state_read_file 3 65489 &__pcibus_to_node_65489
110697 +lookup_inline_extent_backref_65493 lookup_inline_extent_backref 9-0 65493 NULL
110698 +qib_create_ctxtdata_65497 qib_create_ctxtdata 3 65497 NULL
110699 +nvme_trans_standard_inquiry_page_65526 nvme_trans_standard_inquiry_page 4 65526 NULL
110700 diff --git a/tools/gcc/size_overflow_plugin.c b/tools/gcc/size_overflow_plugin.c
110701 new file mode 100644
110702 index 0000000..5515dcb
110703 --- /dev/null
110704 +++ b/tools/gcc/size_overflow_plugin.c
110705 @@ -0,0 +1,3927 @@
110706 +/*
110707 + * Copyright 2011, 2012, 2013 by Emese Revfy <re.emese@gmail.com>
110708 + * Licensed under the GPL v2, or (at your option) v3
110709 + *
110710 + * Homepage:
110711 + * http://www.grsecurity.net/~ephox/overflow_plugin/
110712 + *
110713 + * Documentation:
110714 + * http://forums.grsecurity.net/viewtopic.php?f=7&t=3043
110715 + *
110716 + * This plugin recomputes expressions of function arguments marked by a size_overflow attribute
110717 + * with double integer precision (DImode/TImode for 32/64 bit integer types).
110718 + * The recomputed argument is checked against TYPE_MAX and an event is logged on overflow and the triggering process is killed.
110719 + *
110720 + * Usage:
110721 + * $ 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
110722 + * $ gcc -fplugin=size_overflow_plugin.so test.c -O2
110723 + */
110724 +
110725 +#include "gcc-plugin.h"
110726 +#include "config.h"
110727 +#include "system.h"
110728 +#include "coretypes.h"
110729 +#include "tree.h"
110730 +#include "tree-pass.h"
110731 +#include "intl.h"
110732 +#include "plugin-version.h"
110733 +#include "tm.h"
110734 +#include "toplev.h"
110735 +#include "function.h"
110736 +#include "tree-flow.h"
110737 +#include "plugin.h"
110738 +#include "gimple.h"
110739 +#include "diagnostic.h"
110740 +#include "cfgloop.h"
110741 +
110742 +#if BUILDING_GCC_VERSION >= 4008
110743 +#define TODO_dump_func 0
110744 +#define TODO_dump_cgraph 0
110745 +#endif
110746 +
110747 +#define __unused __attribute__((__unused__))
110748 +#define ASM_NAME(node) IDENTIFIER_POINTER(DECL_ASSEMBLER_NAME(node))
110749 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
110750 +#define NAME_LEN(node) IDENTIFIER_LENGTH(DECL_NAME(node))
110751 +#define BEFORE_STMT true
110752 +#define AFTER_STMT false
110753 +#define CREATE_NEW_VAR NULL_TREE
110754 +#define CODES_LIMIT 32
110755 +#define MAX_PARAM 31
110756 +#define VEC_LEN 128
110757 +#define MY_STMT GF_PLF_1
110758 +#define NO_CAST_CHECK GF_PLF_2
110759 +#define RET_CHECK NULL_TREE
110760 +#define CANNOT_FIND_ARG 32
110761 +#define WRONG_NODE 32
110762 +#define NOT_INTENTIONAL_ASM NULL
110763 +#define MIN_CHECK true
110764 +#define MAX_CHECK false
110765 +
110766 +#define TURN_OFF_ASM_STR "# size_overflow MARK_TURN_OFF\n\t"
110767 +#define YES_ASM_STR "# size_overflow MARK_YES\n\t"
110768 +#define OK_ASM_STR "# size_overflow\n\t"
110769 +
110770 +#if BUILDING_GCC_VERSION == 4005
110771 +#define DECL_CHAIN(NODE) (TREE_CHAIN(DECL_MINIMAL_CHECK(NODE)))
110772 +#endif
110773 +
110774 +struct size_overflow_hash {
110775 + const struct size_overflow_hash * const next;
110776 + const char * const name;
110777 + const unsigned int param;
110778 +};
110779 +
110780 +#include "size_overflow_hash.h"
110781 +
110782 +enum mark {
110783 + MARK_NO, MARK_YES, MARK_NOT_INTENTIONAL, MARK_TURN_OFF
110784 +};
110785 +
110786 +static unsigned int call_count;
110787 +
110788 +struct visited {
110789 + struct visited *next;
110790 + const_tree fndecl;
110791 + unsigned int num;
110792 + const_gimple first_stmt;
110793 +};
110794 +
110795 +struct next_cgraph_node {
110796 + struct next_cgraph_node *next;
110797 + struct cgraph_node *current_function;
110798 + tree callee_fndecl;
110799 + unsigned int num;
110800 +};
110801 +
110802 +struct interesting_node {
110803 + struct interesting_node *next;
110804 + gimple first_stmt;
110805 + const_tree fndecl;
110806 + tree node;
110807 +#if BUILDING_GCC_VERSION <= 4007
110808 + VEC(tree, gc) *last_nodes;
110809 +#else
110810 + vec<tree, va_gc> *last_nodes;
110811 +#endif
110812 + unsigned int num;
110813 + enum mark intentional_attr_decl;
110814 + enum mark intentional_attr_cur_fndecl;
110815 + gimple intentional_mark_from_gimple;
110816 +};
110817 +
110818 +int plugin_is_GPL_compatible;
110819 +void debug_gimple_stmt(gimple gs);
110820 +
110821 +static tree report_size_overflow_decl;
110822 +static const_tree const_char_ptr_type_node;
110823 +
110824 +static tree expand(struct pointer_set_t *visited, struct cgraph_node *caller_node, tree lhs);
110825 +static void set_conditions(struct pointer_set_t *visited, bool *interesting_conditions, const_tree lhs);
110826 +static void walk_use_def(struct pointer_set_t *visited, struct interesting_node *cur_node, tree lhs);
110827 +static enum mark search_intentional(struct pointer_set_t *visited, const_tree lhs);
110828 +static void search_size_overflow_attribute(struct pointer_set_t *visited, tree lhs);
110829 +
110830 +static void check_size_overflow(struct cgraph_node *caller_node, gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before);
110831 +static tree get_size_overflow_type(gimple stmt, const_tree node);
110832 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3);
110833 +
110834 +static struct plugin_info size_overflow_plugin_info = {
110835 + .version = "20131214beta",
110836 + .help = "no-size-overflow\tturn off size overflow checking\n",
110837 +};
110838 +
110839 +static tree handle_size_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
110840 +{
110841 + unsigned int arg_count;
110842 + enum tree_code code = TREE_CODE(*node);
110843 +
110844 + switch (code) {
110845 + case FUNCTION_DECL:
110846 + arg_count = type_num_arguments(TREE_TYPE(*node));
110847 + break;
110848 + case FUNCTION_TYPE:
110849 + case METHOD_TYPE:
110850 + arg_count = type_num_arguments(*node);
110851 + break;
110852 + default:
110853 + *no_add_attrs = true;
110854 + error("%s: %qE attribute only applies to functions", __func__, name);
110855 + return NULL_TREE;
110856 + }
110857 +
110858 + for (; args; args = TREE_CHAIN(args)) {
110859 + tree position = TREE_VALUE(args);
110860 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
110861 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
110862 + *no_add_attrs = true;
110863 + }
110864 + }
110865 + return NULL_TREE;
110866 +}
110867 +
110868 +static tree handle_intentional_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
110869 +{
110870 + unsigned int arg_count;
110871 + enum tree_code code = TREE_CODE(*node);
110872 +
110873 + switch (code) {
110874 + case FUNCTION_DECL:
110875 + arg_count = type_num_arguments(TREE_TYPE(*node));
110876 + break;
110877 + case FUNCTION_TYPE:
110878 + case METHOD_TYPE:
110879 + arg_count = type_num_arguments(*node);
110880 + break;
110881 + case FIELD_DECL:
110882 + return NULL_TREE;
110883 + default:
110884 + *no_add_attrs = true;
110885 + error("%qE attribute only applies to functions", name);
110886 + return NULL_TREE;
110887 + }
110888 +
110889 + if (TREE_INT_CST_HIGH(TREE_VALUE(args)) != 0)
110890 + return NULL_TREE;
110891 +
110892 + for (; args; args = TREE_CHAIN(args)) {
110893 + tree position = TREE_VALUE(args);
110894 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
110895 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
110896 + *no_add_attrs = true;
110897 + }
110898 + }
110899 + return NULL_TREE;
110900 +}
110901 +
110902 +static struct attribute_spec size_overflow_attr = {
110903 + .name = "size_overflow",
110904 + .min_length = 1,
110905 + .max_length = -1,
110906 + .decl_required = true,
110907 + .type_required = false,
110908 + .function_type_required = false,
110909 + .handler = handle_size_overflow_attribute,
110910 +#if BUILDING_GCC_VERSION >= 4007
110911 + .affects_type_identity = false
110912 +#endif
110913 +};
110914 +
110915 +static struct attribute_spec intentional_overflow_attr = {
110916 + .name = "intentional_overflow",
110917 + .min_length = 1,
110918 + .max_length = -1,
110919 + .decl_required = true,
110920 + .type_required = false,
110921 + .function_type_required = false,
110922 + .handler = handle_intentional_overflow_attribute,
110923 +#if BUILDING_GCC_VERSION >= 4007
110924 + .affects_type_identity = false
110925 +#endif
110926 +};
110927 +
110928 +static void register_attributes(void __unused *event_data, void __unused *data)
110929 +{
110930 + register_attribute(&size_overflow_attr);
110931 + register_attribute(&intentional_overflow_attr);
110932 +}
110933 +
110934 +static bool is_bool(const_tree node)
110935 +{
110936 + const_tree type;
110937 +
110938 + if (node == NULL_TREE)
110939 + return false;
110940 +
110941 + type = TREE_TYPE(node);
110942 + if (!INTEGRAL_TYPE_P(type))
110943 + return false;
110944 + if (TREE_CODE(type) == BOOLEAN_TYPE)
110945 + return true;
110946 + if (TYPE_PRECISION(type) == 1)
110947 + return true;
110948 + return false;
110949 +}
110950 +
110951 +static bool skip_types(const_tree var)
110952 +{
110953 + tree type;
110954 + enum tree_code code;
110955 +
110956 + if (is_gimple_constant(var))
110957 + return true;
110958 +
110959 + switch (TREE_CODE(var)) {
110960 + case ADDR_EXPR:
110961 +#if BUILDING_GCC_VERSION >= 4006
110962 + case MEM_REF:
110963 +#endif
110964 + case ARRAY_REF:
110965 + case BIT_FIELD_REF:
110966 + case INDIRECT_REF:
110967 + case TARGET_MEM_REF:
110968 + case COMPONENT_REF:
110969 + case VAR_DECL:
110970 + case VIEW_CONVERT_EXPR:
110971 + return true;
110972 + default:
110973 + break;
110974 + }
110975 +
110976 + code = TREE_CODE(var);
110977 + gcc_assert(code == SSA_NAME || code == PARM_DECL);
110978 +
110979 + type = TREE_TYPE(var);
110980 + switch (TREE_CODE(type)) {
110981 + case INTEGER_TYPE:
110982 + case ENUMERAL_TYPE:
110983 + return false;
110984 + case BOOLEAN_TYPE:
110985 + return is_bool(var);
110986 + default:
110987 + return true;
110988 + }
110989 +}
110990 +
110991 +static inline gimple get_def_stmt(const_tree node)
110992 +{
110993 + gcc_assert(node != NULL_TREE);
110994 +
110995 + if (skip_types(node))
110996 + return NULL;
110997 +
110998 + if (TREE_CODE(node) != SSA_NAME)
110999 + return NULL;
111000 + return SSA_NAME_DEF_STMT(node);
111001 +}
111002 +
111003 +static unsigned char get_tree_code(const_tree type)
111004 +{
111005 + switch (TREE_CODE(type)) {
111006 + case ARRAY_TYPE:
111007 + return 0;
111008 + case BOOLEAN_TYPE:
111009 + return 1;
111010 + case ENUMERAL_TYPE:
111011 + return 2;
111012 + case FUNCTION_TYPE:
111013 + return 3;
111014 + case INTEGER_TYPE:
111015 + return 4;
111016 + case POINTER_TYPE:
111017 + return 5;
111018 + case RECORD_TYPE:
111019 + return 6;
111020 + case UNION_TYPE:
111021 + return 7;
111022 + case VOID_TYPE:
111023 + return 8;
111024 + case REAL_TYPE:
111025 + return 9;
111026 + case VECTOR_TYPE:
111027 + return 10;
111028 + case REFERENCE_TYPE:
111029 + return 11;
111030 + case OFFSET_TYPE:
111031 + return 12;
111032 + case COMPLEX_TYPE:
111033 + return 13;
111034 + default:
111035 + debug_tree((tree)type);
111036 + gcc_unreachable();
111037 + }
111038 +}
111039 +
111040 +struct function_hash {
111041 + size_t tree_codes_len;
111042 + unsigned char tree_codes[CODES_LIMIT];
111043 + tree fndecl;
111044 + unsigned int hash;
111045 +};
111046 +
111047 +// http://www.team5150.com/~andrew/noncryptohashzoo2~/CrapWow.html
111048 +static unsigned int CrapWow(const char *key, unsigned int len, unsigned int seed)
111049 +{
111050 +#define cwfold( a, b, lo, hi ) { p = (unsigned int)(a) * (unsigned long long)(b); lo ^= (unsigned int)p; hi ^= (unsigned int)(p >> 32); }
111051 +#define cwmixa( in ) { cwfold( in, m, k, h ); }
111052 +#define cwmixb( in ) { cwfold( in, n, h, k ); }
111053 +
111054 + unsigned int m = 0x57559429;
111055 + unsigned int n = 0x5052acdb;
111056 + const unsigned int *key4 = (const unsigned int *)key;
111057 + unsigned int h = len;
111058 + unsigned int k = len + seed + n;
111059 + unsigned long long p;
111060 +
111061 + while (len >= 8) {
111062 + cwmixb(key4[0]) cwmixa(key4[1]) key4 += 2;
111063 + len -= 8;
111064 + }
111065 + if (len >= 4) {
111066 + cwmixb(key4[0]) key4 += 1;
111067 + len -= 4;
111068 + }
111069 + if (len)
111070 + cwmixa(key4[0] & ((1 << (len * 8)) - 1 ));
111071 + cwmixb(h ^ (k + n));
111072 + return k ^ h;
111073 +
111074 +#undef cwfold
111075 +#undef cwmixa
111076 +#undef cwmixb
111077 +}
111078 +
111079 +static void set_hash(const char *fn_name, struct function_hash *fn_hash_data)
111080 +{
111081 + unsigned int fn, codes, seed = 0;
111082 +
111083 + fn = CrapWow(fn_name, strlen(fn_name), seed) & 0xffff;
111084 + codes = CrapWow((const char*)fn_hash_data->tree_codes, fn_hash_data->tree_codes_len, seed) & 0xffff;
111085 +
111086 + fn_hash_data->hash = fn ^ codes;
111087 +}
111088 +
111089 +static void set_node_codes(const_tree type, struct function_hash *fn_hash_data)
111090 +{
111091 + gcc_assert(type != NULL_TREE);
111092 + gcc_assert(TREE_CODE_CLASS(TREE_CODE(type)) == tcc_type);
111093 +
111094 + while (type && fn_hash_data->tree_codes_len < CODES_LIMIT) {
111095 + fn_hash_data->tree_codes[fn_hash_data->tree_codes_len] = get_tree_code(type);
111096 + fn_hash_data->tree_codes_len++;
111097 + type = TREE_TYPE(type);
111098 + }
111099 +}
111100 +
111101 +static void set_result_codes(const_tree node, struct function_hash *fn_hash_data)
111102 +{
111103 + const_tree result;
111104 +
111105 + gcc_assert(node != NULL_TREE);
111106 +
111107 + if (DECL_P(node)) {
111108 + result = DECL_RESULT(node);
111109 + if (result != NULL_TREE)
111110 + return set_node_codes(TREE_TYPE(result), fn_hash_data);
111111 + return set_result_codes(TREE_TYPE(node), fn_hash_data);
111112 + }
111113 +
111114 + gcc_assert(TYPE_P(node));
111115 +
111116 + if (TREE_CODE(node) == FUNCTION_TYPE)
111117 + return set_result_codes(TREE_TYPE(node), fn_hash_data);
111118 +
111119 + return set_node_codes(node, fn_hash_data);
111120 +}
111121 +
111122 +static void set_function_codes(struct function_hash *fn_hash_data)
111123 +{
111124 + const_tree arg, type = TREE_TYPE(fn_hash_data->fndecl);
111125 + enum tree_code code = TREE_CODE(type);
111126 +
111127 + gcc_assert(code == FUNCTION_TYPE || code == METHOD_TYPE);
111128 +
111129 + set_result_codes(fn_hash_data->fndecl, fn_hash_data);
111130 +
111131 + for (arg = TYPE_ARG_TYPES(type); arg != NULL_TREE && fn_hash_data->tree_codes_len < CODES_LIMIT; arg = TREE_CHAIN(arg))
111132 + set_node_codes(TREE_VALUE(arg), fn_hash_data);
111133 +}
111134 +
111135 +static const struct size_overflow_hash *get_function_hash(tree fndecl)
111136 +{
111137 + const struct size_overflow_hash *entry;
111138 + struct function_hash fn_hash_data;
111139 + const char *func_name;
111140 +
111141 + // skip builtins __builtin_constant_p
111142 + if (DECL_BUILT_IN(fndecl))
111143 + return NULL;
111144 +
111145 + fn_hash_data.fndecl = fndecl;
111146 + fn_hash_data.tree_codes_len = 0;
111147 +
111148 + set_function_codes(&fn_hash_data);
111149 + gcc_assert(fn_hash_data.tree_codes_len != 0);
111150 +
111151 + func_name = ASM_NAME(fn_hash_data.fndecl);
111152 + set_hash(func_name, &fn_hash_data);
111153 +
111154 + entry = size_overflow_hash[fn_hash_data.hash];
111155 +
111156 + while (entry) {
111157 + if (!strcmp(entry->name, func_name))
111158 + return entry;
111159 + entry = entry->next;
111160 + }
111161 + return NULL;
111162 +}
111163 +
111164 +static void print_missing_msg(tree func, unsigned int argnum)
111165 +{
111166 + location_t loc;
111167 + const char *curfunc;
111168 + struct function_hash fn_hash_data;
111169 +
111170 + fn_hash_data.fndecl = DECL_ORIGIN(func);
111171 + fn_hash_data.tree_codes_len = 0;
111172 +
111173 + loc = DECL_SOURCE_LOCATION(fn_hash_data.fndecl);
111174 + curfunc = ASM_NAME(fn_hash_data.fndecl);
111175 +
111176 + set_function_codes(&fn_hash_data);
111177 + set_hash(curfunc, &fn_hash_data);
111178 +
111179 + inform(loc, "Function %s is missing from the size_overflow hash table +%s+%u+%u+", curfunc, curfunc, argnum, fn_hash_data.hash);
111180 +}
111181 +
111182 +static unsigned int find_arg_number_tree(const_tree arg, const_tree func)
111183 +{
111184 + tree var;
111185 + unsigned int argnum = 1;
111186 +
111187 + if (TREE_CODE(arg) == SSA_NAME)
111188 + arg = SSA_NAME_VAR(arg);
111189 +
111190 + for (var = DECL_ARGUMENTS(func); var; var = TREE_CHAIN(var), argnum++) {
111191 + if (!operand_equal_p(arg, var, 0) && strcmp(NAME(var), NAME(arg)))
111192 + continue;
111193 + if (!skip_types(var))
111194 + return argnum;
111195 + }
111196 +
111197 + return CANNOT_FIND_ARG;
111198 +}
111199 +
111200 +static tree create_new_var(tree type)
111201 +{
111202 + tree new_var = create_tmp_var(type, "cicus");
111203 +
111204 +#if BUILDING_GCC_VERSION <= 4007
111205 + add_referenced_var(new_var);
111206 +#endif
111207 + return new_var;
111208 +}
111209 +
111210 +static gimple create_binary_assign(enum tree_code code, gimple stmt, tree rhs1, tree rhs2)
111211 +{
111212 + gimple assign;
111213 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
111214 + tree type = TREE_TYPE(rhs1);
111215 + tree lhs = create_new_var(type);
111216 +
111217 + gcc_assert(types_compatible_p(type, TREE_TYPE(rhs2)));
111218 + assign = gimple_build_assign_with_ops(code, lhs, rhs1, rhs2);
111219 + gimple_assign_set_lhs(assign, make_ssa_name(lhs, assign));
111220 +
111221 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
111222 + update_stmt(assign);
111223 + gimple_set_plf(assign, MY_STMT, true);
111224 + return assign;
111225 +}
111226 +
111227 +static tree cast_a_tree(tree type, tree var)
111228 +{
111229 + gcc_assert(type != NULL_TREE);
111230 + gcc_assert(var != NULL_TREE);
111231 + gcc_assert(fold_convertible_p(type, var));
111232 +
111233 + return fold_convert(type, var);
111234 +}
111235 +
111236 +static tree get_lhs(const_gimple stmt)
111237 +{
111238 + switch (gimple_code(stmt)) {
111239 + case GIMPLE_ASSIGN:
111240 + case GIMPLE_CALL:
111241 + return gimple_get_lhs(stmt);
111242 + case GIMPLE_PHI:
111243 + return gimple_phi_result(stmt);
111244 + default:
111245 + return NULL_TREE;
111246 + }
111247 +}
111248 +
111249 +static bool skip_cast(tree dst_type, const_tree rhs, bool force)
111250 +{
111251 + const_gimple def_stmt = get_def_stmt(rhs);
111252 +
111253 + if (force)
111254 + return false;
111255 +
111256 + if (is_gimple_constant(rhs))
111257 + return false;
111258 +
111259 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
111260 + return false;
111261 +
111262 + if (!types_compatible_p(dst_type, TREE_TYPE(rhs)))
111263 + return false;
111264 +
111265 + // DI type can be on 32 bit (from create_assign) but overflow type stays DI
111266 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
111267 + return false;
111268 +
111269 + return true;
111270 +}
111271 +
111272 +static gimple build_cast_stmt(tree dst_type, tree rhs, tree lhs, gimple_stmt_iterator *gsi, bool before, bool force)
111273 +{
111274 + gimple assign, def_stmt;
111275 +
111276 + gcc_assert(dst_type != NULL_TREE && rhs != NULL_TREE);
111277 + if (gsi_end_p(*gsi) && before == AFTER_STMT)
111278 + gcc_unreachable();
111279 +
111280 + def_stmt = get_def_stmt(rhs);
111281 + if (def_stmt && gimple_code(def_stmt) != GIMPLE_NOP && skip_cast(dst_type, rhs, force) && gimple_plf(def_stmt, MY_STMT))
111282 + return def_stmt;
111283 +
111284 + if (lhs == CREATE_NEW_VAR)
111285 + lhs = create_new_var(dst_type);
111286 +
111287 + assign = gimple_build_assign(lhs, cast_a_tree(dst_type, rhs));
111288 +
111289 + if (!gsi_end_p(*gsi)) {
111290 + location_t loc = gimple_location(gsi_stmt(*gsi));
111291 + gimple_set_location(assign, loc);
111292 + }
111293 +
111294 + gimple_assign_set_lhs(assign, make_ssa_name(lhs, assign));
111295 +
111296 + if (before)
111297 + gsi_insert_before(gsi, assign, GSI_NEW_STMT);
111298 + else
111299 + gsi_insert_after(gsi, assign, GSI_NEW_STMT);
111300 + update_stmt(assign);
111301 + return assign;
111302 +}
111303 +
111304 +static tree cast_to_new_size_overflow_type(gimple stmt, tree rhs, tree size_overflow_type, bool before)
111305 +{
111306 + gimple_stmt_iterator gsi;
111307 + tree lhs;
111308 + gimple new_stmt;
111309 +
111310 + if (rhs == NULL_TREE)
111311 + return NULL_TREE;
111312 +
111313 + gsi = gsi_for_stmt(stmt);
111314 + new_stmt = build_cast_stmt(size_overflow_type, rhs, CREATE_NEW_VAR, &gsi, before, false);
111315 + gimple_set_plf(new_stmt, MY_STMT, true);
111316 +
111317 + lhs = get_lhs(new_stmt);
111318 + gcc_assert(lhs != NULL_TREE);
111319 + return lhs;
111320 +}
111321 +
111322 +static tree cast_to_TI_type(gimple stmt, tree node)
111323 +{
111324 + gimple_stmt_iterator gsi;
111325 + gimple cast_stmt;
111326 + tree type = TREE_TYPE(node);
111327 +
111328 + if (types_compatible_p(type, intTI_type_node))
111329 + return node;
111330 +
111331 + gsi = gsi_for_stmt(stmt);
111332 + cast_stmt = build_cast_stmt(intTI_type_node, node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
111333 + gimple_set_plf(cast_stmt, MY_STMT, true);
111334 + return gimple_assign_lhs(cast_stmt);
111335 +}
111336 +
111337 +static tree create_assign(struct pointer_set_t *visited, gimple oldstmt, tree rhs1, bool before)
111338 +{
111339 + tree lhs, new_lhs;
111340 + gimple_stmt_iterator gsi;
111341 +
111342 + if (rhs1 == NULL_TREE) {
111343 + debug_gimple_stmt(oldstmt);
111344 + error("%s: rhs1 is NULL_TREE", __func__);
111345 + gcc_unreachable();
111346 + }
111347 +
111348 + switch (gimple_code(oldstmt)) {
111349 + case GIMPLE_ASM:
111350 + lhs = rhs1;
111351 + break;
111352 + case GIMPLE_CALL:
111353 + case GIMPLE_ASSIGN:
111354 + lhs = gimple_get_lhs(oldstmt);
111355 + break;
111356 + default:
111357 + debug_gimple_stmt(oldstmt);
111358 + gcc_unreachable();
111359 + }
111360 +
111361 + gsi = gsi_for_stmt(oldstmt);
111362 + pointer_set_insert(visited, oldstmt);
111363 + if (lookup_stmt_eh_lp(oldstmt) != 0) {
111364 + basic_block next_bb, cur_bb;
111365 + const_edge e;
111366 +
111367 + gcc_assert(before == false);
111368 + gcc_assert(stmt_can_throw_internal(oldstmt));
111369 + gcc_assert(gimple_code(oldstmt) == GIMPLE_CALL);
111370 + gcc_assert(!gsi_end_p(gsi));
111371 +
111372 + cur_bb = gimple_bb(oldstmt);
111373 + next_bb = cur_bb->next_bb;
111374 + e = find_edge(cur_bb, next_bb);
111375 + gcc_assert(e != NULL);
111376 + gcc_assert(e->flags & EDGE_FALLTHRU);
111377 +
111378 + gsi = gsi_after_labels(next_bb);
111379 + gcc_assert(!gsi_end_p(gsi));
111380 +
111381 + before = true;
111382 + oldstmt = gsi_stmt(gsi);
111383 + }
111384 +
111385 + new_lhs = cast_to_new_size_overflow_type(oldstmt, rhs1, get_size_overflow_type(oldstmt, lhs), before);
111386 + return new_lhs;
111387 +}
111388 +
111389 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3)
111390 +{
111391 + gimple stmt;
111392 + gimple_stmt_iterator gsi;
111393 + tree size_overflow_type, new_var, lhs = gimple_assign_lhs(oldstmt);
111394 +
111395 + if (gimple_plf(oldstmt, MY_STMT))
111396 + return lhs;
111397 +
111398 + if (gimple_num_ops(oldstmt) != 4 && rhs1 == NULL_TREE) {
111399 + rhs1 = gimple_assign_rhs1(oldstmt);
111400 + rhs1 = create_assign(visited, oldstmt, rhs1, BEFORE_STMT);
111401 + }
111402 + if (gimple_num_ops(oldstmt) == 3 && rhs2 == NULL_TREE) {
111403 + rhs2 = gimple_assign_rhs2(oldstmt);
111404 + rhs2 = create_assign(visited, oldstmt, rhs2, BEFORE_STMT);
111405 + }
111406 +
111407 + stmt = gimple_copy(oldstmt);
111408 + gimple_set_location(stmt, gimple_location(oldstmt));
111409 + gimple_set_plf(stmt, MY_STMT, true);
111410 +
111411 + if (gimple_assign_rhs_code(oldstmt) == WIDEN_MULT_EXPR)
111412 + gimple_assign_set_rhs_code(stmt, MULT_EXPR);
111413 +
111414 + size_overflow_type = get_size_overflow_type(oldstmt, node);
111415 +
111416 + new_var = create_new_var(size_overflow_type);
111417 + new_var = make_ssa_name(new_var, stmt);
111418 + gimple_assign_set_lhs(stmt, new_var);
111419 +
111420 + if (rhs1 != NULL_TREE)
111421 + gimple_assign_set_rhs1(stmt, rhs1);
111422 +
111423 + if (rhs2 != NULL_TREE)
111424 + gimple_assign_set_rhs2(stmt, rhs2);
111425 +#if BUILDING_GCC_VERSION >= 4007
111426 + if (rhs3 != NULL_TREE)
111427 + gimple_assign_set_rhs3(stmt, rhs3);
111428 +#endif
111429 + gimple_set_vuse(stmt, gimple_vuse(oldstmt));
111430 + gimple_set_vdef(stmt, gimple_vdef(oldstmt));
111431 +
111432 + gsi = gsi_for_stmt(oldstmt);
111433 + gsi_insert_after(&gsi, stmt, GSI_SAME_STMT);
111434 + update_stmt(stmt);
111435 + pointer_set_insert(visited, oldstmt);
111436 + return gimple_assign_lhs(stmt);
111437 +}
111438 +
111439 +static tree cast_parm_decl(tree phi_ssa_name, tree arg, tree size_overflow_type, basic_block bb)
111440 +{
111441 + gimple assign;
111442 + gimple_stmt_iterator gsi;
111443 + basic_block first_bb;
111444 +
111445 + gcc_assert(SSA_NAME_IS_DEFAULT_DEF(arg));
111446 +
111447 + if (bb->index == 0) {
111448 + first_bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
111449 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
111450 + set_immediate_dominator(CDI_DOMINATORS, first_bb, ENTRY_BLOCK_PTR);
111451 + bb = first_bb;
111452 + }
111453 +
111454 + gsi = gsi_after_labels(bb);
111455 + assign = build_cast_stmt(size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
111456 + gimple_set_plf(assign, MY_STMT, true);
111457 +
111458 + return gimple_assign_lhs(assign);
111459 +}
111460 +
111461 +static tree use_phi_ssa_name(tree ssa_name_var, tree new_arg)
111462 +{
111463 + gimple_stmt_iterator gsi;
111464 + gimple assign, def_stmt = get_def_stmt(new_arg);
111465 +
111466 + if (gimple_code(def_stmt) == GIMPLE_PHI) {
111467 + gsi = gsi_after_labels(gimple_bb(def_stmt));
111468 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, ssa_name_var, &gsi, BEFORE_STMT, true);
111469 + } else {
111470 + gsi = gsi_for_stmt(def_stmt);
111471 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, ssa_name_var, &gsi, AFTER_STMT, true);
111472 + }
111473 +
111474 + gimple_set_plf(assign, MY_STMT, true);
111475 + return gimple_assign_lhs(assign);
111476 +}
111477 +
111478 +static tree cast_visited_phi_arg(tree ssa_name_var, tree arg, tree size_overflow_type)
111479 +{
111480 + basic_block bb;
111481 + gimple_stmt_iterator gsi;
111482 + const_gimple def_stmt;
111483 + gimple assign;
111484 +
111485 + def_stmt = get_def_stmt(arg);
111486 + bb = gimple_bb(def_stmt);
111487 + gcc_assert(bb->index != 0);
111488 + gsi = gsi_after_labels(bb);
111489 +
111490 + assign = build_cast_stmt(size_overflow_type, arg, ssa_name_var, &gsi, BEFORE_STMT, false);
111491 + gimple_set_plf(assign, MY_STMT, true);
111492 + return gimple_assign_lhs(assign);
111493 +}
111494 +
111495 +static tree create_new_phi_arg(tree ssa_name_var, tree new_arg, gimple oldstmt, unsigned int i)
111496 +{
111497 + tree size_overflow_type;
111498 + tree arg;
111499 + const_gimple def_stmt;
111500 +
111501 + if (new_arg != NULL_TREE && is_gimple_constant(new_arg))
111502 + return new_arg;
111503 +
111504 + arg = gimple_phi_arg_def(oldstmt, i);
111505 + def_stmt = get_def_stmt(arg);
111506 + gcc_assert(def_stmt != NULL);
111507 + size_overflow_type = get_size_overflow_type(oldstmt, arg);
111508 +
111509 + switch (gimple_code(def_stmt)) {
111510 + case GIMPLE_PHI:
111511 + return cast_visited_phi_arg(ssa_name_var, arg, size_overflow_type);
111512 + case GIMPLE_NOP: {
111513 + basic_block bb;
111514 +
111515 + bb = gimple_phi_arg_edge(oldstmt, i)->src;
111516 + return cast_parm_decl(ssa_name_var, arg, size_overflow_type, bb);
111517 + }
111518 + case GIMPLE_ASM: {
111519 + gimple_stmt_iterator gsi;
111520 + gimple assign, stmt = get_def_stmt(arg);
111521 +
111522 + gsi = gsi_for_stmt(stmt);
111523 + assign = build_cast_stmt(size_overflow_type, arg, ssa_name_var, &gsi, AFTER_STMT, false);
111524 + gimple_set_plf(assign, MY_STMT, true);
111525 + return gimple_assign_lhs(assign);
111526 + }
111527 + default:
111528 + gcc_assert(new_arg != NULL_TREE);
111529 + gcc_assert(types_compatible_p(TREE_TYPE(new_arg), size_overflow_type));
111530 + return use_phi_ssa_name(ssa_name_var, new_arg);
111531 + }
111532 +}
111533 +
111534 +static gimple overflow_create_phi_node(gimple oldstmt, tree result)
111535 +{
111536 + basic_block bb;
111537 + gimple phi;
111538 + gimple_seq seq;
111539 + gimple_stmt_iterator gsi = gsi_for_stmt(oldstmt);
111540 +
111541 + bb = gsi_bb(gsi);
111542 +
111543 + if (result == NULL_TREE) {
111544 + tree old_result = gimple_phi_result(oldstmt);
111545 + tree size_overflow_type = get_size_overflow_type(oldstmt, old_result);
111546 +
111547 + result = create_new_var(size_overflow_type);
111548 + }
111549 +
111550 + phi = create_phi_node(result, bb);
111551 + gimple_phi_set_result(phi, make_ssa_name(result, phi));
111552 + seq = phi_nodes(bb);
111553 + gsi = gsi_last(seq);
111554 + gsi_remove(&gsi, false);
111555 +
111556 + gsi = gsi_for_stmt(oldstmt);
111557 + gsi_insert_after(&gsi, phi, GSI_NEW_STMT);
111558 + gimple_set_bb(phi, bb);
111559 + gimple_set_plf(phi, MY_STMT, true);
111560 + return phi;
111561 +}
111562 +
111563 +#if BUILDING_GCC_VERSION <= 4007
111564 +static tree create_new_phi_node(VEC(tree, gc) *args, tree ssa_name_var, gimple oldstmt)
111565 +#else
111566 +static tree create_new_phi_node(vec<tree, va_gc> *args, tree ssa_name_var, gimple oldstmt)
111567 +#endif
111568 +{
111569 + gimple new_phi;
111570 + unsigned int i;
111571 + tree arg, result;
111572 + location_t loc = gimple_location(oldstmt);
111573 +
111574 +#if BUILDING_GCC_VERSION <= 4007
111575 + gcc_assert(!VEC_empty(tree, args));
111576 +#else
111577 + gcc_assert(!args->is_empty());
111578 +#endif
111579 +
111580 + new_phi = overflow_create_phi_node(oldstmt, ssa_name_var);
111581 + result = gimple_phi_result(new_phi);
111582 + ssa_name_var = SSA_NAME_VAR(result);
111583 +
111584 +
111585 +#if BUILDING_GCC_VERSION == 4005
111586 + for (i = 0; i < VEC_length(tree, args); i++) {
111587 + arg = VEC_index(tree, args, i);
111588 +#elif BUILDING_GCC_VERSION <= 4007
111589 + FOR_EACH_VEC_ELT(tree, args, i, arg) {
111590 +#else
111591 + FOR_EACH_VEC_ELT(*args, i, arg) {
111592 +#endif
111593 + arg = create_new_phi_arg(ssa_name_var, arg, oldstmt, i);
111594 + add_phi_arg(new_phi, arg, gimple_phi_arg_edge(oldstmt, i), loc);
111595 + }
111596 +
111597 +#if BUILDING_GCC_VERSION <= 4007
111598 + VEC_free(tree, gc, args);
111599 +#else
111600 + vec_free(args);
111601 +#endif
111602 + update_stmt(new_phi);
111603 + return result;
111604 +}
111605 +
111606 +static tree handle_phi(struct pointer_set_t *visited, struct cgraph_node *caller_node, tree orig_result)
111607 +{
111608 + tree ssa_name_var = NULL_TREE;
111609 +#if BUILDING_GCC_VERSION <= 4007
111610 + VEC(tree, gc) *args;
111611 +#else
111612 + vec<tree, va_gc> *args;
111613 +#endif
111614 + gimple oldstmt = get_def_stmt(orig_result);
111615 + unsigned int i, len = gimple_phi_num_args(oldstmt);
111616 +
111617 + pointer_set_insert(visited, oldstmt);
111618 +#if BUILDING_GCC_VERSION <= 4007
111619 + args = VEC_alloc(tree, gc, len);
111620 +#else
111621 + vec_alloc(args, len);
111622 +#endif
111623 + for (i = 0; i < len; i++) {
111624 + tree arg, new_arg;
111625 +
111626 + arg = gimple_phi_arg_def(oldstmt, i);
111627 + new_arg = expand(visited, caller_node, arg);
111628 +
111629 + if (ssa_name_var == NULL_TREE && new_arg != NULL_TREE)
111630 + ssa_name_var = SSA_NAME_VAR(new_arg);
111631 +
111632 + if (is_gimple_constant(arg)) {
111633 + tree size_overflow_type = get_size_overflow_type(oldstmt, arg);
111634 +
111635 + new_arg = cast_a_tree(size_overflow_type, arg);
111636 + }
111637 +
111638 +#if BUILDING_GCC_VERSION <= 4007
111639 + VEC_safe_push(tree, gc, args, new_arg);
111640 +#else
111641 + vec_safe_push(args, new_arg);
111642 +#endif
111643 + }
111644 +
111645 + return create_new_phi_node(args, ssa_name_var, oldstmt);
111646 +}
111647 +
111648 +static tree change_assign_rhs(gimple stmt, const_tree orig_rhs, tree new_rhs)
111649 +{
111650 + gimple assign;
111651 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
111652 + tree origtype = TREE_TYPE(orig_rhs);
111653 +
111654 + gcc_assert(is_gimple_assign(stmt));
111655 +
111656 + assign = build_cast_stmt(origtype, new_rhs, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
111657 + gimple_set_plf(assign, MY_STMT, true);
111658 + return gimple_assign_lhs(assign);
111659 +}
111660 +
111661 +static bool is_a_cast_and_const_overflow(const_tree no_const_rhs)
111662 +{
111663 + const_tree rhs1, lhs, rhs1_type, lhs_type;
111664 + enum machine_mode lhs_mode, rhs_mode;
111665 + gimple def_stmt = get_def_stmt(no_const_rhs);
111666 +
111667 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
111668 + return false;
111669 +
111670 + rhs1 = gimple_assign_rhs1(def_stmt);
111671 + lhs = gimple_assign_lhs(def_stmt);
111672 + rhs1_type = TREE_TYPE(rhs1);
111673 + lhs_type = TREE_TYPE(lhs);
111674 + rhs_mode = TYPE_MODE(rhs1_type);
111675 + lhs_mode = TYPE_MODE(lhs_type);
111676 + if (TYPE_UNSIGNED(lhs_type) == TYPE_UNSIGNED(rhs1_type) || lhs_mode != rhs_mode)
111677 + return false;
111678 +
111679 + return true;
111680 +}
111681 +
111682 +static tree create_cast_assign(struct pointer_set_t *visited, gimple stmt)
111683 +{
111684 + tree rhs1 = gimple_assign_rhs1(stmt);
111685 + tree lhs = gimple_assign_lhs(stmt);
111686 + const_tree rhs1_type = TREE_TYPE(rhs1);
111687 + const_tree lhs_type = TREE_TYPE(lhs);
111688 +
111689 + if (TYPE_UNSIGNED(rhs1_type) == TYPE_UNSIGNED(lhs_type))
111690 + return create_assign(visited, stmt, lhs, AFTER_STMT);
111691 +
111692 + return create_assign(visited, stmt, rhs1, AFTER_STMT);
111693 +}
111694 +
111695 +static bool no_uses(tree node)
111696 +{
111697 + imm_use_iterator imm_iter;
111698 + use_operand_p use_p;
111699 +
111700 + FOR_EACH_IMM_USE_FAST(use_p, imm_iter, node) {
111701 + const_gimple use_stmt = USE_STMT(use_p);
111702 +
111703 + if (use_stmt == NULL)
111704 + return true;
111705 + if (is_gimple_debug(use_stmt))
111706 + continue;
111707 + return false;
111708 + }
111709 + return true;
111710 +}
111711 +
111712 +// 3.8.5 mm/page-writeback.c __ilog2_u64(): ret, uint + uintmax; uint -> int; int max
111713 +static bool is_const_plus_unsigned_signed_truncation(const_tree lhs)
111714 +{
111715 + tree rhs1, lhs_type, rhs_type, rhs2, not_const_rhs;
111716 + gimple def_stmt = get_def_stmt(lhs);
111717 +
111718 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
111719 + return false;
111720 +
111721 + rhs1 = gimple_assign_rhs1(def_stmt);
111722 + rhs_type = TREE_TYPE(rhs1);
111723 + lhs_type = TREE_TYPE(lhs);
111724 + if (TYPE_UNSIGNED(lhs_type) || !TYPE_UNSIGNED(rhs_type))
111725 + return false;
111726 + if (TYPE_MODE(lhs_type) != TYPE_MODE(rhs_type))
111727 + return false;
111728 +
111729 + def_stmt = get_def_stmt(rhs1);
111730 + if (!def_stmt || !is_gimple_assign(def_stmt) || gimple_num_ops(def_stmt) != 3)
111731 + return false;
111732 +
111733 + if (gimple_assign_rhs_code(def_stmt) != PLUS_EXPR)
111734 + return false;
111735 +
111736 + rhs1 = gimple_assign_rhs1(def_stmt);
111737 + rhs2 = gimple_assign_rhs2(def_stmt);
111738 + if (!is_gimple_constant(rhs1) && !is_gimple_constant(rhs2))
111739 + return false;
111740 +
111741 + if (is_gimple_constant(rhs2))
111742 + not_const_rhs = rhs1;
111743 + else
111744 + not_const_rhs = rhs2;
111745 +
111746 + return no_uses(not_const_rhs);
111747 +}
111748 +
111749 +static bool skip_lhs_cast_check(const_gimple stmt)
111750 +{
111751 + const_tree rhs = gimple_assign_rhs1(stmt);
111752 + const_gimple def_stmt = get_def_stmt(rhs);
111753 +
111754 + // 3.8.2 kernel/futex_compat.c compat_exit_robust_list(): get_user() 64 ulong -> int (compat_long_t), int max
111755 + if (gimple_code(def_stmt) == GIMPLE_ASM)
111756 + return true;
111757 +
111758 + if (is_const_plus_unsigned_signed_truncation(rhs))
111759 + return true;
111760 +
111761 + return false;
111762 +}
111763 +
111764 +static tree create_cast_overflow_check(struct pointer_set_t *visited, struct cgraph_node *caller_node, tree new_rhs1, gimple stmt)
111765 +{
111766 + bool cast_lhs, cast_rhs;
111767 + tree lhs = gimple_assign_lhs(stmt);
111768 + tree rhs = gimple_assign_rhs1(stmt);
111769 + const_tree lhs_type = TREE_TYPE(lhs);
111770 + const_tree rhs_type = TREE_TYPE(rhs);
111771 + enum machine_mode lhs_mode = TYPE_MODE(lhs_type);
111772 + enum machine_mode rhs_mode = TYPE_MODE(rhs_type);
111773 + unsigned int lhs_size = GET_MODE_BITSIZE(lhs_mode);
111774 + unsigned int rhs_size = GET_MODE_BITSIZE(rhs_mode);
111775 +
111776 + static bool check_lhs[3][4] = {
111777 + // ss su us uu
111778 + { false, true, true, false }, // lhs > rhs
111779 + { false, false, false, false }, // lhs = rhs
111780 + { true, true, true, true }, // lhs < rhs
111781 + };
111782 +
111783 + static bool check_rhs[3][4] = {
111784 + // ss su us uu
111785 + { true, false, true, true }, // lhs > rhs
111786 + { true, false, true, true }, // lhs = rhs
111787 + { true, false, true, true }, // lhs < rhs
111788 + };
111789 +
111790 + // skip lhs check on signed SI -> HI cast or signed SI -> QI cast !!!!
111791 + if (rhs_mode == SImode && !TYPE_UNSIGNED(rhs_type) && (lhs_mode == HImode || lhs_mode == QImode))
111792 + return create_assign(visited, stmt, lhs, AFTER_STMT);
111793 +
111794 + if (lhs_size > rhs_size) {
111795 + cast_lhs = check_lhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
111796 + cast_rhs = check_rhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
111797 + } else if (lhs_size == rhs_size) {
111798 + cast_lhs = check_lhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
111799 + cast_rhs = check_rhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
111800 + } else {
111801 + cast_lhs = check_lhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
111802 + cast_rhs = check_rhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
111803 + }
111804 +
111805 + if (!cast_lhs && !cast_rhs)
111806 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
111807 +
111808 + if (cast_lhs && !skip_lhs_cast_check(stmt))
111809 + check_size_overflow(caller_node, stmt, TREE_TYPE(new_rhs1), new_rhs1, lhs, BEFORE_STMT);
111810 +
111811 + if (cast_rhs)
111812 + check_size_overflow(caller_node, stmt, TREE_TYPE(new_rhs1), new_rhs1, rhs, BEFORE_STMT);
111813 +
111814 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
111815 +}
111816 +
111817 +static tree handle_unary_rhs(struct pointer_set_t *visited, struct cgraph_node *caller_node, gimple stmt)
111818 +{
111819 + tree rhs1, new_rhs1, lhs = gimple_assign_lhs(stmt);
111820 +
111821 + if (gimple_plf(stmt, MY_STMT))
111822 + return lhs;
111823 +
111824 + rhs1 = gimple_assign_rhs1(stmt);
111825 + if (TREE_CODE(TREE_TYPE(rhs1)) == POINTER_TYPE)
111826 + return create_assign(visited, stmt, lhs, AFTER_STMT);
111827 +
111828 + new_rhs1 = expand(visited, caller_node, rhs1);
111829 +
111830 + if (new_rhs1 == NULL_TREE)
111831 + return create_cast_assign(visited, stmt);
111832 +
111833 + if (gimple_plf(stmt, NO_CAST_CHECK))
111834 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
111835 +
111836 + if (gimple_assign_rhs_code(stmt) == BIT_NOT_EXPR) {
111837 + tree size_overflow_type = get_size_overflow_type(stmt, rhs1);
111838 +
111839 + new_rhs1 = cast_to_new_size_overflow_type(stmt, new_rhs1, size_overflow_type, BEFORE_STMT);
111840 + check_size_overflow(caller_node, stmt, size_overflow_type, new_rhs1, rhs1, BEFORE_STMT);
111841 + return create_assign(visited, stmt, lhs, AFTER_STMT);
111842 + }
111843 +
111844 + if (!gimple_assign_cast_p(stmt))
111845 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
111846 +
111847 + return create_cast_overflow_check(visited, caller_node, new_rhs1, stmt);
111848 +}
111849 +
111850 +static tree handle_unary_ops(struct pointer_set_t *visited, struct cgraph_node *caller_node, gimple stmt)
111851 +{
111852 + tree rhs1, lhs = gimple_assign_lhs(stmt);
111853 + gimple def_stmt = get_def_stmt(lhs);
111854 +
111855 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP);
111856 + rhs1 = gimple_assign_rhs1(def_stmt);
111857 +
111858 + if (is_gimple_constant(rhs1))
111859 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
111860 +
111861 + switch (TREE_CODE(rhs1)) {
111862 + case SSA_NAME:
111863 + return handle_unary_rhs(visited, caller_node, def_stmt);
111864 + case ARRAY_REF:
111865 + case BIT_FIELD_REF:
111866 + case ADDR_EXPR:
111867 + case COMPONENT_REF:
111868 + case INDIRECT_REF:
111869 +#if BUILDING_GCC_VERSION >= 4006
111870 + case MEM_REF:
111871 +#endif
111872 + case TARGET_MEM_REF:
111873 + case VIEW_CONVERT_EXPR:
111874 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
111875 + case PARM_DECL:
111876 + case VAR_DECL:
111877 + return create_assign(visited, stmt, lhs, AFTER_STMT);
111878 +
111879 + default:
111880 + debug_gimple_stmt(def_stmt);
111881 + debug_tree(rhs1);
111882 + gcc_unreachable();
111883 + }
111884 +}
111885 +
111886 +static void insert_cond(basic_block cond_bb, tree arg, enum tree_code cond_code, tree type_value)
111887 +{
111888 + gimple cond_stmt;
111889 + gimple_stmt_iterator gsi = gsi_last_bb(cond_bb);
111890 +
111891 + cond_stmt = gimple_build_cond(cond_code, arg, type_value, NULL_TREE, NULL_TREE);
111892 + gsi_insert_after(&gsi, cond_stmt, GSI_CONTINUE_LINKING);
111893 + update_stmt(cond_stmt);
111894 +}
111895 +
111896 +static tree create_string_param(tree string)
111897 +{
111898 + tree i_type, a_type;
111899 + const int length = TREE_STRING_LENGTH(string);
111900 +
111901 + gcc_assert(length > 0);
111902 +
111903 + i_type = build_index_type(build_int_cst(NULL_TREE, length - 1));
111904 + a_type = build_array_type(char_type_node, i_type);
111905 +
111906 + TREE_TYPE(string) = a_type;
111907 + TREE_CONSTANT(string) = 1;
111908 + TREE_READONLY(string) = 1;
111909 +
111910 + return build1(ADDR_EXPR, ptr_type_node, string);
111911 +}
111912 +
111913 +#if BUILDING_GCC_VERSION <= 4006
111914 +struct cgraph_node *cgraph_get_create_node(tree decl);
111915 +
111916 +struct cgraph_node *cgraph_get_create_node(tree decl)
111917 +{
111918 + struct cgraph_node *node;
111919 +
111920 + node = cgraph_get_node(decl);
111921 + if (node)
111922 + return node;
111923 + return cgraph_node(decl);
111924 +}
111925 +#endif
111926 +
111927 +static void insert_cond_result(struct cgraph_node *caller_node, basic_block bb_true, const_gimple stmt, const_tree arg, bool min)
111928 +{
111929 + gimple func_stmt;
111930 + const_gimple def_stmt;
111931 + const_tree loc_line;
111932 + tree loc_file, ssa_name, current_func;
111933 + expanded_location xloc;
111934 + char *ssa_name_buf;
111935 + int len;
111936 + struct cgraph_edge *edge;
111937 + struct cgraph_node *callee_node;
111938 + int frequency;
111939 + gimple_stmt_iterator gsi = gsi_start_bb(bb_true);
111940 +
111941 + def_stmt = get_def_stmt(arg);
111942 + xloc = expand_location(gimple_location(def_stmt));
111943 +
111944 + if (!gimple_has_location(def_stmt)) {
111945 + xloc = expand_location(gimple_location(stmt));
111946 + if (!gimple_has_location(stmt))
111947 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
111948 + }
111949 +
111950 + loc_line = build_int_cstu(unsigned_type_node, xloc.line);
111951 +
111952 + loc_file = build_string(strlen(xloc.file) + 1, xloc.file);
111953 + loc_file = create_string_param(loc_file);
111954 +
111955 + current_func = build_string(NAME_LEN(current_function_decl) + 1, NAME(current_function_decl));
111956 + current_func = create_string_param(current_func);
111957 +
111958 + gcc_assert(DECL_NAME(SSA_NAME_VAR(arg)) != NULL);
111959 + call_count++;
111960 + 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);
111961 + gcc_assert(len > 0);
111962 + ssa_name = build_string(len + 1, ssa_name_buf);
111963 + free(ssa_name_buf);
111964 + ssa_name = create_string_param(ssa_name);
111965 +
111966 + // void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
111967 + func_stmt = gimple_build_call(report_size_overflow_decl, 4, loc_file, loc_line, current_func, ssa_name);
111968 + gsi_insert_after(&gsi, func_stmt, GSI_CONTINUE_LINKING);
111969 +
111970 + callee_node = cgraph_get_create_node(report_size_overflow_decl);
111971 + frequency = compute_call_stmt_bb_frequency(current_function_decl, bb_true);
111972 +
111973 +#if BUILDING_GCC_VERSION <= 4006
111974 + edge = cgraph_create_edge(caller_node, callee_node, func_stmt, bb_true->count, frequency, bb_true->loop_depth);
111975 +#else
111976 + edge = cgraph_create_edge(caller_node, callee_node, func_stmt, bb_true->count, frequency);
111977 +#endif
111978 + gcc_assert(edge != NULL);
111979 +}
111980 +
111981 +static void __unused print_the_code_insertions(const_gimple stmt)
111982 +{
111983 + location_t loc = gimple_location(stmt);
111984 +
111985 + inform(loc, "Integer size_overflow check applied here.");
111986 +}
111987 +
111988 +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)
111989 +{
111990 + basic_block cond_bb, join_bb, bb_true;
111991 + edge e;
111992 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
111993 +
111994 + cond_bb = gimple_bb(stmt);
111995 + if (before)
111996 + gsi_prev(&gsi);
111997 + if (gsi_end_p(gsi))
111998 + e = split_block_after_labels(cond_bb);
111999 + else
112000 + e = split_block(cond_bb, gsi_stmt(gsi));
112001 + cond_bb = e->src;
112002 + join_bb = e->dest;
112003 + e->flags = EDGE_FALSE_VALUE;
112004 + e->probability = REG_BR_PROB_BASE;
112005 +
112006 + bb_true = create_empty_bb(cond_bb);
112007 + make_edge(cond_bb, bb_true, EDGE_TRUE_VALUE);
112008 + make_edge(cond_bb, join_bb, EDGE_FALSE_VALUE);
112009 + make_edge(bb_true, join_bb, EDGE_FALLTHRU);
112010 +
112011 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
112012 + set_immediate_dominator(CDI_DOMINATORS, bb_true, cond_bb);
112013 + set_immediate_dominator(CDI_DOMINATORS, join_bb, cond_bb);
112014 +
112015 + if (current_loops != NULL) {
112016 + gcc_assert(cond_bb->loop_father == join_bb->loop_father);
112017 + add_bb_to_loop(bb_true, cond_bb->loop_father);
112018 + }
112019 +
112020 + insert_cond(cond_bb, arg, cond_code, type_value);
112021 + insert_cond_result(caller_node, bb_true, stmt, arg, min);
112022 +
112023 +// print_the_code_insertions(stmt);
112024 +}
112025 +
112026 +static void check_size_overflow(struct cgraph_node *caller_node, gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before)
112027 +{
112028 + const_tree rhs_type = TREE_TYPE(rhs);
112029 + tree cast_rhs_type, type_max_type, type_min_type, type_max, type_min;
112030 +
112031 + gcc_assert(rhs_type != NULL_TREE);
112032 + if (TREE_CODE(rhs_type) == POINTER_TYPE)
112033 + return;
112034 +
112035 + gcc_assert(TREE_CODE(rhs_type) == INTEGER_TYPE || TREE_CODE(rhs_type) == ENUMERAL_TYPE);
112036 +
112037 + if (is_const_plus_unsigned_signed_truncation(rhs))
112038 + return;
112039 +
112040 + type_max = cast_a_tree(size_overflow_type, TYPE_MAX_VALUE(rhs_type));
112041 + // typemax (-1) < typemin (0)
112042 + if (TREE_OVERFLOW(type_max))
112043 + return;
112044 +
112045 + type_min = cast_a_tree(size_overflow_type, TYPE_MIN_VALUE(rhs_type));
112046 +
112047 + cast_rhs_type = TREE_TYPE(cast_rhs);
112048 + type_max_type = TREE_TYPE(type_max);
112049 + gcc_assert(types_compatible_p(cast_rhs_type, type_max_type));
112050 +
112051 + insert_check_size_overflow(caller_node, stmt, GT_EXPR, cast_rhs, type_max, before, MAX_CHECK);
112052 +
112053 + // special case: get_size_overflow_type(), 32, u64->s
112054 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode) && TYPE_UNSIGNED(size_overflow_type) && !TYPE_UNSIGNED(rhs_type))
112055 + return;
112056 +
112057 + type_min_type = TREE_TYPE(type_min);
112058 + gcc_assert(types_compatible_p(type_max_type, type_min_type));
112059 + insert_check_size_overflow(caller_node, stmt, LT_EXPR, cast_rhs, type_min, before, MIN_CHECK);
112060 +}
112061 +
112062 +static bool is_a_constant_overflow(const_gimple stmt, const_tree rhs)
112063 +{
112064 + if (gimple_assign_rhs_code(stmt) == MIN_EXPR)
112065 + return false;
112066 + if (!is_gimple_constant(rhs))
112067 + return false;
112068 + return true;
112069 +}
112070 +
112071 +static tree get_def_stmt_rhs(const_tree var)
112072 +{
112073 + tree rhs1, def_stmt_rhs1;
112074 + gimple rhs1_def_stmt, def_stmt_rhs1_def_stmt, def_stmt;
112075 +
112076 + def_stmt = get_def_stmt(var);
112077 + if (!gimple_assign_cast_p(def_stmt))
112078 + return NULL_TREE;
112079 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP && gimple_plf(def_stmt, MY_STMT) && gimple_assign_cast_p(def_stmt));
112080 +
112081 + rhs1 = gimple_assign_rhs1(def_stmt);
112082 + rhs1_def_stmt = get_def_stmt(rhs1);
112083 + if (!gimple_assign_cast_p(rhs1_def_stmt))
112084 + return rhs1;
112085 +
112086 + def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
112087 + def_stmt_rhs1_def_stmt = get_def_stmt(def_stmt_rhs1);
112088 +
112089 + switch (gimple_code(def_stmt_rhs1_def_stmt)) {
112090 + case GIMPLE_CALL:
112091 + case GIMPLE_NOP:
112092 + case GIMPLE_ASM:
112093 + case GIMPLE_PHI:
112094 + return def_stmt_rhs1;
112095 + case GIMPLE_ASSIGN:
112096 + return rhs1;
112097 + default:
112098 + debug_gimple_stmt(def_stmt_rhs1_def_stmt);
112099 + gcc_unreachable();
112100 + }
112101 +}
112102 +
112103 +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)
112104 +{
112105 + tree new_rhs, orig_rhs;
112106 + void (*gimple_assign_set_rhs)(gimple, tree);
112107 + tree rhs1 = gimple_assign_rhs1(stmt);
112108 + tree rhs2 = gimple_assign_rhs2(stmt);
112109 + tree lhs = gimple_assign_lhs(stmt);
112110 +
112111 + if (!check_overflow)
112112 + return create_assign(visited, stmt, lhs, AFTER_STMT);
112113 +
112114 + if (change_rhs == NULL_TREE)
112115 + return create_assign(visited, stmt, lhs, AFTER_STMT);
112116 +
112117 + if (new_rhs2 == NULL_TREE) {
112118 + orig_rhs = rhs1;
112119 + gimple_assign_set_rhs = &gimple_assign_set_rhs1;
112120 + } else {
112121 + orig_rhs = rhs2;
112122 + gimple_assign_set_rhs = &gimple_assign_set_rhs2;
112123 + }
112124 +
112125 + check_size_overflow(caller_node, stmt, TREE_TYPE(change_rhs), change_rhs, orig_rhs, BEFORE_STMT);
112126 +
112127 + new_rhs = change_assign_rhs(stmt, orig_rhs, change_rhs);
112128 + gimple_assign_set_rhs(stmt, new_rhs);
112129 + update_stmt(stmt);
112130 +
112131 + return create_assign(visited, stmt, lhs, AFTER_STMT);
112132 +}
112133 +
112134 +static bool is_subtraction_special(const_gimple stmt)
112135 +{
112136 + gimple rhs1_def_stmt, rhs2_def_stmt;
112137 + const_tree rhs1_def_stmt_rhs1, rhs2_def_stmt_rhs1, rhs1_def_stmt_lhs, rhs2_def_stmt_lhs;
112138 + enum machine_mode rhs1_def_stmt_rhs1_mode, rhs2_def_stmt_rhs1_mode, rhs1_def_stmt_lhs_mode, rhs2_def_stmt_lhs_mode;
112139 + const_tree rhs1 = gimple_assign_rhs1(stmt);
112140 + const_tree rhs2 = gimple_assign_rhs2(stmt);
112141 +
112142 + if (is_gimple_constant(rhs1) || is_gimple_constant(rhs2))
112143 + return false;
112144 +
112145 + gcc_assert(TREE_CODE(rhs1) == SSA_NAME && TREE_CODE(rhs2) == SSA_NAME);
112146 +
112147 + if (gimple_assign_rhs_code(stmt) != MINUS_EXPR)
112148 + return false;
112149 +
112150 + rhs1_def_stmt = get_def_stmt(rhs1);
112151 + rhs2_def_stmt = get_def_stmt(rhs2);
112152 + if (!gimple_assign_cast_p(rhs1_def_stmt) || !gimple_assign_cast_p(rhs2_def_stmt))
112153 + return false;
112154 +
112155 + rhs1_def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
112156 + rhs2_def_stmt_rhs1 = gimple_assign_rhs1(rhs2_def_stmt);
112157 + rhs1_def_stmt_lhs = gimple_assign_lhs(rhs1_def_stmt);
112158 + rhs2_def_stmt_lhs = gimple_assign_lhs(rhs2_def_stmt);
112159 + rhs1_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_rhs1));
112160 + rhs2_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_rhs1));
112161 + rhs1_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_lhs));
112162 + rhs2_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_lhs));
112163 + if (GET_MODE_BITSIZE(rhs1_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs1_def_stmt_lhs_mode))
112164 + return false;
112165 + if (GET_MODE_BITSIZE(rhs2_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs2_def_stmt_lhs_mode))
112166 + return false;
112167 +
112168 + gimple_set_plf(rhs1_def_stmt, NO_CAST_CHECK, true);
112169 + gimple_set_plf(rhs2_def_stmt, NO_CAST_CHECK, true);
112170 + return true;
112171 +}
112172 +
112173 +static tree handle_integer_truncation(struct pointer_set_t *visited, struct cgraph_node *caller_node, const_tree lhs)
112174 +{
112175 + tree new_rhs1, new_rhs2;
112176 + tree new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1, new_lhs;
112177 + gimple assign, stmt = get_def_stmt(lhs);
112178 + tree rhs1 = gimple_assign_rhs1(stmt);
112179 + tree rhs2 = gimple_assign_rhs2(stmt);
112180 +
112181 + if (!is_subtraction_special(stmt))
112182 + return NULL_TREE;
112183 +
112184 + new_rhs1 = expand(visited, caller_node, rhs1);
112185 + new_rhs2 = expand(visited, caller_node, rhs2);
112186 +
112187 + new_rhs1_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs1);
112188 + new_rhs2_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs2);
112189 +
112190 + if (new_rhs1_def_stmt_rhs1 == NULL_TREE || new_rhs2_def_stmt_rhs1 == NULL_TREE)
112191 + return NULL_TREE;
112192 +
112193 + if (!types_compatible_p(TREE_TYPE(new_rhs1_def_stmt_rhs1), TREE_TYPE(new_rhs2_def_stmt_rhs1))) {
112194 + new_rhs1_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs1_def_stmt_rhs1);
112195 + new_rhs2_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs2_def_stmt_rhs1);
112196 + }
112197 +
112198 + assign = create_binary_assign(MINUS_EXPR, stmt, new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1);
112199 + new_lhs = gimple_assign_lhs(assign);
112200 + check_size_overflow(caller_node, assign, TREE_TYPE(new_lhs), new_lhs, rhs1, AFTER_STMT);
112201 +
112202 + return dup_assign(visited, stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
112203 +}
112204 +
112205 +static bool is_a_neg_overflow(const_gimple stmt, const_tree rhs)
112206 +{
112207 + const_gimple def_stmt;
112208 +
112209 + if (TREE_CODE(rhs) != SSA_NAME)
112210 + return false;
112211 +
112212 + if (gimple_assign_rhs_code(stmt) != PLUS_EXPR)
112213 + return false;
112214 +
112215 + def_stmt = get_def_stmt(rhs);
112216 + if (!is_gimple_assign(def_stmt) || gimple_assign_rhs_code(def_stmt) != BIT_NOT_EXPR)
112217 + return false;
112218 +
112219 + return true;
112220 +}
112221 +
112222 +static tree handle_binary_ops(struct pointer_set_t *visited, struct cgraph_node *caller_node, tree lhs)
112223 +{
112224 + tree rhs1, rhs2, new_lhs;
112225 + gimple def_stmt = get_def_stmt(lhs);
112226 + tree new_rhs1 = NULL_TREE;
112227 + tree new_rhs2 = NULL_TREE;
112228 +
112229 + rhs1 = gimple_assign_rhs1(def_stmt);
112230 + rhs2 = gimple_assign_rhs2(def_stmt);
112231 +
112232 + /* no DImode/TImode division in the 32/64 bit kernel */
112233 + switch (gimple_assign_rhs_code(def_stmt)) {
112234 + case RDIV_EXPR:
112235 + case TRUNC_DIV_EXPR:
112236 + case CEIL_DIV_EXPR:
112237 + case FLOOR_DIV_EXPR:
112238 + case ROUND_DIV_EXPR:
112239 + case TRUNC_MOD_EXPR:
112240 + case CEIL_MOD_EXPR:
112241 + case FLOOR_MOD_EXPR:
112242 + case ROUND_MOD_EXPR:
112243 + case EXACT_DIV_EXPR:
112244 + case POINTER_PLUS_EXPR:
112245 + case BIT_AND_EXPR:
112246 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
112247 + default:
112248 + break;
112249 + }
112250 +
112251 + new_lhs = handle_integer_truncation(visited, caller_node, lhs);
112252 + if (new_lhs != NULL_TREE)
112253 + return new_lhs;
112254 +
112255 + if (TREE_CODE(rhs1) == SSA_NAME)
112256 + new_rhs1 = expand(visited, caller_node, rhs1);
112257 + if (TREE_CODE(rhs2) == SSA_NAME)
112258 + new_rhs2 = expand(visited, caller_node, rhs2);
112259 +
112260 + if (is_a_neg_overflow(def_stmt, rhs2))
112261 + return handle_intentional_overflow(visited, caller_node, true, def_stmt, new_rhs1, NULL_TREE);
112262 + if (is_a_neg_overflow(def_stmt, rhs1))
112263 + return handle_intentional_overflow(visited, caller_node, true, def_stmt, new_rhs2, new_rhs2);
112264 +
112265 +
112266 + if (is_a_constant_overflow(def_stmt, rhs2))
112267 + return handle_intentional_overflow(visited, caller_node, !is_a_cast_and_const_overflow(rhs1), def_stmt, new_rhs1, NULL_TREE);
112268 + if (is_a_constant_overflow(def_stmt, rhs1))
112269 + return handle_intentional_overflow(visited, caller_node, !is_a_cast_and_const_overflow(rhs2), def_stmt, new_rhs2, new_rhs2);
112270 +
112271 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
112272 +}
112273 +
112274 +#if BUILDING_GCC_VERSION >= 4007
112275 +static tree get_new_rhs(struct pointer_set_t *visited, struct cgraph_node *caller_node, tree size_overflow_type, tree rhs)
112276 +{
112277 + if (is_gimple_constant(rhs))
112278 + return cast_a_tree(size_overflow_type, rhs);
112279 + if (TREE_CODE(rhs) != SSA_NAME)
112280 + return NULL_TREE;
112281 + return expand(visited, caller_node, rhs);
112282 +}
112283 +
112284 +static tree handle_ternary_ops(struct pointer_set_t *visited, struct cgraph_node *caller_node, tree lhs)
112285 +{
112286 + tree rhs1, rhs2, rhs3, new_rhs1, new_rhs2, new_rhs3, size_overflow_type;
112287 + gimple def_stmt = get_def_stmt(lhs);
112288 +
112289 + size_overflow_type = get_size_overflow_type(def_stmt, lhs);
112290 +
112291 + rhs1 = gimple_assign_rhs1(def_stmt);
112292 + rhs2 = gimple_assign_rhs2(def_stmt);
112293 + rhs3 = gimple_assign_rhs3(def_stmt);
112294 + new_rhs1 = get_new_rhs(visited, caller_node, size_overflow_type, rhs1);
112295 + new_rhs2 = get_new_rhs(visited, caller_node, size_overflow_type, rhs2);
112296 + new_rhs3 = get_new_rhs(visited, caller_node, size_overflow_type, rhs3);
112297 +
112298 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, new_rhs3);
112299 +}
112300 +#endif
112301 +
112302 +static tree get_size_overflow_type(gimple stmt, const_tree node)
112303 +{
112304 + const_tree type;
112305 + tree new_type;
112306 +
112307 + gcc_assert(node != NULL_TREE);
112308 +
112309 + type = TREE_TYPE(node);
112310 +
112311 + if (gimple_plf(stmt, MY_STMT))
112312 + return TREE_TYPE(node);
112313 +
112314 + switch (TYPE_MODE(type)) {
112315 + case QImode:
112316 + new_type = intHI_type_node;
112317 + break;
112318 + case HImode:
112319 + new_type = intSI_type_node;
112320 + break;
112321 + case SImode:
112322 + new_type = intDI_type_node;
112323 + break;
112324 + case DImode:
112325 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
112326 + new_type = TYPE_UNSIGNED(type) ? unsigned_intDI_type_node : intDI_type_node;
112327 + else
112328 + new_type = intTI_type_node;
112329 + break;
112330 + case TImode:
112331 + gcc_assert(!TYPE_UNSIGNED(type));
112332 + new_type = intTI_type_node;
112333 + break;
112334 + default:
112335 + debug_tree((tree)node);
112336 + error("%s: unsupported gcc configuration (%qE).", __func__, current_function_decl);
112337 + gcc_unreachable();
112338 + }
112339 +
112340 + if (TYPE_QUALS(type) != 0)
112341 + return build_qualified_type(new_type, TYPE_QUALS(type));
112342 + return new_type;
112343 +}
112344 +
112345 +static tree expand_visited(gimple def_stmt)
112346 +{
112347 + const_gimple next_stmt;
112348 + gimple_stmt_iterator gsi;
112349 + enum gimple_code code = gimple_code(def_stmt);
112350 +
112351 + if (code == GIMPLE_ASM)
112352 + return NULL_TREE;
112353 +
112354 + gsi = gsi_for_stmt(def_stmt);
112355 + gsi_next(&gsi);
112356 +
112357 + if (gimple_code(def_stmt) == GIMPLE_PHI && gsi_end_p(gsi))
112358 + return NULL_TREE;
112359 + gcc_assert(!gsi_end_p(gsi));
112360 + next_stmt = gsi_stmt(gsi);
112361 +
112362 + if (gimple_code(def_stmt) == GIMPLE_PHI && !gimple_plf((gimple)next_stmt, MY_STMT))
112363 + return NULL_TREE;
112364 + gcc_assert(gimple_plf((gimple)next_stmt, MY_STMT));
112365 +
112366 + return get_lhs(next_stmt);
112367 +}
112368 +
112369 +static tree expand(struct pointer_set_t *visited, struct cgraph_node *caller_node, tree lhs)
112370 +{
112371 + gimple def_stmt;
112372 +
112373 + def_stmt = get_def_stmt(lhs);
112374 +
112375 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
112376 + return NULL_TREE;
112377 +
112378 + if (gimple_plf(def_stmt, MY_STMT))
112379 + return lhs;
112380 +
112381 + if (pointer_set_contains(visited, def_stmt))
112382 + return expand_visited(def_stmt);
112383 +
112384 + switch (gimple_code(def_stmt)) {
112385 + case GIMPLE_PHI:
112386 + return handle_phi(visited, caller_node, lhs);
112387 + case GIMPLE_CALL:
112388 + case GIMPLE_ASM:
112389 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
112390 + case GIMPLE_ASSIGN:
112391 + switch (gimple_num_ops(def_stmt)) {
112392 + case 2:
112393 + return handle_unary_ops(visited, caller_node, def_stmt);
112394 + case 3:
112395 + return handle_binary_ops(visited, caller_node, lhs);
112396 +#if BUILDING_GCC_VERSION >= 4007
112397 + case 4:
112398 + return handle_ternary_ops(visited, caller_node, lhs);
112399 +#endif
112400 + }
112401 + default:
112402 + debug_gimple_stmt(def_stmt);
112403 + error("%s: unknown gimple code", __func__);
112404 + gcc_unreachable();
112405 + }
112406 +}
112407 +
112408 +static tree cast_to_orig_type(gimple stmt, const_tree orig_node, tree new_node)
112409 +{
112410 + const_gimple assign;
112411 + tree orig_type = TREE_TYPE(orig_node);
112412 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
112413 +
112414 + assign = build_cast_stmt(orig_type, new_node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
112415 + return gimple_assign_lhs(assign);
112416 +}
112417 +
112418 +static void change_orig_node(struct interesting_node *cur_node, tree new_node)
112419 +{
112420 + void (*set_rhs)(gimple, tree);
112421 + gimple stmt = cur_node->first_stmt;
112422 + const_tree orig_node = cur_node->node;
112423 +
112424 + switch (gimple_code(stmt)) {
112425 + case GIMPLE_RETURN:
112426 + gimple_return_set_retval(stmt, cast_to_orig_type(stmt, orig_node, new_node));
112427 + break;
112428 + case GIMPLE_CALL:
112429 + gimple_call_set_arg(stmt, cur_node->num - 1, cast_to_orig_type(stmt, orig_node, new_node));
112430 + break;
112431 + case GIMPLE_ASSIGN:
112432 + switch (cur_node->num) {
112433 + case 1:
112434 + set_rhs = &gimple_assign_set_rhs1;
112435 + break;
112436 + case 2:
112437 + set_rhs = &gimple_assign_set_rhs2;
112438 + break;
112439 +#if BUILDING_GCC_VERSION > 4005
112440 + case 3:
112441 + set_rhs = &gimple_assign_set_rhs3;
112442 + break;
112443 +#endif
112444 + default:
112445 + gcc_unreachable();
112446 + }
112447 +
112448 + set_rhs(stmt, cast_to_orig_type(stmt, orig_node, new_node));
112449 + break;
112450 + default:
112451 + debug_gimple_stmt(stmt);
112452 + gcc_unreachable();
112453 + }
112454 +
112455 + update_stmt(stmt);
112456 +}
112457 +
112458 +static unsigned int get_correct_arg_count(unsigned int argnum, tree fndecl)
112459 +{
112460 + const struct size_overflow_hash *hash;
112461 + unsigned int new_argnum;
112462 + tree arg;
112463 + const_tree origarg;
112464 +
112465 + if (argnum == 0)
112466 + return argnum;
112467 +
112468 + hash = get_function_hash(fndecl);
112469 + if (hash && hash->param & (1U << argnum))
112470 + return argnum;
112471 +
112472 + if (DECL_EXTERNAL(fndecl))
112473 + return argnum;
112474 +
112475 + origarg = DECL_ARGUMENTS(DECL_ORIGIN(fndecl));
112476 + argnum--;
112477 + while (origarg && argnum) {
112478 + origarg = TREE_CHAIN(origarg);
112479 + argnum--;
112480 + }
112481 + gcc_assert(argnum == 0);
112482 + gcc_assert(origarg != NULL_TREE);
112483 +
112484 + for (arg = DECL_ARGUMENTS(fndecl), new_argnum = 1; arg; arg = TREE_CHAIN(arg), new_argnum++)
112485 + if (operand_equal_p(origarg, arg, 0) || !strcmp(NAME(origarg), NAME(arg)))
112486 + return new_argnum;
112487 +
112488 + return CANNOT_FIND_ARG;
112489 +}
112490 +
112491 +// Don't want to duplicate entries in next_cgraph_node
112492 +static bool is_in_next_cgraph_node(struct next_cgraph_node *head, struct cgraph_node *node, const_tree fndecl, unsigned int num)
112493 +{
112494 + const_tree new_callee_fndecl;
112495 + struct next_cgraph_node *cur_node;
112496 +
112497 + if (fndecl == RET_CHECK)
112498 +#if BUILDING_GCC_VERSION <= 4007
112499 + new_callee_fndecl = node->decl;
112500 +#else
112501 + new_callee_fndecl = node->symbol.decl;
112502 +#endif
112503 + else
112504 + new_callee_fndecl = fndecl;
112505 +
112506 + for (cur_node = head; cur_node; cur_node = cur_node->next) {
112507 +#if BUILDING_GCC_VERSION <= 4007
112508 + if (!operand_equal_p(cur_node->current_function->decl, node->decl, 0))
112509 +#else
112510 + if (!operand_equal_p(cur_node->current_function->symbol.decl, node->symbol.decl, 0))
112511 +#endif
112512 + continue;
112513 + if (!operand_equal_p(cur_node->callee_fndecl, new_callee_fndecl, 0))
112514 + continue;
112515 + if (num == cur_node->num)
112516 + return true;
112517 + }
112518 + return false;
112519 +}
112520 +
112521 +/* Add a next_cgraph_node into the list for handle_function().
112522 + * handle_function() iterates over all the next cgraph nodes and
112523 + * starts the overflow check insertion process.
112524 + */
112525 +static struct next_cgraph_node *create_new_next_cgraph_node(struct next_cgraph_node *head, struct cgraph_node *node, tree fndecl, unsigned int num)
112526 +{
112527 + struct next_cgraph_node *new_node;
112528 +
112529 + if (is_in_next_cgraph_node(head, node, fndecl, num))
112530 + return head;
112531 +
112532 + new_node = (struct next_cgraph_node *)xmalloc(sizeof(*new_node));
112533 + new_node->current_function = node;
112534 + new_node->next = NULL;
112535 + new_node->num = num;
112536 + if (fndecl == RET_CHECK)
112537 +#if BUILDING_GCC_VERSION <= 4007
112538 + new_node->callee_fndecl = node->decl;
112539 +#else
112540 + new_node->callee_fndecl = node->symbol.decl;
112541 +#endif
112542 + else
112543 + new_node->callee_fndecl = fndecl;
112544 +
112545 + if (!head)
112546 + return new_node;
112547 +
112548 + new_node->next = head;
112549 + return new_node;
112550 +}
112551 +
112552 +static struct next_cgraph_node *create_new_next_cgraph_nodes(struct next_cgraph_node *head, struct cgraph_node *node, unsigned int num)
112553 +{
112554 + struct cgraph_edge *e;
112555 +
112556 + if (num == 0)
112557 + return create_new_next_cgraph_node(head, node, RET_CHECK, num);
112558 +
112559 + for (e = node->callers; e; e = e->next_caller) {
112560 + tree fndecl = gimple_call_fndecl(e->call_stmt);
112561 +
112562 + gcc_assert(fndecl != NULL_TREE);
112563 + head = create_new_next_cgraph_node(head, e->caller, fndecl, num);
112564 + }
112565 +
112566 + return head;
112567 +}
112568 +
112569 +static bool is_a_return_check(const_tree node)
112570 +{
112571 + if (TREE_CODE(node) == FUNCTION_DECL)
112572 + return true;
112573 +
112574 + gcc_assert(TREE_CODE(node) == PARM_DECL);
112575 + return false;
112576 +}
112577 +
112578 +static bool is_in_hash_table(tree fndecl, unsigned int num)
112579 +{
112580 + const struct size_overflow_hash *hash;
112581 +
112582 + hash = get_function_hash(fndecl);
112583 + if (hash && (hash->param & (1U << num)))
112584 + return true;
112585 + return false;
112586 +}
112587 +
112588 +struct missing_functions {
112589 + struct missing_functions *next;
112590 + const_tree node;
112591 + tree fndecl;
112592 +};
112593 +
112594 +static struct missing_functions *create_new_missing_function(struct missing_functions *missing_fn_head, tree node)
112595 +{
112596 + struct missing_functions *new_function;
112597 +
112598 + new_function = (struct missing_functions *)xmalloc(sizeof(*new_function));
112599 + new_function->node = node;
112600 + new_function->next = NULL;
112601 +
112602 + if (TREE_CODE(node) == FUNCTION_DECL)
112603 + new_function->fndecl = node;
112604 + else
112605 + new_function->fndecl = current_function_decl;
112606 + gcc_assert(new_function->fndecl);
112607 +
112608 + if (!missing_fn_head)
112609 + return new_function;
112610 +
112611 + new_function->next = missing_fn_head;
112612 + return new_function;
112613 +}
112614 +
112615 +/* Check if the function has a size_overflow attribute or it is in the size_overflow hash table.
112616 + * If the function is missing everywhere then print the missing message into stderr.
112617 + */
112618 +static bool is_missing_function(tree orig_fndecl, unsigned int num)
112619 +{
112620 + switch (DECL_FUNCTION_CODE(orig_fndecl)) {
112621 +#if BUILDING_GCC_VERSION >= 4008
112622 + case BUILT_IN_BSWAP16:
112623 +#endif
112624 + case BUILT_IN_BSWAP32:
112625 + case BUILT_IN_BSWAP64:
112626 + case BUILT_IN_EXPECT:
112627 + case BUILT_IN_MEMCMP:
112628 + return false;
112629 + default:
112630 + break;
112631 + }
112632 +
112633 + // skip test.c
112634 + if (strcmp(NAME(current_function_decl), "coolmalloc")) {
112635 + if (lookup_attribute("size_overflow", DECL_ATTRIBUTES(orig_fndecl)))
112636 + warning(0, "unnecessary size_overflow attribute on: %s\n", NAME(orig_fndecl));
112637 + }
112638 +
112639 + if (is_in_hash_table(orig_fndecl, num))
112640 + return false;
112641 +
112642 + print_missing_msg(orig_fndecl, num);
112643 + return true;
112644 +}
112645 +
112646 +// Get the argnum of a function decl, if node is a return then the argnum is 0
112647 +static unsigned int get_function_num(const_tree node, const_tree orig_fndecl)
112648 +{
112649 + if (is_a_return_check(node))
112650 + return 0;
112651 + else
112652 + return find_arg_number_tree(node, orig_fndecl);
112653 +}
112654 +
112655 +/* If the function is missing from the hash table and it is a static function
112656 + * then create a next_cgraph_node from it for handle_function()
112657 + */
112658 +static struct next_cgraph_node *check_missing_overflow_attribute_and_create_next_node(struct next_cgraph_node *cnodes, struct missing_functions *missing_fn_head)
112659 +{
112660 + unsigned int num;
112661 + tree orig_fndecl;
112662 + struct cgraph_node *next_node = NULL;
112663 +
112664 + orig_fndecl = DECL_ORIGIN(missing_fn_head->fndecl);
112665 +
112666 + num = get_function_num(missing_fn_head->node, orig_fndecl);
112667 + if (num == CANNOT_FIND_ARG)
112668 + return cnodes;
112669 +
112670 + if (!is_missing_function(orig_fndecl, num))
112671 + return cnodes;
112672 +
112673 + next_node = cgraph_get_node(missing_fn_head->fndecl);
112674 + if (next_node && next_node->local.local)
112675 + cnodes = create_new_next_cgraph_nodes(cnodes, next_node, num);
112676 + return cnodes;
112677 +}
112678 +
112679 +/* Search for missing size_overflow attributes on the last nodes in ipa and collect them
112680 + * into the next_cgraph_node list. They will be the next interesting returns or callees.
112681 + */
112682 +static struct next_cgraph_node *search_overflow_attribute(struct next_cgraph_node *cnodes, struct interesting_node *cur_node)
112683 +{
112684 + unsigned int i;
112685 + tree node;
112686 + struct missing_functions *cur, *missing_fn_head = NULL;
112687 +
112688 +#if BUILDING_GCC_VERSION == 4005
112689 + for (i = 0; i < VEC_length(tree, cur_node->last_nodes); i++) {
112690 + node = VEC_index(tree, cur_node->last_nodes, i);
112691 +#elif BUILDING_GCC_VERSION <= 4007
112692 + FOR_EACH_VEC_ELT(tree, cur_node->last_nodes, i, node) {
112693 +#else
112694 + FOR_EACH_VEC_ELT(*cur_node->last_nodes, i, node) {
112695 +#endif
112696 + switch (TREE_CODE(node)) {
112697 + case PARM_DECL:
112698 + if (TREE_CODE(TREE_TYPE(node)) != INTEGER_TYPE)
112699 + break;
112700 + case FUNCTION_DECL:
112701 + missing_fn_head = create_new_missing_function(missing_fn_head, node);
112702 + break;
112703 + default:
112704 + break;
112705 + }
112706 + }
112707 +
112708 + while (missing_fn_head) {
112709 + cnodes = check_missing_overflow_attribute_and_create_next_node(cnodes, missing_fn_head);
112710 +
112711 + cur = missing_fn_head->next;
112712 + free(missing_fn_head);
112713 + missing_fn_head = cur;
112714 + }
112715 +
112716 + return cnodes;
112717 +}
112718 +
112719 +static void walk_phi_set_conditions(struct pointer_set_t *visited, bool *interesting_conditions, const_tree result)
112720 +{
112721 + gimple phi = get_def_stmt(result);
112722 + unsigned int i, n = gimple_phi_num_args(phi);
112723 +
112724 + pointer_set_insert(visited, phi);
112725 + for (i = 0; i < n; i++) {
112726 + const_tree arg = gimple_phi_arg_def(phi, i);
112727 +
112728 + set_conditions(visited, interesting_conditions, arg);
112729 + }
112730 +}
112731 +
112732 +enum conditions {
112733 + FROM_CONST, NOT_UNARY, CAST
112734 +};
112735 +
112736 +// Search for constants, cast assignments and binary/ternary assignments
112737 +static void set_conditions(struct pointer_set_t *visited, bool *interesting_conditions, const_tree lhs)
112738 +{
112739 + gimple def_stmt = get_def_stmt(lhs);
112740 +
112741 + if (is_gimple_constant(lhs)) {
112742 + interesting_conditions[FROM_CONST] = true;
112743 + return;
112744 + }
112745 +
112746 + if (!def_stmt)
112747 + return;
112748 +
112749 + if (pointer_set_contains(visited, def_stmt))
112750 + return;
112751 +
112752 + switch (gimple_code(def_stmt)) {
112753 + case GIMPLE_NOP:
112754 + case GIMPLE_CALL:
112755 + case GIMPLE_ASM:
112756 + return;
112757 + case GIMPLE_PHI:
112758 + return walk_phi_set_conditions(visited, interesting_conditions, lhs);
112759 + case GIMPLE_ASSIGN:
112760 + if (gimple_num_ops(def_stmt) == 2) {
112761 + const_tree rhs = gimple_assign_rhs1(def_stmt);
112762 +
112763 + if (gimple_assign_cast_p(def_stmt))
112764 + interesting_conditions[CAST] = true;
112765 +
112766 + return set_conditions(visited, interesting_conditions, rhs);
112767 + } else {
112768 + interesting_conditions[NOT_UNARY] = true;
112769 + return;
112770 + }
112771 + default:
112772 + debug_gimple_stmt(def_stmt);
112773 + gcc_unreachable();
112774 + }
112775 +}
112776 +
112777 +// determine whether duplication will be necessary or not.
112778 +static void search_interesting_conditions(struct interesting_node *cur_node, bool *interesting_conditions)
112779 +{
112780 + struct pointer_set_t *visited;
112781 +
112782 + if (gimple_assign_cast_p(cur_node->first_stmt))
112783 + interesting_conditions[CAST] = true;
112784 + else if (is_gimple_assign(cur_node->first_stmt) && gimple_num_ops(cur_node->first_stmt) > 2)
112785 + interesting_conditions[NOT_UNARY] = true;
112786 +
112787 + visited = pointer_set_create();
112788 + set_conditions(visited, interesting_conditions, cur_node->node);
112789 + pointer_set_destroy(visited);
112790 +}
112791 +
112792 +// Remove the size_overflow asm stmt and create an assignment from the input and output of the asm
112793 +static void replace_size_overflow_asm_with_assign(gimple asm_stmt, tree lhs, tree rhs)
112794 +{
112795 + gimple assign;
112796 + gimple_stmt_iterator gsi;
112797 +
112798 + // already removed
112799 + if (gimple_bb(asm_stmt) == NULL)
112800 + return;
112801 + gsi = gsi_for_stmt(asm_stmt);
112802 +
112803 + assign = gimple_build_assign(lhs, rhs);
112804 + gsi_insert_before(&gsi, assign, GSI_SAME_STMT);
112805 + SSA_NAME_DEF_STMT(lhs) = assign;
112806 +
112807 + gsi_remove(&gsi, true);
112808 +}
112809 +
112810 +// Get the field decl of a component ref for intentional_overflow checking
112811 +static const_tree search_field_decl(const_tree comp_ref)
112812 +{
112813 + const_tree field = NULL_TREE;
112814 + unsigned int i, len = TREE_OPERAND_LENGTH(comp_ref);
112815 +
112816 + for (i = 0; i < len; i++) {
112817 + field = TREE_OPERAND(comp_ref, i);
112818 + if (TREE_CODE(field) == FIELD_DECL)
112819 + break;
112820 + }
112821 + gcc_assert(TREE_CODE(field) == FIELD_DECL);
112822 + return field;
112823 +}
112824 +
112825 +/* Get the fndecl of an interesting stmt, the fndecl is the caller function if the interesting
112826 + * stmt is a return otherwise it is the callee function.
112827 + */
112828 +static const_tree get_interesting_orig_fndecl(const_gimple stmt, unsigned int argnum)
112829 +{
112830 + const_tree fndecl;
112831 +
112832 + if (argnum == 0)
112833 + fndecl = current_function_decl;
112834 + else
112835 + fndecl = gimple_call_fndecl(stmt);
112836 +
112837 + if (fndecl == NULL_TREE)
112838 + return NULL_TREE;
112839 +
112840 + return DECL_ORIGIN(fndecl);
112841 +}
112842 +
112843 +/* Get the param of the intentional_overflow attribute.
112844 + * * 0: MARK_NOT_INTENTIONAL
112845 + * * 1..MAX_PARAM: MARK_YES
112846 + * * -1: MARK_TURN_OFF
112847 + */
112848 +static tree get_attribute_param(const_tree decl)
112849 +{
112850 + const_tree attr;
112851 +
112852 + if (decl == NULL_TREE)
112853 + return NULL_TREE;
112854 +
112855 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(decl));
112856 + if (!attr || !TREE_VALUE(attr))
112857 + return NULL_TREE;
112858 +
112859 + return TREE_VALUE(attr);
112860 +}
112861 +
112862 +// MARK_TURN_OFF
112863 +static bool is_turn_off_intentional_attr(const_tree decl)
112864 +{
112865 + const_tree param_head;
112866 +
112867 + param_head = get_attribute_param(decl);
112868 + if (param_head == NULL_TREE)
112869 + return false;
112870 +
112871 + if (TREE_INT_CST_HIGH(TREE_VALUE(param_head)) == -1)
112872 + return true;
112873 + return false;
112874 +}
112875 +
112876 +// MARK_NOT_INTENTIONAL
112877 +static bool is_end_intentional_intentional_attr(const_tree decl, unsigned int argnum)
112878 +{
112879 + const_tree param_head;
112880 +
112881 + if (argnum == 0)
112882 + return false;
112883 +
112884 + param_head = get_attribute_param(decl);
112885 + if (param_head == NULL_TREE)
112886 + return false;
112887 +
112888 + if (!TREE_INT_CST_LOW(TREE_VALUE(param_head)))
112889 + return true;
112890 + return false;
112891 +}
112892 +
112893 +// MARK_YES
112894 +static bool is_yes_intentional_attr(const_tree decl, unsigned int argnum)
112895 +{
112896 + tree param, param_head;
112897 +
112898 + if (argnum == 0)
112899 + return false;
112900 +
112901 + param_head = get_attribute_param(decl);
112902 + for (param = param_head; param; param = TREE_CHAIN(param))
112903 + if (argnum == TREE_INT_CST_LOW(TREE_VALUE(param)))
112904 + return true;
112905 + return false;
112906 +}
112907 +
112908 +static const char *get_asm_string(const_gimple stmt)
112909 +{
112910 + if (!stmt)
112911 + return NULL;
112912 + if (gimple_code(stmt) != GIMPLE_ASM)
112913 + return NULL;
112914 +
112915 + return gimple_asm_string(stmt);
112916 +}
112917 +
112918 +static bool is_size_overflow_intentional_asm_turn_off(const_gimple stmt)
112919 +{
112920 + const char *str;
112921 +
112922 + str = get_asm_string(stmt);
112923 + if (!str)
112924 + return false;
112925 + return !strcmp(str, TURN_OFF_ASM_STR);
112926 +}
112927 +
112928 +static bool is_size_overflow_intentional_asm_yes(const_gimple stmt)
112929 +{
112930 + const char *str;
112931 +
112932 + str = get_asm_string(stmt);
112933 + if (!str)
112934 + return false;
112935 + return !strcmp(str, YES_ASM_STR);
112936 +}
112937 +
112938 +static bool is_size_overflow_asm(const_gimple stmt)
112939 +{
112940 + const char *str;
112941 +
112942 + str = get_asm_string(stmt);
112943 + if (!str)
112944 + return false;
112945 + return !strncmp(str, "# size_overflow", 15);
112946 +}
112947 +
112948 +static void print_missing_intentional(enum mark callee_attr, enum mark caller_attr, const_tree decl, unsigned int argnum)
112949 +{
112950 + location_t loc;
112951 +
112952 + if (caller_attr == MARK_NO || caller_attr == MARK_NOT_INTENTIONAL || caller_attr == MARK_TURN_OFF)
112953 + return;
112954 +
112955 + if (callee_attr == MARK_NOT_INTENTIONAL || callee_attr == MARK_YES)
112956 + return;
112957 +
112958 + loc = DECL_SOURCE_LOCATION(decl);
112959 + inform(loc, "The intentional_overflow attribute is missing from +%s+%u+", NAME(decl), argnum);
112960 +}
112961 +
112962 +/* Get the type of the intentional_overflow attribute of a node
112963 + * * MARK_TURN_OFF
112964 + * * MARK_YES
112965 + * * MARK_NO
112966 + * * MARK_NOT_INTENTIONAL
112967 + */
112968 +static enum mark get_intentional_attr_type(const_tree node)
112969 +{
112970 + const_tree cur_decl;
112971 +
112972 + if (node == NULL_TREE)
112973 + return MARK_NO;
112974 +
112975 + switch (TREE_CODE(node)) {
112976 + case COMPONENT_REF:
112977 + cur_decl = search_field_decl(node);
112978 + if (is_turn_off_intentional_attr(cur_decl))
112979 + return MARK_TURN_OFF;
112980 + if (is_end_intentional_intentional_attr(cur_decl, 1))
112981 + return MARK_YES;
112982 + break;
112983 + case PARM_DECL: {
112984 + unsigned int argnum;
112985 +
112986 + cur_decl = DECL_ORIGIN(current_function_decl);
112987 + argnum = find_arg_number_tree(node, cur_decl);
112988 + if (argnum == CANNOT_FIND_ARG)
112989 + return MARK_NO;
112990 + if (is_yes_intentional_attr(cur_decl, argnum))
112991 + return MARK_YES;
112992 + if (is_end_intentional_intentional_attr(cur_decl, argnum))
112993 + return MARK_NOT_INTENTIONAL;
112994 + break;
112995 + }
112996 + case FUNCTION_DECL:
112997 + if (is_turn_off_intentional_attr(DECL_ORIGIN(node)))
112998 + return MARK_TURN_OFF;
112999 + break;
113000 + default:
113001 + break;
113002 + }
113003 + return MARK_NO;
113004 +}
113005 +
113006 +// Search for the intentional_overflow attribute on the last nodes
113007 +static enum mark search_last_nodes_intentional(struct interesting_node *cur_node)
113008 +{
113009 + unsigned int i;
113010 + tree last_node;
113011 + enum mark mark = MARK_NO;
113012 +
113013 +#if BUILDING_GCC_VERSION == 4005
113014 + for (i = 0; i < VEC_length(tree, cur_node->last_nodes); i++) {
113015 + last_node = VEC_index(tree, cur_node->last_nodes, i);
113016 +#elif BUILDING_GCC_VERSION <= 4007
113017 + FOR_EACH_VEC_ELT(tree, cur_node->last_nodes, i, last_node) {
113018 +#else
113019 + FOR_EACH_VEC_ELT(*cur_node->last_nodes, i, last_node) {
113020 +#endif
113021 + mark = get_intentional_attr_type(last_node);
113022 + if (mark != MARK_NO)
113023 + break;
113024 + }
113025 + return mark;
113026 +}
113027 +
113028 +/* Check the intentional kind of size_overflow asm stmt (created by the gimple pass) and
113029 + * set the appropriate intentional_overflow type. Delete the asm stmt in the end.
113030 + */
113031 +static bool is_intentional_attribute_from_gimple(struct interesting_node *cur_node)
113032 +{
113033 + if (!cur_node->intentional_mark_from_gimple)
113034 + return false;
113035 +
113036 + if (is_size_overflow_intentional_asm_yes(cur_node->intentional_mark_from_gimple))
113037 + cur_node->intentional_attr_cur_fndecl = MARK_YES;
113038 + else
113039 + cur_node->intentional_attr_cur_fndecl = MARK_TURN_OFF;
113040 +
113041 + // skip param decls
113042 + if (gimple_asm_noutputs(cur_node->intentional_mark_from_gimple) == 0)
113043 + return true;
113044 + return true;
113045 +}
113046 +
113047 +/* Search intentional_overflow attribute on caller and on callee too.
113048 + * 0</MARK_YES: no dup, search size_overflow and intentional_overflow attributes
113049 + * 0/MARK_NOT_INTENTIONAL: no dup, search size_overflow attribute (int)
113050 + * -1/MARK_TURN_OFF: no dup, no search, current_function_decl -> no dup
113051 +*/
113052 +static void check_intentional_attribute_ipa(struct interesting_node *cur_node)
113053 +{
113054 + const_tree fndecl;
113055 +
113056 + if (is_intentional_attribute_from_gimple(cur_node))
113057 + return;
113058 +
113059 + if (is_turn_off_intentional_attr(DECL_ORIGIN(current_function_decl))) {
113060 + cur_node->intentional_attr_cur_fndecl = MARK_TURN_OFF;
113061 + return;
113062 + }
113063 +
113064 + if (gimple_code(cur_node->first_stmt) == GIMPLE_ASM) {
113065 + cur_node->intentional_attr_cur_fndecl = MARK_NOT_INTENTIONAL;
113066 + return;
113067 + }
113068 +
113069 + if (gimple_code(cur_node->first_stmt) == GIMPLE_ASSIGN)
113070 + return;
113071 +
113072 + fndecl = get_interesting_orig_fndecl(cur_node->first_stmt, cur_node->num);
113073 + if (is_turn_off_intentional_attr(fndecl)) {
113074 + cur_node->intentional_attr_decl = MARK_TURN_OFF;
113075 + return;
113076 + }
113077 +
113078 + if (is_end_intentional_intentional_attr(fndecl, cur_node->num))
113079 + cur_node->intentional_attr_decl = MARK_NOT_INTENTIONAL;
113080 + else if (is_yes_intentional_attr(fndecl, cur_node->num))
113081 + cur_node->intentional_attr_decl = MARK_YES;
113082 +
113083 + cur_node->intentional_attr_cur_fndecl = search_last_nodes_intentional(cur_node);
113084 + print_missing_intentional(cur_node->intentional_attr_decl, cur_node->intentional_attr_cur_fndecl, cur_node->fndecl, cur_node->num);
113085 +}
113086 +
113087 +// e.g., 3.8.2, 64, arch/x86/ia32/ia32_signal.c copy_siginfo_from_user32(): compat_ptr() u32 max
113088 +static bool skip_asm(const_tree arg)
113089 +{
113090 + gimple def_stmt = get_def_stmt(arg);
113091 +
113092 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
113093 + return false;
113094 +
113095 + def_stmt = get_def_stmt(gimple_assign_rhs1(def_stmt));
113096 + return def_stmt && gimple_code(def_stmt) == GIMPLE_ASM;
113097 +}
113098 +
113099 +static void walk_use_def_phi(struct pointer_set_t *visited, struct interesting_node *cur_node, tree result)
113100 +{
113101 + gimple phi = get_def_stmt(result);
113102 + unsigned int i, n = gimple_phi_num_args(phi);
113103 +
113104 + pointer_set_insert(visited, phi);
113105 + for (i = 0; i < n; i++) {
113106 + tree arg = gimple_phi_arg_def(phi, i);
113107 +
113108 + walk_use_def(visited, cur_node, arg);
113109 + }
113110 +}
113111 +
113112 +static void walk_use_def_binary(struct pointer_set_t *visited, struct interesting_node *cur_node, tree lhs)
113113 +{
113114 + gimple def_stmt = get_def_stmt(lhs);
113115 + tree rhs1, rhs2;
113116 +
113117 + rhs1 = gimple_assign_rhs1(def_stmt);
113118 + rhs2 = gimple_assign_rhs2(def_stmt);
113119 +
113120 + walk_use_def(visited, cur_node, rhs1);
113121 + walk_use_def(visited, cur_node, rhs2);
113122 +}
113123 +
113124 +static void insert_last_node(struct interesting_node *cur_node, tree node)
113125 +{
113126 + unsigned int i;
113127 + tree element;
113128 + enum tree_code code;
113129 +
113130 + gcc_assert(node != NULL_TREE);
113131 +
113132 + if (is_gimple_constant(node))
113133 + return;
113134 +
113135 + code = TREE_CODE(node);
113136 + if (code == VAR_DECL) {
113137 + node = DECL_ORIGIN(node);
113138 + code = TREE_CODE(node);
113139 + }
113140 +
113141 + if (code != PARM_DECL && code != FUNCTION_DECL && code != COMPONENT_REF)
113142 + return;
113143 +
113144 +#if BUILDING_GCC_VERSION == 4005
113145 + for (i = 0; i < VEC_length(tree, cur_node->last_nodes); i++) {
113146 + element = VEC_index(tree, cur_node->last_nodes, i);
113147 +#elif BUILDING_GCC_VERSION <= 4007
113148 + FOR_EACH_VEC_ELT(tree, cur_node->last_nodes, i, element) {
113149 +#else
113150 + FOR_EACH_VEC_ELT(*cur_node->last_nodes, i, element) {
113151 +#endif
113152 + if (operand_equal_p(node, element, 0))
113153 + return;
113154 + }
113155 +
113156 +#if BUILDING_GCC_VERSION <= 4007
113157 + gcc_assert(VEC_length(tree, cur_node->last_nodes) < VEC_LEN);
113158 + VEC_safe_push(tree, gc, cur_node->last_nodes, node);
113159 +#else
113160 + gcc_assert(cur_node->last_nodes->length() < VEC_LEN);
113161 + vec_safe_push(cur_node->last_nodes, node);
113162 +#endif
113163 +}
113164 +
113165 +// a size_overflow asm stmt in the control flow doesn't stop the recursion
113166 +static void handle_asm_stmt(struct pointer_set_t *visited, struct interesting_node *cur_node, tree lhs, const_gimple stmt)
113167 +{
113168 + if (!is_size_overflow_asm(stmt))
113169 + walk_use_def(visited, cur_node, SSA_NAME_VAR(lhs));
113170 +}
113171 +
113172 +/* collect the parm_decls and fndecls (for checking a missing size_overflow attribute (ret or arg) or intentional_overflow)
113173 + * and component refs (for checking the intentional_overflow attribute).
113174 + */
113175 +static void walk_use_def(struct pointer_set_t *visited, struct interesting_node *cur_node, tree lhs)
113176 +{
113177 + const_gimple def_stmt;
113178 +
113179 + if (TREE_CODE(lhs) != SSA_NAME) {
113180 + insert_last_node(cur_node, lhs);
113181 + return;
113182 + }
113183 +
113184 + def_stmt = get_def_stmt(lhs);
113185 + if (!def_stmt)
113186 + return;
113187 +
113188 + if (pointer_set_insert(visited, def_stmt))
113189 + return;
113190 +
113191 + switch (gimple_code(def_stmt)) {
113192 + case GIMPLE_NOP:
113193 + return walk_use_def(visited, cur_node, SSA_NAME_VAR(lhs));
113194 + case GIMPLE_ASM:
113195 + return handle_asm_stmt(visited, cur_node, lhs, def_stmt);
113196 + case GIMPLE_CALL: {
113197 + tree fndecl = gimple_call_fndecl(def_stmt);
113198 +
113199 + if (fndecl == NULL_TREE)
113200 + return;
113201 + insert_last_node(cur_node, fndecl);
113202 + return;
113203 + }
113204 + case GIMPLE_PHI:
113205 + return walk_use_def_phi(visited, cur_node, lhs);
113206 + case GIMPLE_ASSIGN:
113207 + switch (gimple_num_ops(def_stmt)) {
113208 + case 2:
113209 + return walk_use_def(visited, cur_node, gimple_assign_rhs1(def_stmt));
113210 + case 3:
113211 + return walk_use_def_binary(visited, cur_node, lhs);
113212 + }
113213 + default:
113214 + debug_gimple_stmt((gimple)def_stmt);
113215 + error("%s: unknown gimple code", __func__);
113216 + gcc_unreachable();
113217 + }
113218 +}
113219 +
113220 +// Collect all the last nodes for checking the intentional_overflow and size_overflow attributes
113221 +static void set_last_nodes(struct interesting_node *cur_node)
113222 +{
113223 + struct pointer_set_t *visited;
113224 +
113225 + visited = pointer_set_create();
113226 + walk_use_def(visited, cur_node, cur_node->node);
113227 + pointer_set_destroy(visited);
113228 +}
113229 +
113230 +enum precond {
113231 + NO_ATTRIBUTE_SEARCH, NO_CHECK_INSERT, NONE
113232 +};
113233 +
113234 +/* 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.
113235 + * There is only missing size_overflow attribute checking if the intentional_overflow attribute is the mark_no type.
113236 + * Stmt duplication is unnecessary if there are no binary/ternary assignements or if the unary assignment isn't a cast.
113237 + * 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.
113238 + */
113239 +static enum precond check_preconditions(struct interesting_node *cur_node)
113240 +{
113241 + bool interesting_conditions[3] = {false, false, false};
113242 +
113243 + set_last_nodes(cur_node);
113244 +
113245 + check_intentional_attribute_ipa(cur_node);
113246 + if (cur_node->intentional_attr_decl == MARK_TURN_OFF || cur_node->intentional_attr_cur_fndecl == MARK_TURN_OFF)
113247 + return NO_ATTRIBUTE_SEARCH;
113248 +
113249 + search_interesting_conditions(cur_node, interesting_conditions);
113250 +
113251 + // error code
113252 + if (interesting_conditions[CAST] && interesting_conditions[FROM_CONST] && !interesting_conditions[NOT_UNARY])
113253 + return NO_ATTRIBUTE_SEARCH;
113254 +
113255 + // unnecessary overflow check
113256 + if (!interesting_conditions[CAST] && !interesting_conditions[NOT_UNARY])
113257 + return NO_CHECK_INSERT;
113258 +
113259 + if (cur_node->intentional_attr_cur_fndecl != MARK_NO)
113260 + return NO_CHECK_INSERT;
113261 +
113262 + return NONE;
113263 +}
113264 +
113265 +/* This function calls the main recursion function (expand) that duplicates the stmts. Before that it checks the intentional_overflow attribute and asm stmts,
113266 + * 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
113267 + * in the original stmt (first stmt) and it inserts the overflow check for the arg of the callee or for the return value.
113268 + */
113269 +static struct next_cgraph_node *handle_interesting_stmt(struct next_cgraph_node *cnodes, struct interesting_node *cur_node, struct cgraph_node *caller_node)
113270 +{
113271 + enum precond ret;
113272 + struct pointer_set_t *visited;
113273 + tree new_node, orig_node = cur_node->node;
113274 +
113275 + ret = check_preconditions(cur_node);
113276 + if (ret == NO_ATTRIBUTE_SEARCH)
113277 + return cnodes;
113278 +
113279 + cnodes = search_overflow_attribute(cnodes, cur_node);
113280 +
113281 + if (ret == NO_CHECK_INSERT)
113282 + return cnodes;
113283 +
113284 + visited = pointer_set_create();
113285 + new_node = expand(visited, caller_node, orig_node);
113286 + pointer_set_destroy(visited);
113287 +
113288 + if (new_node == NULL_TREE)
113289 + return cnodes;
113290 +
113291 + change_orig_node(cur_node, new_node);
113292 + check_size_overflow(caller_node, cur_node->first_stmt, TREE_TYPE(new_node), new_node, orig_node, BEFORE_STMT);
113293 +
113294 + return cnodes;
113295 +}
113296 +
113297 +// Check visited interesting nodes.
113298 +static bool is_in_interesting_node(struct interesting_node *head, const_gimple first_stmt, const_tree node, unsigned int num)
113299 +{
113300 + struct interesting_node *cur;
113301 +
113302 + for (cur = head; cur; cur = cur->next) {
113303 + if (!operand_equal_p(node, cur->node, 0))
113304 + continue;
113305 + if (num != cur->num)
113306 + continue;
113307 + if (first_stmt == cur->first_stmt)
113308 + return true;
113309 + }
113310 + return false;
113311 +}
113312 +
113313 +/* Create an interesting node. The ipa pass starts to duplicate from these stmts.
113314 + 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
113315 + 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
113316 + the intentional_overflow attribute check. They are collected by set_last_nodes().
113317 + num: arg count of a call stmt or 0 when it is a ret
113318 + node: the recursion starts from here, it is a call arg or a return value
113319 + 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.
113320 + intentional_attr_decl: intentional_overflow attribute of the callee function
113321 + intentional_attr_cur_fndecl: intentional_overflow attribute of the caller function
113322 + intentional_mark_from_gimple: the intentional overflow type of size_overflow asm stmt from gimple if it exists
113323 + */
113324 +static struct interesting_node *create_new_interesting_node(struct interesting_node *head, gimple first_stmt, tree node, unsigned int num, gimple asm_stmt)
113325 +{
113326 + struct interesting_node *new_node;
113327 + tree fndecl;
113328 + enum gimple_code code;
113329 +
113330 + gcc_assert(node != NULL_TREE);
113331 + code = gimple_code(first_stmt);
113332 + gcc_assert(code == GIMPLE_CALL || code == GIMPLE_ASM || code == GIMPLE_ASSIGN || code == GIMPLE_RETURN);
113333 +
113334 + if (num == CANNOT_FIND_ARG)
113335 + return head;
113336 +
113337 + if (skip_types(node))
113338 + return head;
113339 +
113340 + if (skip_asm(node))
113341 + return head;
113342 +
113343 + if (is_gimple_call(first_stmt))
113344 + fndecl = gimple_call_fndecl(first_stmt);
113345 + else
113346 + fndecl = current_function_decl;
113347 +
113348 + if (fndecl == NULL_TREE)
113349 + return head;
113350 +
113351 + if (is_in_interesting_node(head, first_stmt, node, num))
113352 + return head;
113353 +
113354 + new_node = (struct interesting_node *)xmalloc(sizeof(*new_node));
113355 +
113356 + new_node->next = NULL;
113357 + new_node->first_stmt = first_stmt;
113358 +#if BUILDING_GCC_VERSION <= 4007
113359 + new_node->last_nodes = VEC_alloc(tree, gc, VEC_LEN);
113360 +#else
113361 + vec_alloc(new_node->last_nodes, VEC_LEN);
113362 +#endif
113363 + new_node->num = num;
113364 + new_node->node = node;
113365 + new_node->fndecl = fndecl;
113366 + new_node->intentional_attr_decl = MARK_NO;
113367 + new_node->intentional_attr_cur_fndecl = MARK_NO;
113368 + new_node->intentional_mark_from_gimple = asm_stmt;
113369 +
113370 + if (!head)
113371 + return new_node;
113372 +
113373 + new_node->next = head;
113374 + return new_node;
113375 +}
113376 +
113377 +/* 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).
113378 + * If the ret stmt is in the next cgraph node list then it's an interesting ret.
113379 + */
113380 +static struct interesting_node *handle_stmt_by_cgraph_nodes_ret(struct interesting_node *head, gimple stmt, struct next_cgraph_node *next_node)
113381 +{
113382 + struct next_cgraph_node *cur_node;
113383 + tree ret = gimple_return_retval(stmt);
113384 +
113385 + if (ret == NULL_TREE)
113386 + return head;
113387 +
113388 + for (cur_node = next_node; cur_node; cur_node = cur_node->next) {
113389 + if (!operand_equal_p(cur_node->callee_fndecl, DECL_ORIGIN(current_function_decl), 0))
113390 + continue;
113391 + if (cur_node->num == 0)
113392 + head = create_new_interesting_node(head, stmt, ret, 0, NOT_INTENTIONAL_ASM);
113393 + }
113394 +
113395 + return head;
113396 +}
113397 +
113398 +/* 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).
113399 + * If the call stmt is in the next cgraph node list then it's an interesting call.
113400 + */
113401 +static struct interesting_node *handle_stmt_by_cgraph_nodes_call(struct interesting_node *head, gimple stmt, struct next_cgraph_node *next_node)
113402 +{
113403 + unsigned int argnum;
113404 + tree fndecl, arg;
113405 + struct next_cgraph_node *cur_node;
113406 +
113407 + fndecl = gimple_call_fndecl(stmt);
113408 + if (fndecl == NULL_TREE)
113409 + return head;
113410 +
113411 + for (cur_node = next_node; cur_node; cur_node = cur_node->next) {
113412 + if (!operand_equal_p(cur_node->callee_fndecl, fndecl, 0))
113413 + continue;
113414 + argnum = get_correct_arg_count(cur_node->num, fndecl);
113415 + gcc_assert(argnum != CANNOT_FIND_ARG);
113416 + if (argnum == 0)
113417 + continue;
113418 +
113419 + arg = gimple_call_arg(stmt, argnum - 1);
113420 + head = create_new_interesting_node(head, stmt, arg, argnum, NOT_INTENTIONAL_ASM);
113421 + }
113422 +
113423 + return head;
113424 +}
113425 +
113426 +static unsigned int check_ops(const_tree orig_node, const_tree node, unsigned int ret_count)
113427 +{
113428 + if (!operand_equal_p(orig_node, node, 0))
113429 + return WRONG_NODE;
113430 + if (skip_types(node))
113431 + return WRONG_NODE;
113432 + return ret_count;
113433 +}
113434 +
113435 +// Get the index of the rhs node in an assignment
113436 +static unsigned int get_assign_ops_count(const_gimple stmt, tree node)
113437 +{
113438 + const_tree rhs1, rhs2;
113439 + unsigned int ret;
113440 +
113441 + gcc_assert(stmt);
113442 + gcc_assert(is_gimple_assign(stmt));
113443 +
113444 + rhs1 = gimple_assign_rhs1(stmt);
113445 + gcc_assert(rhs1 != NULL_TREE);
113446 +
113447 + switch (gimple_num_ops(stmt)) {
113448 + case 2:
113449 + return check_ops(node, rhs1, 1);
113450 + case 3:
113451 + ret = check_ops(node, rhs1, 1);
113452 + if (ret != WRONG_NODE)
113453 + return ret;
113454 +
113455 + rhs2 = gimple_assign_rhs2(stmt);
113456 + gcc_assert(rhs2 != NULL_TREE);
113457 + return check_ops(node, rhs2, 2);
113458 + default:
113459 + gcc_unreachable();
113460 + }
113461 +}
113462 +
113463 +// Find the correct arg number of a call stmt. It is needed when the interesting function is a cloned function.
113464 +static unsigned int find_arg_number_gimple(const_tree arg, const_gimple stmt)
113465 +{
113466 + unsigned int i;
113467 +
113468 + if (gimple_call_fndecl(stmt) == NULL_TREE)
113469 + return CANNOT_FIND_ARG;
113470 +
113471 + for (i = 0; i < gimple_call_num_args(stmt); i++) {
113472 + tree node;
113473 +
113474 + node = gimple_call_arg(stmt, i);
113475 + if (!operand_equal_p(arg, node, 0))
113476 + continue;
113477 + if (!skip_types(node))
113478 + return i + 1;
113479 + }
113480 +
113481 + return CANNOT_FIND_ARG;
113482 +}
113483 +
113484 +/* starting from the size_overflow asm stmt collect interesting stmts. They can be
113485 + * any of return, call or assignment stmts (because of inlining).
113486 + */
113487 +static struct interesting_node *get_interesting_ret_or_call(struct pointer_set_t *visited, struct interesting_node *head, tree node, gimple intentional_asm)
113488 +{
113489 + use_operand_p use_p;
113490 + imm_use_iterator imm_iter;
113491 + unsigned int argnum;
113492 +
113493 + gcc_assert(TREE_CODE(node) == SSA_NAME);
113494 +
113495 + if (pointer_set_insert(visited, node))
113496 + return head;
113497 +
113498 + FOR_EACH_IMM_USE_FAST(use_p, imm_iter, node) {
113499 + gimple stmt = USE_STMT(use_p);
113500 +
113501 + if (stmt == NULL)
113502 + return head;
113503 + if (is_gimple_debug(stmt))
113504 + continue;
113505 +
113506 + switch (gimple_code(stmt)) {
113507 + case GIMPLE_CALL:
113508 + argnum = find_arg_number_gimple(node, stmt);
113509 + head = create_new_interesting_node(head, stmt, node, argnum, intentional_asm);
113510 + break;
113511 + case GIMPLE_RETURN:
113512 + head = create_new_interesting_node(head, stmt, node, 0, intentional_asm);
113513 + break;
113514 + case GIMPLE_ASSIGN:
113515 + argnum = get_assign_ops_count(stmt, node);
113516 + head = create_new_interesting_node(head, stmt, node, argnum, intentional_asm);
113517 + break;
113518 + case GIMPLE_PHI: {
113519 + tree result = gimple_phi_result(stmt);
113520 + head = get_interesting_ret_or_call(visited, head, result, intentional_asm);
113521 + break;
113522 + }
113523 + case GIMPLE_ASM:
113524 + if (gimple_asm_noutputs(stmt) != 0)
113525 + break;
113526 + if (!is_size_overflow_asm(stmt))
113527 + break;
113528 + head = create_new_interesting_node(head, stmt, node, 1, intentional_asm);
113529 + break;
113530 + case GIMPLE_COND:
113531 + case GIMPLE_SWITCH:
113532 + break;
113533 + default:
113534 + debug_gimple_stmt(stmt);
113535 + gcc_unreachable();
113536 + break;
113537 + }
113538 + }
113539 + return head;
113540 +}
113541 +
113542 +static void remove_size_overflow_asm(gimple stmt)
113543 +{
113544 + gimple_stmt_iterator gsi;
113545 + tree input, output;
113546 +
113547 + if (!is_size_overflow_asm(stmt))
113548 + return;
113549 +
113550 + if (gimple_asm_noutputs(stmt) == 0) {
113551 + gsi = gsi_for_stmt(stmt);
113552 + gsi_remove(&gsi, true);
113553 + return;
113554 + }
113555 +
113556 + input = gimple_asm_input_op(stmt, 0);
113557 + output = gimple_asm_output_op(stmt, 0);
113558 + replace_size_overflow_asm_with_assign(stmt, TREE_VALUE(output), TREE_VALUE(input));
113559 +}
113560 +
113561 +/* handle the size_overflow asm stmts from the gimple pass and collect the interesting stmts.
113562 + * If the asm stmt is a parm_decl kind (noutputs == 0) then remove it.
113563 + * If it is a simple asm stmt then replace it with an assignment from the asm input to the asm output.
113564 + */
113565 +static struct interesting_node *handle_stmt_by_size_overflow_asm(gimple stmt, struct interesting_node *head)
113566 +{
113567 + const_tree output;
113568 + struct pointer_set_t *visited;
113569 + gimple intentional_asm = NOT_INTENTIONAL_ASM;
113570 +
113571 + if (!is_size_overflow_asm(stmt))
113572 + return head;
113573 +
113574 + if (is_size_overflow_intentional_asm_yes(stmt) || is_size_overflow_intentional_asm_turn_off(stmt))
113575 + intentional_asm = stmt;
113576 +
113577 + gcc_assert(gimple_asm_ninputs(stmt) == 1);
113578 +
113579 + if (gimple_asm_noutputs(stmt) == 0 && is_size_overflow_intentional_asm_turn_off(stmt))
113580 + return head;
113581 +
113582 + if (gimple_asm_noutputs(stmt) == 0) {
113583 + const_tree input;
113584 +
113585 + if (!is_size_overflow_intentional_asm_turn_off(stmt))
113586 + return head;
113587 +
113588 + input = gimple_asm_input_op(stmt, 0);
113589 + remove_size_overflow_asm(stmt);
113590 + if (is_gimple_constant(TREE_VALUE(input)))
113591 + return head;
113592 + visited = pointer_set_create();
113593 + head = get_interesting_ret_or_call(visited, head, TREE_VALUE(input), intentional_asm);
113594 + pointer_set_destroy(visited);
113595 + return head;
113596 + }
113597 +
113598 + if (!is_size_overflow_intentional_asm_yes(stmt) && !is_size_overflow_intentional_asm_turn_off(stmt))
113599 + remove_size_overflow_asm(stmt);
113600 +
113601 + visited = pointer_set_create();
113602 + output = gimple_asm_output_op(stmt, 0);
113603 + head = get_interesting_ret_or_call(visited, head, TREE_VALUE(output), intentional_asm);
113604 + pointer_set_destroy(visited);
113605 + return head;
113606 +}
113607 +
113608 +/* Iterate over all the stmts of a function and look for the size_overflow asm stmts (they were created in the gimple pass)
113609 + * or a call stmt or a return stmt and store them in the interesting_node list
113610 + */
113611 +static struct interesting_node *collect_interesting_stmts(struct next_cgraph_node *next_node)
113612 +{
113613 + basic_block bb;
113614 + struct interesting_node *head = NULL;
113615 +
113616 + FOR_ALL_BB(bb) {
113617 + gimple_stmt_iterator gsi;
113618 +
113619 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
113620 + enum gimple_code code;
113621 + gimple stmt = gsi_stmt(gsi);
113622 +
113623 + code = gimple_code(stmt);
113624 +
113625 + if (code == GIMPLE_ASM)
113626 + head = handle_stmt_by_size_overflow_asm(stmt, head);
113627 +
113628 + if (!next_node)
113629 + continue;
113630 + if (code == GIMPLE_CALL)
113631 + head = handle_stmt_by_cgraph_nodes_call(head, stmt, next_node);
113632 + if (code == GIMPLE_RETURN)
113633 + head = handle_stmt_by_cgraph_nodes_ret(head, stmt, next_node);
113634 + }
113635 + }
113636 + return head;
113637 +}
113638 +
113639 +static void set_current_function_decl(tree fndecl)
113640 +{
113641 + gcc_assert(fndecl != NULL_TREE);
113642 +
113643 + push_cfun(DECL_STRUCT_FUNCTION(fndecl));
113644 + calculate_dominance_info(CDI_DOMINATORS);
113645 + current_function_decl = fndecl;
113646 +}
113647 +
113648 +static void unset_current_function_decl(void)
113649 +{
113650 + free_dominance_info(CDI_DOMINATORS);
113651 + pop_cfun();
113652 + current_function_decl = NULL_TREE;
113653 +}
113654 +
113655 +static void free_interesting_node(struct interesting_node *head)
113656 +{
113657 + struct interesting_node *cur;
113658 +
113659 + while (head) {
113660 + cur = head->next;
113661 +#if BUILDING_GCC_VERSION <= 4007
113662 + VEC_free(tree, gc, head->last_nodes);
113663 +#else
113664 + vec_free(head->last_nodes);
113665 +#endif
113666 + free(head);
113667 + head = cur;
113668 + }
113669 +}
113670 +
113671 +static struct visited *insert_visited_function(struct visited *head, struct interesting_node *cur_node)
113672 +{
113673 + struct visited *new_visited;
113674 +
113675 + new_visited = (struct visited *)xmalloc(sizeof(*new_visited));
113676 + new_visited->fndecl = cur_node->fndecl;
113677 + new_visited->num = cur_node->num;
113678 + new_visited->first_stmt = cur_node->first_stmt;
113679 + new_visited->next = NULL;
113680 +
113681 + if (!head)
113682 + return new_visited;
113683 +
113684 + new_visited->next = head;
113685 + return new_visited;
113686 +}
113687 +
113688 +/* 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
113689 + * it is a visited function.
113690 + */
113691 +static bool is_visited_function(struct visited *head, struct interesting_node *cur_node)
113692 +{
113693 + struct visited *cur;
113694 +
113695 + if (!head)
113696 + return false;
113697 +
113698 + for (cur = head; cur; cur = cur->next) {
113699 + if (!operand_equal_p(cur_node->fndecl, cur->fndecl, 0))
113700 + continue;
113701 + if (cur_node->num != cur->num)
113702 + continue;
113703 + if (cur_node->first_stmt == cur->first_stmt)
113704 + return true;
113705 + }
113706 + return false;
113707 +}
113708 +
113709 +static void free_next_cgraph_node(struct next_cgraph_node *head)
113710 +{
113711 + struct next_cgraph_node *cur;
113712 +
113713 + while (head) {
113714 + cur = head->next;
113715 + free(head);
113716 + head = cur;
113717 + }
113718 +}
113719 +
113720 +static void remove_all_size_overflow_asm(void)
113721 +{
113722 + basic_block bb;
113723 +
113724 + FOR_ALL_BB(bb) {
113725 + gimple_stmt_iterator si;
113726 +
113727 + for (si = gsi_start_bb(bb); !gsi_end_p(si); gsi_next(&si))
113728 + remove_size_overflow_asm(gsi_stmt(si));
113729 + }
113730 +}
113731 +
113732 +/* Main recursive walk of the ipa pass: iterate over the collected interesting stmts in a function
113733 + * (they are interesting if they have an associated size_overflow asm stmt) and recursively walk
113734 + * the newly collected interesting functions (they are interesting if there is control flow between
113735 + * the interesting stmts and them).
113736 + */
113737 +static struct visited *handle_function(struct cgraph_node *node, struct next_cgraph_node *next_node, struct visited *visited)
113738 +{
113739 + struct interesting_node *head, *cur_node;
113740 + struct next_cgraph_node *cur_cnodes, *cnodes_head = NULL;
113741 +
113742 +#if BUILDING_GCC_VERSION <= 4007
113743 + set_current_function_decl(node->decl);
113744 +#else
113745 + set_current_function_decl(node->symbol.decl);
113746 +#endif
113747 + call_count = 0;
113748 +
113749 + head = collect_interesting_stmts(next_node);
113750 + for (cur_node = head; cur_node; cur_node = cur_node->next) {
113751 + if (is_visited_function(visited, cur_node))
113752 + continue;
113753 + cnodes_head = handle_interesting_stmt(cnodes_head, cur_node, node);
113754 + visited = insert_visited_function(visited, cur_node);
113755 + }
113756 +
113757 + free_interesting_node(head);
113758 + remove_all_size_overflow_asm();
113759 + unset_current_function_decl();
113760 +
113761 + for (cur_cnodes = cnodes_head; cur_cnodes; cur_cnodes = cur_cnodes->next)
113762 + visited = handle_function(cur_cnodes->current_function, cur_cnodes, visited);
113763 +
113764 + free_next_cgraph_node(cnodes_head);
113765 + return visited;
113766 +}
113767 +
113768 +static void free_visited(struct visited *head)
113769 +{
113770 + struct visited *cur;
113771 +
113772 + while (head) {
113773 + cur = head->next;
113774 + free(head);
113775 + head = cur;
113776 + }
113777 +}
113778 +
113779 +// erase the local flag
113780 +static void set_plf_false(void)
113781 +{
113782 + basic_block bb;
113783 +
113784 + FOR_ALL_BB(bb) {
113785 + gimple_stmt_iterator si;
113786 +
113787 + for (si = gsi_start_bb(bb); !gsi_end_p(si); gsi_next(&si))
113788 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
113789 + for (si = gsi_start_phis(bb); !gsi_end_p(si); gsi_next(&si))
113790 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
113791 + }
113792 +}
113793 +
113794 +#if BUILDING_GCC_VERSION <= 4006
113795 +static bool cgraph_function_with_gimple_body_p(struct cgraph_node *node)
113796 +{
113797 + return node->analyzed && !node->thunk.thunk_p && !node->alias;
113798 +}
113799 +
113800 +static struct cgraph_node *cgraph_first_function_with_gimple_body(void)
113801 +{
113802 + struct cgraph_node *node;
113803 +
113804 + for (node = cgraph_nodes; node; node = node->next) {
113805 + if (cgraph_function_with_gimple_body_p(node))
113806 + return node;
113807 + }
113808 + return NULL;
113809 +}
113810 +
113811 +static inline struct cgraph_node *cgraph_next_function_with_gimple_body(struct cgraph_node *node)
113812 +{
113813 + for (node = node->next; node; node = node->next) {
113814 + if (cgraph_function_with_gimple_body_p(node))
113815 + return node;
113816 + }
113817 + return NULL;
113818 +}
113819 +
113820 +#define FOR_EACH_FUNCTION_WITH_GIMPLE_BODY(node) \
113821 + for ((node) = cgraph_first_function_with_gimple_body (); (node); \
113822 + (node) = cgraph_next_function_with_gimple_body (node))
113823 +
113824 +#endif
113825 +
113826 +// Main entry point of the ipa pass: erases the plf flag of all stmts and iterates over all the functions
113827 +static unsigned int search_function(void)
113828 +{
113829 + struct cgraph_node *node;
113830 + struct visited *visited = NULL;
113831 +
113832 + FOR_EACH_FUNCTION_WITH_GIMPLE_BODY(node) {
113833 +#if BUILDING_GCC_VERSION <= 4007
113834 + set_current_function_decl(node->decl);
113835 +#else
113836 + set_current_function_decl(node->symbol.decl);
113837 +#endif
113838 + set_plf_false();
113839 + unset_current_function_decl();
113840 + }
113841 +
113842 + FOR_EACH_FUNCTION_WITH_GIMPLE_BODY(node) {
113843 + gcc_assert(cgraph_function_flags_ready);
113844 +#if BUILDING_GCC_VERSION <= 4007
113845 + gcc_assert(node->reachable);
113846 +#endif
113847 +
113848 + visited = handle_function(node, NULL, visited);
113849 + }
113850 +
113851 + free_visited(visited);
113852 + return 0;
113853 +}
113854 +
113855 +static struct ipa_opt_pass_d pass_ipa = {
113856 + .pass = {
113857 + .type = SIMPLE_IPA_PASS,
113858 + .name = "size_overflow",
113859 +#if BUILDING_GCC_VERSION >= 4008
113860 + .optinfo_flags = OPTGROUP_NONE,
113861 +#endif
113862 + .gate = NULL,
113863 + .execute = search_function,
113864 + .sub = NULL,
113865 + .next = NULL,
113866 + .static_pass_number = 0,
113867 + .tv_id = TV_NONE,
113868 + .properties_required = 0,
113869 + .properties_provided = 0,
113870 + .properties_destroyed = 0,
113871 + .todo_flags_start = 0,
113872 + .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,
113873 + },
113874 + .generate_summary = NULL,
113875 + .write_summary = NULL,
113876 + .read_summary = NULL,
113877 +#if BUILDING_GCC_VERSION >= 4006
113878 + .write_optimization_summary = NULL,
113879 + .read_optimization_summary = NULL,
113880 +#endif
113881 + .stmt_fixup = NULL,
113882 + .function_transform_todo_flags_start = 0,
113883 + .function_transform = NULL,
113884 + .variable_transform = NULL,
113885 +};
113886 +
113887 +// data for the size_overflow asm stmt
113888 +struct asm_data {
113889 + gimple def_stmt;
113890 + tree input;
113891 + tree output;
113892 +};
113893 +
113894 +#if BUILDING_GCC_VERSION <= 4007
113895 +static VEC(tree, gc) *create_asm_io_list(tree string, tree io)
113896 +#else
113897 +static vec<tree, va_gc> *create_asm_io_list(tree string, tree io)
113898 +#endif
113899 +{
113900 + tree list;
113901 +#if BUILDING_GCC_VERSION <= 4007
113902 + VEC(tree, gc) *vec_list = NULL;
113903 +#else
113904 + vec<tree, va_gc> *vec_list = NULL;
113905 +#endif
113906 +
113907 + list = build_tree_list(NULL_TREE, string);
113908 + list = chainon(NULL_TREE, build_tree_list(list, io));
113909 +#if BUILDING_GCC_VERSION <= 4007
113910 + VEC_safe_push(tree, gc, vec_list, list);
113911 +#else
113912 + vec_safe_push(vec_list, list);
113913 +#endif
113914 + return vec_list;
113915 +}
113916 +
113917 +static void create_asm_stmt(const char *str, tree str_input, tree str_output, struct asm_data *asm_data)
113918 +{
113919 + gimple asm_stmt;
113920 + gimple_stmt_iterator gsi;
113921 +#if BUILDING_GCC_VERSION <= 4007
113922 + VEC(tree, gc) *input, *output = NULL;
113923 +#else
113924 + vec<tree, va_gc> *input, *output = NULL;
113925 +#endif
113926 +
113927 + input = create_asm_io_list(str_input, asm_data->input);
113928 +
113929 + if (asm_data->output)
113930 + output = create_asm_io_list(str_output, asm_data->output);
113931 +
113932 + asm_stmt = gimple_build_asm_vec(str, input, output, NULL, NULL);
113933 + gsi = gsi_for_stmt(asm_data->def_stmt);
113934 + gsi_insert_after(&gsi, asm_stmt, GSI_NEW_STMT);
113935 +
113936 + if (asm_data->output)
113937 + SSA_NAME_DEF_STMT(asm_data->output) = asm_stmt;
113938 +}
113939 +
113940 +static void replace_call_lhs(const struct asm_data *asm_data)
113941 +{
113942 + gimple_set_lhs(asm_data->def_stmt, asm_data->input);
113943 + update_stmt(asm_data->def_stmt);
113944 + SSA_NAME_DEF_STMT(asm_data->input) = asm_data->def_stmt;
113945 +}
113946 +
113947 +static enum mark search_intentional_phi(struct pointer_set_t *visited, const_tree result)
113948 +{
113949 + enum mark cur_fndecl_attr;
113950 + gimple phi = get_def_stmt(result);
113951 + unsigned int i, n = gimple_phi_num_args(phi);
113952 +
113953 + pointer_set_insert(visited, phi);
113954 + for (i = 0; i < n; i++) {
113955 + tree arg = gimple_phi_arg_def(phi, i);
113956 +
113957 + cur_fndecl_attr = search_intentional(visited, arg);
113958 + if (cur_fndecl_attr != MARK_NO)
113959 + return cur_fndecl_attr;
113960 + }
113961 + return MARK_NO;
113962 +}
113963 +
113964 +static enum mark search_intentional_binary(struct pointer_set_t *visited, const_tree lhs)
113965 +{
113966 + enum mark cur_fndecl_attr;
113967 + const_tree rhs1, rhs2;
113968 + gimple def_stmt = get_def_stmt(lhs);
113969 +
113970 + rhs1 = gimple_assign_rhs1(def_stmt);
113971 + rhs2 = gimple_assign_rhs2(def_stmt);
113972 +
113973 + cur_fndecl_attr = search_intentional(visited, rhs1);
113974 + if (cur_fndecl_attr != MARK_NO)
113975 + return cur_fndecl_attr;
113976 + return search_intentional(visited, rhs2);
113977 +}
113978 +
113979 +// Look up the intentional_overflow attribute on the caller and the callee functions.
113980 +static enum mark search_intentional(struct pointer_set_t *visited, const_tree lhs)
113981 +{
113982 + const_gimple def_stmt;
113983 +
113984 + if (TREE_CODE(lhs) != SSA_NAME)
113985 + return get_intentional_attr_type(lhs);
113986 +
113987 + def_stmt = get_def_stmt(lhs);
113988 + if (!def_stmt)
113989 + return MARK_NO;
113990 +
113991 + if (pointer_set_contains(visited, def_stmt))
113992 + return MARK_NO;
113993 +
113994 + switch (gimple_code(def_stmt)) {
113995 + case GIMPLE_NOP:
113996 + return search_intentional(visited, SSA_NAME_VAR(lhs));
113997 + case GIMPLE_ASM:
113998 + if (is_size_overflow_intentional_asm_turn_off(def_stmt))
113999 + return MARK_TURN_OFF;
114000 + return MARK_NO;
114001 + case GIMPLE_CALL:
114002 + return MARK_NO;
114003 + case GIMPLE_PHI:
114004 + return search_intentional_phi(visited, lhs);
114005 + case GIMPLE_ASSIGN:
114006 + switch (gimple_num_ops(def_stmt)) {
114007 + case 2:
114008 + return search_intentional(visited, gimple_assign_rhs1(def_stmt));
114009 + case 3:
114010 + return search_intentional_binary(visited, lhs);
114011 + }
114012 + case GIMPLE_RETURN:
114013 + return MARK_NO;
114014 + default:
114015 + debug_gimple_stmt((gimple)def_stmt);
114016 + error("%s: unknown gimple code", __func__);
114017 + gcc_unreachable();
114018 + }
114019 +}
114020 +
114021 +// Check the intentional_overflow attribute and create the asm comment string for the size_overflow asm stmt.
114022 +static enum mark check_intentional_attribute_gimple(const_tree arg, const_gimple stmt, unsigned int argnum)
114023 +{
114024 + const_tree fndecl;
114025 + struct pointer_set_t *visited;
114026 + enum mark cur_fndecl_attr, decl_attr = MARK_NO;
114027 +
114028 + fndecl = get_interesting_orig_fndecl(stmt, argnum);
114029 + if (is_end_intentional_intentional_attr(fndecl, argnum))
114030 + decl_attr = MARK_NOT_INTENTIONAL;
114031 + else if (is_yes_intentional_attr(fndecl, argnum))
114032 + decl_attr = MARK_YES;
114033 + else if (is_turn_off_intentional_attr(fndecl) || is_turn_off_intentional_attr(DECL_ORIGIN(current_function_decl))) {
114034 + return MARK_TURN_OFF;
114035 + }
114036 +
114037 + visited = pointer_set_create();
114038 + cur_fndecl_attr = search_intentional(visited, arg);
114039 + pointer_set_destroy(visited);
114040 +
114041 + switch (cur_fndecl_attr) {
114042 + case MARK_NO:
114043 + return MARK_NO;
114044 + case MARK_TURN_OFF:
114045 + return MARK_TURN_OFF;
114046 + default:
114047 + print_missing_intentional(decl_attr, cur_fndecl_attr, fndecl, argnum);
114048 + return MARK_YES;
114049 + }
114050 +}
114051 +
114052 +static void check_missing_size_overflow_attribute(tree var)
114053 +{
114054 + tree orig_fndecl;
114055 + unsigned int num;
114056 +
114057 + if (is_a_return_check(var))
114058 + orig_fndecl = DECL_ORIGIN(var);
114059 + else
114060 + orig_fndecl = DECL_ORIGIN(current_function_decl);
114061 +
114062 + num = get_function_num(var, orig_fndecl);
114063 + if (num == CANNOT_FIND_ARG)
114064 + return;
114065 +
114066 + is_missing_function(orig_fndecl, num);
114067 +}
114068 +
114069 +static void search_size_overflow_attribute_phi(struct pointer_set_t *visited, const_tree result)
114070 +{
114071 + gimple phi = get_def_stmt(result);
114072 + unsigned int i, n = gimple_phi_num_args(phi);
114073 +
114074 + pointer_set_insert(visited, phi);
114075 + for (i = 0; i < n; i++) {
114076 + tree arg = gimple_phi_arg_def(phi, i);
114077 +
114078 + search_size_overflow_attribute(visited, arg);
114079 + }
114080 +}
114081 +
114082 +static void search_size_overflow_attribute_binary(struct pointer_set_t *visited, const_tree lhs)
114083 +{
114084 + const_gimple def_stmt = get_def_stmt(lhs);
114085 + tree rhs1, rhs2;
114086 +
114087 + rhs1 = gimple_assign_rhs1(def_stmt);
114088 + rhs2 = gimple_assign_rhs2(def_stmt);
114089 +
114090 + search_size_overflow_attribute(visited, rhs1);
114091 + search_size_overflow_attribute(visited, rhs2);
114092 +}
114093 +
114094 +static void search_size_overflow_attribute(struct pointer_set_t *visited, tree lhs)
114095 +{
114096 + const_gimple def_stmt;
114097 +
114098 + if (TREE_CODE(lhs) == PARM_DECL) {
114099 + check_missing_size_overflow_attribute(lhs);
114100 + return;
114101 + }
114102 +
114103 + def_stmt = get_def_stmt(lhs);
114104 + if (!def_stmt)
114105 + return;
114106 +
114107 + if (pointer_set_insert(visited, def_stmt))
114108 + return;
114109 +
114110 + switch (gimple_code(def_stmt)) {
114111 + case GIMPLE_NOP:
114112 + return search_size_overflow_attribute(visited, SSA_NAME_VAR(lhs));
114113 + case GIMPLE_ASM:
114114 + return;
114115 + case GIMPLE_CALL: {
114116 + tree fndecl = gimple_call_fndecl(def_stmt);
114117 +
114118 + if (fndecl == NULL_TREE)
114119 + return;
114120 + check_missing_size_overflow_attribute(fndecl);
114121 + return;
114122 + }
114123 + case GIMPLE_PHI:
114124 + return search_size_overflow_attribute_phi(visited, lhs);
114125 + case GIMPLE_ASSIGN:
114126 + switch (gimple_num_ops(def_stmt)) {
114127 + case 2:
114128 + return search_size_overflow_attribute(visited, gimple_assign_rhs1(def_stmt));
114129 + case 3:
114130 + return search_size_overflow_attribute_binary(visited, lhs);
114131 + }
114132 + default:
114133 + debug_gimple_stmt((gimple)def_stmt);
114134 + error("%s: unknown gimple code", __func__);
114135 + gcc_unreachable();
114136 + }
114137 +}
114138 +
114139 +// Search missing entries in the hash table (invoked from the gimple pass)
114140 +static void search_missing_size_overflow_attribute_gimple(const_gimple stmt, unsigned int num)
114141 +{
114142 + tree fndecl = NULL_TREE;
114143 + tree lhs;
114144 + struct pointer_set_t *visited;
114145 +
114146 + if (is_turn_off_intentional_attr(DECL_ORIGIN(current_function_decl)))
114147 + return;
114148 +
114149 + if (num == 0) {
114150 + gcc_assert(gimple_code(stmt) == GIMPLE_RETURN);
114151 + lhs = gimple_return_retval(stmt);
114152 + } else {
114153 + gcc_assert(is_gimple_call(stmt));
114154 + lhs = gimple_call_arg(stmt, num - 1);
114155 + fndecl = gimple_call_fndecl(stmt);
114156 + }
114157 +
114158 + if (fndecl != NULL_TREE && is_turn_off_intentional_attr(DECL_ORIGIN(fndecl)))
114159 + return;
114160 +
114161 + visited = pointer_set_create();
114162 + search_size_overflow_attribute(visited, lhs);
114163 + pointer_set_destroy(visited);
114164 +}
114165 +
114166 +static void create_output_from_phi(gimple stmt, unsigned int argnum, struct asm_data *asm_data)
114167 +{
114168 + gimple_stmt_iterator gsi;
114169 + gimple assign;
114170 +
114171 + assign = gimple_build_assign(asm_data->input, asm_data->output);
114172 + gsi = gsi_for_stmt(stmt);
114173 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
114174 + asm_data->def_stmt = assign;
114175 +
114176 + asm_data->output = create_new_var(TREE_TYPE(asm_data->output));
114177 + asm_data->output = make_ssa_name(asm_data->output, stmt);
114178 + if (gimple_code(stmt) == GIMPLE_RETURN)
114179 + gimple_return_set_retval(stmt, asm_data->output);
114180 + else
114181 + gimple_call_set_arg(stmt, argnum - 1, asm_data->output);
114182 + update_stmt(stmt);
114183 +}
114184 +
114185 +static const char *convert_mark_to_str(enum mark mark)
114186 +{
114187 + switch (mark) {
114188 + case MARK_NO:
114189 + return OK_ASM_STR;
114190 + case MARK_YES:
114191 + case MARK_NOT_INTENTIONAL:
114192 + return YES_ASM_STR;
114193 + case MARK_TURN_OFF:
114194 + return TURN_OFF_ASM_STR;
114195 + }
114196 +
114197 + gcc_unreachable();
114198 +}
114199 +
114200 +/* Create the input of the size_overflow asm stmt.
114201 + * When the arg of the callee function is a parm_decl it creates this kind of size_overflow asm stmt:
114202 + * __asm__("# size_overflow MARK_YES" : : "rm" size_1(D));
114203 + * The input field in asm_data will be empty if there is no need for further size_overflow asm stmt insertion.
114204 + * otherwise create the input (for a phi stmt the output too) of the asm stmt.
114205 + */
114206 +static void create_asm_input(gimple stmt, unsigned int argnum, struct asm_data *asm_data)
114207 +{
114208 + if (!asm_data->def_stmt) {
114209 + asm_data->input = NULL_TREE;
114210 + return;
114211 + }
114212 +
114213 + gcc_assert(!is_size_overflow_intentional_asm_turn_off(asm_data->def_stmt));
114214 +
114215 + asm_data->input = create_new_var(TREE_TYPE(asm_data->output));
114216 + asm_data->input = make_ssa_name(asm_data->input, asm_data->def_stmt);
114217 +
114218 + switch (gimple_code(asm_data->def_stmt)) {
114219 + case GIMPLE_ASSIGN:
114220 + case GIMPLE_CALL:
114221 + replace_call_lhs(asm_data);
114222 + break;
114223 + case GIMPLE_PHI:
114224 + create_output_from_phi(stmt, argnum, asm_data);
114225 + break;
114226 + case GIMPLE_NOP: {
114227 + enum mark mark;
114228 + const char *str;
114229 +
114230 + mark = check_intentional_attribute_gimple(asm_data->output, stmt, argnum);
114231 + str = convert_mark_to_str(mark);
114232 +
114233 + asm_data->input = asm_data->output;
114234 + asm_data->output = NULL;
114235 + asm_data->def_stmt = stmt;
114236 +
114237 + create_asm_stmt(str, build_string(2, "rm"), NULL, asm_data);
114238 + asm_data->input = NULL_TREE;
114239 + break;
114240 + }
114241 + case GIMPLE_ASM:
114242 + if (is_size_overflow_asm(asm_data->def_stmt)) {
114243 + asm_data->input = NULL_TREE;
114244 + break;
114245 + }
114246 + default:
114247 + debug_gimple_stmt(asm_data->def_stmt);
114248 + gcc_unreachable();
114249 + }
114250 +}
114251 +
114252 +/* This is the gimple part of searching for a missing size_overflow attribute. If the intentional_overflow attribute type
114253 + * is of the right kind create the appropriate size_overflow asm stmts:
114254 + * __asm__("# size_overflow" : =rm" D.3344_8 : "0" cicus.4_16);
114255 + * __asm__("# size_overflow MARK_YES" : : "rm" size_1(D));
114256 + */
114257 +static void create_size_overflow_asm(gimple stmt, tree output_node, unsigned int argnum)
114258 +{
114259 + struct asm_data asm_data;
114260 + const char *str;
114261 + enum mark mark;
114262 +
114263 + if (is_gimple_constant(output_node))
114264 + return;
114265 +
114266 + asm_data.output = output_node;
114267 + mark = check_intentional_attribute_gimple(asm_data.output, stmt, argnum);
114268 + if (mark == MARK_TURN_OFF)
114269 + return;
114270 +
114271 + search_missing_size_overflow_attribute_gimple(stmt, argnum);
114272 +
114273 + asm_data.def_stmt = get_def_stmt(asm_data.output);
114274 + create_asm_input(stmt, argnum, &asm_data);
114275 + if (asm_data.input == NULL_TREE)
114276 + return;
114277 +
114278 + str = convert_mark_to_str(mark);
114279 + create_asm_stmt(str, build_string(1, "0"), build_string(3, "=rm"), &asm_data);
114280 +}
114281 +
114282 +// Determine the return value and insert the asm stmt to mark the return stmt.
114283 +static void insert_asm_ret(gimple stmt)
114284 +{
114285 + tree ret;
114286 +
114287 + ret = gimple_return_retval(stmt);
114288 + create_size_overflow_asm(stmt, ret, 0);
114289 +}
114290 +
114291 +// Determine the correct arg index and arg and insert the asm stmt to mark the stmt.
114292 +static void insert_asm_arg(gimple stmt, unsigned int orig_argnum)
114293 +{
114294 + tree arg;
114295 + unsigned int argnum;
114296 +
114297 + argnum = get_correct_arg_count(orig_argnum, gimple_call_fndecl(stmt));
114298 + gcc_assert(argnum != 0);
114299 + if (argnum == CANNOT_FIND_ARG)
114300 + return;
114301 +
114302 + arg = gimple_call_arg(stmt, argnum - 1);
114303 + gcc_assert(arg != NULL_TREE);
114304 + create_size_overflow_asm(stmt, arg, argnum);
114305 +}
114306 +
114307 +// If a function arg or the return value is marked by the size_overflow attribute then set its index in the array.
114308 +static void set_argnum_attribute(const_tree attr, bool *argnums)
114309 +{
114310 + unsigned int argnum;
114311 + tree attr_value;
114312 +
114313 + for (attr_value = TREE_VALUE(attr); attr_value; attr_value = TREE_CHAIN(attr_value)) {
114314 + argnum = TREE_INT_CST_LOW(TREE_VALUE(attr_value));
114315 + argnums[argnum] = true;
114316 + }
114317 +}
114318 +
114319 +// If a function arg or the return value is in the hash table then set its index in the array.
114320 +static void set_argnum_hash(tree fndecl, bool *argnums)
114321 +{
114322 + unsigned int num;
114323 + const struct size_overflow_hash *hash;
114324 +
114325 + hash = get_function_hash(DECL_ORIGIN(fndecl));
114326 + if (!hash)
114327 + return;
114328 +
114329 + for (num = 0; num <= MAX_PARAM; num++) {
114330 + if (!(hash->param & (1U << num)))
114331 + continue;
114332 +
114333 + argnums[num] = true;
114334 + }
114335 +}
114336 +
114337 +static bool is_all_the_argnums_empty(bool *argnums)
114338 +{
114339 + unsigned int i;
114340 +
114341 + for (i = 0; i <= MAX_PARAM; i++)
114342 + if (argnums[i])
114343 + return false;
114344 + return true;
114345 +}
114346 +
114347 +// Check whether the arguments or the return value of the function are in the hash table or are marked by the size_overflow attribute.
114348 +static void search_interesting_args(tree fndecl, bool *argnums)
114349 +{
114350 + const_tree attr;
114351 +
114352 + set_argnum_hash(fndecl, argnums);
114353 + if (!is_all_the_argnums_empty(argnums))
114354 + return;
114355 +
114356 + attr = lookup_attribute("size_overflow", DECL_ATTRIBUTES(fndecl));
114357 + if (attr && TREE_VALUE(attr))
114358 + set_argnum_attribute(attr, argnums);
114359 +}
114360 +
114361 +/*
114362 + * Look up the intentional_overflow attribute that turns off ipa based duplication
114363 + * on the callee function, if found insert an asm stmt with "MARK_TURN_OFF".
114364 + */
114365 +static bool create_mark_turn_off_asm(gimple stmt)
114366 +{
114367 + enum mark mark;
114368 + struct asm_data asm_data;
114369 + const_tree fndecl = gimple_call_fndecl(stmt);
114370 +
114371 + mark = get_intentional_attr_type(DECL_ORIGIN(fndecl));
114372 + if (mark != MARK_TURN_OFF)
114373 + return false;
114374 +
114375 + asm_data.def_stmt = stmt;
114376 + asm_data.output = gimple_call_lhs(stmt);
114377 +
114378 + if (asm_data.output == NULL_TREE) {
114379 + asm_data.input = gimple_call_arg(stmt, 0);
114380 + if (is_gimple_constant(asm_data.input))
114381 + return false;
114382 + asm_data.output = NULL;
114383 + create_asm_stmt(TURN_OFF_ASM_STR, build_string(2, "rm"), NULL, &asm_data);
114384 + return true;
114385 + }
114386 +
114387 + create_asm_input(stmt, 0, &asm_data);
114388 + gcc_assert(asm_data.input != NULL_TREE);
114389 +
114390 + create_asm_stmt(TURN_OFF_ASM_STR, build_string(1, "0"), build_string(3, "=rm"), &asm_data);
114391 + return true;
114392 +}
114393 +
114394 +// 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
114395 +static void handle_interesting_function(gimple stmt)
114396 +{
114397 + unsigned int argnum;
114398 + tree fndecl;
114399 + bool orig_argnums[MAX_PARAM + 1] = {false};
114400 +
114401 + if (gimple_call_num_args(stmt) == 0)
114402 + return;
114403 + fndecl = gimple_call_fndecl(stmt);
114404 + if (fndecl == NULL_TREE)
114405 + return;
114406 + fndecl = DECL_ORIGIN(fndecl);
114407 +
114408 + if (create_mark_turn_off_asm(stmt))
114409 + return;
114410 +
114411 + search_interesting_args(fndecl, orig_argnums);
114412 +
114413 + for (argnum = 1; argnum < MAX_PARAM; argnum++)
114414 + if (orig_argnums[argnum])
114415 + insert_asm_arg(stmt, argnum);
114416 +}
114417 +
114418 +// 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
114419 +static void handle_interesting_ret(gimple stmt)
114420 +{
114421 + bool orig_argnums[MAX_PARAM + 1] = {false};
114422 +
114423 + search_interesting_args(current_function_decl, orig_argnums);
114424 +
114425 + if (orig_argnums[0])
114426 + insert_asm_ret(stmt);
114427 +}
114428 +
114429 +// Iterate over all the stmts and search for call and return stmts and mark them if they're in the hash table
114430 +static unsigned int search_interesting_functions(void)
114431 +{
114432 + basic_block bb;
114433 +
114434 + FOR_ALL_BB(bb) {
114435 + gimple_stmt_iterator gsi;
114436 +
114437 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
114438 + gimple stmt = gsi_stmt(gsi);
114439 +
114440 + if (is_size_overflow_asm(stmt))
114441 + continue;
114442 +
114443 + if (is_gimple_call(stmt))
114444 + handle_interesting_function(stmt);
114445 + else if (gimple_code(stmt) == GIMPLE_RETURN)
114446 + handle_interesting_ret(stmt);
114447 + }
114448 + }
114449 + return 0;
114450 +}
114451 +
114452 +/*
114453 + * A lot of functions get inlined before the ipa passes so after the build_ssa gimple pass
114454 + * this pass inserts asm stmts to mark the interesting args
114455 + * that the ipa pass will detect and insert the size overflow checks for.
114456 + */
114457 +static struct gimple_opt_pass insert_size_overflow_asm_pass = {
114458 + .pass = {
114459 + .type = GIMPLE_PASS,
114460 + .name = "insert_size_overflow_asm",
114461 +#if BUILDING_GCC_VERSION >= 4008
114462 + .optinfo_flags = OPTGROUP_NONE,
114463 +#endif
114464 + .gate = NULL,
114465 + .execute = search_interesting_functions,
114466 + .sub = NULL,
114467 + .next = NULL,
114468 + .static_pass_number = 0,
114469 + .tv_id = TV_NONE,
114470 + .properties_required = PROP_cfg,
114471 + .properties_provided = 0,
114472 + .properties_destroyed = 0,
114473 + .todo_flags_start = 0,
114474 + .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
114475 + }
114476 +};
114477 +
114478 +// Create the noreturn report_size_overflow() function decl.
114479 +static void start_unit_callback(void __unused *gcc_data, void __unused *user_data)
114480 +{
114481 + tree fntype;
114482 +
114483 + const_char_ptr_type_node = build_pointer_type(build_type_variant(char_type_node, 1, 0));
114484 +
114485 + // void report_size_overflow(const char *loc_file, unsigned int loc_line, const char *current_func, const char *ssa_var)
114486 + fntype = build_function_type_list(void_type_node,
114487 + const_char_ptr_type_node,
114488 + unsigned_type_node,
114489 + const_char_ptr_type_node,
114490 + const_char_ptr_type_node,
114491 + NULL_TREE);
114492 + report_size_overflow_decl = build_fn_decl("report_size_overflow", fntype);
114493 +
114494 + DECL_ASSEMBLER_NAME(report_size_overflow_decl);
114495 + TREE_PUBLIC(report_size_overflow_decl) = 1;
114496 + DECL_EXTERNAL(report_size_overflow_decl) = 1;
114497 + DECL_ARTIFICIAL(report_size_overflow_decl) = 1;
114498 + TREE_THIS_VOLATILE(report_size_overflow_decl) = 1;
114499 +}
114500 +
114501 +static unsigned int dump_functions(void)
114502 +{
114503 + struct cgraph_node *node;
114504 +
114505 + FOR_EACH_FUNCTION_WITH_GIMPLE_BODY(node) {
114506 + basic_block bb;
114507 +
114508 +#if BUILDING_GCC_VERSION <= 4007
114509 + push_cfun(DECL_STRUCT_FUNCTION(node->decl));
114510 + current_function_decl = node->decl;
114511 +#else
114512 + push_cfun(DECL_STRUCT_FUNCTION(node->symbol.decl));
114513 + current_function_decl = node->symbol.decl;
114514 +#endif
114515 +
114516 + fprintf(stderr, "-----------------------------------------\n%s\n-----------------------------------------\n", NAME(current_function_decl));
114517 +
114518 + FOR_ALL_BB(bb) {
114519 + gimple_stmt_iterator si;
114520 +
114521 + fprintf(stderr, "<bb %u>:\n", bb->index);
114522 + for (si = gsi_start_phis(bb); !gsi_end_p(si); gsi_next(&si))
114523 + debug_gimple_stmt(gsi_stmt(si));
114524 + for (si = gsi_start_bb(bb); !gsi_end_p(si); gsi_next(&si))
114525 + debug_gimple_stmt(gsi_stmt(si));
114526 + fprintf(stderr, "\n");
114527 + }
114528 +
114529 + fprintf(stderr, "-------------------------------------------------------------------------\n");
114530 +
114531 + pop_cfun();
114532 + current_function_decl = NULL_TREE;
114533 + }
114534 +
114535 + fprintf(stderr, "###############################################################################\n");
114536 +
114537 + return 0;
114538 +}
114539 +
114540 +static struct ipa_opt_pass_d pass_dump = {
114541 + .pass = {
114542 + .type = SIMPLE_IPA_PASS,
114543 + .name = "dump",
114544 +#if BUILDING_GCC_VERSION >= 4008
114545 + .optinfo_flags = OPTGROUP_NONE,
114546 +#endif
114547 + .gate = NULL,
114548 + .execute = dump_functions,
114549 + .sub = NULL,
114550 + .next = NULL,
114551 + .static_pass_number = 0,
114552 + .tv_id = TV_NONE,
114553 + .properties_required = 0,
114554 + .properties_provided = 0,
114555 + .properties_destroyed = 0,
114556 + .todo_flags_start = 0,
114557 + .todo_flags_finish = 0,
114558 + },
114559 + .generate_summary = NULL,
114560 + .write_summary = NULL,
114561 + .read_summary = NULL,
114562 +#if BUILDING_GCC_VERSION >= 4006
114563 + .write_optimization_summary = NULL,
114564 + .read_optimization_summary = NULL,
114565 +#endif
114566 + .stmt_fixup = NULL,
114567 + .function_transform_todo_flags_start = 0,
114568 + .function_transform = NULL,
114569 + .variable_transform = NULL,
114570 +};
114571 +
114572 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
114573 +{
114574 + int i;
114575 + const char * const plugin_name = plugin_info->base_name;
114576 + const int argc = plugin_info->argc;
114577 + const struct plugin_argument * const argv = plugin_info->argv;
114578 + bool enable = true;
114579 +
114580 + struct register_pass_info insert_size_overflow_asm_pass_info = {
114581 + .pass = &insert_size_overflow_asm_pass.pass,
114582 + .reference_pass_name = "ssa",
114583 + .ref_pass_instance_number = 1,
114584 + .pos_op = PASS_POS_INSERT_AFTER
114585 + };
114586 +
114587 + struct register_pass_info __unused dump_before_pass_info = {
114588 + .pass = &pass_dump.pass,
114589 + .reference_pass_name = "increase_alignment",
114590 + .ref_pass_instance_number = 1,
114591 + .pos_op = PASS_POS_INSERT_BEFORE
114592 + };
114593 +
114594 + struct register_pass_info ipa_pass_info = {
114595 + .pass = &pass_ipa.pass,
114596 + .reference_pass_name = "increase_alignment",
114597 + .ref_pass_instance_number = 1,
114598 + .pos_op = PASS_POS_INSERT_BEFORE
114599 + };
114600 +
114601 + struct register_pass_info __unused dump_after_pass_info = {
114602 + .pass = &pass_dump.pass,
114603 + .reference_pass_name = "increase_alignment",
114604 + .ref_pass_instance_number = 1,
114605 + .pos_op = PASS_POS_INSERT_BEFORE
114606 + };
114607 +
114608 + if (!plugin_default_version_check(version, &gcc_version)) {
114609 + error(G_("incompatible gcc/plugin versions"));
114610 + return 1;
114611 + }
114612 +
114613 + for (i = 0; i < argc; ++i) {
114614 + if (!strcmp(argv[i].key, "no-size-overflow")) {
114615 + enable = false;
114616 + continue;
114617 + }
114618 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
114619 + }
114620 +
114621 + register_callback(plugin_name, PLUGIN_INFO, NULL, &size_overflow_plugin_info);
114622 + if (enable) {
114623 + register_callback("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
114624 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &insert_size_overflow_asm_pass_info);
114625 +// register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &dump_before_pass_info);
114626 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &ipa_pass_info);
114627 +// register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &dump_after_pass_info);
114628 + }
114629 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
114630 +
114631 + return 0;
114632 +}
114633 diff --git a/tools/gcc/stackleak_plugin.c b/tools/gcc/stackleak_plugin.c
114634 new file mode 100644
114635 index 0000000..ac2901e
114636 --- /dev/null
114637 +++ b/tools/gcc/stackleak_plugin.c
114638 @@ -0,0 +1,327 @@
114639 +/*
114640 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
114641 + * Licensed under the GPL v2
114642 + *
114643 + * Note: the choice of the license means that the compilation process is
114644 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
114645 + * but for the kernel it doesn't matter since it doesn't link against
114646 + * any of the gcc libraries
114647 + *
114648 + * gcc plugin to help implement various PaX features
114649 + *
114650 + * - track lowest stack pointer
114651 + *
114652 + * TODO:
114653 + * - initialize all local variables
114654 + *
114655 + * BUGS:
114656 + * - none known
114657 + */
114658 +#include "gcc-plugin.h"
114659 +#include "config.h"
114660 +#include "system.h"
114661 +#include "coretypes.h"
114662 +#include "tree.h"
114663 +#include "tree-pass.h"
114664 +#include "flags.h"
114665 +#include "intl.h"
114666 +#include "toplev.h"
114667 +#include "plugin.h"
114668 +//#include "expr.h" where are you...
114669 +#include "diagnostic.h"
114670 +#include "plugin-version.h"
114671 +#include "tm.h"
114672 +#include "function.h"
114673 +#include "basic-block.h"
114674 +#include "gimple.h"
114675 +#include "rtl.h"
114676 +#include "emit-rtl.h"
114677 +
114678 +#if BUILDING_GCC_VERSION >= 4008
114679 +#define TODO_dump_func 0
114680 +#endif
114681 +
114682 +extern void print_gimple_stmt(FILE *, gimple, int, int);
114683 +
114684 +int plugin_is_GPL_compatible;
114685 +
114686 +static int track_frame_size = -1;
114687 +static const char track_function[] = "pax_track_stack";
114688 +static const char check_function[] = "pax_check_alloca";
114689 +static bool init_locals;
114690 +
114691 +static struct plugin_info stackleak_plugin_info = {
114692 + .version = "201302112000",
114693 + .help = "track-lowest-sp=nn\ttrack sp in functions whose frame size is at least nn bytes\n"
114694 +// "initialize-locals\t\tforcibly initialize all stack frames\n"
114695 +};
114696 +
114697 +static bool gate_stackleak_track_stack(void);
114698 +static unsigned int execute_stackleak_tree_instrument(void);
114699 +static unsigned int execute_stackleak_final(void);
114700 +
114701 +static struct gimple_opt_pass stackleak_tree_instrument_pass = {
114702 + .pass = {
114703 + .type = GIMPLE_PASS,
114704 + .name = "stackleak_tree_instrument",
114705 +#if BUILDING_GCC_VERSION >= 4008
114706 + .optinfo_flags = OPTGROUP_NONE,
114707 +#endif
114708 + .gate = gate_stackleak_track_stack,
114709 + .execute = execute_stackleak_tree_instrument,
114710 + .sub = NULL,
114711 + .next = NULL,
114712 + .static_pass_number = 0,
114713 + .tv_id = TV_NONE,
114714 + .properties_required = PROP_gimple_leh | PROP_cfg,
114715 + .properties_provided = 0,
114716 + .properties_destroyed = 0,
114717 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
114718 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
114719 + }
114720 +};
114721 +
114722 +static struct rtl_opt_pass stackleak_final_rtl_opt_pass = {
114723 + .pass = {
114724 + .type = RTL_PASS,
114725 + .name = "stackleak_final",
114726 +#if BUILDING_GCC_VERSION >= 4008
114727 + .optinfo_flags = OPTGROUP_NONE,
114728 +#endif
114729 + .gate = gate_stackleak_track_stack,
114730 + .execute = execute_stackleak_final,
114731 + .sub = NULL,
114732 + .next = NULL,
114733 + .static_pass_number = 0,
114734 + .tv_id = TV_NONE,
114735 + .properties_required = 0,
114736 + .properties_provided = 0,
114737 + .properties_destroyed = 0,
114738 + .todo_flags_start = 0,
114739 + .todo_flags_finish = TODO_dump_func
114740 + }
114741 +};
114742 +
114743 +static bool gate_stackleak_track_stack(void)
114744 +{
114745 + return track_frame_size >= 0;
114746 +}
114747 +
114748 +static void stackleak_check_alloca(gimple_stmt_iterator *gsi)
114749 +{
114750 + gimple check_alloca;
114751 + tree fntype, fndecl, alloca_size;
114752 +
114753 + fntype = build_function_type_list(void_type_node, long_unsigned_type_node, NULL_TREE);
114754 + fndecl = build_fn_decl(check_function, fntype);
114755 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
114756 +
114757 + // insert call to void pax_check_alloca(unsigned long size)
114758 + alloca_size = gimple_call_arg(gsi_stmt(*gsi), 0);
114759 + check_alloca = gimple_build_call(fndecl, 1, alloca_size);
114760 + gsi_insert_before(gsi, check_alloca, GSI_SAME_STMT);
114761 +}
114762 +
114763 +static void stackleak_add_instrumentation(gimple_stmt_iterator *gsi)
114764 +{
114765 + gimple track_stack;
114766 + tree fntype, fndecl;
114767 +
114768 + fntype = build_function_type_list(void_type_node, NULL_TREE);
114769 + fndecl = build_fn_decl(track_function, fntype);
114770 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
114771 +
114772 + // insert call to void pax_track_stack(void)
114773 + track_stack = gimple_build_call(fndecl, 0);
114774 + gsi_insert_after(gsi, track_stack, GSI_CONTINUE_LINKING);
114775 +}
114776 +
114777 +#if BUILDING_GCC_VERSION == 4005
114778 +static bool gimple_call_builtin_p(gimple stmt, enum built_in_function code)
114779 +{
114780 + tree fndecl;
114781 +
114782 + if (!is_gimple_call(stmt))
114783 + return false;
114784 + fndecl = gimple_call_fndecl(stmt);
114785 + if (!fndecl)
114786 + return false;
114787 + if (DECL_BUILT_IN_CLASS(fndecl) != BUILT_IN_NORMAL)
114788 + return false;
114789 +// print_node(stderr, "pax", fndecl, 4);
114790 + return DECL_FUNCTION_CODE(fndecl) == code;
114791 +}
114792 +#endif
114793 +
114794 +static bool is_alloca(gimple stmt)
114795 +{
114796 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA))
114797 + return true;
114798 +
114799 +#if BUILDING_GCC_VERSION >= 4007
114800 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA_WITH_ALIGN))
114801 + return true;
114802 +#endif
114803 +
114804 + return false;
114805 +}
114806 +
114807 +static unsigned int execute_stackleak_tree_instrument(void)
114808 +{
114809 + basic_block bb, entry_bb;
114810 + bool prologue_instrumented = false, is_leaf = true;
114811 +
114812 + entry_bb = ENTRY_BLOCK_PTR_FOR_FUNCTION(cfun)->next_bb;
114813 +
114814 + // 1. loop through BBs and GIMPLE statements
114815 + FOR_EACH_BB(bb) {
114816 + gimple_stmt_iterator gsi;
114817 +
114818 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
114819 + gimple stmt;
114820 +
114821 + stmt = gsi_stmt(gsi);
114822 +
114823 + if (is_gimple_call(stmt))
114824 + is_leaf = false;
114825 +
114826 + // gimple match: align 8 built-in BUILT_IN_NORMAL:BUILT_IN_ALLOCA attributes <tree_list 0xb7576450>
114827 + if (!is_alloca(stmt))
114828 + continue;
114829 +
114830 + // 2. insert stack overflow check before each __builtin_alloca call
114831 + stackleak_check_alloca(&gsi);
114832 +
114833 + // 3. insert track call after each __builtin_alloca call
114834 + stackleak_add_instrumentation(&gsi);
114835 + if (bb == entry_bb)
114836 + prologue_instrumented = true;
114837 + }
114838 + }
114839 +
114840 + // special cases for some bad linux code: taking the address of static inline functions will materialize them
114841 + // but we mustn't instrument some of them as the resulting stack alignment required by the function call ABI
114842 + // will break other assumptions regarding the expected (but not otherwise enforced) register clobbering ABI.
114843 + // case in point: native_save_fl on amd64 when optimized for size clobbers rdx if it were instrumented here.
114844 + if (is_leaf && !TREE_PUBLIC(current_function_decl) && DECL_DECLARED_INLINE_P(current_function_decl))
114845 + return 0;
114846 + if (is_leaf && !strncmp(IDENTIFIER_POINTER(DECL_NAME(current_function_decl)), "_paravirt_", 10))
114847 + return 0;
114848 +
114849 + // 4. insert track call at the beginning
114850 + if (!prologue_instrumented) {
114851 + gimple_stmt_iterator gsi;
114852 +
114853 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
114854 + if (dom_info_available_p(CDI_DOMINATORS))
114855 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
114856 + gsi = gsi_start_bb(bb);
114857 + stackleak_add_instrumentation(&gsi);
114858 + }
114859 +
114860 + return 0;
114861 +}
114862 +
114863 +static unsigned int execute_stackleak_final(void)
114864 +{
114865 + rtx insn, next;
114866 +
114867 + if (cfun->calls_alloca)
114868 + return 0;
114869 +
114870 + // keep calls only if function frame is big enough
114871 + if (get_frame_size() >= track_frame_size)
114872 + return 0;
114873 +
114874 + // 1. find pax_track_stack calls
114875 + for (insn = get_insns(); insn; insn = next) {
114876 + // 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))
114877 + rtx body;
114878 +
114879 + next = NEXT_INSN(insn);
114880 + if (!CALL_P(insn))
114881 + continue;
114882 + body = PATTERN(insn);
114883 + if (GET_CODE(body) != CALL)
114884 + continue;
114885 + body = XEXP(body, 0);
114886 + if (GET_CODE(body) != MEM)
114887 + continue;
114888 + body = XEXP(body, 0);
114889 + if (GET_CODE(body) != SYMBOL_REF)
114890 + continue;
114891 + if (strcmp(XSTR(body, 0), track_function))
114892 + continue;
114893 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
114894 + // 2. delete call
114895 + delete_insn_and_edges(insn);
114896 +#if BUILDING_GCC_VERSION >= 4007
114897 + if (GET_CODE(next) == NOTE && NOTE_KIND(next) == NOTE_INSN_CALL_ARG_LOCATION) {
114898 + insn = next;
114899 + next = NEXT_INSN(insn);
114900 + delete_insn_and_edges(insn);
114901 + }
114902 +#endif
114903 + }
114904 +
114905 +// print_simple_rtl(stderr, get_insns());
114906 +// print_rtl(stderr, get_insns());
114907 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
114908 +
114909 + return 0;
114910 +}
114911 +
114912 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
114913 +{
114914 + const char * const plugin_name = plugin_info->base_name;
114915 + const int argc = plugin_info->argc;
114916 + const struct plugin_argument * const argv = plugin_info->argv;
114917 + int i;
114918 + struct register_pass_info stackleak_tree_instrument_pass_info = {
114919 + .pass = &stackleak_tree_instrument_pass.pass,
114920 +// .reference_pass_name = "tree_profile",
114921 + .reference_pass_name = "optimized",
114922 + .ref_pass_instance_number = 1,
114923 + .pos_op = PASS_POS_INSERT_BEFORE
114924 + };
114925 + struct register_pass_info stackleak_final_pass_info = {
114926 + .pass = &stackleak_final_rtl_opt_pass.pass,
114927 + .reference_pass_name = "final",
114928 + .ref_pass_instance_number = 1,
114929 + .pos_op = PASS_POS_INSERT_BEFORE
114930 + };
114931 +
114932 + if (!plugin_default_version_check(version, &gcc_version)) {
114933 + error(G_("incompatible gcc/plugin versions"));
114934 + return 1;
114935 + }
114936 +
114937 + register_callback(plugin_name, PLUGIN_INFO, NULL, &stackleak_plugin_info);
114938 +
114939 + for (i = 0; i < argc; ++i) {
114940 + if (!strcmp(argv[i].key, "track-lowest-sp")) {
114941 + if (!argv[i].value) {
114942 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
114943 + continue;
114944 + }
114945 + track_frame_size = atoi(argv[i].value);
114946 + if (argv[i].value[0] < '0' || argv[i].value[0] > '9' || track_frame_size < 0)
114947 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
114948 + continue;
114949 + }
114950 + if (!strcmp(argv[i].key, "initialize-locals")) {
114951 + if (argv[i].value) {
114952 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
114953 + continue;
114954 + }
114955 + init_locals = true;
114956 + continue;
114957 + }
114958 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
114959 + }
114960 +
114961 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_tree_instrument_pass_info);
114962 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_final_pass_info);
114963 +
114964 + return 0;
114965 +}
114966 diff --git a/tools/gcc/structleak_plugin.c b/tools/gcc/structleak_plugin.c
114967 new file mode 100644
114968 index 0000000..4fae911
114969 --- /dev/null
114970 +++ b/tools/gcc/structleak_plugin.c
114971 @@ -0,0 +1,277 @@
114972 +/*
114973 + * Copyright 2013 by PaX Team <pageexec@freemail.hu>
114974 + * Licensed under the GPL v2
114975 + *
114976 + * Note: the choice of the license means that the compilation process is
114977 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
114978 + * but for the kernel it doesn't matter since it doesn't link against
114979 + * any of the gcc libraries
114980 + *
114981 + * gcc plugin to forcibly initialize certain local variables that could
114982 + * otherwise leak kernel stack to userland if they aren't properly initialized
114983 + * by later code
114984 + *
114985 + * Homepage: http://pax.grsecurity.net/
114986 + *
114987 + * Usage:
114988 + * $ # for 4.5/4.6/C based 4.7
114989 + * $ 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
114990 + * $ # for C++ based 4.7/4.8+
114991 + * $ 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
114992 + * $ gcc -fplugin=./structleak_plugin.so test.c -O2
114993 + *
114994 + * TODO: eliminate redundant initializers
114995 + * increase type coverage
114996 + */
114997 +
114998 +#include "gcc-plugin.h"
114999 +#include "config.h"
115000 +#include "system.h"
115001 +#include "coretypes.h"
115002 +#include "tree.h"
115003 +#include "tree-pass.h"
115004 +#include "intl.h"
115005 +#include "plugin-version.h"
115006 +#include "tm.h"
115007 +#include "toplev.h"
115008 +#include "function.h"
115009 +#include "tree-flow.h"
115010 +#include "plugin.h"
115011 +#include "gimple.h"
115012 +#include "diagnostic.h"
115013 +#include "cfgloop.h"
115014 +#include "langhooks.h"
115015 +
115016 +#if BUILDING_GCC_VERSION >= 4008
115017 +#define TODO_dump_func 0
115018 +#endif
115019 +
115020 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
115021 +
115022 +// unused type flag in all versions 4.5-4.8
115023 +#define TYPE_USERSPACE(TYPE) TYPE_LANG_FLAG_3(TYPE)
115024 +
115025 +int plugin_is_GPL_compatible;
115026 +void debug_gimple_stmt(gimple gs);
115027 +
115028 +static struct plugin_info structleak_plugin_info = {
115029 + .version = "201304082245",
115030 + .help = "disable\tdo not activate plugin\n",
115031 +};
115032 +
115033 +static tree handle_user_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
115034 +{
115035 + *no_add_attrs = true;
115036 +
115037 + // check for types? for now accept everything linux has to offer
115038 + if (TREE_CODE(*node) != FIELD_DECL)
115039 + return NULL_TREE;
115040 +
115041 + *no_add_attrs = false;
115042 + return NULL_TREE;
115043 +}
115044 +
115045 +static struct attribute_spec user_attr = {
115046 + .name = "user",
115047 + .min_length = 0,
115048 + .max_length = 0,
115049 + .decl_required = false,
115050 + .type_required = false,
115051 + .function_type_required = false,
115052 + .handler = handle_user_attribute,
115053 +#if BUILDING_GCC_VERSION >= 4007
115054 + .affects_type_identity = true
115055 +#endif
115056 +};
115057 +
115058 +static void register_attributes(void *event_data, void *data)
115059 +{
115060 + register_attribute(&user_attr);
115061 +// register_attribute(&force_attr);
115062 +}
115063 +
115064 +static tree get_field_type(tree field)
115065 +{
115066 + return strip_array_types(TREE_TYPE(field));
115067 +}
115068 +
115069 +static bool is_userspace_type(tree type)
115070 +{
115071 + tree field;
115072 +
115073 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
115074 + tree fieldtype = get_field_type(field);
115075 + enum tree_code code = TREE_CODE(fieldtype);
115076 +
115077 + if (code == RECORD_TYPE || code == UNION_TYPE)
115078 + if (is_userspace_type(fieldtype))
115079 + return true;
115080 +
115081 + if (lookup_attribute("user", DECL_ATTRIBUTES(field)))
115082 + return true;
115083 + }
115084 + return false;
115085 +}
115086 +
115087 +static void finish_type(void *event_data, void *data)
115088 +{
115089 + tree type = (tree)event_data;
115090 +
115091 + if (TYPE_USERSPACE(type))
115092 + return;
115093 +
115094 + if (is_userspace_type(type))
115095 + TYPE_USERSPACE(type) = 1;
115096 +}
115097 +
115098 +static void initialize(tree var)
115099 +{
115100 + basic_block bb;
115101 + gimple_stmt_iterator gsi;
115102 + tree initializer;
115103 + gimple init_stmt;
115104 +
115105 + // this is the original entry bb before the forced split
115106 + // TODO: check further BBs in case more splits occured before us
115107 + bb = ENTRY_BLOCK_PTR->next_bb->next_bb;
115108 +
115109 + // first check if the variable is already initialized, warn otherwise
115110 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
115111 + gimple stmt = gsi_stmt(gsi);
115112 + tree rhs1;
115113 +
115114 + // we're looking for an assignment of a single rhs...
115115 + if (!gimple_assign_single_p(stmt))
115116 + continue;
115117 + rhs1 = gimple_assign_rhs1(stmt);
115118 +#if BUILDING_GCC_VERSION >= 4007
115119 + // ... of a non-clobbering expression...
115120 + if (TREE_CLOBBER_P(rhs1))
115121 + continue;
115122 +#endif
115123 + // ... to our variable...
115124 + if (gimple_get_lhs(stmt) != var)
115125 + continue;
115126 + // if it's an initializer then we're good
115127 + if (TREE_CODE(rhs1) == CONSTRUCTOR)
115128 + return;
115129 + }
115130 +
115131 + // these aren't the 0days you're looking for
115132 +// inform(DECL_SOURCE_LOCATION(var), "userspace variable will be forcibly initialized");
115133 +
115134 + // build the initializer expression
115135 + initializer = build_constructor(TREE_TYPE(var), NULL);
115136 +
115137 + // build the initializer stmt
115138 + init_stmt = gimple_build_assign(var, initializer);
115139 + gsi = gsi_start_bb(ENTRY_BLOCK_PTR->next_bb);
115140 + gsi_insert_before(&gsi, init_stmt, GSI_NEW_STMT);
115141 + update_stmt(init_stmt);
115142 +}
115143 +
115144 +static unsigned int handle_function(void)
115145 +{
115146 + basic_block bb;
115147 + unsigned int ret = 0;
115148 + tree var;
115149 +
115150 +#if BUILDING_GCC_VERSION == 4005
115151 + tree vars;
115152 +#else
115153 + unsigned int i;
115154 +#endif
115155 +
115156 + // split the first bb where we can put the forced initializers
115157 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
115158 + if (dom_info_available_p(CDI_DOMINATORS))
115159 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
115160 +
115161 + // enumarate all local variables and forcibly initialize our targets
115162 +#if BUILDING_GCC_VERSION == 4005
115163 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
115164 + var = TREE_VALUE(vars);
115165 +#else
115166 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
115167 +#endif
115168 + tree type = TREE_TYPE(var);
115169 +
115170 + gcc_assert(DECL_P(var));
115171 + if (!auto_var_in_fn_p(var, current_function_decl))
115172 + continue;
115173 +
115174 + // only care about structure types
115175 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
115176 + continue;
115177 +
115178 + // if the type is of interest, examine the variable
115179 + if (TYPE_USERSPACE(type))
115180 + initialize(var);
115181 + }
115182 +
115183 + return ret;
115184 +}
115185 +
115186 +static struct gimple_opt_pass structleak_pass = {
115187 + .pass = {
115188 + .type = GIMPLE_PASS,
115189 + .name = "structleak",
115190 +#if BUILDING_GCC_VERSION >= 4008
115191 + .optinfo_flags = OPTGROUP_NONE,
115192 +#endif
115193 + .gate = NULL,
115194 + .execute = handle_function,
115195 + .sub = NULL,
115196 + .next = NULL,
115197 + .static_pass_number = 0,
115198 + .tv_id = TV_NONE,
115199 + .properties_required = PROP_cfg,
115200 + .properties_provided = 0,
115201 + .properties_destroyed = 0,
115202 + .todo_flags_start = 0,
115203 + .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
115204 + }
115205 +};
115206 +
115207 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
115208 +{
115209 + int i;
115210 + const char * const plugin_name = plugin_info->base_name;
115211 + const int argc = plugin_info->argc;
115212 + const struct plugin_argument * const argv = plugin_info->argv;
115213 + bool enable = true;
115214 +
115215 + struct register_pass_info structleak_pass_info = {
115216 + .pass = &structleak_pass.pass,
115217 + .reference_pass_name = "ssa",
115218 + .ref_pass_instance_number = 1,
115219 + .pos_op = PASS_POS_INSERT_AFTER
115220 + };
115221 +
115222 + if (!plugin_default_version_check(version, &gcc_version)) {
115223 + error(G_("incompatible gcc/plugin versions"));
115224 + return 1;
115225 + }
115226 +
115227 + if (strcmp(lang_hooks.name, "GNU C")) {
115228 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
115229 + enable = false;
115230 + }
115231 +
115232 + for (i = 0; i < argc; ++i) {
115233 + if (!strcmp(argv[i].key, "disable")) {
115234 + enable = false;
115235 + continue;
115236 + }
115237 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
115238 + }
115239 +
115240 + register_callback(plugin_name, PLUGIN_INFO, NULL, &structleak_plugin_info);
115241 + if (enable) {
115242 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &structleak_pass_info);
115243 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
115244 + }
115245 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
115246 +
115247 + return 0;
115248 +}
115249 diff --git a/tools/lib/lk/Makefile b/tools/lib/lk/Makefile
115250 index 3dba0a4..97175dc 100644
115251 --- a/tools/lib/lk/Makefile
115252 +++ b/tools/lib/lk/Makefile
115253 @@ -13,7 +13,7 @@ LIB_OBJS += $(OUTPUT)debugfs.o
115254
115255 LIBFILE = liblk.a
115256
115257 -CFLAGS = -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) -fPIC
115258 +CFLAGS = -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) -fPIC
115259 EXTLIBS = -lelf -lpthread -lrt -lm
115260 ALL_CFLAGS = $(CFLAGS) $(BASIC_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
115261 ALL_LDFLAGS = $(LDFLAGS)
115262 diff --git a/tools/perf/util/include/asm/alternative-asm.h b/tools/perf/util/include/asm/alternative-asm.h
115263 index 6789d78..4afd019e 100644
115264 --- a/tools/perf/util/include/asm/alternative-asm.h
115265 +++ b/tools/perf/util/include/asm/alternative-asm.h
115266 @@ -5,4 +5,7 @@
115267
115268 #define altinstruction_entry #
115269
115270 + .macro pax_force_retaddr rip=0, reload=0
115271 + .endm
115272 +
115273 #endif
115274 diff --git a/tools/perf/util/include/linux/compiler.h b/tools/perf/util/include/linux/compiler.h
115275 index 96b919d..c49bb74 100644
115276 --- a/tools/perf/util/include/linux/compiler.h
115277 +++ b/tools/perf/util/include/linux/compiler.h
115278 @@ -18,4 +18,12 @@
115279 #define __force
115280 #endif
115281
115282 +#ifndef __size_overflow
115283 +# define __size_overflow(...)
115284 +#endif
115285 +
115286 +#ifndef __intentional_overflow
115287 +# define __intentional_overflow(...)
115288 +#endif
115289 +
115290 #endif
115291 diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
115292 index aac732d..bc87a5d 100644
115293 --- a/virt/kvm/kvm_main.c
115294 +++ b/virt/kvm/kvm_main.c
115295 @@ -75,12 +75,17 @@ LIST_HEAD(vm_list);
115296
115297 static cpumask_var_t cpus_hardware_enabled;
115298 static int kvm_usage_count = 0;
115299 -static atomic_t hardware_enable_failed;
115300 +static atomic_unchecked_t hardware_enable_failed;
115301
115302 struct kmem_cache *kvm_vcpu_cache;
115303 EXPORT_SYMBOL_GPL(kvm_vcpu_cache);
115304
115305 -static __read_mostly struct preempt_ops kvm_preempt_ops;
115306 +static void kvm_sched_in(struct preempt_notifier *pn, int cpu);
115307 +static void kvm_sched_out(struct preempt_notifier *pn, struct task_struct *next);
115308 +static struct preempt_ops kvm_preempt_ops = {
115309 + .sched_in = kvm_sched_in,
115310 + .sched_out = kvm_sched_out,
115311 +};
115312
115313 struct dentry *kvm_debugfs_dir;
115314
115315 @@ -749,7 +754,7 @@ int __kvm_set_memory_region(struct kvm *kvm,
115316 /* We can read the guest memory with __xxx_user() later on. */
115317 if ((mem->slot < KVM_USER_MEM_SLOTS) &&
115318 ((mem->userspace_addr & (PAGE_SIZE - 1)) ||
115319 - !access_ok(VERIFY_WRITE,
115320 + !__access_ok(VERIFY_WRITE,
115321 (void __user *)(unsigned long)mem->userspace_addr,
115322 mem->memory_size)))
115323 goto out;
115324 @@ -1613,8 +1618,17 @@ EXPORT_SYMBOL_GPL(kvm_read_guest_cached);
115325
115326 int kvm_clear_guest_page(struct kvm *kvm, gfn_t gfn, int offset, int len)
115327 {
115328 - return kvm_write_guest_page(kvm, gfn, (const void *) empty_zero_page,
115329 - offset, len);
115330 + int r;
115331 + unsigned long addr;
115332 +
115333 + addr = gfn_to_hva(kvm, gfn);
115334 + if (kvm_is_error_hva(addr))
115335 + return -EFAULT;
115336 + r = __clear_user((void __user *)addr + offset, len);
115337 + if (r)
115338 + return -EFAULT;
115339 + mark_page_dirty(kvm, gfn);
115340 + return 0;
115341 }
115342 EXPORT_SYMBOL_GPL(kvm_clear_guest_page);
115343
115344 @@ -1867,7 +1881,7 @@ static int kvm_vcpu_release(struct inode *inode, struct file *filp)
115345 return 0;
115346 }
115347
115348 -static struct file_operations kvm_vcpu_fops = {
115349 +static file_operations_no_const kvm_vcpu_fops __read_only = {
115350 .release = kvm_vcpu_release,
115351 .unlocked_ioctl = kvm_vcpu_ioctl,
115352 #ifdef CONFIG_COMPAT
115353 @@ -2553,7 +2567,7 @@ static int kvm_vm_mmap(struct file *file, struct vm_area_struct *vma)
115354 return 0;
115355 }
115356
115357 -static struct file_operations kvm_vm_fops = {
115358 +static file_operations_no_const kvm_vm_fops __read_only = {
115359 .release = kvm_vm_release,
115360 .unlocked_ioctl = kvm_vm_ioctl,
115361 #ifdef CONFIG_COMPAT
115362 @@ -2654,7 +2668,7 @@ out:
115363 return r;
115364 }
115365
115366 -static struct file_operations kvm_chardev_ops = {
115367 +static file_operations_no_const kvm_chardev_ops __read_only = {
115368 .unlocked_ioctl = kvm_dev_ioctl,
115369 .compat_ioctl = kvm_dev_ioctl,
115370 .llseek = noop_llseek,
115371 @@ -2680,7 +2694,7 @@ static void hardware_enable_nolock(void *junk)
115372
115373 if (r) {
115374 cpumask_clear_cpu(cpu, cpus_hardware_enabled);
115375 - atomic_inc(&hardware_enable_failed);
115376 + atomic_inc_unchecked(&hardware_enable_failed);
115377 printk(KERN_INFO "kvm: enabling virtualization on "
115378 "CPU%d failed\n", cpu);
115379 }
115380 @@ -2734,10 +2748,10 @@ static int hardware_enable_all(void)
115381
115382 kvm_usage_count++;
115383 if (kvm_usage_count == 1) {
115384 - atomic_set(&hardware_enable_failed, 0);
115385 + atomic_set_unchecked(&hardware_enable_failed, 0);
115386 on_each_cpu(hardware_enable_nolock, NULL, 1);
115387
115388 - if (atomic_read(&hardware_enable_failed)) {
115389 + if (atomic_read_unchecked(&hardware_enable_failed)) {
115390 hardware_disable_all_nolock();
115391 r = -EBUSY;
115392 }
115393 @@ -3171,7 +3185,7 @@ static void kvm_sched_out(struct preempt_notifier *pn,
115394 kvm_arch_vcpu_put(vcpu);
115395 }
115396
115397 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
115398 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
115399 struct module *module)
115400 {
115401 int r;
115402 @@ -3218,7 +3232,7 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
115403 if (!vcpu_align)
115404 vcpu_align = __alignof__(struct kvm_vcpu);
115405 kvm_vcpu_cache = kmem_cache_create("kvm_vcpu", vcpu_size, vcpu_align,
115406 - 0, NULL);
115407 + SLAB_USERCOPY, NULL);
115408 if (!kvm_vcpu_cache) {
115409 r = -ENOMEM;
115410 goto out_free_3;
115411 @@ -3228,9 +3242,11 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
115412 if (r)
115413 goto out_free;
115414
115415 + pax_open_kernel();
115416 kvm_chardev_ops.owner = module;
115417 kvm_vm_fops.owner = module;
115418 kvm_vcpu_fops.owner = module;
115419 + pax_close_kernel();
115420
115421 r = misc_register(&kvm_dev);
115422 if (r) {
115423 @@ -3240,9 +3256,6 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
115424
115425 register_syscore_ops(&kvm_syscore_ops);
115426
115427 - kvm_preempt_ops.sched_in = kvm_sched_in;
115428 - kvm_preempt_ops.sched_out = kvm_sched_out;
115429 -
115430 r = kvm_init_debug();
115431 if (r) {
115432 printk(KERN_ERR "kvm: create debugfs files failed\n");